1 | #include "OgreDistanceCubeMapRenderTechnique.h"
|
---|
2 | #include "OgreTechniqueGroup.h"
|
---|
3 | #include "OgreCubeMapRenderingRun.h"
|
---|
4 |
|
---|
5 | OgreDistanceCubeMapRenderTechnique::OgreDistanceCubeMapRenderTechnique(unsigned long startFrame,
|
---|
6 | unsigned long cubeMapUpdateInterval,
|
---|
7 | unsigned int cubeMapResolution,
|
---|
8 | unsigned char texID,
|
---|
9 | bool useDistCalc,
|
---|
10 | bool useFaceAngleCalc,
|
---|
11 | float distTolerance,
|
---|
12 | float angleTolerance,
|
---|
13 | bool updateAllFace,
|
---|
14 | bool renderSelf,
|
---|
15 | bool renderEnvironment,
|
---|
16 | String selfMaterial,
|
---|
17 | String environmentMaterial,
|
---|
18 | int layer,
|
---|
19 | bool getMinMax,
|
---|
20 | bool attachToTexUnit,
|
---|
21 | String minVariableName,
|
---|
22 | String maxVariableName,
|
---|
23 | String triggerName,
|
---|
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, triggerName, pass, parentRenderable, parentTechniqueGroup),
|
---|
29 | CubeMapRenderTechnique(startFrame, cubeMapUpdateInterval, cubeMapResolution, useDistCalc, useFaceAngleCalc, distTolerance, angleTolerance, updateAllFace, renderSelf, renderEnvironment, layer, parentRenderable, parentTechniqueGroup),
|
---|
30 | DistanceCubeMapRenderTechnique(startFrame, cubeMapUpdateInterval, cubeMapResolution, useDistCalc, useFaceAngleCalc, distTolerance, angleTolerance, updateAllFace, renderSelf, renderEnvironment, layer, parentRenderable, parentTechniqueGroup),
|
---|
31 | RenderTechnique(parentRenderable, parentTechniqueGroup)
|
---|
32 | {
|
---|
33 | switch(layer)
|
---|
34 | {
|
---|
35 | case 0:
|
---|
36 | texturePostFix = "_DISTANCECUBEMAP";
|
---|
37 | break;
|
---|
38 | case 1:
|
---|
39 | texturePostFix = "_DISTANCECUBEMAP_L1";
|
---|
40 | break;
|
---|
41 | case 2:
|
---|
42 | texturePostFix = "_DISTANCECUBEMAP_L2";
|
---|
43 | break;
|
---|
44 | case 3:
|
---|
45 | texturePostFix = "_DISTANCECUBEMAP_L3";
|
---|
46 | break;
|
---|
47 | case 4:
|
---|
48 | texturePostFix = "_DISTANCECUBEMAP_L4";
|
---|
49 | break;
|
---|
50 | case 5:
|
---|
51 | texturePostFix = "_DISTANCECUBEMAP_L5";
|
---|
52 | break;
|
---|
53 | case 6:
|
---|
54 | texturePostFix = "_DISTANCECUBEMAP_L6";
|
---|
55 | break;
|
---|
56 | }
|
---|
57 | if(sharedRuns->getRun(cubemapLayer) == 0)
|
---|
58 | sharedRuns->addRun(cubemapLayer, createCubeMapRun());
|
---|
59 |
|
---|
60 | distanceCubeMapRunChanged(sharedRuns->getRun(cubemapLayer));
|
---|
61 | }
|
---|
62 |
|
---|
63 |
|
---|
64 | OgreDistanceCubeMapRenderTechnique::~OgreDistanceCubeMapRenderTechnique()
|
---|
65 | {
|
---|
66 |
|
---|
67 | }
|
---|
68 |
|
---|
69 | void OgreDistanceCubeMapRenderTechnique::update(unsigned long frameNum)
|
---|
70 | {
|
---|
71 | DistanceCubeMapRenderTechnique::update(frameNum);
|
---|
72 | }
|
---|
73 |
|
---|
74 | void OgreDistanceCubeMapRenderTechnique::distanceCubeMapRunChanged(RenderingRun* run)
|
---|
75 | {
|
---|
76 | OgreCubeMapRenderTechnique::cubeMapRunChanged(run);
|
---|
77 | /* OgreCubeMapRenderingRun* cuberun =(OgreCubeMapRenderingRun*) (run->asOgreRenderingRun());
|
---|
78 | String cubemapname = cuberun->getCubeMapTextureName();
|
---|
79 |
|
---|
80 | pass->getTextureUnitState(texID)->setTextureName(cubemapname);*/
|
---|
81 | }
|
---|
82 |
|
---|
83 | void OgreDistanceCubeMapRenderTechnique::distanceCubeMapRunUpdated(RenderingRun* run)
|
---|
84 | {
|
---|
85 | GpuProgramParametersSharedPtr fpParams = pass->getFragmentProgramParameters();
|
---|
86 | Vector3 center = ((OgreSharedRuns*) sharedRuns)->getRootPosition(cubemapLayer);
|
---|
87 | fpParams->setNamedConstant("lastCenter",center);
|
---|
88 |
|
---|
89 | OgreCubeMapRenderTechnique::cubeMapRunUpdated(run);
|
---|
90 | }
|
---|
91 |
|
---|
92 |
|
---|
93 |
|
---|
94 | ///Technique factory
|
---|
95 | OgreDistanceCubeMapRenderTechniqueFactory::OgreDistanceCubeMapRenderTechniqueFactory()
|
---|
96 | {
|
---|
97 | typeName = "DistanceCubeMap";
|
---|
98 | }
|
---|
99 |
|
---|
100 | OgreRenderTechnique* OgreDistanceCubeMapRenderTechniqueFactory::createInstance(
|
---|
101 | IllumTechniqueParams* params,
|
---|
102 | Pass* pass,
|
---|
103 | OgreRenderable* parentRenderable,
|
---|
104 | OgreTechniqueGroup* parentTechniqueGroup)
|
---|
105 | {
|
---|
106 | OgreCubeMapRenderTechniqueFactory::resetParams();
|
---|
107 | texID = 1;
|
---|
108 | environmentMaterial = "GTP/Basic/Distance";
|
---|
109 | selfMaterial = "GTP/Basic/Distance";
|
---|
110 | triggerName = "ILLUM_TRIGGER_DISTANCE";
|
---|
111 | OgreCubeMapRenderTechniqueFactory::parseParams(params);
|
---|
112 | parseParams(params);
|
---|
113 |
|
---|
114 | OgreDistanceCubeMapRenderTechnique* result = new OgreDistanceCubeMapRenderTechnique(
|
---|
115 | startFrame,
|
---|
116 | cubeMapUpdateInterval,
|
---|
117 | cubeMapResolution,
|
---|
118 | texID,
|
---|
119 | useDistCalc,
|
---|
120 | useFaceAngleCalc,
|
---|
121 | distTolerance,
|
---|
122 | angleTolerance,
|
---|
123 | updateAllFace,
|
---|
124 | renderSelf,
|
---|
125 | renderEnvironment,
|
---|
126 | selfMaterial,
|
---|
127 | environmentMaterial,
|
---|
128 | layer,
|
---|
129 | getMinMax,
|
---|
130 | attachToTexUnit,
|
---|
131 | minVariableName,
|
---|
132 | maxVariableName,
|
---|
133 | triggerName,
|
---|
134 | pass,
|
---|
135 | parentRenderable,
|
---|
136 | parentTechniqueGroup);
|
---|
137 |
|
---|
138 | return result;
|
---|
139 | }
|
---|
140 |
|
---|