Line | |
---|
1 | #include "SceneEntity.h"
|
---|
2 | #include "glInterface.h"
|
---|
3 | #include "Geometry.h"
|
---|
4 | #include "Material.h"
|
---|
5 | #include "RenderState.h"
|
---|
6 | #include <Cg/cg.h>
|
---|
7 | #include <Cg/cgGL.h>
|
---|
8 |
|
---|
9 |
|
---|
10 | namespace CHCDemoEngine
|
---|
11 | {
|
---|
12 |
|
---|
13 | CGparameter SceneEntity::sModelMatrixParam;
|
---|
14 |
|
---|
15 | SceneEntity::SceneEntity(Matrix4x4 *trafo): mTransform(trafo)
|
---|
16 | {
|
---|
17 | }
|
---|
18 |
|
---|
19 |
|
---|
20 | SceneEntity::~SceneEntity()
|
---|
21 | {
|
---|
22 | }
|
---|
23 |
|
---|
24 |
|
---|
25 | ShapeContainer *SceneEntity::GetCurrentLOD()
|
---|
26 | {
|
---|
27 | if (mLODInfos.empty())
|
---|
28 | return &mShapes;
|
---|
29 |
|
---|
30 | float mDistance = 0.0f;
|
---|
31 |
|
---|
32 | int i = 0;
|
---|
33 |
|
---|
34 | for (int i = 0; i < mLODInfos.size(); ++ i)
|
---|
35 | {
|
---|
36 | if (mLODInfos[i].mDistance > mDistance)
|
---|
37 | return mShapes[i];
|
---|
38 | }
|
---|
39 |
|
---|
40 | return mShapes.last();
|
---|
41 | }
|
---|
42 |
|
---|
43 |
|
---|
44 | void SceneEntity::Render(RenderState *state)
|
---|
45 | {
|
---|
46 | //if (mMaterial) mMaterial->Render(state);
|
---|
47 | float mDistance = 0.0f;
|
---|
48 |
|
---|
49 | ShapeContainer *shapes;
|
---|
50 |
|
---|
51 | shspes = GetCurrentLOD(mDistance);
|
---|
52 |
|
---|
53 | for (int i = 0; i < shapes->size(); ++ i)
|
---|
54 | {
|
---|
55 | (shapes*)[i]->Render(state);
|
---|
56 | }
|
---|
57 | }
|
---|
58 |
|
---|
59 |
|
---|
60 | void SceneEntity::AddShape(Shape *shape)
|
---|
61 | {
|
---|
62 | mShapes.push_back(shape);
|
---|
63 | }
|
---|
64 |
|
---|
65 |
|
---|
66 | void SceneEntity::SetTransformation(Matrix4x4 *trafo)
|
---|
67 | {
|
---|
68 | mTransform = trafo;
|
---|
69 | }
|
---|
70 |
|
---|
71 |
|
---|
72 | void SceneEntity::SetLastRendered(int lastRendered)
|
---|
73 | {
|
---|
74 | mLastRendered = lastRendered;
|
---|
75 | }
|
---|
76 |
|
---|
77 |
|
---|
78 | int SceneEntity::GetLastRendered() const
|
---|
79 | {
|
---|
80 | return mLastRendered;
|
---|
81 | }
|
---|
82 |
|
---|
83 |
|
---|
84 | AxisAlignedBox3 SceneEntity::GetBoundingBox() const
|
---|
85 | {
|
---|
86 | #ifdef TODO
|
---|
87 | AxisAlignedBox3 box = mGeometry->GetBoundingBox();
|
---|
88 | #else
|
---|
89 | AxisAlignedBox3 box;
|
---|
90 | #endif
|
---|
91 | if (mTransform) Transform(box, *mTransform);
|
---|
92 |
|
---|
93 | return box;
|
---|
94 | }
|
---|
95 |
|
---|
96 |
|
---|
97 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.