MCPcopy Create free account
hub / github.com/cinder/Cinder / makeIsland

Method makeIsland

samples/FallingGears/src/SceneController.cpp:187–215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

185}
186
187shared_ptr<Island> SceneController::makeIsland()
188{
189 const float baseHeight = randFloat( 70, 110 );
190 const float topHeight = randFloat( 70, 90 );
191 const float baseWidth = 140;
192 const float topWidth = 8;
193
194 auto island = make_shared<Island>( mAudio );
195 island->mOuterVerts = calcNextOuterBumperVerts( baseHeight, topHeight, baseWidth, topWidth );
196 island->mInnerVerts = calcInnerBumperVerts( baseHeight, topHeight, baseWidth );
197 island->setupGeometry();
198
199 vector<b2Vec2> vertsBox2d;
200
201 for( size_t i = 0; i < island->mOuterVerts.size(); i++ )
202 vertsBox2d.emplace_back( pointsToMeters( island->mOuterVerts[i].x ), pointsToMeters( island->mOuterVerts[i].y ) );
203
204 b2PolygonShape polygon;
205 polygon.Set( vertsBox2d.data(), vertsBox2d.size() );
206
207 b2BodyDef islandBodyDef;
208 islandBodyDef.type = b2_kinematicBody;
209
210 island->mBody = box2d::makeBodyShared( mWorld.get(), islandBodyDef );
211 island->mBody->CreateFixture( &polygon, 0.0f );
212 island->mBody->SetUserData( island.get() );
213
214 return island;
215}
216
217void SceneController::addGear( const vec2 &pos )
218{

Callers

nothing calls this directly

Calls 10

randFloatFunction · 0.85
pointsToMetersFunction · 0.85
makeBodySharedFunction · 0.85
CreateFixtureMethod · 0.80
setupGeometryMethod · 0.45
sizeMethod · 0.45
SetMethod · 0.45
dataMethod · 0.45
getMethod · 0.45
SetUserDataMethod · 0.45

Tested by

no test coverage detected