Implement Object::Place
Places the object by manipulating its translation matrix.
This commit is contained in:
parent
97b37d3c53
commit
8af03c3f3d
4 changed files with 24 additions and 0 deletions
|
@ -44,6 +44,16 @@ Matrix4::Identity()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* charles::basics::Translation --
|
||||||
|
*/
|
||||||
|
/* static */ Matrix4
|
||||||
|
Matrix4::Translation(const Vector4& p)
|
||||||
|
{
|
||||||
|
return Translation(p.X(), p.Y(), p.Z());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* charles::basics::TranslationMatrix --
|
* charles::basics::TranslationMatrix --
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -30,6 +30,7 @@ struct Matrix4
|
||||||
|
|
||||||
/** Create a 4x4 translation matrix. */
|
/** Create a 4x4 translation matrix. */
|
||||||
static Matrix4 Translation(Double x, Double y, Double z);
|
static Matrix4 Translation(Double x, Double y, Double z);
|
||||||
|
static Matrix4 Translation(const Vector4 &p);
|
||||||
|
|
||||||
Matrix4();
|
Matrix4();
|
||||||
Matrix4(const Double *data);
|
Matrix4(const Double *data);
|
||||||
|
|
|
@ -47,6 +47,16 @@ Object::GetMaterial()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* charles::Object::Place --
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Object::Place(const Vector4 &p)
|
||||||
|
{
|
||||||
|
mTranslation = Matrix4::Translation(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* charles::Object::SetMaterial --
|
* charles::Object::SetMaterial --
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -27,6 +27,8 @@ struct Object
|
||||||
Material& GetMaterial();
|
Material& GetMaterial();
|
||||||
void SetMaterial(const Material& material);
|
void SetMaterial(const Material& material);
|
||||||
|
|
||||||
|
void Place(const basics::Vector4 &p);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if the given ray intersects with this object. Converts the
|
* Determine if the given ray intersects with this object. Converts the
|
||||||
* ray's origin and direction to object space before calling the protected
|
* ray's origin and direction to object space before calling the protected
|
||||||
|
@ -67,6 +69,7 @@ private:
|
||||||
/** Convert `v` to global space from object space. */
|
/** Convert `v` to global space from object space. */
|
||||||
basics::Vector4 FromObjectSpace(const basics::Vector4& v) const;
|
basics::Vector4 FromObjectSpace(const basics::Vector4& v) const;
|
||||||
|
|
||||||
|
|
||||||
/** A translation matrix from global coordinates to this object's space. */
|
/** A translation matrix from global coordinates to this object's space. */
|
||||||
basics::Matrix4 mTranslation;
|
basics::Matrix4 mTranslation;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue