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


C++ Matrixf::makeRotate方法代码示例

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


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

示例1: applyEditorInfo

/***************************************************************
* Function: applyEditorInfo()
***************************************************************/
void CAVEGroupEditGeodeWireframe::applyEditorInfo(CAVEGeodeShape::EditorInfo **infoPtr)
{
    /* reset root offset only when the shape is moved */
    if ((*infoPtr)->getTypeMasking() == CAVEGeodeShape::EditorInfo::MOVE)
    {
	/* apply translations on 'mAccRootMat' */
	const Vec3 offset = (*infoPtr)->getMoveOffset();

	Matrixd transMat;
	transMat.makeTranslate(offset);
	mAccRootMat = mAccRootMat * transMat;
    }
    else if ((*infoPtr)->getTypeMasking() == CAVEGeodeShape::EditorInfo::ROTATE)
    {
	/* apply rotations on 'mAccRootMat' */
	const float angle = (*infoPtr)->getRotateAngle();
	const Vec3 axis = (*infoPtr)->getRotateAxis();

	Matrixf rotateMat;
	rotateMat.makeRotate(angle, axis);
	mAccRootMat = mAccRootMat * rotateMat;
    }
    else if ((*infoPtr)->getTypeMasking() == CAVEGeodeShape::EditorInfo::SCALE)
    {
	const Vec3f scaleVect = (*infoPtr)->getScaleVect();
	const Vec3f scaleCenter = (*infoPtr)->getScaleCenter();

	Matrixd scalingMat, transMat, revTransMat;
	scalingMat.makeScale(scaleVect);
	transMat.makeTranslate(scaleCenter);
	revTransMat.makeTranslate(-scaleCenter);

	mAccRootMat = mAccRootMat * scalingMat;
    }
}
开发者ID:aprudhomme,项目名称:calvr_plugins,代码行数:38,代码来源:CAVEGroupEditGeodeWireframe.cpp

示例2: get

void Quat::get(Matrixf& matrix) const
{
    matrix.makeRotate(*this);
}
开发者ID:Kurdakov,项目名称:emscripten_OSG,代码行数:4,代码来源:Quat.cpp

示例3: applyEditorInfo

