# The scale of a 3D world?

This topic is 4904 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

How do I figure this out? I need to scale 3D objects to fit in a scene as they were 2D. The usage is for a Galacian clone I've been trying to build for some time. The scaling problem is one thing that is holding me back in my design and implementation. I need all the objeccts scaled to fit in the screen as if they were 2D sprites. But they will all be 3D models excluding particles and the like. If I position them at a certain depth, I can get them scaled that way with out the math. But I don't know how to compute such as thing. What do I position them by? I can't figure this out. If objects exists in a 3D world, they wshould be scaled to that world. Is there a better formula for finding a solution other then hit & miss by guessing where they look best at?

##### Share on other sites
If your field of view is 90 degrees, just position them with a z value of -1. Then, an x value of -1 corresponds to the left side of your screen, and an x of 1 corresponds to the right.

Similarly, a y value of -1 corresponds to the top of your screen, and a y of 1 corresponds to the bottom.

Mike C.
http://www.coolgroups.com/

##### Share on other sites
If you're asking what I think you're asking, you want orthographic projection. When you're using an orthographic projection matrix, stuff that is farther away doesn't get any smaller, so everything that is 5 units long will be the same size anywhere on the screen. You can still use a depth coordinate to help sort things in the right order (for example, so bullets pass in front of the background), but it won't have any other effects on the image displayed. You should be able to find information about orthographic projection on google

If not, then you'll need to rephrase the question.

##### Share on other sites
I'm wondering on how to scale things in a 3D world so the objecs are the corrent size. I used the 2D example above to help explain. I though I explained things pretty good, guess not.

Ortho will not work because I want the perspective. I only need to figure out how to scale and position the models in spacec so that they all fit on screen.

Think of an old 2D space shooter game. My application is similar, but instead of sprites I'm using 3D models. I'm having problems figuring how to scale the world, or objects to the world for my application.

Like, how deep should I position them or how much should I scale them...

##### Share on other sites
create one model and get it loaded into the game. If its to big/small either scale the object with the appropiate API function (theres probably a glScale and a DX equivilent), or move the camera further away.

If you use the same import/export technique, you can base all your other models off the first model. For example, create a human and scale/set up the camera - if you want a building twice as tall as a human, just compare the building to the human model.

Or model all your stuff as if 1 unit in your 3d modelling software was 1 unit (foot / meter) in virtual space and then just scale/move the camera appropiatly.

##### Share on other sites
Right. if your model doesn't fit the screen than there is something wrong with the model and it should be adapted.

##### Share on other sites
Yes, I know how to scale. It's the measuring thing that I'm having problems with. I'm just wondering how to measure the models. I can't measure one model to another because their sizes and bounding boxes are different.

I'm having troubles figuring out how to scale / measure the models to the world. I have a guess what each object should be.

It's a Galaxian clone, except 3D models instead of 2D sprites. So the 3D models need to be scaled to fit in the scene correctly. I'm trying to see if there is a way to use the projection matrices or view frustum to scale the objects.

So the better question would be how to find the units/pixels are in the 3D world. That way I could maybe specify the scaling of a model using pixels. For example, a 32x32 pixel area would cover about 0.5 units depending on the depth.

It's the ratio between things is what I'm trying to figure out. Sort of like, backwards engineering the projection matrices or view frustum.

##### Share on other sites
Quote:
 Original post by sakkyI can't measure one model to another because their sizes and bounding boxes are different.

You need to decide yourself what a unit in your world corresponds to. In my apps one unit == 1 meter and all resources are modelled with that in mind. If you decide to do this you will never need to scale your models at all; they will "fit" if they´re inside the camera frustum.

##### Share on other sites
So you're saying model all the models to 32x32 units? I'm using Lightwave and the models are more like 6x4.5 units. See, what my problems is the measurement of everything in the 3D world. I need to get things correct in order for them to look right.

A unit should at least cover 2x2 square pixels but not more then 4x4. Something a long those lines. Each objects will be positioned at a certain depth. They will all use the same depth, it's just a matter of figuring out how they scale in the view. The view frustum isn't a perfect cube and I don't want to use Ortho because the lack of perspective.

The objects are lined up in rows and columns like a grid. So in order to fit all these objects onto the screen, they have to be scaled or modeled correctly. The model's center point is used to translate, scale and rotate them.

I just need to know how things are measured. A unit, can be many things and modeling software only specifies a few of them of which I have no clue on how to convert from Direct3D's measure units to theirs.

You say by using meters, they are about the same size a single unit. But what defines a unit? How do we know how big a unit actually is? There has got to be a spatial comparison to find the proper depth and scale of each model. Once I have this information, I'll just scale the models to size.

##### Share on other sites
Quote:
 Original post by sakkyA unit, can be many things and modeling software only specifies a few of them of which I have no clue on how to convert from Direct3D's measure units to theirs.[...]There has got to be a spatial comparison to find the proper depth and scale of each model. Once I have this information, I'll just scale the models to size.

The thing is, there is no such thing as a "Direct3D unit" - that´s what I was trying to explain. You decide how big/long/heavy a unit is. That´s why it is so easy to "convert" units from whatever modelling package you use. If you decide that one unit in your modelling app equals one meter or yard or what you meassure your units in, you just have to follow that rule in your own app.

Choose a unit length that is logical for your app. I wouldn´t choose nanometers if I made a CS-clone ;)

Quote:
 Original post by sakkySo the better question would be how to find the units/pixels are in the 3D world. That way I could maybe specify the scaling of a model using pixels. For example, a 32x32 pixel area would cover about 0.5 units depending on the depth.

Do you ever change the FOV of your camera or move/rotate it? If not, you can easily find the coordinates where the frustum intersects the plane your objects will be rendered at. Then calculate the rect from those intersections. If you move it you have to calculate the intersections again.

1. 1
2. 2
3. 3
Rutin
12
4. 4
5. 5

• 26
• 10
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633694
• Total Posts
3013381
×