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

Revision 2782, 1.2 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
20void SceneEntity::Render(RenderState *state)
21{
22        if (mMaterial) mMaterial->Render(state);
23
24        if (mTransform)
25        {
26                glPushMatrix();
27                glMultMatrixf((float *)mTransform->x);
28                mGeometry->Render(state);
29
30                glPopMatrix();
31        }
32        else
33        {
34                mGeometry->Render(state);
35        }
36}
37
38
39void SceneEntity::SetGeometry(Geometry *geom)
40{
41        mGeometry = geom;
42}
43
44
45void SceneEntity::SetTransformation(Matrix4x4 *trafo)
46{
47        mTransform = trafo;
48}
49
50
51void SceneEntity::SetMaterial(Material *mat)
52{
53        mMaterial = mat;
54}
55
56
57void SceneEntity::SetLastRendered(int lastRendered)
58{
59        mLastRendered = lastRendered;
60}
61
62
63int SceneEntity::GetLastRendered() const
64{
65        return mLastRendered;
66}
67
68
69AxisAlignedBox3 SceneEntity::GetBoundingBox() const
70{
71        AxisAlignedBox3 box = mGeometry->GetBoundingBox();
72        if (mTransform) Transform(box, *mTransform);
73
74        return box;
75}
76
77
78}
Note: See TracBrowser for help on using the repository browser.