• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ SFMatrix类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中SFMatrix的典型用法代码示例。如果您正苦于以下问题:C++ SFMatrix类的具体用法?C++ SFMatrix怎么用?C++ SFMatrix使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1:

void CyberX3D::UpdateBoundingBox(
Node		*node,
BoundingBox	*bbox)
{
	if (node->isGeometry3DNode()) {
		Geometry3DNode *gnode = (Geometry3DNode *)node;
		gnode->recomputeBoundingBox();

		float	bboxCenter[3];
		float	bboxSize[3];

		gnode->getBoundingBoxCenter(bboxCenter);
		gnode->getBoundingBoxSize(bboxSize);

		SFMatrix	mx;
		gnode->getTransformMatrix(&mx);

		for (int n=0; n<8; n++) {
			float	point[3];
			point[0] = (n < 4)			? bboxCenter[0] - bboxSize[0] : bboxCenter[0] + bboxSize[0];
			point[1] = (n % 2)			? bboxCenter[1] - bboxSize[1] : bboxCenter[1] + bboxSize[1];
			point[2] = ((n % 4) < 2)	? bboxCenter[2] - bboxSize[2] : bboxCenter[2] + bboxSize[2];
			mx.multi(point);
			bbox->addPoint(point);
		}
	}

	for (Node *cnode=node->getChildNodes(); cnode; cnode=cnode->next()) 
		UpdateBoundingBox(cnode, bbox);
}
开发者ID:StephanieSpanjian,项目名称:CyberX3D4CC,代码行数:30,代码来源:BoundedNode.cpp


示例2: recomputeBoundingBox

void SceneGraph::recomputeBoundingBox()
{
    Node	*node;
    float	center[3];
    float	size[3];
    float	m4[4][4];
    SFMatrix mx;

    BoundingBox bbox;

    for (node=getNodes(); node; node=node->nextTraversal()) {
        if (node->isBoundedGroupingNode()) {
            BoundedGroupingNode *gnode = (BoundedGroupingNode *)node;
            gnode->getBoundingBoxCenter(center);
            gnode->getBoundingBoxSize(size);
            // Thanks for Peter DeSantis (07/22/04)
            gnode->getTransformMatrix(m4);
            mx.setValue(m4);
            bbox.addBoundingBox(&mx, center, size);
        }
        else if (node->isGeometry3DNode()) {
            Geometry3DNode *gnode = (Geometry3DNode *)node;
            gnode->getBoundingBoxCenter(center);
            gnode->getBoundingBoxSize(size);
            // Thanks for Peter DeSantis (07/22/04)
            gnode->getTransformMatrix(m4);
            mx.setValue(m4);
            bbox.addBoundingBox(&mx, center, size);
        }
    }

    setBoundingBox(&bbox);
}
开发者ID:cybergarage,项目名称:CyberX3D4CC,代码行数:33,代码来源:SceneGraph.cpp


示例3: rotation

void SFMatrix::setRotation(float x, float y, float z, float rot) 
{
	SFRotation rotation(x, y, z, rot);
	SFMatrix matrix;
	rotation.getSFMatrix(&matrix);
	float value[4][4];
	matrix.getValue(value); 
	setValue(value);
}
开发者ID:lukfugl,项目名称:raytracer,代码行数:9,代码来源:SFMatrix.cpp


示例4: getPosition

void ViewpointNode::getTranslationMatrix(SFMatrix *matrix) 
{
	float	position[3];
	
	getPosition(position);
	SFVec3f	transView(position);
	transView.invert();

	SFMatrix	mxTrans;
	mxTrans.setTranslation(&transView);

	matrix->init();
	matrix->add(&mxTrans);
}
开发者ID:lukfugl,项目名称:raytracer,代码行数:14,代码来源:ViewpointNode.cpp


示例5: getTransformMatrix

void Node::getTransformMatrix(SFMatrix *mxOut) const
{
	mxOut->init();

	for (const Node *node=this; node; node=node->getParentNode()) {
		if (node->isTransformNode() || node->isBillboardNode()) {
			SFMatrix	mxNode;
			if (node->isTransformNode())
				((TransformNode *)node)->getSFMatrix(&mxNode);
			else
				((BillboardNode *)node)->getSFMatrix(&mxNode);
			mxNode.add(mxOut);
			mxOut->setValue(&mxNode);
		}
	}
}
开发者ID:StephanieSpanjian,项目名称:CyberX3D4CC,代码行数:16,代码来源:Node.cpp


