MCPcopy Create free account
hub / github.com/axmolengine/axmol / TerrainWalkThru

Method TerrainWalkThru

tests/cpp-tests/Source/TerrainTest/TerrainTest.cpp:113–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111}
112
113TerrainWalkThru::TerrainWalkThru()
114{
115 auto listener = EventListenerTouchAllAtOnce::create();
116 listener->onTouchesBegan = AX_CALLBACK_2(TerrainWalkThru::onTouchesBegan, this);
117 listener->onTouchesEnded = AX_CALLBACK_2(TerrainWalkThru::onTouchesEnd, this);
118 _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
119
120 Size visibleSize = Director::getInstance()->getVisibleSize();
121
122 // use custom camera
123 _camera = Camera::createPerspective(60, visibleSize.width / visibleSize.height, 0.1f, 200);
124 _camera->setCameraFlag(CameraFlag::USER1);
125 addChild(_camera);
126
127 Terrain::DetailMap r("TerrainTest/dirt.jpg"), g("TerrainTest/Grass2.jpg", 10), b("TerrainTest/road.jpg"),
128 a("TerrainTest/GreenSkin.jpg", 20);
129
130 Terrain::TerrainData data("TerrainTest/heightmap16.jpg", "TerrainTest/alphamap.png", r, g, b, a, Size(32, 32),
131 40.0f, 2);
132 _terrain = Terrain::create(data, Terrain::CrackFixedType::SKIRT);
133 _terrain->setMaxDetailMapAmount(4);
134 _terrain->setCameraMask(2);
135 _terrain->setDrawWire(false);
136
137 _terrain->setSkirtHeightRatio(3);
138 _terrain->setLODDistance(64, 128, 192);
139 _player = Player::create("MeshRendererTest/girl.c3b", _camera, _terrain);
140 _player->setCameraMask(2);
141 _player->setScale(0.08f);
142 _player->setPositionY(_terrain->getHeight(_player->getPositionX(), _player->getPositionZ()) + PLAYER_HEIGHT);
143
144 // add Particle3D for test blend
145 auto rootps = PUParticleSystem3D::create("Particle3D/scripts/mp_torch.pu");
146 rootps->setCameraMask((unsigned short)CameraFlag::USER1);
147 rootps->setScale(30.0f);
148 rootps->startParticleSystem();
149 _player->addChild(rootps);
150
151 // add BillBoard for test blend
152 auto billboard = BillBoard::create("Images/btn-play-normal.png");
153 billboard->setPosition3D(Vec3(0, 180, 0));
154 billboard->setCameraMask((unsigned short)CameraFlag::USER1);
155 _player->addChild(billboard);
156
157 auto animation = Animation3D::create("MeshRendererTest/girl.c3b", "Take 001");
158 if (animation)
159 {
160 auto animate = Animate3D::create(animation);
161 _player->runAction(RepeatForever::create(animate));
162 }
163
164 _camera->setPosition3D(_player->getPosition3D() + camera_offset);
165 _camera->setRotation3D(Vec3(-45, 0, 0));
166
167 addChild(_player);
168 addChild(_terrain);
169}
170

Callers

nothing calls this directly

Calls 15

createFunction · 0.85
getInstanceFunction · 0.85
setMaxDetailMapAmountMethod · 0.80
setDrawWireMethod · 0.80
setSkirtHeightRatioMethod · 0.80
setLODDistanceMethod · 0.80
getPositionZMethod · 0.80
SizeFunction · 0.50
Vec3Function · 0.50
getVisibleSizeMethod · 0.45
setCameraMaskMethod · 0.45

Tested by

no test coverage detected