1 | #include "OgreCubeMapRenderTechnique.h"
|
---|
2 | #include "OgreTechniqueGroup.h"
|
---|
3 | #include "OgreColorCubeMapRenderingRun.h"
|
---|
4 |
|
---|
5 | OgreCubeMapRenderTechnique::OgreCubeMapRenderTechnique(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 | Pass* pass,
|
---|
16 | OgreRenderable* parentRenderable,
|
---|
17 | OgreTechniqueGroup* parentTechniqueGroup)
|
---|
18 | :OgreRenderTechnique( pass, parentRenderable, parentTechniqueGroup),
|
---|
19 | CubeMapRenderTechnique(startFrame, cubeMapUpdateInterval, cubeMapResolution, useDistCalc, useFaceAngleCalc, distTolerance, angleTolerance, updateAllFace, renderSelf, parentRenderable, parentTechniqueGroup),
|
---|
20 | RenderTechnique(parentRenderable, parentTechniqueGroup)
|
---|
21 | {
|
---|
22 | this->texID = texID;
|
---|
23 | }
|
---|
24 |
|
---|
25 |
|
---|
26 | OgreCubeMapRenderTechnique::~OgreCubeMapRenderTechnique()
|
---|
27 | {
|
---|
28 |
|
---|
29 | }
|
---|
30 |
|
---|
31 | ///Technique Parsers
|
---|
32 | namespace CubemapParsers
|
---|
33 | {
|
---|
34 | void parseStartFrame(String& params, RenderTechniqueFactory* factory)
|
---|
35 | {
|
---|
36 | OgreCubeMapRenderTechniqueFactory* f = (OgreCubeMapRenderTechniqueFactory*) factory;
|
---|
37 | f->startFrame = StringConverter::parseUnsignedLong(params);
|
---|
38 | }
|
---|
39 | void parseCubeMapUpdateInterval(String& params, RenderTechniqueFactory* factory)
|
---|
40 | {
|
---|
41 | OgreCubeMapRenderTechniqueFactory* f = (OgreCubeMapRenderTechniqueFactory*) factory;
|
---|
42 | f->cubeMapUpdateInterval = StringConverter::parseUnsignedLong(params);
|
---|
43 | }
|
---|
44 |
|
---|
45 | void parseCubeMapResolution(String& params, RenderTechniqueFactory* factory)
|
---|
46 | {
|
---|
47 | OgreCubeMapRenderTechniqueFactory* f = (OgreCubeMapRenderTechniqueFactory*) factory;
|
---|
48 | f->cubeMapResolution = StringConverter::parseUnsignedInt(params);
|
---|
49 | }
|
---|
50 |
|
---|
51 | void parseTexID(String& params, RenderTechniqueFactory* factory)
|
---|
52 | {
|
---|
53 | OgreCubeMapRenderTechniqueFactory* f = (OgreCubeMapRenderTechniqueFactory*) factory;
|
---|
54 | f->texID = StringConverter::parseUnsignedInt(params);
|
---|
55 | }
|
---|
56 |
|
---|
57 | void parseUseDistCalc(String& params, RenderTechniqueFactory* factory)
|
---|
58 | {
|
---|
59 | OgreCubeMapRenderTechniqueFactory* f = (OgreCubeMapRenderTechniqueFactory*) factory;
|
---|
60 | // format: on/off tolerance(float)
|
---|
61 | StringVector vecparams = StringUtil::split(params, " \t");
|
---|
62 |
|
---|
63 | if(StringConverter::parseBool(vecparams[0]))//on
|
---|
64 | {
|
---|
65 | f->useDistCalc = true;
|
---|
66 |
|
---|
67 | if(vecparams.size()>1)
|
---|
68 | {
|
---|
69 | f->distTolerance = StringConverter::parseReal(vecparams[1]);
|
---|
70 | }
|
---|
71 | }
|
---|
72 | else
|
---|
73 | {
|
---|
74 | f->useDistCalc = false;
|
---|
75 | }
|
---|
76 | }
|
---|
77 |
|
---|
78 | void parseUseFaceAngleCalc(String& params, RenderTechniqueFactory* factory)
|
---|
79 | {
|
---|
80 | OgreCubeMapRenderTechniqueFactory* f = (OgreCubeMapRenderTechniqueFactory*) factory;
|
---|
81 | // format: on/off tolerance(float)
|
---|
82 | StringVector vecparams = StringUtil::split(params, " \t");
|
---|
83 |
|
---|
84 | if(StringConverter::parseBool(vecparams[0]))//on
|
---|
85 | {
|
---|
86 | f->useFaceAngleCalc = true;
|
---|
87 |
|
---|
88 | if(vecparams.size()>1)
|
---|
89 | {
|
---|
90 | f->angleTolerance = StringConverter::parseReal(vecparams[1]);
|
---|
91 | }
|
---|
92 | }
|
---|
93 | else
|
---|
94 | {
|
---|
95 | f->useFaceAngleCalc = false;
|
---|
96 | }
|
---|
97 | }
|
---|
98 |
|
---|
99 | void parseUpdateAllFace(String& params, RenderTechniqueFactory* factory)
|
---|
100 | {
|
---|
101 | OgreCubeMapRenderTechniqueFactory* f = (OgreCubeMapRenderTechniqueFactory*) factory;
|
---|
102 | f->updateAllFace = StringConverter::parseBool(params);
|
---|
103 | }
|
---|
104 |
|
---|
105 | void parseRenderSelf(String& params, RenderTechniqueFactory* factory)
|
---|
106 | {
|
---|
107 | OgreCubeMapRenderTechniqueFactory* f = (OgreCubeMapRenderTechniqueFactory*) factory;
|
---|
108 | f->renderSelf = StringConverter::parseBool(params);
|
---|
109 | }
|
---|
110 | }
|
---|
111 | ///Technique factory
|
---|
112 | OgreCubeMapRenderTechniqueFactory::OgreCubeMapRenderTechniqueFactory()
|
---|
113 | {
|
---|
114 |
|
---|
115 | using namespace CubemapParsers;
|
---|
116 |
|
---|
117 | //register parsers
|
---|
118 | this->attributeParsers.insert(AttribParserList::value_type("start_frame", (ILLUM_ATTRIBUTE_PARSER) parseStartFrame));
|
---|
119 | this->attributeParsers.insert(AttribParserList::value_type("update_interval", (ILLUM_ATTRIBUTE_PARSER) parseCubeMapUpdateInterval));
|
---|
120 | this->attributeParsers.insert(AttribParserList::value_type("resolution", (ILLUM_ATTRIBUTE_PARSER) parseCubeMapResolution));
|
---|
121 | this->attributeParsers.insert(AttribParserList::value_type("texture_unit_id", (ILLUM_ATTRIBUTE_PARSER) parseTexID));
|
---|
122 | this->attributeParsers.insert(AttribParserList::value_type("distance_calc", (ILLUM_ATTRIBUTE_PARSER) parseUseDistCalc));
|
---|
123 | this->attributeParsers.insert(AttribParserList::value_type("face_angle_calc", (ILLUM_ATTRIBUTE_PARSER) parseUseFaceAngleCalc));
|
---|
124 | this->attributeParsers.insert(AttribParserList::value_type("update_all_face", (ILLUM_ATTRIBUTE_PARSER) parseUpdateAllFace));
|
---|
125 | this->attributeParsers.insert(AttribParserList::value_type("render_self", (ILLUM_ATTRIBUTE_PARSER) parseUpdateAllFace));
|
---|
126 |
|
---|
127 | }
|
---|
128 |
|
---|
129 | void OgreCubeMapRenderTechniqueFactory::resetParams()
|
---|
130 | {
|
---|
131 | startFrame = 1;
|
---|
132 | cubeMapUpdateInterval = 1;
|
---|
133 | cubeMapResolution = 256;
|
---|
134 | texID = 0;
|
---|
135 | useDistCalc = 1;
|
---|
136 | useFaceAngleCalc = false;
|
---|
137 | distTolerance = 2.0;
|
---|
138 | angleTolerance = 2.0;
|
---|
139 | updateAllFace = false;
|
---|
140 | renderSelf = false;
|
---|
141 | } |
---|