| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- #include "CmMeshManager.h"
- #include "CmCoreThreadAccessor.h"
- #include "CmApplication.h"
- #include "CmVector3.h"
- #include "CmMesh.h"
- #include "CmVertexDataDesc.h"
- namespace CamelotFramework
- {
- MeshManager::MeshManager()
- {
- }
- MeshManager::~MeshManager()
- {
- }
- MeshPtr MeshManager::create(UINT32 numVertices, UINT32 numIndices, const VertexDataDescPtr& vertexDesc,
- MeshBufferType bufferType, DrawOperationType drawOp, IndexBuffer::IndexType indexType)
- {
- MeshPtr mesh = cm_core_ptr<Mesh, PoolAlloc>(new (cm_alloc<Mesh, PoolAlloc>())
- Mesh(numVertices, numIndices, vertexDesc, bufferType, drawOp, indexType));
- mesh->setThisPtr(mesh);
- mesh->initialize();
- return mesh;
- }
- MeshPtr MeshManager::create(UINT32 numVertices, UINT32 numIndices, const VertexDataDescPtr& vertexDesc,
- const MeshDataPtr& initialData, MeshBufferType bufferType, DrawOperationType drawOp, IndexBuffer::IndexType indexType)
- {
- MeshPtr mesh = cm_core_ptr<Mesh, PoolAlloc>(new (cm_alloc<Mesh, PoolAlloc>())
- Mesh(numVertices, numIndices, vertexDesc, initialData, bufferType, drawOp, indexType));
- mesh->setThisPtr(mesh);
- mesh->initialize();
- return mesh;
- }
- MeshPtr MeshManager::create(const MeshDataPtr& initialData, MeshBufferType bufferType, DrawOperationType drawOp)
- {
- MeshPtr mesh = cm_core_ptr<Mesh, PoolAlloc>(new (cm_alloc<Mesh, PoolAlloc>()) Mesh(initialData, bufferType, drawOp));
- mesh->setThisPtr(mesh);
- mesh->initialize();
- return mesh;
- }
- MeshPtr MeshManager::createEmpty()
- {
- MeshPtr mesh = cm_core_ptr<Mesh, PoolAlloc>(new (cm_alloc<Mesh, PoolAlloc>()) Mesh());
- mesh->setThisPtr(mesh);
- return mesh;
- }
- void MeshManager::onStartUp()
- {
- VertexDataDescPtr vertexDesc = cm_shared_ptr<VertexDataDesc>();
- vertexDesc->addVertElem(VET_FLOAT3, VES_POSITION);
- mDummyMeshData = cm_shared_ptr<MeshData>(1, 3, vertexDesc);
- auto vecIter = mDummyMeshData->getVec3DataIter(VES_POSITION);
- vecIter.setValue(Vector3(0, 0, 0));
- auto indices = mDummyMeshData->getIndices32();
- indices[0] = 0;
- indices[1] = 0;
- indices[2] = 0;
- mDummyMesh = Mesh::create(mDummyMeshData);
- }
- }
|