Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperLicht
Cant get Collision Detection to work

icereaper
Registered User
Quote
2011-02-08 16:21:51

Hello again, another day, another problem, but im getting into it :)
I have a SceneNode representating a world. It includes multiple meshes, so every mesh is a part of the world. I tried getting the MeshTriangleSelector to work, but till now without success. What i need is best described in 2 steps:

1. when i click with the left mouse button i want to know which model i clicked. whatever is in the middle of my view, i want the mesh object.
2. when that worked i want that i can click somewhere in the view and selecting from there, and not the middle of the screen.

Documentation says that a MeshTriangleSelector gets one mesh as a param... Does that mean for me i need to create one for every mesh i have(256)? or am i able to bind a selector to the whole scene node, so i can simply return the coordinates of the clicked polygon?

Thanks again for help :)


niko
Moderator
Quote
2011-02-09 07:09:27

A simple and fast test would be to test the bounding box of each model if it collides with the mouse. Use yourNode.getTransformedBoundingBox().intersectsWithLine(lineStart, lineEnd) for this. In most cases, this is all you need, but for polygon level collision detection, creating a MeshTriangleSelector is the way to go, yes.

About 2: You only need a 3d line to do the collision detection, use engine.get3DPositionFrom2DPosition(pixelPosX, pixelPosY) to get a point on that line. Calculating the line from the position of the camera to an end point which is far enough away from it, going through the point you get from get3DPositionFrom2DPosition is all you need.

Maybe I should create a new tutorial for this.


icereaper
Registered User
Quote
2011-02-09 10:31:29

That would be awesome :) i guess i'll spend this day on figuring out how to get it to work... the problem (for me) is that i never did 3d-stuff before.. well not that kind of.. building gamescripts yes, but complete camera / collision etc stuff not. so this forum/website is atm my only resource.


icereaper
Registered User
Quote
2011-02-13 12:50:50

After spending days to get it to work, i give up. i simply cant get it to work.. :(
I tried using the camera position and the position i get with get3DPositionFrom2DPosition ... a tutorial on how to get collision detection by clicking somewhere in the screen in a custom scene node with maybe multiple mesh support would be helpful.
Till that i have to pause my project


niko
Moderator
Quote
2011-02-13 16:58:26

Yes, you need a bit to dive into programming for this. The tutorial will need a bit still, but there are some threads in this forum also describing this.


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internation?l" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact