1 | #include "..\include\ogrerenderable.h"
|
---|
2 |
|
---|
3 | OgreRenderable::OgreRenderable(SubEntity* sube, Entity* parentEntity)
|
---|
4 | {
|
---|
5 | renderableType = OGRE_RENDERABLETYPE_SUBENTITY;
|
---|
6 | subEntityRenderable = sube;
|
---|
7 | this->parentEntity = parentEntity;
|
---|
8 | int subEntityNum = 0;
|
---|
9 | updateBounds();
|
---|
10 | for(unsigned int i = 0; i < parentEntity->getNumSubEntities(); i++)
|
---|
11 | {
|
---|
12 | if(parentEntity->getSubEntity(i) == sube)
|
---|
13 | {
|
---|
14 | subEntityNum = i;
|
---|
15 | break;
|
---|
16 | }
|
---|
17 | }
|
---|
18 | name = parentEntity->getName() + "_SE_" + StringConverter::toString(subEntityNum);
|
---|
19 | }
|
---|
20 |
|
---|
21 | OgreRenderable::OgreRenderable(Entity* parentEntity, int subEntityNum)
|
---|
22 | {
|
---|
23 | SubEntity* sube = parentEntity->getSubEntity(subEntityNum);
|
---|
24 | renderableType = OGRE_RENDERABLETYPE_SUBENTITY;
|
---|
25 | subEntityRenderable = sube;
|
---|
26 | this->parentEntity = parentEntity;
|
---|
27 | updateBounds();
|
---|
28 | name = parentEntity->getName() + "_SE_" + StringConverter::toString(subEntityNum);
|
---|
29 | }
|
---|
30 |
|
---|
31 | OgreRenderable::OgreRenderable(BillboardSet* billboardset, ParticleSystem* sys)
|
---|
32 | {
|
---|
33 | renderableType = OGRE_RENDERABLETYPE_BILLBOARDSET;
|
---|
34 | billboardSetRenderable = billboardset;
|
---|
35 | parentParticleSystem = sys;
|
---|
36 | updateBounds();
|
---|
37 | name = sys->getName();
|
---|
38 | }
|
---|
39 |
|
---|
40 | OgreRenderable::~OgreRenderable(void)
|
---|
41 | {
|
---|
42 |
|
---|
43 | }
|
---|
44 |
|
---|
45 | void OgreRenderable::setVisible(bool visible)
|
---|
46 | {
|
---|
47 | switch(renderableType)
|
---|
48 | {
|
---|
49 | case OGRE_RENDERABLETYPE_SUBENTITY:
|
---|
50 | // subEntityRenderable->setVisible(visible);
|
---|
51 | parentEntity->setVisible(visible);
|
---|
52 | break;
|
---|
53 | case OGRE_RENDERABLETYPE_BILLBOARDSET:
|
---|
54 | if(parentParticleSystem != 0)
|
---|
55 | parentParticleSystem->setVisible(visible);
|
---|
56 | else
|
---|
57 | billboardSetRenderable->setVisible(visible);
|
---|
58 | break;
|
---|
59 | default:
|
---|
60 | OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR,
|
---|
61 | "Unknown renderable type! Check RenderTechnique initializations!",
|
---|
62 | "OgreRenderable::setVisible");
|
---|
63 | }
|
---|
64 | }
|
---|
65 |
|
---|
66 | void OgreRenderable::setMaterialName(String& name)
|
---|
67 | {
|
---|
68 | switch(renderableType)
|
---|
69 | {
|
---|
70 | case OGRE_RENDERABLETYPE_SUBENTITY:
|
---|
71 | subEntityRenderable->setMaterialName(name);
|
---|
72 | break;
|
---|
73 | case OGRE_RENDERABLETYPE_BILLBOARDSET:
|
---|
74 | billboardSetRenderable->setMaterialName(name);
|
---|
75 | break;
|
---|
76 | default:
|
---|
77 | OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR,
|
---|
78 | "Unknown renderable type! Check RenderTechnique initializations!",
|
---|
79 | "OgreRenderable::setMaterialName");
|
---|
80 | }
|
---|
81 | }
|
---|
82 |
|
---|
83 | const MaterialPtr& OgreRenderable::getMaterialPtr()
|
---|
84 | {
|
---|
85 | switch(renderableType)
|
---|
86 | {
|
---|
87 | case OGRE_RENDERABLETYPE_SUBENTITY:
|
---|
88 | return subEntityRenderable->getMaterial();
|
---|
89 | case OGRE_RENDERABLETYPE_BILLBOARDSET:
|
---|
90 | return billboardSetRenderable->getMaterial();
|
---|
91 | default:
|
---|
92 | OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR,
|
---|
93 | "Unknown renderable type, can't return material pointer! Check RenderTechnique initializations!",
|
---|
94 | "OgreRenderable::getMaterialPtr");
|
---|
95 | }
|
---|
96 | }
|
---|
97 |
|
---|
98 | void OgreRenderable::setRenderGroup(unsigned char groupID)
|
---|
99 | {
|
---|
100 | switch(renderableType)
|
---|
101 | {
|
---|
102 | case OGRE_RENDERABLETYPE_SUBENTITY:
|
---|
103 | parentEntity->setRenderQueueGroup(groupID);
|
---|
104 | case OGRE_RENDERABLETYPE_BILLBOARDSET:
|
---|
105 | billboardSetRenderable->setRenderQueueGroup(groupID);
|
---|
106 | default:
|
---|
107 | OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR,
|
---|
108 | "Unknown renderable type! Check RenderTechnique initializations!",
|
---|
109 | "OgreRenderable::setRenderGroup");
|
---|
110 | }
|
---|
111 | }
|
---|
112 |
|
---|
113 | bool OgreRenderable::isVisible()
|
---|
114 | {
|
---|
115 | switch(renderableType)
|
---|
116 | {
|
---|
117 | case OGRE_RENDERABLETYPE_SUBENTITY:
|
---|
118 | return subEntityRenderable->isVisible();
|
---|
119 | case OGRE_RENDERABLETYPE_BILLBOARDSET:
|
---|
120 | return billboardSetRenderable->isVisible();
|
---|
121 | default:
|
---|
122 | OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR,
|
---|
123 | "Unknown renderable type! Check RenderTechnique initializations!",
|
---|
124 | "OgreRenderable::isVisible");
|
---|
125 | }
|
---|
126 | }
|
---|
127 |
|
---|
128 | void OgreRenderable::updateBounds()
|
---|
129 | {
|
---|
130 | switch(renderableType)
|
---|
131 | {
|
---|
132 | case OGRE_RENDERABLETYPE_SUBENTITY:
|
---|
133 | parentEntity->getParentSceneNode()->_updateBounds();
|
---|
134 | boundingBox = parentEntity->getWorldBoundingBox(true);
|
---|
135 | boundingSphere = parentEntity->getWorldBoundingSphere(true);
|
---|
136 | break;
|
---|
137 | case OGRE_RENDERABLETYPE_BILLBOARDSET:
|
---|
138 | /* billboardSetRenderable->getParentSceneNode()->_updateBounds();
|
---|
139 | boundingBox = billboardSetRenderable->getWorldBoundingBox(true);
|
---|
140 | boundingSphere = billboardSetRenderable->getWorldBoundingSphere(true);*/
|
---|
141 | parentParticleSystem->getParentSceneNode()->_updateBounds();
|
---|
142 | boundingBox = parentParticleSystem->getParentSceneNode()->_getWorldAABB();
|
---|
143 | boundingSphere.setRadius( (boundingBox.getMaximum() - boundingBox.getMinimum()).length() / 2.0);
|
---|
144 | boundingSphere.setCenter( (boundingBox.getMaximum() + boundingBox.getMinimum()) / 2.0);
|
---|
145 | break;
|
---|
146 | default:
|
---|
147 | OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR,
|
---|
148 | "Unknown renderable type! Check RenderTechnique initializations!",
|
---|
149 | "OgreRenderable::updateBounds");
|
---|
150 | }
|
---|
151 |
|
---|
152 | }
|
---|
153 |
|
---|
154 | Renderable* OgreRenderable::getRenderable()
|
---|
155 | {
|
---|
156 | switch(renderableType)
|
---|
157 | {
|
---|
158 | case OGRE_RENDERABLETYPE_SUBENTITY:
|
---|
159 | return subEntityRenderable;
|
---|
160 | break;
|
---|
161 | case OGRE_RENDERABLETYPE_BILLBOARDSET:
|
---|
162 | return billboardSetRenderable;
|
---|
163 | break;
|
---|
164 | default:
|
---|
165 | OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR,
|
---|
166 | "Unknown renderable type! Check RenderTechnique initializations!",
|
---|
167 | "OgreRenderable::getRenderable");
|
---|
168 | }
|
---|
169 | }
|
---|
170 |
|
---|
171 | void OgreRenderable::notifyCamera(Camera* cam)
|
---|
172 | {
|
---|
173 | switch(renderableType)
|
---|
174 | {
|
---|
175 | case OGRE_RENDERABLETYPE_SUBENTITY:
|
---|
176 | parentEntity->_notifyCurrentCamera(cam);
|
---|
177 | break;
|
---|
178 | case OGRE_RENDERABLETYPE_BILLBOARDSET:
|
---|
179 | parentParticleSystem->_notifyCurrentCamera(cam);
|
---|
180 | break;
|
---|
181 | default:
|
---|
182 | OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR,
|
---|
183 | "Unknown renderable type! Check RenderTechnique initializations!",
|
---|
184 | "OgreRenderable::notifyCamera");
|
---|
185 | }
|
---|
186 | }
|
---|
187 |
|
---|
188 |
|
---|
189 | void OgreRenderable::updateRenderQueue(RenderQueue* rq)
|
---|
190 | {
|
---|
191 | switch(renderableType)
|
---|
192 | {
|
---|
193 | case OGRE_RENDERABLETYPE_SUBENTITY:
|
---|
194 | parentEntity->_updateRenderQueue(rq);
|
---|
195 | break;
|
---|
196 | case OGRE_RENDERABLETYPE_BILLBOARDSET:
|
---|
197 | parentParticleSystem->_updateRenderQueue(rq);
|
---|
198 | break;
|
---|
199 | default:
|
---|
200 | OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR,
|
---|
201 | "Unknown renderable type! Check RenderTechnique initializations!",
|
---|
202 | "OgreRenderable::notifyCamera");
|
---|
203 | }
|
---|
204 | } |
---|