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 | float attenuation)
|
---|
16 | :CausticCubeMapRenderingRun(startFrame, updateInterval, resolution, updateAllFace)
|
---|
17 | , OgreRenderingRun(startFrame, updateInterval)
|
---|
18 | , RenderingRun(startFrame, updateInterval)
|
---|
19 | {
|
---|
20 | this->attenuation = attenuation;
|
---|
21 | this->sharedRuns = sharedRuns;
|
---|
22 | this->name = name;
|
---|
23 | this->materialName = materialName;
|
---|
24 | this->photonMapTexId = photonMapTexId;
|
---|
25 |
|
---|
26 | spriteSetName = name + String("_pixelSpriteSet");
|
---|
27 |
|
---|
28 | createCausticCubeMap();
|
---|
29 | }
|
---|
30 |
|
---|
31 | void OgreCausticCubeMapRenderingRun::createCausticCubeMap()
|
---|
32 | {
|
---|
33 | causticCubemapTexture = createCubeRenderTexture(name,
|
---|
34 | Vector3(0,0,0),
|
---|
35 | resolution,
|
---|
36 | PF_FLOAT16_RGBA,
|
---|
37 | 0);
|
---|
38 |
|
---|
39 | }
|
---|
40 |
|
---|
41 | void OgreCausticCubeMapRenderingRun::photonMapChanged(RenderingRun* run)
|
---|
42 | {
|
---|
43 | Material* mat = (Material*) MaterialManager::getSingleton().getByName(materialName).getPointer();
|
---|
44 | String photonMapName = ((OgrePhotonMapRenderingRun*) run->asOgreRenderingRun())->getPhotonMapTextureName();
|
---|
45 | mat->getTechnique(0)->getPass(0)->getTextureUnitState(photonMapTexId)->setTextureName(photonMapName);
|
---|
46 |
|
---|
47 | //rt = TextureManager::getSingleton().getByName(photonMapName);
|
---|
48 | LogManager::getSingleton().logMessage(LML_NORMAL, name + " map: " + photonMapName + " material: " + mat->getName());
|
---|
49 | }
|
---|
50 |
|
---|
51 | void OgreCausticCubeMapRenderingRun::updateCubeFace(int facenum)
|
---|
52 | {
|
---|
53 | RenderTarget* rt = causticCubemapTexture->getBuffer(facenum, 0).getPointer()
|
---|
54 | ->getRenderTarget();
|
---|
55 |
|
---|
56 | Camera* cam = rt->getViewport(0)->getCamera();
|
---|
57 | cam->setNearClipDistance(0.001);
|
---|
58 | cam->setFarClipDistance(2.0);
|
---|
59 | cam->setAspectRatio(1.0);
|
---|
60 | Radian r(Degree(90));
|
---|
61 | cam->setFOVy(r);
|
---|
62 |
|
---|
63 | RenderingRun* run = sharedRuns->getRun(ILLUMRUN_PHOTONMAP);
|
---|
64 | String photonMapName = ((OgrePhotonMapRenderingRun*) run->asOgreRenderingRun())->getPhotonMapTextureName();
|
---|
65 | TexturePtr tex = TextureManager::getSingleton().getByName(photonMapName);
|
---|
66 | renderPixelSprites(materialName, rt, tex->getWidth(), tex->getHeight());
|
---|
67 |
|
---|
68 | //rt->writeContentsToFile("caucube" + this->name + StringConverter::toString(facenum) + ".dds");
|
---|
69 | }
|
---|
70 |
|
---|
71 | bool OgreCausticCubeMapRenderingRun::faceNeedsUpdate(int facenum)
|
---|
72 | {
|
---|
73 | return true;
|
---|
74 | }
|
---|