| 1284 | } |
| 1285 | |
| 1286 | void 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 |
no test coverage detected