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


C++ Spatial::setParentToLocalR方法代码示例

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


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

示例1: window

Game::Game() : window("New renderer demo", windowWidth, windowHeight, false),
lastAnimation(NULL),
walking(false),
pos(vector3f::zero),
dir(0),
cameraMode(false)
{
	//Engine setup:
	root = new RootObject(); //creation
	ResourceManager::getInstance().discoveryDirectory("Content"); //discovery
	//window.setActive(true);
	
	//interaction setup
	window.getKeyboard().setKeyCallback(MakeDelegate(this, &Game::onKeyboardKey));
	window.getMouse().setRelativeMode(true);
	window.getMouse().setButtonCallback(MakeDelegate(this, &Game::onMouseButton));
	window.getMouse().setMoveCallback(MakeDelegate(this, &Game::onMouseMove));

	//scene setup
	scene = new Spatial(new Spheref(vector3f::zero, 0));
	scene->setParentToLocal(matrix4f::identity); // this is critical

	ref<SkinnedMesh> dragon_mesh = ResourceManager::getInstance().getSkinnedMesh("Content/meshes/Dragon/dragon.smf");
	HASSERT(dragon_mesh.isValid());
	dragon_mesh->load();
	player = new SkeletalAnimatedObject(dragon_mesh);

	camera = new Camera(vector3f(0, 0, -1), vector3f(0, 1, 0), M_PI / 4, (float) windowWidth / windowHeight, 10, 20000);
	camera2 = new Camera(vector3f(0, 0, -1), vector3f(0, 1, 0), M_PI / 4, (float) windowWidth / windowHeight, .06, .1);

	ref<HeightMapMesh> hm_mesh = ResourceManager::getInstance().getHeightMapMesh("Content/meshes/HM1/HM.hmf");
	HASSERT(hm_mesh.isValid());
	hm_mesh->load();
	terrain = new HeightMapObject(hm_mesh);
	//terrain->setParentToLocalR(matrix4f::identity.scaled(2.0));
	
	//scene->__forceTransformUpdate();

	scene->attach(terrain);
	scene->attach(player);
	Spatial * dupa = new Spatial(new AABBf(-0.2, -0.2, -0.2, 0.2, 0.2, 0.2));
	dupa->setParentToLocalR(matrix4f::identity.translated(0, 0.1, 0));
	scene->attach(dupa);
	player->attach(camera);
	terrain->attach(camera2);

	ref<StaticMesh> church_mesh = ResourceManager::getInstance().getStaticMesh("Content/meshes/Church/Church.tmf");
	church_mesh->load();
	ref<SkinnedMesh> bigman_mesh = ResourceManager::getInstance().getSkinnedMesh("Content/meshes/BigMan/big_man.smf");
	bigman_mesh->load();
	
	SkeletalAnimatedObject * bigman = new SkeletalAnimatedObject(bigman_mesh);
	bigman->setParentToLocalR(matrix4f::identity.scaled(0.005).rotated(vector3f::nx, M_PI * 0.5).rotated(vector3f::nx, M_PI * 2.3).translated(0.2,.1,0.3));
	
	bigman->animationSet.getAnimationState((uint)0).loop = true;
	bigman->animationSet.getAnimationState((uint) 0).autoRewind = true;
	bigman->animationSet.getAnimationState((uint) 0).start();
	
	Spatial * church = new StaticObject(church_mesh);
	church->setParentToLocalR(matrix4f::identity.translated(30.0, 0.0, 30.0).scaled(0.01));
	scene->attach(church);
	scene->attach(bigman);
	
	camera2->setVisualizeBoudingVolume(false);
	camera2->setParentToLocalR(matrix4f::identity.translated(0.30, 0.1, 0.30));

	Spatial * light = new DirectionalLight(Color(0.3, 0.3, 0.0, 0.0), vector3f::nx, 4*  0.11);
	//Spatial * light = new PointLight(Color(1.0, 1.0, 1.0, 0.0), 5*  0.11);
	dupa->attach(light);
	dupa->setParentToLocalR(matrix4f::identity.translated(vector3f(0.1, 0.2, 0.3)));
	light->setParentToLocalR(matrix4f::identity.rotated(vector3f::nz, M_PI * -0.2));
	
	Spatial * light2 = new DirectionalLight(Color(0.5,0.5,0.5, 0.0), vector3f::nx, 4*  0.11);
	Spatial * dupa2 = new Spatial(new AABBf(-0.2, -0.2, -0.2, 0.2, 0.2, 0.2));
	dupa2->setParentToLocalR(matrix4f::identity.rotated(vector3f::nz, M_PI * 1.5).translated(0.2, 0.4, 0.2));
	dupa2->attach(light2);
	scene->attach(dupa2);
	
	camera->setParentToLocalR(matrix4f::identity.translated(0, 500, 2000).rotated(vector3f::ny, M_PI * .5).rotated(vector3f::nx, M_PI * 0.5).rotated(vector3f::nz, M_PI *0.5));

	//camera->setParentToLocalR(matrix4f::identity.translated(0, 500, 2000).rotated(vector3f::ny, M_PI * .5).rotated(vector3f::nx, M_PI * 0.5).rotated(vector3f::nz, M_PI *0.5));

	//scene->attach(new PointLight(Color(0.85, 0.85, 0.85) ,0.6));
	
	player->animationSet.getAnimationState(6).loop = true;
	player->animationSet.getAnimationState(3).loop = true;
	player->animationSet.getAnimationState((uint) 0).autoRewind = true;
	player->animationSet.getAnimationState(2).autoRewind = true;
	player->animationSet.getAnimationState(5).autoRewind = true;

	setAnimation(-1u);
}
开发者ID:habanero3d,项目名称:habanero3d-current,代码行数:92,代码来源:game.cpp


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