Changeset 2122 for GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src
- Timestamp:
- 02/15/07 19:09:13 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src/ObjReader.cpp
r2119 r2122 52 52 53 53 std::stringstream d; 54 d << "successfully loaded " << pvsObjects.size() << " objects ";54 d << "successfully loaded " << pvsObjects.size() << " objects from " << preprocessor->mObjects.size() << " preprocessor objects"; 55 55 56 56 Ogre::LogManager::getSingleton().logMessage(d.str()); … … 60 60 int i = 0; 61 61 for (oit = pvsObjects.begin(); oit != oit_end; ++ oit, ++ i) 62 {Ogre::LogManager::getSingleton().logMessage("r"); 63 const Ogre::String entname = "Object" + i; 64 65 Ogre::Entity *ent = CreateEntity(entname, *oit); 66 67 const Ogre::String nodeName = entname + "/Node"; 68 root->createChildSceneNode(nodeName); 62 { 63 Ogre::LogManager::getSingleton().logMessage("r"); 64 const Ogre::String entname = "Object" + Ogre::StringConverter::toString(i); 65 66 Ogre::ManualObject *ent = CreateEntity(entname, *oit); 67 68 const Ogre::String nodeName = entname + "Node"; 69 Ogre::SceneNode* node = root->createChildSceneNode(nodeName); 70 node->attachObject(ent); 71 72 if (i > 100) 73 break; 69 74 } 70 75 71 76 delete preprocessor; 72 77 73 return false; 78 return true; 79 } 80 81 82 Ogre::ManualObject *ObjReader::CreateManualObject(const std::string &name, 83 GtpVisibilityPreprocessor::Intersectable *object) 84 { 85 using namespace Ogre; 86 //using namespace GtpVisibilityPreprocessor; 87 88 std::string meshName = name + ".mesh"; 89 std::string entityName = name + "Entity"; 90 91 GtpVisibilityPreprocessor::BvhLeaf *bvhObj = 92 static_cast<GtpVisibilityPreprocessor::BvhLeaf *>(object); 93 const int vertexCount = (int)bvhObj->mObjects.size() * 3; 94 95 ManualObject* manual = mSceneManager->createManualObject(entityName); 96 manual->begin("BaseWhiteNoLighting", RenderOperation::OT_LINE_STRIP); 97 98 // create vertices 99 100 GtpVisibilityPreprocessor::ObjectContainer::const_iterator oit, oit_end = bvhObj->mObjects.end(); 101 102 for (oit = bvhObj->mObjects.begin(); oit != oit_end; ++ oit) 103 { 104 GtpVisibilityPreprocessor::TriangleIntersectable *tObj = 105 static_cast<GtpVisibilityPreprocessor::TriangleIntersectable *>(*oit); 106 107 GtpVisibilityPreprocessor::Triangle3 tri = tObj->GetItem(); 108 109 for (int i = 0; i < 3; ++ i) 110 { 111 const GtpVisibilityPreprocessor::Vector3 vtx = tri.mVertices[i]; 112 manual->position(vtx.x, vtx.y, vtx.z); 113 manual->colour(1.0f, 0.0f, 0.0f); 114 } 115 } 116 117 for (int i = 0; i < vertexCount; ++ i) 118 { 119 manual->index(i); 120 } 121 122 return manual; 74 123 } 75 124 … … 79 128 { 80 129 using namespace Ogre; 81 //using namespace GtpVisibilityPreprocessor;82 130 83 131 Entity *entity; … … 86 134 static_cast<GtpVisibilityPreprocessor::BvhLeaf *>(object); 87 135 88 std::string meshName = name + " /Mesh";89 std::string entityName = name + " /Entity";90 91 MeshPtr mesh = MeshManager::getSingleton().createManual(meshName, " ObjGroup");136 std::string meshName = name + ".mesh"; 137 std::string entityName = name + "Entity"; 138 139 MeshPtr mesh = MeshManager::getSingleton().createManual(meshName, "Custom"); 92 140 SubMesh* submesh = mesh->createSubMesh(); 141 142 const int vertexCount = (int)bvhObj->mObjects.size() * 3; 93 143 94 144 // We must create the vertex data, indicating how many vertices there will be … … 96 146 submesh->vertexData = new VertexData(); 97 147 submesh->vertexData->vertexStart = 0; 98 submesh->vertexData->vertexCount = (int)bvhObj->mObjects.size() * 3; 148 submesh->vertexData->vertexCount = vertexCount; 149 150 std::stringstream d; d << "objects: " << bvhObj->mObjects.size() << " vtx: " << submesh->vertexData->vertexCount << endl; 151 Ogre::LogManager::getSingleton().logMessage(d.str()); 99 152 100 153 static const unsigned short source = 0; … … 103 156 VertexDeclaration* declaration = HardwareBufferManager::getSingleton().createVertexDeclaration(); 104 157 105 offset += declaration->addElement(source, offset, VET_FLOAT3, VES_POSITION).getSize();106 // offset += declaration->addElement(source,offset,VET_FLOAT3,VES_NORMAL).getSize();107 // offset += declaration->addElement(source,offset,VET_FLOAT2,VES_TEXTURE_COORDINATES).getSize();158 offset += declaration->addElement(source, offset, VET_FLOAT3, VES_POSITION).getSize(); 159 //offset += declaration->addElement(source, offset, VET_FLOAT3,VES_NORMAL).getSize(); 160 //offset += declaration->addElement(source, offset, VET_FLOAT2,VES_TEXTURE_COORDINATES).getSize(); 108 161 109 162 … … 113 166 createVertexBuffer(declaration->getVertexSize(source), 114 167 submesh->vertexData->vertexCount, 115 HardwareBuffer::HBU_STATIC_WRITE_ONLY, 116 false); 168 HardwareBuffer::HBU_STATIC_WRITE_ONLY); 117 169 118 170 // No we get access to the buffer to fill it. During so we record the bounding box. … … 132 184 for (int i = 0; i < 3; ++ i) 133 185 { 134 Vector3 vtx (tri.mVertices[i]);186 Vector3 vtx = Vector3(tri.mVertices[i]); 135 187 136 188 *vdata ++ = vtx.x; … … 138 190 *vdata ++ = vtx.z; 139 191 192 //std::stringstream d; d << vtx; 193 //Ogre::LogManager::getSingleton().logMessage(d.str()); 140 194 aabox.merge(vtx); 141 195 } 142 196 } 143 197 //Ogre::LogManager::getSingleton().logMessage("***"); 144 198 vbuffer->unlock(); 199 200 /*Ogre::RenderOperation rop; 201 submesh->_getRenderOperation(rop); 202 rop.useIndexes = false; 203 */ 204 ////// 205 //-- Creates the index data 206 207 submesh->vertexData->vertexBufferBinding->setBinding(source, vbuffer); 208 209 submesh->indexData->indexStart = 0; 210 // we use an index for every vertex 211 submesh->indexData->indexCount = vertexCount; 212 submesh->indexData->indexBuffer = 213 HardwareBufferManager::getSingleton(). 214 createIndexBuffer(HardwareIndexBuffer::IT_16BIT, 215 submesh->indexData->indexCount, 216 HardwareBuffer::HBU_STATIC_WRITE_ONLY); 217 submesh->operationType = RenderOperation::OT_LINE_STRIP; 218 //uint16* idata = static_cast<uint16*>(submesh->indexData->indexBuffer->lock(HardwareBuffer::HBL_DISCARD)); 219 unsigned short* idata = static_cast<unsigned short*>(submesh->indexData->indexBuffer->lock(HardwareBuffer::HBL_DISCARD)); 220 221 for (int j = 0; j < vertexCount; ++ j) 222 { 223 *idata = j; 224 ++ idata; 225 } 226 227 submesh->indexData->indexBuffer->unlock(); 228 229 submesh->setMaterialName("BaseWhiteNoLighting"); 145 230 146 231 // We must indicate the bounding box 147 232 mesh->_setBounds(aabox); 148 149 mesh->_setBoundingSphereRadius((aabox.getMaximum()-aabox.getMinimum()).length()/2.0); 233 mesh->_setBoundingSphereRadius((aabox.getMaximum() - aabox.getMinimum()).length() / 2.0); 150 234 mesh->load(); 151 235 mesh->touch(); 236 152 237 // Create an entity with the mesh 153 entity = mSceneManager->createEntity(meshName, entityName); 238 entity = mSceneManager->createEntity(entityName, meshName); 239 240 //entity->setRenderQueueGroup(Ogre::RENDER_QUEUE_MAIN); 154 241 155 242 return entity; 243 #endif 156 244 } -
GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src/ObjReader.vcproj
r2119 r2122 73 73 Name="VCCLCompilerTool" 74 74 AdditionalIncludeDirectories=""$(OGRE_PATH)\OgreMain\include";"$(OGRE_PATH)\Dependencies\include";"$(OGRE_PATH)\Samples\Common\include";..\include;..\..\..\Preprocessing\src" 75 PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;OBJREADER_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE1 "75 PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;OBJREADER_EXPORTS;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE1;USE_VERBOSE_PVS" 76 76 RuntimeLibrary="2" 77 77 UsePrecompiledHeader="0"
Note: See TracChangeset
for help on using the changeset viewer.