コード例 #1
0
void DebugDrawer::buildFilledQuad(const Ogre::Vector3 *vertices,
                                  const Ogre::ColourValue& colour,
                                  float alpha)
{
    int index = addTriangleVertex(vertices[0], Ogre::ColourValue(colour.r, colour.g, colour.b, alpha));
    addTriangleVertex(vertices[1], Ogre::ColourValue(colour.r, colour.g, colour.b, alpha));
    addTriangleVertex(vertices[2], Ogre::ColourValue(colour.r, colour.g, colour.b, alpha));
    addTriangleVertex(vertices[3], Ogre::ColourValue(colour.r, colour.g, colour.b, alpha));
 
    addQuadIndices(index, index + 1, index + 2, index + 3);
}
コード例 #2
0
void DebugDrawer::buildFilledCuboid(
    const Ogre::Vector3 *vertices,
    const Ogre::ColourValue& colour,
    float alpha)
{
    const int index = addTriangleVertex(
        vertices[0],
        Ogre::ColourValue(colour.r, colour.g, colour.b, alpha));

    for (int i = 1; i < 8; ++i)
    {
        addTriangleVertex(
            vertices[i],
            Ogre::ColourValue(colour.r, colour.g, colour.b, alpha));
    }

    addQuadIndices(index,     index + 1, index + 2, index + 3);
    addQuadIndices(index + 4, index + 5, index + 6, index + 7);

    addQuadIndices(index + 1, index + 5, index + 4, index + 2);
    addQuadIndices(index,     index + 3, index + 7, index + 6);

    addQuadIndices(index + 1, index    , index + 6, index + 5);
    addQuadIndices(index + 4, index + 7, index + 3, index + 2);
}
コード例 #3
0
void DebugDrawer::buildFilledCylinder(const Ogre::Vector3 &centre,
							  float radius,
	                          int segmentsCount,
							  float height,
							  const Ogre::ColourValue& colour,
							  float alpha)
{
	int index = trianglesIndex;
	float increment = 2 * Ogre::Math::PI / segmentsCount;
	float angle = 0.0f;
 
	// Top circle
	for (int i = 0; i < segmentsCount; i++)
	{
		addTriangleVertex(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;
	}

	addTriangleVertex(Ogre::Vector3(centre.x, centre.y + height / 2, centre.z), Ogre::ColourValue(colour.r, colour.g, colour.b, alpha));

	angle = 0.0f;

	// Bottom circle
	for (int i = 0; i < segmentsCount; i++)
	{
		addTriangleVertex(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;
	}
 
	addTriangleVertex(Ogre::Vector3(centre.x, centre.y - height / 2, centre.z), Ogre::ColourValue(colour.r, colour.g, colour.b, alpha));
 
	for (int i = 0; i < segmentsCount; i++)
	{
		addTriangleIndices(i + 1 < segmentsCount ? index + i + 1 : index,
			               index + i,
						   index + segmentsCount);

		addTriangleIndices(i + 1 < segmentsCount ? (segmentsCount + 1) + index + i + 1 : (segmentsCount + 1) + index,
						   (segmentsCount + 1) + index + segmentsCount,
						   (segmentsCount + 1) + index + i);
		
		addQuadIndices(
			index + i,
			i + 1 < segmentsCount ? index + i + 1 : index,
			i + 1 < segmentsCount ? (segmentsCount + 1) + index + i + 1 : (segmentsCount + 1) + index,
			(segmentsCount + 1) + index + i);
	}
}
コード例 #4
0
size_t VertexData::addQuadAndIndices(int a, int b, int c, int d) {
	addQuadIndices(a,b,c,d);
	return addQuad(a,b,c,d);
}