[2189] | 1 | #include "OgrePMEntryPointMapRenderingRun.h"
|
---|
| 2 | #include "OgreIlluminationManager.h"
|
---|
| 3 |
|
---|
| 4 | OgrePMEntryPointMapRenderingRun::OgrePMEntryPointMapRenderingRun(String name)
|
---|
| 5 | : OgreRenderingRun(1, 1)
|
---|
| 6 | , RenderingRun(1, 1)
|
---|
| 7 | {
|
---|
| 8 | this->name = name;
|
---|
| 9 |
|
---|
| 10 | createEntryPointMap();
|
---|
| 11 | }
|
---|
| 12 |
|
---|
| 13 | void OgrePMEntryPointMapRenderingRun::createEntryPointMap()
|
---|
| 14 | {
|
---|
| 15 | unsigned int entryPointCnt = OgreIlluminationManager::getSingleton().getPathMapEntryPoints().size();
|
---|
| 16 | int width = entryPointCnt / 4096 * 2;
|
---|
| 17 | int height = 4096;
|
---|
| 18 | TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual(name,
|
---|
| 19 | "default",
|
---|
| 20 | TEX_TYPE_2D,
|
---|
| 21 | width,
|
---|
| 22 | height,
|
---|
| 23 | 0,
|
---|
| 24 | 0,
|
---|
| 25 | PF_FLOAT32_RGBA,
|
---|
| 26 | TU_DEFAULT);
|
---|
| 27 | entryPointTexture = texPtr.getPointer();
|
---|
| 28 |
|
---|
| 29 | struct TMR
|
---|
| 30 | {
|
---|
| 31 | float pos[4];
|
---|
| 32 | float dir[4];
|
---|
| 33 | };
|
---|
| 34 | TMR* tm = new TMR[entryPointCnt];
|
---|
| 35 | for(int i=0; i<entryPointCnt; i++)
|
---|
| 36 | {
|
---|
| 37 | PathMapEntryPoint* EP = &OgreIlluminationManager::getSingleton().getPathMapEntryPoints().at(i);
|
---|
| 38 | tm[i].pos[0] = EP->position.x;
|
---|
| 39 | tm[i].pos[1] = EP->position.y;
|
---|
| 40 | tm[i].pos[2] = EP->position.z;
|
---|
| 41 | tm[i].pos[3] = 1.0;
|
---|
| 42 | tm[i].dir[0] = EP->normal.x;
|
---|
| 43 | tm[i].dir[1] = EP->normal.y;
|
---|
| 44 | tm[i].dir[2] = EP->normal.z;
|
---|
[2200] | 45 | tm[i].dir[3] = EP->prob;
|
---|
[2189] | 46 | }
|
---|
| 47 |
|
---|
| 48 | PixelBox lockBox(width, height, 1, PF_FLOAT32_RGBA, tm);
|
---|
| 49 | entryPointTexture->getBuffer()->blitFromMemory(lockBox);
|
---|
[2200] | 50 |
|
---|
| 51 | delete[] tm;
|
---|
| 52 |
|
---|
| 53 | int clusterCount = OgreIlluminationManager::getSingleton().getPathMapClusterLengthsSize();
|
---|
| 54 | width = clusterCount;
|
---|
| 55 | height = 2;
|
---|
| 56 | texPtr = Ogre::TextureManager::getSingleton().createManual(name + "_CL",
|
---|
| 57 | "default",
|
---|
| 58 | TEX_TYPE_2D,
|
---|
| 59 | width,
|
---|
| 60 | height,
|
---|
| 61 | 0,
|
---|
| 62 | 0,
|
---|
| 63 | PF_FLOAT32_R,
|
---|
| 64 | TU_RENDERTARGET);
|
---|
| 65 | clusterLengthTexture = texPtr.getPointer();
|
---|
| 66 |
|
---|
| 67 | float* data = new float[clusterCount * 2];
|
---|
| 68 | unsigned int entryPointCount = 0;
|
---|
| 69 | for(int i = 0; i < clusterCount; i++)
|
---|
| 70 | {
|
---|
| 71 | unsigned int clusterSize = OgreIlluminationManager::getSingleton().getPathMapClusterLength(i);
|
---|
| 72 | data[i] = clusterSize;//clustercount
|
---|
| 73 | data[clusterCount + i] = entryPointCount;
|
---|
| 74 | entryPointCount += clusterSize;
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | PixelBox lockBox2(width, height, 1, PF_FLOAT32_R, data);
|
---|
| 78 | clusterLengthTexture->getBuffer()->blitFromMemory(lockBox2);
|
---|
| 79 |
|
---|
| 80 | delete[] data;
|
---|
[2189] | 81 | }
|
---|
| 82 |
|
---|
| 83 | void OgrePMEntryPointMapRenderingRun::updateFrame(unsigned long frameNum)
|
---|
| 84 | {
|
---|
| 85 |
|
---|
| 86 | }
|
---|
| 87 |
|
---|
| 88 |
|
---|