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 |
|
---|
10 | namespace CHCDemoEngine
|
---|
11 | {
|
---|
12 |
|
---|
13 | CGparameter SceneEntity::sModelMatrixParam;
|
---|
14 |
|
---|
15 | SceneEntity::SceneEntity(Geometry *geometry,
|
---|
16 | Material *mat,
|
---|
17 | Matrix4x4 *trafo):
|
---|
18 | mGeometry(geometry), mMaterial(mat), mTransform(trafo), mRenderQueueBucket(NULL)
|
---|
19 | {
|
---|
20 | }
|
---|
21 |
|
---|
22 |
|
---|
23 | SceneEntity::~SceneEntity()
|
---|
24 | {
|
---|
25 | }
|
---|
26 |
|
---|
27 |
|
---|
28 | void 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 |
|
---|
51 | void SceneEntity::SetGeometry(Geometry *geom)
|
---|
52 | {
|
---|
53 | mGeometry = geom;
|
---|
54 | }
|
---|
55 |
|
---|
56 |
|
---|
57 | void SceneEntity::SetTransformation(Matrix4x4 *trafo)
|
---|
58 | {
|
---|
59 | mTransform = trafo;
|
---|
60 | }
|
---|
61 |
|
---|
62 |
|
---|
63 | void SceneEntity::SetMaterial(Material *mat)
|
---|
64 | {
|
---|
65 | mMaterial = mat;
|
---|
66 | }
|
---|
67 |
|
---|
68 |
|
---|
69 | void SceneEntity::SetLastRendered(int lastRendered)
|
---|
70 | {
|
---|
71 | mLastRendered = lastRendered;
|
---|
72 | }
|
---|
73 |
|
---|
74 |
|
---|
75 | int SceneEntity::GetLastRendered() const
|
---|
76 | {
|
---|
77 | return mLastRendered;
|
---|
78 | }
|
---|
79 |
|
---|
80 |
|
---|
81 | AxisAlignedBox3 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.