private MotionEntity CreateNPC(Vector2 position) { Vector3 translation = new Vector3(position, 3); var npc = new MotionEntity { MainGraphic = new MetaModel { SkinnedMesh = new SkinnedMeshFromFile("Models/Units/Zombie1.x"), Texture = new TextureFromFile("Models/Units/Zombie1.png"), World = SkinnedMesh.InitSkinnedMeshFromMaya * Matrix.Scaling(0.1f, 0.1f, 0.1f), IsBillboard = false, }, Translation = translation }; var mo = motionSimulation.CreateNPC(); mo.LocalBounding = new Common.Bounding.Cylinder(Vector3.Zero, 1f, 0.5f); mo.Position = translation; mo.SteeringEnabled = true; mo.RunSpeed = 2f; npc.MotionObject = mo; npc.VisibilityLocalBounding = CreateBoundingBoxFromModel((MetaModel)npc.MainGraphic); Graphics.Renderer.Renderer.EntityAnimation ea = scene.View.Content.Peek <Graphics.Renderer.Renderer.EntityAnimation>(npc.MetaEntityAnimation); ea.PlayAnimation(new AnimationPlayParameters("Idle1", true)); return(npc); }
private void AddCreatedGridEvent(MotionEntity unit) { if (motionSimulation is Common.Motion.ThreadSimulationProxy) { ((Common.Motion.NPC)((Common.Motion.ThreadNPCProxy)unit.MotionObject).GetInnerObject()).DebugCreatedGrid += new EventHandler <Common.Motion.NPC.DebugGridCreatedEventArgs>(PathingView_CreatedGrid); } else { ((Common.Motion.NPC)unit.MotionObject).DebugCreatedGrid += new EventHandler <Common.Motion.NPC.DebugGridCreatedEventArgs>(PathingView_CreatedGrid); } }
public 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 = Vector3.Zero, Max = new Vector3(boxSize.X, boxSize.Y, boxSize.Z) }, Layout = Graphics.Software.Vertex.PositionNormalTexcoord.Instance }, Texture = new TextureFromFile(textureFilename), }, Translation = position }; var mo = motionSimulation.CreateStatic(); mo.Position = position; mo.LocalBounding = new Common.Bounding.Chain { Shallow = true, Boundings = new object[] { new Graphics.MetaBoundingBox { Mesh = ((MetaModel)block.MainGraphic).XMesh }, new Graphics.BoundingMetaMesh { Mesh = ((MetaModel)block.MainGraphic).XMesh } } }; block.MotionObject = mo; return(block); }