示例6: getTranslationMatrix

void Node::getTranslationMatrix(SFMatrix *mxOut) const
{
	mxOut->init();

	for (const Node *node=this; node; node=node->getParentNode()) {
		if (node->isTransformNode() || node->isBillboardNode()) {
			SFMatrix	mxNode;
			if (node->isTransformNode()) {
				float	translation[3];
				TransformNode *transNode = (TransformNode *)node;
				transNode->getTranslation(translation);
				mxNode.setTranslation(translation);
			}
			mxNode.add(mxOut);
			mxOut->setValue(&mxNode);
		}
	}
}
开发者ID:StephanieSpanjian,项目名称:CyberX3D4CC,代码行数:18,代码来源:Node.cpp


示例7: GetRotateMatrixFromNormal

static void GetRotateMatrixFromNormal(
float		normal[3],
SFMatrix	&matrix)
{
	SFMatrix	mx;
	SFMatrix	my;
	float		mxValue[4][4];
	float		myValue[4][4];

	mx.getValue(mxValue);
	my.getValue(myValue);

	float d = (float)sqrt(normal[1]*normal[1] + normal[2]*normal[2]);

	if (d) {
		float cosa = normal[2] / d;
		float sina = normal[1] / d;
		mxValue[0][0] = 1.0;
		mxValue[0][1] = 0.0;
		mxValue[0][2] = 0.0;
		mxValue[1][0] = 0.0;
		mxValue[1][1] = cosa;
		mxValue[1][2] = sina;
		mxValue[2][0] = 0.0;
		mxValue[2][1] = -sina;
		mxValue[2][2] = cosa;
	}
	
	float cosb = d;
	float sinb = normal[0];
	
	myValue[0][0] = cosb;
	myValue[0][1] = 0.0;
	myValue[0][2] = sinb;
	myValue[1][0] = 0.0;
	myValue[1][1] = 1.0;
	myValue[1][2] = 0.0;
	myValue[2][0] = -sinb;
	myValue[2][1] = 0.0;
	myValue[2][2] = cosb;

	mx.setValue(mxValue);
	my.setValue(myValue);

	matrix.init();
	matrix.add(&my);
	matrix.add(&mx);
}
开发者ID:x414e54,项目名称:CyberX3D4CC,代码行数:48,代码来源:IndexedFaceSetNode.cpp


示例8: setDirection

void SFMatrix::setDirection(float x, float y, float z) {
	SFMatrix	mx;
	SFMatrix	my;
	float		mxValue[4][4];
	float		myValue[4][4];
	float		normal[3];

	mx.getValue(mxValue);
	my.getValue(myValue);

	normal[0] = x;
	normal[1] = y;
	normal[2] = z;

	float d = (float)sqrt(normal[1]*normal[1] + normal[2]*normal[2]);

	if (d) {
		float cosa = normal[2] / d;
		float sina = normal[1] / d;
		mxValue[0][0] = 1.0;
		mxValue[0][1] = 0.0;
		mxValue[0][2] = 0.0;
		mxValue[1][0] = 0.0;
		mxValue[1][1] = cosa;
		mxValue[1][2] = sina;
		mxValue[2][0] = 0.0;
		mxValue[2][1] = -sina;
		mxValue[2][2] = cosa;
	}
	
	float cosb = d;
	float sinb = normal[0];
	
	myValue[0][0] = cosb;
	myValue[0][1] = 0.0;
	myValue[0][2] = sinb;
	myValue[1][0] = 0.0;
	myValue[1][1] = 1.0;
	myValue[1][2] = 0.0;
	myValue[2][0] = -sinb;
	myValue[2][1] = 0.0;
	myValue[2][2] = cosb;

	mx.setValue(mxValue);
	my.setValue(myValue);

	init();
	add(&my);
	add(&mx);
}
开发者ID:lukfugl,项目名称:raytracer,代码行数:50,代码来源:SFMatrix.cpp


示例9: getSFMatrix

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);
}
开发者ID:lukfugl,项目名称:raytracer,代码行数:49,代码来源:TransformNode.cpp


