1 | #include "Ogre.h"
|
---|
2 | #include "RenderingType.h"
|
---|
3 | #include "OgreEffectWrapper.h"
|
---|
4 | #include "ManagedOgreRenderTexturePass.h"
|
---|
5 | #include "FinalRenderingRun.h"
|
---|
6 | #include "entityrenderingobject.h"
|
---|
7 |
|
---|
8 | #include "LightMapFinalRenderingRun.h"
|
---|
9 |
|
---|
10 | const long EntityRenderingObject::entityRenderingObjectTypeId(-2);
|
---|
11 | const String EntityRenderingObject::entityRenderingObjectTypeName("EntityRenderingObject");
|
---|
12 |
|
---|
13 | EntityRenderingObject::EntityRenderingObject(Entity* owner, unsigned long startFrame, const RenderingType& renderingType )
|
---|
14 | {
|
---|
15 | this->startFrame = startFrame;
|
---|
16 |
|
---|
17 | if(renderingType.diffuseShaded &&
|
---|
18 | !renderingType.diffuseTextured )
|
---|
19 | finalRenderingRun = new LightMapFinalRenderingRun(owner);
|
---|
20 |
|
---|
21 | //for all possible per entity preComputingRuns
|
---|
22 | if(finalRenderingRun->getLightMapUpdateInterval() != 0)
|
---|
23 | {
|
---|
24 | lightMapRun = new LightMapRun(
|
---|
25 | renderingType.lightMapResolutionX,
|
---|
26 | renderingType.lightMapResolutionY,
|
---|
27 | renderingType.lightMapNumberOfMipmapLevels,
|
---|
28 | renderingType.lightMapLOD,
|
---|
29 | owner);
|
---|
30 | finalRenderingRun->setLightMapTexture(lightMapRun->getResultTextureName());
|
---|
31 | }
|
---|
32 | else
|
---|
33 | lightMapRun = NULL;
|
---|
34 |
|
---|
35 | if(finalRenderingRun->getVRMUpdateInterval() != 0)
|
---|
36 | {
|
---|
37 | vrmRun = new VRMRun(
|
---|
38 | owner,
|
---|
39 | renderingType.vrmMapResolutionX,
|
---|
40 | renderingType.vrmMapResolutionY
|
---|
41 | );
|
---|
42 | finalRenderingRun->setVRMTexture(vrmRun->getResultTextureName());
|
---|
43 | }
|
---|
44 | else
|
---|
45 | vrmRun = NULL;
|
---|
46 |
|
---|
47 | if(finalRenderingRun->getCausticMapUpdateInterval() != 0)
|
---|
48 | {
|
---|
49 | causticMapRun = new CausticMapRun(owner, renderingType.causticMapResolutionX, renderingType.causticMapResolutionY);
|
---|
50 | finalRenderingRun->setCausticMapTexture(causticMapRun->getResultTextureName());
|
---|
51 | }
|
---|
52 | else
|
---|
53 | vrmRun = NULL;
|
---|
54 |
|
---|
55 | if(finalRenderingRun->getPRMUpdateInterval() != 0)
|
---|
56 | {
|
---|
57 | prmRun = new PRMRun(
|
---|
58 | owner,
|
---|
59 | renderingType.prmResolution,
|
---|
60 | renderingType.prmNEntryPoints,
|
---|
61 | renderingType.prmNClusters,
|
---|
62 | renderingType.prmTileSize
|
---|
63 | );
|
---|
64 | finalRenderingRun->setPRMTexture(prmRun->getResultTextureName());
|
---|
65 | finalRenderingRun->setEntryPointsTexture(prmRun->getEntryPointsTextureName());
|
---|
66 | finalRenderingRun->setNEntryPoints(prmRun->getNEntryPoints());
|
---|
67 | finalRenderingRun->setNClusters(prmRun->getNClusters());
|
---|
68 | finalRenderingRun->setTileSize(prmRun->getTileSize());
|
---|
69 | }
|
---|
70 | else
|
---|
71 | prmRun = NULL;
|
---|
72 |
|
---|
73 | if(finalRenderingRun->getDiffuseEnvironmentUpdateInterval() != 0)
|
---|
74 | {
|
---|
75 | diffuseEnvironmentRun = new DiffuseEnvironmentMapRun(owner, renderingType.diffuseEnvironmentMapResolution);
|
---|
76 | finalRenderingRun->setDiffuseEnvironmentTextureCube(diffuseEnvironmentRun->getResultTextureName());
|
---|
77 | }
|
---|
78 | else
|
---|
79 | diffuseEnvironmentRun = NULL;
|
---|
80 |
|
---|
81 | if(finalRenderingRun->getSpecularEnvironmentUpdateInterval() != 0)
|
---|
82 | {
|
---|
83 | specularEnvironmentRun = new SpecularEnvironmentMapRun(owner, renderingType.specularEnvironmentMapResolution);
|
---|
84 | finalRenderingRun->setSpecularEnvironmentTextureCube(specularEnvironmentRun->getResultTextureName());
|
---|
85 | }
|
---|
86 | else
|
---|
87 | specularEnvironmentRun = NULL;
|
---|
88 |
|
---|
89 | if(finalRenderingRun->getFresnelEnvironmentUpdateInterval() != 0)
|
---|
90 | {
|
---|
91 | fresnelEnvironmentRun = new FresnelEnvironmentMapRun(owner, renderingType.fresnelEnvironmentMapResolution);
|
---|
92 | finalRenderingRun->setFresnelEnvironmentTextureCube(fresnelEnvironmentRun->getResultTextureName());
|
---|
93 | }
|
---|
94 | else
|
---|
95 | fresnelEnvironmentRun = NULL;
|
---|
96 |
|
---|
97 | }
|
---|
98 |
|
---|
99 | /**
|
---|
100 | perform preproc necessary in this frame
|
---|
101 | */
|
---|
102 | void EntityRenderingObject::updateLightMap(long frameCount)
|
---|
103 | {
|
---|
104 | if(finalRenderingRun->getLightMapUpdateInterval() != 0 &&
|
---|
105 | ((frameCount - startFrame) % finalRenderingRun->getLightMapUpdateInterval()) == 0 )
|
---|
106 | lightMapRun->update();
|
---|
107 | }
|
---|
108 |
|
---|
109 | void EntityRenderingObject::updateVRM(long frameCount)
|
---|
110 | {
|
---|
111 | if(finalRenderingRun->getVRMUpdateInterval() != 0 &&
|
---|
112 | ((frameCount - startFrame) % finalRenderingRun->getVRMUpdateInterval()) == 0 )
|
---|
113 | vrmRun->update();
|
---|
114 | }
|
---|
115 |
|
---|
116 | void EntityRenderingObject::updateCausticMap(long frameCount)
|
---|
117 | {
|
---|
118 | if(finalRenderingRun->getCausticMapUpdateInterval() != 0 &&
|
---|
119 | ((frameCount - startFrame) % finalRenderingRun->getCausticMapUpdateInterval()) == 0 )
|
---|
120 | causticMapRun->update();
|
---|
121 | }
|
---|
122 |
|
---|
123 | void EntityRenderingObject::updatePRM(long frameCount)
|
---|
124 | {
|
---|
125 | if(finalRenderingRun->getPRMUpdateInterval() != 0 &&
|
---|
126 | ((frameCount - startFrame) % finalRenderingRun->getPRMUpdateInterval()) == 0 )
|
---|
127 | prmRun->update();
|
---|
128 | }
|
---|
129 |
|
---|
130 | void EntityRenderingObject::updateEnvironmentCubes(long frameCount)
|
---|
131 | {
|
---|
132 | if(finalRenderingRun->getDiffuseEnvironmentUpdateInterval() != 0 &&
|
---|
133 | ((frameCount - startFrame) % finalRenderingRun->getDiffuseEnvironmentUpdateInterval()) == 0 )
|
---|
134 | diffuseEnvironmentRun->update();
|
---|
135 | if(finalRenderingRun->getSpecularEnvironmentUpdateInterval() != 0 &&
|
---|
136 | ((frameCount - startFrame) % finalRenderingRun->getSpecularEnvironmentUpdateInterval()) == 0 )
|
---|
137 | specularEnvironmentRun->update();
|
---|
138 | if(finalRenderingRun->getFresnelEnvironmentUpdateInterval() != 0 &&
|
---|
139 | ((frameCount - startFrame) % finalRenderingRun->getFresnelEnvironmentUpdateInterval()) == 0 )
|
---|
140 | fresnelEnvironmentRun->update();
|
---|
141 | }
|
---|
142 |
|
---|
143 | EntityRenderingObject::~EntityRenderingObject(void)
|
---|
144 | {
|
---|
145 | delete finalRenderingRun;
|
---|
146 | } |
---|