15 #ifndef COMPONENTS_SCENEOBJECT_H_ 
   16 #define COMPONENTS_SCENEOBJECT_H_ 
   19 #include "components_generated.h" 
   20 #include "corgi/component.h" 
   21 #include "mathfu/constants.h" 
   22 #include "motive/motivator.h" 
   23 #include "scene_description.h" 
   36       : global_matrix_(mathfu::mat4::Identity()),
 
   37         tint_(mathfu::kOnes4f),
 
   41   void Initialize(motive::MotiveEngine* engine);
 
   57   void SetRotation(
const mathfu::vec3& rotation) {
 
   58     transform_.SetChildValue3f(kRotateAboutX, rotation);
 
   60   void SetRotationAboutX(
float angle) {
 
   61     transform_.SetChildValue1f(kRotateAboutX, angle);
 
   63   void SetRotationAboutY(
float angle) {
 
   64     transform_.SetChildValue1f(kRotateAboutY, angle);
 
   66   void SetRotationAboutZ(
float angle) {
 
   67     transform_.SetChildValue1f(kRotateAboutZ, angle);
 
   69   void SetRotationAboutAxis(
float angle, fplbase::Axis axis) {
 
   70     transform_.SetChildValue1f(kRotateAboutX + axis, angle);
 
   72   void SetPreRotation(
const mathfu::vec3& rotation) {
 
   73     transform_.SetChildValue3f(kPreRotateAboutX, rotation);
 
   75   void SetPreRotationAboutX(
float angle) {
 
   76     transform_.SetChildValue1f(kPreRotateAboutX, angle);
 
   78   void SetPreRotationAboutY(
float angle) {
 
   79     transform_.SetChildValue1f(kPreRotateAboutY, angle);
 
   81   void SetPreRotationAboutZ(
float angle) {
 
   82     transform_.SetChildValue1f(kPreRotateAboutZ, angle);
 
   84   void SetPreRotationAboutAxis(
float angle, fplbase::Axis axis) {
 
   85     transform_.SetChildValue1f(kPreRotateAboutX + axis, angle);
 
   87   void SetTranslation(
const mathfu::vec3& translation) {
 
   88     transform_.SetChildValue3f(kTranslateX, translation);
 
   90   void SetScale(
const mathfu::vec3& scale) {
 
   91     transform_.SetChildValue3f(kScaleX, scale);
 
   93   void SetScaleX(
float scale) { transform_.SetChildValue1f(kScaleX, scale); }
 
   94   void SetScaleY(
float scale) { transform_.SetChildValue1f(kScaleY, scale); }
 
   95   void SetScaleZ(
float scale) { transform_.SetChildValue1f(kScaleZ, scale); }
 
   96   void SetOriginPoint(
const mathfu::vec3& origin) {
 
   97     transform_.SetChildValue3f(kTranslateToOriginX, -origin);
 
  101   mathfu::vec3 Translation()
 const {
 
  102     return transform_.ChildValue3f(kTranslateX);
 
  104   mathfu::vec3 Rotation()
 const {
 
  105     return transform_.ChildValue3f(kRotateAboutX);
 
  107   mathfu::vec3 Scale()
 const { 
return transform_.ChildValue3f(kScaleX); }
 
  108   mathfu::vec3 OriginPoint()
 const {
 
  109     return transform_.ChildValue3f(kTranslateToOriginX);
 
  112   const mathfu::mat4& LocalMatrix()
 const { 
return transform_.Value(); }
 
  113   const mathfu::vec3 GlobalPosition()
 const {
 
  114     return global_matrix_.TranslationVector3D();
 
  116   void set_global_matrix(
const mathfu::mat4& m) { global_matrix_ = m; }
 
  117   const mathfu::mat4& global_matrix()
 const { 
return global_matrix_; }
 
  119   bool HasParent()
 const { 
return parent_.IsValid(); }
 
  120   corgi::EntityRef& parent() { 
return parent_; }
 
  121   const corgi::EntityRef& parent()
 const { 
return parent_; }
 
  122   void set_parent(corgi::EntityRef& parent) { parent_ = parent; }
 
  124   mathfu::vec4 tint()
 const { 
return mathfu::vec4(tint_); }
 
  125   void set_tint(
const mathfu::vec4& tint) { tint_ = tint; }
 
  127   uint16_t renderable_id()
 const { 
return renderable_id_; }
 
  128   void set_renderable_id(uint16_t 
id) { renderable_id_ = id; }
 
  130   uint16_t variant()
 const { 
return variant_; }
 
  131   void set_variant(uint16_t variant) { variant_ = variant; }
 
  133   bool visible()
 const { 
return visible_; }
 
  134   void set_visible(
bool visible) { visible_ = visible; }
 
  141   enum TransformMatrixOperations {
 
  157     kNumTransformMatrixOperations
 
  161   mathfu::mat4 global_matrix_;
 
  165   motive::MatrixMotivator4f transform_;
 
  172   corgi::EntityRef parent_;
 
  175   mathfu::vec4_packed tint_;
 
  178   uint16_t renderable_id_;
 
  193   virtual void AddFromRawData(corgi::EntityRef& entity, 
const void* data);
 
  194   virtual void InitEntity(corgi::EntityRef& entity);
 
  198   void UpdateGlobalMatrix(corgi::EntityRef& entity,
 
  199                           std::vector<bool>& matrix_calculated);
 
  200   void UpdateGlobalMatrices();
 
  201   bool VisibleInHierarchy(
const corgi::EntityRef& entity) 
const;
 
  203   motive::MotiveEngine* engine_;
 
  212 #endif  // COMPONENTS_SCENEOBJECT_H_ 
Definition: scene_object.h:189
Definition: scene_description.h:60
Definition: scene_object.h:33