public static MotionEntity CreateBlock(Vector3 position, Vector3 boxSize, String textureFilename) { var block = new MotionEntity { MainGraphic = new MetaModel { XMesh = new MeshConcretize { MeshDescription = new Graphics.Software.Meshes.BoxMesh { Min = new Vector3(-boxSize.X / 2f, -boxSize.Y / 2f, 0), Max = new Vector3(boxSize.X / 2f, boxSize.Y / 2f, boxSize.Z), }, Layout = Graphics.Software.Vertex.PositionNormalTexcoord.Instance }, Texture = new TextureFromFile(textureFilename), }, Translation = position }; block.MotionObject = new Common.Motion.Static(); block.MotionObject.LocalBounding = new BoundingMetaMesh { Mesh = ((MetaModel)block.MainGraphic).XMesh, //Transformation = Matrix.Translation(Vector3.Zero) }; block.MotionObject.Position = position; return block; }
private MotionEntity CreateUnit(Vector2 position) { Vector3 translation = new Vector3(position, 0); var unit = new MotionEntity { MainGraphic = new MetaModel { SkinnedMesh = new SkinnedMeshFromFile("goblin_blade_master1.x"), Texture = new TextureFromFile("goblin_blade_master1.png"), World = SkinnedMesh.InitSkinnedMeshFromMaya * Matrix.Scaling(0.1f, 0.1f, 0.1f), IsBillboard = false, }, //Animation = "idle1", //AnimationLoop = true, Translation = translation }; unit.MotionObject = new Common.Motion.Unit() { LocalBounding = new Common.Bounding.Cylinder(Vector3.Zero, 1f, 0.5f), Position = translation }; unit.VisibilityLocalBounding = unit.MotionObject.LocalBounding; return(unit); }
public static MotionEntity CreateBlock(Vector3 position, Vector3 boxSize, String textureFilename) { var block = new MotionEntity { MainGraphic = new MetaModel { XMesh = new MeshConcretize { MeshDescription = new Graphics.Software.Meshes.BoxMesh { Min = new Vector3(-boxSize.X / 2f, -boxSize.Y / 2f, 0), Max = new Vector3(boxSize.X / 2f, boxSize.Y / 2f, boxSize.Z), }, Layout = Graphics.Software.Vertex.PositionNormalTexcoord.Instance }, Texture = new TextureFromFile(textureFilename), }, Translation = position }; block.MotionObject = new Common.Motion.Static(); block.MotionObject.LocalBounding = new BoundingMetaMesh { Mesh = ((MetaModel)block.MainGraphic).XMesh, //Transformation = Matrix.Translation(Vector3.Zero) }; block.MotionObject.Position = position; return(block); }
private void DisplayCollision(MotionEntity u) { var t = ((MetaModel)u.MainGraphic).Texture; if (((Common.Motion.Unit)u.MotionObject).IntersectedUnits) { if (!(t is TextureConcretizer)) { ((MetaModel)u.MainGraphic).Texture = new TextureConcretizer { Texture = global::Graphics.Software.ITexture.SingleColorTexture(Color.White) } } ; } else if (!(t is Graphics.Content.TextureFromFile)) { ((MetaModel)u.MainGraphic).Texture = new TextureFromFile("goblin_blade_master1.png"); } } void scene_EntityAdded(Entity obj) { var me = obj as MotionEntity; if (me != null && me.MotionObject != null) { motionSimulation.Insert(me.MotionObject); } } void scene_EntityRemoved(Entity obj) { var me = obj as MotionEntity; if (me != null && me.MotionObject != null) { motionSimulation.Remove(me.MotionObject); } }
private void DisplayCollision(MotionEntity u) { var t = ((MetaModel)u.MainGraphic).Texture; if (((Common.Motion.Unit)u.MotionObject).IntersectedUnits) { if (!(t is TextureConcretizer)) ((MetaModel)u.MainGraphic).Texture = new TextureConcretizer { Texture = global::Graphics.Software.ITexture.SingleColorTexture(Color.White) }; } else if (!(t is Graphics.Content.TextureFromFile)) ((MetaModel)u.MainGraphic).Texture = new TextureFromFile("goblin_blade_master1.png"); }
private MotionEntity CreateUnit(Vector2 position) { Vector3 translation = new Vector3(position, 0); var unit = new MotionEntity { MainGraphic = new MetaModel { SkinnedMesh = new SkinnedMeshFromFile("goblin_blade_master1.x"), Texture = new TextureFromFile("goblin_blade_master1.png"), World = SkinnedMesh.InitSkinnedMeshFromMaya * Matrix.Scaling(0.1f, 0.1f, 0.1f), IsBillboard = false, }, //Animation = "idle1", //AnimationLoop = true, Translation = translation }; unit.MotionObject = new Common.Motion.Unit() { LocalBounding = new Common.Bounding.Cylinder(Vector3.Zero, 1f, 0.5f), Position = translation }; unit.VisibilityLocalBounding = unit.MotionObject.LocalBounding; return unit; }