Coordinate system/ dynamically placing objects on the map

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Worteltaart
Posts: 17
Joined: Sat Mar 24, 2007 5:03 pm
Location: Holland

Coordinate system/ dynamically placing objects on the map

Post by Worteltaart »

Consider the following.

I'm loading an XML file containing some (static) world data, for example trees and rocks on certain places.

This produces tiles of which the world is composed (for ease think of a 2d map, so only x en y coordinates exist), so while running the application we see a world in which we can travel.

But, now I would want to add object to the world dynamically, like when i click a certain button and then click a certain spot on the map I want a mesh to be drawn on that position.

Ofcourse I would need to know the x and y coordinates of the point specified.

Here comes the question, what is a good why of getting the coordinates of the point clicked ON the map, should we come up with our own coordinate system, or how should we handle this?
Common sense is what tells you the world is flat.
LLDD
Posts: 43
Joined: Fri May 11, 2007 9:50 am

Post by LLDD »

If I understood it properly, you should do something like this:
1) Get a ray using getRayFromScreenCoordinates.
2) Make it collide with your level.
3) Place a new object on the collission coordinates.
________
Justin bieber
Last edited by LLDD on Sun Feb 20, 2011 7:48 am, edited 1 time in total.
Worteltaart
Posts: 17
Joined: Sat Mar 24, 2007 5:03 pm
Location: Holland

Post by Worteltaart »

Hmm ok, I have to look into that, not very familiar with collision yet.

And just 'asking' the current cursor location in the worldspace?
Common sense is what tells you the world is flat.
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

same thing. each pixel on your screen exists as a 3d line within your cameras fustrum. you can get this line using getRayFromScreenCoordinates like LLDD said, and use this to find a collision with your world (see the collision example)
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Post Reply