source: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.cpp @ 2792

Revision 2792, 1.4 KB checked in by mattausch, 17 years ago (diff)
Line 
1#include "SceneEntity.h"
2#include "glInterface.h"
3#include "Geometry.h"
4#include "Material.h"
5#include "RenderState.h"
6
7
8namespace CHCDemoEngine
9{
10
11
12SceneEntity::SceneEntity(Geometry *geometry,
13                                                 Material *mat,
14                                                 Matrix4x4 *trafo):
15mGeometry(geometry), mMaterial(mat), mTransform(trafo)
16{
17}
18
19
20SceneEntity::~SceneEntity()
21{
22        // delete only trafo here, the other members could be shared
23        // among several entities and are therefore handled separately
24        DEL_PTR(mTransform);
25}
26
27
28void SceneEntity::Render(RenderState *state)
29{
30        if (mMaterial) mMaterial->Render(state);
31
32        if (mTransform)
33        {
34                glPushMatrix();
35                glMultMatrixf((float *)mTransform->x);
36                mGeometry->Render(state);
37
38                glPopMatrix();
39        }
40        else
41        {
42                mGeometry->Render(state);
43        }
44}
45
46
47void SceneEntity::SetGeometry(Geometry *geom)
48{
49        mGeometry = geom;
50}
51
52
53void SceneEntity::SetTransformation(Matrix4x4 *trafo)
54{
55        mTransform = trafo;
56}
57
58
59void SceneEntity::SetMaterial(Material *mat)
60{
61        mMaterial = mat;
62}
63
64
65void SceneEntity::SetLastRendered(int lastRendered)
66{
67        mLastRendered = lastRendered;
68}
69
70
71int SceneEntity::GetLastRendered() const
72{
73        return mLastRendered;
74}
75
76
77AxisAlignedBox3 SceneEntity::GetBoundingBox() const
78{
79        AxisAlignedBox3 box = mGeometry->GetBoundingBox();
80        if (mTransform) Transform(box, *mTransform);
81
82        return box;
83}
84
85
86}
Note: See TracBrowser for help on using the repository browser.