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

Revision 2818, 1.5 KB checked in by mattausch, 16 years ago (diff)

worked on deferred shading

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
10namespace CHCDemoEngine
11{
12
13CGparameter SceneEntity::sModelMatrixParam;
14
15SceneEntity::SceneEntity(Geometry *geometry,
16                                                 Material *mat,
17                                                 Matrix4x4 *trafo):
18mGeometry(geometry), mMaterial(mat), mTransform(trafo), mRenderQueueBucket(NULL)
19{
20}
21
22
23SceneEntity::~SceneEntity()
24{
25}
26
27
28void SceneEntity::Render(RenderState *state)
29{
30        if (mMaterial) mMaterial->Render(state);
31
32        if (mTransform)
33        {
34                cgGLSetMatrixParameterfc(sModelMatrixParam, (const float *)mTransform->x);
35                //glPushMatrix();
36                //glMultMatrixf((float *)mTransform->x);
37                mGeometry->Render(state);
38
39                //glPopMatrix();
40        }
41        else
42        {
43                static Matrix4x4 identity = IdentityMatrix();
44
45                cgGLSetMatrixParameterfc(sModelMatrixParam, (const float *)identity.x);
46                mGeometry->Render(state);
47        }
48}
49
50
51void SceneEntity::SetGeometry(Geometry *geom)
52{
53        mGeometry = geom;
54}
55
56
57void SceneEntity::SetTransformation(Matrix4x4 *trafo)
58{
59        mTransform = trafo;
60}
61
62
63void SceneEntity::SetMaterial(Material *mat)
64{
65        mMaterial = mat;
66}
67
68
69void SceneEntity::SetLastRendered(int lastRendered)
70{
71        mLastRendered = lastRendered;
72}
73
74
75int SceneEntity::GetLastRendered() const
76{
77        return mLastRendered;
78}
79
80
81AxisAlignedBox3 SceneEntity::GetBoundingBox() const
82{
83        AxisAlignedBox3 box = mGeometry->GetBoundingBox();
84        if (mTransform) Transform(box, *mTransform);
85
86        return box;
87}
88
89
90}
Note: See TracBrowser for help on using the repository browser.