mirror of
https://github.com/brl/mutter.git
synced 2024-11-29 19:40:43 -05:00
use ClutterVertex to pass parameters into clutter_actor_apply_transform_to_point()
This commit is contained in:
parent
741382567a
commit
b9e486f587
@ -1,3 +1,11 @@
|
||||
2007-07-02 Tomas Frydrych <tf@openedhand.com>
|
||||
|
||||
* clutter/clutter-actor.h:
|
||||
* clutter/clutter-actor.c:
|
||||
* tests/test-project.c:
|
||||
(clutter_actor_apply_transform_to_point):
|
||||
Use ClutterVertex for input and output parameters.
|
||||
|
||||
2007-07-01 Emmanuele Bassi <ebassi@openedhand.com>
|
||||
|
||||
Merge from clutter.git/work branch
|
||||
|
@ -383,26 +383,18 @@ clutter_actor_transform_point (ClutterActor *actor,
|
||||
/**
|
||||
* clutter_actor_apply_transform_to_point:
|
||||
* @self: A #ClutterActor
|
||||
* @x: x coordinance of the point to project
|
||||
* @y: y coordinance of the point to project
|
||||
* @z: z coordinance of the point to project
|
||||
* @x2: projected x coordinance
|
||||
* @y2: projected y coordinance
|
||||
* @z2: projected z coordinance
|
||||
* @point: A point as #ClutterVertex
|
||||
* @vertex: The translated #ClutterVertex
|
||||
*
|
||||
* Transforms point (x, y, z) in coordinates relative to the actor
|
||||
* into screen coordiances (x2, y2, z2)
|
||||
* Transforms point in coordinates relative to the actor
|
||||
* into screen coordiances
|
||||
*
|
||||
* Since: 0.4
|
||||
**/
|
||||
void
|
||||
clutter_actor_apply_transform_to_point (ClutterActor *self,
|
||||
ClutterUnit x,
|
||||
ClutterUnit y,
|
||||
ClutterUnit z,
|
||||
ClutterUnit *x2,
|
||||
ClutterUnit *y2,
|
||||
ClutterUnit *z2)
|
||||
ClutterVertex *point,
|
||||
ClutterVertex *vertex)
|
||||
{
|
||||
ClutterFixed mtx_p[16];
|
||||
ClutterFixed v[4];
|
||||
@ -411,18 +403,18 @@ clutter_actor_apply_transform_to_point (ClutterActor *self,
|
||||
g_return_if_fail (CLUTTER_IS_ACTOR (self));
|
||||
|
||||
/* First we tranform the point using the OpenGL modelview matrix */
|
||||
clutter_actor_transform_point (self, &x, &y, &z, &w);
|
||||
clutter_actor_transform_point (self, &point->x, &point->y, &point->z, &w);
|
||||
|
||||
cogl_get_projection_matrix (mtx_p);
|
||||
cogl_get_viewport (v);
|
||||
|
||||
/* Now, transform it again with the projection matrix */
|
||||
mtx_transform (mtx_p, &x, &y, &z, &w);
|
||||
mtx_transform (mtx_p, &point->x, &point->y, &point->z, &w);
|
||||
|
||||
/* Finaly translate from OpenGL coords to window coords */
|
||||
*x2 = MTX_GL_SCALE_X(x,w,v[2],v[0]);
|
||||
*y2 = MTX_GL_SCALE_Y(y,w,v[3],v[1]);
|
||||
*z2 = MTX_GL_SCALE_Z(z,w,v[2],v[0]);
|
||||
vertex->x = MTX_GL_SCALE_X(point->x,w,v[2],v[0]);
|
||||
vertex->y = MTX_GL_SCALE_Y(point->y,w,v[3],v[1]);
|
||||
vertex->z = MTX_GL_SCALE_Z(point->z,w,v[2],v[0]);
|
||||
}
|
||||
|
||||
/* Recursively tranform supplied vertices with the tranform for the current
|
||||
@ -1434,10 +1426,14 @@ clutter_actor_get_abs_position_units (ClutterActor *self,
|
||||
gint32 *x,
|
||||
gint32 *y)
|
||||
{
|
||||
ClutterUnit zu;
|
||||
ClutterVertex v1;
|
||||
ClutterVertex v2;
|
||||
|
||||
*x = *y = 0;
|
||||
clutter_actor_apply_transform_to_point (self, 0, 0, 0, x, y, &zu);
|
||||
v1.x = v1.y = v1.z = 0;
|
||||
clutter_actor_apply_transform_to_point (self, &v1, &v2);
|
||||
|
||||
*x = v2.x;
|
||||
*y = v2.y;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -345,12 +345,8 @@ void clutter_actor_get_vertices (ClutterActor
|
||||
ClutterVertex verts[4]);
|
||||
|
||||
void clutter_actor_apply_transform_to_point (ClutterActor *actor,
|
||||
ClutterUnit x,
|
||||
ClutterUnit y,
|
||||
ClutterUnit z,
|
||||
ClutterUnit *x2,
|
||||
ClutterUnit *y2,
|
||||
ClutterUnit *z2);
|
||||
ClutterVertex *point,
|
||||
ClutterVertex *vertex);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -10,7 +10,7 @@ init_handles ()
|
||||
{
|
||||
gint i;
|
||||
ClutterVertex v[4];
|
||||
ClutterFixed xp, yp, zp;
|
||||
ClutterVertex v1, v2;
|
||||
ClutterColor blue = { 0, 0, 0xff, 0xff };
|
||||
|
||||
clutter_actor_get_vertices (rect, v);
|
||||
@ -32,19 +32,19 @@ init_handles ()
|
||||
clutter_actor_show (p[i]);
|
||||
}
|
||||
|
||||
xp = CLUTTER_INT_TO_FIXED (clutter_actor_get_width (rect)/2);
|
||||
yp = CLUTTER_INT_TO_FIXED (clutter_actor_get_height (rect)/2);
|
||||
zp = 0;
|
||||
v1.x = CLUTTER_INT_TO_FIXED (clutter_actor_get_width (rect)/2);
|
||||
v1.y = CLUTTER_INT_TO_FIXED (clutter_actor_get_height (rect)/2);
|
||||
v1.z = 0;
|
||||
|
||||
clutter_actor_apply_transform_to_point (rect, xp, yp, zp, &xp, &yp, &zp);
|
||||
clutter_actor_apply_transform_to_point (rect, &v1, &v2);
|
||||
p[4] = clutter_rectangle_new_with_color (&blue);
|
||||
clutter_actor_set_size (p[4], 5, 5);
|
||||
clutter_actor_set_position (p[4], 0, 0);
|
||||
clutter_group_add (CLUTTER_GROUP(stage), p[4]);
|
||||
clutter_actor_set_position (p[4],
|
||||
CLUTTER_FIXED_INT (xp) -
|
||||
CLUTTER_FIXED_INT (v2.x) -
|
||||
clutter_actor_get_width (p[4])/2,
|
||||
CLUTTER_FIXED_INT (yp) -
|
||||
CLUTTER_FIXED_INT (v2.y) -
|
||||
clutter_actor_get_height (p[4])/2);
|
||||
|
||||
clutter_actor_raise_top (p[4]);
|
||||
@ -57,7 +57,7 @@ place_handles ()
|
||||
{
|
||||
gint i;
|
||||
ClutterVertex v[4];
|
||||
ClutterFixed xp, yp, zp;
|
||||
ClutterVertex v1, v2;
|
||||
ClutterColor blue = { 0, 0, 0xff, 0xff };
|
||||
|
||||
clutter_actor_get_vertices (rect, v);
|
||||
@ -70,15 +70,15 @@ place_handles ()
|
||||
clutter_actor_get_height (p[i])/2);
|
||||
}
|
||||
|
||||
xp = CLUTTER_INT_TO_FIXED (clutter_actor_get_width (rect)/2);
|
||||
yp = CLUTTER_INT_TO_FIXED (clutter_actor_get_height (rect)/2);
|
||||
zp = 0;
|
||||
v1.x = CLUTTER_INT_TO_FIXED (clutter_actor_get_width (rect)/2);
|
||||
v1.y = CLUTTER_INT_TO_FIXED (clutter_actor_get_height (rect)/2);
|
||||
v1.z = 0;
|
||||
|
||||
clutter_actor_apply_transform_to_point (rect, xp, yp, zp, &xp, &yp, &zp);
|
||||
clutter_actor_apply_transform_to_point (rect, &v1, &v2);
|
||||
clutter_actor_set_position (p[4],
|
||||
CLUTTER_FIXED_INT (xp) -
|
||||
CLUTTER_FIXED_INT (v2.x) -
|
||||
clutter_actor_get_width (p[4])/2,
|
||||
CLUTTER_FIXED_INT (yp) -
|
||||
CLUTTER_FIXED_INT (v2.y) -
|
||||
clutter_actor_get_height (p[4])/2);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user