GeometryBufferPtr Gizmo::generateLines() { static const float OriginOffset = 0.01f; // Create a new VBO and upload triangle data GeometryBufferPtr gb = AllocateThis(GeometryBuffer); // Vertex position data std::vector< Vector3 > pos; // X axis pos.push_back( Vector3::Zero ); pos.push_back( Vector3::UnitX / 2.0f ); // Y axis pos.push_back( Vector3::UnitY*OriginOffset ); pos.push_back( Vector3::UnitY / 2.0f ); // Z axis pos.push_back( Vector3::Zero ); pos.push_back( Vector3::UnitZ / 2.0f ); // Vertex color data std::vector< Vector3 > colors; generateLinesColors(colors); // Vertex buffer setup gb->set( VertexAttribute::Position, pos ); gb->set( VertexAttribute::Color, colors ); return gb; }
GeometryBufferPtr GizmoRotate::generateCircles() { // Vertex data std::vector< Vector3 > pos; std::vector< Vector3 > colors; Matrix4x3 transform; // X axis std::vector< Vector3 > posX; generateCircle(posX, SLICES); generateColors(colors, X); transform = Matrix4x3::createScale( Vector3(0.4f) ); TransformVertices(pos, posX, transform); // Y axis std::vector< Vector3 > posY; generateCircle(posY, SLICES); generateColors(colors, Y); transform = Matrix4x3::createScale( Vector3(0.4f) ); transform = transform*Matrix4x3::createRotation( EulerAngles(0, 90, 0) ); TransformVertices(pos, posY, transform); // Z axis std::vector< Vector3 > posZ; generateCircle(posZ, SLICES); generateColors(colors, Z); transform = Matrix4x3::createScale( Vector3(0.4f) ); transform = transform*Matrix4x3::createRotation( EulerAngles(90, 0, 0) ); TransformVertices(pos, posZ, transform); // Translate it a bit. transform = Matrix4x3::createTranslation( Vector3::UnitY * 0.5f ); for( uint i = 0; i < pos.size(); i++ ) { Vector3& v = pos[i]; v = transform*v; } // Vertex buffer setup GeometryBufferPtr gb = AllocateHeap(GeometryBuffer); assert( pos.size() == colors.size() ); gb->set( VertexAttribute::Position, pos ); gb->set( VertexAttribute::Color, colors ); return gb; }