示例10: getTranslationMatrix

void ViewpointNode::getTranslationMatrix(float value[4][4]) 
{
	SFMatrix	mx;
	getTranslationMatrix(&mx);
	mx.getValue(value);
}
开发者ID:lukfugl,项目名称:raytracer,代码行数:6,代码来源:ViewpointNode.cpp


示例11: getTextureCoordinateNodes

bool IndexedFaceSetNode::generateTextureCoordinate() 
{
	TextureCoordinateNode *texCoord = getTextureCoordinateNodes();
	if (texCoord)
		return false;

	CoordinateNode *coordinateNode = getCoordinateNodes();
	if (!coordinateNode)
		return false;

	texCoord = new TextureCoordinateNode();

	int nPolygon = getNPolygons();

	if (nPolygon <= 0)
		return false;

	float	(*normal)[3] = new float[nPolygon][3];
	SFVec3f	*center = new SFVec3f[nPolygon];
	SFVec3f	*maxExtents = new SFVec3f[nPolygon];
	SFVec3f	*minExtents = new SFVec3f[nPolygon];

	bool	bPolygonBegin;
	int		polyn;

	float	point[3][3];
	float	coord[3];

	int		vertexn = 0;
	int		n;


	bPolygonBegin = true;
	polyn = 0;
/*
	int nColorIndexes = idxFaceSet->getNColorIndexes();
	int nNormalIndexes = idxFaceSet->getNNormalIndexes();
	int nTexCoordIndexes = idxFaceSet->getNTexCoordIndexes();
*/
	int nCoordIndexes = getNCoordIndexes();


	for (n=0; n<nCoordIndexes; n++) {
		int coordIndex = getCoordIndex(n);
		if (coordIndex != -1) {

			if (vertexn < 3)
				coordinateNode->getPoint(coordIndex, point[vertexn]);

			float point[3];
			coordinateNode->getPoint(coordIndex, point);
			if (bPolygonBegin) {
				maxExtents[polyn].setValue(point);
				minExtents[polyn].setValue(point);
				center[polyn].setValue(point);
				bPolygonBegin = false;
			}
			else {
				SetExtents(maxExtents[polyn], minExtents[polyn], point);
				center[polyn].add(point);
			}

			vertexn++;
		}
		else {
			GetNormalFromVertices(point, normal[polyn]);
			center[polyn].scale(1.0f / (float)vertexn);
			maxExtents[polyn].sub(center[polyn]);
			minExtents[polyn].sub(center[polyn]);
			vertexn = 0;
			bPolygonBegin = true;
			polyn++;
		}
	}

	float		minx, miny, maxx, maxy, xlength, ylength;
	SFMatrix	matrix;

	bPolygonBegin = true;
	polyn = 0;

	for (n=0; n<nCoordIndexes; n++) {
		int coordIndex = getCoordIndex(n);
		if (coordIndex != -1) {

			if (bPolygonBegin) {
				GetRotateMatrixFromNormal(normal[polyn], matrix);
				matrix.multi(&minExtents[polyn]);
				matrix.multi(&maxExtents[polyn]);
				minx = minExtents[polyn].getX();
				miny = minExtents[polyn].getY();
				maxx = maxExtents[polyn].getX();
				maxy = maxExtents[polyn].getY();
				xlength = (float)fabs(maxExtents[polyn].getX() - minExtents[polyn].getX());
				ylength = (float)fabs(maxExtents[polyn].getY() - minExtents[polyn].getY());

				if (xlength == 0.0f || ylength == 0.0f) {
					delete texCoord;
					delete []minExtents;
					delete []maxExtents;
//.........这里部分代码省略.........
开发者ID:x414e54,项目名称:CyberX3D4CC,代码行数:101,代码来源:IndexedFaceSetNode.cpp


示例12: getSFMatrix

void SFRotation::multi(SFVec3f *vector)
{
	SFMatrix m;
	getSFMatrix(&m);
	m.multi(vector);
}
开发者ID:lukfugl,项目名称:raytracer,代码行数:6,代码来源:SFRotation.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ SFNT_Service类代码示例发布时间:2022-05-31
下一篇:
C++ SFMTRandTSS::URandom方法代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap