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


C++ TransformNode::RotateBy方法代码示例

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


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

示例1: bodyPosition

Scene::Scene(int viewSizeX, int viewSizeY) :
m_root(new Node(0)),
m_camera(vEyePos, vFocus, vUp, Point(viewSizeX, viewSizeY), fov, zNear, zFar),
m_light(lightDirection),
m_renderer(&m_camera, &m_light),
m_viewSize(viewSizeX, viewSizeY),
m_cameraFolows(true),
m_fpsStart(0),
m_numFrames(0),
m_frameTime(0.0f),
fpsString()
{
	// Here we build our scene, adding nodes to the scene graph:
	//
	//			---> terrainMeshNode
	//			|
	//	root ---|										  ---> rwingTransformNode -> rwingAnimationNode -> rwingMeshNode
	//			|										 |
	//			---> bodyTransformNode -> bodyMeshNode --|
	//													 |
	//													  ---> lwingTransformNode -> lwingAnimationNode -> lwingMeshNode

	// std::vectors for raw geometry data (they will be reused)
	std::vector<Vertex> vertices;
	std::vector<unsigned int> indices;

	// Terrain : only mesh node
	CreateGrid(terrainSize, terrainResolution, vertices, indices);
	Mesh* terrainMesh = m_renderer.CreateMesh(vertices, indices, false);

	MeshNode* terrainMeshNode = new MeshNode(terrainMesh, &m_renderer);
	m_root->AddChild(terrainMeshNode);


	// Body : transform node -> mesh node
	TransformNode* bodyTransformNode = new TransformNode(&m_renderer);
	Vector3 bodyPosition(0.0f, 10.0f, 0.0f);
	bodyTransformNode->MoveTo(bodyPosition);
	bodyTransformNode->SetDirection(Vector3(1.0f, 0.0f, 0.0f));
	bodyTransformNode->RotateBy(-math::PiDiv6, Vector3(0.0f, 1.0f, 0.0f));
	m_root->AddChild(bodyTransformNode);

	vertices.clear();
	indices.clear();
	LoadMesh("../../meshes/teapot.obj", vertices, indices, Color(1.0f, 0.0f, 0.0f, 1.0f));
	Mesh* bodyMesh = m_renderer.CreateMesh(vertices, indices);

	MeshNode* bodyMeshNode = new MeshNode(bodyMesh, &m_renderer);
	bodyTransformNode->AddChild(bodyMeshNode);

	m_bird = new PlayerCharacter(bodyTransformNode, &m_keyboard);

	// Right wing : transform node -> animation node -> mesh node
	TransformNode* rwingTransformNode = new TransformNode(&m_renderer);
	Vector3 rwingPosition(0.0f, 0.0f, 0.0f);
	rwingTransformNode->MoveTo(rwingPosition);
	bodyMeshNode->AddChild(rwingTransformNode);

	AnimationNode* rwingAnimationNode = new WingAnimationNode(&m_renderer);
	rwingTransformNode->AddChild(rwingAnimationNode);

	vertices.clear();
	indices.clear();
	LoadMesh("../../meshes/wing.obj", vertices, indices, Color(1.0f, 1.0f, 0.0f, 1.0f));
	Mesh* rwingMesh = m_renderer.CreateMesh(vertices, indices);

	MeshNode* rwingMeshNode = new MeshNode(rwingMesh, &m_renderer);
	rwingAnimationNode->AddChild(rwingMeshNode);


	// Left wing : transform node -> animation node -> mesh node
	TransformNode* lwingTransformNode = new TransformNode(&m_renderer);
	Vector3 lwingPosition(0.0f, 0.0f, 0.0f);
	lwingTransformNode->MoveTo(lwingPosition);
	lwingTransformNode->RotateBy(math::Pi, Vector3(0.0f, 1.0f, 0.0f));
	bodyMeshNode->AddChild(lwingTransformNode);

	AnimationNode* lwingAnimationNode = new WingAnimationNode(&m_renderer, true);
	lwingTransformNode->AddChild(lwingAnimationNode);

	vertices.clear();
	indices.clear();
	LoadMesh("../../meshes/wing.obj", vertices, indices, Color(1.0f, 1.0f, 0.0f, 1.0f));
	Mesh* lwingMesh = m_renderer.CreateMesh(vertices, indices);

	MeshNode* lwingMeshNode = new MeshNode(lwingMesh, &m_renderer);
	lwingAnimationNode->AddChild(lwingMeshNode);

	m_fpsStart = glutGet(GLUT_ELAPSED_TIME);
	fpsString.resize(256);
}
开发者ID:Luckymee,项目名称:INB381,代码行数:91,代码来源:scene.cpp


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