Revision 2957,
1.3 KB
checked in by mattausch, 16 years ago
(diff) |
preetham working
|
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 |
|
---|
9 | namespace CHCDemoEngine
|
---|
10 | {
|
---|
11 |
|
---|
12 | Shape::Shape(Geometry *geometry, Material *mat, SceneEntity *parent):
|
---|
13 | mGeometry(geometry),
|
---|
14 | mMaterial(mat),
|
---|
15 | mParent(parent),
|
---|
16 | mRenderQueueBucket(NULL)
|
---|
17 | {
|
---|
18 | mCenter = GetBoundingBox().Center();
|
---|
19 | }
|
---|
20 |
|
---|
21 |
|
---|
22 | Shape::~Shape()
|
---|
23 | {}
|
---|
24 |
|
---|
25 |
|
---|
26 | void Shape::Render(RenderState *state)
|
---|
27 | {
|
---|
28 | if (mMaterial)
|
---|
29 | mMaterial->Render(state);
|
---|
30 |
|
---|
31 | mParent->GetTransform()->Load(state);
|
---|
32 | mGeometry->Render(state);
|
---|
33 | mParent->GetTransform()->Unload(state);
|
---|
34 | }
|
---|
35 |
|
---|
36 |
|
---|
37 | void Shape::SetGeometry(Geometry *geom)
|
---|
38 | {
|
---|
39 | mGeometry = geom;
|
---|
40 | }
|
---|
41 |
|
---|
42 |
|
---|
43 | void Shape::SetMaterial(Material *mat)
|
---|
44 | {
|
---|
45 | mMaterial = mat;
|
---|
46 | }
|
---|
47 |
|
---|
48 |
|
---|
49 |
|
---|
50 | AxisAlignedBox3 Shape::GetBoundingBox() const
|
---|
51 | {
|
---|
52 | return mGeometry->GetBoundingBox();
|
---|
53 | }
|
---|
54 |
|
---|
55 |
|
---|
56 | AxisAlignedBox3 Shape::GetTransformedBoundingBox() const
|
---|
57 | {
|
---|
58 | if (mParent->GetTransform()->IsIdentity())
|
---|
59 | return mGeometry->GetBoundingBox();
|
---|
60 |
|
---|
61 | Matrix4x4 mat = mParent->GetTransform()->GetMatrix();
|
---|
62 |
|
---|
63 | return Transform(mGeometry->GetBoundingBox(), mat);
|
---|
64 | }
|
---|
65 |
|
---|
66 |
|
---|
67 | Vector3 Shape::GetCenter() const
|
---|
68 | {
|
---|
69 | if (mParent->GetTransform()->IsIdentity())
|
---|
70 | return mCenter;
|
---|
71 |
|
---|
72 | Matrix4x4 mat = mParent->GetTransform()->GetMatrix();
|
---|
73 |
|
---|
74 | return mat * mCenter;
|
---|
75 | }
|
---|
76 |
|
---|
77 |
|
---|
78 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.