- Main Page
- Packages
- Classes
- Files

- File List
- File Members

# D:/guillaume/guillara/3D/DXGfx/DXGfxLib/DXGfxManager.cs

Go to the documentation of this file.

    00001 //BSD License
    00002 //DXGfx® - http://www.eteractions.com
    00003 //Copyright (c) 2005
    00004 //by Guillaume Randon
    00005 //Permission is hereby granted, free of charge, to any person obtaining a copy of this software
    00006 //and associated documentation files (the "Software"), to deal in the Software without restriction,
    00007 //including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
    00008 //and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
    00009 //subject to the following conditions:
    00010 //The above copyright notice and this permission notice shall be included in all copies or substantial
    00011 //portions of the Software.
    00012 //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
    00013 //INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
    00014 //AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
    00015 //DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    00016 //OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    00017 using System;
    00018 using System.Collections;
    00019 using System.Collections.Generic;
    00020 using System.Collections.Specialized;
    00021 using System.Text;
    00022 using System.IO;
    00023 using System.Drawing;
    00024 using System.Diagnostics;
    00025 using System.Reflection;
    00026 using Microsoft.DirectX;
    00027 using Microsoft.DirectX.Direct3D;
    00028 using Microsoft.Samples.DirectX.UtilityToolkit;
    00029 using System.Xml;
    00030 using System.Windows.Forms;
    00031
    00032 namespace DXGfxLib
    00033 {
    00038     public class DXGfxManager
    00039     {
    00046         public int height = 640;
    00053         public int width = 480;
    00054
    00058         public Framework frameworkInUse;
    00059
    00063         public Device d3dDevice;
    00064
    00065         public SurfaceDescription backBufferDescription;
    00066
    00070         public EffectGroup defaultEffectGroup = null;
    00071
    00075         public string defaultEffectGroupBaseFile = "base.fx";
    00076
    00083         public bool cullNodes = true;
    00084
    00089         public ScriptManager scriptManager = null;
    00090
    00094         public DXGfxLib.Serialization.Manager serializationManager = null;
    00095
    00099         public string currentSceneName = "Default Scene";
    00100
    00108         private OutDoorScene outdoorScene = null;
    00109
    00113         public string sceneFile;
    00114
    00118         public string mediaFolderPath;
    00119
    00123         private string skyFile;
    00124
    00128         private string waterFile;
    00129
    00133         private string heigthMapFile;
    00134
    00135         //private ShaderFlags shaderFlags = ShaderFlags.Debug | ShaderFlags.SkipOptimization;
    00136         private ShaderFlags shaderFlags = ShaderFlags.NoPreShader;
    00137
    00138         public Avatar CurrentAvatar
    00139         {
    00140             get
    00141             {
    00142                 if (outdoorScene == null)
    00143                     return null;
    00144                 return outdoorScene.CurrentAvatar;
    00145             }
    00146             set
    00147             {
    00148                 if (outdoorScene == null)
    00149                     return;
    00150                 outdoorScene.CurrentAvatar = value;
    00151             }
    00152         }
    00153
    00154         public ThirdPersonCamera CurrentCamera
    00155         {
    00156             get
    00157             {
    00158                 if (outdoorScene == null)
    00159                     return null;
    00160                 return outdoorScene.CurrentCamera;
    00161             }
    00162             set
    00163             {
    00164                 if (outdoorScene == null)
    00165                     return;
    00166                 outdoorScene.CurrentCamera = value;
    00167             }
    00168         }
    00169
    00170         public Matrix MatView
    00171         {
    00172             get
    00173             {
    00174                 if (outdoorScene == null)
    00175                     return Matrix.Identity;
    00176                 return outdoorScene.matView;
    00177             }
    00178             set
    00179             {
    00180                 if (outdoorScene == null)
    00181                     return;
    00182                 outdoorScene.matView = value;
    00183             }
    00184         }
    00185
    00186         public Matrix MatProj
    00187         {
    00188             get
    00189             {
    00190                 if (outdoorScene == null)
    00191                     return Matrix.Identity;
    00192                 return outdoorScene.matProj;
    00193             }
    00194             set
    00195             {
    00196                 if (outdoorScene == null)
    00197                     return;
    00198                 outdoorScene.matProj = value;
    00199             }
    00200         }
    00201
    00202         public IInputHandler CurrentInputHandler
    00203         {
    00204             get
    00205             {
    00206                 if (outdoorScene == null)
    00207                     return null;
    00208                 return outdoorScene.CurrentInputHandler;
    00209             }
    00210             set
    00211             {
    00212                 if (outdoorScene == null)
    00213                     return;
    00214                 outdoorScene.CurrentInputHandler = value;
    00215             }
    00216         }
    00217
    00218         private static DXGfxManager globalInstance = null;
    00219
    00224         public DXGfxManager()
    00225         {
    00226             if (globalInstance == null)
    00227             {
    00228                 globalInstance = this;
    00229             }
    00230             else
    00231             {
    00232                 throw new Exception("This is inapropriate! Only one instance of DXGfxManager should exist per process! Use GetGlobalInstance() instead!");
    00233             }
    00234         }
    00235
    00240         public static DXGfxManager GetGlobalInstance()
    00241         {
    00242             if (globalInstance == null)
    00243             {
    00244                 globalInstance = new DXGfxManager();
    00245             }
    00246
    00247             return globalInstance;
    00248         }
    00249
    00253         public void Init()
    00254         {
    00255             scriptManager = new ScriptManager();
    00256
    00257             //currentInputHandler = new PointAndClickHandler();
    00258
    00259             //currentCamera = new ThirdPersonCamera(); // A model viewing camera
    00261             //currentCamera.SetViewParameters(new Vector3(0.0f, 0.0f, -5.0f), Vector3.Empty);
    00262
    00263             serializationManager = new DXGfxLib.Serialization.Manager();
    00264         }
    00265
    00270         public void Reset()
    00271         {
    00272             if (scriptManager != null)
    00273             {
    00274                 scriptManager.Dispose();
    00275                 scriptManager = null;
    00276             }
    00277             if (serializationManager != null)
    00278             {
    00279                 serializationManager.Dispose();
    00280                 serializationManager = null;
    00281             }
    00282         }
    00283
    00290         public void Init(Framework framework)
    00291         {
    00292             frameworkInUse = framework;
    00293
    00294             // Add handlers for specific device events.
    00295             // If Init method is called directly it is the outside code responsability
    00296             // to call the appropriate DXGfxManager methods on specific device events.
    00297             framework.Disposing += new EventHandler(OnDestroyDevice);
    00298             framework.DeviceLost += new EventHandler(OnLostDevice);
    00299             framework.DeviceCreated += new DeviceEventHandler(OnCreateDevice);
    00300             framework.DeviceReset += new DeviceEventHandler(OnDeviceReset);
    00301
    00302             Init();
    00303         }
    00304
    00312         public void OnDeviceReset(object sender, DeviceEventArgs e)
    00313         {
    00314             if (outdoorScene != null)
    00315             {
    00316                 if (outdoorScene.CurrentCamera != null)
    00317                 {
    00318                     // Setup the camera's view parameters
    00319                     outdoorScene.CurrentCamera.SetViewParameters(new Vector3(0.0f, 0.0f, -5.0f), Vector3.Empty);
    00320                     // Setup the camera's projection parameters
    00321                     float aspectRatio = (float)e.BackBufferDescription.Width / (float)e.BackBufferDescription.Height;
    00322                     outdoorScene.CurrentCamera.SetProjectionParameters((float)Math.PI / 4, aspectRatio, 0.1f, 1000.0f);
    00323                     outdoorScene.CurrentCamera.SetViewParameters(new Vector3(0.0f, 5.0f, -30.0f), new Vector3(0.0f, 0.0f, 0.0f));
    00324                     outdoorScene.CurrentCamera.IsPositionMovementEnabled = true;
    00325                 }
    00326             }
    00327
    00328             d3dDevice = e.Device;
    00329             backBufferDescription = e.BackBufferDescription;
    00330         }
    00331
    00339         public void OnLostDevice(object sender, EventArgs e)
    00340         {
    00341         }
    00342
    00349         public void OnDestroyDevice(object sender, EventArgs e)
    00350         {
    00351         }
    00352
    00360         public void OnCreateDevice(object sender, DeviceEventArgs e)
    00361         {
    00362             d3dDevice = e.Device;
    00363             backBufferDescription = e.BackBufferDescription;
    00364
    00365             defaultEffectGroup = new EffectGroup();
    00366             defaultEffectGroup.Set(d3dDevice, defaultEffectGroupBaseFile);
    00367         }
    00368
    00369         public void UpdateOutdoorScene(float elapsedTime, double appTime)
    00370         {
    00371             if (outdoorScene == null)
    00372             {
    00373                 return;
    00374             }
    00375
    00376             outdoorScene.Update(d3dDevice, appTime, elapsedTime);
    00377         }
    00378
    00379         public void DrawOutdoorScene()
    00380         {
    00381             //bool beginSceneCalled = false;
    00382
    00383             if (outdoorScene == null)
    00384             {
    00385                 return;
    00386             }
    00387
    00388             //try
    00389             //{
    00390                 // Clear the render target and the zbuffer
    00391                 d3dDevice.Clear(ClearFlags.ZBuffer | ClearFlags.Target, 0x00424B79, 1.0f, 0);
    00392
    00393                 //d3dDevice.BeginScene();
    00394                 //beginSceneCalled = true;
    00395
    00396                 outdoorScene.RenderScene(d3dDevice, outdoorScene.currentFrustrum);
    00397             //}
    00398             //finally
    00399             //{
    00400             //    if (beginSceneCalled)
    00401             //        d3dDevice.EndScene();
    00402             //}
    00403         }
    00404
    00410         public FrameworkMesh FrameworkMeshFromFile(string fileName)
    00411         {
    00412             if (d3dDevice == null)
    00413             {
    00414                 throw new Exception("d3dDevice is null, loading of a FrameworkMesh is impossible without a valid device!");
    00415             }
    00416             return new FrameworkMesh(d3dDevice, fileName);
    00417         }
    00418
    00426         public OutDoorScene NewScene(string name, float size, int quadtreeLevels)
    00427         {
    00428             AABBox desiredBBox = new AABBox(new BBox(new Vector3(0.0f, 0.0f, 0.0f), size));
    00429             outdoorScene = new OutDoorScene(desiredBBox, quadtreeLevels);
    00430
    00431             outdoorScene.sceneContent.Remove(currentSceneName);
    00432             outdoorScene.sceneContent.Add(name, outdoorScene);
    00433             currentSceneName = name;
    00434
    00435             outdoorScene.name = StringUtil.GetName(name);
    00436
    00437             return outdoorScene;
    00438         }
    00439
    00440         public void SetScene(OutDoorScene outdoor)
    00441         {
    00442             this.outdoorScene = outdoor;
    00443         }
    00444
    00445         public void CloseScene()
    00446         {
    00447             if (outdoorScene != null)
    00448             {
    00449                 outdoorScene.Dispose();
    00450                 outdoorScene = null;
    00451             }
    00452
    00453             // Let's do this, it is safer !!
    00454             Reset();
    00455             Init();
    00456         }
    00457
    00462         public Hashtable GetSceneContent()
    00463         {
    00464             return outdoorScene.sceneContent;
    00465         }
    00466
    00471         public void SetHeightMap(string fileName)
    00472         {
    00473             if (outdoorScene == null)
    00474             {
    00475                 throw new NullReferenceException("The is no outdoorScene at this stage so this method can not be called!");
    00476             }
    00477
    00478             outdoorScene.LoadTerrain(fileName);
    00479
    00480             heigthMapFile = fileName;
    00481         }
    00482
    00489         public Water2 SetWater(string fileName)
    00490         {
    00491             if (outdoorScene == null)
    00492             {
    00493                 throw new NullReferenceException("The is no outdoorScene at this stage so this method can not be called!");
    00494             }
    00495
    00496             Water2 theWater = new Water2(1000);
    00497             outdoorScene.SceneWater = theWater;
    00498             theWater.name = "Water";
    00499             theWater.fileName = fileName;
    00500
    00501             waterFile = fileName;
    00502
    00503             outdoorScene.sceneContent.Add(fileName, theWater);
    00504
    00505             return theWater;
    00506         }
    00507
    00514         public SkyDome SetSky(string fileName)
    00515         {
    00516             if (outdoorScene == null)
    00517             {
    00518                 throw new NullReferenceException("The is no outdoorScene at this stage so this method can not be called!");
    00519             }
    00520
    00521             SkyDome theSky = new SkyDome();
    00522             theSky.LoadFromFile(this.d3dDevice, fileName);
    00523             outdoorScene.SceneSky = theSky;
    00524             theSky.name = "theSky";
    00525             theSky.fileName = fileName;
    00526
    00527             skyFile = fileName;
    00528
    00529             outdoorScene.sceneContent.Add(fileName, theSky);
    00530
    00531             return theSky;
    00532         }
    00533
    00539         public SceneObject LoadObject(string fileName)
    00540         {
    00541             if (outdoorScene == null)
    00542             {
    00543                 throw new NullReferenceException("The is no outdoorScene at this stage so this method can not be called!");
    00544             }
    00545
    00546             MeshObject sceneObject = new MeshObject(d3dDevice, fileName);
    00547             outdoorScene.Attach(sceneObject);
    00548
    00549             if (outdoorScene.sceneContent.Contains(fileName))
    00550             {
    00551                 // We already have one object with the same name so let's rename our object !!
    00552                 sceneObject.name += "I";
    00553             }
    00554             outdoorScene.sceneContent.Add(sceneObject.name, sceneObject);
    00555
    00556             return sceneObject;
    00557         }
    00558
    00567         public SceneObject LoadObject(Type desiredType, string fileName)
    00568         {
    00569             if (outdoorScene == null)
    00570             {
    00571                 throw new NullReferenceException("The is no outdoorScene at this stage so this method can not be called!");
    00572             }
    00573
    00574             ConstructorInfo ctor = desiredType.GetConstructor(new Type[] { });
    00575             Object[] args = new Object[] { };
    00576             Object obj = ctor.Invoke(args);
    00577
    00578             if (obj == null)
    00579             {
    00580                 throw new Exception("Non creatable type !!");
    00581             }
    00582
    00583             SceneObject sobj = obj as SceneObject;
    00584
    00585             if (sobj == null)
    00586             {
    00587                 throw new Exception("Type doesn't derive from SceneObject this is wrong!!");
    00588             }
    00589
    00590             if (File.Exists(fileName))
    00591             {
    00592                 sobj.LoadFromFile(d3dDevice, fileName);
    00593             }
    00594             outdoorScene.Attach(sobj);
    00595
    00596             if (outdoorScene.sceneContent.Contains(fileName))
    00597             {
    00598                 // We already have one object with the same name so let's rename our object !!
    00599                 sobj.name += "I";
    00600             }
    00601             outdoorScene.sceneContent.Add(sobj.name, sobj);
    00602
    00603             return sobj;
    00604         }
    00605
    00606         public void LoadEffect(Device device, string file, ref Effect effOut)
    00607         {
    00608             // Read the D3DX effect file
    00609             if (!File.Exists(file))
    00610             {
    00611                 OpenFileDialog ofdlg = new OpenFileDialog();
    00612                 ofdlg.Title = file + " not found. Select it!";
    00613
    00614                 if (ofdlg.ShowDialog() == DialogResult.OK)
    00615                 {
    00616                     file = ofdlg.FileName;
    00617                 }
    00618             }
    00619
    00620             string effError;
    00621
    00622             effOut = ResourceCache.GetGlobalInstance().CreateEffectFromFile(device,
    00623             file, null, null, shaderFlags, null, out effError);
    00624
    00625             if (!effError.Equals(""))
    00626             {
    00627                 MessageBox.Show(effError);
    00628             }
    00629         }
    00630
    00631         public Effect LoadEffect(Device device, string file)
    00632         {
    00633             Effect newEff = null;
    00634             LoadEffect(device, file, ref newEff);
    00635
    00636             return newEff;
    00637         }
    00643         public Object GetObj(string fileName)
    00644         {
    00645             if (outdoorScene == null)
    00646             {
    00647                 throw new NullReferenceException("The is no outdoorScene at this stage so this method can not be called!");
    00648             }
    00649
    00650             return outdoorScene.sceneContent[fileName];
    00651         }
    00652
    00658         public SceneObject GetSceneObject(string fileName)
    00659         {
    00660             if (outdoorScene == null)
    00661             {
    00662                 throw new NullReferenceException("The is no outdoorScene at this stage so this method can not be called!");
    00663             }
    00664
    00665             SceneObject sceneObj = outdoorScene.sceneContent[fileName] as SceneObject;
    00666             return sceneObj;
    00667         }
    00668
    00673         public Scene GetScene()
    00674         {
    00675             if (outdoorScene == null)
    00676             {
    00677                 throw new NullReferenceException("The is no outdoorScene at this stage so this method can not be called!");
    00678             }
    00679
    00680             return outdoorScene;
    00681         }
    00682
    00692         public void Save(string dstFullPathName)
    00693         {
    00694             if (outdoorScene == null)
    00695             {
    00696                 throw new NullReferenceException("The is no outdoorScene at this stage so this method can not be called!");
    00697             }
    00698
    00700             //XmlWriter writer = XmlWriter.Create(dstFullPathName);
    00701
    00702             //writer.WriteStartElement("Scene");
    00703             //writer.WriteAttributeString("Name", "DefaultSceneName!");
    00704
    00705             //writer.WriteElementString("HeigthMap", heigthMapFile);
    00706
    00707             //IDictionaryEnumerator sceneEnumerator = outdoorScene.sceneContent.GetEnumerator();
    00708
    00709             //writer.WriteStartElement("SceneContent");
    00710             //while (sceneEnumerator.MoveNext())
    00711             //{
    00712             //    SceneObject sceneObj = sceneEnumerator.Value as SceneObject;
    00713
    00714             //    if (sceneObj != null)
    00715             //    {
    00716             //        writer.WriteStartElement(StringUtil.GetName(sceneObj.name));
    00717             //        writer.WriteAttributeString("Type", sceneObj.GetType().ToString());
    00718             //        writer.WriteAttributeString("Name", sceneObj.name);
    00719             //        writer.WriteAttributeString("FileName", sceneObj.fileName);
    00720             //        writer.WriteAttributeString("X", sceneObj.X.ToString());
    00721             //        writer.WriteAttributeString("Y", sceneObj.Y.ToString());
    00722             //        writer.WriteAttributeString("Z", sceneObj.Z.ToString());
    00723             //        writer.WriteAttributeString("Yaw", sceneObj.Yaw.ToString());
    00724             //        writer.WriteAttributeString("Pitch", sceneObj.Pitch.ToString());
    00725             //        writer.WriteAttributeString("Roll", sceneObj.Roll.ToString());
    00726             //        string varSrc = "";
    00727             //        string codeSrc = "";
    00728             //        string onClickSrc = "";
    00729             //        string onCollSrc = "";
    00730             //        if (sceneObj.OurScript != null)
    00731             //        {
    00732             //            varSrc = sceneObj.OurScript.GetVarSrc();
    00733             //            codeSrc = sceneObj.OurScript.GetCodeSrc();
    00734             //            onClickSrc = sceneObj.OurScript.GetClickCodeSrc();
    00735             //            onCollSrc = sceneObj.OurScript.GetCollisionCodeSrc();
    00736             //        }
    00737             //        writer.WriteAttributeString("VarSrc", varSrc);
    00738             //        writer.WriteAttributeString("CodeSrc", codeSrc);
    00739             //        writer.WriteAttributeString("OnClickSrc", onClickSrc);
    00740             //        writer.WriteAttributeString("OnCollSrc", onCollSrc);
    00741             //        writer.WriteEndElement();
    00742             //    }
    00743             //}
    00744             //writer.WriteEndElement();
    00745             //writer.WriteEndElement();
    00746             //writer.Flush();
    00747             //writer.Close();
    00748
    00749             DXGfxLib.Serialization.Manager.GetGlobalInstance().SaveScene(outdoorScene, dstFullPathName);
    00750         }
    00751
    00757         public void Load(string fullPathName)
    00758         {
    00759             string mediaFolder = StringUtil.GetPath(fullPathName);
    00760             mediaFolder += "Media";
    00761
    00762             Load(fullPathName, mediaFolder);
    00763         }
    00764
    00772         public void Load(string fullPathName, string mediaFolder)
    00773         {
    00774             //string currentFolder = Directory.GetCurrentDirectory();
    00775             //Directory.SetCurrentDirectory(mediaFolder);
    00776
    00777             //XmlReader reader = XmlReader.Create(fullPathName);
    00778
    00779             //reader.ReadStartElement("Scene");
    00780
    00781             //NewScene(reader.Name, 1000, 4);
    00782
    00783             //heigthMapFile = reader.ReadElementString("HeigthMap");
    00784             //if (File.Exists(heigthMapFile))
    00785             //{
    00786             //    SetHeightMap(heigthMapFile);
    00787             //}
    00788
    00789             //reader.ReadStartElement("SceneContent");
    00790
    00791             //do
    00792             //{
    00793             //    if (reader.HasAttributes)
    00794             //    {
    00795
    00796             //        reader.MoveToAttribute("Type");
    00797             //        Type type = Type.GetType(reader.Value);
    00798             //        reader.MoveToElement();
    00799
    00800             //        reader.MoveToAttribute("Name");
    00801             //        string name = reader.Value;
    00802             //        reader.MoveToElement();
    00803
    00804             //        reader.MoveToAttribute("FileName");
    00805             //        string fileName = reader.Value;
    00806             //        reader.MoveToElement();
    00807
    00808             //        reader.MoveToAttribute("X");
    00809             //        float X = float.Parse(reader.Value);
    00810             //        reader.MoveToElement();
    00811
    00812             //        reader.MoveToAttribute("Y");
    00813             //        float Y = float.Parse(reader.Value);
    00814             //        reader.MoveToElement();
    00815
    00816             //        reader.MoveToAttribute("Z");
    00817             //        float Z = float.Parse(reader.Value);
    00818             //        reader.MoveToElement();
    00819
    00820             //        reader.MoveToAttribute("Yaw");
    00821             //        float Yaw = float.Parse(reader.Value);
    00822             //        reader.MoveToElement();
    00823
    00824             //        reader.MoveToAttribute("Pitch");
    00825             //        float Pitch = float.Parse(reader.Value);
    00826             //        reader.MoveToElement();
    00827
    00828             //        reader.MoveToAttribute("Roll");
    00829             //        float Roll = float.Parse(reader.Value);
    00830             //        reader.MoveToElement();
    00831
    00832             //        reader.MoveToAttribute("VarSrc");
    00833             //        string VarSrc = reader.Value;
    00834             //        reader.MoveToElement();
    00835
    00836             //        reader.MoveToAttribute("CodeSrc");
    00837             //        string CodeSrc = reader.Value;
    00838             //        reader.MoveToElement();
    00839
    00840             //        reader.MoveToAttribute("OnClickSrc");
    00841             //        string onClickSrc = reader.Value;
    00842             //        reader.MoveToElement();
    00843
    00844             //        reader.MoveToAttribute("OnCollSrc");
    00845             //        string onCollSrc = reader.Value;
    00846             //        reader.MoveToElement();
    00847
    00848             //        if (name == "theSky")
    00849             //        {
    00850             //            if (File.Exists(fileName))
    00851             //            {
    00852             //                SkyBox sky = SetSky(fileName);
    00853             //                sky.Position = new Vector3(X, Y, Z);
    00854             //                sky.Orientation = new Vector3(Yaw, Pitch, Roll);
    00855
    00856             //                Script script = sky.GetScript();
    00857             //                script.UpdateVarSrc(VarSrc);
    00858             //                script.UpdateCodeSrc(CodeSrc);
    00859             //                script.UpdateClickCodeSrc(onClickSrc);
    00860             //                script.UpdateCollisionCodeSrc(onCollSrc);
    00861             //            }
    00862             //        }
    00863             //        else if (name == "Water")
    00864             //        {
    00865             //            if (File.Exists(fileName))
    00866             //            {
    00867             //                Water water = SetWater(fileName);
    00868             //                water.Position = new Vector3(X, Y, Z);
    00869             //                water.Orientation = new Vector3(Yaw, Pitch, Roll);
    00870
    00871             //                Script script = water.GetScript();
    00872             //                script.UpdateVarSrc(VarSrc);
    00873             //                script.UpdateCodeSrc(CodeSrc);
    00874             //                script.UpdateClickCodeSrc(onClickSrc);
    00875             //                script.UpdateCollisionCodeSrc(onCollSrc);
    00876             //            }
    00877             //        }
    00878             //        else if (type != null)
    00879             //        {
    00880             //            if (File.Exists(fileName))
    00881             //            {
    00882             //                SceneObject sobj = LoadObject(type, fileName);
    00883
    00884             //                sobj.Position = new Vector3(X, Y, Z);
    00885             //                sobj.Orientation = new Vector3(Yaw, Pitch, Roll);
    00886
    00887             //                Script script = sobj.GetScript();
    00888             //                script.UpdateVarSrc(VarSrc);
    00889             //                script.UpdateCodeSrc(CodeSrc);
    00890             //                script.UpdateClickCodeSrc(onClickSrc);
    00891             //                script.UpdateCollisionCodeSrc(onCollSrc);
    00892             //            }
    00893             //        }
    00894             //    }
    00895             //} while (reader.Read());
    00896             //Directory.SetCurrentDirectory(currentFolder);
    00897
    00898             sceneFile = fullPathName;
    00899             mediaFolderPath = mediaFolder;
    00900
    00901             outdoorScene = DXGfxLib.Serialization.Manager.GetGlobalInstance().LoadOutdoor(fullPathName);
    00902             // We now have a fully functionnal outdoorscene. Let's really load the data.
    00903             string currentFolder = Directory.GetCurrentDirectory();
    00904             Directory.SetCurrentDirectory(mediaFolder);
    00905             if (outdoorScene.SceneTerrain != null)
    00906             {
    00907                 if (File.Exists(outdoorScene.SceneTerrain.heightmapFile))
    00908                 {
    00909                     outdoorScene.SceneTerrain.LoadFromFile(DXGfxManager.GetGlobalInstance().d3dDevice, (OutDoorScene)DXGfxManager.GetGlobalInstance().GetScene(), outdoorScene.SceneTerrain.heightmapFile);
    00910                 }
    00911             }
    00912             // Let's ask the whole scene to get prepared !!
    00913             outdoorScene.GetPrepared();
    00914
    00915             Directory.SetCurrentDirectory(currentFolder);
    00916         }
    00917
    00923         public void CallEvaluation(double appTime, float elapsedTime)
    00924         {
    00925             IDictionaryEnumerator sceneEnum = outdoorScene.sceneContent.GetEnumerator();
    00926
    00928             while (sceneEnum.MoveNext())
    00929             {
    00930                 SceneObject sceneObj = sceneEnum.Value as SceneObject;
    00931
    00932                 if (sceneObj != null)
    00933                 {
    00934                     sceneObj.Evaluate(appTime, elapsedTime);
    00935                     continue;
    00936                 }
    00937
    00938                 Scene scene = sceneEnum.Value as Scene;
    00939
    00940                 if (scene != null)
    00941                 {
    00942                     scene.Evaluate(appTime, elapsedTime);
    00943                     continue;
    00944                 }
    00945             }
    00946         }
    00947     }
    00948 }