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