Esempio n. 1
0
void Bvh::CreateBoneMesh()
{
	m_block.Clear();

	for (BONE_ID i = 0; (unsigned)i < m_frames.size(); i++)	{
		BvhFrame& f2 = m_frames[i];
		BONE_ID pId = f2.parentId;
		if (pId < 0) {
			continue;
		}
		int depth = GetDepth(pId);
		BvhFrame& f1 = m_frames[pId];
		Vec3 v1 = f1.offsetCombined;
		Vec3 v2 = f2.offsetCombined;

		static const uint32_t depthToColor[] = {
			0xffffffff,
			0xffffff00,
			0xffff00ff,
			0xffff0000,
			0xff00ffff,
			0xff00ff00,
			0xff0000ff,
			0xff000000,
		};
		CreateCone(m_block, v1, v2, pId, depthToColor[depth % dimof(depthToColor)]);
	}

	m_block.Verify();
	m_meshRenderer.Init(m_block);

	Material mat;
	mat.faceColor.x = 0.6f;
	mat.faceColor.y = 0.6f;
	mat.faceColor.z = 0.6f;
	mat.faceColor.w = 1.0f;
	mat.power = 1.0f;
	mat.specular.x = 1.0f;
	mat.specular.y = 1.0f;
	mat.specular.z = 1.0f;
	mat.emissive.x = 0.4f;
	mat.emissive.y = 0.4f;
	mat.emissive.z = 0.4f;
	mat.texture = texMan.CreateWhiteTexture();

	MaterialMap map;
	map.materialId = matMan.Create(mat);
	map.faceStartIndex = 0;
	map.faces = m_block.indices.size() / 3;
	m_block.materialMaps.push_back(map);
}
Esempio n. 2
0
bool EpaPolyhedron::Expand( const btPoint3& wSupportPoint,
						    const btPoint3& wSupportPointOnA,
						    const btPoint3& wSupportPointOnB,
						    EpaFace* pFace, std::list< EpaFace* >& newFaces )
{
	EPA_DEBUG_ASSERT( !pFace->m_deleted ,"Face is already deleted!" );
	EPA_DEBUG_ASSERT( newFaces.empty() ,"NewFaces list must be empty!" );

	EPA_DEBUG_ASSERT( !pFace->m_deleted ,"Cannot expand deleted face!" );

	// wSupportPoint must be front of face's plane used to do the expansion

#ifdef EPA_POLYHEDRON_USE_PLANES
	btScalar dist = pFace->m_planeNormal.dot( wSupportPoint ) + pFace->m_planeDistance;
	if ( dist <= PLANE_THICKNESS )
	{
		return false;
	}
#endif

	std::list< EpaHalfEdge* > coneBaseEdges;
	DeleteVisibleFaces( wSupportPoint, pFace, coneBaseEdges );

	EPA_DEBUG_ASSERT( ( coneBaseEdges.size() >= 3 ) ,"Cone base must have at least 3 edges!" );

	EpaVertex* pConeAppex = CreateVertex( wSupportPoint, wSupportPointOnA, wSupportPointOnB );
	EPA_DEBUG_ASSERT( pConeAppex ,"Failed to create vertex!" );

	CreateCone( pConeAppex, coneBaseEdges, newFaces );

	// Initialize new faces

	std::list< EpaFace* >::iterator newFacesItr( newFaces.begin() );

	while ( newFacesItr != newFaces.end() )
	{
		EpaFace* pNewFace = *newFacesItr;

		if ( !pNewFace->Initialize() )
		{
			return false;
		}

		++newFacesItr;
	}

	return true;
}
Esempio n. 3
0
// Initialisierung des Rendering Kontextes
void SetupRC() {
	// Schwarzer Hintergrund
	glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
	// In Uhrzeigerrichtung zeigende Polygone sind die Vorderseiten.
	// Dies ist umgekehrt als bei der Default-Einstellung weil wir Triangle_Fans benützen
	glFrontFace(GL_CW);

	//initialisiert die standard shader
	shaderManager.InitializeStockShaders();
	transformPipeline.SetMatrixStacks(modelViewMatrix, projectionMatrix);

	//erzeuge die geometrie
	CreateCone(0, 0, 0);
	CreateCube(0, 0, 0);
	CreateCylinder(0, 0, 0);
	CreateSphere(0, 0, 0);

	InitGUI();
}
Esempio n. 4
0
void Draw3DArrow (const dMatrix& location, int segments, dFloat radius, dFloat height, const dVector& color)
{
#ifdef COMPILE_OPENGL
	SetMaterial (color);

	dVector points[128 * 3];  
	dVector normals[128];  
	int count = CreateCone (points, normals, segments, radius, height, 128);

	glPushMatrix();
	glMultMatrix(&location[0][0]);
	glBegin(GL_TRIANGLES);
	for (int i = 0; i < count; i ++) {
		glNormal3f(normals[i].m_x, normals[i].m_y, normals[i].m_z);
		glVertex3f(points[i * 3 + 0].m_x, points[i * 3 + 0].m_y, points[i * 3 + 0].m_z); 
		glNormal3f(normals[i].m_x, normals[i].m_y, normals[i].m_z);
		glVertex3f(points[i * 3 + 1].m_x, points[i * 3 + 1].m_y, points[i * 3 + 1].m_z); 
		glNormal3f(normals[i].m_x, normals[i].m_y, normals[i].m_z);
		glVertex3f(points[i * 3 + 2].m_x, points[i * 3 + 2].m_y, points[i * 3 + 2].m_z); 
	}
	glEnd();
	glPopMatrix();
#endif
}