1 | #include "OgreCausticCasterRenderTechnique.h"
|
---|
2 | #include "OgreTechniqueGroup.h"
|
---|
3 | #include "OgreCausticCubeMapRenderingRun.h"
|
---|
4 | #include "OgrePhotonMapRenderingRun.h"
|
---|
5 | #include "OgreDistanceCubeMapRenderingRun.h"
|
---|
6 |
|
---|
7 |
|
---|
8 | OgreCausticCasterRenderTechnique::OgreCausticCasterRenderTechnique(unsigned long startFrame,
|
---|
9 | unsigned long photonMapUpdateInterval,
|
---|
10 | unsigned int photonMapResolution,
|
---|
11 | unsigned int causticCubeMapResolution,
|
---|
12 | String photonMapMaterialName,
|
---|
13 | String causticMapMaterialName,
|
---|
14 | unsigned char photonMapTexID,
|
---|
15 | bool updateAllFace,
|
---|
16 | bool useDistance,
|
---|
17 | Pass* pass,
|
---|
18 | OgreRenderable* parentRenderable,
|
---|
19 | OgreTechniqueGroup* parentTechniqueGroup)
|
---|
20 | :OgreRenderTechnique( pass, parentRenderable, parentTechniqueGroup),
|
---|
21 | CausticCasterRenderTechnique(startFrame, photonMapUpdateInterval, photonMapResolution, causticCubeMapResolution, updateAllFace, useDistance, parentRenderable, parentTechniqueGroup),
|
---|
22 | RenderTechnique( parentRenderable, parentTechniqueGroup)
|
---|
23 | {
|
---|
24 | this->photonMapMaterialName = photonMapMaterialName;
|
---|
25 | this->causticMapMaterialName = causticMapMaterialName;
|
---|
26 | this->photonMapTexID = photonMapTexID;
|
---|
27 |
|
---|
28 | if(sharedRuns->getRun(ILLUMRUN_CAUSTIC_CUBEMAP) == 0)
|
---|
29 | sharedRuns->addRun(ILLUMRUN_CAUSTIC_CUBEMAP, createCausticCubeMapRun());
|
---|
30 | if(sharedRuns->getRun(ILLUMRUN_PHOTONMAP) == 0)
|
---|
31 | sharedRuns->addRun(ILLUMRUN_PHOTONMAP, createPhotonMapRun());
|
---|
32 |
|
---|
33 | if(useDistance)
|
---|
34 | {
|
---|
35 | if(sharedRuns->getRun(ILLUMRUN_DISTANCE_CUBEMAP) == 0)
|
---|
36 | sharedRuns->addRun(ILLUMRUN_DISTANCE_CUBEMAP, createDistanceCubeMapRun());
|
---|
37 | distanceCubeMapRunChanged(sharedRuns->getRun(ILLUMRUN_DISTANCE_CUBEMAP));
|
---|
38 | }
|
---|
39 |
|
---|
40 | photonMapRunChanged(sharedRuns->getRun(ILLUMRUN_PHOTONMAP));
|
---|
41 | causticCubeMapRunChanged(sharedRuns->getRun(ILLUMRUN_CAUSTIC_CUBEMAP));
|
---|
42 | }
|
---|
43 |
|
---|
44 | OgreCausticCasterRenderTechnique::~OgreCausticCasterRenderTechnique()
|
---|
45 | {
|
---|
46 |
|
---|
47 | }
|
---|
48 |
|
---|
49 | void OgreCausticCasterRenderTechnique::photonMapRunChanged(RenderingRun* run)
|
---|
50 | {
|
---|
51 | OgreCausticCubeMapRenderingRun* caurun = (OgreCausticCubeMapRenderingRun*)
|
---|
52 | sharedRuns->getRun(ILLUMRUN_CAUSTIC_CUBEMAP)->asOgreRenderingRun();
|
---|
53 | caurun->photonMapChanged(sharedRuns->getRun(ILLUMRUN_PHOTONMAP));
|
---|
54 | }
|
---|
55 |
|
---|
56 | void OgreCausticCasterRenderTechnique::distanceCubeMapRunChanged(RenderingRun* run)
|
---|
57 | {
|
---|
58 | if(useDistance)
|
---|
59 | {
|
---|
60 | OgrePhotonMapRenderingRun* photonrun = (OgrePhotonMapRenderingRun*)
|
---|
61 | sharedRuns->getRun(ILLUMRUN_PHOTONMAP)->asOgreRenderingRun();
|
---|
62 | photonrun->distanceCubeMapChanged(sharedRuns->getRun(ILLUMRUN_DISTANCE_CUBEMAP));
|
---|
63 | }
|
---|
64 | }
|
---|
65 |
|
---|
66 | void OgreCausticCasterRenderTechnique::causticCubeMapRunChanged(RenderingRun* run)
|
---|
67 | {
|
---|
68 | }
|
---|
69 |
|
---|
70 | RenderingRun* OgreCausticCasterRenderTechnique::createPhotonMapRun()
|
---|
71 | {
|
---|
72 | return new OgrePhotonMapRenderingRun((OgreSharedRuns*) sharedRuns,
|
---|
73 | parentOgreRenderable->getName() + "_PHOTONMAP",
|
---|
74 | startFrame,
|
---|
75 | photonMapUpdateInterval,
|
---|
76 | photonMapResolution,
|
---|
77 | photonMapMaterialName,
|
---|
78 | useDistance);
|
---|
79 |
|
---|
80 | }
|
---|
81 |
|
---|
82 | RenderingRun* OgreCausticCasterRenderTechnique::createCausticCubeMapRun()
|
---|
83 | {
|
---|
84 | return new OgreCausticCubeMapRenderingRun((OgreSharedRuns*) sharedRuns,
|
---|
85 | parentOgreRenderable->getName() + "_CAUSTICCUBEMAP",
|
---|
86 | startFrame,
|
---|
87 | photonMapUpdateInterval,
|
---|
88 | causticCubeMapResolution,
|
---|
89 | causticMapMaterialName,
|
---|
90 | photonMapTexID,
|
---|
91 | updateAllFace
|
---|
92 | );
|
---|
93 |
|
---|
94 | }
|
---|
95 |
|
---|
96 | RenderingRun* OgreCausticCasterRenderTechnique::createDistanceCubeMapRun()
|
---|
97 | {
|
---|
98 | return new OgreDistanceCubeMapRenderingRun((OgreSharedRuns*) sharedRuns,
|
---|
99 | parentOgreRenderable->getName() + "_DISTANCECUBEMAP",
|
---|
100 | startFrame,
|
---|
101 | photonMapUpdateInterval,
|
---|
102 | causticCubeMapResolution,
|
---|
103 | 0,
|
---|
104 | 0,
|
---|
105 | 0,
|
---|
106 | 0,
|
---|
107 | updateAllFace
|
---|
108 | );
|
---|
109 |
|
---|
110 | }
|
---|
111 |
|
---|
112 | String& OgreCausticCasterRenderTechnique::getCausticCubeMapName()
|
---|
113 | {
|
---|
114 | return ((OgreCausticCubeMapRenderingRun*) sharedRuns->getRun(ILLUMRUN_CAUSTIC_CUBEMAP)->asOgreRenderingRun())->
|
---|
115 | getCausticCubeMapTextureName();
|
---|
116 | }
|
---|