int IcoSphere::addToVertices(std::list<VertexPair> *target, const Ogre::Vector3 &position, const Ogre::ColourValue &colour, float scale) { Ogre::Matrix4 transform = Ogre::Matrix4::IDENTITY; transform.setTrans(position); transform.setScale(Ogre::Vector3(scale, scale, scale)); for (int i = 0; i < (int)vertices.size(); i++) target->push_back(VertexPair(transform * vertices[i], colour)); return vertices.size(); }
// // 根据输入的平移, 旋转, 缩放分量创建出位置变换矩阵. // void FairyEditorFrame::BuildTransformMatrix(Ogre::Matrix4& Matrix, const Ogre::Vector3& position, const Ogre::Quaternion rotate, const Ogre::Vector3 scale) { Ogre::Matrix4 posMatrix; Ogre::Matrix4 scaleMatrix; Ogre::Matrix4 rotateMatrix(rotate); posMatrix = Ogre::Matrix4::IDENTITY; posMatrix.setTrans(position); scaleMatrix = Ogre::Matrix4::IDENTITY; scaleMatrix.setScale(scale); // 最终的变换矩阵. Matrix = posMatrix * rotateMatrix * scaleMatrix; }