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 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 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()); }
public void CreateMesh(Scene.Entity3D ent) { System.Collections.Generic.List <OpenTK.Vector3> verts = ent.GetAllVerts; System.Numerics.Vector3[] rvert = new System.Numerics.Vector3[verts.Count]; int vi = 0; foreach (OpenTK.Vector3 v in verts) { rvert [vi] = new System.Numerics.Vector3(v.X, v.Y, v.Z); vi++; } int[] tris = new int[verts.Count]; for (int i = 0; i < tris.Length; i++) { tris [i] = i; } TriangleMeshDesc tm = new TriangleMeshDesc() { Flags = 0, Triangles = tris, Points = rvert }; Cooking cook = PhysicsManager.py.CreateCooking(); MemoryStream str = new MemoryStream(); TriangleMeshCookingResult cookr = cook.CookTriangleMesh(tm, str); str.Position = 0; TriangleMesh trim = PhysicsManager.py.CreateTriangleMesh(str); TriangleMeshGeometry trig = new TriangleMeshGeometry(trim); RID = PhysicsManager.py.CreateRigidStatic( ); RID.CreateShape(trig, Mat); float m11 = ent.World.M11; float m12 = ent.World.M12; float m13 = ent.World.M13; float m14 = ent.World.M14; float m21 = ent.World.M21; float m22 = ent.World.M22; float m23 = ent.World.M23; float m24 = ent.World.M24; float m31 = ent.World.M31; float m32 = ent.World.M32; float m33 = ent.World.M33; float m34 = ent.World.M34; float m41 = ent.World.M41; float m42 = ent.World.M42; float m43 = ent.World.M43; float m44 = ent.World.M44; System.Numerics.Matrix4x4 tp = new System.Numerics.Matrix4x4(m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44); // RID.GlobalPose = System.Numerics.Matrix4x4.CreateRotationX(-(float)System.Math.PI / 2); //RID.GlobalPosePosition = ent.LocalPos; PhysicsManager.Scene.AddActor(RID); }
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()); }