source: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Transform3.cpp @ 2960

Revision 2960, 1.4 KB checked in by mattausch, 16 years ago (diff)
Line 
1#include "Transform3.h"
2#include "RenderState.h"
3
4
5namespace CHCDemoEngine
6{
7
8CGparameter Transform3::sModelMatrixParam;
9
10
11Transform3::Transform3(const Matrix4x4 &trafo): mMatrix(trafo)
12{
13        mIsIdentity = false;
14}
15
16
17Transform3::Transform3()
18{
19        Reset();
20}
21
22
23void Transform3::Load(RenderState *state)
24{
25        if (mIsIdentity) return;
26       
27        // note: would not need to pass the model matrix,
28        // as all required information is avaiabl in the glstate
29        // however, we require it compute the word positions,
30        // as computing the world position by use the inverse of the viewprojection
31        // matrix turned out to be too inaccurate for temporal reprojection
32
33        if (state->GetRenderPassType() == RenderState::DEFERRED)
34        {
35                cgGLSetMatrixParameterfc(sModelMatrixParam, (const float *)mMatrix.x);
36        }
37
38        glPushMatrix();
39        glMultMatrixf((float *)mMatrix.x);
40}
41
42
43void Transform3::Unload(RenderState *state)
44{
45        if (mIsIdentity) return;
46
47        // reset model matrix
48        if (state->GetRenderPassType() == RenderState::DEFERRED)
49        {
50                static Matrix4x4 identity = IdentityMatrix();
51                cgGLSetMatrixParameterfc(sModelMatrixParam, (const float *)identity.x);
52        }
53
54        glPopMatrix();
55}
56
57
58void Transform3::MultMatrix(const Matrix4x4 &trafo)
59{
60        mIsIdentity = false;
61        mMatrix = mMatrix * trafo;
62}
63
64
65void Transform3::Reset()
66{
67        mIsIdentity = true;
68        mMatrix = IdentityMatrix();
69}
70
71
72}
Note: See TracBrowser for help on using the repository browser.