public void TestObjectFullDataFactory() { string dataDir = System.Windows.Forms.Application.StartupPath + "\\Test\\TestObjectFullDataFactory"; TheWizards.WorldDatabase.WorldDatabase db = new MHGameWork.TheWizards.WorldDatabase.WorldDatabase(dataDir); db.RegisterDataElementType(typeof(ObjectFullData), "TestObjectFullData"); db.AddDataElementFactory(new ObjectFullDataFactory(db), true); ObjectFullData data = new ObjectFullData(); data.Name = "MyBuilding1"; data.BoundingBox = new BoundingBox(Vector3.Forward, Vector3.One); data.BoundingSphere = new BoundingSphere(Vector3.One, 5); DataItem item = db.WorkingCopy.CreateNewDataItem(db.FindOrCreateDataItemType("TestObject")); db.WorkingCopy.PutDataElement(item, data); db.SaveWorkingCopy(); db = new MHGameWork.TheWizards.WorldDatabase.WorldDatabase(dataDir); db.RegisterDataElementType(typeof(ObjectFullData), "TestObjectFullData"); db.AddDataElementFactory(new ObjectFullDataFactory(db), true); Assert.AreEqual(data, db.LoadDataElement <ObjectFullData>(db.WorkingCopy.Revision.DataItems[db.WorkingCopy.Revision.DataItems.Count - 1])); }
public void TestColladaImportMeshParts() { TheWizards.WorldDatabase.WorldDatabase db = new MHGameWork.TheWizards.WorldDatabase.WorldDatabase(System.Windows.Forms.Application.StartupPath + "\\Test\\Entity\\Editor\\ImportMeshParts"); ColladaMeshImporter importer = new ColladaMeshImporter(db); COLLADA collada; List <EditorMeshPart> meshParts; collada = COLLADA.FromStream(ColladaFiles.GetSimplePlaneDAE()); meshParts = importer.ImportMeshParts(collada); collada = COLLADA.FromStream(ColladaFiles.GetAdvancedScene001DAE()); meshParts = importer.ImportMeshParts(collada); collada = COLLADA.FromStream(ColladaFiles.GetTeapot001DAE()); meshParts = importer.ImportMeshParts(collada); }
public void TestEditorMeshPartRenderDataAdvanced() { List <EditorMeshPart> parts = new List <EditorMeshPart>(); TheWizards.WorldDatabase.WorldDatabase db = new MHGameWork.TheWizards.WorldDatabase.WorldDatabase( System.Windows.Forms.Application.StartupPath + "\\Test\\EntityEditor\\TestEMPRDAdvanced"); ColladaMeshImporter importer = new ColladaMeshImporter(db); COLLADA collada; List <EditorMeshPart> meshParts; collada = COLLADA.FromStream(ColladaFiles.GetSimplePlaneDAE()); parts.AddRange(importer.ImportMeshParts(collada)); collada = COLLADA.FromStream(ColladaFiles.GetAdvancedScene001DAE()); parts.AddRange(importer.ImportMeshParts(collada)); collada = COLLADA.FromStream(ColladaFiles.GetTeapot001DAE()); parts.AddRange(importer.ImportMeshParts(collada)); XNAGame game = new XNAGame(); ColladaShader shader = null; List <EditorMeshPartRenderData> renderDatas = new List <EditorMeshPartRenderData>(); game.InitializeEvent += delegate { for (int i = 0; i < parts.Count; i++) { EditorMeshPartRenderData renderData = new EditorMeshPartRenderData(parts[i]); renderData.Initialize(game); renderDatas.Add(renderData); } shader = new ColladaShader(game, null); shader.DiffuseColor = Color.Red.ToVector4(); shader.SpecularColor = Color.White.ToVector4(); shader.LightDirection = Vector3.Normalize(new Vector3(0, 0, 1)); shader.Shininess = 20; }; game.DrawEvent += delegate { game.GraphicsDevice.RenderState.CullMode = Microsoft.Xna.Framework.Graphics.CullMode.None; shader.ViewProjection = game.Camera.ViewProjection; shader.ViewInverse = game.Camera.ViewInverse; for (int i = 0; i < renderDatas.Count; i++) { shader.World = Matrix.CreateRotationX(-MathHelper.PiOver2) * Matrix.CreateTranslation(Vector3.UnitX * (-100 + 40 * i)); shader.RenderPrimitiveSinglePass(renderDatas[i], Microsoft.Xna.Framework.Graphics.SaveStateMode.None); } }; game.Run(); }