Jump to content

  • Log In with Google      Sign In   
  • Create Account

measure a mesh to aline it to a position


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
7 replies to this topic

#1 ankhd   Members   -  Reputation: 1282

Like
0Likes
Like

Posted 13 March 2014 - 06:49 AM

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.



Sponsor:

#2 Ashaman73   Crossbones+   -  Reputation: 7471

Like
1Likes
Like

Posted 13 March 2014 - 08:14 AM

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.



#3 Buckeye   Crossbones+   -  Reputation: 4918

Like
1Likes
Like

Posted 13 March 2014 - 11:25 AM


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.


#4 ankhd   Members   -  Reputation: 1282

Like
0Likes
Like

Posted 13 March 2014 - 04:55 PM

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



#5 frob   Moderators   -  Reputation: 21293

Like
1Likes
Like

Posted 13 March 2014 - 05:33 PM

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.

 

 


Check out my personal indie blog at bryanwagstaff.com.

#6 ankhd   Members   -  Reputation: 1282

Like
0Likes
Like

Posted 13 March 2014 - 06:10 PM

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.



#7 Buckeye   Crossbones+   -  Reputation: 4918

Like
1Likes
Like

Posted 13 March 2014 - 06:16 PM

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.


#8 ankhd   Members   -  Reputation: 1282

Like
0Likes
Like

Posted 13 March 2014 - 06:37 PM

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






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS