当前位置: 首页>>代码示例>>C++>>正文


C++ btHashMap类代码示例

本文整理汇总了C++中btHashMap的典型用法代码示例。如果您正苦于以下问题:C++ btHashMap类的具体用法?C++ btHashMap怎么用?C++ btHashMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了btHashMap类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: readLibraryGeometries

void readLibraryGeometries(TiXmlDocument& doc, btAlignedObjectArray<GLInstanceGraphicsShape>& visualShapes, btHashMap<btHashString,int>& name2Shape, float extraScaling) 
{
	btHashMap<btHashString,TiXmlElement* > allSources;
	btHashMap<btHashString,VertexSource> vertexSources;
	for(TiXmlElement* geometry = doc.RootElement()->FirstChildElement("library_geometries")->FirstChildElement("geometry");
			geometry != NULL; geometry = geometry->NextSiblingElement("geometry")) 
	{
		btAlignedObjectArray<btVector3> vertexPositions;
		btAlignedObjectArray<btVector3> vertexNormals;
		btAlignedObjectArray<int> indices;

		const char* geometryName = geometry->Attribute("id");
		for (TiXmlElement* mesh = geometry->FirstChildElement("mesh");(mesh != NULL); mesh = mesh->NextSiblingElement("mesh")) 
		{
			TiXmlElement* vertices2 = mesh->FirstChildElement("vertices");
			
			for (TiXmlElement* source = mesh->FirstChildElement("source");source != NULL;source = source->NextSiblingElement("source")) 
			{
				const char* srcId= source->Attribute("id");
//				printf("source id=%s\n",srcId);
				allSources.insert(srcId,source);
			}
			const char* vertexId = vertices2->Attribute("id");
			//printf("vertices id=%s\n",vertexId);
			VertexSource vs;
			for(TiXmlElement* input = vertices2->FirstChildElement("input");input != NULL;input = input->NextSiblingElement("input")) 
			{
				const char* sem = input->Attribute("semantic");
				std::string semName(sem);
//					printf("sem=%s\n",sem);
				const char* src = input->Attribute("source");
//					printf("src=%s\n",src);
				const char* srcIdRef = input->Attribute("source");
				std::string source_name;
				source_name = std::string(srcIdRef);
				source_name = source_name.erase(0, 1);
				if (semName=="POSITION")
				{
					vs.m_positionArrayId = source_name;
				}
				if (semName=="NORMAL")
				{
					vs.m_normalArrayId = source_name;
				}
			}
			vertexSources.insert(vertexId,vs);

			for (TiXmlElement* primitive = mesh->FirstChildElement("triangles"); primitive; primitive = primitive->NextSiblingElement("triangles"))
			{
				std::string positionSourceName;
				std::string normalSourceName;
				int primitiveCount;
				primitive->QueryIntAttribute("count", &primitiveCount);
				bool positionAndNormalInVertex=false;
				int indexStride=1;
				int posOffset = 0;
				int normalOffset = 0;
				int numIndices = 0;
				{
					for (TiXmlElement* input = primitive->FirstChildElement("input");input != NULL;input = input->NextSiblingElement("input")) 
					{
						const char* sem = input->Attribute("semantic");
						std::string semName(sem);
						int offset = atoi(input->Attribute("offset"));
						if ((offset+1)>indexStride)
							indexStride=offset+1;
						//printf("sem=%s\n",sem);
						const char* src = input->Attribute("source");
						//printf("src=%s\n",src);
						const char* srcIdRef = input->Attribute("source");
						std::string source_name;
						source_name = std::string(srcIdRef);
						source_name = source_name.erase(0, 1);
							
						if (semName=="VERTEX")
						{
							//now we have POSITION and possibly NORMAL too, using same index array (<p>)
							VertexSource* vs = vertexSources[source_name.c_str()];
							if (vs->m_positionArrayId.length())
							{
								positionSourceName = vs->m_positionArrayId;
								posOffset = offset;
							}
							if (vs->m_normalArrayId.length())
							{
								normalSourceName = vs->m_normalArrayId;
								normalOffset  = offset;
								positionAndNormalInVertex = true;
							}
						}
						if (semName=="NORMAL")
						{
							btAssert(normalSourceName.length()==0);
							normalSourceName = source_name;
							normalOffset  = offset;
							positionAndNormalInVertex = false;
						}
					}
					numIndices = primitiveCount * 3; 
				}
//.........这里部分代码省略.........
开发者ID:Aatch,项目名称:bullet3,代码行数:101,代码来源:LoadMeshFromCollada.cpp

示例2: registerGraphicsShape

	virtual int registerGraphicsShape(const float* vertices, int numvertices, const int* indices, int numIndices,int primitiveType, int textureId)
	{
		int shapeIndex = m_swRenderObjects.size();

		TinyRenderObjectData* swObj = new TinyRenderObjectData(m_rgbColorBuffer,m_depthBuffer);
        float rgbaColor[4] = {1,1,1,1};

		//if (textureId>=0)
		//{
		//	swObj->registerMeshShape(vertices,numvertices,indices,numIndices,rgbaColor);
		//} else
		{
			swObj->registerMeshShape(vertices,numvertices,indices,numIndices,rgbaColor);
		}
		//swObj->createCube(1,1,1);//MeshShape(vertices,numvertices,indices,numIndices);
        m_swRenderObjects.insert(shapeIndex,swObj);
		return shapeIndex;
	}
开发者ID:GYGit,项目名称:bullet3,代码行数:18,代码来源:main_tinyrenderer_single_example.cpp

示例3: findTexture

	BasicTexture* findTexture(const char* fileName)
	{
		
		BasicTexture** result = m_textures.find(fileName);
		if (result)
			return *result;

		return 0;
	}
开发者ID:ani19tha,项目名称:dynamica,代码行数:9,代码来源:BasicDemo.cpp

示例4:

 virtual ~TinyRendererGUIHelper()
 {
     for (int i=0;i<m_swRenderObjects.size();i++)
     {
         TinyRenderObjectData** d = m_swRenderObjects[i];
         if (d && *d)
         {
             delete *d;
         }
     }
 }
开发者ID:GYGit,项目名称:bullet3,代码行数:11,代码来源:main_tinyrenderer_single_example.cpp

示例5: createCollisionObjectGraphicsObject

	virtual void createCollisionObjectGraphicsObject(btCollisionObject* obj, const btVector3& color)
	{
		OpenGLGuiHelper::createCollisionObjectGraphicsObject(obj, color);
		int colIndex = obj->getUserIndex();
		int shapeIndex = obj->getCollisionShape()->getUserIndex();

		if (colIndex >= 0 && shapeIndex >= 0)
		{
			m_swInstances.insert(colIndex, shapeIndex);
		}
	}
开发者ID:Hongtae,项目名称:bullet3,代码行数:11,代码来源:main_sw_tinyrenderer_single_example.cpp

示例6:

	virtual ~SW_And_OpenGLGuiHelper()
	{
		for (int i = 0; i < m_swRenderObjects.size(); i++)
		{
			TinyRenderObjectData** d = m_swRenderObjects[i];
			if (d && *d)
			{
				delete *d;
			}
		}
	}
开发者ID:Hongtae,项目名称:bullet3,代码行数:11,代码来源:main_sw_tinyrenderer_single_example.cpp

示例7: registerGraphicsShape

	virtual int registerGraphicsShape(const float* vertices, int numvertices, const int* indices, int numIndices, int primitiveType, int textureId)
	{
		int shapeIndex = OpenGLGuiHelper::registerGraphicsShape(vertices, numvertices, indices, numIndices, primitiveType, textureId);
		if (shapeIndex >= 0)
		{
			TinyRenderObjectData* swObj = new TinyRenderObjectData(m_rgbColorBuffer, m_depthBuffer);
			float rgbaColor[4] = {1, 1, 1, 1};
			swObj->registerMeshShape(vertices, numvertices, indices, numIndices, rgbaColor);
			//swObj->createCube(1,1,1);//MeshShape(vertices,numvertices,indices,numIndices);
			m_swRenderObjects.insert(shapeIndex, swObj);
		}
		return shapeIndex;
	}
开发者ID:Hongtae,项目名称:bullet3,代码行数:13,代码来源:main_sw_tinyrenderer_single_example.cpp

示例8: createCollisionObjectGraphicsObject

	virtual void createCollisionObjectGraphicsObject(btCollisionObject* obj,const btVector3& color) 
	{
		if (obj->getUserIndex()<0)
		{
			int colIndex = m_colObjUniqueIndex++;
			obj->setUserIndex(colIndex);
			int shapeIndex = obj->getCollisionShape()->getUserIndex();
		
			if (colIndex>=0 && shapeIndex>=0)
			{
				m_swInstances.insert(colIndex,shapeIndex);
			}
		}
	}
开发者ID:GYGit,项目名称:bullet3,代码行数:14,代码来源:main_tinyrenderer_single_example.cpp

示例9: registerGraphicsInstance

	virtual int registerGraphicsInstance(int shapeIndex, const float* position, const float* quaternion, const float* color, const float* scaling) 
	{
		int colIndex = m_colObjUniqueIndex++;
		
		if (colIndex>=0 && shapeIndex>=0)
		{
			TinyRenderObjectData** dPtr = m_swRenderObjects[shapeIndex];
            if (dPtr && *dPtr)
            {
				TinyRenderObjectData* d= *dPtr;
				d->m_localScaling.setValue(scaling[0],scaling[1],scaling[2]);
				m_swInstances.insert(colIndex,shapeIndex);
			}
		}
		
		return colIndex;
	}
开发者ID:GYGit,项目名称:bullet3,代码行数:17,代码来源:main_tinyrenderer_single_example.cpp

示例10: convertAllObjects

	virtual bool convertAllObjects(  bParse::btBulletFile* bulletFile2)
	{
		bool result = btBulletWorldImporter::convertAllObjects(bulletFile2);
		int i;
		//now the soft bodies
		for (i=0;i<bulletFile2->m_softBodies.size();i++)
		{
			if (bulletFile2->getFlags() & bParse::FD_DOUBLE_PRECISION)
			{
				btAssert(0); //not yet
				//btSoftBodyFloatData* softBodyData = (btSoftBodyFloatData*)bulletFile2->m_softBodies[i];
			} else
			{
				btSoftBodyFloatData* softBodyData = (btSoftBodyFloatData*)bulletFile2->m_softBodies[i];
				int i;
				int numNodes = softBodyData->m_numNodes;
				
		
				btSoftBody*		psb=new btSoftBody(&m_softRigidWorld->getWorldInfo());
				m_softBodyMap.insert(softBodyData,psb);

				//materials
				for (i=0;i<softBodyData->m_numMaterials;i++)
				{
					SoftBodyMaterialData* matData = softBodyData->m_materials[i];
					btSoftBody::Material** matPtr = m_materialMap.find(matData);
					btSoftBody::Material* mat = 0;
					if (matPtr&& *matPtr)
					{
						mat = *matPtr;
					} else
					{
						mat = psb->appendMaterial();
						mat->m_flags = matData->m_flags;
						mat->m_kAST = matData->m_angularStiffness;
						mat->m_kLST = matData->m_linearStiffness;
						mat->m_kVST = matData->m_volumeStiffness;
						m_materialMap.insert(matData,mat);
					}
				}




				for (i=0;i<numNodes;i++)
				{
					SoftBodyNodeData& nodeData = softBodyData->m_nodes[i];
					btVector3 position;
					position.deSerializeFloat(nodeData.m_position);
					btScalar mass = nodeData.m_inverseMass? 1./nodeData.m_inverseMass : 0.f;
					psb->appendNode(position,mass);
					btSoftBody::Node* node = &psb->m_nodes[psb->m_nodes.size()-1];
					node->m_area = nodeData.m_area;
					node->m_battach = nodeData.m_attach;
					node->m_f.deSerializeFloat(nodeData.m_accumulatedForce);
					node->m_im = nodeData.m_inverseMass;

					btSoftBody::Material** matPtr = m_materialMap.find(nodeData.m_material);
					if (matPtr && *matPtr)
					{
						node->m_material = *matPtr;
					} else
					{
						printf("no mat?\n");
					}
					
					node->m_n.deSerializeFloat(nodeData.m_normal);
					node->m_q = node->m_x;
					node->m_v.deSerializeFloat(nodeData.m_velocity);
					
				}

				for (i=0;i<softBodyData->m_numLinks;i++)
				{
					SoftBodyLinkData& linkData = softBodyData->m_links[i];
					btSoftBody::Material** matPtr = m_materialMap.find(linkData.m_material);
					if (matPtr && *matPtr)
					{
						psb->appendLink(linkData.m_nodeIndices[0],linkData.m_nodeIndices[1],*matPtr);
					} else
					{
						psb->appendLink(linkData.m_nodeIndices[0],linkData.m_nodeIndices[1]);
					}
					btSoftBody::Link* link = &psb->m_links[psb->m_links.size()-1];
					link->m_bbending = linkData.m_bbending;
					link->m_rl = linkData.m_restLength;
				}

				for (i=0;i<softBodyData->m_numFaces;i++)
				{
					SoftBodyFaceData& faceData = softBodyData->m_faces[i];
					btSoftBody::Material** matPtr = m_materialMap.find(faceData.m_material);
					if (matPtr && *matPtr)
					{
						psb->appendFace(faceData.m_nodeIndices[0],faceData.m_nodeIndices[1],faceData.m_nodeIndices[2],*matPtr);
					} else
					{
						psb->appendFace(faceData.m_nodeIndices[0],faceData.m_nodeIndices[1],faceData.m_nodeIndices[2]);
					}
					btSoftBody::Face* face = &psb->m_faces[psb->m_faces.size()-1];
//.........这里部分代码省略.........
开发者ID:BBlayne,项目名称:COMP371-Codebase,代码行数:101,代码来源:SerializeDemo.cpp

示例11: createGraphicsObject

	//after each object is converter, including collision object, create a graphics object (and bind them)
	virtual void createGraphicsObject(_bObj* tmpObject, class btCollisionObject* bulletObject)
	{
		btRigidBody* body = btRigidBody::upcast(bulletObject);

		btRenderMesh* mesh = 0;
		if (tmpObject->data.mesh && tmpObject->data.mesh->vert_count && tmpObject->data.mesh->face_count)
		{
			if (tmpObject->data.mesh->vert_count> 16300)
			{
				printf("tmpObject->data.mesh->vert_count = %d\n",tmpObject->data.mesh->vert_count);
				
			}


			mesh = new btRenderMesh();
			mesh->m_bulletObject = bulletObject;

			btAlignedObjectArray<btVector3> originalVertices;
			originalVertices.resize(tmpObject->data.mesh->vert_count);

			for (int v=0;v<tmpObject->data.mesh->vert_count;v++)
			{
				float* vt3 = tmpObject->data.mesh->vert[v].xyz;
				originalVertices[v].setValue( IRR_X_M*vt3[IRR_X],IRR_Y_M*vt3[IRR_Y],IRR_Z_M*vt3[IRR_Z]);
			}
			int numVertices = 0;
			int numTriangles=0;
			int currentIndex=0;
			btTexVert* texVert = 0;
			

			for (int t=0;t<tmpObject->data.mesh->face_count;t++)
			{
				
				int originalIndex = tmpObject->data.mesh->face[t].v[IRR_TRI_0_X];
				mesh->m_indices.push_back(currentIndex);
				texVert = &mesh->m_vertices.expand();
				texVert->m_localxyz = originalVertices[originalIndex];
				texVert->m_uv1[0] = tmpObject->data.mesh->face[t].uv[IRR_TRI_0_X][0];
				texVert->m_uv1[1] = tmpObject->data.mesh->face[t].uv[IRR_TRI_0_X][1];
				numVertices++;
				currentIndex++;

				originalIndex = tmpObject->data.mesh->face[t].v[IRR_TRI_0_Y];
				mesh->m_indices.push_back(currentIndex);
				texVert = &mesh->m_vertices.expand();
				texVert->m_localxyz = originalVertices[originalIndex];
				texVert->m_uv1[0] = tmpObject->data.mesh->face[t].uv[IRR_TRI_0_Y][0];
				texVert->m_uv1[1] = tmpObject->data.mesh->face[t].uv[IRR_TRI_0_Y][1];
				numVertices++;
				currentIndex++;

				originalIndex = tmpObject->data.mesh->face[t].v[IRR_TRI_0_Z];
				mesh->m_indices.push_back(currentIndex);
				texVert = &mesh->m_vertices.expand();
				texVert->m_localxyz = originalVertices[originalIndex];
				texVert->m_uv1[0] = tmpObject->data.mesh->face[t].uv[IRR_TRI_0_Z][0];
				texVert->m_uv1[1] = tmpObject->data.mesh->face[t].uv[IRR_TRI_0_Z][1];
				numVertices++;
				currentIndex++;
				numTriangles++;

				if (tmpObject->data.mesh->face[t].v[3])
				{
					originalIndex = tmpObject->data.mesh->face[t].v[IRR_TRI_1_X];
					mesh->m_indices.push_back(currentIndex);
					texVert = &mesh->m_vertices.expand();
					texVert->m_localxyz = originalVertices[originalIndex];
					texVert->m_uv1[0] = tmpObject->data.mesh->face[t].uv[IRR_TRI_1_X][0];
					texVert->m_uv1[1] = tmpObject->data.mesh->face[t].uv[IRR_TRI_1_X][1];
					numVertices++;
					currentIndex++;

					originalIndex = tmpObject->data.mesh->face[t].v[IRR_TRI_1_Y];
					mesh->m_indices.push_back(currentIndex);
					texVert = &mesh->m_vertices.expand();
					texVert->m_localxyz = originalVertices[originalIndex];
					texVert->m_uv1[0] = tmpObject->data.mesh->face[t].uv[IRR_TRI_1_Y][0];
					texVert->m_uv1[1] = tmpObject->data.mesh->face[t].uv[IRR_TRI_1_Y][1];
					numVertices++;
					currentIndex++;

					originalIndex = tmpObject->data.mesh->face[t].v[IRR_TRI_1_Z];
					mesh->m_indices.push_back(currentIndex);
					texVert = &mesh->m_vertices.expand();
					texVert->m_localxyz = originalVertices[originalIndex];
					texVert->m_uv1[0] = tmpObject->data.mesh->face[t].uv[IRR_TRI_1_Z][0];
					texVert->m_uv1[1] = tmpObject->data.mesh->face[t].uv[IRR_TRI_1_Z][1];
					numVertices++;
					numTriangles++;
					currentIndex++;
				}
			}

			if (numTriangles>0)
			{
				m_renderMeshes.push_back(mesh);
				printf("numTris = %d\n",numTriangles);
				//scene::ISceneNode* node = createMeshNode(mesh->m_vertices,numVertices,indices,numIndices,numTriangles,bulletObject,tmpObject);
//.........这里部分代码省略.........
开发者ID:ani19tha,项目名称:dynamica,代码行数:101,代码来源:BasicDemo.cpp


注:本文中的btHashMap类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。