void TransformNode::getSFMatrix(SFMatrix *mOut) { float center[3]; float rotation[4]; float scale[3]; float scaleOri[4]; float trans[3]; SFMatrix mSRI; SFMatrix mSR; SFMatrix mCI; SFMatrix mC; SFMatrix mT; SFMatrix mR; SFMatrix mS; getTranslation(trans); mT.setTranslation(trans); getCenter(center); mC.setTranslation(center); getRotation(rotation); mR.setRotation(rotation); getScaleOrientation(scaleOri); mSR.setRotation(scaleOri); getScale(scale); mS.setScaling(scale); getScaleOrientation(scaleOri); scaleOri[3] = -scaleOri[3]; mSRI.setRotation(scaleOri); getCenter(center); center[0] = -center[0]; center[1] = -center[1]; center[2] = -center[2]; mCI.setTranslation(center); mOut->init(); mOut->add(&mT); mOut->add(&mC); mOut->add(&mR); mOut->add(&mSR); mOut->add(&mS); mOut->add(&mSRI); mOut->add(&mCI); }
void TransformNode::outputContext(ostream &printStream, const char *indentString) { float vec[3]; float rot[4]; getTranslation(vec); printStream << indentString << "\t" << "translation " << vec[0] << " "<< vec[1] << " " << vec[2] << endl; getRotation(rot); printStream << indentString << "\t" << "rotation " << rot[0] << " "<< rot[1] << " " << rot[2] << " " << rot[3] << endl; getScale(vec); printStream << indentString << "\t" << "scale " << vec[0] << " "<< vec[1] << " " << vec[2] << endl; getScaleOrientation(rot); printStream << indentString << "\t" << "scaleOrientation " << rot[0] << " "<< rot[1] << " " << rot[2] << " " << rot[3] << endl; getCenter(vec); printStream << indentString << "\t" << "center " << vec[0] << " "<< vec[1] << " " << vec[2] << endl; }
OSG_USING_NAMESPACE /*! \class osg::ComponentTransform */ /*-------------------------------------------------------------------------*/ /* Changed */ void ComponentTransform::changed(BitVector whichField, UInt32 origin) { ComponentTransformPtr ptr(*this); if((whichField & CenterFieldMask ) || (whichField & RotationFieldMask ) || (whichField & ScaleFieldMask ) || (whichField & ScaleOrientationFieldMask) || (whichField & TranslationFieldMask ) ) { // be careful not to mark the matrix as changed here to avoid // bouncing changes back and forth _sfMatrix.getValue().setTransform(getTranslation (), getRotation (), getScale (), getScaleOrientation(), getCenter () ); invalidateVolume(); } else if(whichField & Inherited::MatrixFieldMask) { Vec3f translation; Quaternion rotation; Vec3f scale; Quaternion scaleOrientation; Vec3f center; _sfMatrix.getValue().getTransform(translation, rotation, scale, scaleOrientation, center ); // be careful not to mark the components as changed here to avoid // bouncing changes back and forth _sfTranslation .setValue(translation ); _sfRotation .setValue(rotation ); _sfScale .setValue(scale ); _sfScaleOrientation.setValue(scaleOrientation); _sfCenter .setValue(center ); } Inherited::changed(whichField, origin); }
vgm::MatrixR Transform::gethMatrix() const { vgm::MatrixR matrix; matrix.setTransform( getTranslation(), getRotation(), getScaleFactor(), getScaleOrientation(), getCenter() ); return ( matrix ); }
void CX3DHAnimSiteNode::print(int indent) { FILE *fp = CX3DParser::getDebugLogFp(); char *nodeName = getNodeName(); if (nodeName) { float x, y, z, rot; int i, n; CX3DParser::printIndent(indent); fprintf(fp, "%s (%s)\n", nodeName, CX3DNode::getNodeTypeString(getNodeType())); CX3DParser::printIndent(indent+1); fprintf(fp, "children\n"); MFNode *nodes = getChildren(); n = nodes->count(); for (i=0; i<n; i++) { CX3DNode *child = nodes->getNode(i); if (child) { child->print(indent+2); } } CX3DParser::printIndent(indent+1); getCenter()->getValue(x, y, z); fprintf(fp, "center : (%f %f %f)\n", x, y, z); CX3DParser::printIndent(indent+1); getRotation()->getValue(x, y, z, rot); fprintf(fp, "rotation : (%f %f %f)(%f)\n", x, y, z, rot); CX3DParser::printIndent(indent+1); getScale()->getValue(x, y, z); fprintf(fp, "scale : (%f %f %f)\n", x, y, z); CX3DParser::printIndent(indent+1); getScaleOrientation()->getValue(x, y, z, rot); fprintf(fp, "scaleOrientation : (%f %f %f)(%f)\n", x, y, z, rot); CX3DParser::printIndent(indent+1); getTranslation()->getValue(x, y, z); fprintf(fp, "translation : (%f %f %f)\n", x, y, z); CX3DParser::printIndent(indent+1); fprintf(fp, "name (%s)\n", m_name.getValue()); } }
D3DXMATRIX Transform::GetTransform() { Vec3f T = getTranslation(); Vec3f C = getCenter(); Vec3f S = getScale(); Rotation R = getRotation(); Rotation SR = getScaleOrientation(); gm::matrix4f m = gm::matrix4f::getTranslate(T) * gm::matrix4f::getTranslate(C) * gm::matrix4f::getRotate(gmDegrees(R.m_angle), R.m_axis) * gm::matrix4f::getRotate(gmDegrees(SR.m_angle), SR.m_axis) * gm::matrix4f::getScale(S) * gm::matrix4f::getRotate(gmDegrees(SR.m_angle), -SR.m_axis) * gm::matrix4f::getTranslate(-C); return *(D3DXMATRIX*)&m; }
void CX3DOpenHRPHumanoidNode::print(int indent) { FILE *fp = CX3DParser::getDebugLogFp(); int nMax = CX3DParser::getMaxPrintElemsForMFField(); bool bPartialPrint = false; char *nodeName = getNodeName(); if (nodeName) { float x, y, z, rot; MFNode *nodes; int i, n; CX3DParser::printIndent(indent); fprintf(fp, "%s (%s)\n", nodeName, CX3DNode::getNodeTypeString(getNodeType())); CX3DParser::printIndent(indent+1); getCenter()->getValue(x, y, z); fprintf(fp, "center : (%f %f %f)\n", x, y, z); CX3DParser::printIndent(indent+1); getRotation()->getValue(x, y, z, rot); fprintf(fp, "rotation : (%f %f %f)(%f)\n", x, y, z, rot); CX3DParser::printIndent(indent+1); getScale()->getValue(x, y, z); fprintf(fp, "scale : (%f %f %f)\n", x, y, z); CX3DParser::printIndent(indent+1); getScaleOrientation()->getValue(x, y, z, rot); fprintf(fp, "scaleOrientation : (%f %f %f)(%f)\n", x, y, z, rot); CX3DParser::printIndent(indent+1); getTranslation()->getValue(x, y, z); fprintf(fp, "translation : (%f %f %f)\n", x, y, z); CX3DParser::printIndent(indent+1); fprintf(fp, "name (%s)\n", m_name.getValue()); CX3DParser::printIndent(indent+1); n = m_info.count(); fprintf(fp, "info [%d]\n", n); if ((nMax > 0) && (n > nMax)) { n = nMax; bPartialPrint = true; } else { bPartialPrint = false; } for (i=0; i<n; i++) { CX3DParser::printIndent(indent+2); fprintf(fp, "%s\n", m_info.getValue(i)); } if (bPartialPrint) { CX3DParser::printIndent(indent+2); fprintf(fp, "...\n"); } CX3DParser::printIndent(indent+1); nodes = getJoints(); n = nodes->count(); fprintf(fp, "joints [%d]\n", n); for (i=0; i<n; i++) { CX3DNode *child = nodes->getNode(i); if (child) { child->print(indent+2); } } CX3DParser::printIndent(indent+1); nodes = getSegments(); n = nodes->count(); fprintf(fp, "segments [%d]\n", n); for (i=0; i<n; i++) { CX3DNode *child = nodes->getNode(i); if (child) { child->print(indent+2); } } CX3DParser::printIndent(indent+1); nodes = getSites(); n = nodes->count(); fprintf(fp, "sites [%d]\n", n); for (i=0; i<n; i++) { CX3DNode *child = nodes->getNode(i); if (child) { child->print(indent+2); } } CX3DParser::printIndent(indent+1); nodes = getHumanoidBody(); n = nodes->count(); fprintf(fp, "humanoidBody [%d]\n", n); for (i=0; i<n; i++) { CX3DNode *child = nodes->getNode(i); if (child) { child->print(indent+2); } } CX3DParser::printIndent(indent+1); fprintf(fp, "version (%s)\n", m_version.getValue()); CX3DParser::printIndent(indent+1); nodes = getViewpoints(); n = nodes->count(); fprintf(fp, "viewpoints [%d]\n", n); for (i=0; i<n; i++) { CX3DNode *child = nodes->getNode(i); if (child) { child->print(indent+2); } } } }