Spinner.cpp 935 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include <Atomic/Scene/Node.h>
  2. #include "Spinner.h"
  3. //
  4. // this class is for eye candy-ization only
  5. //
  6. Rotator::Rotator(Context* context) :
  7. LogicComponent(context),
  8. rotationSpeed_(Vector3::ZERO)
  9. {
  10. SetUpdateEventMask(USE_UPDATE);
  11. }
  12. void Rotator::SetRotationSpeed(const Vector3& speedxyz)
  13. {
  14. rotationSpeed_ = speedxyz;
  15. }
  16. void Rotator::Update(float timeStep)
  17. {
  18. node_->Rotate(Quaternion(rotationSpeed_.x_ * timeStep, rotationSpeed_.y_ * timeStep, rotationSpeed_.z_ * timeStep));
  19. }
  20. /*
  21. "atomic component";
  22. //define inspector fields
  23. var inspectorFields = {
  24. //value speed will be able to be edited from editor
  25. //default value sets to the 1.0, so speed has a number type
  26. speed: 1.0
  27. };
  28. exports.component = function(self) {
  29. //update function calls each frame
  30. self.update = function(timeStep) {
  31. //rotate node around Y axis
  32. self.node.yaw(timeStep * 75 * self.speed);
  33. };
  34. };
  35. */