Question about 3D
-
OK, so it might surprise some to see me asking for help. "He's a member of team Fuze, doesn't he know all there is to know about Fuze?" you may ask. Well, that's a fair question, and the answer is absolutely not! Fuze is huge in scope of what you can do with it and so it's not at all uncommon for people to spend their entire time within their own comfort zones, and I'm no exception. If you want to know about sprites and 2D in particular then fine, I'm your man (one of them).
To date, I've not so much as touched 3D. My interests are very much with retro games so I've just not felt the urge. Therefore, queue (probably) pretty stupid question time...
Flicking through the in-Fuze tutorials on 3D we quickly learn that co-ordinates in 3D space are defined in "metres". OK. Odd, but OK, I'll take that. But, but, but...
My screen is 1280x720 pixels high. If I want to position something at, let's not say the centre because I know that would be 0, so let's say half way across the upper right quadrant. How do I convert 960,180 - the 2D co-ordinates, into metres??
Why would I ask this? Because 2D is just 3D where everything is positioned with it's front face on the Z axis and the camera facing it straight on, is it not? Therefore, as far as I'm concerned I should be able to take my 2D code and with a bit of conversion and camera / light positioning display it in a 3D world should I not? Such that the camera position means that 0,0 is in the bottom left which doesn't exactly mimic 2D co-ordinates, but it's X,-Y,0 isn't it?
Someone please explain to me why a) this isn't the case or b) it is the case and I'm missing some trick somewhere.
PS: I'm aware that to people who know 3D and do it all the time, asking this probably doesn't make any sense and it's probably just not the way it is. So help me understand. I know I won't be alone here.
-
@Martin said in Question about 3D:
Flicking through the in-Fuze tutorials on 3D we quickly learn that co-ordinates in 3D space are defined in "metres". OK. Odd, but OK, I'll take that. But, but, but...
My screen is 1280x720 pixels high. If I want to position something at, let's not say the centre because I know that would be 0, so let's say half way across the upper right quadrant. How do I convert 960,180 - the 2D co-ordinates, into metres??
Someone please explain to me why a) this isn't the case or b) it is the case and I'm missing some trick somewhere.
This is actually a very good question. The answer is that it depends on how far away the objects are from the camera. Farther away objects look smaller than closer objects.
At least that is how it works in a 'perspective projection', which most modern 3D systems use. I do a lot of my work in a parallel or orthographic projection where distance doesn't affect the size and there is always a 1 to 1 correspondence between screen pixels and distances in the world.
In Fuze3D the volume of space that you can see from the camera point is a pyramid with the top missing called the 'viewing frustum'
The camera is at the top of the pyramid and in front of the camera is the 'near clip plane'. The near clip plane represents the screen. The screen (or near clip plane) is like a boundary portal between the real world and the virtual world, its the only thing that we can really think of as existing in both.We know how wide the screen is in 'pixels'. How wide is it in the units Fuze3D uses '3D world meters'? - This is the question I think you are asking Martin.
I actually don't know the answer at the moment. It depends on the parameters of the view transformation Fuze3D uses, such as the 'field of view angle' (fov) which determines how steep the sides of the view frustum pyramid are.
-
Thank you @Gothon !
So in theory then, if the camera were moved far enough out then we could draw a rectangle that is 1280x720, with the centre point being 0,0 in the 3d world, and at some point you would indeed have a 1:1 relationship. And at that point, I guess we have our scale factor. But then the problem is that you've gone out so far (probably) that your objects are tiny so need to be scaled.
So I think that makes sense. It just strikes me that there must be a known camera distance that results in a 1:1 2D->3D mapping.
-
Draw a flattened (in z) cube of the desired dimensioms at 0,0,0 and dolly the camera in or out till it perfectly fills the screen.
You might want to think about simply matching the aspect ratio as opposed to the exact dimensions. -
I might be able to help more if I knew what you were aiming for here.
-
I'm not specifically, I'm more trying to understand the way the co-ordinate system works in 3d when my only experience is in 2d.
For a little context, I was part way through a 2d game when I discovered that there were no suitable 2d assets in Fuze, all of the suitable ones were 3d. In my mind given 2d is, in very simple terms 3d with no Z, I figured I'd load the 3d object. Rotate it so the angle I wanted was facing the camera (which I managed) and then just use it in my 2d world by just specifying { x, y, 0 }. And that is when I read the fact that 1 in 3d is 1 metre. Which kind of blew my mind and led to the question above.
I also of course then discovered that if I set my object along the path I had calculated in 2d space, even ignoring the difference in origin and co-ordinate direction, it immediately shot off the screen due to the difference between 1 pixel and 1 metre.
-
You can dismiss that 1 metre thing. One unit is one unit. The various objects in the assets library are all to different scales.
One way to get a 3d object into a 2d scene is to load it up, create an image and use drawobjects() to draw the object to the image then use the image as a normal sprite image. -
It’s not simple to put 3d on top of 2d, as the entire screen is drawn including the background (There’s no need to do clear() in 3d.). It can be done, just with a few extra steps involved.
I don’t know how normal that is. I’d never done anything with 3d until recently either...