MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / drawCone

Method drawCone

Engine/source/gfx/gfxDrawUtil.cpp:1286–1354  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1284}
1285
1286void GFXDrawUtil::drawCone( const GFXStateBlockDesc &desc, const Point3F &basePnt, const Point3F &tipPnt, F32 baseRadius, const ColorI &color )
1287{
1288 VectorF uvec = tipPnt - basePnt;
1289 F32 height = uvec.len();
1290 uvec.normalize();
1291 MatrixF mat( true );
1292 MathUtils::getMatrixFromUpVector( uvec, &mat );
1293 mat.setPosition(basePnt);
1294
1295 Point3F scale( baseRadius, baseRadius, height );
1296 mat.scale(scale);
1297
1298 GFXTransformSaver saver;
1299
1300 mDevice->pushWorldMatrix();
1301 mDevice->multWorld(mat);
1302
1303 S32 numPoints = sizeof(circlePoints)/sizeof(Point2F);
1304 GFXVertexBufferHandle<GFXVertexPCT> verts(mDevice, numPoints * 3 + 2, GFXBufferTypeVolatile);
1305 verts.lock();
1306 F32 sign = -1.f;
1307 S32 indexDown = 0; //counting down from numPoints
1308 S32 indexUp = 0; //counting up from 0
1309 S32 index = 0; //circlePoints index for cap
1310
1311 for (S32 i = 0; i < numPoints + 1; i++)
1312 {
1313 //Top cap
1314 if (i != numPoints)
1315 {
1316 if (sign < 0)
1317 index = indexDown;
1318 else
1319 index = indexUp;
1320
1321 verts[i].point = Point3F(circlePoints[index].x, circlePoints[index].y, 0);
1322 verts[i].color = color;
1323
1324 if (sign < 0)
1325 indexUp += 1;
1326 else
1327 indexDown = numPoints - indexUp;
1328
1329 // invert sign
1330 sign *= -1.0f;
1331 }
1332
1333 //cone
1334 S32 imod = i % numPoints;
1335 S32 vertindex = 2 * i + numPoints;
1336 verts[vertindex].point = Point3F(circlePoints[imod].x, circlePoints[imod].y, 0);
1337 verts[vertindex].color = color;
1338 verts[vertindex + 1].point = Point3F(0.0f, 0.0f, 1.0f);
1339 verts[vertindex + 1].color = color;
1340 }
1341
1342 verts.unlock();
1343

Callers 2

renderMethod · 0.45
_renderVizMethod · 0.45

Calls 15

getMatrixFromUpVectorFunction · 0.85
pushWorldMatrixMethod · 0.80
multWorldMethod · 0.80
setStateBlockByDescMethod · 0.80
setVertexBufferMethod · 0.80
popWorldMatrixMethod · 0.80
Point3FClass · 0.50
lenMethod · 0.45
normalizeMethod · 0.45
setPositionMethod · 0.45
scaleMethod · 0.45
lockMethod · 0.45

Tested by

no test coverage detected