Rev | Line | |
---|
[2839] | 1 | #include "Shape.h"
|
---|
| 2 | #include "Material.h"
|
---|
| 3 | #include "RenderState.h"
|
---|
| 4 | #include "Geometry.h"
|
---|
[2840] | 5 | #include "SceneEntity.h"
|
---|
[2842] | 6 | #include "Transform3.h"
|
---|
[2840] | 7 |
|
---|
[2839] | 8 |
|
---|
| 9 | namespace CHCDemoEngine
|
---|
| 10 | {
|
---|
| 11 |
|
---|
[2840] | 12 | Shape::Shape(Geometry *geometry, Material *mat, SceneEntity *parent):
|
---|
| 13 | mGeometry(geometry),
|
---|
| 14 | mMaterial(mat),
|
---|
| 15 | mParent(parent),
|
---|
| 16 | mRenderQueueBucket(NULL)
|
---|
[2839] | 17 | {
|
---|
[2847] | 18 | mCenter = GetBoundingBox().Center();
|
---|
[2839] | 19 | }
|
---|
| 20 |
|
---|
| 21 |
|
---|
| 22 | Shape::~Shape()
|
---|
| 23 | {}
|
---|
| 24 |
|
---|
| 25 |
|
---|
| 26 | void Shape::Render(RenderState *state)
|
---|
| 27 | {
|
---|
[2867] | 28 | if (mMaterial)
|
---|
| 29 | mMaterial->Render(state);
|
---|
[2839] | 30 |
|
---|
[2842] | 31 | mParent->GetTransform()->Load(state);
|
---|
[2839] | 32 | mGeometry->Render(state);
|
---|
[2842] | 33 | mParent->GetTransform()->Unload(state);
|
---|
[2839] | 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 |
|
---|
[2842] | 49 |
|
---|
| 50 | AxisAlignedBox3 Shape::GetBoundingBox() const
|
---|
| 51 | {
|
---|
| 52 | return mGeometry->GetBoundingBox();
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 |
|
---|
| 56 | AxisAlignedBox3 Shape::GetTransformedBoundingBox() const
|
---|
| 57 | {
|
---|
| 58 | Matrix4x4 *mat = mParent->GetTransform()->GetMatrix();
|
---|
| 59 |
|
---|
[2844] | 60 | if (!mat)
|
---|
| 61 | return mGeometry->GetBoundingBox();
|
---|
[2842] | 62 |
|
---|
[2844] | 63 | return Transform(mGeometry->GetBoundingBox(), *mat);
|
---|
[2842] | 64 | }
|
---|
| 65 |
|
---|
[2847] | 66 |
|
---|
| 67 | Vector3 Shape::GetCenter() const
|
---|
| 68 | {
|
---|
| 69 | Matrix4x4 *mat = mParent->GetTransform()->GetMatrix();
|
---|
| 70 |
|
---|
| 71 | if (!mat) return mCenter;
|
---|
| 72 |
|
---|
| 73 | return (*mat) * mCenter;
|
---|
| 74 | }
|
---|
| 75 |
|
---|
| 76 |
|
---|
[2839] | 77 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.