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->getWorldBoundingBox(true);
|
---|
143 | boundingSphere = parentParticleSystem->getWorldBoundingSphere(true);
|
---|
144 | break;
|
---|
145 | default:
|
---|
146 | OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR,
|
---|
147 | "Unknown renderable type! Check RenderTechnique initializations!",
|
---|
148 | "OgreRenderable::updateBounds");
|
---|
149 | }
|
---|
150 |
|
---|
151 | }
|
---|
152 |
|
---|
153 | Renderable* OgreRenderable::getRenderable()
|
---|
154 | {
|
---|
155 | switch(renderableType)
|
---|
156 | {
|
---|
157 | case OGRE_RENDERABLETYPE_SUBENTITY:
|
---|
158 | return subEntityRenderable;
|
---|
159 | break;
|
---|
160 | case OGRE_RENDERABLETYPE_BILLBOARDSET:
|
---|
161 | return billboardSetRenderable;
|
---|
162 | break;
|
---|
163 | default:
|
---|
164 | OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR,
|
---|
165 | "Unknown renderable type! Check RenderTechnique initializations!",
|
---|
166 | "OgreRenderable::getRenderable");
|
---|
167 | }
|
---|
168 | }
|
---|
169 |
|
---|
170 | void OgreRenderable::notifyCamera(Camera* cam)
|
---|
171 | {
|
---|
172 | switch(renderableType)
|
---|
173 | {
|
---|
174 | case OGRE_RENDERABLETYPE_SUBENTITY:
|
---|
175 | parentEntity->_notifyCurrentCamera(cam);
|
---|
176 | break;
|
---|
177 | case OGRE_RENDERABLETYPE_BILLBOARDSET:
|
---|
178 | billboardSetRenderable->_notifyCurrentCamera(cam);
|
---|
179 | break;
|
---|
180 | default:
|
---|
181 | OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR,
|
---|
182 | "Unknown renderable type! Check RenderTechnique initializations!",
|
---|
183 | "OgreRenderable::notifyCamera");
|
---|
184 | }
|
---|
185 | } |
---|