1 | #include "OgreCausticCubeMapRenderingRun.h"
|
---|
2 | //#include "OgreIlluminationManager.h"
|
---|
3 | #include "OgrePhotonMapRenderingRun.h"
|
---|
4 |
|
---|
5 |
|
---|
6 |
|
---|
7 | OgreCausticCubeMapRenderingRun::OgreCausticCubeMapRenderingRun(OgreSharedRuns* sharedRuns,
|
---|
8 | String name,
|
---|
9 | unsigned long startFrame,
|
---|
10 | unsigned long updateInterval,
|
---|
11 | unsigned int resolution,
|
---|
12 | String materialName,
|
---|
13 | unsigned char photonMapTexId,
|
---|
14 | bool updateAllFace)
|
---|
15 | :CausticCubeMapRenderingRun(startFrame, updateInterval, resolution, updateAllFace)
|
---|
16 | , OgreRenderingRun(startFrame, updateInterval)
|
---|
17 | , RenderingRun(startFrame, updateInterval)
|
---|
18 | {
|
---|
19 | this->sharedRuns = sharedRuns;
|
---|
20 | this->name = name;
|
---|
21 | this->materialName = materialName;
|
---|
22 | this->photonMapTexId = photonMapTexId;
|
---|
23 |
|
---|
24 | createCausticCubeMap();
|
---|
25 | }
|
---|
26 |
|
---|
27 | void OgreCausticCubeMapRenderingRun::createCausticCubeMap()
|
---|
28 | {
|
---|
29 | causticCubemapTexture = createCubeRenderTexture(name,
|
---|
30 | Vector3(0,0,0),
|
---|
31 | resolution,
|
---|
32 | PF_FLOAT16_RGBA,
|
---|
33 | 0);
|
---|
34 |
|
---|
35 | }
|
---|
36 |
|
---|
37 | void OgreCausticCubeMapRenderingRun::photonMapChanged(RenderingRun* run)
|
---|
38 | {
|
---|
39 | Material* mat = (Material*) MaterialManager::getSingleton().getByName(materialName).getPointer();
|
---|
40 | String photonMapName = ((OgrePhotonMapRenderingRun*) run->asOgreRenderingRun())->getPhotonMapTextureName();
|
---|
41 | mat->getTechnique(0)->getPass(0)->getTextureUnitState(photonMapTexId)->setTextureName(photonMapName);
|
---|
42 | }
|
---|
43 |
|
---|
44 | void OgreCausticCubeMapRenderingRun::updateCubeFace(int facenum)
|
---|
45 | {
|
---|
46 | RenderTarget* rt = causticCubemapTexture->getBuffer(facenum, 0).getPointer()
|
---|
47 | ->getRenderTarget();
|
---|
48 |
|
---|
49 | Camera* cam = rt->getViewport(0)->getCamera();
|
---|
50 | cam->setNearClipDistance(0.001);
|
---|
51 | cam->setFarClipDistance(2.0);
|
---|
52 | cam->setAspectRatio(1.0);
|
---|
53 | Radian r(Degree(90));
|
---|
54 | cam->setFOVy(r);
|
---|
55 |
|
---|
56 | RenderingRun* run = sharedRuns->getRun(ILLUMRUN_PHOTONMAP);
|
---|
57 | String photonMapName = ((OgrePhotonMapRenderingRun*) run->asOgreRenderingRun())->getPhotonMapTextureName();
|
---|
58 | TexturePtr tex = TextureManager::getSingleton().getByName(photonMapName);
|
---|
59 | renderPixelSprites(materialName, rt, tex->getWidth(), tex->getHeight());
|
---|
60 |
|
---|
61 | //rt->writeContentsToFile("caucube" + StringConverter::toString(facenum) + ".dds");
|
---|
62 | }
|
---|
63 |
|
---|
64 | bool OgreCausticCubeMapRenderingRun::faceNeedsUpdate(int facenum)
|
---|
65 | {
|
---|
66 | return true;
|
---|
67 | }
|
---|