Latest UploadsKing SalmonPakzSnookerJayenkaiYou've ... o have youJayenkaiMerry XmasJayenkaiRCT Classic on iOSJayenkaiOopsJayenkai
 Code Snippets > Collisions and Physics ( Created 26 September 2006 | Last Edited 26 September 2006)

 3D Collisions by Scherererer | No Votes3D Collisions and detecting which object collided Written inBlitz Graphics3D 800,600 Const USER = 1, CUBE = 2 ; Collision constants, technically we can just use the numbers, but this makes it easier to read ; Creating a camera cam = CreateCamera() EntityType cam, USER ; Assign it a type so it knows how its colliding EntityRadius cam, 2 ; the imaginary sphere around the camera that acts as the collision object ; Make and objects type with an entity field Type objects Field entity End Type ; This function just creates an object, and is all wrapped up so we can easily make as many as we want ; without repeating code Function objects.objects(x,y,z) o.objects = New objects ; Create the object o\entity = CreateCube() ; Give it a mesh so that we can see it EntityType o\entity, CUBE ; Tell it what type of object it is, so it can identify it in the collisions PositionEntity o\entity, x, y, z ; Position it End Function ; creating a few objects around the map to collide with objects(0,0,20) objects(5,0,15) objects(-5,0,15) objects(15,0,0) ; lets tell blitz what's going to be colliding with what, and what way to tell it that its colliding Collisions USER, CUBE, 2, 3 While Not KeyDown(1) UpdateWorld ;this is where the actual collisions are calculated RenderWorld ; Checks to see if an object collided, if so it changes red For o.objects = Each objects If EntityCollided(cam, CUBE) = o\entity EntityColor o\entity, 255, 0,0 EndIf Next ; ----------------- ; All this does is move the camera around If KeyDown(200) TurnEntity cam,.1,0,0 ElseIf KeyDown(208) TurnEntity cam,-.1,0,0 EndIf If KeyDown(205) TurnEntity cam,0,-.3,0 ElseIf KeyDown(203) TurnEntity cam,0,.3,0 EndIf If KeyDown(30) MoveEntity cam,0,0,.1 ElseIf KeyDown(44) MoveEntity cam,0,0,-.1 EndIf ; End camera movement code Flip ; flip the buffer Wend -->

There are no comments for this entry. -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 549|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
 Latest PostsHurricane Doris vs Shed Roof steve_ancell Wed 20:23 PIP Crap Jayenkai Wed 16:45 What Have You Done? - Feb 2017 rockford Wed 12:23 SSL Options Jayenkai Wed 11:31 AGameAWeek : 2017 - Part One Jayenkai Mon 08:35 Nintendo Switch Indies rychan Mon 02:48 UWP Languages rskgames Sun 05:05 Switchmas rockford Sun 04:24 Happy Birthday, Mrs Rockford rockford Fri 05:30 Pokemon Go Jayenkai Fri 04:46 More

 Latest Items Snippet : Wall Tracing on Random Maps (rpg)Pakz Wed 18:56 Blog : mini projectJayenkai Tue 06:23 Snippet : Path FollowingPakz Mon 16:25 Dev-Diary : PS2 to N64 Adapterspinal Mon 01:53 Snippet : Flowers (Jan 2017)Kuron Thu 01:13 Showcase : Clusters of Hextherevillsgames Mon 15:01 Article : Maths 101 - Episode 1: Basic Trigonometryshroom_monk Sun 14:07 Article : Maths 101 - Episode 5: Line Intersectionshroom_monk Sun 14:02 Dev-Diary : Normals and Dot productsPakz Sat 20:37 Pets : Molly On The CouchJayenkai Thu 04:32 Showcase : Between SpacePakz Sun 12:55 Snippet : Additive Particle FlamesPakz Fri 18:12 Snippet : Maze 2d - Recursive BacktrackerPakz Sun 07:34 Snippet : Bush fire mapsPakz Wed 09:43 Woot : My MusicJayenkai Sat 14:20More

Who's Online
steve_ancell
Wed, at 20:27
rskgames
Wed, at 20:21
Pakz
Wed, at 19:43
Jayenkai
Wed, at 18:27