Exemplo n.º 1
0
		LinearBlendMeshTetra (DemoEntityManager* const scene, NewtonMesh* const skinMesh, NewtonBody* const body)
			:DemoMesh(skinMesh, scene->GetShaderCache())
			,m_body (body)
			,m_weightSet(NULL)
		{
			ResetOptimization();
			dAssert (0);
/*
			NewtonCollision* const deformableCollision = NewtonBodyGetCollision(m_body);

			int skinPointCount = NewtonMeshGetPointCount(skinMesh);
			const int* const deformableIndexMap = NewtonDeformableMeshGetIndexToVertexMap(deformableCollision);

			int weightIndex[16];
			dFloat weightValue[16];
			m_weightSet = new WeightIndexPair[skinPointCount];
			for (int i = 0; i < skinPointCount; i++) {
				int weightCount = NewtonMeshGetVertexWeights(skinMesh, i, weightIndex, weightValue);
				for (int k = 0; k < weightCount; k ++) {
					m_weightSet[i].m_index[k] = deformableIndexMap[weightIndex[k]];
					m_weightSet[i].m_weight[k] = weightValue[k];
				}
			}
*/
		}
Exemplo n.º 2
0
DemoMesh::~DemoMesh()
{
	if (m_vertex) {
		delete[] m_vertex;
		delete[] m_normal;
		delete[] m_uv;
		ResetOptimization();
	}
}
Exemplo n.º 3
0
		ClothPatchMesh(DemoEntityManager* const scene, NewtonMesh* const clothPatchMesh, NewtonBody* const body)
			:DemoMesh(clothPatchMesh, scene->GetShaderCache())
			,m_body(body)
		{
			ResetOptimization();
			//NewtonCollision* const deformableCollision = NewtonBodyGetCollision(m_body);

			int pointCount = NewtonMeshGetPointCount(clothPatchMesh);
			const int* const indexMap = NewtonMeshGetIndexToVertexMap(clothPatchMesh);
			m_indexMap = new int[pointCount];
			for (int i = 0; i < pointCount; i++) {
				int j = indexMap[i];
				m_indexMap[i] = j;
			}
		}
Exemplo n.º 4
0
		TetrahedraSoftMesh (DemoEntityManager* const scene, NewtonMesh* const tetrahedraMesh, NewtonBody* const body)
			:DemoMesh(tetrahedraMesh, scene->GetShaderCache())
			,m_body (body)
		{
			ResetOptimization();
			
dAssert (0);
/*
			NewtonCollision* const deformableCollision = NewtonBodyGetCollision(m_body);
			int pointCount = NewtonMeshGetPointCount(tetrahedraMesh);
			const int* const indexMap = NewtonMeshGetIndexToVertexMap(tetrahedraMesh);
			const int* const solidIndexList = NewtonDeformableMeshGetIndexToVertexMap(deformableCollision);

			m_indexMap = new int[pointCount];
			for (int i = 0; i < pointCount; i++) {
				int j = indexMap[i];
				m_indexMap[i] = solidIndexList[j];
			}
*/
		}
Exemplo n.º 5
0
void  DemoMesh::OptimizeForRender()
{
	// first make sure the previous optimization is removed
	ResetOptimization();

	dListNode* nextNode;
	for (dListNode* node = GetFirst(); node; node = nextNode) {
		DemoSubMesh& segment = node->GetInfo();
		nextNode = node->GetNext();
		if (segment.m_indexCount > 128 * 128 * 6) {
			SpliteSegment(node, 128 * 128 * 6);
		}
	}

#ifdef USING_DISPLAY_LIST
	bool isOpaque = false;
	bool hasTranparency = false;

	for (dListNode* node = GetFirst(); node; node = node->GetNext()) {
		DemoSubMesh& segment = node->GetInfo();
		isOpaque |= segment.m_opacity > 0.999f;
		hasTranparency |= segment.m_opacity <= 0.999f;
	}

	if (isOpaque) {
		m_optimizedOpaqueDiplayList = glGenLists(1);

		glNewList(m_optimizedOpaqueDiplayList, GL_COMPILE);

		//glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );

		for (dListNode* node = GetFirst(); node; node = node->GetNext()) {
			DemoSubMesh& segment = node->GetInfo();
			if (segment.m_opacity > 0.999f) {
				segment.OptimizeForRender(this);
			}
		}
		glEndList();
	}

	if (hasTranparency) {
        m_optimizedTransparentDiplayList = glGenLists(1);

        glNewList(m_optimizedTransparentDiplayList, GL_COMPILE);
        //glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );

		glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
		glEnable (GL_BLEND);
		glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        for (dListNode* node = GetFirst(); node; node = node->GetNext()) {
            DemoSubMesh& segment = node->GetInfo();
            if (segment.m_opacity <= 0.999f) {
                segment.OptimizeForRender(this);
            }
        }
		glDisable(GL_BLEND);
		glLoadIdentity();
        glEndList();
	}
#endif
}