void Storm3D_Bone::TransformBones(std::vector<Storm3D_Bone*> *bones) { Matrix t; for(unsigned int index = 0; index < bones->size(); ++index) { Storm3D_Bone *b = (*bones)[index]; if(b->useForceTransform) { b->model_tm.CreateRotationMatrix(b->forceRotation); t.CreateTranslationMatrix(b->forcePosition); //b->model_tm = t; b->model_tm.Multiply(t); } else { b->model_tm.CreateRotationMatrix(b->current_rotation); t.CreateTranslationMatrix(b->current_position); b->model_tm.Multiply(t); // Apply hierarchy if(b->parent_index != -1) { assert(b->parent_index < int(index)); b->model_tm.Multiply((*bones)[b->parent_index]->model_tm); } } b->global_tm_ok = false; b->vertex_tm_ok = false; b->InformChangeToChilds(); } for(unsigned int index = 0; index < bones->size(); ++index) { Storm3D_Bone *b = (*bones)[index]; b->global_tm_ok = false; b->vertex_tm_ok = false; // Temp b->current_rotation = b->rotation; b->InformChangeToChilds(); } }
/*! \param position bone position \param rotation bone rotation \param model_position parent model position \param model_rotation parent model rotation */ void Storm3D_Bone::SetOriginalProperties(const Vector &position, const Rotation &rotation, const Vector &model_position, const Rotation &model_rotation) { this->position = position; this->rotation = rotation; // We need original orientations inverse to create vertex tm Matrix r; r.CreateRotationMatrix(model_rotation); Matrix t; t.CreateTranslationMatrix(model_position); original_inverse_tm = r * t; original_inverse_tm.Inverse(); }
void tick() { static float angle = 0.0f; static Vector oldPosition(0.0f, 0.0f, 0.0f); angle += 0.01f; if(m_effect.get()) { Vector position; Vector velocity; switch(m_movementType) { case EMITTER_MOVE_NONE: { position = Vector(0.0f, 0.0f, 0.0f); velocity = Vector(0.0f, 0.0f, 0.0f); } break; case EMITTER_MOVE_CIRCULAR: { position.x = sin(angle) * 10.0f; position.z = cos(angle) * 10.0f + 10.0f; position.y = (sin(angle) + cos(angle)) * 5.0f; velocity = position - oldPosition; oldPosition = position; } break; } Matrix tm; //calcFacingMatrix(tm, velocity); tm.CreateTranslationMatrix(position); m_effect->setTM(tm); m_effect->setVelocity(velocity); } m_particleSystemManager->tick(); }