| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- #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, IndexBuffer::IndexType indexType)
- {
- MeshPtr mesh = cm_core_ptr<Mesh, PoolAlloc>(new (cm_alloc<Mesh, PoolAlloc>()) Mesh(numVertices, numIndices, vertexDesc, bufferType, indexType));
- mesh->setThisPtr(mesh);
- mesh->initialize();
- return mesh;
- }
- MeshPtr MeshManager::create(const MeshDataPtr& initialData, MeshBufferType bufferType)
- {
- MeshPtr mesh = cm_core_ptr<Mesh, PoolAlloc>(new (cm_alloc<Mesh, PoolAlloc>()) Mesh(initialData, bufferType));
- 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(0);
- indices[0] = 0;
- indices[1] = 0;
- indices[2] = 0;
- SyncedCoreAccessor& coreAccessor = gMainSyncedCA();
- mDummyMesh = Mesh::create(mDummyMeshData);
- }
- }
|