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