Sign in to follow this  

Viewspace unit

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Maybe I need to explain a little better. I use the direct3d sample framework. When I run the empty_project sample the screen is less than 10 units wide I think (I don't rembember, because it isn't important). How can I change the size of it, making it 100 units wide? I know I can zoom out the camera to make it wider, but thats not what I want. I have a mesh which is 10 units wide and I want to make room for 10 of these on the screen at the same time. I think the question I'm asking is how to define what a unit is? Meter, centimeter, millimeter, inch ... Maybe settings the size of the backbuffer is the answer to this, but I don't understand how. Can you explain?

Share this post


Link to post
Share on other sites
1 unit is always 1 unit. You can move the camera back to fit more on the screen, or you can position your objects further into the screen.
If you have 10 objects that are 10 units wide, you need to move the camera back to see them all. The only other way would be to use a larger FOV for the projection matrix, but that'll cause distortion.

If you can only fit 50m wide on to a view with a camera in real life. The only way around that is to use a fisheye lens (change FOV) or move the camera back to fit more onscreen. Changing what 1 unit represents won't help. If you can only fit 50cm onscreen, and each object is 10cm wide, it still doesn't help.

I'm useless at explaining things [smile]

Share this post


Link to post
Share on other sites
I think I understand. Thank you. The model I'm loading is about 50x50x50 cm in the 3d modeling program, but when I load it into direct3d it's about 10 units wide. 1 unit is then 5 cm. Can I change this. I want my model to be 1 unit wide. I know I can scale it when rendering it, but is this the only way?

Share this post


Link to post
Share on other sites
Quote:
Original post by KalleKlovn
I think I understand. Thank you. The model I'm loading is about 50x50x50 cm in the 3d modeling program, but when I load it into direct3d it's about 10 units wide. 1 unit is then 5 cm. Can I change this. I want my model to be 1 unit wide. I know I can scale it when rendering it, but is this the only way?
You'd have to either scale it when you render it, or scale it just after loading (change the position of all the vertices), yes.

Share this post


Link to post
Share on other sites
Thank you:) Scale it just after loading it seems like a good idea? How can I do that? I know how to scale it before rendering, but how can i scale it after loading it. It seems like a good idea to scale it once, instead of fore every frame. Sorry for wasting your time with stupid questions.. It helps me a lot:)

Share this post


Link to post
Share on other sites
I'm not too sure about the details of ID3DXMesh (Which I presume is what you're using), but you need to lock the vertex buffer, divide each of the X, Y and Z components of the vertex by 10, then unlock the vertex buffer.

EDIT: Something like (untested):

struct Vertex
{
float x, y z;
};

BYTE* pVertex;
DWORD dwVerts = pMesh->GetNumVertices();
DWORD dwStride = D3DXGetFVFVertexSize(pMesh->GetFVF());

pMesh->LockVertexBuffer(D3DLOCK_READONLY,&pVertex);
for(DWORD i=0; i<dwVerts; ++i)
{
Vertex* pVert = (Vertex*)pVertex;
pVert->x /= 10.0f;
pVert->y /= 10.0f;
pVert->z /= 10.0f;
pVertex += dwStride;
}
pMesh->UnlockVertexBuffer();

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this