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

C++ TransformNode类代码示例

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

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



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

示例1: Matrix

void Scene::render(Pixel* px, Vertex *eyePoint, double attenuation)
{
   //create the zbuffer matrix
   int width = px->getWidth();
   int height = px->getHeight();
   Matrix* zbuffer = new Matrix(height, width);    //rows come first

   //populate zbuffer with -1
   for (int i = 1; i <= height; i++)
   {
      for (int j = 1; j <= width; j++)
      {
         zbuffer->setElement(i, j, -1.0);
      }
   }
   
   //loop over all the Instance instances in the Scene and render them
   ListIterator<TransformNode>* ioIter = transformNodes->iterator();
   while (ioIter->hasNext())
   {
      TransformNode* tn = ioIter->next();
      tn->render(px, sceneTransform, zbuffer, ambientLight, pointLight, eyePoint, attenuation);
   }

   delete ioIter;
   delete zbuffer;
}
开发者ID:alwalker,项目名称:TTU,代码行数:27,代码来源:Scene.cpp


示例2: size

    Node *update(Node *old) {
        if (old)
            return old;

        vec2 s = size();
        vec2 s3 = s / 3;

        // Root has origin in screen center
        TransformNode *root = TransformNode::create();
        root->setMatrix(mat4::translate2D(s.x * 0.5, s.y * 0.5));

        OpacityNode *opacityNode = OpacityNode::create();
        // opacityNode->setOpacity(0.5);
        root->append(opacityNode);

        vec4 color(0.5, 0.5, 0.8, 1.0);

        *opacityNode << RectangleNode::create(rect2d::fromPosSize(-s3, s3), color)
                     << RectangleNode::create(rect2d::fromPosSize(-s3/2, s3), color)
                     << RectangleNode::create(rect2d::fromPosSize(vec2(), s3), color);

        AnimationClosure<OpacityNode> *anim = new AnimationClosure<OpacityNode>(opacityNode);
        anim->setDuration(3);
        anim->setDirection(Animation::Alternate);
        anim->setIterations(-1);
        anim->keyFrames.times() << 0 << 1;
        anim->keyFrames.addValues<double, OpacityNode_setOpacity>() << 0 << 1;
        animationManager()->startAnimation(anim);

        return root;

    }
开发者ID:sletta,项目名称:rengine,代码行数:32,代码来源:layeredopacity.cpp


示例3: Vector3

Vector3 Bone::CalculateNodePositionInSkeletonSpace(
	const std::vector<int>& node_locator,
	uint& index,
	const Transform& parent_transform,
	const TransformNode& parent_transform_node
	) const
{
	if( (uint)node_locator.size() == index )
	{
		return parent_transform * m_vOffset;
	}

	int bone_and_node_index = node_locator[index];
	const int num_children = (int)m_vecChild.size();
	if( num_children <= bone_and_node_index
	 || parent_transform_node.GetNumChildren() <= bone_and_node_index )
	{
		return Vector3(0,0,0);
	}

	index++;

	const TransformNode& child_transform_node = parent_transform_node.GetChildNode(bone_and_node_index);
	Transform offset_transform = Transform( Quaternion().FromRotationMatrix(Matrix33Identity()), m_vOffset );
	Matrix34 transform;
	CalculateWorldTransform( transform, parent_transform.ToMatrix34(), child_transform_node );
	return m_vecChild[bone_and_node_index].CalculateNodePositionInSkeletonSpace(
		node_locator,
		index,
		parent_transform * child_transform_node.GetLocalTransform() * offset_transform,
		child_transform_node
		);
}
开发者ID:HermanHGF,项目名称:amorphous,代码行数:33,代码来源:Skeleton.cpp


示例4: ConstructWall

SceneNode* ConstructWall(PresentationNode* material,PresentationNode* containedMaterial,SceneNode* contained){
	SceneNode* wall = new TransformNode;
	wall->AddChild(material);
	wall->AddChild(containedMaterial);

	SceneNode* box = ConstructBox(200,6,25);

	TransformNode* t = new TransformNode;
	t->AddChild(box);
	t->Translate(0,14.6f,12.5f);
	material->AddChild(t);

	TransformNode* t2 = new TransformNode;
	t2->AddChild(box);
	t2->Translate(0,-14.6f,12.5f);
	material->AddChild(t2);

	TransformNode* inner = new TransformNode;
	inner->AddChild(ConstructBox(200,26.2,15));
	inner->Translate(0,0,7.5f);
	material->AddChild(inner);

	TransformNode* top = new TransformNode;
	top->AddChild(contained);
	top->Translate(0,0,20);
	containedMaterial->AddChild(top);
	return wall;
 }
开发者ID:zmnatz,项目名称:2010-Fall-Computer-Graphics-Class,代码行数:28,代码来源:PhongShading.cpp


示例5: update

void RotateBehavior::update(SceneNode* node, InputHandler* input, double deltaTime)
{
	TransformNode* transformNode = (TransformNode *)node->getParent();
	glm::highp_mat4 trans = transformNode->getTransform();

	//glm::highp_vec3 translation = glm::highp_vec3(trans[3][0], trans[3][1], trans[3][2]);
	glm::highp_vec3 translation = glm::highp_vec3(0, 0, -0.30);
	trans = glm::translate(trans, -translation);
	trans = glm::rotate(trans, -1., glm::highp_vec3(0, 1, 0));
	trans = glm::translate(trans, translation);
	transformNode->setNewTransform(trans);
}
开发者ID:MaryAnnZ,项目名称:Beyond_the_Black_Rainbow,代码行数:12,代码来源:RotateBehavior.cpp


示例6:

TransformNode *SceneGraph::findTransformNode(char *name) {
	if (!name || strlen(name) <= 0)
		return NULL;
	for (TransformNode *node = findTransformNode(); node; node = node->nextTraversal()) {
		const char *nodeName = node->getName();
		if (nodeName && strlen(nodeName)) {
			if (!strcmp(name, nodeName))
				return node;
		}
	}
	return NULL;
}
开发者ID:lukfugl,项目名称:raytracer,代码行数:12,代码来源:SceneGraph.cpp


示例7: groupSelectedObjects

// Function to process the Group menu command. 
void groupSelectedObjects()
{
	if (!onlySiblingsSelected()) return;
	if (lastSelected == sceneRoot)
	{
		sceneRoot = new TransformNode(NULL);
		sceneRoot->addChild(lastSelected);
		lastSelected->setParent(sceneRoot);
	}
	TransformNode* oldParent = lastSelected->getParent();
	oldParent->groupObjects(selections);
}
开发者ID:zuchermann,项目名称:GraphicsClass,代码行数:13,代码来源:drawing.cpp


示例8: while

Scene::~Scene()
{
   //clean up all of the basic object heap-allocated memory
   ListIterator<TransformNode>* ioIter = transformNodes->iterator();
   while (ioIter->hasNext())
   {
      TransformNode* tn = ioIter->next();
      tn->removeRef();
   }

   delete ioIter;
   delete transformNodes;
   delete sceneTransform;
}
开发者ID:alwalker,项目名称:TTU,代码行数:14,代码来源:Scene.cpp


示例9: noParentAncestorSelections

// Function to verify that no ancestor of the last selected node 
// is a member of the selection set. 
bool noParentAncestorSelections()
{
	TransformNode* current = lastSelected->getParent();
	while (current)
	{
		if (selections.find(current) != selections.end())
		{
			cerr << "Operation not valid for selection set." << endl;
			cerr << "An ancestor of the last selected item is also selected." << endl;
			return false;
		}
		current = current->getParent();
	}
	return true;
}
开发者ID:zuchermann,项目名称:GraphicsClass,代码行数:17,代码来源:drawing.cpp


示例10: lastSelectedLeft

// Change last selection to previous sibling. 
void lastSelectedLeft()
{
	TransformNode* parent = lastSelected->getParent();
	if (parent)
	{
		TransformNode* node = parent->previousChild(lastSelected);
		if (node)
		{
			lastSelected->deSelect();
			selections.erase(lastSelected);
			lastSelected = node;
			lastSelected->select();
			selections.insert(lastSelected);
		}
	}
}
开发者ID:zuchermann,项目名称:GraphicsClass,代码行数:17,代码来源:drawing.cpp


示例11: calcOrientation

static void calcOrientation(TransformNode& node, const ofVec3f& orientation)
{
	switch(node.getRotationOrder()) {
		case TransformNode::ROTATION_ORDER_XYZ:
			node.setOrientation(orientation.x,ofVec3f(1,0,0),
								orientation.y,ofVec3f(0,1,0),
								orientation.z,ofVec3f(0,0,1));
			break;
		case TransformNode::ROTATION_ORDER_YZX:
			node.setOrientation(orientation.y,ofVec3f(0,1,0),
								orientation.z,ofVec3f(0,0,1),
								orientation.x,ofVec3f(1,0,0));
			break;
		case TransformNode::ROTATION_ORDER_ZXY:
			node.setOrientation(orientation.z,ofVec3f(0,0,1),
								orientation.x,ofVec3f(1,0,0),
								orientation.y,ofVec3f(0,1,0));
			break;
		case TransformNode::ROTATION_ORDER_XZY:
			node.setOrientation(orientation.x,ofVec3f(1,0,0),
								orientation.z,ofVec3f(0,0,1),
								orientation.y,ofVec3f(0,1,0));
			break;
		case TransformNode::ROTATION_ORDER_YXZ:
			node.setOrientation(orientation.y,ofVec3f(0,1,0),
								orientation.x,ofVec3f(1,0,0),
								orientation.z,ofVec3f(0,0,1));
			break;
		case TransformNode::ROTATION_ORDER_ZYX:
			node.setOrientation(orientation.z,ofVec3f(0,0,1),
								orientation.y,ofVec3f(0,1,0),
								orientation.x,ofVec3f(1,0,0));
			break;
	}
}
开发者ID:saadahid,项目名称:ofxAE,代码行数:35,代码来源:ofxAEProperty.cpp


示例12: 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


示例13: Color

void Picture::render(Pixel* px)
{
	Color *ambient = new Color(1, 1, 1);
	Vertex *eye = new Vertex(0,0,0);
	Light *light = new Light();
	double attenuation = 0;
//while(true)
//{

   char* fileName = "sphere.txt";
   //cout<<"calling read object"<<endl;
   BasicObject* sphere = readObject(fileName);
   sphere->computeSandT();
   //sphere->printFaces();
   //cout<<"called it bitches"<<endl;
   //delete[] fileName;  //mingw appears to delete this automatically

   fileName = "trs.txt";
   InstanceObject* sphereInstance = buildInstanceObject(fileName, sphere);
   //delete[] fileName;

   //obtaining the window transform
   int widthPixels = px->getWidth();  //the dimensions of the panel on which the drawing will occur
   int heightPixels = px->getHeight();

   getShaderInfo(eye, ambient, light, &attenuation);
   Scene* scene = new Scene(light, ambient);
   scene->buildTransform(getCameraTransform("camera.txt"));
   scene->buildTransform(getPerspectiveTransform("fov.txt", widthPixels, heightPixels));
   scene->buildTransform(AffineTransforms::window(widthPixels, heightPixels));


   TransformNode* tn = new TransformNode();
   tn->addChild(sphereInstance);
   scene->addTransformNode(tn);

   //for(;;)
   //{
   scene->render(px, eye, attenuation);
   //}
   delete scene;
//}
}
开发者ID:alwalker,项目名称:TTU,代码行数:43,代码来源:Picture.cpp


示例14: CalculateWorldTransform

void Bone::CalculateWorldTransform( Matrix34& dest_transform, const Matrix34& parent_transform, const TransformNode& input_node ) const
{
  if( g_htrans_rev == 3 )
  {
	if( false/*m_TransformStyle & APPLY_LOCAL_ROTATION_TO_OFFSET*/ )
	{
		const Matrix33 matLocalRot = input_node.GetLocalRotationQuaternion().ToRotationMatrix();
		const Vector3 vLocalTrans = input_node.GetLocalTranslation() + m_vOffset;
/*		dest_transform.vPosition = parent_transform.matOrient * matLocalRot * vLocalTrans + parent_transform.vPosition;
		dest_transform.matOrient = parent_transform.matOrient * matLocalRot;
*/
		dest_transform
			= parent_transform
			* Matrix34( input_node.GetLocalTranslation(), matLocalRot );
//			* Matrix34( -m_vOffset, Matrix33Transpose(m_matOrient) );
//			* Matrix34( m_vOffset, m_matOrient ).GetInverseROT();
//			* Matrix34( Vector3(0,0,0), m_matOrient );
	}
	else
	{
		Matrix33 matRotation = input_node.GetLocalRotationQuaternion().ToRotationMatrix() * m_matOrient;
		dest_transform
			= parent_transform
//			* Matrix34( input_node.GetLocalTranslation(), input_node.GetLocalRotationQuaternion().ToRotationMatrix() )
//			* Matrix34( m_vOffset, Matrix33Identity() );
///			* Matrix34( input_node.GetLocalTranslation() + m_vOffset, input_node.GetLocalRotationQuaternion().ToRotationMatrix() );
///			* Matrix34( input_node.GetLocalTranslation() + m_vOffset, matRotation );
///			* Matrix34( Vector3(0,0,0), matRotation ) * Matrix34( input_node.GetLocalTranslation() + m_vOffset, Matrix33Identity() );
///			* Matrix34( Vector3(0,0,0), m_matOrient ) * Matrix34( input_node.GetLocalTranslation() + m_vOffset, input_node.GetLocalRotationQuaternion().ToRotationMatrix() );
//			* Matrix34( input_node.GetLocalTranslation(), input_node.GetLocalRotationQuaternion().ToRotationMatrix() ) * Matrix34( m_vOffset, m_matOrient );
//			* Matrix34( input_node.GetLocalTranslation(), input_node.GetLocalRotationQuaternion().ToRotationMatrix() ) * Matrix34( Vector3(0,0,0), m_matOrient ) * Matrix34( m_vOffset, Matrix33Identity() );

			// Transforms for arms are not correctly calculated.
			// The root and other nodes are not correctly transformed for run motion.
			* Matrix34( m_vOffset, m_matOrient ) * Matrix34( input_node.GetLocalTranslation(), input_node.GetLocalRotationQuaternion().ToRotationMatrix() );
	}
  }
  else // if( sg_rev == 2 )
  {
	//
  }
}
开发者ID:HermanHGF,项目名称:amorphous,代码行数:42,代码来源:Skeleton.cpp


