示例#1
0
HRESULT RacorX8::CreateSphere()
{
	HRESULT hr;
	LPD3DXMESH pSphere;
	hr = CreateSphereMesh(m_spDevice.get(), &pSphere);
	m_spEarthMesh.reset(pSphere, [](LPD3DXMESH sphere){ sphere->Release(); });
	IDirect3DIndexBuffer8* ib;
	m_spEarthMesh->GetIndexBuffer(&ib);
	m_spIB.reset(ib, [](IDirect3DIndexBuffer8* ib){ib->Release(); });
	IDirect3DVertexBuffer8* vb;
	m_spEarthMesh->GetVertexBuffer(&vb);
	m_spVB.reset(vb, [](IDirect3DVertexBuffer8* vb){vb->Release(); });
	m_iNumTriangles = m_spEarthMesh->GetNumFaces();
	m_iNumVertices = m_spEarthMesh->GetNumVertices();
	return hr;
}
示例#2
0
文件: dyndebug.cpp 项目: yushiming/CS
  csRef<iMeshWrapper> DynamicsDebugger::CreateColliderMesh
    (iDynamicsSystemCollider* collider, iMaterialWrapper* material)
  {
    csRef<iMeshWrapper> mesh;

    switch (collider->GetGeometryType ())
      {
      case BOX_COLLIDER_GEOMETRY:
	{
	  // Get box geometry
	  csVector3 boxSize;
	  collider->GetBoxGeometry (boxSize);
	  boxSize /= 2.0;
	  const csBox3 box(-boxSize, boxSize);

	  // Create box
	  mesh = CreateBoxMesh (box, material, collider->GetLocalTransform (),
				sector);
	}
	break;

      case SPHERE_COLLIDER_GEOMETRY:
	{
	  // Get sphere geometry
	  csSphere sphere;
	  collider->GetSphereGeometry (sphere);

	  // Create sphere
	  mesh = CreateSphereMesh (sphere, material, sector);
	}
	break;

      case CYLINDER_COLLIDER_GEOMETRY:
	{
	  // Get cylinder geometry
	  float length, radius;
	  collider->GetCylinderGeometry (length, radius);

	  // Create cylinder
	  mesh = CreateCylinderMesh (length, radius, material,
				     collider->GetLocalTransform (), sector);
	}
	break;

      case CAPSULE_COLLIDER_GEOMETRY:
	{
	  // Get capsule geometry
	  float length, radius;
	  collider->GetCapsuleGeometry (length, radius);

	  // Create capsule
	  mesh = CreateCapsuleMesh (length, radius, material,
				    collider->GetLocalTransform (), sector);
	}
	break;

      case TRIMESH_COLLIDER_GEOMETRY:
	{
	  // Get mesh geometry
	  csVector3* vertices = 0;
	  int* indices = 0;
	  size_t vertexCount, triangleCount;
	  collider->GetMeshGeometry (vertices, vertexCount, indices, triangleCount);

	  // Create mesh
	  mesh = CreateCustomMesh (vertices, vertexCount, indices, triangleCount,
				   material, collider->GetLocalTransform (), sector);
	}
	break;

      case CONVEXMESH_COLLIDER_GEOMETRY:
	{
	  // Get mesh geometry
	  csVector3* vertices = 0;
	  int* indices = 0;
	  size_t vertexCount, triangleCount;
	  collider->GetConvexMeshGeometry (vertices, vertexCount, indices, triangleCount);

	  // Create mesh
	  mesh = CreateCustomMesh (vertices, vertexCount, indices, triangleCount, material,
				   collider->GetLocalTransform (), sector);
	}
	break;

      default:
	// TODO: plan meshes
	break;
      }

    return mesh;
  }
示例#3
0
void MeshManager::Initialize(LPDIRECT3DDEVICE9 device){
	m_Device = device;

	// Create Basic meshes
	CreateSphereMesh();
}