void createMeshWithMaterial(String fileName) { String matFileNameSuffix = ".material"; String matName1 = "red"; String matFileName1 = matName1 + matFileNameSuffix; MaterialPtr matPtr = MaterialManager::getSingleton().create(matName1, "General"); Pass* pass = matPtr->getTechnique(0)->getPass(0); pass->setDiffuse(1.0, 0.1, 0.1, 0); String matName2 = "green"; String matFileName2 = matName2 + matFileNameSuffix; matPtr = MaterialManager::getSingleton().create(matName2, "General"); pass = matPtr->getTechnique(0)->getPass(0); pass->setDiffuse(0.1, 1.0, 0.1, 0); String matName3 = "blue"; String matFileName3 = matName3 + matFileNameSuffix; matPtr = MaterialManager::getSingleton().create(matName3, "General"); pass = matPtr->getTechnique(0)->getPass(0); pass->setDiffuse(0.1, 0.1, 1.0, 0); String matName4 = "yellow"; String matFileName4 = matName4 + matFileNameSuffix; matPtr = MaterialManager::getSingleton().create(matName4, "General"); pass = matPtr->getTechnique(0)->getPass(0); pass->setDiffuse(1.0, 1.0, 0.1, 0); ManualObject* manObj = OGRE_NEW ManualObject("mesh"); manObj->begin(matName1, RenderOperation::OT_TRIANGLE_LIST); manObj->position(0, 50, 0); manObj->position(50, 50, 0); manObj->position(0, 100, 0); manObj->triangle(0, 1, 2); manObj->position(50, 100, 0); manObj->position(0, 100, 0); manObj->position(50, 50, 0); manObj->triangle(3, 4, 5); manObj->end(); manObj->begin(matName2, RenderOperation::OT_LINE_LIST); manObj->position(0, 100, 0); manObj->position(-50, 50, 0); manObj->position(-50, 0, 0); manObj->position(-50, 50, 0); manObj->position(-100, 0, 0); manObj->position(-50, 0, 0); manObj->end(); manObj->begin(matName3, RenderOperation::OT_LINE_STRIP); manObj->position(50, 100, 0); manObj->position(100, 50, 0); manObj->position(100, 0, 0); manObj->position(150, 0, 0); manObj->end(); manObj->begin(matName4, RenderOperation::OT_POINT_LIST); manObj->position(50, 0, 0); manObj->position(0, 0, 0); manObj->end(); manObj->convertToMesh(fileName); OGRE_DELETE manObj; }
void MeshWithoutIndexDataTests::testCreateLineWithMaterial() { String matName = "lineMat"; MaterialPtr matPtr = MaterialManager::getSingleton().create(matName, "General"); Pass* pass = matPtr->getTechnique(0)->getPass(0); pass->setDiffuse(1.0, 0.1, 0.1, 0); ManualObject* line = OGRE_NEW ManualObject("line"); line->begin(matName, RenderOperation::OT_LINE_LIST); line->position(0, 50, 0); line->position(50, 100, 0); line->end(); String fileName = "lineWithMat.mesh"; MeshPtr lineMesh = line->convertToMesh(fileName); OGRE_DELETE line; CPPUNIT_ASSERT(lineMesh->getNumSubMeshes() == 1); CPPUNIT_ASSERT(lineMesh->getSubMesh(0)->indexData->indexCount == 0); RenderOperation rop; lineMesh->getSubMesh(0)->_getRenderOperation(rop); CPPUNIT_ASSERT(rop.useIndexes == false); CPPUNIT_ASSERT(lineMesh->getSubMesh(0)->vertexData->vertexCount == 2); MeshSerializer meshWriter; meshWriter.exportMesh(lineMesh.get(), fileName); MaterialSerializer matWriter; matWriter.exportMaterial( MaterialManager::getSingleton().getByName(matName), matName + ".material" ); mMeshMgr->remove( fileName ); ResourceGroupManager::getSingleton().addResourceLocation(".", "FileSystem"); MeshPtr loadedLine = mMeshMgr->load(fileName, "General"); remove(fileName.c_str()); remove((matName + ".material").c_str()); CPPUNIT_ASSERT(loadedLine->getNumSubMeshes() == 1); CPPUNIT_ASSERT(loadedLine->getSubMesh(0)->indexData->indexCount == 0); loadedLine->getSubMesh(0)->_getRenderOperation(rop); CPPUNIT_ASSERT(rop.useIndexes == false); CPPUNIT_ASSERT(lineMesh->getSubMesh(0)->vertexData->vertexCount == 2); mMeshMgr->remove( fileName ); }
void MeshWithoutIndexDataTests::testCreateLineList() { ManualObject* lineList = OGRE_NEW ManualObject("line"); lineList->begin("BaseWhiteNoLighting", RenderOperation::OT_LINE_LIST); lineList->position(0, 50, 0); lineList->position(50, 100, 0); lineList->position(50, 50, 0); lineList->position(100, 100, 0); lineList->position(0, 50, 0); lineList->position(50, 50, 0); lineList->end(); String fileName = "lineList.mesh"; MeshPtr lineListMesh = lineList->convertToMesh(fileName); OGRE_DELETE lineList; CPPUNIT_ASSERT(lineListMesh->getNumSubMeshes() == 1); CPPUNIT_ASSERT(lineListMesh->getSubMesh(0)->indexData->indexCount == 0); RenderOperation rop; lineListMesh->getSubMesh(0)->_getRenderOperation(rop); CPPUNIT_ASSERT(rop.useIndexes == false); CPPUNIT_ASSERT(lineListMesh->getSubMesh(0)->vertexData->vertexCount == 6); MeshSerializer meshWriter; meshWriter.exportMesh(lineListMesh.get(), fileName); mMeshMgr->remove( fileName ); ResourceGroupManager::getSingleton().addResourceLocation(".", "FileSystem"); MeshPtr loadedLineList = mMeshMgr->load(fileName, "General"); remove(fileName.c_str()); CPPUNIT_ASSERT(loadedLineList->getNumSubMeshes() == 1); CPPUNIT_ASSERT(loadedLineList->getSubMesh(0)->indexData->indexCount == 0); loadedLineList->getSubMesh(0)->_getRenderOperation(rop); CPPUNIT_ASSERT(rop.useIndexes == false); CPPUNIT_ASSERT(loadedLineList->getSubMesh(0)->vertexData->vertexCount == 6); mMeshMgr->remove( fileName ); }
void MeshWithoutIndexDataTests::testEdgeList() { String fileName = "testEdgeList.mesh"; ManualObject* line = OGRE_NEW ManualObject("line"); line->begin("BaseWhiteNoLighting", RenderOperation::OT_LINE_LIST); line->position(0, 50, 0); line->position(50, 100, 0); line->end(); MeshPtr mesh = line->convertToMesh(fileName); OGRE_DELETE line; // whole mesh must not contain index data, for this test CPPUNIT_ASSERT(mesh->getNumSubMeshes() == 1); CPPUNIT_ASSERT(mesh->getSubMesh(0)->indexData->indexCount == 0); mesh->buildEdgeList(); MeshSerializer meshWriter; // if it does not crash here, test is passed meshWriter.exportMesh(mesh.get(), fileName); remove(fileName.c_str()); mMeshMgr->remove( fileName ); }
//----------------------------------------------------------------------------- MovableObject* ManualObjectFactory::createInstanceImpl( const String& name, const NameValuePairList* params) { return OGRE_NEW ManualObject(name); }