- Timestamp:
- 09/12/06 20:49:30 (18 years ago)
- Location:
- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreRenderingRun.h
r1342 r1351 23 23 { 24 24 pixelSprites = 0; 25 fullscreenGrid = 0; 25 26 } 26 27 /** -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreCausticCasterRenderTechnique.h
r1055 r1351 44 44 bool useDistance, 45 45 float attenuation, 46 bool useTriangles, 46 47 Pass* pass, 47 48 OgreRenderable* parentRenderable, … … 75 76 unsigned char photonMapTexID; 76 77 float attenuation; 78 bool useTriangles; 77 79 78 80 //inherited … … 115 117 bool updateAllFace; 116 118 bool useDistance; 119 bool useTriangles; 117 120 118 121 -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreCausticCubeMapRenderingRun.h
r1055 r1351 41 41 unsigned char photonMapTexId, 42 42 bool updateAllFace, 43 float attenuation 43 float attenuation, 44 bool useTriangles 44 45 ); 45 46 /** … … 82 83 String materialName; 83 84 float attenuation; 85 bool useTriangles; 84 86 85 87 //inherited -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreRenderingRun.cpp
r1342 r1351 208 208 void OgreRenderingRun::renderFullscreenGrid(String& materialName, RenderTarget* rt, int width, int height) 209 209 { 210 MeshPtr mesh = MeshManager::getSingleton().createManual("FullScreenGrid",ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); 211 SubMesh* sm = mesh->createSubMesh(); 212 sm-> 210 SceneManager* sm = Root::getSingleton()._getCurrentSceneManager(); 211 212 if(this->fullscreenGrid == NULL) 213 { 214 MeshPtr mesh = MeshManager::getSingleton().createManual("FullScreenGrid",ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); 215 SubMesh* subMesh = mesh->createSubMesh(); 216 217 mesh->sharedVertexData = new VertexData(); 218 VertexData* vertexData = mesh->sharedVertexData; 219 220 // define the vertex format 221 VertexDeclaration* vertexDecl = vertexData->vertexDeclaration; 222 size_t currOffset = 0; 223 // positions 224 vertexDecl->addElement(0, currOffset, VET_FLOAT3, VES_POSITION); 225 currOffset += VertexElement::getTypeSize(VET_FLOAT3); 226 227 // allocate the vertex buffer 228 vertexData->vertexCount = width * height; 229 HardwareVertexBufferSharedPtr vBuf = HardwareBufferManager::getSingleton().createVertexBuffer(vertexDecl->getVertexSize(0), vertexData->vertexCount, HardwareBuffer::HBU_STATIC_WRITE_ONLY, false); 230 VertexBufferBinding* binding = vertexData->vertexBufferBinding; 231 binding->setBinding(0, vBuf); 232 float* pVertex = static_cast<float*>(vBuf->lock(HardwareBuffer::HBL_DISCARD)); 233 234 // allocate index buffer 235 subMesh->indexData->indexCount = 6 * (width - 1) * (height - 1); 236 subMesh->indexData->indexBuffer = HardwareBufferManager::getSingleton().createIndexBuffer(HardwareIndexBuffer::IT_16BIT, subMesh->indexData->indexCount, HardwareBuffer::HBU_STATIC_WRITE_ONLY, false); 237 HardwareIndexBufferSharedPtr iBuf = subMesh->indexData->indexBuffer; 238 unsigned short* pIndices = static_cast<unsigned short*>(iBuf->lock(HardwareBuffer::HBL_DISCARD)); 239 240 unsigned short wVerticeIndex = 0 ; 241 242 243 for( int j = 0; j < height; j++ ) 244 { 245 for( int i = 0; i < width; i++ ) 246 { //positions 247 float x = ((float)i + 0.5) / (float) width; 248 float y = ((float)j + 0.5) / (float) height; 249 *pVertex++ = x; 250 *pVertex++ = y; 251 *pVertex++ = 0; 252 253 //indexes 254 if( j < height - 1 && i < width -1 ) 255 { 256 *pIndices++ = j * width + i; 257 *pIndices++ = (j + 1) * width + i; 258 *pIndices++ = j * width + i + 1; 259 *pIndices++ = j * width + i + 1; 260 *pIndices++ = (j + 1) * width + i; 261 *pIndices++ = (j + 1) * width + i + 1; 262 } 263 264 } 265 } 266 267 // Unlock 268 vBuf->unlock(); 269 iBuf->unlock(); 270 // Generate face list 271 subMesh->useSharedVertices = true; 272 273 // this line makes clear the mesh is loaded (avoids memory leaks) 274 mesh->load(); 275 276 fullscreenGrid = sm->createEntity("FullScreenGridEntity", "FullScreenGrid"); 277 SceneNode* n = sm->getRootSceneNode()->createChildSceneNode("FullScreenGridNode"); 278 n->attachObject(fullscreenGrid); 279 fullscreenGrid->setVisible(false); 280 } 281 282 fullscreenGrid->setMaterialName(materialName); 283 284 sm->getRenderQueue()->clear(); 285 sm->getRenderQueue()->addRenderable(fullscreenGrid->getSubEntity(0)); 286 sm->setFindVisibleObjects(false); 287 rt->update(); 288 sm->setFindVisibleObjects(true); 289 213 290 } 214 291 -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreCausticCasterRenderTechnique.cpp
r1055 r1351 16 16 bool useDistance, 17 17 float attenuation, 18 bool useTriangles, 18 19 Pass* pass, 19 20 OgreRenderable* parentRenderable, … … 24 25 { 25 26 this->attenuation = attenuation; 27 this->useTriangles = useTriangles; 26 28 this->photonMapMaterialName = photonMapMaterialName; 27 29 … … 106 108 photonMapTexID, 107 109 updateAllFace, 108 attenuation 110 attenuation, 111 useTriangles 109 112 ); 110 113 … … 194 197 OgreCausticCasterRenderTechniqueFactory* f = (OgreCausticCasterRenderTechniqueFactory*) factory; 195 198 f->attenuation = StringConverter::parseReal(params); 199 } 200 201 void parseUseTriangles(String& params, RenderTechniqueFactory* factory) 202 { 203 OgreCausticCasterRenderTechniqueFactory* f = (OgreCausticCasterRenderTechniqueFactory*) factory; 204 f->useTriangles = StringConverter::parseBool(params); 196 205 } 197 206 } … … 216 225 this->attributeParsers.insert(AttribParserList::value_type("update_all_face", (ILLUM_ATTRIBUTE_PARSER) parseUpdateAllFace)); 217 226 this->attributeParsers.insert(AttribParserList::value_type("attenuation", (ILLUM_ATTRIBUTE_PARSER) parseAttenuation)); 227 this->attributeParsers.insert(AttribParserList::value_type("use_triangles", (ILLUM_ATTRIBUTE_PARSER) parseUseTriangles)); 218 228 219 229 } … … 236 246 useDistance = true; 237 247 updateAllFace = false; 248 useTriangles = false; 238 249 239 250 parseParams(params); … … 250 261 useDistance, 251 262 attenuation, 263 useTriangles, 252 264 pass, 253 265 parentRenderable, -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreCausticCubeMapRenderingRun.cpp
r1055 r1351 13 13 unsigned char photonMapTexId, 14 14 bool updateAllFace, 15 float attenuation) 15 float attenuation, 16 bool useTriangles) 16 17 :CausticCubeMapRenderingRun(startFrame, updateInterval, resolution, updateAllFace) 17 18 , OgreRenderingRun(startFrame, updateInterval) … … 19 20 { 20 21 this->attenuation = attenuation; 22 this->useTriangles = useTriangles; 21 23 this->sharedRuns = sharedRuns; 22 24 this->name = name; … … 64 66 String photonMapName = ((OgrePhotonMapRenderingRun*) run->asOgreRenderingRun())->getPhotonMapTextureName(); 65 67 TexturePtr tex = TextureManager::getSingleton().getByName(photonMapName); 66 renderPixelSprites(materialName, rt, tex->getWidth(), tex->getHeight()); 68 69 if(!useTriangles) 70 renderPixelSprites(materialName, rt, tex->getWidth(), tex->getHeight()); 71 else 72 renderFullscreenGrid(materialName, rt, tex->getWidth(), tex->getHeight()); 67 73 68 74 //rt->writeContentsToFile("caucube" + this->name + StringConverter::toString(facenum) + ".dds");
Note: See TracChangeset
for help on using the changeset viewer.