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


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

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


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

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