Jump to content

  • Log In with Google      Sign In   
  • Create Account


pilarsor

Member Since 31 Jul 2003
Offline Last Active Apr 02 2012 02:14 PM

Posts I've Made

In Topic: the plane and axes.

30 March 2012 - 09:15 AM

Thanks for the illustrations.

First, if you want to compute a rotation matrix, that rotates points around the center of profile inside that plane, I would suggest, that you create a quaternion from an
axis, angle representation.
The axis of rotation you already have defined by your plane's normal vector.
The angle you can compute like the following ( using 3D coordinates ):

vec3 v0 = RotPlane - centerOfProfile;
vec3 v1 = RotPlane' - centerOfProfile;
v0.normalize();
v1.normalize();
float angle = acosf( dotProd<v0,v1> ); ( = acosf( v0.x*v0.x + v1.x*v1.x ) )

Now, generate your quaternion q by: ( axis needs to be normalized )

q.x = axis.x * sinf( angle / 2 );
q.y = axis.y * sinf( angle / 2 );
q.z = axis.z * sinf( angle / 2 );
q.w = cosf( angle / 2 )

If you want a matrix representation from q, just use a standard method for converting from normalized quaternion to a rotation matrix.


Btw... if you just want the angle to apply in one of your predefined axis aligned planes xy,xz or yz, just leave out the whole quaterion step.
Here you can just generate a standard 2d rotation matrix using sin and cos from that angle.

In Topic: the plane and axes.

30 March 2012 - 04:14 AM

Actually, you need to plugin position vectors to x,y,z in the same coordinate system your plane is defined, not directional vectors as you did with (0,0,1) and (0,1,0).

But I'm not sure what you're actually looking for... maybe you can clarify a bit more, what information you actually have given, and what you need to calculate.

Thanks.

In Topic: 2D Coordinates from 3D View and Projection Matricies

28 March 2012 - 03:00 PM

Keep in mind, that your matrix M transforms each point into homogeneous clip space HCS, ranging from
x=-w..w, y=-w..w, z=-w..w,w=z, so you might want to devide each projected coordinate additionally by w, to get
your screen values in range x=-1..1,y=-1..1,z=-1..1, the normalized device coords ( NDC ).

So:

M*w = c (in HCS)
s = c / c.w ( divide by homogeneous coordinate c.w )


To get back into world space, store your c.w per fragment/pixel/screen coord.

For each screen coord:
c = s * c.w
w = M^-1 * c

In Topic: the plane and axes.

28 March 2012 - 01:56 PM

You calculate a,b,c,d and substitute x,y,z with the values you want to check.

In Topic: Creating a hud/gui with GLSL

23 March 2012 - 04:33 PM

Dynamic text is something, that you might want to prepare in your c++ code.
Take a texture containing the letters of the alphabet, each letter in the texture equally spaced in width and height.
Write a C++ module, that inputs a string and you basically convert each character in the string to an u,v offset in the 2D alphabet texture.
For rendering this text as textured quads for example, you can just use a standard vertex and fragment shader, which has the functionality of a vertex/fragment shader pendant of a fixed function pipeline.

But sure, if you like, go ahead and do something fancy with that text, e.g. like displacing the quad vertices, distorting the uv coords, or applying some function for color generation...

PARTNERS