Example #1
0
Vectormath::Aos::Vector3
Md3Model::getLocalOrigin()
{
	// if there is a problem... delete it :)
	Vectormath::Aos::Vector3 origin;
	origin.setX(frame.local_origin[0]);
	origin.setY(frame.local_origin[1]);
	origin.setZ(frame.local_origin[2]);
	return origin;
}
/*
 * Draw the half half points, these are not stored so they will be calculated every frame.
 * For debugging
 */
void ModelViewer::drawHalfPoints()
{
	for(unsigned int i=1;i<edges.size();i++)
	{
		Vectormath::Aos::Vector3 halfPoint = findHalfPointUsingFace(i);
		glPushMatrix();
			glTranslatef(halfPoint.getX(),halfPoint.getY(),halfPoint.getZ());
			glColor3f(0.0,1.0,0.0);
			gluSphere(gluNewQuadric(),0.01,32,32);
			glPopMatrix();
	}
}
Example #3
0
void btSoftBodySolverOutputCPUtoCPU::copySoftBodyToVertexBuffer( const btSoftBody * const softBody, btVertexBufferDescriptor *vertexBuffer )
{
	// Currently only support CPU output buffers
	
	const btSoftBodySolver *solver = softBody->getSoftBodySolver();
	btAssert( solver->getSolverType() == btSoftBodySolver::CPU_SOLVER );
	const btCPUSoftBodySolver *cpuSolver = static_cast< const btCPUSoftBodySolver * >( solver );
	const btCPUSoftBodySolver::btAcceleratedSoftBodyInterface * const currentCloth = cpuSolver->findSoftBodyInterface( softBody );
	const btSoftBodyVertexData &vertexData( cpuSolver->m_vertexData );

	if( vertexBuffer->getBufferType() == btVertexBufferDescriptor::CPU_BUFFER )
	{		
		const int firstVertex = currentCloth->getFirstVertex();
		const int lastVertex = firstVertex + currentCloth->getNumVertices();
		const btCPUVertexBufferDescriptor *cpuVertexBuffer = static_cast< btCPUVertexBufferDescriptor* >(vertexBuffer);						
		float *basePointer = cpuVertexBuffer->getBasePointer();						

		if( vertexBuffer->hasVertexPositions() )
		{
			const int vertexOffset = cpuVertexBuffer->getVertexOffset();
			const int vertexStride = cpuVertexBuffer->getVertexStride();
			float *vertexPointer = basePointer + vertexOffset;

			for( int vertexIndex = firstVertex; vertexIndex < lastVertex; ++vertexIndex )
			{
				Vectormath::Aos::Point3 position = vertexData.getPosition(vertexIndex);
				*(vertexPointer + 0) = position.getX();
				*(vertexPointer + 1) = position.getY();
				*(vertexPointer + 2) = position.getZ();
				vertexPointer += vertexStride;
			}
		}
		if( vertexBuffer->hasNormals() )
		{
			const int normalOffset = cpuVertexBuffer->getNormalOffset();
			const int normalStride = cpuVertexBuffer->getNormalStride();
			float *normalPointer = basePointer + normalOffset;

			for( int vertexIndex = firstVertex; vertexIndex < lastVertex; ++vertexIndex )
			{
				Vectormath::Aos::Vector3 normal = vertexData.getNormal(vertexIndex);
				*(normalPointer + 0) = normal.getX();
				*(normalPointer + 1) = normal.getY();
				*(normalPointer + 2) = normal.getZ();
				normalPointer += normalStride;
			}
		}
	} else {
		btAssert( 0=="Invalid vertex buffer descriptor used in CPU output." );
	}
} // btCPUSoftBodySolver::outputToVertexBuffers