1 | #include "OgreSBBRenderTechnique.h"
|
---|
2 | #include "OgreTechniqueGroup.h"
|
---|
3 | #include "OgreIlluminationManager.h"
|
---|
4 |
|
---|
5 |
|
---|
6 | OgreSBBRenderTechnique::OgreSBBRenderTechnique( unsigned char depthTexID,
|
---|
7 | Pass* pass,
|
---|
8 | OgreRenderable* parentRenderable,
|
---|
9 | OgreTechniqueGroup* parentTechniqueGroup)
|
---|
10 | :RenderTechnique( parentRenderable, parentTechniqueGroup),
|
---|
11 | OgreRenderTechnique(pass, parentRenderable, parentTechniqueGroup),
|
---|
12 | SBBRenderTechnique(parentRenderable, parentTechniqueGroup)
|
---|
13 | {
|
---|
14 | this->depthTexID = depthTexID;
|
---|
15 |
|
---|
16 | OgreIlluminationManager::getSingleton().createGlobalRun(ILLUMRUN_SCENE_CAMERA_DEPTH);
|
---|
17 |
|
---|
18 | OgreSceneCameraDepthRenderingRun* run = (OgreSceneCameraDepthRenderingRun*)
|
---|
19 | OgreIlluminationManager::getSingleton().getGlobalRun(ILLUMRUN_SCENE_CAMERA_DEPTH)->asOgreRenderingRun();
|
---|
20 |
|
---|
21 | Root::getSingleton().addFrameListener(this);
|
---|
22 | OgreIlluminationManager::getSingleton().getMainViewport()
|
---|
23 | ->getTarget()->addListener(this);
|
---|
24 | OgreIlluminationManager::getSingleton().addUpdateListener(this);
|
---|
25 |
|
---|
26 | pass->getTextureUnitState(depthTexID)->setTextureName(run->getDepthTextureName());
|
---|
27 |
|
---|
28 | }
|
---|
29 |
|
---|
30 | void OgreSBBRenderTechnique::preAllUpdates()
|
---|
31 | {
|
---|
32 | lastVisibility = parentOgreRenderable->isVisible();
|
---|
33 | parentOgreRenderable->setVisible(false);
|
---|
34 | }
|
---|
35 | void OgreSBBRenderTechnique::preRenderTargetUpdate (const RenderTargetEvent &evt)
|
---|
36 | {
|
---|
37 | //parentOgreRenderable->setVisible(lastVisibility);
|
---|
38 | }
|
---|
39 | void OgreSBBRenderTechnique::postRenderTargetUpdate (const RenderTargetEvent &evt)
|
---|
40 | {
|
---|
41 | //parentOgreRenderable->setVisible(false);
|
---|
42 | }
|
---|
43 | bool OgreSBBRenderTechnique::frameEnded (const FrameEvent &evt)
|
---|
44 | {
|
---|
45 |
|
---|
46 | return true;
|
---|
47 | }
|
---|
48 | void OgreSBBRenderTechnique::postAllUpdates()
|
---|
49 | {
|
---|
50 | parentOgreRenderable->setVisible(lastVisibility);
|
---|
51 | }
|
---|
52 |
|
---|
53 | OgreSBBRenderTechnique::~OgreSBBRenderTechnique()
|
---|
54 | {
|
---|
55 |
|
---|
56 | }
|
---|
57 |
|
---|
58 | void OgreSBBRenderTechnique::update(unsigned long frameNum)
|
---|
59 | {
|
---|
60 | OgreIlluminationManager::getSingleton().updateGlobalRun(ILLUMRUN_SCENE_CAMERA_DEPTH, frameNum);
|
---|
61 | }
|
---|
62 |
|
---|
63 | namespace SBBParsers
|
---|
64 | {
|
---|
65 | ///Technique parsers
|
---|
66 | void parseDepthTexID(String& params, RenderTechniqueFactory* factory)
|
---|
67 | {
|
---|
68 | OgreSBBRenderTechniqueFactory* f = (OgreSBBRenderTechniqueFactory*) factory;
|
---|
69 | f->depthTexID = StringConverter::parseUnsignedInt(params);
|
---|
70 | }
|
---|
71 | }
|
---|
72 |
|
---|
73 | OgreSBBRenderTechniqueFactory::OgreSBBRenderTechniqueFactory()
|
---|
74 | {
|
---|
75 | typeName = "SphericalBillboard";
|
---|
76 |
|
---|
77 | using namespace SBBParsers;
|
---|
78 |
|
---|
79 | //register parsers
|
---|
80 | this->attributeParsers.insert(AttribParserList::value_type("texture_unit_id", (ILLUM_ATTRIBUTE_PARSER) parseDepthTexID));
|
---|
81 | }
|
---|
82 |
|
---|
83 | OgreRenderTechnique* OgreSBBRenderTechniqueFactory::createInstance(
|
---|
84 | IllumTechniqueParams* params,
|
---|
85 | Pass* pass,
|
---|
86 | OgreRenderable* parentRenderable,
|
---|
87 | OgreTechniqueGroup* parentTechniqueGroup)
|
---|
88 | {
|
---|
89 | //reset parameters
|
---|
90 | depthTexID = 1;
|
---|
91 |
|
---|
92 | parseParams(params);
|
---|
93 |
|
---|
94 | OgreSBBRenderTechnique* result = new OgreSBBRenderTechnique(
|
---|
95 | depthTexID,
|
---|
96 | pass,
|
---|
97 | parentRenderable,
|
---|
98 | parentTechniqueGroup);
|
---|
99 | return result;
|
---|
100 | }
|
---|
101 |
|
---|
102 |
|
---|
103 |
|
---|