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