BulletCSharp.btPolyhedralConvexShape.getConvexPolyhedron C# (CSharp) Method

getConvexPolyhedron() public method

public getConvexPolyhedron ( ) : btConvexPolyhedron
return btConvexPolyhedron
        public btConvexPolyhedron getConvexPolyhedron()
        {
            IntPtr cPtr = BulletCollisionPINVOKE.btPolyhedralConvexShape_getConvexPolyhedron(swigCPtr);
            btConvexPolyhedron ret = (cPtr == IntPtr.Zero) ? null : new btConvexPolyhedron(cPtr, false);
            return ret;
        }

Usage Example

コード例 #1
0
ファイル: BUtility.cs プロジェクト: sanglin307/BulletUnity3D
    //it is very slow, so don't use it if you don't need it indeed..
    public static void DebugDrawPolyhedron(Vector3 position,Quaternion rotation,Vector3 scale,btPolyhedralConvexShape shape,Color color)
    {
        if( shape == null )
            return;

        Matrix4x4 matrix = Matrix4x4.TRS(position,rotation,scale);
        Gizmos.color = color;
        btConvexPolyhedron poly = shape.getConvexPolyhedron();
        if( poly == null )
            return;

        int faceSize = poly.m_faces.size();
        for (int i=0;i < faceSize;i++)
        {
            Vector3 centroid = new Vector3(0,0,0);
            btFace face = poly.m_faces.at(i);
            int numVerts = face.m_indices.size();
            if (numVerts > 0)
            {
                int lastV = face.m_indices.at(numVerts-1);
                for (int v=0;v < numVerts;v++)
                {
                    int curVert = face.m_indices.at(v);
                    btVector3 curVertObject = btVector3.GetObjectFromSwigPtr(poly.m_vertices.at(curVert));
                    centroid.x += curVertObject.x();
                    centroid.y += curVertObject.y();
                    centroid.z += curVertObject.z();
                    btVector3 btv1 = btVector3.GetObjectFromSwigPtr(poly.m_vertices.at(lastV));
                    btVector3 btv2 = btVector3.GetObjectFromSwigPtr(poly.m_vertices.at(curVert));
                    Vector3 v1 = new Vector3(btv1.x(),btv1.y(),btv1.z());
                    Vector3 v2 = new Vector3(btv2.x(),btv2.y(),btv2.z());
                    v1 = matrix.MultiplyPoint(v1);
                    v2 = matrix.MultiplyPoint(v2);
                    Gizmos.DrawLine(v1,v2);
                    lastV = curVert;
                }
            }
            float s = 1.0f/numVerts;
            centroid.x *= s;
            centroid.y *= s;
            centroid.z *= s;

            //normal draw
        //            {
        //                Vector3 normalColor = new Vector3(1,1,0);
        //
        //                btVector3 faceNormal(face.m_plane[0],poly->m_faces[i].m_plane[1],poly->m_faces[i].m_plane[2]);
        //                getDebugDrawer()->drawLine(worldTransform*centroid,worldTransform*(centroid+faceNormal),normalColor);
        //            }

        }
    }