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

Revision 2960, 1.4 KB checked in by mattausch, 16 years ago (diff)
RevLine 
[2840]1#include "Transform3.h"
2#include "RenderState.h"
[2839]3
4
5namespace CHCDemoEngine
6{
7
[2840]8CGparameter Transform3::sModelMatrixParam;
[2839]9
[2952]10
[2957]11Transform3::Transform3(const Matrix4x4 &trafo): mMatrix(trafo)
[2839]12{
[2957]13        mIsIdentity = false;
[2839]14}
15
16
[2957]17Transform3::Transform3()
[2839]18{
[2957]19        Reset();
[2839]20}
21
22
[2840]23void Transform3::Load(RenderState *state)
[2839]24{
[2957]25        if (mIsIdentity) return;
[2952]26       
[2960]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
[2955]33        if (state->GetRenderPassType() == RenderState::DEFERRED)
[2839]34        {
[2957]35                cgGLSetMatrixParameterfc(sModelMatrixParam, (const float *)mMatrix.x);
[2839]36        }
[2952]37
38        glPushMatrix();
[2957]39        glMultMatrixf((float *)mMatrix.x);
[2839]40}
41
42
[2840]43void Transform3::Unload(RenderState *state)
[2839]44{
[2957]45        if (mIsIdentity) return;
[2839]46
[2960]47        // reset model matrix
[2955]48        if (state->GetRenderPassType() == RenderState::DEFERRED)
[2839]49        {
50                static Matrix4x4 identity = IdentityMatrix();
51                cgGLSetMatrixParameterfc(sModelMatrixParam, (const float *)identity.x);
52        }
[2952]53
54        glPopMatrix();
[2839]55}
56
[2957]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
[2839]72}
Note: See TracBrowser for help on using the repository browser.