Exemple #1
0
        public PhysicsShape(PhysX.Geometry primitive, ShapeType shapeType, ulong meshHash)
        {
            this.AssignGeom(primitive, shapeType);

            _shapeType = shapeType;
            _shapeHash = meshHash;
        }
 private Tuple <PhysX.Geometry, ShapeType> GenerateBasicPhysXShape(PrimitiveBaseShape primitiveBaseShape)
 {
     if (primitiveBaseShape.ProfileShape == ProfileShape.HalfCircle)
     {
         //this is a sphere
         PhysX.Geometry geom = this.GeneratePhysXSphereShape(primitiveBaseShape);
         return(new Tuple <PhysX.Geometry, ShapeType>(geom, ShapeType.PrimitiveSphere));
     }
     else
     {
         //this is a box
         PhysX.Geometry geom = this.GeneratePhysXBoxShape(primitiveBaseShape);
         return(new Tuple <PhysX.Geometry, ShapeType>(geom, ShapeType.PrimitiveBox));
     }
 }
Exemple #3
0
        private void AssignGeom(PhysX.Geometry primitive, ShapeType shapeType)
        {
            switch (shapeType)
            {
            case ShapeType.PrimitiveBox:
            case ShapeType.PrimitiveSphere:
                _primitiveGeom = primitive;
                break;

            case ShapeType.TriMesh:
                _triMesh = (PhysX.TriangleMeshGeometry)primitive;
                break;
            }

            Complexity = 1;
        }
Exemple #4
0
            private void GenerateTrimeshAndComplete(MeshingStage meshingStage, ulong meshHash)
            {
                PhysicsShape phyShape;

                PhysX.TriangleMeshGeometry triMesh = meshingStage.GeneratePhysXTrimeshShape(PrimName, Shape, Size, MeshingStage.SCULPT_MESH_LOD, IsDynamic);

                if (triMesh == null)
                {
                    //meshing  or one of its prereq steps failed, generate a bounding box
                    PhysX.Geometry geom = meshingStage.GeneratePhysXBoxShape(Shape);
                    //basic shapes are not cached
                    phyShape = new PhysicsShape(geom, ShapeType.PrimitiveBox, meshHash);
                }
                else
                {
                    phyShape = CreatePhysicsShapeFromTrimeshAndCache(meshingStage, meshHash, triMesh);
                }

                //we are done here, call back to caller
                this.CompletedDelegate(phyShape);
            }
Exemple #5
0
            private void GenerateConvexSetAndComplete(MeshingStage meshingStage, ulong meshHash)
            {
                PhysicsShape phyShape;

                //we need to mesh this object into convex hulls appropriate for dynamic objects
                List <PhysX.ConvexMeshGeometry> convexes = meshingStage.GenerateComplexPhysXShape(meshHash, PrimName, Shape, Size, MeshingStage.SCULPT_MESH_LOD, IsDynamic);

                if (convexes == null)
                {
                    //meshing  or one of its prereq steps failed, generate a bounding box
                    PhysX.Geometry geom = meshingStage.GeneratePhysXBoxShape(Shape);
                    //basic shapes are not cached
                    phyShape = new PhysicsShape(geom, ShapeType.PrimitiveBox, meshHash);
                }
                else
                {
                    phyShape = CreatePhysicsShapeFromConvexSetAndCache(meshingStage, meshHash, convexes);
                }

                //we are done here, call back to caller
                this.CompletedDelegate(phyShape);
            }
 /// <summary>
 /// A convenience/backwards-compatability method.
 /// </summary>
 public static Shape CreateShape(this RigidActor actor, PhysX.Geometry geometry, Material material)
 {
     return(RigidActorExt.CreateExclusiveShape(actor, geometry, material));
 }
Exemple #7
0
        private void AssignGeom(PhysX.Geometry primitive, ShapeType shapeType)
        {
            switch (shapeType)
            {
                case ShapeType.PrimitiveBox:
                case ShapeType.PrimitiveSphere:
                    _primitiveGeom = primitive;
                    break;

                case ShapeType.TriMesh:
                    _triMesh = (PhysX.TriangleMeshGeometry)primitive;
                    break;
            }

            Complexity = 1;
        }