Jump to content

Collision and Raycasting?


Andr3wHur5t
 Share

Recommended Posts

HI,

can someone tell me how they get what object collided with another?

Tools:

AC3D | 3D Canvas(pro) | Texture Maker(pro) | Genetica(basic) | 3D World Studio | Fragmotion |Leadwerks 2 | XNA 4 | Visual Studio 2010 Professional | XCode 5.x |UU3D Pro

 

Programing & Scripting Languages:

C |C++ | C# | Obj-C | LUA | Javascript | PHP | Ruby

Link to comment
Share on other sites

EntityCollisionCallback

C: void _stdcall EntityCollisionCallback( TEntity entity0, TEntity entity1, byte* position, byte* normal, byte* force, flt speed )

BlitzMax: EntityCollisionCallback(entity0:TEntity,entity1:TEntity,position:Byte Ptr,normal:Byte Ptr,force:Byte Ptr,speed:Float)

This will be called when entity0 collides with another entity. The first entity is always the one which the callback was specified for. Note that the function can have any name. See the examples page for more info.

[Examples]

http://www.leadwerks.com/wiki/index.php?title=Entities

Intel Corei7-6700, NVIDIA GeForce GTX 980, 32GB DDR4, W-10.

Link to comment
Share on other sites

alright, also could you tell me how to share the data between the collision callback and my main loop i have tried some of my methods without success. :)

 

 

thanks.

Tools:

AC3D | 3D Canvas(pro) | Texture Maker(pro) | Genetica(basic) | 3D World Studio | Fragmotion |Leadwerks 2 | XNA 4 | Visual Studio 2010 Professional | XCode 5.x |UU3D Pro

 

Programing & Scripting Languages:

C |C++ | C# | Obj-C | LUA | Javascript | PHP | Ruby

Link to comment
Share on other sites

I need to know what entity1 and entity0 are so I can compare them to see if one of them is a trigger body and the other is the environment or player inside my main loop.

 

also: when you say public variable you mean created outside of created main loop and callback then initialized in one of them?

Tools:

AC3D | 3D Canvas(pro) | Texture Maker(pro) | Genetica(basic) | 3D World Studio | Fragmotion |Leadwerks 2 | XNA 4 | Visual Studio 2010 Professional | XCode 5.x |UU3D Pro

 

Programing & Scripting Languages:

C |C++ | C# | Obj-C | LUA | Javascript | PHP | Ruby

Link to comment
Share on other sites

when you say public variable you mean created outside of created main loop and callback then initialized in one of them?

Exactly, the public variable will be visible to both so can be set by the callback and read by the main loop.

 

Conversely, you could encapsulate your main loop within a 'game' class and have it reference a member variable. The member variable could be set by a public member function in the class which is called from the callback passing the value as a parameter. In this case the pointer to the 'game' class would be a public variable ensuring it's scoped to the callback function.

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

Link to comment
Share on other sites

Also don't forget that you could set key and retrieve it in this way you don't need many public variable..

As for example:

You create 5 trigger trap, you set a key like this "Type of entity" = 1 (1 trap, 2 ai, 3 player, 4..) , when 2 entity collide you can get the key, also you could set other value to them as for example the "effect" you need to reproduce.

Intel Corei7-6700, NVIDIA GeForce GTX 980, 32GB DDR4, W-10.

Link to comment
Share on other sites

Pixel Perfect could you post an example for me of this?

Tools:

AC3D | 3D Canvas(pro) | Texture Maker(pro) | Genetica(basic) | 3D World Studio | Fragmotion |Leadwerks 2 | XNA 4 | Visual Studio 2010 Professional | XCode 5.x |UU3D Pro

 

Programing & Scripting Languages:

C |C++ | C# | Obj-C | LUA | Javascript | PHP | Ruby

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...