; EntityRadius Example ; -------------------- Graphics3D 640,480,0,2 SetBuffer BackBuffer() ; Collision type ids type_player=1 type_scenery=2 ; NOTE: fixed overhead camera - the arrow keys steer the PLAYER, not the camera camera=CreateCamera() PositionEntity camera,0,13,-13 RotateEntity camera,45,0,0 light=CreateLight() RotateEntity light,60,30,0 floor=CreatePlane() EntityColor floor,70,110,70 ; The player ball - the collision source whose radius we will change player=CreateSphere() EntityColor player,220,60,60 PositionEntity player,0,1,0 EntityType player,type_player ; A wall with a 2-unit doorway in the middle wallL=CreateCube() ScaleEntity wallL,2,1.2,1.2 PositionEntity wallL,-3,1.2,4 EntityColor wallL,150,150,160 EntityType wallL,type_scenery wallR=CreateCube() ScaleEntity wallR,2,1.2,1.2 PositionEntity wallR,3,1.2,4 EntityColor wallR,150,150,160 EntityType wallR,type_scenery ; Ellipsoid-to-polygon collisions with a sliding response Collisions type_player,type_scenery,2,2 radius#=1.4 While Not KeyDown(1) ; Arrow keys steer the player ball If KeyDown(200) Then MoveEntity player,0,0,0.1 If KeyDown(208) Then MoveEntity player,0,0,-0.1 If KeyDown(203) Then MoveEntity player,-0.1,0,0 If KeyDown(205) Then MoveEntity player,0.1,0,0 ; [ and ] shrink or grow the collision radius If KeyDown(26) And radius>0.3 Then radius=radius-0.02 If KeyDown(27) And radius<2 Then radius=radius+0.02 ; The star of the show: set the ball's collision ellipsoid radius... EntityRadius player,radius ; ...and scale the mesh to match, so what you see is what collides ScaleEntity player,radius,radius,radius ; Keep the ball resting on the floor whatever its size PositionEntity player,EntityX(player),radius,EntityZ(player) ; UpdateWorld performs the collision checks and the slide response UpdateWorld RenderWorld Text 0,0,"Arrow keys: drive the ball [ / ] : change radius Esc: exit" Text 0,20,"EntityRadius player,"+radius Text 0,40,"The doorway is 2 units wide - shrink the radius below 1.0 to fit through" Flip Wend End