/***************************************************************
* Function: applyEditorInfo()
***************************************************************/
void CAVEGeodeShape::applyEditorInfo(Vec3Array **vertexArrayPtr, Vec3Array **normalArrayPtr, 
		Vec3Array **udirArrayPtr, Vec3Array **vdirArrayPtr, Vec2Array **texcoordArrayPtr,
		const Vec3Array *refVertexArrayPtr, const Vec3Array *refNormalArrayPtr, 
		const Vec3Array *refUDirArrayPtr, const Vec3Array *refVDirArrayPtr, const Vec2Array *refTexcoordArrayPtr,
		const int &nVerts, EditorInfo **infoPtr, const VertexMaskingVector &vertMaskingVector)
{
    /* access target and source data pointers */
    Vec3 *geodeVertexDataPtr, *geodeNormalDataPtr, *geodeUDirDataPtr, *geodeVDirDataPtr;
    Vec2 *geodeTexcoordDataPtr;
    const Vec3 *refGeodeVertexDataPtr, *refGeodeNormalDataPtr, *refGeodeUDirDataPtr, *refGeodeVDirDataPtr;
    const Vec2 *refGeodeTexcoordDataPtr;

    geodeVertexDataPtr = (Vec3*) ((*vertexArrayPtr)->getDataPointer());
    geodeNormalDataPtr = (Vec3*) ((*normalArrayPtr)->getDataPointer());
    geodeUDirDataPtr = (Vec3*) ((*udirArrayPtr)->getDataPointer());
    geodeVDirDataPtr = (Vec3*) ((*vdirArrayPtr)->getDataPointer());
    geodeTexcoordDataPtr = (Vec2*) ((*texcoordArrayPtr)->getDataPointer());

    refGeodeVertexDataPtr = (const Vec3*) (refVertexArrayPtr->getDataPointer());
    refGeodeNormalDataPtr = (const Vec3*) (refNormalArrayPtr->getDataPointer());
    refGeodeUDirDataPtr =  (const Vec3*) (refUDirArrayPtr->getDataPointer());
    refGeodeVDirDataPtr =  (const Vec3*) (refVDirArrayPtr->getDataPointer());
    refGeodeTexcoordDataPtr = (const Vec2*) (refTexcoordArrayPtr->getDataPointer());

    /* implement vertex & normal updates with respect to all ActiveTypeMasking
       texture coordinates are only changed in 'MOVE' and 'SCALE' operations,
       texture directional vectors are only changed in 'ROTATE' operations. 
    */
    if ((*infoPtr)->getTypeMasking() == EditorInfo::MOVE)
    {
	const Vec3 offset = (*infoPtr)->getMoveOffset();
	for (int i = 0; i < nVerts; i++)
	{
	    if (vertMaskingVector[i])
	    {
		/* apply offset values to vetex data vector */
		geodeVertexDataPtr[i] = refGeodeVertexDataPtr[i] + offset;

		/* apply offset values to texture coordinates, normal is not changed */
		Vec3 udir = refGeodeUDirDataPtr[i];
		Vec3 vdir = refGeodeVDirDataPtr[i];
		Vec2 texoffset = Vec2(udir * offset, vdir * offset) / gTextureTileSize;
		geodeTexcoordDataPtr[i] = refGeodeTexcoordDataPtr[i] + texoffset;
	    }
	}
    }
    else if ((*infoPtr)->getTypeMasking() == EditorInfo::ROTATE)
    {
	const Vec3 center = (*infoPtr)->getRotateCenter();
	const Vec3 axis = (*infoPtr)->getRotateAxis();
	const float angle = (*infoPtr)->getRotateAngle();

	Matrixf rotMat;
	rotMat.makeRotate(angle, axis);

	for (int i = 0; i < nVerts; i++)
	{
	    if (vertMaskingVector[i])
	    {
		/* update vertex list: 'translation' -> 'rotation' -> 'reversed translation' */
		Vec3 pos = refGeodeVertexDataPtr[i];
		geodeVertexDataPtr[i] = (pos - center) * rotMat + center;

		/* update normal and u, v-direction vectors with single rotations */
		Vec3 norm = refGeodeNormalDataPtr[i];
		Vec3 udir = refGeodeUDirDataPtr[i];
		Vec3 vdir = refGeodeVDirDataPtr[i];
		geodeNormalDataPtr[i] = norm * rotMat;
		geodeUDirDataPtr[i] = udir * rotMat;
		geodeVDirDataPtr[i] = vdir * rotMat;
	    }
	}
    }
    else if ((*infoPtr)->getTypeMasking() == EditorInfo::SCALE)
    {
	const Vec3 center = (*infoPtr)->getScaleCenter();
	const Vec3 scale = (*infoPtr)->getScaleVect();

	Matrixf scaleMat;
	scaleMat.makeScale(scale);

	for (int i = 0; i < nVerts; i++)
	{
	    if (vertMaskingVector[i])
	    {
		/* update vertex list: 'translation' -> 'scaling' -> 'reversed translation' */
		Vec3 pos = refGeodeVertexDataPtr[i];
		geodeVertexDataPtr[i] = (pos - center) * scaleMat + center;
		Vec3 offset = geodeVertexDataPtr[i] - pos;

		/* update texture coordinates 'u', 'v', normal and u, v-direction vectors are not changed  */
		Vec3 udir = refGeodeUDirDataPtr[i];
		Vec3 vdir = refGeodeVDirDataPtr[i];
		Vec2 texoffset = Vec2(udir * offset, vdir * offset) / gTextureTileSize;
		geodeTexcoordDataPtr[i] = refGeodeTexcoordDataPtr[i] + texoffset;
	    }
	}
//.........这里部分代码省略.........
开发者ID:aprudhomme,项目名称:calvr_plugins,代码行数:101,代码来源:CAVEGeodeShape.cpp


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