public MainSceneEditor() { var texturePool = new TexturePool(); var meshpartPool = new MeshPartPool(); var vertexDeclarationPool = new VertexDeclarationPool(); vertexDeclarationPool.SetVertexElements <TangentVertex>(TangentVertex.VertexElements); renderer = new SimpleMeshRenderer(texturePool, meshpartPool, vertexDeclarationPool); game.IsFixedTimeStep = false; game.DrawFps = true; game.AddXNAObject(texturePool); game.AddXNAObject(meshpartPool); game.AddXNAObject(vertexDeclarationPool); game.AddXNAObject(renderer); renderingFactory = new DiskRenderingAssetFactory(); placeTool = new WorldObjectPlaceTool(game, world, renderer, builder, renderingFactory, tileFaceFactory); moveTool = new WorldObjectMoveTool(game, world, builder, renderer); snapLearnTool = new SnapLearnTool(world, renderer, builder); game.AddXNAObject(placeTool); game.AddXNAObject(moveTool); game.AddXNAObject(snapLearnTool); diskTileDataFactory = new DiskTileDataFactory(renderingFactory, tileFaceTypeFactory); worldSerializer = new WorldSerializer(renderingFactory, diskTileDataFactory, game, renderer, worldObjectTypeFactory, builder); }
public void TestLearnPlace() { XNAGame game = new XNAGame(); var texturePool = new TexturePool(); var meshpartPool = new MeshPartPool(); var vertexDeclarationPool = new VertexDeclarationPool(); vertexDeclarationPool.SetVertexElements <TangentVertex>(TangentVertex.VertexElements); var renderer = new SimpleMeshRenderer(texturePool, meshpartPool, vertexDeclarationPool); game.IsFixedTimeStep = false; game.DrawFps = true; game.AddXNAObject(texturePool); game.AddXNAObject(meshpartPool); game.AddXNAObject(vertexDeclarationPool); game.AddXNAObject(renderer); EditorGrid grid; grid = new EditorGrid(); grid.Size = new Vector2(100, 100); grid.Interval = 1; grid.MajorInterval = 10; World world = new World(); var builder = new TileSnapInformationBuilder(); //var TileInnerCorner = factory.CreateNewWorldObject(game, wallInnerCornerType, renderer); //TileInnerCorner.Position = new Vector3(-7, 0, 0); //var TileStraight = factory.CreateNewWorldObject(game, wallStraightType, renderer); //TileStraight.Position = new Vector3(7, 0, 0); var placeTool = new WorldObjectPlaceTool(game, world, renderer, builder, new SimpleMeshFactory(), new SimpleTileFaceTypeFactory()); var moveTool = new WorldObjectMoveTool(game, world, builder, renderer); var snapLearnTool = new SnapLearnTool(world, renderer, builder); game.AddXNAObject(placeTool); game.AddXNAObject(moveTool); game.AddXNAObject(snapLearnTool); setupWorldObjectTypes(game, renderer, builder); bool mouseEnabled = false; game.UpdateEvent += delegate { if (game.Keyboard.IsKeyPressed(Microsoft.Xna.Framework.Input.Keys.M)) { placeTool.Enabled = false; moveTool.Enabled = true; snapLearnTool.Enabled = false; } if (game.Keyboard.IsKeyPressed(Microsoft.Xna.Framework.Input.Keys.L)) { placeTool.Enabled = false; moveTool.Enabled = false; snapLearnTool.Enabled = true; } if (placeTool.Enabled) { moveTool.Enabled = false; snapLearnTool.Enabled = false; if (placeTool.ObjectsPlacedSinceEnabled() == 1) { placeTool.Enabled = false; } } if (game.Keyboard.IsKeyPressed(Microsoft.Xna.Framework.Input.Keys.NumPad1)) { placeTool.PlaceType = typeList[0]; placeTool.Enabled = true; } if (game.Keyboard.IsKeyPressed(Microsoft.Xna.Framework.Input.Keys.NumPad2)) { placeTool.PlaceType = typeList[1]; placeTool.Enabled = true; } if (game.Keyboard.IsKeyPressed(Microsoft.Xna.Framework.Input.Keys.LeftAlt)) { mouseEnabled = !mouseEnabled; } if (mouseEnabled) { game.Mouse.CursorEnabled = true; game.IsMouseVisible = true; game.SpectaterCamera.Enabled = false; } else { game.Mouse.CursorEnabled = false; game.IsMouseVisible = false; game.SpectaterCamera.Enabled = true; //activeWorldObject = null; } }; game.DrawEvent += delegate { grid.Render(game); }; game.Run(); }
public void TestLearnSnap() { XNAGame game = new XNAGame(); OBJParser.ObjImporter importer = new OBJParser.ObjImporter(); var c = new OBJToRAMMeshConverter(new RAMTextureFactory()); importer.AddMaterialFileStream("WallInnerCorner.mtl", new FileStream(TWDir.GameData.CreateSubdirectory("Core\\TileEngine") + "/TileSet001/WallInnerCorner.mtl", FileMode.Open)); importer.ImportObjFile(TWDir.GameData.CreateSubdirectory("Core\\TileEngine") + "/TileSet001/WallInnerCorner.obj"); var meshWallInnerCorner = c.CreateMesh(importer); importer.AddMaterialFileStream("WallStraight.mtl", new FileStream(TWDir.GameData.CreateSubdirectory("Core\\TileEngine") + "/TileSet001/WallStraight.mtl", FileMode.Open)); importer.ImportObjFile(TWDir.GameData.CreateSubdirectory("Core\\TileEngine") + "/TileSet001/WallStraight.obj"); var meshWallStraight = c.CreateMesh(importer); var texturePool = new TexturePool(); var meshpartPool = new MeshPartPool(); var vertexDeclarationPool = new VertexDeclarationPool(); var renderer = new SimpleMeshRenderer(texturePool, meshpartPool, vertexDeclarationPool); vertexDeclarationPool.SetVertexElements <TangentVertex>(TangentVertex.VertexElements); World world = new World(); TileSnapInformationBuilder builder = new TileSnapInformationBuilder(); WorldObjectType type1 = new WorldObjectType(meshWallInnerCorner, Guid.NewGuid(), builder); WorldObjectType type2 = new WorldObjectType(meshWallStraight, Guid.NewGuid(), builder); var tileDataInnerCorner = new TileData(Guid.NewGuid()); var tileDataStraight = new TileData(Guid.NewGuid()); tileDataInnerCorner.Dimensions = type1.BoundingBox.Max - type1.BoundingBox.Min; tileDataStraight.Dimensions = type2.BoundingBox.Max - type2.BoundingBox.Min; type1.TileData = tileDataInnerCorner; type2.TileData = tileDataStraight; var TileInnerCorner = world.CreateNewWorldObject(game, type1, renderer); TileInnerCorner.Position = new Vector3(-7, 0, 0); var TileStraight = world.CreateNewWorldObject(game, type2, renderer); TileStraight.Position = new Vector3(7, 0, 0); game.IsFixedTimeStep = false; game.DrawFps = true; game.AddXNAObject(texturePool); game.AddXNAObject(meshpartPool); game.AddXNAObject(vertexDeclarationPool); game.AddXNAObject(renderer); EditorGrid grid; grid = new EditorGrid(); grid.Size = new Vector2(100, 100); grid.Interval = 1; grid.MajorInterval = 10; var snapLearnTool = new SnapLearnTool(world, renderer, builder); game.AddXNAObject(snapLearnTool); bool mouseEnabled = false; var WallCornerBB = type1.TileData.GetBoundingBox(); game.UpdateEvent += delegate { if (game.Keyboard.IsKeyPressed(Microsoft.Xna.Framework.Input.Keys.LeftAlt)) { mouseEnabled = !mouseEnabled; } if (mouseEnabled) { game.Mouse.CursorEnabled = true; game.IsMouseVisible = true; game.SpectaterCamera.Enabled = false; } else { game.Mouse.CursorEnabled = false; game.IsMouseVisible = false; game.SpectaterCamera.Enabled = true; //activeWorldObject = null; } }; game.DrawEvent += delegate { grid.Render(game); game.LineManager3D.WorldMatrix = TileInnerCorner.WorldMatrix; //game.LineManager3D.AddBox(WallCornerBB, Color.White); }; game.Run(); }