Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualKryzon

Posted 23 June 2013 - 06:49 PM

What you're asking depends on how you created the mesh, and how it's positioned relative to its "pivot point" (or transformation matrix, in other words).

 

Steps:

1) Create a blank mesh object with an identity pivot point. This pivot point being identity means it's located at the world's origin and has zero orientation.

 

2) Measure the distance between the two 3D points and consider this as the length of the quad. The height of the quad is some predefined value.

Build the quad with absolute world coordinates and centered on the world's origin (so this mesh is actually centered on its own pivot point, which is also at the worlds origin). 

Make sure the length of the quad goes along the world's Z axis.

Make sure the visible face of the quad points along the world's Y axis.

This mesh is aligned to the world, it's not facing the camera yet.

 

3) Build a rotation matrix from vectors A and B.

Vector A is the 'vector going from point 1 to point 2' (considered as Z).

Vector B is the resulting vector from 'crossProduct( A, World_Y_Axis )' (considered as X). 

With these two vectors A and B you can find an orientation matrix O.

 

4) Find the location at 'the middle point between point 1 and point 2' (it's just the average of their coordinates). This finds a location vector L.

 

5) Transform the quad's matrix by orientation O and location L. This positions and orients the quad just like you want it to be, except it's not facing the camera yet.

 

6) Transform the quad's matrix Roll (Z) value by the way previously described in post #12. This way the rectangle faces the camera.


#2Kryzon

Posted 23 June 2013 - 06:48 PM

What you're asking depends on how you created the mesh, and how it's positioned relative to its "pivot point" (or transformation matrix, in other words).

 

Steps:

1) Create a blank mesh object with an identity pivot point. This pivot point being identity means it's located at the world's origin and has zero orientation.

 

2) Measure the distance between the two 3D points and consider this as the length of the quad. The height of the quad is some predefined value.

Build the quad with absolute world coordinates and centered on the world's origin (so this mesh is actually centered on its own pivot point, which is also at the worlds origin). 

Make sure the length of the quad goes along the world's Z axis.

Make sure the visible face of the quad points along the world's Y axis.

This mesh is aligned to the world, it's not facing the camera yet.

 

3) Build a rotation matrix from vectors A and B.

Vector A is the 'vector going from point 1 to point 2' (considered as Z).

Vector B is the resulting vector from 'crossProduct( A, World_Y_Axis )' (considered as X). 

With these two vectors A and B you can find an orientation matrix O.

 

4) Find the location at 'the middle point between point 1 and point 2' (it's just the average of their coordinates). This finds a location vector L.

 

5) Transform the quad's matrix by orientation O and location L.

 

6) Transform the quad's matrix Roll (Z) value by the way previously described in post #12. This way the rectangle faces the camera.


#1Kryzon

Posted 23 June 2013 - 06:47 PM

What you're asking depends on how you created the mesh, and how it's positioned relative to its "pivot point" (or transformation matrix, in other words).

 

Steps:

1) Create a blank mesh object with an identity pivot point. This pivot point being identity means it's located at the world's origin and has zero orientation.

 

2) Measure the distance between the two 3D points and consider this as the length of the quad. The height of the quad is some predefined value.

Build the quad with absolute world coordinates and centered on the world's origin (so this mesh is actually centered on its own pivot point, which is also at the worlds origin). 

Make sure the length of the quad is aligned to the world's Z axis.

Make sure the visible face of the quad is aligned to the world's Y axis.

This mesh is aligned to the world, it's not facing the camera yet.

 

3) Build a rotation matrix from vectors A and B.

Vector A is the 'vector going from point 1 to point 2' (considered as Z).

Vector B is the resulting vector from 'crossProduct( A, World_Y_Axis )' (considered as X). 

With these two vectors A and B you can find an orientation matrix O.

 

4) Find the location at 'the middle point between point 1 and point 2' (it's just the average of their coordinates). This finds a location vector L.

 

5) Transform the quad's matrix by orientation O and location L.

 

6) Transform the quad's matrix Roll (Z) value by the way previously described in post #12. This way the rectangle faces the camera.


PARTNERS