1 | #include "OgreDistanceCubeMapRenderTechnique.h"
|
---|
2 | #include "OgreTechniqueGroup.h"
|
---|
3 | #include "OgreDistanceCubeMapRenderingRun.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 | Pass* pass,
|
---|
15 | OgreRenderable* parentRenderable,
|
---|
16 | OgreTechniqueGroup* parentTechniqueGroup)
|
---|
17 | :OgreRenderTechnique( pass, parentRenderable, parentTechniqueGroup),
|
---|
18 | DistanceCubeMapRenderTechnique(startFrame, cubeMapUpdateInterval, cubeMapResolution, useDistCalc, useFaceAngleCalc, distTolerance, angleTolerance, updateAllFace, parentRenderable, parentTechniqueGroup),
|
---|
19 | RenderTechnique(parentRenderable, parentTechniqueGroup)
|
---|
20 | {
|
---|
21 | this->texID = texID;
|
---|
22 |
|
---|
23 | if(sharedRuns->getRun(ILLUMRUN_DISTANCE_CUBEMAP) == 0)
|
---|
24 | sharedRuns->addRun(ILLUMRUN_DISTANCE_CUBEMAP, createDistanceCubeMapRun());
|
---|
25 |
|
---|
26 | distanceCubeMapRunChanged(sharedRuns->getRun(ILLUMRUN_DISTANCE_CUBEMAP));
|
---|
27 | }
|
---|
28 |
|
---|
29 |
|
---|
30 | OgreDistanceCubeMapRenderTechnique::~OgreDistanceCubeMapRenderTechnique()
|
---|
31 | {
|
---|
32 |
|
---|
33 | }
|
---|
34 |
|
---|
35 | void OgreDistanceCubeMapRenderTechnique::update(unsigned long frameNum)
|
---|
36 | {
|
---|
37 | DistanceCubeMapRenderTechnique::update(frameNum);
|
---|
38 | }
|
---|
39 |
|
---|
40 | void OgreDistanceCubeMapRenderTechnique::distanceCubeMapRunChanged(RenderingRun* run)
|
---|
41 | {
|
---|
42 | OgreDistanceCubeMapRenderingRun* cuberun =(OgreDistanceCubeMapRenderingRun*) (run->asOgreRenderingRun());
|
---|
43 | String cubemapname = cuberun->getDistanceCubeMapTextureName();
|
---|
44 |
|
---|
45 | pass->getTextureUnitState(texID)->setTextureName(cubemapname);
|
---|
46 | }
|
---|
47 |
|
---|
48 | void OgreDistanceCubeMapRenderTechnique::distanceCubeMapRunUpdated(RenderingRun* run)
|
---|
49 | {
|
---|
50 | GpuProgramParametersSharedPtr fpParams = pass->getFragmentProgramParameters();
|
---|
51 | Vector3 center = ((OgreSharedRuns*) sharedRuns)->getRootPosition(ILLUMRUN_DISTANCE_CUBEMAP);
|
---|
52 | fpParams->setNamedConstant("lastCenter",center);
|
---|
53 | }
|
---|
54 |
|
---|
55 | RenderingRun* OgreDistanceCubeMapRenderTechnique::createDistanceCubeMapRun()
|
---|
56 | {
|
---|
57 | return new OgreDistanceCubeMapRenderingRun( (OgreSharedRuns*) parentTechniqueGroup->getSharedRuns(),
|
---|
58 | parentOgreRenderable->getName() + "_DISTANCECUBEMAP",
|
---|
59 | startFrame,
|
---|
60 | cubeMapUpdateInterval,
|
---|
61 | cubeMapResolution,
|
---|
62 | useDistCalc,
|
---|
63 | useFaceAngleCalc,
|
---|
64 | distTolerance,
|
---|
65 | angleTolerance,
|
---|
66 | updateAllFace);
|
---|
67 | }
|
---|
68 |
|
---|
69 |
|
---|