last day (14 days later) » 

3:17 AM
0
Q: 2D isometric engine - Math problems - Cube selection - diamond shape map

MadzI calculate my coordinates when i create a layer with a std::vector, filled with cube objects(wich is a class of mine): for(int J = 0; J < mapSize; J++) { for(int I = 0; I < mapSize; I++) { x = (J - I) * (cubeSize/2); y = (J + I) * (cubeSize/4); c = new cube(cube...

 
I have my cursor coordinates(x,y), and i want to convert them in isometric coordinates(something like 0, 1 for example) if my click is on the map. Then, i want to convert (I,J) in the numero of my cube in the std::vector<cubes> (named cs here) Sorry for broken english, it was hard for me to explain all of this. I tried your calculs, it didn't work, i don't get isometric coordinates.
I don't use tiles, but 4 points of vertex for the 6 sides of my cubes.
I don't want to reverse the equation, i want to calculate for an x and y, in wich cube they are(the I-J coordinates)
When i display my cubes or i do getY() -> y - (z * (cubeSize/2)). Thanks for free downvote. I spent days on this problem... and the whole day to clarify my post. Sorry to no be english fluent....
It's same as a classic 2D isometric tile system. It's the start of the bouding box. (sorry if i'm not clear >_<). Then, i use the classic isometric formula to rotate all of this and calculate each points. So there is no I,J for the points.
I edited the whole post, i think i have now more clear ideas about what i want. I deleted all not needed informations.
 
So the question basically is “how to write a ray caster”? Such questions are a bit broad, and are generally considered off-topic for StackOverflow
 
A ray what ??? I'm sorry, i don't know why i'm off-topic. I just want to select a cube with a left click, and for that i need formulas wich i can't find by myself.
I took a look on wikipedia, it's like it's a 3D technique, i'm using 2D here. I just fake the 3D using vertex, but it's still 2D.
 
@Madz Depends. If a few cubes overlap, do you want to get the cube which is “on top” of the others?
 
@roeland I'll do something like this with all those formulas : maps[currentMapID].layers()[currentLayerID].cubes()[getCubeByID(cursorX, cursorY)].setTexture(numTexture); currentLayerID will always be the layer at the top of all layers.
 
3:17 AM
So (1) you're absolutely sure that no 2 cubes in a layer will overlap in image space? Think about that for a while, what if you click in an area where 2 cubes overlap. And (2) just implement a simple for loop. There is no magic formula.
 
I'm sure, the formula to calcul coordinates give me the coordinates for the upper side of my cube, the upper sides don't overlap beetween each others. (I just fake 3D with vertex, but i still use 2D method). I'm sure if i got those 3 formulas it will work perfectly. PS: I can get the coordinates of the side of my cube i want.
Really the downvote ? I'm having hard time to find answers, and i'm on this problem for days..... Thanks a lot. (apologize in case it's not you.)
 
Did someone missclick ?
 
No, probably someone who had hard time to understand my broken english (^^)
And i probably know who since i'm spammed with off-topic comments :/
 
hey-ho.
 
?
Sorry, i don't understand why you said "hey-ho" ? I wasn't talking about you when i said "off-topic comments".
 

last day (14 days later) »