Example #1
0
void CCJSPrimitiveFBX::renderVertices(const bool textured)
{
    CCRenderer::CCSetRenderStates( true );

    for( int subModelIndex=0; subModelIndex<submodels.length; ++subModelIndex )
    {
        Submodel &submodel = *submodels.list[subModelIndex];

        if( submodel.adjustedUVs != NULL )
        {
            CCSetTexCoords( submodel.adjustedUVs );
        }
        else if( submodel.modelUVs )
        {
            CCSetTexCoords( submodel.modelUVs );
        }
        GLVertexPointer( 3, GL_FLOAT, 0, submodel.skinnedVertices, submodel.vertexCount );

        if( submodel.indices != NULL )
        {
            for( int i=0; i<submodel.submeshes.length; ++i )
            {
                Submesh &submesh = *submodel.submeshes.list[i];
                gRenderer->GLDrawElements( GL_TRIANGLES, submesh.count, GL_UNSIGNED_SHORT, &submodel.indices[submesh.offset] );
            }
        }
    }
}
Example #2
0
void CCPrimitiveObj::renderVertices(const bool textured)
{
    CCSetViewMatrix();
	GLVertexPointer( 3, GL_FLOAT, 0, vertices );
    CCSetVertexAttribute( ATTRIB_NORMAL, 3, GL_FLOAT, 0, normals, true );
    CCSetTexCoords( textureUVs != NULL ? textureUVs : modelUVs );

	glDrawArrays( GL_TRIANGLES, 0, vertexCount );
}
Example #3
0
void CCPrimitiveObj::renderVertices(const bool textured)
{
    CCRenderer::CCSetRenderStates( true );

	GLVertexPointer( 3, GL_FLOAT, 0, vertices, vertexCount );
    CCSetVertexAttribute( ATTRIB_NORMAL, 3, GL_FLOAT, 0, normals, true, vertexCount );
    CCSetTexCoords( adjustedUVs != NULL ? adjustedUVs : modelUVs );

	GLDrawArrays( GL_TRIANGLES, 0, vertexCount );
}
Example #4
0
void CCRenderLine(const CCVector3 &start, const CCVector3 &end)
{
	const float vertices[] =
	{
		start.x, start.y, start.z,
		end.x, end.y, end.z,
	};
	
    CCSetViewMatrix();
	GLVertexPointer( 3, GL_FLOAT, 0, vertices );
	glDrawArrays( GL_LINES, 0, 2 );
}
Example #5
0
// Render functions
//-----------------
void CCRenderSquare(const CCPoint &start, const CCPoint &end, const bool outline)
{
#if defined PROFILEON
    CCProfiler profile( "CCRenderSquare()" );
#endif

    CCSetViewMatrix();
	if( outline )
	{
		const float vertices[] = 
		{
			start.x, start.y,	// Top left
			end.x, start.y,		// Top right
			end.x, end.y,		// Bottom right
			start.x, end.y,		// Bottom left
			start.x, start.y,	// Top left
		};
		
		// draw the square
		GLVertexPointer( 2, GL_FLOAT, 0, vertices );
		glDrawArrays( GL_LINE_STRIP, 0, 5 );
	}
	else
	{
		const float vertices[] = 
		{
			start.x, start.y,	// Top left
			end.x, start.y,		// Top right
			start.x, end.y,		// Bottom left
			end.x, end.y,		// Bottom right
		};
		
		// draw the square
		GLVertexPointer( 2, GL_FLOAT, 0, vertices );
		glDrawArrays( GL_TRIANGLE_STRIP, 0, 4 );
	}
}
Example #6
0
void CCRenderSquareYAxisAligned(const CCVector3 &start, const CCVector3 &end)
{
    const float vertices[] = 
	{
		start.x, start.y, start.z,	// Top left
		end.x, start.y, end.z,		// Top right
		start.x, end.y, start.z,	// Bottom left
		end.x, end.y, end.z,		// Bottom right
    };
	
	// draw the square
    CCSetViewMatrix();
	GLVertexPointer( 3, GL_FLOAT, 0, vertices );
	glDrawArrays( GL_TRIANGLE_STRIP, 0, 4 );
}
void CCPrimitiveSquare::renderOutline()
{
#if defined PROFILEON
	CCProfiler profile( "CCPrimitiveSquare::renderOutline()" );
#endif
    
    CCSetViewMatrix();
	GLVertexPointer( 3, GL_FLOAT, 0, vertices );
	
	static const GLubyte faces[] = 
	{
		0, 1, 3, 2, 0,
	};
	static const uint numberOfFaces = sizeof( faces ) / sizeof( GLubyte );

	glDrawElements( GL_LINE_STRIP, numberOfFaces, GL_UNSIGNED_BYTE, faces );
}
void CCPrimitiveSquare::renderVertices(const bool textured)
{	
#if defined PROFILEON
    CCProfiler profile( "CCPrimitiveSquare::renderVertices()" );
#endif

	if( customUVs != NULL )
	{
		CCSetTexCoords( customUVs->uvs );
	}
	else
	{
		CCDefaultTexCoords();
	}
	
    CCSetViewMatrix();
    GLVertexPointer( 3, GL_FLOAT, 0, vertices );
    glDrawArrays( GL_TRIANGLE_STRIP, 0, 4 );
}
Example #9
0
void CCRenderCubeMinMax(const CCVector3 min, const CCVector3 max, const bool outline)
{
	// Define the square vertices
	const float vertices[] = 
	{
		// Front
		min.x, min.y, min.z,		// Bottom left	0
		max.x, min.y, min.z,		// Bottom right	1
		min.x, max.y, min.z,		// Top Left		2
		max.x, max.y, min.z,		// Top Right	3
		
		// Back
		min.x, min.y, max.z,		// Bottom left	4
		max.x, min.y, max.z,		// Bottom right	5
		min.x, max.y, max.z,		// Top left		6
		max.x, max.y, max.z,		// Top right	7
	};
    
    CCSetViewMatrix();
	GLVertexPointer( 3, GL_FLOAT, 0, vertices );
	
	if( outline )
	{
		static const GLubyte faces[] = 
		{
			0, 1, 3, 2, 0, 4, 5, 1, 5, 7, 3, 7, 6, 2, 6, 4, 
		};
		static const uint numberOfFaces = sizeof( faces ) / sizeof( GLubyte );
		glDrawElements( GL_LINE_STRIP, numberOfFaces, GL_UNSIGNED_BYTE, faces );
	}
	else
	{
		static const GLubyte faces[] = 
		{
			0, 1, 2, 3, 7, 1, 5, 4, 7, 6, 2, 4, 0, 1,
		};
		static const uint numberOfFaces = sizeof( faces ) / sizeof( GLubyte );
		glDrawElements( GL_TRIANGLE_STRIP, numberOfFaces, GL_UNSIGNED_BYTE, faces );
	}
}
Example #10
0
void CCRenderCube(const bool outline)
{
	// Define the square vertices
	static const float vertices[] = 
	{
		// Front
		-1.0f, -1.0f, -1.0f,	// Bottom left	0
		1.0f, -1.0f, -1.0f,		// Bottom right	1
		-1.0f, 1.0f, -1.0f,		// Top Left		2
		1.0f, 1.0f, -1.0f,		// Top Right	3
		
		// Back
		-1.0f, -1.0f, 1.0f,		// Bottom left	4
		1.0f, -1.0f, 1.0f,		// Bottom right	5
		-1.0f, 1.0f, 1.0f,		// Top left		6
		1.0f, 1.0f, 1.0f,		// Top right	7
	};
    
    CCSetViewMatrix();
	GLVertexPointer( 3, GL_FLOAT, 0, vertices );
	
	if( outline )
	{
		static const GLubyte faces[] = 
		{
			0, 1, 3, 2, 0, 4, 5, 1, 5, 7, 3, 7, 6, 2, 6, 4, 
		};
		static const uint numberOfFaces = sizeof( faces ) / sizeof( GLubyte );
		glDrawElements( GL_LINE_STRIP, numberOfFaces, GL_UNSIGNED_BYTE, faces );
	}
	else
	{
		static const GLubyte faces[] = 
		{
			0, 1, 2, 3, 7, 1, 5, 4, 7, 6, 2, 4, 0, 1,
		};
		static const uint numberOfFaces = sizeof( faces ) / sizeof( GLubyte );
		glDrawElements( GL_TRIANGLE_STRIP, numberOfFaces, GL_UNSIGNED_BYTE, faces );
	}
}
Example #11
0
void CCPathFinderNetwork::view()
{
    if( nodes.length > 0 && connectingNodes == false )
    {
		gEngine->textureManager->setTextureIndex( 1 );

        const CCColour nodeColour = CCColour( 1.0f, 0.0f, 0.0f, 1.0f );
        const CCColour pathColour = CCColour( 1.0f, 1.0f, 1.0f, 1.0f );

        CCSetColour( nodeColour );

        for( int i=0; i<nodes.length; ++i )
        {
            const PathNode *node = nodes.list[i];
            GLPushMatrix();
            GLTranslatef( node->point.x, node->point.y, node->point.z );
            CCRenderCube( true );
            GLPopMatrix();
        }

        static CCVector3 start, end;
		{
            GLVertexPointer( 3, GL_FLOAT, sizeof( PathNode ), &nodes.list[0]->point, nodes.length );
#ifndef DXRENDERER
            GLDrawArrays( GL_POINTS, 0, nodes.length );
#endif

            for( int i=0; i<nodes.length; ++i )
            {
                const PathNode *node = nodes.list[i];
                const CCList<PathNode::PathConnection> &connections = node->connections;
                for( int j=0; j<connections.length; ++j )
                {
                    const PathNode::PathConnection *connection = connections.list[j];
                    start.set( node->point.x, 2.0f, node->point.z );
                    end.set( connection->node->point.x, 2.0f, connection->node->point.z );
                    CCRenderLine( start, end );
                }
            }
        }

        if( pathingFrom != NULL )
        {
            CCRenderer::CCSetDepthRead( false );

            CCSetColour( pathColour );

            const PathNode *currentNode = pathingFrom;
            for( int i=0; i<path.endDirection; ++i )
            {
                const int connectionIndex = path.directions[i];
                const CCList<PathNode::PathConnection> &connections = currentNode->connections;
                if( connectionIndex < connections.length )
                {
                    const PathNode::PathConnection *connection = connections.list[connectionIndex];
                    const PathNode *toNode = connection->node;
                    ASSERT( toNode != NULL );
                    start.set( currentNode->point.x, 5.0f, currentNode->point.z );
                    end.set( toNode->point.x, 5.0f, toNode->point.z );
                    CCRenderLine( start, end );
                    currentNode = toNode;
                }
            }

            CCRenderer::CCSetDepthRead( true );
        }
    }
}