本文整理汇总了C++中Spatial::attach方法的典型用法代码示例。如果您正苦于以下问题:C++ Spatial::attach方法的具体用法?C++ Spatial::attach怎么用?C++ Spatial::attach使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Spatial
的用法示例。
在下文中一共展示了Spatial::attach方法的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);
}