measure a mesh to aline it to a position

Started by
6 comments, last by ankhd 10 years, 1 month ago

Hi.

I'm trying to line up two box shape meshes. In perspective view it works fine even with mesh scaling,

but when I set a orthographic view the height of my mesh are smaller I've multiplied my meshes height value with the orthographic zoom value I use but its off by about 10 to 15 pixels on screen.

this is how I set up the ortho projection

float zoom = 1.8f;

D3DXMatrixOrthoOffCenterLH(&OrthograpicProjection, (-Width/2)/zoom, (Width/2)/zoom, (-Height/2)/zoom, (Height/2)/zoom, 0.0f,1000.0f);

and my height is like so

Height = GetMeshHeight(mesh) * 1.8;//it just goes through all verts and gets the largest y value

any Idea how or whats wrong. it works in perspective projection with the GetMeshHeight() function so it cant be that hey.

Advertisement

Your post is somewhat confusion... I'm not sure if I get it, but I will give it a try.

You use two different ways to render your mesh to the screen, perspective and orthographic, and compares the height measured in pixels of those two renders, right ? Now, you discovered, that the mesh is smaller/taller in perspective mode vs ortho and you try to compensate by zooming in. The zoom-level is caluclated by the (object-space) height of the mesh.

I've some issues with this approach. First, the rendered height of an mesh in perspective view depends on the depth of this mesh, even on the depth of each rendered vertex. Therefor the front surfaces will appear larger than the back surfaces. To measure the height I would take either a flat surface (eg a rect) or atleast a sphere. Second, you can't just take the mesh height (which is in object space) and compare it with something in camera space of a perspective camera. Though this will work for ortho. And eventually , what is the tolerance of 10 to 15 pixels ? Is it just 3% of the height or 200% ?

Well it comes down to this: If you don't have flat meshes, all on the same plane, orthogonal to the camera, then comparing perspective with orthografic rendered images is not really useful and I would be happy with a tolerance of a few pixel, just don't try to make it perfectly fitting.


I'm trying to line up two box shape meshes.

Ashaman implies it and maybe he guessed correctly - but what does "line up" mean? You mention a couple of times that "it" works fine in perspective projection, but a better technical explanation is needed for what "it" is. Help us to not have to guess.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

no no no. Im making a interface from the mesh there front view and Im was just saying the Get meshHeight returns the correct height when I use it in a perspective projection.

but for this Im only in ortho some thing like this

-------------------------------------------------

| |

-------------------------------------------- |

| _________________________|___|

| see it over lapps this much

--------------------------------------------

and I want the other one to be placed under this quad thats the line up I'm talking about

What is the "height" of a mesh? The AABB volume?

Mesh data comes from art tools, and artists who build them know where the key positions are that need to line up. I strongly suggest the data be embedded in the art resources themselves. Most artists are very comfortable with the process, dropping whatever kind of object you want such as a bone/joint or locator or some other kind of named marker.

The common modern model formats (such as collada) allow you to create many different kinds of named markers inside files. All it takes is a named object with a position and orientation. Think of one object having a slot and the other having a tab. An inverse transformation will let you position the second object's marker at the same position and orientation as the first object's marker.

Hi Frob.

I normaly do put in bones for things like this for my skinned meshes but this is just frames just some mesh containers that make up my interface.

my other menus I just pass in a offset found by trial and error to find the offset needed, this time I thought I would get smart and make it automatic so much for smart hehe.

I'll try changing the z value of the interface and see if I can get the right height.

Is this what you're trying to do?

box%20align.png

If so, are you trying to do that by moving the meshes, or by changing the view?

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

Opps Sorry everyone I did 11 hours of programming and it ends up it was just me the height is in fact the depth hehe.

so in fact it does get the correct height(depth)

here it is, its a list box that can hold dialogboxes for players who join the game

I think I will change the text I dont like the text the red quad is just a image frame with no image its for the players avatar.

Thanks all, I should take some breaks but time is a factor I have so much work to do.

PlayerSlots.jpg?psid=1

This topic is closed to new replies.

Advertisement