CommandTransformLinear::CommandTransformLinear(TransformType type, Editor::Axis axis, Editor::RotationPivot pivot, float delta, const QSet<int> &selection, ldraw::model *model) : CommandTransform(selection, model, pivot) { axis_ = axis; type_ = type; delta_ = delta; /* no use for translating 'position' */ if (type == Position) pivot_ = Editor::PivotEach; if (type == Rotation) postmult_ = getRotationMatrix(axis_, delta); else premult_ = getPositionMatrix(axis_, delta); }
//ALEX OWEN 10/04/15 XMMATRIX GameObject::getWorldMatrix() { if(!transformed) return XMLoadFloat4x4(&worldMatrix); // create matrices to create a single world matrix for the GameObject's transform XMMATRIX scaleMatrix = XMMatrixScaling( scale.x, scale.y, scale.z ); XMMATRIX rotationMatrix = getRotationMatrix(); XMMATRIX positionMatrix = getPositionMatrix(); // 1) scale // 2) rotate // 3) position XMMATRIX _worldMatrix = XMMatrixTranspose( scaleMatrix * rotationMatrix * positionMatrix ); XMStoreFloat4x4(&worldMatrix,_worldMatrix); transformed = false; return _worldMatrix; }
bool CommandTransformLinear::mergeWith(const QUndoCommand *command) { if (command->id() != id()) return false; const CommandTransformLinear *ctl = dynamic_cast<const CommandTransformLinear *>(command); if (selection_ != ctl->selection()) return false; delta_ += ctl->delta(); if (type_ == Position) premult_ = getPositionMatrix(axis_, delta_); else postmult_ = getRotationMatrix(axis_, delta_); return true; }
//Public - getTranslation Matrix to translate other objects in calling gameObject coordinate system myEngine::Matrix4x4 GameObject::getTranslationMatrix() { Matrix4x4 translationMatrix = getPositionMatrix(); translationMatrix.invert(); return(translationMatrix); }