示例15: noAncestorDescendantSelections

// Function to verify that selection set includes no two nodes, one of
// which is an ancestor of the other. 
bool noAncestorDescendantSelections()
{
	for (set<TransformNode*>::const_iterator iter = selections.begin();
	iter != selections.end();
		++iter)
	{
		TransformNode* current = (*iter)->getParent();
		while (current)
		{
			if (selections.find(current) != selections.end())
			{
				cerr << "Operation not valid for selection set." << endl;
				cerr << "An ancestor of a selected item is also selected." << endl;
				return false;
			}
			current = current->getParent();
		}
	}
	return true;
}
开发者ID:zuchermann,项目名称:GraphicsClass,代码行数:22,代码来源:drawing.cpp


示例16: Matrix

void Scene::render(Pixel* px)
{
	//Create zbuffer
	Matrix *zBuffer = new Matrix(px->getHeight(), px->getWidth());
	for(int i=0 ; i<px->getHeight() ; i++)
	{
		for(int j=0 ; j<px->getWidth() ; j++)
		{
			zBuffer->setElement(i, j, -1);
		}
	}
   //loop over all the Instance instances in the Scene and render them
   ListIterator<TransformNode>* ioIter = transformNodes->iterator();
   while (ioIter->hasNext())
   {
      TransformNode* tn = ioIter->next();
      tn->render(px, sceneTransform, zBuffer);
   }
   delete ioIter;
}
开发者ID:alwalker,项目名称:TTU,代码行数:20,代码来源:Scene.cpp


示例17: deleteSelectedObjects

// Function to process the Delete menu command. 
void deleteSelectedObjects()
{
	if (lastSelected == NULL) return;
	if (!noAncestorDescendantSelections()) return;
	for (set<TransformNode*>::const_iterator iter = selections.begin();
	iter != selections.end();
		++iter)
	{
		TransformNode* target = *iter;
		if (target == sceneRoot)
		{
			sceneRoot = new TransformNode(NULL);
			sceneRoot->addChild(target);
			target->setParent(sceneRoot);
		}
		target->getParent()->removeChild(target);
		delete target;
	}
	selections.clear();
	glutPostRedisplay();
}
开发者ID:zuchermann,项目名称:GraphicsClass,代码行数:22,代码来源:drawing.cpp


示例18: SetInterpolatedTransform_r

void TransformNode::SetInterpolatedTransform_r( float frac,
	const TransformNode& node0,
	const TransformNode& node1,
	const TransformNode& node2,
	const TransformNode& node3
	)
{
//	SetInterpolatedTransform_r( frac, node1, node2 );
//	return;

	Transform local_transform = InterpolateWithTCBSpline(
		frac,
		Transform( node0.GetLocalTransform() ),
		Transform( node1.GetLocalTransform() ),
		Transform( node2.GetLocalTransform() ),
		Transform( node3.GetLocalTransform() )
		);

	SetTransform( local_transform );

	const Matrix33 mat = m_Rotation.ToRotationMatrix(); // check the rotation for debugging

	const size_t num_children = node0.m_vecChildNode.size();

	if( m_vecChildNode.size() != num_children )
	{
		m_vecChildNode.resize( num_children );
	}

	for( size_t i=0; i<num_children; i++ )
	{
		m_vecChildNode[i].SetInterpolatedTransform_r( frac,
			node0.m_vecChildNode[i],
			node1.m_vecChildNode[i],
			node2.m_vecChildNode[i],
			node3.m_vecChildNode[i]
			);
	}
}
开发者ID:HermanHGF,项目名称:amorphous,代码行数:39,代码来源:TransformNode.cpp


