mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 15:44:36 +00:00
wireframe capsule set to the contents of the solid capsule for corrections and backwards compatibility
This commit is contained in:
parent
110d815b39
commit
46624cc95a
1 changed files with 41 additions and 23 deletions
|
|
@ -1202,43 +1202,61 @@ void GFXDrawUtil::_drawSolidCapsule( const GFXStateBlockDesc &desc, const Point3
|
||||||
void GFXDrawUtil::_drawWireCapsule( const GFXStateBlockDesc &desc, const Point3F ¢er, F32 radius, F32 height, const ColorI &color, const MatrixF *xfm )
|
void GFXDrawUtil::_drawWireCapsule( const GFXStateBlockDesc &desc, const Point3F ¢er, F32 radius, F32 height, const ColorI &color, const MatrixF *xfm )
|
||||||
{
|
{
|
||||||
MatrixF mat;
|
MatrixF mat;
|
||||||
if ( xfm )
|
if (xfm)
|
||||||
mat = *xfm;
|
mat = *xfm;
|
||||||
else
|
else
|
||||||
mat = MatrixF::Identity;
|
mat = MatrixF::Identity;
|
||||||
|
|
||||||
mat.scale( Point3F(radius,radius,height*0.5f) );
|
S32 numPoints = sizeof(circlePoints) / sizeof(Point2F);
|
||||||
mat.setPosition(center);
|
GFXVertexBufferHandle<GFXVertexPCT> verts(mDevice, numPoints * 2 + 2, GFXBufferTypeVolatile);
|
||||||
mDevice->pushWorldMatrix();
|
|
||||||
mDevice->multWorld(mat);
|
|
||||||
|
|
||||||
S32 numPoints = sizeof(circlePoints)/sizeof(Point2F);
|
|
||||||
GFXVertexBufferHandle<GFXVertexPCT> verts(mDevice, numPoints, GFXBufferTypeVolatile);
|
|
||||||
verts.lock();
|
verts.lock();
|
||||||
for (S32 i=0; i< numPoints; i++)
|
for (S32 i = 0; i < numPoints + 1; i++)
|
||||||
{
|
{
|
||||||
S32 idx = i & (~1); // just draw the even ones
|
S32 imod = i % numPoints;
|
||||||
F32 z = i & 1 ? 1.0f : -1.0f;
|
verts[2 * i].point = Point3F(circlePoints[imod].x * radius, circlePoints[imod].y * radius, height / 2);
|
||||||
verts[i].point = Point3F(circlePoints[idx].x,circlePoints[idx].y, z);
|
verts[2 * i].color = color;
|
||||||
verts[i].color = color;
|
verts[2 * i + 1].point = Point3F(circlePoints[imod].x * radius, circlePoints[imod].y * radius, -height / 2);
|
||||||
|
verts[2 * i + 1].color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
S32 totalNumPnts = numPoints * 2 + 2;
|
||||||
|
|
||||||
|
// Apply xfm if we were passed one.
|
||||||
|
for (U32 i = 0; i < totalNumPnts; i++)
|
||||||
|
mat.mulV(verts[i].point);
|
||||||
|
|
||||||
|
// Apply position offset
|
||||||
|
for (U32 i = 0; i < totalNumPnts; i++)
|
||||||
|
verts[i].point += center;
|
||||||
|
|
||||||
verts.unlock();
|
verts.unlock();
|
||||||
|
|
||||||
mDevice->setStateBlockByDesc( desc );
|
mDevice->setStateBlockByDesc(desc);
|
||||||
|
|
||||||
mDevice->setVertexBuffer( verts );
|
mDevice->setVertexBuffer(verts);
|
||||||
mDevice->setupGenericShaders();
|
mDevice->setupGenericShaders();
|
||||||
|
|
||||||
for (S32 i=0; i<numPoints; i += 2)
|
mDevice->drawPrimitive(GFXTriangleStrip, 0, 2 * numPoints);
|
||||||
mDevice->drawPrimitive(GFXLineStrip, i, 1);
|
|
||||||
|
|
||||||
mDevice->popWorldMatrix();
|
|
||||||
|
|
||||||
Point3F sphereCenter;
|
Point3F sphereCenter;
|
||||||
sphereCenter.z = center.z + 0.5f * height;
|
MatrixF sphereMat;
|
||||||
drawSphere( desc, radius,sphereCenter,color,true,false);
|
|
||||||
sphereCenter.z = center.z - 0.5f * height;
|
if (xfm)
|
||||||
drawSphere( desc, radius,sphereCenter,color,false,true);
|
sphereMat = *xfm;
|
||||||
|
else
|
||||||
|
sphereMat = MatrixF::Identity;
|
||||||
|
|
||||||
|
sphereCenter.set(0, 0, 0.5f * height);
|
||||||
|
mat.mulV(sphereCenter);
|
||||||
|
sphereCenter += center;
|
||||||
|
|
||||||
|
drawSphere(desc, radius, sphereCenter, color, true, false, &sphereMat);
|
||||||
|
|
||||||
|
sphereCenter.set(0, 0, -0.5f * height);
|
||||||
|
mat.mulV(sphereCenter);
|
||||||
|
sphereCenter += center;
|
||||||
|
|
||||||
|
drawSphere(desc, radius, sphereCenter, color, false, true, &sphereMat);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GFXDrawUtil::drawCone( const GFXStateBlockDesc &desc, const Point3F &basePnt, const Point3F &tipPnt, F32 baseRadius, const ColorI &color )
|
void GFXDrawUtil::drawCone( const GFXStateBlockDesc &desc, const Point3F &basePnt, const Point3F &tipPnt, F32 baseRadius, const ColorI &color )
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue