2
0
marauder2k7 1 жил өмнө
parent
commit
25d6ee5372

+ 2 - 4
Engine/source/T3D/groundPlane.cpp

@@ -299,10 +299,8 @@ void GroundPlane::buildConvex( const Box3F& box, Convex* convex )
    {
       Point3F queryCenter = box.getCenter();
 
-      planeConvex->mCenter      = Point3F( queryCenter.x, queryCenter.y, 0 );
-      planeConvex->mSize        = Point3F( box.getExtents().x,
-                                         box.getExtents().y,
-                                         0 );
+      planeConvex->mCenter = Point3F( queryCenter.x, queryCenter.y, 0 );
+      planeConvex->mSize   = Point3F( box.getExtents().x, box.getExtents().y, 0 );
    }
 }
 

+ 28 - 3
Engine/source/collision/concretePolyList.cpp

@@ -150,13 +150,13 @@ void ConcretePolyList::render()
    GFXStateBlockRef sb = GFX->createStateBlock( solidZDisable );
    GFX->setStateBlock( sb );
 
-   PrimBuild::color3i( 255, 0, 255 );
-
    Poly *p;
    Point3F *pnt;
 
    for ( p = mPolyList.begin(); p < mPolyList.end(); p++ )
    {
+      PrimBuild::color3i(255, 0, 255);
+
       PrimBuild::begin( GFXLineStrip, p->vertexCount + 1 );      
 
       for ( U32 i = 0; i < p->vertexCount; i++ )
@@ -169,6 +169,31 @@ void ConcretePolyList::render()
       PrimBuild::vertex3fv( pnt );
 
       PrimBuild::end();
+
+      // Calculate the center of the polygon
+      Point3F centroid(0, 0, 0);
+      for (U32 i = 0; i < p->vertexCount; i++)
+      {
+         pnt = &mVertexList[mIndexList[p->vertexStart + i]];
+         centroid += *pnt;
+      }
+      centroid /= p->vertexCount;
+
+      // Calculate the end point of the normal line
+      Point3F norm = p->plane.getNormal();
+
+      U8 red = static_cast<U8>((norm.x + 1.0f) * 0.5f * 255);
+      U8 green = static_cast<U8>((norm.y + 1.0f) * 0.5f * 255);
+      U8 blue = static_cast<U8>((norm.z + 1.0f) * 0.5f * 255);
+
+      PrimBuild::color3i(red, green, blue);
+      Point3F normalEnd = centroid + norm;
+
+      // Draw the normal line
+      PrimBuild::begin(GFXLineList, 2);
+      PrimBuild::vertex3fv(centroid);
+      PrimBuild::vertex3fv(normalEnd);
+      PrimBuild::end();
    }   
 }
 
@@ -220,4 +245,4 @@ void ConcretePolyList::triangulate()
 
    mPolyList = polyList;
    mIndexList = indexList;
-}
+}