source: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Shape.cpp @ 2844

Revision 2844, 1.0 KB checked in by mattausch, 16 years ago (diff)

lod starting to work

Line 
1#include "Shape.h"
2#include "Material.h"
3#include "RenderState.h"
4#include "Geometry.h"
5#include "SceneEntity.h"
6#include "Transform3.h"
7
8
9namespace CHCDemoEngine
10{
11
12Shape::Shape(Geometry *geometry, Material *mat, SceneEntity *parent):
13mGeometry(geometry),
14mMaterial(mat),
15mParent(parent),
16mRenderQueueBucket(NULL)
17{
18}
19
20
21Shape::~Shape()
22{}
23
24
25void Shape::Render(RenderState *state)
26{
27        if (mMaterial) mMaterial->Render(state);
28
29        mParent->GetTransform()->Load(state);
30        mGeometry->Render(state);
31        mParent->GetTransform()->Unload(state);
32
33}
34
35
36void Shape::SetGeometry(Geometry *geom)
37{
38        mGeometry = geom;
39}
40
41
42void Shape::SetMaterial(Material *mat)
43{
44        mMaterial = mat;
45}
46
47
48
49AxisAlignedBox3 Shape::GetBoundingBox() const
50{
51        return mGeometry->GetBoundingBox();
52}
53
54
55AxisAlignedBox3 Shape::GetTransformedBoundingBox() const
56{
57        Matrix4x4 *mat = mParent->GetTransform()->GetMatrix();
58
59        if (!mat)
60                return mGeometry->GetBoundingBox();
61
62        return Transform(mGeometry->GetBoundingBox(), *mat);
63}
64
65}
Note: See TracBrowser for help on using the repository browser.