public PhysxTriangleMesh(PhysxPhysicWorld PhysxPhysicWorld, IModelo model,Microsoft.Xna.Framework.Matrix localTransformation, Microsoft.Xna.Framework.Matrix worldTransformation, Microsoft.Xna.Framework.Vector3 scale, MaterialDescription MaterialDescription) { Microsoft.Xna.Framework.Vector3[] vertices = null; int[] indices = null; ExtractData(ref vertices, ref indices, model); TriangleMeshDesc meshDesc = new TriangleMeshDesc(); Vector3[] points = new Vector3[vertices.Count()]; for (int i = 0; i < vertices.Count(); i++) { points[i] = vertices[i].AsPhysX(); } meshDesc.Points = points; meshDesc.SetTriangles<int>(indices); //meshDesc.Triangles = indices; MemoryStream ms = new MemoryStream(); if(PhysxPhysicWorld.Cooking.CookTriangleMesh(meshDesc,ms)==false) { PloobsEngine.Engine.Logger.ActiveLogger.LogMessage("Cant Cook Model",Engine.Logger.LogLevel.FatalError); } ms.Position = 0; TriangleMesh triangleMesh = PhysxPhysicWorld.Physix.CreateTriangleMesh(ms); staticActor = PhysxPhysicWorld.Physix.CreateRigidStatic(worldTransformation.AsPhysX()); TriangleMeshGeometry TriangleMeshGeometry = new TriangleMeshGeometry(triangleMesh,new MeshScale(scale.AsPhysX(),Quaternion.Identity)); material = PhysxPhysicWorld.Physix.CreateMaterial(MaterialDescription.StaticFriction, MaterialDescription.DynamicFriction, MaterialDescription.Bounciness); aTriMeshShape = staticActor.CreateShape(TriangleMeshGeometry, material, localTransformation.AsPhysX()); this.Scale = scale; }
public PhysxTriangleMesh(PhysxPhysicWorld PhysxPhysicWorld, FileStream FileStream, Microsoft.Xna.Framework.Matrix localTransformation, Microsoft.Xna.Framework.Matrix worldTransformation, Microsoft.Xna.Framework.Vector3 scale, MaterialDescription MaterialDescription) { TriangleMesh triangleMesh = PhysxPhysicWorld.Physix.CreateTriangleMesh(FileStream); staticActor = PhysxPhysicWorld.Physix.CreateRigidStatic(worldTransformation.AsPhysX()); TriangleMeshGeometry TriangleMeshGeometry = new TriangleMeshGeometry(triangleMesh, new MeshScale(scale.AsPhysX(), Quaternion.Identity)); material = PhysxPhysicWorld.Physix.CreateMaterial(MaterialDescription.StaticFriction, MaterialDescription.DynamicFriction, MaterialDescription.Bounciness); aTriMeshShape = staticActor.CreateShape(TriangleMeshGeometry, material, localTransformation.AsPhysX()); this.Scale = scale; }
public PhysxStaticActor(PhysxPhysicWorld PhysxPhysicWorld ,Geometry geometry, Microsoft.Xna.Framework.Matrix localTransformation, Microsoft.Xna.Framework.Matrix worldTransformation, Microsoft.Xna.Framework.Vector3 scale, MaterialDescription MaterialDescription) { staticActor = PhysxPhysicWorld.Physix.CreateRigidStatic(worldTransformation.AsPhysX()); material = PhysxPhysicWorld.Physix.CreateMaterial(MaterialDescription.StaticFriction, MaterialDescription.DynamicFriction, MaterialDescription.Bounciness); Shape aTriMeshShape = staticActor.CreateShape(geometry, material, localTransformation.AsPhysX()); }