Public Group

# measure a mesh to aline it to a position

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

## Recommended Posts

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.

##### Share on other sites

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.

##### Share on other sites

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.

##### Share on other sites

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

##### Share on other sites

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.

##### Share on other sites

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.

##### Share on other sites

Is this what you're trying to do?

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

##### Share on other sites

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.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 11
• 9
• 9
• 40
• ### Forum Statistics

• Total Topics
634130
• Total Posts
3015705
×