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)
|
---|
32 | {
|
---|
33 | renderableType = OGRE_RENDERABLETYPE_BILLBOARDSET;
|
---|
34 | billboardSetRenderable = billboardset;
|
---|
35 | updateBounds();
|
---|
36 | name = billboardset->getName();
|
---|
37 | }
|
---|
38 |
|
---|
39 | OgreRenderable::~OgreRenderable(void)
|
---|
40 | {
|
---|
41 |
|
---|
42 | }
|
---|
43 |
|
---|
44 | void OgreRenderable::setVisible(bool visible)
|
---|
45 | {
|
---|
46 | switch(renderableType)
|
---|
47 | {
|
---|
48 | case OGRE_RENDERABLETYPE_SUBENTITY:
|
---|
49 | subEntityRenderable->setVisible(visible);
|
---|
50 | break;
|
---|
51 | case OGRE_RENDERABLETYPE_BILLBOARDSET:
|
---|
52 | billboardSetRenderable->setVisible(visible);
|
---|
53 | break;
|
---|
54 | default:
|
---|
55 | OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR,
|
---|
56 | "Unknown renderable type! Check RenderTechnique initializations!",
|
---|
57 | "OgreRenderable::setVisible");
|
---|
58 | }
|
---|
59 | }
|
---|
60 |
|
---|
61 | void OgreRenderable::setMaterialName(String& name)
|
---|
62 | {
|
---|
63 | switch(renderableType)
|
---|
64 | {
|
---|
65 | case OGRE_RENDERABLETYPE_SUBENTITY:
|
---|
66 | subEntityRenderable->setMaterialName(name);
|
---|
67 | break;
|
---|
68 | case OGRE_RENDERABLETYPE_BILLBOARDSET:
|
---|
69 | billboardSetRenderable->setMaterialName(name);
|
---|
70 | break;
|
---|
71 | default:
|
---|
72 | OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR,
|
---|
73 | "Unknown renderable type! Check RenderTechnique initializations!",
|
---|
74 | "OgreRenderable::setMaterialName");
|
---|
75 | }
|
---|
76 | }
|
---|
77 |
|
---|
78 | const MaterialPtr& OgreRenderable::getMaterialPtr()
|
---|
79 | {
|
---|
80 | switch(renderableType)
|
---|
81 | {
|
---|
82 | case OGRE_RENDERABLETYPE_SUBENTITY:
|
---|
83 | return subEntityRenderable->getMaterial();
|
---|
84 | case OGRE_RENDERABLETYPE_BILLBOARDSET:
|
---|
85 | return billboardSetRenderable->getMaterial();
|
---|
86 | default:
|
---|
87 | OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR,
|
---|
88 | "Unknown renderable type, can't return material pointer! Check RenderTechnique initializations!",
|
---|
89 | "OgreRenderable::getMaterialPtr");
|
---|
90 | }
|
---|
91 | }
|
---|
92 |
|
---|
93 | void OgreRenderable::setRenderGroup(unsigned char groupID)
|
---|
94 | {
|
---|
95 | switch(renderableType)
|
---|
96 | {
|
---|
97 | case OGRE_RENDERABLETYPE_SUBENTITY:
|
---|
98 | parentEntity->setRenderQueueGroup(groupID);
|
---|
99 | case OGRE_RENDERABLETYPE_BILLBOARDSET:
|
---|
100 | billboardSetRenderable->setRenderQueueGroup(groupID);
|
---|
101 | default:
|
---|
102 | OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR,
|
---|
103 | "Unknown renderable type! Check RenderTechnique initializations!",
|
---|
104 | "OgreRenderable::setRenderGroup");
|
---|
105 | }
|
---|
106 | }
|
---|
107 |
|
---|
108 | bool OgreRenderable::isVisible()
|
---|
109 | {
|
---|
110 | switch(renderableType)
|
---|
111 | {
|
---|
112 | case OGRE_RENDERABLETYPE_SUBENTITY:
|
---|
113 | return subEntityRenderable->isVisible();
|
---|
114 | case OGRE_RENDERABLETYPE_BILLBOARDSET:
|
---|
115 | return billboardSetRenderable->isVisible();
|
---|
116 | default:
|
---|
117 | OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR,
|
---|
118 | "Unknown renderable type! Check RenderTechnique initializations!",
|
---|
119 | "OgreRenderable::isVisible");
|
---|
120 | }
|
---|
121 | }
|
---|
122 |
|
---|
123 | void OgreRenderable::updateBounds()
|
---|
124 | {
|
---|
125 | switch(renderableType)
|
---|
126 | {
|
---|
127 | case OGRE_RENDERABLETYPE_SUBENTITY:
|
---|
128 | parentEntity->getParentSceneNode()->_updateBounds();
|
---|
129 | boundingBox = parentEntity->getWorldBoundingBox(true);
|
---|
130 | boundingSphere = parentEntity->getWorldBoundingSphere(true);
|
---|
131 | break;
|
---|
132 | case OGRE_RENDERABLETYPE_BILLBOARDSET:
|
---|
133 | billboardSetRenderable->getParentSceneNode()->_updateBounds();
|
---|
134 | boundingBox = billboardSetRenderable->getWorldBoundingBox(true);
|
---|
135 | boundingSphere = billboardSetRenderable->getWorldBoundingSphere(true);
|
---|
136 | break;
|
---|
137 | default:
|
---|
138 | OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR,
|
---|
139 | "Unknown renderable type! Check RenderTechnique initializations!",
|
---|
140 | "OgreRenderable::updateBounds");
|
---|
141 | }
|
---|
142 |
|
---|
143 | }
|
---|
144 |
|
---|
145 | Renderable* OgreRenderable::getRenderable()
|
---|
146 | {
|
---|
147 | switch(renderableType)
|
---|
148 | {
|
---|
149 | case OGRE_RENDERABLETYPE_SUBENTITY:
|
---|
150 | return subEntityRenderable;
|
---|
151 | break;
|
---|
152 | case OGRE_RENDERABLETYPE_BILLBOARDSET:
|
---|
153 | return billboardSetRenderable;
|
---|
154 | break;
|
---|
155 | default:
|
---|
156 | OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR,
|
---|
157 | "Unknown renderable type! Check RenderTechnique initializations!",
|
---|
158 | "OgreRenderable::getRenderable");
|
---|
159 | }
|
---|
160 | }
|
---|
161 |
|
---|
162 | void OgreRenderable::notifyCamera(Camera* cam)
|
---|
163 | {
|
---|
164 | switch(renderableType)
|
---|
165 | {
|
---|
166 | case OGRE_RENDERABLETYPE_SUBENTITY:
|
---|
167 | parentEntity->_notifyCurrentCamera(cam);
|
---|
168 | break;
|
---|
169 | case OGRE_RENDERABLETYPE_BILLBOARDSET:
|
---|
170 | billboardSetRenderable->_notifyCurrentCamera(cam);
|
---|
171 | break;
|
---|
172 | default:
|
---|
173 | OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR,
|
---|
174 | "Unknown renderable type! Check RenderTechnique initializations!",
|
---|
175 | "OgreRenderable::notifyCamera");
|
---|
176 | }
|
---|
177 | } |
---|