1 | #include "OgreConvolvedCubeMapRenderTechnique.h"
|
---|
2 | #include "OgreTechniqueGroup.h"
|
---|
3 | #include "OgreReducedCubeMapRenderingRun.h"
|
---|
4 | #include "OgreCubeMapRenderingRun.h"
|
---|
5 |
|
---|
6 | OgreConvolvedCubeMapRenderTechnique::OgreConvolvedCubeMapRenderTechnique(unsigned long startFrame,
|
---|
7 | unsigned long cubeMapUpdateInterval,
|
---|
8 | unsigned int cubeMapResolution,
|
---|
9 | unsigned int reducedCubeMapResolution,
|
---|
10 | unsigned char texID,
|
---|
11 | bool useDistCalc,
|
---|
12 | bool useFaceAngleCalc,
|
---|
13 | float distTolerance,
|
---|
14 | float angleTolerance,
|
---|
15 | bool updateAllFace,
|
---|
16 | bool renderSelf,
|
---|
17 | bool renderEnvironment,
|
---|
18 | String selfMaterial,
|
---|
19 | String environmentMaterial,
|
---|
20 | bool getMinMax,
|
---|
21 | bool attachToTexUnit,
|
---|
22 | String minVariableName,
|
---|
23 | String maxVariableName,
|
---|
24 | String triggerName,
|
---|
25 | Pass* pass,
|
---|
26 | OgreRenderable* parentRenderable,
|
---|
27 | OgreTechniqueGroup* parentTechniqueGroup)
|
---|
28 | :
|
---|
29 | OgreCubeMapRenderTechnique(startFrame, cubeMapUpdateInterval, cubeMapResolution, texID, useDistCalc, useFaceAngleCalc, distTolerance, angleTolerance, updateAllFace, renderSelf, renderEnvironment, selfMaterial, environmentMaterial, layer, getMinMax, attachToTexUnit, minVariableName, maxVariableName, triggerName, pass, parentRenderable, parentTechniqueGroup),
|
---|
30 | CubeMapRenderTechnique(startFrame, cubeMapUpdateInterval, cubeMapResolution, useDistCalc, useFaceAngleCalc, distTolerance, angleTolerance, updateAllFace, renderSelf, renderEnvironment, layer, parentRenderable, parentTechniqueGroup),
|
---|
31 | ConvolvedCubeMapRenderTechnique(startFrame, cubeMapUpdateInterval, cubeMapResolution, reducedCubeMapResolution, useDistCalc, useFaceAngleCalc, distTolerance, angleTolerance, updateAllFace, renderSelf, renderEnvironment, parentRenderable, parentTechniqueGroup),
|
---|
32 | RenderTechnique(parentRenderable, parentTechniqueGroup)
|
---|
33 | {
|
---|
34 | texturePostFix = "_COLORCUBEMAP";
|
---|
35 |
|
---|
36 | if(sharedRuns->getRun(ILLUMRUN_COLOR_CUBEMAP) == 0)
|
---|
37 | sharedRuns->addRun(ILLUMRUN_COLOR_CUBEMAP, createCubeMapRun());
|
---|
38 |
|
---|
39 | if(sharedRuns->getRun(ILLUMRUN_REDUCED_CUBEMAP) == 0)
|
---|
40 | sharedRuns->addRun(ILLUMRUN_REDUCED_CUBEMAP, createReducedCubeMapRun());
|
---|
41 |
|
---|
42 | colorCubeMapRunChanged(sharedRuns->getRun(ILLUMRUN_COLOR_CUBEMAP));
|
---|
43 | reducedCubeMapRunChanged(sharedRuns->getRun(ILLUMRUN_REDUCED_CUBEMAP));
|
---|
44 | }
|
---|
45 |
|
---|
46 |
|
---|
47 | OgreConvolvedCubeMapRenderTechnique::~OgreConvolvedCubeMapRenderTechnique()
|
---|
48 | {
|
---|
49 |
|
---|
50 | }
|
---|
51 |
|
---|
52 | void OgreConvolvedCubeMapRenderTechnique::update(unsigned long frameNum)
|
---|
53 | {
|
---|
54 | ConvolvedCubeMapRenderTechnique::update(frameNum);
|
---|
55 | }
|
---|
56 |
|
---|
57 | void OgreConvolvedCubeMapRenderTechnique::reducedCubeMapRunChanged(RenderingRun* run)
|
---|
58 | {
|
---|
59 | OgreReducedCubeMapRenderingRun* cuberun =(OgreReducedCubeMapRenderingRun*) (run->asOgreRenderingRun());
|
---|
60 | String cubemapname = cuberun->getReducedCubeMapTextureName();
|
---|
61 |
|
---|
62 | pass->getTextureUnitState(texID)->setTextureName(cubemapname);
|
---|
63 | }
|
---|
64 |
|
---|
65 | void OgreConvolvedCubeMapRenderTechnique::colorCubeMapRunChanged(RenderingRun* run)
|
---|
66 | {
|
---|
67 | OgreCubeMapRenderingRun* cuberun =(OgreCubeMapRenderingRun*) (run->asOgreRenderingRun());
|
---|
68 | String cubemapname = cuberun->getCubeMapTextureName();
|
---|
69 |
|
---|
70 | OgreReducedCubeMapRenderingRun* rr = (OgreReducedCubeMapRenderingRun*) sharedRuns->getRun(ILLUMRUN_REDUCED_CUBEMAP)->asOgreRenderingRun();
|
---|
71 | rr->colorCubeMapChanged(cubemapname);
|
---|
72 |
|
---|
73 | }
|
---|
74 |
|
---|
75 | RenderingRun* OgreConvolvedCubeMapRenderTechnique::createReducedCubeMapRun()
|
---|
76 | {
|
---|
77 | return new OgreReducedCubeMapRenderingRun( (OgreSharedRuns*) parentTechniqueGroup->getSharedRuns(),
|
---|
78 | parentOgreRenderable->getName() + "_COLORCUBEMAP_REDUCED",
|
---|
79 | startFrame,
|
---|
80 | cubeMapUpdateInterval,
|
---|
81 | reducedCubeMapResolution,
|
---|
82 | useDistCalc,
|
---|
83 | useFaceAngleCalc,
|
---|
84 | distTolerance,
|
---|
85 | angleTolerance,
|
---|
86 | updateAllFace);
|
---|
87 | }
|
---|
88 |
|
---|
89 | ///Technique Parsers
|
---|
90 | namespace ConvolvedCubemapParsers
|
---|
91 | {
|
---|
92 | void parseReducedCubeMapResolution(String& params, RenderTechniqueFactory* factory)
|
---|
93 | {
|
---|
94 | OgreConvoledCubeMapRenderTechniqueFactory* f = (OgreConvoledCubeMapRenderTechniqueFactory*) factory;
|
---|
95 | f->reducedCubeMapResolution = StringConverter::parseUnsignedInt(params);
|
---|
96 | }
|
---|
97 | }
|
---|
98 | ///Technique factory
|
---|
99 | OgreConvoledCubeMapRenderTechniqueFactory::OgreConvoledCubeMapRenderTechniqueFactory()
|
---|
100 | {
|
---|
101 | typeName = "ReducedColorCubeMap";
|
---|
102 |
|
---|
103 | using namespace ConvolvedCubemapParsers;
|
---|
104 | this->attributeParsers.insert(AttribParserList::value_type("reduced_resolution", (ILLUM_ATTRIBUTE_PARSER) parseReducedCubeMapResolution));
|
---|
105 | }
|
---|
106 |
|
---|
107 | OgreRenderTechnique* OgreConvoledCubeMapRenderTechniqueFactory::createInstance(
|
---|
108 | IllumTechniqueParams* params,
|
---|
109 | Pass* pass,
|
---|
110 | OgreRenderable* parentRenderable,
|
---|
111 | OgreTechniqueGroup* parentTechniqueGroup)
|
---|
112 | {
|
---|
113 | reducedCubeMapResolution = 8;
|
---|
114 |
|
---|
115 | OgreCubeMapRenderTechniqueFactory::resetParams();
|
---|
116 | OgreCubeMapRenderTechniqueFactory::parseParams(params);
|
---|
117 | parseParams(params);
|
---|
118 |
|
---|
119 | OgreConvolvedCubeMapRenderTechnique* result = new OgreConvolvedCubeMapRenderTechnique(
|
---|
120 | startFrame,
|
---|
121 | cubeMapUpdateInterval,
|
---|
122 | cubeMapResolution,
|
---|
123 | reducedCubeMapResolution,
|
---|
124 | texID,
|
---|
125 | useDistCalc,
|
---|
126 | useFaceAngleCalc,
|
---|
127 | distTolerance,
|
---|
128 | angleTolerance,
|
---|
129 | updateAllFace,
|
---|
130 | renderSelf,
|
---|
131 | renderEnvironment,
|
---|
132 | selfMaterial,
|
---|
133 | environmentMaterial,
|
---|
134 | getMinMax,
|
---|
135 | attachToTexUnit,
|
---|
136 | minVariableName,
|
---|
137 | maxVariableName,
|
---|
138 | triggerName,
|
---|
139 | pass,
|
---|
140 | parentRenderable,
|
---|
141 | parentTechniqueGroup);
|
---|
142 |
|
---|
143 | return result;
|
---|
144 | }
|
---|
145 |
|
---|
146 |
|
---|