<cite>@KonradZuse said:</cite>
That's cool, but not really what I need for this issue anyways :).
Again, I am given a 2D representation of data. It’s as if you were using Java Swing and creating data using x and y values only, which uses a upper-left coordinate system.
I am taking this data, and making it 3D.
I have the 3D items all placed, the only problem is that they are not placed in the correct places.
I am attributing this to the fact Open GL uses a Centered, Right-Handed Coordinate System, whereas 2D does not. I need to use the correct coordinate system, or find a way to convert it.
So again if I am using upper left @ point (0,0) and I have a box 5x5 it will be @ 5,5.
If I use Jmonkey it is centered and I get @ (0,0,0) a box that is5x5x5 will be @ X(5+ 5- )Y(5+ 5-) Z(5+ 5-) according to the tutorial which says that a 5x5x5 will be 10x10x10 “world units”
The size itself seems to be, but the item placements are what matters. I most likely will have to half the size.
This is going to be a importer, so I am going to be grabbing a ton of 2D data, and converting it to 3D, so this is very important.
If people want pictures then I will post them, I believe I am explaining this simply.
Ah alright, that makes it alot clearer
The sizes for the box basically mean x amount in each direction for that axis, so 5x5x5 will indeed result in a 10x10x10 cube, so you probably will have to compensate for that.
It would be nice to have some pictures or something to get a better insight in what you have to do, although as of now the following solutions seems possible to me:
Take a point to start from, substract the values you receive from that.
E.g.
[java]Vector3f startPoint = new Vector3f(0f, 10f, 0f);
//Then for all the data you can do something like:
for(Vector2f point: data) {
Vector3f point3D = new Vector3f(point.getX(), point.getY(), 0f);
Box b = new Box(startPoint.substract(point3D );
//add box to scene etc…
}[/java]
Edit
Oh wait, just realised you only need to substract from the Y value, so basically :
[java]
float startY = 0f;
//Then for all the data you can do something like:
for(Vector2f point: data) {
Vector3f location = new Vector3f(data.getX(), startY - data.getY(), 0f);
Box b = new Box(location, xSize / 2, ySize/2, zSize/2);
//add box to scene etc…
}[/java]
EDIT:
After seeing the pictures you just posted I realise what is wrong.
You are halving the sizes, but you also gotta realise it still has an offset.
Meaning, a box at origin, with 1, 1, 1 size, results in 2x2x2 cube, from -1 to 1 for each axis.
When you half the size, the location of the object is -0.5, to 0.5, meaning you still have to move it 0.5 to place it at the correct spot.
So, my example was wrong too, you have to do this I guess:
[java]
float startY = 0f;
//Then for all the data you can do something like:
for(Vector2f point: data) {
Vector3f location = new Vector3f(data.getX() + xSize / 2f, startY - (data.getY() + ySize / 2f), 0f);
Box b = new Box(location, xSize / 2f, ySize/2f, zSize/2f);
//add box to scene etc…
}[/java]