void DebugDrawer::buildQuad(const Ogre::Vector3 *vertices, const Ogre::ColourValue& colour, float alpha) { int index = addLineVertex(vertices[0], Ogre::ColourValue(colour.r, colour.g, colour.b, alpha)); addLineVertex(vertices[1], Ogre::ColourValue(colour.r, colour.g, colour.b, alpha)); addLineVertex(vertices[2], Ogre::ColourValue(colour.r, colour.g, colour.b, alpha)); addLineVertex(vertices[3], Ogre::ColourValue(colour.r, colour.g, colour.b, alpha)); for (int i = 0; i < 4; ++i) addLineIndices(index + i, index + ((i + 1) % 4)); }
void DebugDrawer::buildLine( const Ogre::Vector3& start, const Ogre::Vector3& end, const Ogre::ColourValue& colour, float alpha) { const int i = addLineVertex( start, Ogre::ColourValue(colour.r, colour.g, colour.b, alpha)); addLineVertex(end, Ogre::ColourValue(colour.r, colour.g, colour.b, alpha)); addLineIndices(i, i + 1); }
void DebugDrawer::buildCuboid(const Ogre::Vector3 *vertices, const Ogre::ColourValue& colour, float alpha) { int index = addLineVertex(vertices[0], Ogre::ColourValue(colour.r, colour.g, colour.b, alpha)); for (int i = 1; i < 8; ++i) addLineVertex(vertices[i], Ogre::ColourValue(colour.r, colour.g, colour.b, alpha)); for (int i = 0; i < 4; ++i) addLineIndices(index + i, index + ((i + 1) % 4)); for (int i = 4; i < 8; ++i) addLineIndices(index + i, i == 7 ? index + 4 : index + i + 1); addLineIndices(index + 1, index + 5); addLineIndices(index + 2, index + 4); addLineIndices(index, index + 6); addLineIndices(index + 3, index + 7); }
void DebugDrawer::buildCylinder(const Ogre::Vector3 ¢re, float radius, int segmentsCount, float height, const Ogre::ColourValue& colour, float alpha) { int index = linesIndex; float increment = 2 * Ogre::Math::PI / segmentsCount; float angle = 0.0f; // Top circle for (int i = 0; i < segmentsCount; i++) { addLineVertex(Ogre::Vector3(centre.x + radius * Ogre::Math::Cos(angle), centre.y + height / 2, centre.z + radius * Ogre::Math::Sin(angle)), Ogre::ColourValue(colour.r, colour.g, colour.b, alpha)); angle += increment; } angle = 0.0f; // Bottom circle for (int i = 0; i < segmentsCount; i++) { addLineVertex(Ogre::Vector3(centre.x + radius * Ogre::Math::Cos(angle), centre.y - height / 2, centre.z + radius * Ogre::Math::Sin(angle)), Ogre::ColourValue(colour.r, colour.g, colour.b, alpha)); angle += increment; } for (int i = 0; i < segmentsCount; i++) { addLineIndices(index + i, i + 1 < segmentsCount ? index + i + 1 : index); addLineIndices(segmentsCount + index + i, i + 1 < segmentsCount ? segmentsCount + index + i + 1 : segmentsCount + index); addLineIndices(index + i, segmentsCount + index + i); } }
void DebugDrawer::buildCircle(const Ogre::Vector3 ¢re, float radius, int segmentsCount, const Ogre::ColourValue& colour, float alpha) { int index = linesIndex; float increment = 2 * Ogre::Math::PI / segmentsCount; float angle = 0.0f; for (int i = 0; i < segmentsCount; i++) { addLineVertex(Ogre::Vector3(centre.x + radius * Ogre::Math::Cos(angle), centre.y, centre.z + radius * Ogre::Math::Sin(angle)), Ogre::ColourValue(colour.r, colour.g, colour.b, alpha)); angle += increment; } for (int i = 0; i < segmentsCount; i++) addLineIndices(index + i, i + 1 < segmentsCount ? index + i + 1 : index); }