示例19: copySelectedObjects

// Function to process the Copy menu command. 
void copySelectedObjects()
{
	if (!noAncestorDescendantSelections()) return;
	for (set<TransformNode*>::const_iterator iter = selections.begin();
	iter != selections.end();
		++iter)
	{
		TransformNode* target = *iter;
		if (target == sceneRoot)
		{
			sceneRoot = new TransformNode(NULL);
			sceneRoot->addChild(target);
			target->setParent(sceneRoot);
		}
		TransformNode* parent = target->getParent();
		TransformNode* newThing = target->clone();
		parent->addChild(newThing);
		newThing->setParent(parent);
		target->translate(COPY_OFF_X, COPY_OFF_Y);
	}
	glutPostRedisplay();
}
开发者ID:zuchermann,项目名称:GraphicsClass,代码行数:23,代码来源:drawing.cpp


示例20: animate

void Scenegraph::animate(float time)
{
	
	TransformNode * rideTransform = (TransformNode *) root->getNode("car-transform");
	TransformNode * seatTransform = (TransformNode *) root->getNode("seat-transform");

	if(rideTransform!=NULL)
		rideTransform->setAnimationTransform(glm::translate(glm::mat4(1.0),glm::vec3(sin(time*10)*100,0,0)) );//* glm::rotate(glm::mat4(1.0),time*10,glm::vec3(0,1,0)));
	
	if(seatTransform!=NULL)
		seatTransform->setAnimationTransform(glm::rotate(glm::mat4(1.0),time*10,glm::vec3(0,1,0)));

	if(root->getNode("chair") != NULL){
	TransformNode *ch1 = NULL;
	TransformNode *ch2 = NULL;
	TransformNode *ch3 = NULL;
	TransformNode *ch4 = NULL;
	TransformNode *ride = NULL;
	glm::mat4 temp = glm::mat4(1.0);
	glm::mat4 temp2 = glm::mat4(1.0);
	glm::mat4 temp3 = glm::mat4(1.0);
	glm::mat4 temp4 = glm::mat4(1.0);
	glm::mat4 temp5 = glm::mat4(1.0);

	temp = glm::translate(glm::mat4(1),glm::vec3(0,abs(cos(time*3))*12,0));
	temp2 = glm::translate(glm::mat4(1),glm::vec3(0,0,abs(cos(time*3))*12));
	temp3 = glm::translate(glm::mat4(1),glm::vec3(0,0,-1*abs(cos(time*3))*12));
	temp4 = glm::translate(glm::mat4(1),glm::vec3(0,-1*abs(cos(time*3))*12,0));
	temp5 *= glm::rotate(glm::mat4(1.0),glm::radians(time*50),glm::vec3(0,1,0));
	temp5 *= glm::rotate(glm::mat4(1.0),glm::radians(sin(time*5.0f)*30),glm::vec3(0,0,1));
	temp5 *= glm::rotate(glm::mat4(1.0),glm::radians(cos(time*5.0f)*30),glm::vec3(1,0,0));
	//temp5 *= glm::rotate(glm::mat4(1.0),glm::radians(40.0f),glm::vec3(1,0,0));
	
	temp *= glm::rotate(glm::mat4(1.0),glm::radians(time*500),glm::vec3(1,0,0));
	temp2 *= glm::rotate(glm::mat4(1.0),glm::radians(time*500),glm::vec3(1,0,0));
	temp3 *= glm::rotate(glm::mat4(1.0),glm::radians(time*500),glm::vec3(1,0,0));
	temp4 *= glm::rotate(glm::mat4(1.0),glm::radians(time*500),glm::vec3(1,0,0));
	
	ch1 = static_cast<TransformNode*> (root->getNode("chair"));
	ch2 = static_cast<TransformNode*>(root->getNode("chair2"));
	ch3 = static_cast<TransformNode*>(root->getNode("chair3"));
	ch4 =static_cast<TransformNode*>( root->getNode("chair4"));
	ride = static_cast<TransformNode*>( root->getNode("ride"));
	ch1->setAnimationTransform(temp);
	ch2->setAnimationTransform(temp2);
	ch3->setAnimationTransform(temp3);
	ch4->setAnimationTransform(temp4);
	ride->setAnimationTransform(temp5);
	

	}

}
开发者ID:bmgrayb,项目名称:IT356,代码行数:53,代码来源:Scenegraph.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ TransformOperations类代码示例发布时间:2022-05-31
下一篇:
C++ TransformKeyFrame类代码示例发布时间: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