当前位置: 首页>>代码示例>>C++>>正文


C++ SbMatrix::getTransform方法代码示例

本文整理汇总了C++中SbMatrix::getTransform方法的典型用法代码示例。如果您正苦于以下问题:C++ SbMatrix::getTransform方法的具体用法?C++ SbMatrix::getTransform怎么用?C++ SbMatrix::getTransform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SbMatrix的用法示例。


在下文中一共展示了SbMatrix::getTransform方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: planeFromMatrix

SbPlane XipGeomUtils::planeFromMatrix(const SbMatrix &m)
{
    SbVec3f translation, scaleFactor, normal;
    SbRotation rotation, scaleOrientation;
    m.getTransform(translation, rotation, scaleFactor, scaleOrientation);

    normal = SbVec3f(m[2][0], m[2][1], m[2][2]);
    normal.normalize();

    return SbPlane(normal, translation);
}
开发者ID:OpenXIP,项目名称:xip-libraries,代码行数:11,代码来源:XipGeomUtils.cpp

示例2:

SbMatrix
extractRotationMatrix( const SbMatrix& matrix )
{
	SbVec3f t, s;
	SbRotation r, so;
	matrix.getTransform( t, r, s, so );

	SbMatrix rotationMatrix;
	rotationMatrix.setRotate(r);

	return rotationMatrix;
}
开发者ID:OpenXIP,项目名称:xip-libraries,代码行数:12,代码来源:geomutils.cpp

示例3: assert

/*! \COININTERNAL */
void
SoRotateSphericalDragger::fieldSensorCB(void *d, SoSensor *)
{
  assert(d);
  SoRotateSphericalDragger * thisp = THISP(d);
  SbMatrix matrix = thisp->getMotionMatrix();
  SbVec3f trans, scale;
  SbRotation rot, scaleOrient;
  matrix.getTransform(trans, rot, scale, scaleOrient);
  matrix.setTransform(trans, thisp->rotation.getValue(), scale, scaleOrient);
  thisp->setMotionMatrix(matrix);
}
开发者ID:Alexpux,项目名称:Coin3D,代码行数:13,代码来源:SoRotateSphericalDragger.cpp

示例4: plane

bool
XipGeomUtils::isIntersect(const SbMatrix &mpr, const SbMatrix &model)
{
    SbVec3f s, origin;
    SbRotation r, so;
    model.getTransform(origin, r, s, so);

    SbVec3f axisX, axisY, axisZ;
    axisX.setValue(model[0][0], model[0][1], model[0][2]);
    axisY.setValue(model[1][0], model[1][1], model[1][2]);
    axisZ.setValue(model[2][0], model[2][1], model[2][2]);

    SbVec3f pt0[12], pt1[12];
    pt0[0] = origin;
    pt1[0] = origin + axisX;
    pt0[1] = origin + axisX;
    pt1[1] = origin + axisX + axisY;
    pt0[2] = origin + axisX + axisY;
    pt1[2] = origin + axisY;
    pt0[3] = origin + axisY;
    pt1[3] = origin;

    pt0[4] = origin + axisZ;
    pt1[4] = origin + axisX + axisZ;
    pt0[5] = origin + axisX + axisZ;
    pt1[5] = origin + axisX + axisY + axisZ;
    pt0[6] = origin + axisX + axisY + axisZ;
    pt1[6] = origin + axisY + axisZ;
    pt0[7] = origin + axisY + axisZ;
    pt1[7] = origin + axisZ;

    pt0[8] = origin;
    pt1[8] = pt0[8] + axisZ;
    pt0[9] = origin + axisX;
    pt1[9] = pt0[9] + axisZ;
    pt0[10] = origin + axisX + axisY;
    pt1[10] = pt0[10] + axisZ;
    pt0[11] = origin + axisY;
    pt1[11] = pt0[11] + axisZ;

    axisX.setValue(mpr[0][0], mpr[0][1], mpr[0][2]);
    axisY.setValue(mpr[1][0], mpr[1][1], mpr[1][2]);
    origin.setValue(mpr[3][0], mpr[3][1], mpr[3][2]);
    SbPlane plane(origin, origin+axisX, origin+axisY);

    for (int i=0; i<12; ++i)
    {
        if ( isIntersect(pt0[i], pt1[i], plane) ) return true;
    }

    return false;
}
开发者ID:OpenXIP,项目名称:xip-libraries,代码行数:52,代码来源:XipGeomUtils.cpp

示例5: THISP

/*! \COININTERNAL */
void
SoScale2Dragger::valueChangedCB(void *, SoDragger * d)
{
  SoScale2Dragger * thisp = THISP(d);
  SbMatrix matrix = thisp->getMotionMatrix();

  SbVec3f trans, scale;
  SbRotation rot, scaleOrient;
  matrix.getTransform(trans, rot, scale, scaleOrient);
  thisp->fieldSensor->detach();
  if (thisp->scaleFactor.getValue() != scale)
    thisp->scaleFactor = scale;
  thisp->fieldSensor->attach(&thisp->scaleFactor);
}
开发者ID:Alexpux,项目名称:Coin3D,代码行数:15,代码来源:SoScale2Dragger.cpp

示例6: THISP

/*! \COININTERNAL */
void
SoRotateSphericalDragger::valueChangedCB(void *, SoDragger * d)
{
  SoRotateSphericalDragger * thisp = THISP(d);
  SbMatrix matrix = thisp->getMotionMatrix();

  SbVec3f trans, scale;
  SbRotation rot, scaleOrient;
  matrix.getTransform(trans, rot, scale, scaleOrient);
  thisp->fieldSensor->detach();
  if (thisp->rotation.getValue() != rot)
    thisp->rotation = rot;
  thisp->fieldSensor->attach(&thisp->rotation);
}
开发者ID:Alexpux,项目名称:Coin3D,代码行数:15,代码来源:SoRotateSphericalDragger.cpp

示例7: filteredMatrix

SbMatrix ManipWidget::filteredMatrix(const SbMatrix &mat, ComponentMask components)
{
	SbVec3f xlat, scaleFactor;
	SbRotation rot, scaleOrient;
	mat.getTransform(xlat, rot, scaleFactor, scaleOrient);

	SbMatrix ret;
	ret.setTransform(
				components & COMPONENT_XLAT ? xlat : SbVec3f(0, 0, 0),
				components & COMPONENT_ROT ? rot : SbRotation(),
				components & COMPONENT_SCALE ? scaleFactor : SbVec3f(1, 1, 1),
				components & COMPONENT_SCALE ? scaleOrient : SbRotation()
				);
	return ret;
}
开发者ID:dewf,项目名称:mrLab3d,代码行数:15,代码来源:ManipWidget.cpp

示例8: assert

/*! \COININTERNAL */
void
SoScale2Dragger::fieldSensorCB(void * d, SoSensor *)
{
  assert(d);
  SoScale2Dragger * thisp = THISP(d);
  SbMatrix matrix = thisp->getMotionMatrix();

  SbVec3f t, s;
  SbRotation r, so;

  matrix.getTransform(t, r, s, so);
  s = thisp->scaleFactor.getValue();
  matrix.setTransform(t, r, s, so);
  thisp->setMotionMatrix(matrix);
}
开发者ID:Alexpux,项目名称:Coin3D,代码行数:16,代码来源:SoScale2Dragger.cpp

示例9: valueChangedCB

void RDragger::valueChangedCB(void *, SoDragger *d)
{
    RDragger *sudoThis = dynamic_cast<RDragger *>(d);
    assert(sudoThis);
    SbMatrix matrix = sudoThis->getMotionMatrix();

    //all this just to get the translation?
    SbVec3f translationDummy, scaleDummy;
    SbRotation localRotation, scaleOrientationDummy;
    matrix.getTransform(translationDummy, localRotation, scaleDummy, scaleOrientationDummy);

    sudoThis->fieldSensor.detach();
    if (sudoThis->rotation.getValue() != localRotation)
        sudoThis->rotation = localRotation;
    sudoThis->fieldSensor.attach(&sudoThis->rotation);
}
开发者ID:AjinkyaDahale,项目名称:FreeCAD,代码行数:16,代码来源:SoFCCSysDragger.cpp

示例10:

/*! \COININTERNAL */
void
SoHandleBoxDragger::valueChangedCB(void * COIN_UNUSED_ARG(f), SoDragger * d)
{
  SoHandleBoxDragger * thisp = static_cast<SoHandleBoxDragger *>(d);
  SbMatrix matrix = thisp->getMotionMatrix();
  SbVec3f trans, scale;
  SbRotation rot, scaleOrient;
  matrix.getTransform(trans, rot, scale, scaleOrient);

  thisp->translFieldSensor->detach();
  if (thisp->translation.getValue() != trans)
    thisp->translation = trans;
  thisp->translFieldSensor->attach(&thisp->translation);

  thisp->scaleFieldSensor->detach();
  if (thisp->scaleFactor.getValue() != scale)
    thisp->scaleFactor = scale;
  thisp->scaleFieldSensor->attach(&thisp->scaleFactor);
}
开发者ID:Alexpux,项目名称:Coin3D,代码行数:20,代码来源:SoHandleBoxDragger.cpp

示例11:

void TranslateRadialDragger::
valueChangedCB(
  void *,
  SoDragger *inDragger)
{
  TranslateRadialDragger *myself = (TranslateRadialDragger *) inDragger;

  // Get translation by decomposing motionMatrix.
  SbMatrix motMat = myself->getMotionMatrix();
  SbVec3f trans, scale;
  SbRotation rot, scaleOrient;
  motMat.getTransform(trans, rot, scale, scaleOrient);

  // Set "translation", disconnecting sensor while doing so.
  myself->fieldSensor->detach();
  if(myself->translation.getValue() != trans)
  {
    myself->translation = trans;
  }
  myself->fieldSensor->attach(&(myself->translation));
}
开发者ID:ma-tech,项目名称:WlzQtApps,代码行数:21,代码来源:TranslateRadialDragger.cpp

示例12: difftrans

/*! \COININTERNAL */
void
SoCenterballDragger::valueChangedCB(void *, SoDragger * d)
{
  SoCenterballDragger * thisp = static_cast<SoCenterballDragger *>(d);
  SbMatrix matrix = thisp->getMotionMatrix();
  SbVec3f t, s;
  SbRotation r, so;

  // Eliminate center variable of matrix
  if (thisp->savedcenter != SbVec3f(0.0f, 0.0f, 0.0f)) {
    SbMatrix trans;
    trans.setTranslate(thisp->savedcenter);
    matrix.multLeft(trans);
    trans.setTranslate(-(thisp->savedcenter));
    matrix.multRight(trans);
  }

  // Do an inverse rotation, using matrix with center eliminated
  // to obtain correct translation
  matrix.getTransform(t, r, s, so);
  SbMatrix rotmat;
  rotmat.setRotate(r);
  //SbMatrix tmp = matrix;
  matrix.multLeft(rotmat.inverse());

  // Update center of object if dragger has translated
  SbVec3f difftrans(matrix[3][0], matrix[3][1], matrix[3][2]);
  if (difftrans != SbVec3f(0.0f, 0.0f, 0.0f)) {
    thisp->centerFieldSensor->detach();
    thisp->center.setValue(thisp->savedcenter + difftrans);
    thisp->centerFieldSensor->attach(&thisp->center);
  }

  thisp->rotFieldSensor->detach();
  if (thisp->rotation.getValue() != r) {
    thisp->rotation = r;
  }
  thisp->rotFieldSensor->attach(&thisp->rotation);
}
开发者ID:Alexpux,项目名称:Coin3D,代码行数:40,代码来源:SoCenterballDragger.cpp

示例13: Exception

		void
		Scene::load(const ::std::string& filename, const bool& doBoundingBoxPoints, const bool& doPoints)
		{
			::rl::xml::DomParser parser;
			
			::rl::xml::Document doc = parser.readFile(filename, "", XML_PARSE_NOENT | XML_PARSE_XINCLUDE);
			
			doc.substitute(XML_PARSE_NOENT | XML_PARSE_XINCLUDE);
			
			::rl::xml::Path path(doc);
			
			::rl::xml::Object scenes = path.eval("//scene");
			
			for (int i = 0; i < ::std::min(1, scenes.getNodeNr()); ++i)
			{
				SoInput input;
				
				if (!input.openFile(scenes.getNodeTab(i).getLocalPath(scenes.getNodeTab(i).getAttribute("href").getValue()).c_str() ,true))
				{
					throw Exception("::rl::sg::Scene::load() - failed to open file");
				}
				
				SoVRMLGroup* root = SoDB::readAllVRML(&input);
				
				if (NULL == root)
				{
					throw Exception("::rl::sg::Scene::load() - failed to read file");
				}
				
				SbViewportRegion viewportRegion;
				
				root->ref();
				
				// model
				
				::rl::xml::Object models = path.eval("model", scenes.getNodeTab(i));
				
				for (int j = 0; j < models.getNodeNr(); ++j)
				{
					SoSearchAction modelSearchAction;
					modelSearchAction.setName(models.getNodeTab(j).getAttribute("name").getValue().c_str());
					modelSearchAction.apply(root);
					
					if (NULL == modelSearchAction.getPath())
					{
						continue;
					}
					
					Model* model = this->create();
					
					model->setName(models.getNodeTab(j).getAttribute("name").getValue());
					
					// body
					
					::rl::xml::Object bodies = path.eval("body", models.getNodeTab(j));
					
					for (int k = 0; k < bodies.getNodeNr(); ++k)
					{
						SoSearchAction bodySearchAction;
						bodySearchAction.setName(bodies.getNodeTab(k).getAttribute("name").getValue().c_str());
						bodySearchAction.apply(static_cast< SoFullPath* >(modelSearchAction.getPath())->getTail());
						
						if (NULL == bodySearchAction.getPath())
						{
							continue;
						}
						
						Body* body = model->create();
						
						body->setName(bodies.getNodeTab(k).getAttribute("name").getValue());
						
						SoSearchAction pathSearchAction;
						pathSearchAction.setNode(static_cast< SoFullPath* >(bodySearchAction.getPath())->getTail());
						pathSearchAction.apply(root);
						
						SoGetMatrixAction bodyGetMatrixAction(viewportRegion);
						bodyGetMatrixAction.apply(static_cast< SoFullPath* >(pathSearchAction.getPath()));
						SbMatrix bodyMatrix = bodyGetMatrixAction.getMatrix();
						
						if (!this->isScalingSupported)
						{
							SbVec3f bodyTranslation;
							SbRotation bodyRotation;
							SbVec3f bodyScaleFactor;
							SbRotation bodyScaleOrientation;
							SbVec3f bodyCenter;
							bodyMatrix.getTransform(bodyTranslation, bodyRotation, bodyScaleFactor, bodyScaleOrientation, bodyCenter);
							
							for (int l = 0; l < 3; ++l)
							{
								if (::std::abs(bodyScaleFactor[l] - 1.0f) > 1.0e-6f)
								{
									throw Exception("::rl::sg::Scene::load() - bodyScaleFactor not supported");
								}
							}
						}
						
						::rl::math::Transform frame;
						
						for (int m = 0; m < 4; ++m)
//.........这里部分代码省略.........
开发者ID:Serge45,项目名称:rl,代码行数:101,代码来源:Scene.cpp

示例14: evaluate

void SoXipImageAttributes::evaluate()
{
	SoXipDataImage *imgData = image.getValue();

	if (imgData)
	{
		SbXipImage *img = imgData->get();
		if (img)
		{
			SO_ENGINE_OUTPUT(modelMatrix, SoSFMatrix, setValue(img->getModelMatrix()));
			SO_ENGINE_OUTPUT(bitsStored, SoSFShort, setValue(img->getBitsStored()));

			SO_ENGINE_OUTPUT(width,  SoSFShort, setValue(img->getDimStored()[0]));
			SO_ENGINE_OUTPUT(height, SoSFShort, setValue(img->getDimStored()[1]));
			SO_ENGINE_OUTPUT(depth,  SoSFShort, setValue(img->getDimStored()[2]));

			SbMatrix modelMat = img->getModelMatrix();

			SbVec3f t, s;
			SbRotation r, so;
			modelMat.getTransform(t, r, s, so);
			modelMat.multVecMatrix(SbVec3f(0.5, 0.5, 0.5), t);

			// scale MPR model matrix always to max. individual dimension by default
			float maxScale = s[0] > s[1] ? s[0] : s[1] > s[2] ? s[1] : s[2];
//			modelMat.setTransform(t, r, SbVec3f(maxScale, maxScale, maxScale), so);

			// when using get/setTransform, the rotation is derived from normal vector
			// but for gantry tilt, we need to compute normal from row and column vector
			SbVec3f rot[3];
			rot[0] = SbVec3f(modelMat[0][0], modelMat[0][1], modelMat[0][2]);
			rot[1] = SbVec3f(modelMat[1][0], modelMat[1][1], modelMat[1][2]);
			rot[2] = rot[0].cross(rot[1]);

			rot[0].normalize();
			rot[1].normalize();
			rot[2].normalize();
			rot[0] *= maxScale;
			rot[1] *= maxScale;
			rot[2] *= maxScale;

			modelMat = SbMatrix(
				rot[0][0], rot[0][1], rot[0][2], 0,
				rot[1][0], rot[1][1], rot[1][2], 0,
				rot[2][0], rot[2][1], rot[2][2], 0,
				t[0], t[1], t[2], 1);

			// update engine outputs
			SbMatrix tmp = SbMatrix::identity();

			// flip default viewing direction
			tmp.setRotate(SbRotation(SbVec3f(1, 0, 0), M_PI));

			SbMatrix defOrient = tmp * modelMat;

			// adjust so plane falls onto original plane
			defOrient.getTransform(t, r, s, so);
			SbVec3f object;
			modelMat = img->getModelMatrix();
			modelMat.inverse().multVecMatrix(t, object);

			object[0] = int(object[0] * img->getDimStored()[0] + 0.5);
			object[1] = int(object[1] * img->getDimStored()[1] + 0.5);
			object[2] = int(object[2] * img->getDimStored()[2] + 0.5);

			object[0] /= img->getDimStored()[0];
			object[1] /= img->getDimStored()[1];
			object[2] /= img->getDimStored()[2];

			modelMat.multVecMatrix(object, t);
			defOrient.setTransform(t, r, s, so);

			SO_ENGINE_OUTPUT(defaultOrientation, SoSFMatrix, setValue(defOrient));

			SbMatrix ortho1, ortho2, ortho3;
			int which = XipGeomUtils::orthoOrientations(defOrient, ortho1, ortho2, ortho3);
			SO_ENGINE_OUTPUT(orthoScanOrientation, SoSFShort, setValue(which));

			SO_ENGINE_OUTPUT(orthoOrientation1, SoSFMatrix, setValue(ortho1));
			SO_ENGINE_OUTPUT(orthoOrientation2, SoSFMatrix, setValue(ortho2));
			SO_ENGINE_OUTPUT(orthoOrientation3, SoSFMatrix, setValue(ortho3));

			defOrient.getTransform(t, r, s, so);
			SO_ENGINE_OUTPUT(defaultCenter, SoSFVec3f, setValue(t));

			return;
		}
	}

	SO_ENGINE_OUTPUT(modelMatrix, SoSFMatrix, setValue(SbMatrix::identity()));
	SO_ENGINE_OUTPUT(bitsStored, SoSFShort, setValue(0));

	SO_ENGINE_OUTPUT(width,  SoSFShort, setValue(0));
	SO_ENGINE_OUTPUT(height, SoSFShort, setValue(0));
	SO_ENGINE_OUTPUT(depth,  SoSFShort, setValue(0));

	SbMatrix rot1, rot2;
	SO_ENGINE_OUTPUT(defaultOrientation, SoSFMatrix, setValue(SbMatrix::identity()));
	SO_ENGINE_OUTPUT(orthoScanOrientation, SoSFShort, setValue(0));
	SO_ENGINE_OUTPUT(orthoOrientation1, SoSFMatrix, setValue(SbMatrix::identity()));
//.........这里部分代码省略.........
开发者ID:OpenXIP,项目名称:xip-libraries,代码行数:101,代码来源:SoXipImageAttributes.cpp

示例15: sizeof

void	computeMPRCacheLUT(SoXipCPUMprRender *mprRender, T *volBuf, SoState *state)
{
	// Clear the contents of the mpr buffer
	memset(mprRender->mMPRBuf, 0, (int)mprRender->mMPRSize[0] * (int)mprRender->mMPRSize[1] * sizeof(float) * 4);

	// Get some constant sizes ready
	const int volWidth = mprRender->mVolDim[0];
	const int volHeight = mprRender->mVolDim[1];
	const int volDepth = mprRender->mVolDim[2];
	const int volSliceSize = volWidth * volHeight;
	const float boundX = volWidth - 1.0f;
	const float boundY = volHeight - 1.0f;
	const float boundZ = volDepth - 1.0f;

	// Get bounding box span and start from model matrix
	SbMatrix modelMat = SoModelMatrixElement::get(state);
	SbVec3f wSpan, wStart;
	SbRotation dummy;
	modelMat.getTransform(wStart, dummy, wSpan, dummy);

	SbMatrix inv = modelMat.inverse();

	// Convert the corner points from worldspace to model space
	SbVec3f	corners[4];
	short i;
	for (i = 0; i < 4; ++i)
	{
		inv.multVecMatrix( mprRender->mCorners[i], corners[i] );
		corners[i][0] *= boundX;
		corners[i][1] *= boundY;
		corners[i][2] *= boundZ;

	}

	SbVec3f vGrad1((corners[0] - corners[3]) / (mprRender->mMPRSize[1] - 1.0f));
	SbVec3f vGrad2((corners[1] - corners[2]) / (mprRender->mMPRSize[1] - 1.0f));
	SbVec3f vIntrp1 = corners[3];
	SbVec3f vIntrp2 = corners[2];
	
	SbVec3f hGrad;
	SbVec3f pos;

	// Prepare data cache stuff
	float neighboursVol[8];
	int	lastBaseOffsetVol = -1;	
	
	int bitRatio = (int)(powf(2, sizeof(T) * 8) / powf(2, mprRender->mVolBitsUsed));
	//
	mprCacheElem *cacheElem = mprRender->mMPRCache;
	float *mprVal = (float*) mprRender->mMPRBuf;

	for (i = 0; i < mprRender->mMPRSize[1]; ++i)
	{
		hGrad = (vIntrp2 - vIntrp1) / (mprRender->mMPRSize[0] - 1.0f);
		pos = vIntrp1;
		for (short j = 0; j < mprRender->mMPRSize[0]; ++j)
		{
			// Check if coord is out of bounds
			if (pos[0] >= 0 && pos[0] < boundX &&
				pos[1] >= 0 && pos[1] < boundY &&
				pos[2] >= 0 && pos[2] < boundZ)
			{

				cacheElem->volCoord[0] = pos[0];
				cacheElem->volCoord[1] = pos[1];
				cacheElem->volCoord[2] = pos[2];

				T val = (T)(sample3Di(volBuf, cacheElem->volCoord, volWidth, volSliceSize, neighboursVol, lastBaseOffsetVol) * bitRatio);

				sampleLut(mprVal, val, mprRender->mLutBuf, mprRender->mLutSize);
				
				cacheElem->mprOffset = mprVal - (float*) mprRender->mMPRBuf;
				cacheElem++;
			}
			mprVal += 4;
			pos += hGrad;
		}
		vIntrp1 += vGrad1;
		vIntrp2 += vGrad2;
	}
	mprRender->mNumCacheElems = cacheElem - mprRender->mMPRCache;
}
开发者ID:OpenXIP,项目名称:xip-libraries,代码行数:82,代码来源:SoXipCPUMprRender.cpp


注:本文中的SbMatrix::getTransform方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。