mirror of https://github.com/GNOME/gimp.git
plug-ins/libgck/gck/Makefile.am plug-ins/libgck/gck/gckcommon.h
2000-02-14 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/Makefile.am * plug-ins/libgck/gck/gckcommon.h * plug-ins/libgck/gck/gcklistbox.[ch] * plug-ins/libgck/gck/gckmath.[ch] * plug-ins/libgck/gck/gckvector.[ch]: removed. * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gcktypes.h: modified accordingly. * libgimp/Makefile.am * libgimp/gimpvector.[ch]: new files. Modified the vector functions from GCK. Changed the licence to LGPL, if there are any objections, please let me know. * libgimp/gimp.h: #include "gimpvector.h" * libgimp/gimpmath.h: added deg <-> rad conversion macros. * libgimp/gimpmatrix.[ch]: added a 4x4 vector to rotation angle function from GCK, s/GimpMatrix,gimp_matrix/GimpMatrix3,gimp_matrix3/ * plug-ins/Lighting/* * plug-ins/MapObject/*: s/GckVector,gck_vector/GimpVector,gimp_vector/ * app/pathsP.h * app/paths_dialog.c * app/perspective_tool.[ch] * app/rotate_tool.[ch] * app/scale_tool.[ch] * app/shear_tool.[ch] * app/tools_cmds.c * app/transform_core.[ch] * tools/pdbgen/pdb/tools.pdb: s/GimpMatrix,gimp_matrix/GimpMatrix3,gimp_matrix3/
This commit is contained in:
parent
f0432d8182
commit
260d7b2d1d
39
ChangeLog
39
ChangeLog
|
@ -1,3 +1,42 @@
|
|||
2000-02-14 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* plug-ins/libgck/gck/Makefile.am
|
||||
* plug-ins/libgck/gck/gckcommon.h
|
||||
* plug-ins/libgck/gck/gcklistbox.[ch]
|
||||
* plug-ins/libgck/gck/gckmath.[ch]
|
||||
* plug-ins/libgck/gck/gckvector.[ch]: removed.
|
||||
|
||||
* plug-ins/libgck/gck/gck.h
|
||||
* plug-ins/libgck/gck/gcktypes.h: modified accordingly.
|
||||
|
||||
* libgimp/Makefile.am
|
||||
* libgimp/gimpvector.[ch]: new files. Modified the vector
|
||||
functions from GCK. Changed the licence to LGPL, if there are any
|
||||
objections, please let me know.
|
||||
|
||||
* libgimp/gimp.h: #include "gimpvector.h"
|
||||
|
||||
* libgimp/gimpmath.h: added deg <-> rad conversion macros.
|
||||
|
||||
* libgimp/gimpmatrix.[ch]: added a 4x4 vector to rotation angle
|
||||
function from GCK,
|
||||
s/GimpMatrix,gimp_matrix/GimpMatrix3,gimp_matrix3/
|
||||
|
||||
* plug-ins/Lighting/*
|
||||
* plug-ins/MapObject/*:
|
||||
s/GckVector,gck_vector/GimpVector,gimp_vector/
|
||||
|
||||
* app/pathsP.h
|
||||
* app/paths_dialog.c
|
||||
* app/perspective_tool.[ch]
|
||||
* app/rotate_tool.[ch]
|
||||
* app/scale_tool.[ch]
|
||||
* app/shear_tool.[ch]
|
||||
* app/tools_cmds.c
|
||||
* app/transform_core.[ch]
|
||||
* tools/pdbgen/pdb/tools.pdb:
|
||||
s/GimpMatrix,gimp_matrix/GimpMatrix3,gimp_matrix3/
|
||||
|
||||
2000-02-14 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/preferences_dialog.c: purely cosmetic.
|
||||
|
|
|
@ -2672,9 +2672,9 @@ paths_transform_xy (GimpImage *gimage,
|
|||
}
|
||||
|
||||
void
|
||||
paths_transform_current_path (GimpImage *gimage,
|
||||
GimpMatrix transform,
|
||||
gboolean forpreview)
|
||||
paths_transform_current_path (GimpImage *gimage,
|
||||
GimpMatrix3 transform,
|
||||
gboolean forpreview)
|
||||
{
|
||||
PATHIMAGELISTP plp;
|
||||
PATHP p;
|
||||
|
@ -2715,10 +2715,10 @@ paths_transform_current_path (GimpImage *gimage,
|
|||
|
||||
/* printf("[x,y] = [%g,%g]\n",ppoint->x, ppoint->y); */
|
||||
|
||||
gimp_matrix_transform_point (transform,
|
||||
ppoint->x,
|
||||
ppoint->y,
|
||||
&newx,&newy);
|
||||
gimp_matrix3_transform_point (transform,
|
||||
ppoint->x,
|
||||
ppoint->y,
|
||||
&newx,&newy);
|
||||
|
||||
/* printf("->[x,y] = [%g,%g]\n", newx, newy); */
|
||||
|
||||
|
@ -2754,9 +2754,9 @@ paths_transform_current_path (GimpImage *gimage,
|
|||
}
|
||||
|
||||
void
|
||||
paths_draw_current (GDisplay *gdisp,
|
||||
DrawCore *core,
|
||||
GimpMatrix transform)
|
||||
paths_draw_current (GDisplay *gdisp,
|
||||
DrawCore *core,
|
||||
GimpMatrix3 transform)
|
||||
{
|
||||
PATHIMAGELISTP plp;
|
||||
PATHP bzp;
|
||||
|
@ -2790,10 +2790,10 @@ paths_draw_current (GDisplay *gdisp,
|
|||
|
||||
/* printf("[x,y] = [%g,%g]\n",ppoint->x, ppoint->y); */
|
||||
|
||||
gimp_matrix_transform_point (transform,
|
||||
ppoint->x,
|
||||
ppoint->y,
|
||||
&newx,&newy);
|
||||
gimp_matrix3_transform_point (transform,
|
||||
ppoint->x,
|
||||
ppoint->y,
|
||||
&newx,&newy);
|
||||
|
||||
/* printf("->[x,y] = [%g,%g]\n", newx, newy); */
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ PATHP paths_get_path_by_tattoo(GimpImage *,Tattoo);
|
|||
void * paths_transform_start_undo(GimpImage *);
|
||||
void paths_transform_free_undo(void *);
|
||||
void paths_transform_do_undo(GimpImage *,void *);
|
||||
void paths_transform_current_path(GimpImage *,GimpMatrix,gboolean);
|
||||
void paths_transform_current_path(GimpImage *,GimpMatrix3,gboolean);
|
||||
gboolean paths_delete_path(GimpImage *,gchar *);
|
||||
|
||||
#endif /* __PATHSP_H__ */
|
||||
|
|
|
@ -2672,9 +2672,9 @@ paths_transform_xy (GimpImage *gimage,
|
|||
}
|
||||
|
||||
void
|
||||
paths_transform_current_path (GimpImage *gimage,
|
||||
GimpMatrix transform,
|
||||
gboolean forpreview)
|
||||
paths_transform_current_path (GimpImage *gimage,
|
||||
GimpMatrix3 transform,
|
||||
gboolean forpreview)
|
||||
{
|
||||
PATHIMAGELISTP plp;
|
||||
PATHP p;
|
||||
|
@ -2715,10 +2715,10 @@ paths_transform_current_path (GimpImage *gimage,
|
|||
|
||||
/* printf("[x,y] = [%g,%g]\n",ppoint->x, ppoint->y); */
|
||||
|
||||
gimp_matrix_transform_point (transform,
|
||||
ppoint->x,
|
||||
ppoint->y,
|
||||
&newx,&newy);
|
||||
gimp_matrix3_transform_point (transform,
|
||||
ppoint->x,
|
||||
ppoint->y,
|
||||
&newx,&newy);
|
||||
|
||||
/* printf("->[x,y] = [%g,%g]\n", newx, newy); */
|
||||
|
||||
|
@ -2754,9 +2754,9 @@ paths_transform_current_path (GimpImage *gimage,
|
|||
}
|
||||
|
||||
void
|
||||
paths_draw_current (GDisplay *gdisp,
|
||||
DrawCore *core,
|
||||
GimpMatrix transform)
|
||||
paths_draw_current (GDisplay *gdisp,
|
||||
DrawCore *core,
|
||||
GimpMatrix3 transform)
|
||||
{
|
||||
PATHIMAGELISTP plp;
|
||||
PATHP bzp;
|
||||
|
@ -2790,10 +2790,10 @@ paths_draw_current (GDisplay *gdisp,
|
|||
|
||||
/* printf("[x,y] = [%g,%g]\n",ppoint->x, ppoint->y); */
|
||||
|
||||
gimp_matrix_transform_point (transform,
|
||||
ppoint->x,
|
||||
ppoint->y,
|
||||
&newx,&newy);
|
||||
gimp_matrix3_transform_point (transform,
|
||||
ppoint->x,
|
||||
ppoint->y,
|
||||
&newx,&newy);
|
||||
|
||||
/* printf("->[x,y] = [%g,%g]\n", newx, newy); */
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ tools_new_perspective_tool (void)
|
|||
private->trans_info[Y3] = 0;
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix_identity (private->transform);
|
||||
gimp_matrix3_identity (private->transform);
|
||||
|
||||
return tool;
|
||||
}
|
||||
|
@ -205,7 +205,7 @@ perspective_tool_recalc (Tool *tool,
|
|||
{
|
||||
TransformCore *transform_core;
|
||||
GDisplay *gdisp;
|
||||
GimpMatrix m;
|
||||
GimpMatrix3 m;
|
||||
gdouble cx, cy;
|
||||
gdouble scalex, scaley;
|
||||
|
||||
|
@ -228,10 +228,10 @@ perspective_tool_recalc (Tool *tool,
|
|||
scaley = 1.0 / (transform_core->y2 - transform_core->y1);
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix_identity (transform_core->transform);
|
||||
gimp_matrix_translate (transform_core->transform, -cx, -cy);
|
||||
gimp_matrix_scale (transform_core->transform, scalex, scaley);
|
||||
gimp_matrix_mult (m, transform_core->transform);
|
||||
gimp_matrix3_identity (transform_core->transform);
|
||||
gimp_matrix3_translate (transform_core->transform, -cx, -cy);
|
||||
gimp_matrix3_scale (transform_core->transform, scalex, scaley);
|
||||
gimp_matrix3_mult (m, transform_core->transform);
|
||||
|
||||
/* transform the bounding box */
|
||||
transform_core_transform_bounding_box (tool);
|
||||
|
@ -241,8 +241,8 @@ perspective_tool_recalc (Tool *tool,
|
|||
}
|
||||
|
||||
void
|
||||
perspective_find_transform (gdouble *coords,
|
||||
GimpMatrix matrix)
|
||||
perspective_find_transform (gdouble *coords,
|
||||
GimpMatrix3 matrix)
|
||||
{
|
||||
gdouble dx1, dx2, dx3, dy1, dy2, dy3;
|
||||
gdouble det1, det2;
|
||||
|
@ -294,7 +294,7 @@ perspective_tool_perspective (GImage *gimage,
|
|||
GDisplay *gdisp,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix matrix)
|
||||
GimpMatrix3 matrix)
|
||||
{
|
||||
gimp_progress *progress;
|
||||
TileManager *ret;
|
||||
|
|
|
@ -29,9 +29,9 @@ TileManager * perspective_tool_perspective (GimpImage *gimage,
|
|||
GDisplay *gdisp,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix matrix);
|
||||
GimpMatrix3 matrix);
|
||||
void perspective_find_transform (gdouble *coords,
|
||||
GimpMatrix matrix);
|
||||
GimpMatrix3 matrix);
|
||||
|
||||
Tool * tools_new_perspective_tool (void);
|
||||
void tools_free_perspective_tool (Tool *tool);
|
||||
|
|
|
@ -202,7 +202,7 @@ tools_new_rotate_tool (void)
|
|||
private->trans_info[CENTER_Y] = 0.0;
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix_identity (private->transform);
|
||||
gimp_matrix3_identity (private->transform);
|
||||
|
||||
return tool;
|
||||
}
|
||||
|
@ -364,11 +364,11 @@ rotate_tool_recalc (Tool *tool,
|
|||
cy = transform_core->cy;
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix_identity (transform_core->transform);
|
||||
gimp_matrix_translate (transform_core->transform, -cx, -cy);
|
||||
gimp_matrix_rotate (transform_core->transform,
|
||||
transform_core->trans_info[ANGLE]);
|
||||
gimp_matrix_translate (transform_core->transform, +cx, +cy);
|
||||
gimp_matrix3_identity (transform_core->transform);
|
||||
gimp_matrix3_translate (transform_core->transform, -cx, -cy);
|
||||
gimp_matrix3_rotate (transform_core->transform,
|
||||
transform_core->trans_info[ANGLE]);
|
||||
gimp_matrix3_translate (transform_core->transform, +cx, +cy);
|
||||
|
||||
/* transform the bounding box */
|
||||
transform_core_transform_bounding_box (tool);
|
||||
|
@ -384,7 +384,7 @@ rotate_tool_rotate (GImage *gimage,
|
|||
gdouble angle,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix matrix)
|
||||
GimpMatrix3 matrix)
|
||||
{
|
||||
gimp_progress *progress;
|
||||
TileManager *ret;
|
||||
|
|
|
@ -30,7 +30,7 @@ TileManager * rotate_tool_rotate (GimpImage *gimage,
|
|||
gdouble angle,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix matrix);
|
||||
GimpMatrix3 matrix);
|
||||
|
||||
Tool * tools_new_rotate_tool (void);
|
||||
void tools_free_rotate_tool (Tool *tool);
|
||||
|
|
|
@ -189,7 +189,7 @@ tools_new_scale_tool (void)
|
|||
private->trans_info[Y1] = 0.0;
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix_identity (private->transform);
|
||||
gimp_matrix3_identity (private->transform);
|
||||
|
||||
return tool;
|
||||
}
|
||||
|
@ -475,10 +475,11 @@ scale_tool_recalc (Tool *tool,
|
|||
}
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix_identity (transform_core->transform);
|
||||
gimp_matrix_translate (transform_core->transform, (double) -cx + diffx, (double) -cy + diffy);
|
||||
gimp_matrix_scale (transform_core->transform, scalex, scaley);
|
||||
gimp_matrix_translate (transform_core->transform, (double) cx, (double) cy);
|
||||
gimp_matrix3_identity (transform_core->transform);
|
||||
gimp_matrix3_translate (transform_core->transform,
|
||||
(double) -cx + diffx, (double) -cy + diffy);
|
||||
gimp_matrix3_scale (transform_core->transform, scalex, scaley);
|
||||
gimp_matrix3_translate (transform_core->transform, (double) cx, (double) cy);
|
||||
|
||||
/* transform the bounding box */
|
||||
transform_core_transform_bounding_box (tool);
|
||||
|
@ -494,7 +495,7 @@ scale_tool_scale (GImage *gimage,
|
|||
gdouble *trans_info,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix matrix)
|
||||
GimpMatrix3 matrix)
|
||||
{
|
||||
gimp_progress *progress;
|
||||
TileManager *ret;
|
||||
|
|
|
@ -30,7 +30,7 @@ TileManager * scale_tool_scale (GimpImage *gimage,
|
|||
gdouble *trans_info,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix matrix);
|
||||
GimpMatrix3 matrix);
|
||||
|
||||
Tool * tools_new_scale_tool (void);
|
||||
void tools_free_scale_tool (Tool *tool);
|
||||
|
|
|
@ -129,7 +129,7 @@ tools_new_shear_tool (void)
|
|||
private->trans_func = shear_tool_transform;
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix_identity (private->transform);
|
||||
gimp_matrix3_identity (private->transform);
|
||||
|
||||
return tool;
|
||||
}
|
||||
|
@ -310,18 +310,18 @@ shear_tool_recalc (Tool *tool,
|
|||
height = 1;
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix_identity (transform_core->transform);
|
||||
gimp_matrix_translate (transform_core->transform, -cx, -cy);
|
||||
gimp_matrix3_identity (transform_core->transform);
|
||||
gimp_matrix3_translate (transform_core->transform, -cx, -cy);
|
||||
|
||||
/* shear matrix */
|
||||
if (transform_core->trans_info[HORZ_OR_VERT] == ORIENTATION_HORIZONTAL)
|
||||
gimp_matrix_xshear (transform_core->transform,
|
||||
(float) transform_core->trans_info [XSHEAR] / height);
|
||||
gimp_matrix3_xshear (transform_core->transform,
|
||||
(float) transform_core->trans_info [XSHEAR] / height);
|
||||
else
|
||||
gimp_matrix_yshear (transform_core->transform,
|
||||
(float) transform_core->trans_info [YSHEAR] / width);
|
||||
gimp_matrix3_yshear (transform_core->transform,
|
||||
(float) transform_core->trans_info [YSHEAR] / width);
|
||||
|
||||
gimp_matrix_translate (transform_core->transform, +cx, +cy);
|
||||
gimp_matrix3_translate (transform_core->transform, +cx, +cy);
|
||||
|
||||
/* transform the bounding box */
|
||||
transform_core_transform_bounding_box (tool);
|
||||
|
@ -336,7 +336,7 @@ shear_tool_shear (GimpImage *gimage,
|
|||
GDisplay *gdisp,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix matrix)
|
||||
GimpMatrix3 matrix)
|
||||
{
|
||||
gimp_progress *progress;
|
||||
TileManager *ret;
|
||||
|
|
|
@ -29,7 +29,7 @@ TileManager * shear_tool_shear (GimpImage *gimage,
|
|||
GDisplay *gdisp,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix matrix);
|
||||
GimpMatrix3 matrix);
|
||||
|
||||
Tool * tools_new_shear_tool (void);
|
||||
void tools_free_shear_tool (Tool *matrix);
|
||||
|
|
|
@ -125,7 +125,7 @@ tools_new_perspective_tool (void)
|
|||
private->trans_info[Y3] = 0;
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix_identity (private->transform);
|
||||
gimp_matrix3_identity (private->transform);
|
||||
|
||||
return tool;
|
||||
}
|
||||
|
@ -205,7 +205,7 @@ perspective_tool_recalc (Tool *tool,
|
|||
{
|
||||
TransformCore *transform_core;
|
||||
GDisplay *gdisp;
|
||||
GimpMatrix m;
|
||||
GimpMatrix3 m;
|
||||
gdouble cx, cy;
|
||||
gdouble scalex, scaley;
|
||||
|
||||
|
@ -228,10 +228,10 @@ perspective_tool_recalc (Tool *tool,
|
|||
scaley = 1.0 / (transform_core->y2 - transform_core->y1);
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix_identity (transform_core->transform);
|
||||
gimp_matrix_translate (transform_core->transform, -cx, -cy);
|
||||
gimp_matrix_scale (transform_core->transform, scalex, scaley);
|
||||
gimp_matrix_mult (m, transform_core->transform);
|
||||
gimp_matrix3_identity (transform_core->transform);
|
||||
gimp_matrix3_translate (transform_core->transform, -cx, -cy);
|
||||
gimp_matrix3_scale (transform_core->transform, scalex, scaley);
|
||||
gimp_matrix3_mult (m, transform_core->transform);
|
||||
|
||||
/* transform the bounding box */
|
||||
transform_core_transform_bounding_box (tool);
|
||||
|
@ -241,8 +241,8 @@ perspective_tool_recalc (Tool *tool,
|
|||
}
|
||||
|
||||
void
|
||||
perspective_find_transform (gdouble *coords,
|
||||
GimpMatrix matrix)
|
||||
perspective_find_transform (gdouble *coords,
|
||||
GimpMatrix3 matrix)
|
||||
{
|
||||
gdouble dx1, dx2, dx3, dy1, dy2, dy3;
|
||||
gdouble det1, det2;
|
||||
|
@ -294,7 +294,7 @@ perspective_tool_perspective (GImage *gimage,
|
|||
GDisplay *gdisp,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix matrix)
|
||||
GimpMatrix3 matrix)
|
||||
{
|
||||
gimp_progress *progress;
|
||||
TileManager *ret;
|
||||
|
|
|
@ -29,9 +29,9 @@ TileManager * perspective_tool_perspective (GimpImage *gimage,
|
|||
GDisplay *gdisp,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix matrix);
|
||||
GimpMatrix3 matrix);
|
||||
void perspective_find_transform (gdouble *coords,
|
||||
GimpMatrix matrix);
|
||||
GimpMatrix3 matrix);
|
||||
|
||||
Tool * tools_new_perspective_tool (void);
|
||||
void tools_free_perspective_tool (Tool *tool);
|
||||
|
|
|
@ -202,7 +202,7 @@ tools_new_rotate_tool (void)
|
|||
private->trans_info[CENTER_Y] = 0.0;
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix_identity (private->transform);
|
||||
gimp_matrix3_identity (private->transform);
|
||||
|
||||
return tool;
|
||||
}
|
||||
|
@ -364,11 +364,11 @@ rotate_tool_recalc (Tool *tool,
|
|||
cy = transform_core->cy;
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix_identity (transform_core->transform);
|
||||
gimp_matrix_translate (transform_core->transform, -cx, -cy);
|
||||
gimp_matrix_rotate (transform_core->transform,
|
||||
transform_core->trans_info[ANGLE]);
|
||||
gimp_matrix_translate (transform_core->transform, +cx, +cy);
|
||||
gimp_matrix3_identity (transform_core->transform);
|
||||
gimp_matrix3_translate (transform_core->transform, -cx, -cy);
|
||||
gimp_matrix3_rotate (transform_core->transform,
|
||||
transform_core->trans_info[ANGLE]);
|
||||
gimp_matrix3_translate (transform_core->transform, +cx, +cy);
|
||||
|
||||
/* transform the bounding box */
|
||||
transform_core_transform_bounding_box (tool);
|
||||
|
@ -384,7 +384,7 @@ rotate_tool_rotate (GImage *gimage,
|
|||
gdouble angle,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix matrix)
|
||||
GimpMatrix3 matrix)
|
||||
{
|
||||
gimp_progress *progress;
|
||||
TileManager *ret;
|
||||
|
|
|
@ -30,7 +30,7 @@ TileManager * rotate_tool_rotate (GimpImage *gimage,
|
|||
gdouble angle,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix matrix);
|
||||
GimpMatrix3 matrix);
|
||||
|
||||
Tool * tools_new_rotate_tool (void);
|
||||
void tools_free_rotate_tool (Tool *tool);
|
||||
|
|
|
@ -189,7 +189,7 @@ tools_new_scale_tool (void)
|
|||
private->trans_info[Y1] = 0.0;
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix_identity (private->transform);
|
||||
gimp_matrix3_identity (private->transform);
|
||||
|
||||
return tool;
|
||||
}
|
||||
|
@ -475,10 +475,11 @@ scale_tool_recalc (Tool *tool,
|
|||
}
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix_identity (transform_core->transform);
|
||||
gimp_matrix_translate (transform_core->transform, (double) -cx + diffx, (double) -cy + diffy);
|
||||
gimp_matrix_scale (transform_core->transform, scalex, scaley);
|
||||
gimp_matrix_translate (transform_core->transform, (double) cx, (double) cy);
|
||||
gimp_matrix3_identity (transform_core->transform);
|
||||
gimp_matrix3_translate (transform_core->transform,
|
||||
(double) -cx + diffx, (double) -cy + diffy);
|
||||
gimp_matrix3_scale (transform_core->transform, scalex, scaley);
|
||||
gimp_matrix3_translate (transform_core->transform, (double) cx, (double) cy);
|
||||
|
||||
/* transform the bounding box */
|
||||
transform_core_transform_bounding_box (tool);
|
||||
|
@ -494,7 +495,7 @@ scale_tool_scale (GImage *gimage,
|
|||
gdouble *trans_info,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix matrix)
|
||||
GimpMatrix3 matrix)
|
||||
{
|
||||
gimp_progress *progress;
|
||||
TileManager *ret;
|
||||
|
|
|
@ -30,7 +30,7 @@ TileManager * scale_tool_scale (GimpImage *gimage,
|
|||
gdouble *trans_info,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix matrix);
|
||||
GimpMatrix3 matrix);
|
||||
|
||||
Tool * tools_new_scale_tool (void);
|
||||
void tools_free_scale_tool (Tool *tool);
|
||||
|
|
|
@ -129,7 +129,7 @@ tools_new_shear_tool (void)
|
|||
private->trans_func = shear_tool_transform;
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix_identity (private->transform);
|
||||
gimp_matrix3_identity (private->transform);
|
||||
|
||||
return tool;
|
||||
}
|
||||
|
@ -310,18 +310,18 @@ shear_tool_recalc (Tool *tool,
|
|||
height = 1;
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix_identity (transform_core->transform);
|
||||
gimp_matrix_translate (transform_core->transform, -cx, -cy);
|
||||
gimp_matrix3_identity (transform_core->transform);
|
||||
gimp_matrix3_translate (transform_core->transform, -cx, -cy);
|
||||
|
||||
/* shear matrix */
|
||||
if (transform_core->trans_info[HORZ_OR_VERT] == ORIENTATION_HORIZONTAL)
|
||||
gimp_matrix_xshear (transform_core->transform,
|
||||
(float) transform_core->trans_info [XSHEAR] / height);
|
||||
gimp_matrix3_xshear (transform_core->transform,
|
||||
(float) transform_core->trans_info [XSHEAR] / height);
|
||||
else
|
||||
gimp_matrix_yshear (transform_core->transform,
|
||||
(float) transform_core->trans_info [YSHEAR] / width);
|
||||
gimp_matrix3_yshear (transform_core->transform,
|
||||
(float) transform_core->trans_info [YSHEAR] / width);
|
||||
|
||||
gimp_matrix_translate (transform_core->transform, +cx, +cy);
|
||||
gimp_matrix3_translate (transform_core->transform, +cx, +cy);
|
||||
|
||||
/* transform the bounding box */
|
||||
transform_core_transform_bounding_box (tool);
|
||||
|
@ -336,7 +336,7 @@ shear_tool_shear (GimpImage *gimage,
|
|||
GDisplay *gdisp,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix matrix)
|
||||
GimpMatrix3 matrix)
|
||||
{
|
||||
gimp_progress *progress;
|
||||
TileManager *ret;
|
||||
|
|
|
@ -29,7 +29,7 @@ TileManager * shear_tool_shear (GimpImage *gimage,
|
|||
GDisplay *gdisp,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix matrix);
|
||||
GimpMatrix3 matrix);
|
||||
|
||||
Tool * tools_new_shear_tool (void);
|
||||
void tools_free_shear_tool (Tool *matrix);
|
||||
|
|
|
@ -125,7 +125,7 @@ tools_new_perspective_tool (void)
|
|||
private->trans_info[Y3] = 0;
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix_identity (private->transform);
|
||||
gimp_matrix3_identity (private->transform);
|
||||
|
||||
return tool;
|
||||
}
|
||||
|
@ -205,7 +205,7 @@ perspective_tool_recalc (Tool *tool,
|
|||
{
|
||||
TransformCore *transform_core;
|
||||
GDisplay *gdisp;
|
||||
GimpMatrix m;
|
||||
GimpMatrix3 m;
|
||||
gdouble cx, cy;
|
||||
gdouble scalex, scaley;
|
||||
|
||||
|
@ -228,10 +228,10 @@ perspective_tool_recalc (Tool *tool,
|
|||
scaley = 1.0 / (transform_core->y2 - transform_core->y1);
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix_identity (transform_core->transform);
|
||||
gimp_matrix_translate (transform_core->transform, -cx, -cy);
|
||||
gimp_matrix_scale (transform_core->transform, scalex, scaley);
|
||||
gimp_matrix_mult (m, transform_core->transform);
|
||||
gimp_matrix3_identity (transform_core->transform);
|
||||
gimp_matrix3_translate (transform_core->transform, -cx, -cy);
|
||||
gimp_matrix3_scale (transform_core->transform, scalex, scaley);
|
||||
gimp_matrix3_mult (m, transform_core->transform);
|
||||
|
||||
/* transform the bounding box */
|
||||
transform_core_transform_bounding_box (tool);
|
||||
|
@ -241,8 +241,8 @@ perspective_tool_recalc (Tool *tool,
|
|||
}
|
||||
|
||||
void
|
||||
perspective_find_transform (gdouble *coords,
|
||||
GimpMatrix matrix)
|
||||
perspective_find_transform (gdouble *coords,
|
||||
GimpMatrix3 matrix)
|
||||
{
|
||||
gdouble dx1, dx2, dx3, dy1, dy2, dy3;
|
||||
gdouble det1, det2;
|
||||
|
@ -294,7 +294,7 @@ perspective_tool_perspective (GImage *gimage,
|
|||
GDisplay *gdisp,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix matrix)
|
||||
GimpMatrix3 matrix)
|
||||
{
|
||||
gimp_progress *progress;
|
||||
TileManager *ret;
|
||||
|
|
|
@ -29,9 +29,9 @@ TileManager * perspective_tool_perspective (GimpImage *gimage,
|
|||
GDisplay *gdisp,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix matrix);
|
||||
GimpMatrix3 matrix);
|
||||
void perspective_find_transform (gdouble *coords,
|
||||
GimpMatrix matrix);
|
||||
GimpMatrix3 matrix);
|
||||
|
||||
Tool * tools_new_perspective_tool (void);
|
||||
void tools_free_perspective_tool (Tool *tool);
|
||||
|
|
|
@ -202,7 +202,7 @@ tools_new_rotate_tool (void)
|
|||
private->trans_info[CENTER_Y] = 0.0;
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix_identity (private->transform);
|
||||
gimp_matrix3_identity (private->transform);
|
||||
|
||||
return tool;
|
||||
}
|
||||
|
@ -364,11 +364,11 @@ rotate_tool_recalc (Tool *tool,
|
|||
cy = transform_core->cy;
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix_identity (transform_core->transform);
|
||||
gimp_matrix_translate (transform_core->transform, -cx, -cy);
|
||||
gimp_matrix_rotate (transform_core->transform,
|
||||
transform_core->trans_info[ANGLE]);
|
||||
gimp_matrix_translate (transform_core->transform, +cx, +cy);
|
||||
gimp_matrix3_identity (transform_core->transform);
|
||||
gimp_matrix3_translate (transform_core->transform, -cx, -cy);
|
||||
gimp_matrix3_rotate (transform_core->transform,
|
||||
transform_core->trans_info[ANGLE]);
|
||||
gimp_matrix3_translate (transform_core->transform, +cx, +cy);
|
||||
|
||||
/* transform the bounding box */
|
||||
transform_core_transform_bounding_box (tool);
|
||||
|
@ -384,7 +384,7 @@ rotate_tool_rotate (GImage *gimage,
|
|||
gdouble angle,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix matrix)
|
||||
GimpMatrix3 matrix)
|
||||
{
|
||||
gimp_progress *progress;
|
||||
TileManager *ret;
|
||||
|
|
|
@ -30,7 +30,7 @@ TileManager * rotate_tool_rotate (GimpImage *gimage,
|
|||
gdouble angle,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix matrix);
|
||||
GimpMatrix3 matrix);
|
||||
|
||||
Tool * tools_new_rotate_tool (void);
|
||||
void tools_free_rotate_tool (Tool *tool);
|
||||
|
|
|
@ -189,7 +189,7 @@ tools_new_scale_tool (void)
|
|||
private->trans_info[Y1] = 0.0;
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix_identity (private->transform);
|
||||
gimp_matrix3_identity (private->transform);
|
||||
|
||||
return tool;
|
||||
}
|
||||
|
@ -475,10 +475,11 @@ scale_tool_recalc (Tool *tool,
|
|||
}
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix_identity (transform_core->transform);
|
||||
gimp_matrix_translate (transform_core->transform, (double) -cx + diffx, (double) -cy + diffy);
|
||||
gimp_matrix_scale (transform_core->transform, scalex, scaley);
|
||||
gimp_matrix_translate (transform_core->transform, (double) cx, (double) cy);
|
||||
gimp_matrix3_identity (transform_core->transform);
|
||||
gimp_matrix3_translate (transform_core->transform,
|
||||
(double) -cx + diffx, (double) -cy + diffy);
|
||||
gimp_matrix3_scale (transform_core->transform, scalex, scaley);
|
||||
gimp_matrix3_translate (transform_core->transform, (double) cx, (double) cy);
|
||||
|
||||
/* transform the bounding box */
|
||||
transform_core_transform_bounding_box (tool);
|
||||
|
@ -494,7 +495,7 @@ scale_tool_scale (GImage *gimage,
|
|||
gdouble *trans_info,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix matrix)
|
||||
GimpMatrix3 matrix)
|
||||
{
|
||||
gimp_progress *progress;
|
||||
TileManager *ret;
|
||||
|
|
|
@ -30,7 +30,7 @@ TileManager * scale_tool_scale (GimpImage *gimage,
|
|||
gdouble *trans_info,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix matrix);
|
||||
GimpMatrix3 matrix);
|
||||
|
||||
Tool * tools_new_scale_tool (void);
|
||||
void tools_free_scale_tool (Tool *tool);
|
||||
|
|
|
@ -129,7 +129,7 @@ tools_new_shear_tool (void)
|
|||
private->trans_func = shear_tool_transform;
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix_identity (private->transform);
|
||||
gimp_matrix3_identity (private->transform);
|
||||
|
||||
return tool;
|
||||
}
|
||||
|
@ -310,18 +310,18 @@ shear_tool_recalc (Tool *tool,
|
|||
height = 1;
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix_identity (transform_core->transform);
|
||||
gimp_matrix_translate (transform_core->transform, -cx, -cy);
|
||||
gimp_matrix3_identity (transform_core->transform);
|
||||
gimp_matrix3_translate (transform_core->transform, -cx, -cy);
|
||||
|
||||
/* shear matrix */
|
||||
if (transform_core->trans_info[HORZ_OR_VERT] == ORIENTATION_HORIZONTAL)
|
||||
gimp_matrix_xshear (transform_core->transform,
|
||||
(float) transform_core->trans_info [XSHEAR] / height);
|
||||
gimp_matrix3_xshear (transform_core->transform,
|
||||
(float) transform_core->trans_info [XSHEAR] / height);
|
||||
else
|
||||
gimp_matrix_yshear (transform_core->transform,
|
||||
(float) transform_core->trans_info [YSHEAR] / width);
|
||||
gimp_matrix3_yshear (transform_core->transform,
|
||||
(float) transform_core->trans_info [YSHEAR] / width);
|
||||
|
||||
gimp_matrix_translate (transform_core->transform, +cx, +cy);
|
||||
gimp_matrix3_translate (transform_core->transform, +cx, +cy);
|
||||
|
||||
/* transform the bounding box */
|
||||
transform_core_transform_bounding_box (tool);
|
||||
|
@ -336,7 +336,7 @@ shear_tool_shear (GimpImage *gimage,
|
|||
GDisplay *gdisp,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix matrix)
|
||||
GimpMatrix3 matrix)
|
||||
{
|
||||
gimp_progress *progress;
|
||||
TileManager *ret;
|
||||
|
|
|
@ -29,7 +29,7 @@ TileManager * shear_tool_shear (GimpImage *gimage,
|
|||
GDisplay *gdisp,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix matrix);
|
||||
GimpMatrix3 matrix);
|
||||
|
||||
Tool * tools_new_shear_tool (void);
|
||||
void tools_free_shear_tool (Tool *matrix);
|
||||
|
|
|
@ -61,7 +61,7 @@ static void transform_core_setup_grid (Tool *);
|
|||
static void transform_core_grid_recalc (TransformCore *);
|
||||
|
||||
/* Hmmm... Should be in a headerfile but which? */
|
||||
void paths_draw_current (GDisplay *, DrawCore *, GimpMatrix);
|
||||
void paths_draw_current (GDisplay *, DrawCore *, GimpMatrix3);
|
||||
|
||||
#define BILINEAR(jk,j1k,jk1,j1k1,dx,dy) \
|
||||
((1-dy) * (jk + dx * (j1k - jk)) + \
|
||||
|
@ -817,15 +817,15 @@ transform_core_draw (Tool *tool)
|
|||
|
||||
if (transform_tool_showpath ())
|
||||
{
|
||||
GimpMatrix tmp_matrix;
|
||||
GimpMatrix3 tmp_matrix;
|
||||
|
||||
if (transform_tool_direction () == TRANSFORM_CORRECTIVE)
|
||||
{
|
||||
gimp_matrix_invert (transform_core->transform, tmp_matrix);
|
||||
gimp_matrix3_invert (transform_core->transform, tmp_matrix);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_matrix_duplicate (transform_core->transform, tmp_matrix);
|
||||
gimp_matrix3_duplicate (transform_core->transform, tmp_matrix);
|
||||
}
|
||||
|
||||
paths_draw_current (gdisp, transform_core->core, tmp_matrix);
|
||||
|
@ -919,23 +919,23 @@ transform_core_transform_bounding_box (Tool *tool)
|
|||
|
||||
transform_core = (TransformCore *) tool->private;
|
||||
|
||||
gimp_matrix_transform_point (transform_core->transform,
|
||||
transform_core->x1, transform_core->y1,
|
||||
&transform_core->tx1, &transform_core->ty1);
|
||||
gimp_matrix_transform_point (transform_core->transform,
|
||||
transform_core->x2, transform_core->y1,
|
||||
&transform_core->tx2, &transform_core->ty2);
|
||||
gimp_matrix_transform_point (transform_core->transform,
|
||||
transform_core->x1, transform_core->y2,
|
||||
&transform_core->tx3, &transform_core->ty3);
|
||||
gimp_matrix_transform_point (transform_core->transform,
|
||||
transform_core->x2, transform_core->y2,
|
||||
&transform_core->tx4, &transform_core->ty4);
|
||||
gimp_matrix3_transform_point (transform_core->transform,
|
||||
transform_core->x1, transform_core->y1,
|
||||
&transform_core->tx1, &transform_core->ty1);
|
||||
gimp_matrix3_transform_point (transform_core->transform,
|
||||
transform_core->x2, transform_core->y1,
|
||||
&transform_core->tx2, &transform_core->ty2);
|
||||
gimp_matrix3_transform_point (transform_core->transform,
|
||||
transform_core->x1, transform_core->y2,
|
||||
&transform_core->tx3, &transform_core->ty3);
|
||||
gimp_matrix3_transform_point (transform_core->transform,
|
||||
transform_core->x2, transform_core->y2,
|
||||
&transform_core->tx4, &transform_core->ty4);
|
||||
|
||||
if (tool->type == ROTATE)
|
||||
gimp_matrix_transform_point (transform_core->transform,
|
||||
transform_core->cx, transform_core->cy,
|
||||
&transform_core->tcx, &transform_core->tcy);
|
||||
gimp_matrix3_transform_point (transform_core->transform,
|
||||
transform_core->cx, transform_core->cy,
|
||||
&transform_core->tcx, &transform_core->tcy);
|
||||
|
||||
if (transform_core->grid_coords != NULL &&
|
||||
transform_core->tgrid_coords != NULL)
|
||||
|
@ -944,11 +944,11 @@ transform_core_transform_bounding_box (Tool *tool)
|
|||
k = (transform_core->ngx + transform_core->ngy) * 2;
|
||||
for (i = 0; i < k; i++)
|
||||
{
|
||||
gimp_matrix_transform_point (transform_core->transform,
|
||||
transform_core->grid_coords[gci],
|
||||
transform_core->grid_coords[gci+1],
|
||||
&(transform_core->tgrid_coords[gci]),
|
||||
&(transform_core->tgrid_coords[gci+1]));
|
||||
gimp_matrix3_transform_point (transform_core->transform,
|
||||
transform_core->grid_coords[gci],
|
||||
transform_core->grid_coords[gci+1],
|
||||
&(transform_core->tgrid_coords[gci]),
|
||||
&(transform_core->tgrid_coords[gci+1]));
|
||||
gci += 2;
|
||||
}
|
||||
}
|
||||
|
@ -1139,14 +1139,14 @@ transform_core_do (GImage *gimage,
|
|||
GimpDrawable *drawable,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix matrix,
|
||||
GimpMatrix3 matrix,
|
||||
progress_func_t progress_callback,
|
||||
gpointer progress_data)
|
||||
{
|
||||
PixelRegion destPR;
|
||||
TileManager *tiles;
|
||||
GimpMatrix m;
|
||||
GimpMatrix im;
|
||||
GimpMatrix3 m;
|
||||
GimpMatrix3 im;
|
||||
gint itx, ity;
|
||||
gint tx1, ty1, tx2, ty2;
|
||||
gint width, height;
|
||||
|
@ -1172,7 +1172,7 @@ transform_core_do (GImage *gimage,
|
|||
alpha = 0;
|
||||
|
||||
/* turn interpolation off for simple transformations (e.g. rot90) */
|
||||
if (gimp_matrix_is_simple (matrix)
|
||||
if (gimp_matrix3_is_simple (matrix)
|
||||
|| interpolation_type == NEAREST_NEIGHBOR_INTERPOLATION)
|
||||
interpolation = FALSE;
|
||||
|
||||
|
@ -1201,14 +1201,14 @@ transform_core_do (GImage *gimage,
|
|||
{
|
||||
/* keep the original matrix here, so we dont need to recalculate
|
||||
the inverse later */
|
||||
gimp_matrix_duplicate (matrix, m);
|
||||
gimp_matrix_invert (matrix, im);
|
||||
gimp_matrix3_duplicate (matrix, m);
|
||||
gimp_matrix3_invert (matrix, im);
|
||||
matrix = im;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Find the inverse of the transformation matrix */
|
||||
gimp_matrix_invert (matrix, m);
|
||||
gimp_matrix3_invert (matrix, m);
|
||||
}
|
||||
|
||||
paths_transform_current_path (gimage, matrix, FALSE);
|
||||
|
@ -1230,10 +1230,10 @@ transform_core_do (GImage *gimage,
|
|||
{
|
||||
gdouble dx1, dy1, dx2, dy2, dx3, dy3, dx4, dy4;
|
||||
|
||||
gimp_matrix_transform_point (matrix, x1, y1, &dx1, &dy1);
|
||||
gimp_matrix_transform_point (matrix, x2, y1, &dx2, &dy2);
|
||||
gimp_matrix_transform_point (matrix, x1, y2, &dx3, &dy3);
|
||||
gimp_matrix_transform_point (matrix, x2, y2, &dx4, &dy4);
|
||||
gimp_matrix3_transform_point (matrix, x1, y1, &dx1, &dy1);
|
||||
gimp_matrix3_transform_point (matrix, x2, y1, &dx2, &dy2);
|
||||
gimp_matrix3_transform_point (matrix, x1, y2, &dx3, &dy3);
|
||||
gimp_matrix3_transform_point (matrix, x2, y2, &dx4, &dy4);
|
||||
|
||||
tx1 = MIN (dx1, dx2);
|
||||
tx1 = MIN (tx1, dx3);
|
||||
|
|
|
@ -92,7 +92,7 @@ struct _TransformCore
|
|||
gint sx4, sy4; /* */
|
||||
gint scx, scy; /* and center for rotation */
|
||||
|
||||
GimpMatrix transform; /* transformation matrix */
|
||||
GimpMatrix3 transform; /* transformation matrix */
|
||||
TranInfo trans_info; /* transformation info */
|
||||
|
||||
TileManager *original; /* pointer to original tiles */
|
||||
|
@ -157,7 +157,7 @@ TileManager * transform_core_do (GImage *gimage,
|
|||
GimpDrawable *drawable,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix matrix,
|
||||
GimpMatrix3 matrix,
|
||||
progress_func_t progress_callback,
|
||||
gpointer progress_data);
|
||||
TileManager * transform_core_cut (GImage *gimage,
|
||||
|
|
|
@ -2112,7 +2112,7 @@ perspective_invoker (Argument *args)
|
|||
double cx, cy;
|
||||
double scalex, scaley;
|
||||
double trans_info[8];
|
||||
GimpMatrix m, matrix;
|
||||
GimpMatrix3 m, matrix;
|
||||
|
||||
drawable = gimp_drawable_get_ID (args[0].value.pdb_int);
|
||||
if (drawable == NULL)
|
||||
|
@ -2161,10 +2161,10 @@ perspective_invoker (Argument *args)
|
|||
scaley = 1.0 / float_tiles->height;
|
||||
|
||||
/* Assemble the transformation matrix */
|
||||
gimp_matrix_identity (matrix);
|
||||
gimp_matrix_translate (matrix, -cx, -cy);
|
||||
gimp_matrix_scale (matrix, scalex, scaley);
|
||||
gimp_matrix_mult (m, matrix);
|
||||
gimp_matrix3_identity (matrix);
|
||||
gimp_matrix3_translate (matrix, -cx, -cy);
|
||||
gimp_matrix3_scale (matrix, scalex, scaley);
|
||||
gimp_matrix3_mult (m, matrix);
|
||||
|
||||
/* Perspective the buffer */
|
||||
new_tiles = perspective_tool_perspective (gimage, drawable, NULL,
|
||||
|
@ -2391,7 +2391,7 @@ rotate_invoker (Argument *args)
|
|||
Layer *layer;
|
||||
gboolean new_layer;
|
||||
double cx, cy;
|
||||
GimpMatrix matrix;
|
||||
GimpMatrix3 matrix;
|
||||
|
||||
drawable = gimp_drawable_get_ID (args[0].value.pdb_int);
|
||||
if (drawable == NULL)
|
||||
|
@ -2415,10 +2415,10 @@ rotate_invoker (Argument *args)
|
|||
cy = float_tiles->y + float_tiles->height / 2.0;
|
||||
|
||||
/* Assemble the transformation matrix */
|
||||
gimp_matrix_identity (matrix);
|
||||
gimp_matrix_translate (matrix, -cx, -cy);
|
||||
gimp_matrix_rotate (matrix, angle);
|
||||
gimp_matrix_translate (matrix, +cx, +cy);
|
||||
gimp_matrix3_identity (matrix);
|
||||
gimp_matrix3_translate (matrix, -cx, -cy);
|
||||
gimp_matrix3_rotate (matrix, angle);
|
||||
gimp_matrix3_translate (matrix, +cx, +cy);
|
||||
|
||||
/* Rotate the buffer */
|
||||
new_tiles = rotate_tool_rotate (gimage, drawable, NULL, angle,
|
||||
|
@ -2504,7 +2504,7 @@ scale_invoker (Argument *args)
|
|||
gboolean new_layer;
|
||||
double scalex, scaley;
|
||||
double trans_info[4];
|
||||
GimpMatrix matrix;
|
||||
GimpMatrix3 matrix;
|
||||
|
||||
drawable = gimp_drawable_get_ID (args[0].value.pdb_int);
|
||||
if (drawable == NULL)
|
||||
|
@ -2542,10 +2542,10 @@ scale_invoker (Argument *args)
|
|||
(double) float_tiles->height;
|
||||
|
||||
/* Assemble the transformation matrix */
|
||||
gimp_matrix_identity (matrix);
|
||||
gimp_matrix_translate (matrix, float_tiles->x, float_tiles->y);
|
||||
gimp_matrix_scale (matrix, scalex, scaley);
|
||||
gimp_matrix_translate (matrix, trans_info[X0], trans_info[Y0]);
|
||||
gimp_matrix3_identity (matrix);
|
||||
gimp_matrix3_translate (matrix, float_tiles->x, float_tiles->y);
|
||||
gimp_matrix3_scale (matrix, scalex, scaley);
|
||||
gimp_matrix3_translate (matrix, trans_info[X0], trans_info[Y0]);
|
||||
|
||||
/* Scale the buffer */
|
||||
new_tiles = scale_tool_scale (gimage, drawable, NULL, trans_info,
|
||||
|
@ -2650,7 +2650,7 @@ shear_invoker (Argument *args)
|
|||
Layer *layer;
|
||||
gboolean new_layer;
|
||||
double cx, cy;
|
||||
GimpMatrix matrix;
|
||||
GimpMatrix3 matrix;
|
||||
|
||||
drawable = gimp_drawable_get_ID (args[0].value.pdb_int);
|
||||
if (drawable == NULL)
|
||||
|
@ -2677,18 +2677,18 @@ shear_invoker (Argument *args)
|
|||
cx = float_tiles->x + float_tiles->width / 2.0;
|
||||
cy = float_tiles->y + float_tiles->height / 2.0;
|
||||
|
||||
gimp_matrix_identity (matrix);
|
||||
gimp_matrix_translate (matrix, -cx, -cy);
|
||||
gimp_matrix3_identity (matrix);
|
||||
gimp_matrix3_translate (matrix, -cx, -cy);
|
||||
/* Shear matrix */
|
||||
shear_type = shear_type == HORIZONTAL ? ORIENTATION_HORIZONTAL :
|
||||
shear_type == VERTICAL ? ORIENTATION_VERTICAL :
|
||||
ORIENTATION_UNKNOWN;
|
||||
|
||||
if (shear_type == ORIENTATION_HORIZONTAL)
|
||||
gimp_matrix_xshear (matrix, magnitude / float_tiles->height);
|
||||
gimp_matrix3_xshear (matrix, magnitude / float_tiles->height);
|
||||
else if (shear_type == ORIENTATION_VERTICAL)
|
||||
gimp_matrix_yshear (matrix, magnitude / float_tiles->width);
|
||||
gimp_matrix_translate (matrix, +cx, +cy);
|
||||
gimp_matrix3_yshear (matrix, magnitude / float_tiles->width);
|
||||
gimp_matrix3_translate (matrix, +cx, +cy);
|
||||
|
||||
/* Shear the buffer */
|
||||
new_tiles = shear_tool_shear (gimage, drawable, NULL, float_tiles,
|
||||
|
|
|
@ -61,7 +61,7 @@ static void transform_core_setup_grid (Tool *);
|
|||
static void transform_core_grid_recalc (TransformCore *);
|
||||
|
||||
/* Hmmm... Should be in a headerfile but which? */
|
||||
void paths_draw_current (GDisplay *, DrawCore *, GimpMatrix);
|
||||
void paths_draw_current (GDisplay *, DrawCore *, GimpMatrix3);
|
||||
|
||||
#define BILINEAR(jk,j1k,jk1,j1k1,dx,dy) \
|
||||
((1-dy) * (jk + dx * (j1k - jk)) + \
|
||||
|
@ -817,15 +817,15 @@ transform_core_draw (Tool *tool)
|
|||
|
||||
if (transform_tool_showpath ())
|
||||
{
|
||||
GimpMatrix tmp_matrix;
|
||||
GimpMatrix3 tmp_matrix;
|
||||
|
||||
if (transform_tool_direction () == TRANSFORM_CORRECTIVE)
|
||||
{
|
||||
gimp_matrix_invert (transform_core->transform, tmp_matrix);
|
||||
gimp_matrix3_invert (transform_core->transform, tmp_matrix);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_matrix_duplicate (transform_core->transform, tmp_matrix);
|
||||
gimp_matrix3_duplicate (transform_core->transform, tmp_matrix);
|
||||
}
|
||||
|
||||
paths_draw_current (gdisp, transform_core->core, tmp_matrix);
|
||||
|
@ -919,23 +919,23 @@ transform_core_transform_bounding_box (Tool *tool)
|
|||
|
||||
transform_core = (TransformCore *) tool->private;
|
||||
|
||||
gimp_matrix_transform_point (transform_core->transform,
|
||||
transform_core->x1, transform_core->y1,
|
||||
&transform_core->tx1, &transform_core->ty1);
|
||||
gimp_matrix_transform_point (transform_core->transform,
|
||||
transform_core->x2, transform_core->y1,
|
||||
&transform_core->tx2, &transform_core->ty2);
|
||||
gimp_matrix_transform_point (transform_core->transform,
|
||||
transform_core->x1, transform_core->y2,
|
||||
&transform_core->tx3, &transform_core->ty3);
|
||||
gimp_matrix_transform_point (transform_core->transform,
|
||||
transform_core->x2, transform_core->y2,
|
||||
&transform_core->tx4, &transform_core->ty4);
|
||||
gimp_matrix3_transform_point (transform_core->transform,
|
||||
transform_core->x1, transform_core->y1,
|
||||
&transform_core->tx1, &transform_core->ty1);
|
||||
gimp_matrix3_transform_point (transform_core->transform,
|
||||
transform_core->x2, transform_core->y1,
|
||||
&transform_core->tx2, &transform_core->ty2);
|
||||
gimp_matrix3_transform_point (transform_core->transform,
|
||||
transform_core->x1, transform_core->y2,
|
||||
&transform_core->tx3, &transform_core->ty3);
|
||||
gimp_matrix3_transform_point (transform_core->transform,
|
||||
transform_core->x2, transform_core->y2,
|
||||
&transform_core->tx4, &transform_core->ty4);
|
||||
|
||||
if (tool->type == ROTATE)
|
||||
gimp_matrix_transform_point (transform_core->transform,
|
||||
transform_core->cx, transform_core->cy,
|
||||
&transform_core->tcx, &transform_core->tcy);
|
||||
gimp_matrix3_transform_point (transform_core->transform,
|
||||
transform_core->cx, transform_core->cy,
|
||||
&transform_core->tcx, &transform_core->tcy);
|
||||
|
||||
if (transform_core->grid_coords != NULL &&
|
||||
transform_core->tgrid_coords != NULL)
|
||||
|
@ -944,11 +944,11 @@ transform_core_transform_bounding_box (Tool *tool)
|
|||
k = (transform_core->ngx + transform_core->ngy) * 2;
|
||||
for (i = 0; i < k; i++)
|
||||
{
|
||||
gimp_matrix_transform_point (transform_core->transform,
|
||||
transform_core->grid_coords[gci],
|
||||
transform_core->grid_coords[gci+1],
|
||||
&(transform_core->tgrid_coords[gci]),
|
||||
&(transform_core->tgrid_coords[gci+1]));
|
||||
gimp_matrix3_transform_point (transform_core->transform,
|
||||
transform_core->grid_coords[gci],
|
||||
transform_core->grid_coords[gci+1],
|
||||
&(transform_core->tgrid_coords[gci]),
|
||||
&(transform_core->tgrid_coords[gci+1]));
|
||||
gci += 2;
|
||||
}
|
||||
}
|
||||
|
@ -1139,14 +1139,14 @@ transform_core_do (GImage *gimage,
|
|||
GimpDrawable *drawable,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix matrix,
|
||||
GimpMatrix3 matrix,
|
||||
progress_func_t progress_callback,
|
||||
gpointer progress_data)
|
||||
{
|
||||
PixelRegion destPR;
|
||||
TileManager *tiles;
|
||||
GimpMatrix m;
|
||||
GimpMatrix im;
|
||||
GimpMatrix3 m;
|
||||
GimpMatrix3 im;
|
||||
gint itx, ity;
|
||||
gint tx1, ty1, tx2, ty2;
|
||||
gint width, height;
|
||||
|
@ -1172,7 +1172,7 @@ transform_core_do (GImage *gimage,
|
|||
alpha = 0;
|
||||
|
||||
/* turn interpolation off for simple transformations (e.g. rot90) */
|
||||
if (gimp_matrix_is_simple (matrix)
|
||||
if (gimp_matrix3_is_simple (matrix)
|
||||
|| interpolation_type == NEAREST_NEIGHBOR_INTERPOLATION)
|
||||
interpolation = FALSE;
|
||||
|
||||
|
@ -1201,14 +1201,14 @@ transform_core_do (GImage *gimage,
|
|||
{
|
||||
/* keep the original matrix here, so we dont need to recalculate
|
||||
the inverse later */
|
||||
gimp_matrix_duplicate (matrix, m);
|
||||
gimp_matrix_invert (matrix, im);
|
||||
gimp_matrix3_duplicate (matrix, m);
|
||||
gimp_matrix3_invert (matrix, im);
|
||||
matrix = im;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Find the inverse of the transformation matrix */
|
||||
gimp_matrix_invert (matrix, m);
|
||||
gimp_matrix3_invert (matrix, m);
|
||||
}
|
||||
|
||||
paths_transform_current_path (gimage, matrix, FALSE);
|
||||
|
@ -1230,10 +1230,10 @@ transform_core_do (GImage *gimage,
|
|||
{
|
||||
gdouble dx1, dy1, dx2, dy2, dx3, dy3, dx4, dy4;
|
||||
|
||||
gimp_matrix_transform_point (matrix, x1, y1, &dx1, &dy1);
|
||||
gimp_matrix_transform_point (matrix, x2, y1, &dx2, &dy2);
|
||||
gimp_matrix_transform_point (matrix, x1, y2, &dx3, &dy3);
|
||||
gimp_matrix_transform_point (matrix, x2, y2, &dx4, &dy4);
|
||||
gimp_matrix3_transform_point (matrix, x1, y1, &dx1, &dy1);
|
||||
gimp_matrix3_transform_point (matrix, x2, y1, &dx2, &dy2);
|
||||
gimp_matrix3_transform_point (matrix, x1, y2, &dx3, &dy3);
|
||||
gimp_matrix3_transform_point (matrix, x2, y2, &dx4, &dy4);
|
||||
|
||||
tx1 = MIN (dx1, dx2);
|
||||
tx1 = MIN (tx1, dx3);
|
||||
|
|
|
@ -92,7 +92,7 @@ struct _TransformCore
|
|||
gint sx4, sy4; /* */
|
||||
gint scx, scy; /* and center for rotation */
|
||||
|
||||
GimpMatrix transform; /* transformation matrix */
|
||||
GimpMatrix3 transform; /* transformation matrix */
|
||||
TranInfo trans_info; /* transformation info */
|
||||
|
||||
TileManager *original; /* pointer to original tiles */
|
||||
|
@ -157,7 +157,7 @@ TileManager * transform_core_do (GImage *gimage,
|
|||
GimpDrawable *drawable,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix matrix,
|
||||
GimpMatrix3 matrix,
|
||||
progress_func_t progress_callback,
|
||||
gpointer progress_data);
|
||||
TileManager * transform_core_cut (GImage *gimage,
|
||||
|
|
|
@ -49,6 +49,8 @@ libgimpi_a_SOURCES = \
|
|||
gimpsizeentry.h \
|
||||
gimpunitmenu.c \
|
||||
gimpunitmenu.h \
|
||||
gimpvector.c \
|
||||
gimpvector.h \
|
||||
gimpwidgets.c \
|
||||
gimpwidgets.h \
|
||||
gimpwire.c \
|
||||
|
@ -95,6 +97,8 @@ libgimp_la_SOURCES = \
|
|||
gimptile.c \
|
||||
gimpunit.c \
|
||||
gimpunit.h \
|
||||
gimpvector.c \
|
||||
gimpvector.h \
|
||||
gimpwire.c \
|
||||
gimpwire.h \
|
||||
gserialize.c \
|
||||
|
@ -151,6 +155,7 @@ gimpinclude_HEADERS = \
|
|||
gimpui.h \
|
||||
gimpunit.h \
|
||||
gimpunitmenu.h \
|
||||
gimpvector.h \
|
||||
gimpwidgets.h \
|
||||
gimpintl.h \
|
||||
gserialize.h \
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
#include "libgimp/parasite.h"
|
||||
#include "libgimp/parasiteP.h"
|
||||
#include "libgimp/gimpunit.h"
|
||||
#include "libgimp/gimpvector.h"
|
||||
|
||||
#include "libgimp/gimpcompat.h" /* to be removed in 1.3 */
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
|
|
|
@ -70,6 +70,9 @@ extern "C" {
|
|||
/* broken! -> #define CLAMP0255(a) ((a & 0xFFFFFF00)? (~(a>>31)) : a) */
|
||||
#define CLAMP0255(a) CLAMP(a,0,255)
|
||||
|
||||
#define gimp_deg_to_rad(angle) ((angle) * (2.0 * G_PI) / 360.0)
|
||||
#define gimp_rad_to_deg(angle) ((angle) * 360.0 / (2.0 * G_PI))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
|
|
@ -17,16 +17,14 @@
|
|||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <glib.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include "gimpmath.h"
|
||||
#include "gimpmatrix.h"
|
||||
|
||||
#define EPSILON 1e-6
|
||||
|
||||
|
||||
/**
|
||||
* gimp_matrix_transform_point:
|
||||
* gimp_matrix3_transform_point:
|
||||
* @matrix: The transformation matrix.
|
||||
* @x: The source X coordinate.
|
||||
* @y: The source Y coordinate.
|
||||
|
@ -36,11 +34,11 @@
|
|||
* Transforms a point in 2D as specified by the transformation matrix.
|
||||
*/
|
||||
void
|
||||
gimp_matrix_transform_point (GimpMatrix matrix,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gdouble *newx,
|
||||
gdouble *newy)
|
||||
gimp_matrix3_transform_point (GimpMatrix3 matrix,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gdouble *newx,
|
||||
gdouble *newy)
|
||||
{
|
||||
gdouble w;
|
||||
|
||||
|
@ -56,18 +54,18 @@ gimp_matrix_transform_point (GimpMatrix matrix,
|
|||
}
|
||||
|
||||
/**
|
||||
* gimp_matrix_mult:
|
||||
* gimp_matrix3_mult:
|
||||
* @matrix1: The first input matrix.
|
||||
* @matrix2: The second input matrix which will be oeverwritten ba the result.
|
||||
*
|
||||
* Multiplies two matrices and puts the result into the second one.
|
||||
*/
|
||||
void
|
||||
gimp_matrix_mult (GimpMatrix matrix1,
|
||||
GimpMatrix matrix2)
|
||||
gimp_matrix3_mult (GimpMatrix3 matrix1,
|
||||
GimpMatrix3 matrix2)
|
||||
{
|
||||
gint i, j;
|
||||
GimpMatrix tmp;
|
||||
GimpMatrix3 tmp;
|
||||
gdouble t1, t2, t3;
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
|
@ -84,27 +82,27 @@ gimp_matrix_mult (GimpMatrix matrix1,
|
|||
}
|
||||
|
||||
/* put the results in matrix2 */
|
||||
memcpy (&matrix2[0][0], &tmp[0][0], sizeof(GimpMatrix));
|
||||
memcpy (&matrix2[0][0], &tmp[0][0], sizeof (GimpMatrix3));
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_matrix_identity:
|
||||
* gimp_matrix3_identity:
|
||||
* @matrix: A matrix.
|
||||
*
|
||||
* Sets the matrix to the identity matrix.
|
||||
*/
|
||||
void
|
||||
gimp_matrix_identity (GimpMatrix matrix)
|
||||
gimp_matrix3_identity (GimpMatrix3 matrix)
|
||||
{
|
||||
static GimpMatrix identity = { {1.0, 0.0, 0.0},
|
||||
{0.0, 1.0, 0.0},
|
||||
{0.0, 0.0, 1.0} };
|
||||
static GimpMatrix3 identity = { { 1.0, 0.0, 0.0 },
|
||||
{ 0.0, 1.0, 0.0 },
|
||||
{ 0.0, 0.0, 1.0 } };
|
||||
|
||||
memcpy (&matrix[0][0], &identity[0][0], sizeof(GimpMatrix));
|
||||
memcpy (&matrix[0][0], &identity[0][0], sizeof (GimpMatrix3));
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_matrix_translate:
|
||||
* gimp_matrix3_translate:
|
||||
* @matrix: The matrix that is to be translated.
|
||||
* @x: Translation in X direction.
|
||||
* @y: Translation in Y direction.
|
||||
|
@ -112,9 +110,9 @@ gimp_matrix_identity (GimpMatrix matrix)
|
|||
* Translates the matrix by x and y.
|
||||
*/
|
||||
void
|
||||
gimp_matrix_translate (GimpMatrix matrix,
|
||||
gdouble x,
|
||||
gdouble y)
|
||||
gimp_matrix3_translate (GimpMatrix3 matrix,
|
||||
gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
gdouble g, h, i;
|
||||
|
||||
|
@ -122,16 +120,16 @@ gimp_matrix_translate (GimpMatrix matrix,
|
|||
h = matrix[2][1];
|
||||
i = matrix[2][2];
|
||||
|
||||
matrix[0][0] += x*g;
|
||||
matrix[0][1] += x*h;
|
||||
matrix[0][2] += x*i;
|
||||
matrix[1][0] += y*g;
|
||||
matrix[1][1] += y*h;
|
||||
matrix[1][2] += y*i;
|
||||
matrix[0][0] += x * g;
|
||||
matrix[0][1] += x * h;
|
||||
matrix[0][2] += x * i;
|
||||
matrix[1][0] += y * g;
|
||||
matrix[1][1] += y * h;
|
||||
matrix[1][2] += y * i;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_matrix_scale:
|
||||
* gimp_matrix3_scale:
|
||||
* @matrix: The matrix that is to be scaled.
|
||||
* @x: X scale factor.
|
||||
* @y: Y scale factor.
|
||||
|
@ -139,9 +137,9 @@ gimp_matrix_translate (GimpMatrix matrix,
|
|||
* Scales the matrix by x and y
|
||||
*/
|
||||
void
|
||||
gimp_matrix_scale (GimpMatrix matrix,
|
||||
gdouble x,
|
||||
gdouble y)
|
||||
gimp_matrix3_scale (GimpMatrix3 matrix,
|
||||
gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
matrix[0][0] *= x;
|
||||
matrix[0][1] *= x;
|
||||
|
@ -153,30 +151,30 @@ gimp_matrix_scale (GimpMatrix matrix,
|
|||
}
|
||||
|
||||
/**
|
||||
* gimp_matrix_rotate:
|
||||
* gimp_matrix3_rotate:
|
||||
* @matrix: The matrix that is to be rotated.
|
||||
* @theta: The angle of rotation (in radians).
|
||||
*
|
||||
* Rotates the matrix by theta degrees.
|
||||
*/
|
||||
void
|
||||
gimp_matrix_rotate (GimpMatrix matrix,
|
||||
gdouble theta)
|
||||
gimp_matrix3_rotate (GimpMatrix3 matrix,
|
||||
gdouble theta)
|
||||
{
|
||||
gdouble t1, t2;
|
||||
gdouble cost, sint;
|
||||
|
||||
cost = cos(theta);
|
||||
sint = sin(theta);
|
||||
cost = cos (theta);
|
||||
sint = sin (theta);
|
||||
|
||||
t1 = matrix[0][0];
|
||||
t2 = matrix[1][0];
|
||||
matrix[0][0] = cost*t1 - sint*t2;
|
||||
matrix[1][0] = sint*t1 + cost*t2;
|
||||
matrix[0][0] = cost * t1 - sint * t2;
|
||||
matrix[1][0] = sint * t1 + cost * t2;
|
||||
|
||||
t1 = matrix[0][1];
|
||||
t2 = matrix[1][1];
|
||||
matrix[0][1] = cost*t1 - sint*t2;
|
||||
matrix[0][1] = cost * t1 - sint * t2;
|
||||
matrix[1][1] = sint*t1 + cost*t2;
|
||||
|
||||
t1 = matrix[0][2];
|
||||
|
@ -186,15 +184,15 @@ gimp_matrix_rotate (GimpMatrix matrix,
|
|||
}
|
||||
|
||||
/**
|
||||
* gimp_matrix_xshear:
|
||||
* gimp_matrix3_xshear:
|
||||
* @matrix: The matrix that is to be sheared.
|
||||
* @amount: X shear amount.
|
||||
*
|
||||
* Shears the matrix in the X direction.
|
||||
*/
|
||||
void
|
||||
gimp_matrix_xshear (GimpMatrix matrix,
|
||||
gdouble amount)
|
||||
gimp_matrix3_xshear (GimpMatrix3 matrix,
|
||||
gdouble amount)
|
||||
{
|
||||
matrix[0][0] += amount * matrix[1][0];
|
||||
matrix[0][1] += amount * matrix[1][1];
|
||||
|
@ -202,15 +200,15 @@ gimp_matrix_xshear (GimpMatrix matrix,
|
|||
}
|
||||
|
||||
/**
|
||||
* gimp_matrix_yshear:
|
||||
* gimp_matrix3_yshear:
|
||||
* @matrix: The matrix that is to be sheared.
|
||||
* @amount: Y shear amount.
|
||||
*
|
||||
* Shears the matrix in the Y direction.
|
||||
*/
|
||||
void
|
||||
gimp_matrix_yshear (GimpMatrix matrix,
|
||||
gdouble amount)
|
||||
gimp_matrix3_yshear (GimpMatrix3 matrix,
|
||||
gdouble amount)
|
||||
{
|
||||
matrix[1][0] += amount * matrix[0][0];
|
||||
matrix[1][1] += amount * matrix[0][1];
|
||||
|
@ -218,7 +216,7 @@ gimp_matrix_yshear (GimpMatrix matrix,
|
|||
}
|
||||
|
||||
/**
|
||||
* gimp_matrix_determinant:
|
||||
* gimp_matrix3_determinant:
|
||||
* @matrix: The input matrix.
|
||||
*
|
||||
* Calculates the determinant of the given matrix.
|
||||
|
@ -226,7 +224,7 @@ gimp_matrix_yshear (GimpMatrix matrix,
|
|||
* Returns: The determinant.
|
||||
*/
|
||||
gdouble
|
||||
gimp_matrix_determinant (GimpMatrix matrix)
|
||||
gimp_matrix3_determinant (GimpMatrix3 matrix)
|
||||
{
|
||||
gdouble determinant;
|
||||
|
||||
|
@ -241,19 +239,19 @@ gimp_matrix_determinant (GimpMatrix matrix)
|
|||
}
|
||||
|
||||
/**
|
||||
* gimp_matrix_invert:
|
||||
* gimp_matrix3_invert:
|
||||
* @matrix: The matrix that is to be inverted.
|
||||
* @matrix_inv: A matrix the inverted matrix should be written into.
|
||||
*
|
||||
* Inverts the given matrix.
|
||||
*/
|
||||
void
|
||||
gimp_matrix_invert (GimpMatrix matrix,
|
||||
GimpMatrix matrix_inv)
|
||||
gimp_matrix3_invert (GimpMatrix3 matrix,
|
||||
GimpMatrix3 matrix_inv)
|
||||
{
|
||||
gdouble det_1;
|
||||
|
||||
det_1 = gimp_matrix_determinant (matrix);
|
||||
det_1 = gimp_matrix3_determinant (matrix);
|
||||
|
||||
if (det_1 == 0.0)
|
||||
return;
|
||||
|
@ -290,17 +288,17 @@ gimp_matrix_invert (GimpMatrix matrix,
|
|||
|
||||
|
||||
/**
|
||||
* gimp_matrix_duplicate:
|
||||
* gimp_matrix3_duplicate:
|
||||
* @src: The source matrix.
|
||||
* @target: The destination matrix.
|
||||
*
|
||||
* Copies the source matrix to the destination matrix.
|
||||
*/
|
||||
void
|
||||
gimp_matrix_duplicate (GimpMatrix src,
|
||||
GimpMatrix target)
|
||||
gimp_matrix3_duplicate (GimpMatrix3 src,
|
||||
GimpMatrix3 target)
|
||||
{
|
||||
memcpy (&target[0][0], &src[0][0], sizeof(GimpMatrix));
|
||||
memcpy (&target[0][0], &src[0][0], sizeof (GimpMatrix3));
|
||||
}
|
||||
|
||||
|
||||
|
@ -308,7 +306,7 @@ gimp_matrix_duplicate (GimpMatrix src,
|
|||
|
||||
|
||||
/**
|
||||
* gimp_matrix_is_diagonal:
|
||||
* gimp_matrix3_is_diagonal:
|
||||
* @matrix: The matrix that is to be tested.
|
||||
*
|
||||
* Checks if the given matrix is diagonal.
|
||||
|
@ -316,7 +314,7 @@ gimp_matrix_duplicate (GimpMatrix src,
|
|||
* Returns: TRUE if the matrix is diagonal.
|
||||
*/
|
||||
gboolean
|
||||
gimp_matrix_is_diagonal (GimpMatrix matrix)
|
||||
gimp_matrix3_is_diagonal (GimpMatrix3 matrix)
|
||||
{
|
||||
gint i, j;
|
||||
|
||||
|
@ -333,7 +331,7 @@ gimp_matrix_is_diagonal (GimpMatrix matrix)
|
|||
}
|
||||
|
||||
/**
|
||||
* gimp_matrix_is_identity:
|
||||
* gimp_matrix3_is_identity:
|
||||
* @matrix: The matrix that is to be tested.
|
||||
*
|
||||
* Checks if the given matrix is the identity matrix.
|
||||
|
@ -341,7 +339,7 @@ gimp_matrix_is_diagonal (GimpMatrix matrix)
|
|||
* Returns: TRUE if the matrix is the identity matrix.
|
||||
*/
|
||||
gboolean
|
||||
gimp_matrix_is_identity (GimpMatrix matrix)
|
||||
gimp_matrix3_is_identity (GimpMatrix3 matrix)
|
||||
{
|
||||
gint i,j;
|
||||
|
||||
|
@ -372,7 +370,7 @@ gimp_matrix_is_identity (GimpMatrix matrix)
|
|||
|
||||
|
||||
/**
|
||||
* gimp_matrix_is_simple:
|
||||
* gimp_matrix3_is_simple:
|
||||
* @matrix: The matrix that is to be tested.
|
||||
*
|
||||
* Checks if we'll need to interpolate when applying this matrix as
|
||||
|
@ -382,7 +380,7 @@ gimp_matrix_is_identity (GimpMatrix matrix)
|
|||
* 0 or 1
|
||||
*/
|
||||
gboolean
|
||||
gimp_matrix_is_simple (GimpMatrix matrix)
|
||||
gimp_matrix3_is_simple (GimpMatrix3 matrix)
|
||||
{
|
||||
gdouble absm;
|
||||
gint i, j;
|
||||
|
@ -399,3 +397,14 @@ gimp_matrix_is_simple (GimpMatrix matrix)
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_matrix4_to_deg (GimpMatrix4 matrix,
|
||||
gdouble *a,
|
||||
gdouble *b,
|
||||
gdouble *c)
|
||||
{
|
||||
*a = 180 * (asin (matrix[1][0]) / G_PI_2);
|
||||
*b = 180 * (asin (matrix[2][0]) / G_PI_2);
|
||||
*c = 180 * (asin (matrix[2][1]) / G_PI_2);
|
||||
}
|
||||
|
|
|
@ -17,47 +17,56 @@
|
|||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMPMATRIX_H__
|
||||
#define __GIMPMATRIX_H__
|
||||
#ifndef __GIMP_MATRIX_H__
|
||||
#define __GIMP_MATRIX_H__
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef gdouble GimpMatrix[3][3];
|
||||
typedef gdouble GimpMatrix3[3][3];
|
||||
typedef gdouble GimpMatrix4[4][4];
|
||||
|
||||
void gimp_matrix_transform_point (GimpMatrix matrix,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gdouble *newx,
|
||||
gdouble *newy);
|
||||
void gimp_matrix_mult (GimpMatrix matrix1,
|
||||
GimpMatrix matrix2);
|
||||
void gimp_matrix_identity (GimpMatrix matrix);
|
||||
void gimp_matrix_translate (GimpMatrix matrix,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
void gimp_matrix_scale (GimpMatrix matrix,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
void gimp_matrix_rotate (GimpMatrix matrix,
|
||||
gdouble theta);
|
||||
void gimp_matrix_xshear (GimpMatrix matrix,
|
||||
gdouble amount);
|
||||
void gimp_matrix_yshear (GimpMatrix matrix,
|
||||
gdouble amount);
|
||||
gdouble gimp_matrix_determinant (GimpMatrix matrix);
|
||||
void gimp_matrix_invert (GimpMatrix matrix,
|
||||
GimpMatrix matrix_inv);
|
||||
void gimp_matrix_duplicate (GimpMatrix src,
|
||||
GimpMatrix target);
|
||||
void gimp_matrix3_transform_point (GimpMatrix3 matrix,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gdouble *newx,
|
||||
gdouble *newy);
|
||||
void gimp_matrix3_mult (GimpMatrix3 matrix1,
|
||||
GimpMatrix3 matrix2);
|
||||
void gimp_matrix3_identity (GimpMatrix3 matrix);
|
||||
void gimp_matrix3_translate (GimpMatrix3 matrix,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
void gimp_matrix3_scale (GimpMatrix3 matrix,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
void gimp_matrix3_rotate (GimpMatrix3 matrix,
|
||||
gdouble theta);
|
||||
void gimp_matrix3_xshear (GimpMatrix3 matrix,
|
||||
gdouble amount);
|
||||
void gimp_matrix3_yshear (GimpMatrix3 matrix,
|
||||
gdouble amount);
|
||||
gdouble gimp_matrix3_determinant (GimpMatrix3 matrix);
|
||||
void gimp_matrix3_invert (GimpMatrix3 matrix,
|
||||
GimpMatrix3 matrix_inv);
|
||||
void gimp_matrix3_duplicate (GimpMatrix3 src,
|
||||
GimpMatrix3 target);
|
||||
|
||||
gboolean gimp_matrix_is_diagonal (GimpMatrix matrix);
|
||||
gboolean gimp_matrix_is_identity (GimpMatrix matrix);
|
||||
gboolean gimp_matrix_is_simple (GimpMatrix matrix);
|
||||
gboolean gimp_matrix3_is_diagonal (GimpMatrix3 matrix);
|
||||
gboolean gimp_matrix3_is_identity (GimpMatrix3 matrix);
|
||||
gboolean gimp_matrix3_is_simple (GimpMatrix3 matrix);
|
||||
|
||||
|
||||
void gimp_matrix4_to_deg (GimpMatrix4 matrix,
|
||||
gdouble *a,
|
||||
gdouble *b,
|
||||
gdouble *c);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __GIMPMATRIX_H__ */
|
||||
#endif /* __GIMP_MATRIX_H__ */
|
||||
|
|
|
@ -0,0 +1,396 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* The gimp_vector* functions were taken from:
|
||||
* GCK - The General Convenience Kit
|
||||
* Copyright (C) 1996 Tom Bech
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/**********************************************/
|
||||
/* A little collection of useful vector stuff */
|
||||
/**********************************************/
|
||||
|
||||
#include "gimpmath.h"
|
||||
#include "gimpvector.h"
|
||||
|
||||
/*************************/
|
||||
/* Some useful constants */
|
||||
/*************************/
|
||||
|
||||
const GimpVector2 gimp_vector2_zero = { 0.0, 0.0 };
|
||||
const GimpVector2 gimp_vector2_unit_x = { 1.0, 0.0 };
|
||||
const GimpVector2 gimp_vector2_unit_y = { 0.0, 1.0 };
|
||||
|
||||
const GimpVector3 gimp_vector3_zero = { 0.0, 0.0, 0.0 };
|
||||
const GimpVector3 gimp_vector3_unit_x = { 1.0, 0.0, 0.0 };
|
||||
const GimpVector3 gimp_vector3_unit_y = { 0.0, 1.0, 0.0 };
|
||||
const GimpVector3 gimp_vector3_unit_z = { 0.0, 0.0, 1.0 };
|
||||
|
||||
/**************************************/
|
||||
/* Three dimensional vector functions */
|
||||
/**************************************/
|
||||
|
||||
gdouble
|
||||
gimp_vector2_inner_product (GimpVector2 *a,
|
||||
GimpVector2 *b)
|
||||
{
|
||||
g_assert (a != NULL);
|
||||
g_assert (b != NULL);
|
||||
|
||||
return (a->x * b->x + a->y * b->y);
|
||||
}
|
||||
|
||||
GimpVector2
|
||||
gimp_vector2_cross_product (GimpVector2 *a,
|
||||
GimpVector2 *b)
|
||||
{
|
||||
GimpVector2 normal;
|
||||
|
||||
g_assert (a != NULL);
|
||||
g_assert (b != NULL);
|
||||
|
||||
normal.x = a->x * b->y - a->y * b->x;
|
||||
normal.y = a->y * b->x - a->x * b->y;
|
||||
|
||||
return normal;
|
||||
}
|
||||
|
||||
gdouble
|
||||
gimp_vector2_length (GimpVector2 *a)
|
||||
{
|
||||
g_assert (a != NULL);
|
||||
|
||||
return (sqrt (a->x * a->x + a->y * a->y));
|
||||
}
|
||||
|
||||
void
|
||||
gimp_vector2_normalize (GimpVector2 *a)
|
||||
{
|
||||
gdouble len;
|
||||
|
||||
g_assert (a != NULL);
|
||||
|
||||
len = gimp_vector2_length (a);
|
||||
if (len != 0.0)
|
||||
{
|
||||
len = 1.0 / len;
|
||||
a->x = a->x * len;
|
||||
a->y = a->y * len;
|
||||
}
|
||||
else
|
||||
{
|
||||
*a = gimp_vector2_zero;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_vector2_mul (GimpVector2 *a,
|
||||
double b)
|
||||
{
|
||||
g_assert (a != NULL);
|
||||
|
||||
a->x = a->x * b;
|
||||
a->y = a->y * b;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_vector2_sub (GimpVector2 *c,
|
||||
GimpVector2 *a,
|
||||
GimpVector2 *b)
|
||||
{
|
||||
g_assert (a != NULL);
|
||||
g_assert (b != NULL);
|
||||
g_assert (c != NULL);
|
||||
|
||||
c->x = a->x - b->x;
|
||||
c->y = a->y - b->y;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_vector2_set (GimpVector2 *a,
|
||||
gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
g_assert (a != NULL);
|
||||
|
||||
a->x = x;
|
||||
a->y = y;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_vector2_add (GimpVector2 *c,
|
||||
GimpVector2 *a,
|
||||
GimpVector2 *b)
|
||||
{
|
||||
g_assert (a != NULL);
|
||||
g_assert (b != NULL);
|
||||
g_assert (c != NULL);
|
||||
|
||||
c->x = a->x + b->x;
|
||||
c->y = a->y + b->y;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_vector2_neg (GimpVector2 *a)
|
||||
{
|
||||
g_assert (a != NULL);
|
||||
|
||||
a->x *= -1.0;
|
||||
a->y *= -1.0;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_vector2_rotate (GimpVector2 *v,
|
||||
gdouble alpha)
|
||||
{
|
||||
GimpVector2 s;
|
||||
|
||||
g_assert (v != NULL);
|
||||
|
||||
s.x = cos (alpha) * v->x + sin (alpha) * v->y;
|
||||
s.y = cos (alpha) * v->y - sin (alpha) * v->x;
|
||||
|
||||
*v = s;
|
||||
}
|
||||
|
||||
/**************************************/
|
||||
/* Three dimensional vector functions */
|
||||
/**************************************/
|
||||
|
||||
gdouble
|
||||
gimp_vector3_inner_product (GimpVector3 *a,
|
||||
GimpVector3 *b)
|
||||
{
|
||||
g_assert (a != NULL);
|
||||
g_assert (b != NULL);
|
||||
|
||||
return (a->x * b->x + a->y * b->y + a->z * b->z);
|
||||
}
|
||||
|
||||
GimpVector3
|
||||
gimp_vector3_cross_product (GimpVector3 *a,
|
||||
GimpVector3 *b)
|
||||
{
|
||||
GimpVector3 normal;
|
||||
|
||||
g_assert (a != NULL);
|
||||
g_assert (b != NULL);
|
||||
|
||||
normal.x = a->y * b->z - a->z * b->y;
|
||||
normal.y = a->z * b->x - a->x * b->z;
|
||||
normal.z = a->x * b->y - a->y * b->x;
|
||||
|
||||
return normal;
|
||||
}
|
||||
|
||||
gdouble
|
||||
gimp_vector3_length (GimpVector3 *a)
|
||||
{
|
||||
g_assert (a != NULL);
|
||||
|
||||
return (sqrt (a->x * a->x + a->y * a->y + a->z * a->z));
|
||||
}
|
||||
|
||||
void
|
||||
gimp_vector3_normalize (GimpVector3 *a)
|
||||
{
|
||||
gdouble len;
|
||||
|
||||
g_assert (a != NULL);
|
||||
|
||||
len = gimp_vector3_length (a);
|
||||
if (len != 0.0)
|
||||
{
|
||||
len = 1.0 / len;
|
||||
a->x = a->x * len;
|
||||
a->y = a->y * len;
|
||||
a->z = a->z * len;
|
||||
}
|
||||
else
|
||||
{
|
||||
*a = gimp_vector3_zero;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_vector3_mul (GimpVector3 *a,
|
||||
gdouble b)
|
||||
{
|
||||
g_assert (a != NULL);
|
||||
|
||||
a->x = a->x * b;
|
||||
a->y = a->y * b;
|
||||
a->z = a->z * b;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_vector3_sub (GimpVector3 *c,
|
||||
GimpVector3 *a,
|
||||
GimpVector3 *b)
|
||||
{
|
||||
g_assert (a != NULL);
|
||||
g_assert (b != NULL);
|
||||
g_assert (c != NULL);
|
||||
|
||||
c->x = a->x - b->x;
|
||||
c->y = a->y - b->y;
|
||||
c->z = a->z - b->z;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_vector3_set (GimpVector3 *a,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gdouble z)
|
||||
{
|
||||
g_assert (a != NULL);
|
||||
|
||||
a->x = x;
|
||||
a->y = y;
|
||||
a->z = z;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_vector3_add (GimpVector3 *c,
|
||||
GimpVector3 *a,
|
||||
GimpVector3 *b)
|
||||
{
|
||||
g_assert (a != NULL);
|
||||
g_assert (b != NULL);
|
||||
g_assert (c != NULL);
|
||||
|
||||
c->x = a->x + b->x;
|
||||
c->y = a->y + b->y;
|
||||
c->z = a->z + b->z;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_vector3_neg (GimpVector3 *a)
|
||||
{
|
||||
g_assert (a != NULL);
|
||||
|
||||
a->x *= -1.0;
|
||||
a->y *= -1.0;
|
||||
a->z *= -1.0;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_vector3_rotate (GimpVector3 *v,
|
||||
gdouble alpha,
|
||||
gdouble beta,
|
||||
gdouble gamma)
|
||||
{
|
||||
GimpVector3 s, t;
|
||||
|
||||
g_assert (v != NULL);
|
||||
|
||||
/* First we rotate it around the Z axis (XY plane).. */
|
||||
/* ================================================= */
|
||||
|
||||
s.x = cos (alpha) * v->x + sin (alpha) * v->y;
|
||||
s.y = cos (alpha) * v->y - sin (alpha) * v->x;
|
||||
|
||||
/* ..then around the Y axis (XZ plane).. */
|
||||
/* ===================================== */
|
||||
|
||||
t = s;
|
||||
|
||||
v->x = cos (beta) *t.x + sin (beta) * v->z;
|
||||
s.z = cos (beta) *v->z - sin (beta) * t.x;
|
||||
|
||||
/* ..and at last around the X axis (YZ plane) */
|
||||
/* ========================================== */
|
||||
|
||||
v->y = cos (gamma) * t.y + sin (gamma) * s.z;
|
||||
v->z = cos (gamma) * s.z - sin (gamma) * t.y;
|
||||
}
|
||||
|
||||
/******************************************************************/
|
||||
/* Compute screen (sx,sy)-(sx+w,sy+h) to 3D unit square mapping. */
|
||||
/* The plane to map to is given in the z field of p. The observer */
|
||||
/* is located at position vp (vp->z!=0.0). */
|
||||
/******************************************************************/
|
||||
|
||||
void
|
||||
gimp_vector_2d_to_3d (gint sx,
|
||||
gint sy,
|
||||
gint w,
|
||||
gint h,
|
||||
gint x,
|
||||
gint y,
|
||||
GimpVector3 *vp,
|
||||
GimpVector3 *p)
|
||||
{
|
||||
gdouble t = 0.0;
|
||||
|
||||
g_assert (vp != NULL);
|
||||
g_assert (p != NULL);
|
||||
|
||||
if (vp->x != 0.0)
|
||||
t = (p->z - vp->z) / vp->z;
|
||||
|
||||
if (t != 0.0)
|
||||
{
|
||||
p->x = vp->x + t * (vp->x - ((gdouble) (x - sx) / (gdouble) w));
|
||||
p->y = vp->y + t * (vp->y - ((gdouble) (y - sy) / (gdouble) h));
|
||||
}
|
||||
else
|
||||
{
|
||||
p->x = (gdouble) (x - sx) / (gdouble) w;
|
||||
p->y = (gdouble) (y - sy) / (gdouble) h;
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************/
|
||||
/* Convert the given 3D point to 2D (project it onto the */
|
||||
/* viewing plane, (sx,sy,0)-(sx+w,sy+h,0). The input is */
|
||||
/* assumed to be in the unit square (0,0,z)-(1,1,z). */
|
||||
/* The viewpoint of the observer is passed in vp. */
|
||||
/*********************************************************/
|
||||
|
||||
void
|
||||
gimp_vector_3d_to_2d (gint sx,
|
||||
gint sy,
|
||||
gint w,
|
||||
gint h,
|
||||
gdouble *x,
|
||||
gdouble *y,
|
||||
GimpVector3 *vp,
|
||||
GimpVector3 *p)
|
||||
{
|
||||
gdouble t;
|
||||
GimpVector3 dir;
|
||||
|
||||
g_assert (vp != NULL);
|
||||
g_assert (p != NULL);
|
||||
|
||||
gimp_vector3_sub (&dir, p, vp);
|
||||
gimp_vector3_normalize (&dir);
|
||||
|
||||
if (dir.z != 0.0)
|
||||
{
|
||||
t = (-1.0 * vp->z) / dir.z;
|
||||
*x = (gdouble) sx + ((vp->x + t * dir.x) * (gdouble) w);
|
||||
*y = (gdouble) sy + ((vp->y + t * dir.y) * (gdouble) h);
|
||||
}
|
||||
else
|
||||
{
|
||||
*x = (gdouble) sx + (p->x * (gdouble) w);
|
||||
*y = (gdouble) sy + (p->y * (gdouble) h);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,128 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* The gimp_vector* functions were taken from:
|
||||
* GCK - The General Convenience Kit
|
||||
* Copyright (C) 1996 Tom Bech
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_VECTOR_H__
|
||||
#define __GIMP_VECTOR_H__
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct _GimpVector2 GimpVector2;
|
||||
typedef struct _GimpVector3 GimpVector3;
|
||||
typedef struct _GimpVector4 GimpVector4;
|
||||
|
||||
struct _GimpVector2
|
||||
{
|
||||
gdouble x, y;
|
||||
};
|
||||
|
||||
struct _GimpVector3
|
||||
{
|
||||
gdouble x, y, z;
|
||||
};
|
||||
|
||||
struct _GimpVector4
|
||||
{
|
||||
gdouble x, y, z, w;
|
||||
};
|
||||
|
||||
/* Two dimensional vector functions */
|
||||
/* ================================ */
|
||||
|
||||
gdouble gimp_vector2_inner_product (GimpVector2 *a,
|
||||
GimpVector2 *b);
|
||||
GimpVector2 gimp_vector2_cross_product (GimpVector2 *a,
|
||||
GimpVector2 *b);
|
||||
double gimp_vector2_length (GimpVector2 *a);
|
||||
void gimp_vector2_normalize (GimpVector2 *a);
|
||||
void gimp_vector2_mul (GimpVector2 *a,
|
||||
gdouble b);
|
||||
void gimp_vector2_sub (GimpVector2 *c,
|
||||
GimpVector2 *a,
|
||||
GimpVector2 *b);
|
||||
void gimp_vector2_set (GimpVector2 *a,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
void gimp_vector2_add (GimpVector2 *c,
|
||||
GimpVector2 *a,
|
||||
GimpVector2 *b);
|
||||
void gimp_vector2_neg (GimpVector2 *a);
|
||||
void gimp_vector2_rotate (GimpVector2 *v,
|
||||
gdouble alpha);
|
||||
|
||||
/* Three dimensional vector functions */
|
||||
/* ================================== */
|
||||
|
||||
gdouble gimp_vector3_inner_product (GimpVector3 *a,
|
||||
GimpVector3 *b);
|
||||
GimpVector3 gimp_vector3_cross_product (GimpVector3 *a,
|
||||
GimpVector3 *b);
|
||||
double gimp_vector3_length (GimpVector3 *a);
|
||||
void gimp_vector3_normalize (GimpVector3 *a);
|
||||
void gimp_vector3_mul (GimpVector3 *a,
|
||||
gdouble b);
|
||||
void gimp_vector3_sub (GimpVector3 *c,
|
||||
GimpVector3 *a,
|
||||
GimpVector3 *b);
|
||||
void gimp_vector3_set (GimpVector3 *a,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gdouble z);
|
||||
void gimp_vector3_add (GimpVector3 *c,
|
||||
GimpVector3 *a,
|
||||
GimpVector3 *b);
|
||||
void gimp_vector3_neg (GimpVector3 *a);
|
||||
void gimp_vector3_rotate (GimpVector3 *v,
|
||||
gdouble alpha,
|
||||
gdouble beta,
|
||||
gdouble gamma);
|
||||
|
||||
/* 2d <-> 3d Vector projection functions */
|
||||
/* ===================================== */
|
||||
|
||||
void gimp_vector_2d_to_3d (gint sx,
|
||||
gint sy,
|
||||
gint w,
|
||||
gint h,
|
||||
gint x,
|
||||
gint y,
|
||||
GimpVector3 *vp,
|
||||
GimpVector3 *p);
|
||||
|
||||
void gimp_vector_3d_to_2d (gint sx,
|
||||
gint sy,
|
||||
gint w,
|
||||
gint h,
|
||||
gdouble *x,
|
||||
gdouble *y,
|
||||
GimpVector3 *vp,
|
||||
GimpVector3 *p);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __GIMP_VECTOR_H__ */
|
|
@ -16,7 +16,7 @@ void init_compute(void)
|
|||
|
||||
void render(gdouble x,gdouble y,GckRGB *col)
|
||||
{
|
||||
GckVector3 pos;
|
||||
GimpVector3 pos;
|
||||
|
||||
pos=int_to_pos(x,y);
|
||||
|
||||
|
@ -33,7 +33,7 @@ void compute_image(void)
|
|||
gint xcount,ycount;
|
||||
GckRGB color;
|
||||
glong progress_counter=0;
|
||||
GckVector3 p;
|
||||
GimpVector3 p;
|
||||
gint32 new_image_id=-1,new_layer_id=-1,index;
|
||||
guchar *row = NULL, obpp;
|
||||
|
||||
|
|
|
@ -114,9 +114,9 @@ gint check_bounds(gint x,gint y)
|
|||
return(TRUE);
|
||||
}
|
||||
|
||||
GckVector3 int_to_pos(gint x,gint y)
|
||||
GimpVector3 int_to_pos(gint x,gint y)
|
||||
{
|
||||
GckVector3 pos;
|
||||
GimpVector3 pos;
|
||||
|
||||
if (width>=height)
|
||||
{
|
||||
|
@ -137,9 +137,9 @@ GckVector3 int_to_pos(gint x,gint y)
|
|||
return(pos);
|
||||
}
|
||||
|
||||
GckVector3 int_to_posf(gdouble x,gdouble y)
|
||||
GimpVector3 int_to_posf(gdouble x,gdouble y)
|
||||
{
|
||||
GckVector3 pos;
|
||||
GimpVector3 pos;
|
||||
|
||||
if (width>=height)
|
||||
{
|
||||
|
|
|
@ -38,8 +38,8 @@ GckRGB peek (gint x,gint y);
|
|||
GckRGB peek_env_map (gint x,gint y);
|
||||
void poke (gint x,gint y,GckRGB *color);
|
||||
gint check_bounds (gint x,gint y);
|
||||
GckVector3 int_to_pos (gint x,gint y);
|
||||
GckVector3 int_to_posf (gdouble x,gdouble y);
|
||||
GimpVector3 int_to_pos (gint x,gint y);
|
||||
GimpVector3 int_to_posf (gdouble x,gdouble y);
|
||||
extern void pos_to_int (gdouble x,gdouble y,gint *scr_x,gint *scr_y);
|
||||
extern void pos_to_float (gdouble x,gdouble y,gdouble *xf,gdouble *yf);
|
||||
extern GckRGB get_image_color (gdouble u,gdouble v,gint *inside);
|
||||
|
|
|
@ -42,11 +42,11 @@ void lighting_noninteractive (GDrawable *drawable);
|
|||
|
||||
void set_default_settings(void)
|
||||
{
|
||||
gck_vector3_set(&mapvals.viewpoint, 0.5, 0.5, 0.25);
|
||||
gck_vector3_set(&mapvals.planenormal, 0.0, 0.0, 1.0);
|
||||
gimp_vector3_set(&mapvals.viewpoint, 0.5, 0.5, 0.25);
|
||||
gimp_vector3_set(&mapvals.planenormal, 0.0, 0.0, 1.0);
|
||||
|
||||
gck_vector3_set(&mapvals.lightsource.position, 1.0, 0.0, 1.0);
|
||||
gck_vector3_set(&mapvals.lightsource.direction, -1.0, -1.0, 1.0);
|
||||
gimp_vector3_set(&mapvals.lightsource.position, 1.0, 0.0, 1.0);
|
||||
gimp_vector3_set(&mapvals.lightsource.direction, -1.0, -1.0, 1.0);
|
||||
|
||||
gck_rgb_set(&mapvals.lightsource.color, 1.0, 1.0, 1.0);
|
||||
mapvals.lightsource.intensity = 1.0;
|
||||
|
|
|
@ -51,8 +51,8 @@ typedef struct
|
|||
typedef struct
|
||||
{
|
||||
LightType type;
|
||||
GckVector3 position;
|
||||
GckVector3 direction;
|
||||
GimpVector3 position;
|
||||
GimpVector3 direction;
|
||||
GckRGB color;
|
||||
gdouble intensity;
|
||||
} LightSettings;
|
||||
|
@ -66,8 +66,8 @@ typedef struct {
|
|||
/* Render variables */
|
||||
/* ================ */
|
||||
|
||||
GckVector3 viewpoint;
|
||||
GckVector3 planenormal;
|
||||
GimpVector3 viewpoint;
|
||||
GimpVector3 planenormal;
|
||||
LightSettings lightsource;
|
||||
MaterialSettings material;
|
||||
MaterialSettings ref_material;
|
||||
|
|
|
@ -27,7 +27,7 @@ void compute_preview (gint startx,gint starty,gint w,gint h)
|
|||
gdouble imagex,imagey;
|
||||
gint32 index=0;
|
||||
GckRGB color,darkcheck,lightcheck,temp;
|
||||
GckVector3 pos;
|
||||
GimpVector3 pos;
|
||||
get_ray_func ray_func;
|
||||
|
||||
if (xpostab_size != w)
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
#include "lighting_shade.h"
|
||||
|
||||
GckVector3 *triangle_normals[2] = { NULL, NULL };
|
||||
GckVector3 *vertex_normals[3] = { NULL, NULL, NULL };
|
||||
GimpVector3 *triangle_normals[2] = { NULL, NULL };
|
||||
GimpVector3 *vertex_normals[3] = { NULL, NULL, NULL };
|
||||
gdouble *heights[3] = { NULL, NULL, NULL };
|
||||
gdouble xstep,ystep;
|
||||
guchar *bumprow=NULL;
|
||||
|
@ -17,14 +17,14 @@ gint pre_h=-1;
|
|||
/* Phong shading */
|
||||
/*****************/
|
||||
|
||||
GckRGB phong_shade(GckVector3 *position,GckVector3 *viewpoint,
|
||||
GckVector3 *normal,GckVector3 *lightposition,
|
||||
GckRGB phong_shade(GimpVector3 *position,GimpVector3 *viewpoint,
|
||||
GimpVector3 *normal,GimpVector3 *lightposition,
|
||||
GckRGB *diff_col,GckRGB *spec_col,
|
||||
LightType light_type)
|
||||
{
|
||||
GckRGB ambient_color,diffuse_color,specular_color;
|
||||
gdouble nl,rv,dist;
|
||||
GckVector3 l,nn,v,n;
|
||||
GimpVector3 l,nn,v,n;
|
||||
|
||||
/* Compute ambient intensity */
|
||||
/* ========================= */
|
||||
|
@ -37,28 +37,28 @@ GckRGB phong_shade(GckVector3 *position,GckVector3 *viewpoint,
|
|||
/* ====================================== */
|
||||
|
||||
if (light_type==POINT_LIGHT)
|
||||
gck_vector3_sub(&l,lightposition,position);
|
||||
gimp_vector3_sub(&l,lightposition,position);
|
||||
else
|
||||
l=*lightposition;
|
||||
|
||||
dist=gck_vector3_length(&l);
|
||||
dist=gimp_vector3_length(&l);
|
||||
|
||||
if (dist!=0.0)
|
||||
gck_vector3_mul(&l,1.0/dist);
|
||||
gimp_vector3_mul(&l,1.0/dist);
|
||||
|
||||
nl=2.0*gck_vector3_inner_product(&n,&l);
|
||||
nl=2.0*gimp_vector3_inner_product(&n,&l);
|
||||
|
||||
if (nl>=0.0)
|
||||
{
|
||||
/* Compute (R*V)^alpha term of Phong's equation */
|
||||
/* ============================================ */
|
||||
|
||||
gck_vector3_sub(&v,viewpoint,position);
|
||||
gck_vector3_normalize(&v);
|
||||
gimp_vector3_sub(&v,viewpoint,position);
|
||||
gimp_vector3_normalize(&v);
|
||||
|
||||
gck_vector3_mul(&n,nl);
|
||||
gck_vector3_sub(&nn,&n,&l);
|
||||
rv=gck_vector3_inner_product(&nn,&v);
|
||||
gimp_vector3_mul(&n,nl);
|
||||
gimp_vector3_sub(&nn,&n,&l);
|
||||
rv=gimp_vector3_inner_product(&nn,&v);
|
||||
rv=pow(rv,mapvals.material.highlight);
|
||||
|
||||
/* Compute diffuse and specular intensity contribution */
|
||||
|
@ -83,9 +83,9 @@ GckRGB phong_shade(GckVector3 *position,GckVector3 *viewpoint,
|
|||
return(ambient_color);
|
||||
}
|
||||
|
||||
void get_normal(gdouble xf,gdouble yf,GckVector3 *normal)
|
||||
void get_normal(gdouble xf,gdouble yf,GimpVector3 *normal)
|
||||
{
|
||||
GckVector3 v1,v2,n;
|
||||
GimpVector3 v1,v2,n;
|
||||
gint numvecs=0,x,y,f;
|
||||
gdouble val,val1=-1.0,val2=-1.0,val3=-1.0,val4=-1.0, xstep,ystep;
|
||||
|
||||
|
@ -101,19 +101,19 @@ void get_normal(gdouble xf,gdouble yf,GckVector3 *normal)
|
|||
if (check_bounds(x+1,y)) val3=mapvals.bumpmax*get_map_value(&bump_region, xf+1.0,yf, &f)/255.0 - val;
|
||||
if (check_bounds(x,y+1)) val4=mapvals.bumpmax*get_map_value(&bump_region, xf,yf+1.0, &f)/255.0 - val;
|
||||
|
||||
gck_vector3_set(normal, 0.0,0.0,0.0);
|
||||
gimp_vector3_set(normal, 0.0,0.0,0.0);
|
||||
|
||||
if (val1!=-1.0 && val4!=-1.0)
|
||||
{
|
||||
v1.x=-xstep; v1.y=0.0; v1.z=val1;
|
||||
v2.x=0.0; v2.y=ystep; v2.z=val4;
|
||||
n=gck_vector3_cross_product(&v1,&v2);
|
||||
gck_vector3_normalize(&n);
|
||||
n=gimp_vector3_cross_product(&v1,&v2);
|
||||
gimp_vector3_normalize(&n);
|
||||
|
||||
if (n.z<0.0)
|
||||
n.z=-n.z;
|
||||
|
||||
gck_vector3_add(normal,normal,&n);
|
||||
gimp_vector3_add(normal,normal,&n);
|
||||
numvecs++;
|
||||
}
|
||||
|
||||
|
@ -121,13 +121,13 @@ void get_normal(gdouble xf,gdouble yf,GckVector3 *normal)
|
|||
{
|
||||
v1.x=-xstep; v1.y=0.0; v1.z=val1;
|
||||
v2.x=0.0; v2.y=-ystep; v2.z=val2;
|
||||
n=gck_vector3_cross_product(&v1,&v2);
|
||||
gck_vector3_normalize(&n);
|
||||
n=gimp_vector3_cross_product(&v1,&v2);
|
||||
gimp_vector3_normalize(&n);
|
||||
|
||||
if (n.z<0.0)
|
||||
n.z=-n.z;
|
||||
|
||||
gck_vector3_add(normal,normal,&n);
|
||||
gimp_vector3_add(normal,normal,&n);
|
||||
numvecs++;
|
||||
}
|
||||
|
||||
|
@ -135,13 +135,13 @@ void get_normal(gdouble xf,gdouble yf,GckVector3 *normal)
|
|||
{
|
||||
v1.x=0.0; v1.y=-ystep; v1.z=val2;
|
||||
v2.x=xstep; v2.y=0.0; v2.z=val3;
|
||||
n=gck_vector3_cross_product(&v1,&v2);
|
||||
gck_vector3_normalize(&n);
|
||||
n=gimp_vector3_cross_product(&v1,&v2);
|
||||
gimp_vector3_normalize(&n);
|
||||
|
||||
if (n.z<0.0)
|
||||
n.z=-n.z;
|
||||
|
||||
gck_vector3_add(normal,normal,&n);
|
||||
gimp_vector3_add(normal,normal,&n);
|
||||
numvecs++;
|
||||
}
|
||||
|
||||
|
@ -149,18 +149,18 @@ void get_normal(gdouble xf,gdouble yf,GckVector3 *normal)
|
|||
{
|
||||
v1.x=xstep; v1.y=0.0; v1.z=val3;
|
||||
v2.x=0.0; v2.y=ystep; v2.z=val4;
|
||||
n=gck_vector3_cross_product(&v1,&v2);
|
||||
gck_vector3_normalize(&n);
|
||||
n=gimp_vector3_cross_product(&v1,&v2);
|
||||
gimp_vector3_normalize(&n);
|
||||
|
||||
if (n.z<0.0)
|
||||
n.z=-n.z;
|
||||
|
||||
gck_vector3_add(normal,normal,&n);
|
||||
gimp_vector3_add(normal,normal,&n);
|
||||
numvecs++;
|
||||
}
|
||||
|
||||
gck_vector3_mul(normal,1.0/(gdouble)numvecs);
|
||||
gck_vector3_normalize(normal);
|
||||
gimp_vector3_mul(normal,1.0/(gdouble)numvecs);
|
||||
gimp_vector3_normalize(normal);
|
||||
}
|
||||
|
||||
void precompute_init(gint w,gint h)
|
||||
|
@ -181,7 +181,7 @@ void precompute_init(gint w,gint h)
|
|||
free(heights[n]);
|
||||
|
||||
heights[n]=(gdouble *)malloc(sizeof(gdouble)*(size_t)w);
|
||||
vertex_normals[n]=(GckVector3 *)malloc(sizeof(GckVector3)*(size_t)w);
|
||||
vertex_normals[n]=(GimpVector3 *)malloc(sizeof(GimpVector3)*(size_t)w);
|
||||
}
|
||||
|
||||
for (n=0;n<2;n++)
|
||||
|
@ -196,20 +196,20 @@ void precompute_init(gint w,gint h)
|
|||
|
||||
bumprow=(guchar *)malloc(sizeof(guchar)*(size_t)w);
|
||||
|
||||
triangle_normals[0]=(GckVector3 *)malloc(sizeof(GckVector3)*(size_t)((w<<1)+2));
|
||||
triangle_normals[1]=(GckVector3 *)malloc(sizeof(GckVector3)*(size_t)((w<<1)+2));
|
||||
triangle_normals[0]=(GimpVector3 *)malloc(sizeof(GimpVector3)*(size_t)((w<<1)+2));
|
||||
triangle_normals[1]=(GimpVector3 *)malloc(sizeof(GimpVector3)*(size_t)((w<<1)+2));
|
||||
|
||||
for (n=0;n<(w<<1)+1;n++)
|
||||
{
|
||||
gck_vector3_set(&triangle_normals[0][n],0.0,0.0,1.0);
|
||||
gck_vector3_set(&triangle_normals[1][n],0.0,0.0,1.0);
|
||||
gimp_vector3_set(&triangle_normals[0][n],0.0,0.0,1.0);
|
||||
gimp_vector3_set(&triangle_normals[1][n],0.0,0.0,1.0);
|
||||
}
|
||||
|
||||
for (n=0;n<w;n++)
|
||||
{
|
||||
gck_vector3_set(&vertex_normals[0][n],0.0,0.0,1.0);
|
||||
gck_vector3_set(&vertex_normals[1][n],0.0,0.0,1.0);
|
||||
gck_vector3_set(&vertex_normals[2][n],0.0,0.0,1.0);
|
||||
gimp_vector3_set(&vertex_normals[0][n],0.0,0.0,1.0);
|
||||
gimp_vector3_set(&vertex_normals[1][n],0.0,0.0,1.0);
|
||||
gimp_vector3_set(&vertex_normals[2][n],0.0,0.0,1.0);
|
||||
heights[0][n]=0.0;
|
||||
heights[1][n]=0.0;
|
||||
heights[2][n]=0.0;
|
||||
|
@ -222,7 +222,7 @@ void precompute_init(gint w,gint h)
|
|||
|
||||
void precompute_normals(gint x1,gint x2,gint y)
|
||||
{
|
||||
GckVector3 *tmpv,p1,p2,p3,normal;
|
||||
GimpVector3 *tmpv,p1,p2,p3,normal;
|
||||
gdouble *tmpd;
|
||||
gint n,i,nv;
|
||||
guchar *map=NULL;
|
||||
|
@ -286,11 +286,11 @@ void precompute_normals(gint x1,gint x2,gint y)
|
|||
p3.y=0.0;
|
||||
p3.z=heights[1][n+1]-heights[1][n];
|
||||
|
||||
triangle_normals[1][i]=gck_vector3_cross_product(&p2,&p1);
|
||||
triangle_normals[1][i+1]=gck_vector3_cross_product(&p3,&p2);
|
||||
triangle_normals[1][i]=gimp_vector3_cross_product(&p2,&p1);
|
||||
triangle_normals[1][i+1]=gimp_vector3_cross_product(&p3,&p2);
|
||||
|
||||
gck_vector3_normalize(&triangle_normals[1][i]);
|
||||
gck_vector3_normalize(&triangle_normals[1][i+1]);
|
||||
gimp_vector3_normalize(&triangle_normals[1][i]);
|
||||
gimp_vector3_normalize(&triangle_normals[1][i+1]);
|
||||
|
||||
i+=2;
|
||||
}
|
||||
|
@ -299,7 +299,7 @@ void precompute_normals(gint x1,gint x2,gint y)
|
|||
/* ====================== */
|
||||
|
||||
i=0;
|
||||
gck_vector3_set(&normal, 0.0,0.0,0.0);
|
||||
gimp_vector3_set(&normal, 0.0,0.0,0.0);
|
||||
for (n=0;n<(x2-x1-1);n++)
|
||||
{
|
||||
nv=0;
|
||||
|
@ -307,13 +307,13 @@ void precompute_normals(gint x1,gint x2,gint y)
|
|||
{
|
||||
if (y>0)
|
||||
{
|
||||
gck_vector3_add(&normal, &normal, &triangle_normals[0][i-1]);
|
||||
gck_vector3_add(&normal, &normal, &triangle_normals[0][i-2]);
|
||||
gimp_vector3_add(&normal, &normal, &triangle_normals[0][i-1]);
|
||||
gimp_vector3_add(&normal, &normal, &triangle_normals[0][i-2]);
|
||||
nv+=2;
|
||||
}
|
||||
if (y<pre_h)
|
||||
{
|
||||
gck_vector3_add(&normal, &normal, &triangle_normals[1][i-1]);
|
||||
gimp_vector3_add(&normal, &normal, &triangle_normals[1][i-1]);
|
||||
nv++;
|
||||
}
|
||||
}
|
||||
|
@ -321,20 +321,20 @@ void precompute_normals(gint x1,gint x2,gint y)
|
|||
{
|
||||
if (y>0)
|
||||
{
|
||||
gck_vector3_add(&normal, &normal, &triangle_normals[0][i]);
|
||||
gck_vector3_add(&normal, &normal, &triangle_normals[0][i+1]);
|
||||
gimp_vector3_add(&normal, &normal, &triangle_normals[0][i]);
|
||||
gimp_vector3_add(&normal, &normal, &triangle_normals[0][i+1]);
|
||||
nv+=2;
|
||||
}
|
||||
if (y<pre_h)
|
||||
{
|
||||
gck_vector3_add(&normal, &normal, &triangle_normals[1][i]);
|
||||
gck_vector3_add(&normal, &normal, &triangle_normals[1][i+1]);
|
||||
gimp_vector3_add(&normal, &normal, &triangle_normals[1][i]);
|
||||
gimp_vector3_add(&normal, &normal, &triangle_normals[1][i+1]);
|
||||
nv+=2;
|
||||
}
|
||||
}
|
||||
|
||||
gck_vector3_mul(&normal, 1.0/(gdouble)nv);
|
||||
gck_vector3_normalize(&normal);
|
||||
gimp_vector3_mul(&normal, 1.0/(gdouble)nv);
|
||||
gimp_vector3_normalize(&normal);
|
||||
vertex_normals[1][n]=normal;
|
||||
|
||||
i+=2;
|
||||
|
@ -345,17 +345,17 @@ void precompute_normals(gint x1,gint x2,gint y)
|
|||
/* Compute the reflected ray given the normalized normal and ins. vec. */
|
||||
/***********************************************************************/
|
||||
|
||||
GckVector3 compute_reflected_ray(GckVector3 *normal,GckVector3 *view)
|
||||
GimpVector3 compute_reflected_ray(GimpVector3 *normal,GimpVector3 *view)
|
||||
{
|
||||
GckVector3 ref;
|
||||
GimpVector3 ref;
|
||||
gdouble nl;
|
||||
|
||||
nl = 2.0*gck_vector3_inner_product(normal,view);
|
||||
nl = 2.0*gimp_vector3_inner_product(normal,view);
|
||||
|
||||
ref = *normal;
|
||||
|
||||
gck_vector3_mul(&ref,nl);
|
||||
gck_vector3_sub(&ref,&ref,view);
|
||||
gimp_vector3_mul(&ref,nl);
|
||||
gimp_vector3_sub(&ref,&ref,view);
|
||||
|
||||
return(ref);
|
||||
}
|
||||
|
@ -365,21 +365,21 @@ GckVector3 compute_reflected_ray(GckVector3 *normal,GckVector3 *view)
|
|||
/* the conversion from spherical coordinates to image space coordinates */
|
||||
/************************************************************************/
|
||||
|
||||
void sphere_to_image(GckVector3 *normal,gdouble *u,gdouble *v)
|
||||
void sphere_to_image(GimpVector3 *normal,gdouble *u,gdouble *v)
|
||||
{
|
||||
static gdouble alpha,fac;
|
||||
static GckVector3 cross_prod;
|
||||
static GckVector3 firstaxis = { 1.0, 0.0, 0.0 };
|
||||
static GckVector3 secondaxis = { 0.0, 1.0, 0.0 };
|
||||
static GimpVector3 cross_prod;
|
||||
static GimpVector3 firstaxis = { 1.0, 0.0, 0.0 };
|
||||
static GimpVector3 secondaxis = { 0.0, 1.0, 0.0 };
|
||||
|
||||
alpha=acos(-gck_vector3_inner_product(&secondaxis,normal));
|
||||
alpha=acos(-gimp_vector3_inner_product(&secondaxis,normal));
|
||||
|
||||
*v=alpha/M_PI;
|
||||
|
||||
if (*v==0.0 || *v==1.0) *u=0.0;
|
||||
else
|
||||
{
|
||||
fac=gck_vector3_inner_product(&firstaxis,normal)/sin(alpha);
|
||||
fac=gimp_vector3_inner_product(&firstaxis,normal)/sin(alpha);
|
||||
|
||||
/* Make sure that we map to -1.0..1.0 (take care of rounding errors) */
|
||||
/* ================================================================= */
|
||||
|
@ -391,9 +391,9 @@ void sphere_to_image(GckVector3 *normal,gdouble *u,gdouble *v)
|
|||
|
||||
*u=acos(fac)/(2.0*M_PI);
|
||||
|
||||
cross_prod=gck_vector3_cross_product(&secondaxis,&firstaxis);
|
||||
cross_prod=gimp_vector3_cross_product(&secondaxis,&firstaxis);
|
||||
|
||||
if (gck_vector3_inner_product(&cross_prod,normal)<0.0)
|
||||
if (gimp_vector3_inner_product(&cross_prod,normal)<0.0)
|
||||
*u=1.0-*u;
|
||||
}
|
||||
}
|
||||
|
@ -402,12 +402,12 @@ void sphere_to_image(GckVector3 *normal,gdouble *u,gdouble *v)
|
|||
/* These routines computes the color of the surface at a given point */
|
||||
/*********************************************************************/
|
||||
|
||||
GckRGB get_ray_color(GckVector3 *position)
|
||||
GckRGB get_ray_color(GimpVector3 *position)
|
||||
{
|
||||
GckRGB color;
|
||||
gint x,f;
|
||||
gdouble xf,yf;
|
||||
GckVector3 normal,*p;
|
||||
GimpVector3 normal,*p;
|
||||
|
||||
pos_to_float(position->x,position->y,&xf,&yf);
|
||||
|
||||
|
@ -449,12 +449,12 @@ GckRGB get_ray_color(GckVector3 *position)
|
|||
return(color);
|
||||
}
|
||||
|
||||
GckRGB get_ray_color_ref(GckVector3 *position)
|
||||
GckRGB get_ray_color_ref(GimpVector3 *position)
|
||||
{
|
||||
GckRGB color,env_color;
|
||||
gint x,f;
|
||||
gdouble xf,yf;
|
||||
GckVector3 normal,*p,v,r;
|
||||
GimpVector3 normal,*p,v,r;
|
||||
|
||||
pos_to_float(position->x,position->y,&xf,&yf);
|
||||
|
||||
|
@ -483,8 +483,8 @@ GckRGB get_ray_color_ref(GckVector3 *position)
|
|||
{
|
||||
normal=vertex_normals[1][(gint)(xf+0.5)];
|
||||
|
||||
gck_vector3_sub(&v,&mapvals.viewpoint,position);
|
||||
gck_vector3_normalize(&v);
|
||||
gimp_vector3_sub(&v,&mapvals.viewpoint,position);
|
||||
gimp_vector3_normalize(&v);
|
||||
|
||||
r = compute_reflected_ray(&normal,&v);
|
||||
|
||||
|
@ -507,12 +507,12 @@ GckRGB get_ray_color_ref(GckVector3 *position)
|
|||
return(color);
|
||||
}
|
||||
|
||||
GckRGB get_ray_color_no_bilinear(GckVector3 *position)
|
||||
GckRGB get_ray_color_no_bilinear(GimpVector3 *position)
|
||||
{
|
||||
GckRGB color;
|
||||
gint x;
|
||||
gdouble xf,yf;
|
||||
GckVector3 normal,*p;
|
||||
GimpVector3 normal,*p;
|
||||
|
||||
pos_to_float(position->x,position->y,&xf,&yf);
|
||||
|
||||
|
@ -554,12 +554,12 @@ GckRGB get_ray_color_no_bilinear(GckVector3 *position)
|
|||
return(color);
|
||||
}
|
||||
|
||||
GckRGB get_ray_color_no_bilinear_ref(GckVector3 *position)
|
||||
GckRGB get_ray_color_no_bilinear_ref(GimpVector3 *position)
|
||||
{
|
||||
GckRGB color,env_color;
|
||||
gint x;
|
||||
gdouble xf,yf;
|
||||
GckVector3 normal,*p,v,r;
|
||||
GimpVector3 normal,*p,v,r;
|
||||
|
||||
pos_to_float(position->x,position->y,&xf,&yf);
|
||||
|
||||
|
@ -582,8 +582,8 @@ GckRGB get_ray_color_no_bilinear_ref(GckVector3 *position)
|
|||
|
||||
color=peek((gint)(xf+0.5),(gint)(yf+0.5));
|
||||
|
||||
gck_vector3_sub(&v,&mapvals.viewpoint,position);
|
||||
gck_vector3_normalize(&v);
|
||||
gimp_vector3_sub(&v,&mapvals.viewpoint,position);
|
||||
gimp_vector3_normalize(&v);
|
||||
|
||||
r = compute_reflected_ray(&mapvals.planenormal,&v);
|
||||
|
||||
|
@ -608,8 +608,8 @@ GckRGB get_ray_color_no_bilinear_ref(GckVector3 *position)
|
|||
pos_to_float(position->x,position->y,&xf,&yf);
|
||||
color=peek((gint)(xf+0.5),(gint)(yf+0.5));
|
||||
|
||||
gck_vector3_sub(&v,&mapvals.viewpoint,position);
|
||||
gck_vector3_normalize(&v);
|
||||
gimp_vector3_sub(&v,&mapvals.viewpoint,position);
|
||||
gimp_vector3_normalize(&v);
|
||||
|
||||
r = compute_reflected_ray(&normal,&v);
|
||||
|
||||
|
|
|
@ -10,12 +10,12 @@
|
|||
#include "lighting_main.h"
|
||||
#include "lighting_image.h"
|
||||
|
||||
typedef GckRGB (*get_ray_func) (GckVector3 *);
|
||||
typedef GckRGB (*get_ray_func) (GimpVector3 *);
|
||||
|
||||
extern GckRGB get_ray_color (GckVector3 *position);
|
||||
extern GckRGB get_ray_color_no_bilinear (GckVector3 *position);
|
||||
extern GckRGB get_ray_color_ref (GckVector3 *position);
|
||||
extern GckRGB get_ray_color_no_bilinear_ref (GckVector3 *position);
|
||||
extern GckRGB get_ray_color (GimpVector3 *position);
|
||||
extern GckRGB get_ray_color_no_bilinear (GimpVector3 *position);
|
||||
extern GckRGB get_ray_color_ref (GimpVector3 *position);
|
||||
extern GckRGB get_ray_color_no_bilinear_ref (GimpVector3 *position);
|
||||
|
||||
extern void precompute_init (gint w,gint h);
|
||||
extern void precompute_normals (gint x1,gint x2,gint y);
|
||||
|
|
|
@ -22,13 +22,13 @@ void init_compute(void)
|
|||
/* Rotate the equator/northpole axis */
|
||||
/* ================================= */
|
||||
|
||||
gck_vector3_set(&mapvals.firstaxis,0.0,0.0,-1.0);
|
||||
gck_vector3_set(&mapvals.secondaxis,0.0,1.0,0.0);
|
||||
gimp_vector3_set(&mapvals.firstaxis,0.0,0.0,-1.0);
|
||||
gimp_vector3_set(&mapvals.secondaxis,0.0,1.0,0.0);
|
||||
|
||||
gck_vector3_rotate(&mapvals.firstaxis,gck_deg_to_rad(mapvals.alpha),
|
||||
gck_deg_to_rad(mapvals.beta),gck_deg_to_rad(mapvals.gamma));
|
||||
gck_vector3_rotate(&mapvals.secondaxis,gck_deg_to_rad(mapvals.alpha),
|
||||
gck_deg_to_rad(mapvals.beta),gck_deg_to_rad(mapvals.gamma));
|
||||
gimp_vector3_rotate(&mapvals.firstaxis,gimp_deg_to_rad(mapvals.alpha),
|
||||
gimp_deg_to_rad(mapvals.beta),gimp_deg_to_rad(mapvals.gamma));
|
||||
gimp_vector3_rotate(&mapvals.secondaxis,gimp_deg_to_rad(mapvals.alpha),
|
||||
gimp_deg_to_rad(mapvals.beta),gimp_deg_to_rad(mapvals.gamma));
|
||||
|
||||
/* Compute the 2D bounding box of the sphere spanned by the axis */
|
||||
/* ============================================================= */
|
||||
|
@ -44,19 +44,19 @@ void init_compute(void)
|
|||
/* Rotate the plane axis */
|
||||
/* ===================== */
|
||||
|
||||
gck_vector3_set(&mapvals.firstaxis, 1.0,0.0,0.0);
|
||||
gck_vector3_set(&mapvals.secondaxis,0.0,1.0,0.0);
|
||||
gck_vector3_set(&mapvals.normal,0.0,0.0,1.0);
|
||||
gimp_vector3_set(&mapvals.firstaxis, 1.0,0.0,0.0);
|
||||
gimp_vector3_set(&mapvals.secondaxis,0.0,1.0,0.0);
|
||||
gimp_vector3_set(&mapvals.normal,0.0,0.0,1.0);
|
||||
|
||||
gck_vector3_rotate(&mapvals.firstaxis,gck_deg_to_rad(mapvals.alpha),
|
||||
gck_deg_to_rad(mapvals.beta),gck_deg_to_rad(mapvals.gamma));
|
||||
gck_vector3_rotate(&mapvals.secondaxis,gck_deg_to_rad(mapvals.alpha),
|
||||
gck_deg_to_rad(mapvals.beta),gck_deg_to_rad(mapvals.gamma));
|
||||
gimp_vector3_rotate(&mapvals.firstaxis,gimp_deg_to_rad(mapvals.alpha),
|
||||
gimp_deg_to_rad(mapvals.beta),gimp_deg_to_rad(mapvals.gamma));
|
||||
gimp_vector3_rotate(&mapvals.secondaxis,gimp_deg_to_rad(mapvals.alpha),
|
||||
gimp_deg_to_rad(mapvals.beta),gimp_deg_to_rad(mapvals.gamma));
|
||||
|
||||
mapvals.normal=gck_vector3_cross_product(&mapvals.firstaxis,&mapvals.secondaxis);
|
||||
mapvals.normal=gimp_vector3_cross_product(&mapvals.firstaxis,&mapvals.secondaxis);
|
||||
|
||||
if (mapvals.normal.z<0.0)
|
||||
gck_vector3_mul(&mapvals.normal,-1.0);
|
||||
gimp_vector3_mul(&mapvals.normal,-1.0);
|
||||
|
||||
/* Initialize intersection matrix */
|
||||
/* ============================== */
|
||||
|
@ -77,9 +77,9 @@ void init_compute(void)
|
|||
|
||||
break;
|
||||
case MAP_BOX:
|
||||
gck_vector3_set(&mapvals.firstaxis, 1.0,0.0,0.0);
|
||||
gck_vector3_set(&mapvals.secondaxis,0.0,1.0,0.0);
|
||||
gck_vector3_set(&mapvals.normal,0.0,0.0,1.0);
|
||||
gimp_vector3_set(&mapvals.firstaxis, 1.0,0.0,0.0);
|
||||
gimp_vector3_set(&mapvals.secondaxis,0.0,1.0,0.0);
|
||||
gimp_vector3_set(&mapvals.normal,0.0,0.0,1.0);
|
||||
|
||||
get_ray_color=get_ray_color_box;
|
||||
|
||||
|
@ -117,9 +117,9 @@ void init_compute(void)
|
|||
case MAP_CYLINDER:
|
||||
get_ray_color=get_ray_color_cylinder;
|
||||
|
||||
gck_vector3_set(&mapvals.firstaxis, 1.0,0.0,0.0);
|
||||
gck_vector3_set(&mapvals.secondaxis,0.0,1.0,0.0);
|
||||
gck_vector3_set(&mapvals.normal,0.0,0.0,1.0);
|
||||
gimp_vector3_set(&mapvals.firstaxis, 1.0,0.0,0.0);
|
||||
gimp_vector3_set(&mapvals.secondaxis,0.0,1.0,0.0);
|
||||
gimp_vector3_set(&mapvals.normal,0.0,0.0,1.0);
|
||||
|
||||
ident_mat(rotmat);
|
||||
|
||||
|
@ -159,7 +159,7 @@ void init_compute(void)
|
|||
|
||||
void render(gdouble x,gdouble y,GckRGB *col)
|
||||
{
|
||||
GckVector3 pos;
|
||||
GimpVector3 pos;
|
||||
|
||||
pos.x=x/(gdouble)width;
|
||||
pos.y=y/(gdouble)height;
|
||||
|
@ -183,7 +183,7 @@ void compute_image(void)
|
|||
gint xcount,ycount;
|
||||
GckRGB color;
|
||||
glong progress_counter=0;
|
||||
GckVector3 p;
|
||||
GimpVector3 p;
|
||||
gint32 new_image_id=-1,new_layer_id=-1;
|
||||
|
||||
init_compute();
|
||||
|
|
|
@ -148,9 +148,9 @@ gint checkbounds_cylinder_image(gint image, gint x,gint y)
|
|||
return(TRUE);
|
||||
}
|
||||
|
||||
GckVector3 int_to_pos(gint x,gint y)
|
||||
GimpVector3 int_to_pos(gint x,gint y)
|
||||
{
|
||||
GckVector3 pos;
|
||||
GimpVector3 pos;
|
||||
|
||||
pos.x=(gdouble)x/(gdouble)width;
|
||||
pos.y=(gdouble)y/(gdouble)height;
|
||||
|
|
|
@ -47,7 +47,7 @@ extern glong out_xy_to_index (gint x,gint y);
|
|||
extern gint checkbounds (gint x,gint y);
|
||||
extern GckRGB peek (gint x,gint y);
|
||||
extern void poke (gint x,gint y,GckRGB *color);
|
||||
extern GckVector3 int_to_pos (gint x,gint y);
|
||||
extern GimpVector3 int_to_pos (gint x,gint y);
|
||||
extern void pos_to_int (gdouble x,gdouble y,gint *scr_x,gint *scr_y);
|
||||
|
||||
extern GckRGB get_image_color (gdouble u,gdouble v,gint *inside);
|
||||
|
|
|
@ -44,14 +44,14 @@ void set_default_settings(void)
|
|||
{
|
||||
gint i;
|
||||
|
||||
gck_vector3_set(&mapvals.viewpoint, 0.5,0.5,2.0);
|
||||
gck_vector3_set(&mapvals.firstaxis, 1.0,0.0,0.0);
|
||||
gck_vector3_set(&mapvals.secondaxis, 0.0,1.0,0.0);
|
||||
gck_vector3_set(&mapvals.normal, 0.0,0.0,1.0);
|
||||
gck_vector3_set(&mapvals.position, 0.5,0.5,0.0);
|
||||
gck_vector3_set(&mapvals.lightsource.position, -0.5,-0.5,2.0);
|
||||
gck_vector3_set(&mapvals.lightsource.direction, -1.0,-1.0,1.0);
|
||||
gck_vector3_set(&mapvals.scale, 0.5,0.5,0.5);
|
||||
gimp_vector3_set(&mapvals.viewpoint, 0.5,0.5,2.0);
|
||||
gimp_vector3_set(&mapvals.firstaxis, 1.0,0.0,0.0);
|
||||
gimp_vector3_set(&mapvals.secondaxis, 0.0,1.0,0.0);
|
||||
gimp_vector3_set(&mapvals.normal, 0.0,0.0,1.0);
|
||||
gimp_vector3_set(&mapvals.position, 0.5,0.5,0.0);
|
||||
gimp_vector3_set(&mapvals.lightsource.position, -0.5,-0.5,2.0);
|
||||
gimp_vector3_set(&mapvals.lightsource.direction, -1.0,-1.0,1.0);
|
||||
gimp_vector3_set(&mapvals.scale, 0.5,0.5,0.5);
|
||||
|
||||
mapvals.maptype=MAP_PLANE;
|
||||
|
||||
|
|
|
@ -53,14 +53,14 @@ typedef struct
|
|||
typedef struct
|
||||
{
|
||||
LightType type;
|
||||
GckVector3 position;
|
||||
GckVector3 direction;
|
||||
GimpVector3 position;
|
||||
GimpVector3 direction;
|
||||
GckRGB color;
|
||||
gdouble intensity;
|
||||
} LightSettings;
|
||||
|
||||
typedef struct {
|
||||
GckVector3 viewpoint,firstaxis,secondaxis,normal,position,scale;
|
||||
GimpVector3 viewpoint,firstaxis,secondaxis,normal,position,scale;
|
||||
LightSettings lightsource;
|
||||
|
||||
MaterialSettings material;
|
||||
|
|
|
@ -19,7 +19,7 @@ void clear_light_marker (void);
|
|||
|
||||
gint draw_line (gint n, gint startx,gint starty,gint pw,gint ph,
|
||||
gdouble cx1, gdouble cy1, gdouble cx2, gdouble cy2,
|
||||
GckVector3 a,GckVector3 b);
|
||||
GimpVector3 a,GimpVector3 b);
|
||||
|
||||
void draw_wireframe_plane (gint startx,gint starty,gint pw,gint ph);
|
||||
void draw_wireframe_sphere (gint startx,gint starty,gint pw,gint ph);
|
||||
|
@ -28,6 +28,91 @@ void draw_wireframe_cylinder (gint startx,gint starty,gint pw,gint ph);
|
|||
|
||||
void clear_wireframe (void);
|
||||
|
||||
/*************************************************/
|
||||
/* Quick and dirty (and slow) line clip routine. */
|
||||
/* The function returns FALSE if the line isn't */
|
||||
/* visible according to the limits given. */
|
||||
/*************************************************/
|
||||
|
||||
static gboolean
|
||||
clip_line (gdouble *x1,
|
||||
gdouble *y1,
|
||||
gdouble *x2,
|
||||
gdouble *y2,
|
||||
gdouble minx,
|
||||
gdouble miny,
|
||||
gdouble maxx,
|
||||
gdouble maxy)
|
||||
{
|
||||
gdouble tmp;
|
||||
|
||||
g_assert (x1!=NULL);
|
||||
g_assert (y1!=NULL);
|
||||
g_assert (x2!=NULL);
|
||||
g_assert (y2!=NULL);
|
||||
|
||||
/* First, check if line is visible at all */
|
||||
/* ====================================== */
|
||||
|
||||
if (*x1<minx && *x2<minx) return(FALSE);
|
||||
if (*x1>maxx && *x2>maxx) return(FALSE);
|
||||
if (*y1<miny && *y2<miny) return(FALSE);
|
||||
if (*y1>maxy && *y2>maxy) return(FALSE);
|
||||
|
||||
/* Check for intersection with the four edges. Sort on x first. */
|
||||
/* ============================================================ */
|
||||
|
||||
if (*x2<*x1)
|
||||
{
|
||||
tmp=*x1;
|
||||
*x1=*x2;
|
||||
*x2=tmp;
|
||||
tmp=*y1;
|
||||
*y1=*y2;
|
||||
*y2=tmp;
|
||||
}
|
||||
|
||||
if (*x1<minx)
|
||||
{
|
||||
if (*y1<*y2) *y1=*y1+(minx-*x1)*((*y2-*y1)/(*x2-*x1));
|
||||
else *y1=*y1-(minx-*x1)*((*y1-*y2)/(*x2-*x1));
|
||||
*x1=minx;
|
||||
}
|
||||
|
||||
if (*x2>maxx)
|
||||
{
|
||||
if (*y1<*y2) *y2=*y2-(*x2-maxx)*((*y2-*y1)/(*x2-*x1));
|
||||
else *y2=*y2+(*x2-maxx)*((*y1-*y2)/(*x2-*x1));
|
||||
*x2=maxx;
|
||||
}
|
||||
|
||||
if (*y1<miny)
|
||||
{
|
||||
*x1=*x1+(miny-*y1)*((*x2-*x1)/(*y2-*y1));
|
||||
*y1=miny;
|
||||
}
|
||||
|
||||
if (*y2<miny)
|
||||
{
|
||||
*x2=*x2-(miny-*y2)*((*x2-*x1)/(*y1-*y2));
|
||||
*y2=miny;
|
||||
}
|
||||
|
||||
if (*y1>maxy)
|
||||
{
|
||||
*x1=*x1+(*y1-maxy)*((*x2-*x1)/(*y1-*y2));
|
||||
*y1=maxy;
|
||||
}
|
||||
|
||||
if (*y2>maxy)
|
||||
{
|
||||
*x2=*x2-(*y2-maxy)*((*x2-*x1)/(*y2-*y1));
|
||||
*y2=maxy;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**************************************************************/
|
||||
/* Computes a preview of the rectangle starting at (x,y) with */
|
||||
/* dimensions (w,h), placing the result in preview_RGB_data. */
|
||||
|
@ -36,7 +121,7 @@ void clear_wireframe (void);
|
|||
void compute_preview(gint x,gint y,gint w,gint h,gint pw,gint ph)
|
||||
{
|
||||
gdouble xpostab[PREVIEW_WIDTH],ypostab[PREVIEW_HEIGHT],realw,realh;
|
||||
GckVector3 p1,p2;
|
||||
GimpVector3 p1,p2;
|
||||
GckRGB color,lightcheck,darkcheck,temp;
|
||||
guchar r,g,b;
|
||||
gint xcnt,ycnt,f1,f2;
|
||||
|
@ -75,7 +160,7 @@ void compute_preview(gint x,gint y,gint w,gint h,gint pw,gint ph)
|
|||
|
||||
gck_rgb_set(&lightcheck,0.75,0.75,0.75);
|
||||
gck_rgb_set(&darkcheck, 0.50,0.50,0.50);
|
||||
gck_vector3_set(&p2,-1.0,-1.0,0.0);
|
||||
gimp_vector3_set(&p2,-1.0,-1.0,0.0);
|
||||
|
||||
for (ycnt=0;ycnt<ph;ycnt++)
|
||||
{
|
||||
|
@ -221,7 +306,7 @@ void draw_lights(gint startx,gint starty,gint pw,gint ph)
|
|||
|
||||
clear_light_marker();
|
||||
|
||||
gck_3d_to_2d(startx,starty,pw,ph,&dxpos,&dypos,&mapvals.viewpoint,
|
||||
gimp_vector_3d_to_2d(startx,starty,pw,ph,&dxpos,&dypos,&mapvals.viewpoint,
|
||||
&mapvals.lightsource.position);
|
||||
xpos=(gint)(dxpos+0.5);
|
||||
ypos=(gint)(dypos+0.5);
|
||||
|
@ -243,7 +328,7 @@ void update_light(gint xpos,gint ypos)
|
|||
startx=(PREVIEW_WIDTH-pw)>>1;
|
||||
starty=(PREVIEW_HEIGHT-ph)>>1;
|
||||
|
||||
gck_2d_to_3d(startx,starty,pw,ph,xpos,ypos,&mapvals.viewpoint,&mapvals.lightsource.position);
|
||||
gimp_vector_2d_to_3d(startx,starty,pw,ph,xpos,ypos,&mapvals.viewpoint,&mapvals.lightsource.position);
|
||||
draw_lights(startx,starty,pw,ph);
|
||||
}
|
||||
|
||||
|
@ -328,34 +413,34 @@ void draw_wireframe(gint startx,gint starty,gint pw,gint ph)
|
|||
|
||||
void draw_wireframe_plane(gint startx,gint starty,gint pw,gint ph)
|
||||
{
|
||||
GckVector3 v1,v2,a,b,c,d,dir1,dir2;
|
||||
GimpVector3 v1,v2,a,b,c,d,dir1,dir2;
|
||||
gint cnt,n=0;
|
||||
gdouble x1,y1,x2,y2,cx1,cy1,cx2,cy2,fac;
|
||||
|
||||
/* Find rotated box corners */
|
||||
/* ======================== */
|
||||
|
||||
gck_vector3_set(&v1,0.5,0.0,0.0);
|
||||
gck_vector3_set(&v2,0.0,0.5,0.0);
|
||||
gimp_vector3_set(&v1,0.5,0.0,0.0);
|
||||
gimp_vector3_set(&v2,0.0,0.5,0.0);
|
||||
|
||||
gck_vector3_rotate(&v1,gck_deg_to_rad(mapvals.alpha),
|
||||
gck_deg_to_rad(mapvals.beta),gck_deg_to_rad(mapvals.gamma));
|
||||
gck_vector3_rotate(&v2,gck_deg_to_rad(mapvals.alpha),
|
||||
gck_deg_to_rad(mapvals.beta),gck_deg_to_rad(mapvals.gamma));
|
||||
gimp_vector3_rotate(&v1,gimp_deg_to_rad(mapvals.alpha),
|
||||
gimp_deg_to_rad(mapvals.beta),gimp_deg_to_rad(mapvals.gamma));
|
||||
gimp_vector3_rotate(&v2,gimp_deg_to_rad(mapvals.alpha),
|
||||
gimp_deg_to_rad(mapvals.beta),gimp_deg_to_rad(mapvals.gamma));
|
||||
|
||||
dir1=v1; gck_vector3_normalize(&dir1);
|
||||
dir2=v2; gck_vector3_normalize(&dir2);
|
||||
dir1=v1; gimp_vector3_normalize(&dir1);
|
||||
dir2=v2; gimp_vector3_normalize(&dir2);
|
||||
|
||||
fac=1.0/(gdouble)WIRESIZE;
|
||||
|
||||
gck_vector3_mul(&dir1,fac);
|
||||
gck_vector3_mul(&dir2,fac);
|
||||
gimp_vector3_mul(&dir1,fac);
|
||||
gimp_vector3_mul(&dir2,fac);
|
||||
|
||||
gck_vector3_add(&a,&mapvals.position,&v1);
|
||||
gck_vector3_sub(&b,&a,&v2);
|
||||
gck_vector3_add(&a,&a,&v2);
|
||||
gck_vector3_sub(&d,&mapvals.position,&v1);
|
||||
gck_vector3_sub(&d,&d,&v2);
|
||||
gimp_vector3_add(&a,&mapvals.position,&v1);
|
||||
gimp_vector3_sub(&b,&a,&v2);
|
||||
gimp_vector3_add(&a,&a,&v2);
|
||||
gimp_vector3_sub(&d,&mapvals.position,&v1);
|
||||
gimp_vector3_sub(&d,&d,&v2);
|
||||
|
||||
c=b;
|
||||
|
||||
|
@ -366,10 +451,10 @@ void draw_wireframe_plane(gint startx,gint starty,gint pw,gint ph)
|
|||
|
||||
for (cnt=0;cnt<=WIRESIZE;cnt++)
|
||||
{
|
||||
gck_3d_to_2d(startx,starty,pw,ph,&x1,&y1,&mapvals.viewpoint,&a);
|
||||
gck_3d_to_2d(startx,starty,pw,ph,&x2,&y2,&mapvals.viewpoint,&b);
|
||||
gimp_vector_3d_to_2d(startx,starty,pw,ph,&x1,&y1,&mapvals.viewpoint,&a);
|
||||
gimp_vector_3d_to_2d(startx,starty,pw,ph,&x2,&y2,&mapvals.viewpoint,&b);
|
||||
|
||||
if (gck_clip_line(&x1,&y1,&x2,&y2,cx1,cy1,cx2,cy2)==TRUE)
|
||||
if (clip_line(&x1,&y1,&x2,&y2,cx1,cy1,cx2,cy2)==TRUE)
|
||||
{
|
||||
linetab[n].x1=(gint)(x1+0.5);
|
||||
linetab[n].y1=(gint)(y1+0.5);
|
||||
|
@ -382,10 +467,10 @@ void draw_wireframe_plane(gint startx,gint starty,gint pw,gint ph)
|
|||
n++;
|
||||
}
|
||||
|
||||
gck_3d_to_2d(startx,starty,pw,ph,&x1,&y1,&mapvals.viewpoint,&c);
|
||||
gck_3d_to_2d(startx,starty,pw,ph,&x2,&y2,&mapvals.viewpoint,&d);
|
||||
gimp_vector_3d_to_2d(startx,starty,pw,ph,&x1,&y1,&mapvals.viewpoint,&c);
|
||||
gimp_vector_3d_to_2d(startx,starty,pw,ph,&x2,&y2,&mapvals.viewpoint,&d);
|
||||
|
||||
if (gck_clip_line(&x1,&y1,&x2,&y2,cx1,cy1,cx2,cy2)==TRUE)
|
||||
if (clip_line(&x1,&y1,&x2,&y2,cx1,cy1,cx2,cy2)==TRUE)
|
||||
{
|
||||
linetab[n].x1=(gint)(x1+0.5);
|
||||
linetab[n].y1=(gint)(y1+0.5);
|
||||
|
@ -398,10 +483,10 @@ void draw_wireframe_plane(gint startx,gint starty,gint pw,gint ph)
|
|||
n++;
|
||||
}
|
||||
|
||||
gck_vector3_sub(&a,&a,&dir1);
|
||||
gck_vector3_sub(&b,&b,&dir1);
|
||||
gck_vector3_add(&c,&c,&dir2);
|
||||
gck_vector3_add(&d,&d,&dir2);
|
||||
gimp_vector3_sub(&a,&a,&dir1);
|
||||
gimp_vector3_sub(&b,&b,&dir1);
|
||||
gimp_vector3_add(&c,&c,&dir2);
|
||||
gimp_vector3_add(&d,&d,&dir2);
|
||||
}
|
||||
|
||||
/* Mark end of lines */
|
||||
|
@ -412,7 +497,7 @@ void draw_wireframe_plane(gint startx,gint starty,gint pw,gint ph)
|
|||
|
||||
void draw_wireframe_sphere(gint startx,gint starty,gint pw,gint ph)
|
||||
{
|
||||
GckVector3 p[2*(WIRESIZE+5)];
|
||||
GimpVector3 p[2*(WIRESIZE+5)];
|
||||
gint cnt,cnt2,n=0;
|
||||
gdouble x1,y1,x2,y2,twopifac,cx1,cy1,cx2,cy2;
|
||||
|
||||
|
@ -426,9 +511,9 @@ void draw_wireframe_sphere(gint startx,gint starty,gint pw,gint ph)
|
|||
p[cnt].x=mapvals.radius*cos((gdouble)cnt*twopifac);
|
||||
p[cnt].y=0.0;
|
||||
p[cnt].z=mapvals.radius*sin((gdouble)cnt*twopifac);
|
||||
gck_vector3_rotate(&p[cnt],gck_deg_to_rad(mapvals.alpha),
|
||||
gck_deg_to_rad(mapvals.beta),gck_deg_to_rad(mapvals.gamma));
|
||||
gck_vector3_add(&p[cnt],&p[cnt],&mapvals.position);
|
||||
gimp_vector3_rotate(&p[cnt],gimp_deg_to_rad(mapvals.alpha),
|
||||
gimp_deg_to_rad(mapvals.beta),gimp_deg_to_rad(mapvals.gamma));
|
||||
gimp_vector3_add(&p[cnt],&p[cnt],&mapvals.position);
|
||||
}
|
||||
p[cnt]=p[0];
|
||||
for (cnt=WIRESIZE+1;cnt<2*WIRESIZE+1;cnt++)
|
||||
|
@ -436,9 +521,9 @@ void draw_wireframe_sphere(gint startx,gint starty,gint pw,gint ph)
|
|||
p[cnt].x=mapvals.radius*cos((gdouble)(cnt-(WIRESIZE+1))*twopifac);
|
||||
p[cnt].y=mapvals.radius*sin((gdouble)(cnt-(WIRESIZE+1))*twopifac);
|
||||
p[cnt].z=0.0;
|
||||
gck_vector3_rotate(&p[cnt],gck_deg_to_rad(mapvals.alpha),
|
||||
gck_deg_to_rad(mapvals.beta),gck_deg_to_rad(mapvals.gamma));
|
||||
gck_vector3_add(&p[cnt],&p[cnt],&mapvals.position);
|
||||
gimp_vector3_rotate(&p[cnt],gimp_deg_to_rad(mapvals.alpha),
|
||||
gimp_deg_to_rad(mapvals.beta),gimp_deg_to_rad(mapvals.gamma));
|
||||
gimp_vector3_add(&p[cnt],&p[cnt],&mapvals.position);
|
||||
}
|
||||
p[cnt]=p[WIRESIZE+1];
|
||||
cnt++;
|
||||
|
@ -447,23 +532,23 @@ void draw_wireframe_sphere(gint startx,gint starty,gint pw,gint ph)
|
|||
/* Find rotated axis */
|
||||
/* ================= */
|
||||
|
||||
gck_vector3_set(&p[cnt],0.0,-0.35,0.0);
|
||||
gck_vector3_rotate(&p[cnt],gck_deg_to_rad(mapvals.alpha),
|
||||
gck_deg_to_rad(mapvals.beta),gck_deg_to_rad(mapvals.gamma));
|
||||
gimp_vector3_set(&p[cnt],0.0,-0.35,0.0);
|
||||
gimp_vector3_rotate(&p[cnt],gimp_deg_to_rad(mapvals.alpha),
|
||||
gimp_deg_to_rad(mapvals.beta),gimp_deg_to_rad(mapvals.gamma));
|
||||
p[cnt+1]=mapvals.position;
|
||||
|
||||
gck_vector3_set(&p[cnt+2],0.0,0.0,-0.35);
|
||||
gck_vector3_rotate(&p[cnt+2],gck_deg_to_rad(mapvals.alpha),
|
||||
gck_deg_to_rad(mapvals.beta),gck_deg_to_rad(mapvals.gamma));
|
||||
gimp_vector3_set(&p[cnt+2],0.0,0.0,-0.35);
|
||||
gimp_vector3_rotate(&p[cnt+2],gimp_deg_to_rad(mapvals.alpha),
|
||||
gimp_deg_to_rad(mapvals.beta),gimp_deg_to_rad(mapvals.gamma));
|
||||
p[cnt+3]=mapvals.position;
|
||||
|
||||
p[cnt+4]=p[cnt];
|
||||
gck_vector3_mul(&p[cnt+4],-1.0);
|
||||
gimp_vector3_mul(&p[cnt+4],-1.0);
|
||||
p[cnt+5]=p[cnt+1];
|
||||
|
||||
gck_vector3_add(&p[cnt],&p[cnt],&mapvals.position);
|
||||
gck_vector3_add(&p[cnt+2],&p[cnt+2],&mapvals.position);
|
||||
gck_vector3_add(&p[cnt+4],&p[cnt+4],&mapvals.position);
|
||||
gimp_vector3_add(&p[cnt],&p[cnt],&mapvals.position);
|
||||
gimp_vector3_add(&p[cnt+2],&p[cnt+2],&mapvals.position);
|
||||
gimp_vector3_add(&p[cnt+4],&p[cnt+4],&mapvals.position);
|
||||
|
||||
/* Draw the circles (equator and zero meridian) */
|
||||
/* ============================================ */
|
||||
|
@ -477,10 +562,10 @@ void draw_wireframe_sphere(gint startx,gint starty,gint pw,gint ph)
|
|||
{
|
||||
if (p[cnt].z>mapvals.position.z && p[cnt+1].z>mapvals.position.z)
|
||||
{
|
||||
gck_3d_to_2d(startx,starty,pw,ph,&x1,&y1,&mapvals.viewpoint,&p[cnt]);
|
||||
gck_3d_to_2d(startx,starty,pw,ph,&x2,&y2,&mapvals.viewpoint,&p[cnt+1]);
|
||||
gimp_vector_3d_to_2d(startx,starty,pw,ph,&x1,&y1,&mapvals.viewpoint,&p[cnt]);
|
||||
gimp_vector_3d_to_2d(startx,starty,pw,ph,&x2,&y2,&mapvals.viewpoint,&p[cnt+1]);
|
||||
|
||||
if (gck_clip_line(&x1,&y1,&x2,&y2,cx1,cy1,cx2,cy2)==TRUE)
|
||||
if (clip_line(&x1,&y1,&x2,&y2,cx1,cy1,cx2,cy2)==TRUE)
|
||||
{
|
||||
linetab[n].x1=(gint)(x1+0.5);
|
||||
linetab[n].y1=(gint)(y1+0.5);
|
||||
|
@ -500,10 +585,10 @@ void draw_wireframe_sphere(gint startx,gint starty,gint pw,gint ph)
|
|||
|
||||
for (cnt=0;cnt<3;cnt++)
|
||||
{
|
||||
gck_3d_to_2d(startx,starty,pw,ph,&x1,&y1,&mapvals.viewpoint,&p[cnt2]);
|
||||
gck_3d_to_2d(startx,starty,pw,ph,&x2,&y2,&mapvals.viewpoint,&p[cnt2+1]);
|
||||
gimp_vector_3d_to_2d(startx,starty,pw,ph,&x1,&y1,&mapvals.viewpoint,&p[cnt2]);
|
||||
gimp_vector_3d_to_2d(startx,starty,pw,ph,&x2,&y2,&mapvals.viewpoint,&p[cnt2+1]);
|
||||
|
||||
if (gck_clip_line(&x1,&y1,&x2,&y2,cx1,cy1,cx2,cy2)==TRUE)
|
||||
if (clip_line(&x1,&y1,&x2,&y2,cx1,cy1,cx2,cy2)==TRUE)
|
||||
{
|
||||
linetab[n].x1=(gint)(x1+0.5);
|
||||
linetab[n].y1=(gint)(y1+0.5);
|
||||
|
@ -535,15 +620,15 @@ void draw_wireframe_sphere(gint startx,gint starty,gint pw,gint ph)
|
|||
|
||||
gint draw_line(gint n, gint startx,gint starty,gint pw,gint ph,
|
||||
gdouble cx1, gdouble cy1, gdouble cx2, gdouble cy2,
|
||||
GckVector3 a,GckVector3 b)
|
||||
GimpVector3 a,GimpVector3 b)
|
||||
{
|
||||
gdouble x1,y1,x2,y2;
|
||||
gint i = n;
|
||||
|
||||
gck_3d_to_2d(startx,starty,pw,ph,&x1,&y1,&mapvals.viewpoint,&a);
|
||||
gck_3d_to_2d(startx,starty,pw,ph,&x2,&y2,&mapvals.viewpoint,&b);
|
||||
gimp_vector_3d_to_2d(startx,starty,pw,ph,&x1,&y1,&mapvals.viewpoint,&a);
|
||||
gimp_vector_3d_to_2d(startx,starty,pw,ph,&x2,&y2,&mapvals.viewpoint,&b);
|
||||
|
||||
if (gck_clip_line(&x1,&y1,&x2,&y2,cx1,cy1,cx2,cy2)==TRUE)
|
||||
if (clip_line(&x1,&y1,&x2,&y2,cx1,cy1,cx2,cy2)==TRUE)
|
||||
{
|
||||
linetab[i].x1=(gint)(x1+0.5);
|
||||
linetab[i].y1=(gint)(y1+0.5);
|
||||
|
@ -563,7 +648,7 @@ gint draw_line(gint n, gint startx,gint starty,gint pw,gint ph,
|
|||
|
||||
void draw_wireframe_box(gint startx,gint starty,gint pw,gint ph)
|
||||
{
|
||||
GckVector3 p[8], tmp, scale;
|
||||
GimpVector3 p[8], tmp, scale;
|
||||
gint n=0,i;
|
||||
gdouble cx1,cy1,cx2,cy2;
|
||||
|
||||
|
@ -573,17 +658,17 @@ void draw_wireframe_box(gint startx,gint starty,gint pw,gint ph)
|
|||
init_compute();
|
||||
|
||||
scale = mapvals.scale;
|
||||
gck_vector3_mul(&scale,0.5);
|
||||
gimp_vector3_mul(&scale,0.5);
|
||||
|
||||
gck_vector3_set(&p[0], -scale.x, -scale.y, scale.z);
|
||||
gck_vector3_set(&p[1], scale.x, -scale.y, scale.z);
|
||||
gck_vector3_set(&p[2], scale.x, scale.y, scale.z);
|
||||
gck_vector3_set(&p[3], -scale.x, scale.y, scale.z);
|
||||
gimp_vector3_set(&p[0], -scale.x, -scale.y, scale.z);
|
||||
gimp_vector3_set(&p[1], scale.x, -scale.y, scale.z);
|
||||
gimp_vector3_set(&p[2], scale.x, scale.y, scale.z);
|
||||
gimp_vector3_set(&p[3], -scale.x, scale.y, scale.z);
|
||||
|
||||
gck_vector3_set(&p[4], -scale.x, -scale.y, -scale.z);
|
||||
gck_vector3_set(&p[5], scale.x, -scale.y, -scale.z);
|
||||
gck_vector3_set(&p[6], scale.x, scale.y, -scale.z);
|
||||
gck_vector3_set(&p[7], -scale.x, scale.y, -scale.z);
|
||||
gimp_vector3_set(&p[4], -scale.x, -scale.y, -scale.z);
|
||||
gimp_vector3_set(&p[5], scale.x, -scale.y, -scale.z);
|
||||
gimp_vector3_set(&p[6], scale.x, scale.y, -scale.z);
|
||||
gimp_vector3_set(&p[7], -scale.x, scale.y, -scale.z);
|
||||
|
||||
/* Rotate and translate points */
|
||||
/* =========================== */
|
||||
|
@ -591,7 +676,7 @@ void draw_wireframe_box(gint startx,gint starty,gint pw,gint ph)
|
|||
for (i=0;i<8;i++)
|
||||
{
|
||||
vecmulmat(&tmp,&p[i],rotmat);
|
||||
gck_vector3_add(&p[i],&tmp,&mapvals.position);
|
||||
gimp_vector3_add(&p[i],&tmp,&mapvals.position);
|
||||
}
|
||||
|
||||
/* Draw the box */
|
||||
|
@ -625,7 +710,7 @@ void draw_wireframe_box(gint startx,gint starty,gint pw,gint ph)
|
|||
|
||||
void draw_wireframe_cylinder(gint startx,gint starty,gint pw,gint ph)
|
||||
{
|
||||
GckVector3 p[2*8], a, axis, scale;
|
||||
GimpVector3 p[2*8], a, axis, scale;
|
||||
gint n=0,i;
|
||||
gdouble cx1,cy1,cx2,cy2;
|
||||
gfloat m[16], l, angle;
|
||||
|
@ -636,18 +721,18 @@ void draw_wireframe_cylinder(gint startx,gint starty,gint pw,gint ph)
|
|||
init_compute();
|
||||
|
||||
scale = mapvals.scale;
|
||||
gck_vector3_mul(&scale,0.5);
|
||||
gimp_vector3_mul(&scale,0.5);
|
||||
|
||||
l = mapvals.cylinder_length/2.0;
|
||||
angle = 0;
|
||||
|
||||
gck_vector3_set(&axis, 0.0,1.0,0.0);
|
||||
gimp_vector3_set(&axis, 0.0,1.0,0.0);
|
||||
|
||||
for (i=0;i<8;i++)
|
||||
{
|
||||
rotatemat(angle, &axis, m);
|
||||
|
||||
gck_vector3_set(&a, mapvals.cylinder_radius,0.0,0.0);
|
||||
gimp_vector3_set(&a, mapvals.cylinder_radius,0.0,0.0);
|
||||
|
||||
vecmulmat(&p[i], &a, m);
|
||||
|
||||
|
@ -665,7 +750,7 @@ void draw_wireframe_cylinder(gint startx,gint starty,gint pw,gint ph)
|
|||
for (i=0;i<16;i++)
|
||||
{
|
||||
vecmulmat(&a,&p[i],rotmat);
|
||||
gck_vector3_add(&p[i],&a,&mapvals.position);
|
||||
gimp_vector3_add(&p[i],&a,&mapvals.position);
|
||||
}
|
||||
|
||||
/* Draw the box */
|
||||
|
|
|
@ -10,8 +10,8 @@ get_ray_color_func get_ray_color;
|
|||
typedef struct {
|
||||
gdouble u,v;
|
||||
gdouble t;
|
||||
GckVector3 s;
|
||||
GckVector3 n;
|
||||
GimpVector3 s;
|
||||
GimpVector3 n;
|
||||
gint face;
|
||||
} FaceIntersectInfo;
|
||||
|
||||
|
@ -19,12 +19,12 @@ typedef struct {
|
|||
/* Phong shading */
|
||||
/*****************/
|
||||
|
||||
GckRGB phong_shade(GckVector3 *pos,GckVector3 *viewpoint,GckVector3 *normal,GckVector3 *light,
|
||||
GckRGB phong_shade(GimpVector3 *pos,GimpVector3 *viewpoint,GimpVector3 *normal,GimpVector3 *light,
|
||||
GckRGB *diff_col,GckRGB *spec_col,gint type)
|
||||
{
|
||||
GckRGB ambientcolor,diffusecolor,specularcolor;
|
||||
gdouble NL,RV,dist;
|
||||
GckVector3 L,NN,V,N;
|
||||
GimpVector3 L,NN,V,N;
|
||||
|
||||
/* Compute ambient intensity */
|
||||
/* ========================= */
|
||||
|
@ -37,28 +37,28 @@ GckRGB phong_shade(GckVector3 *pos,GckVector3 *viewpoint,GckVector3 *normal,GckV
|
|||
/* ====================================== */
|
||||
|
||||
if (type==POINT_LIGHT)
|
||||
gck_vector3_sub(&L,light,pos);
|
||||
gimp_vector3_sub(&L,light,pos);
|
||||
else
|
||||
L=*light;
|
||||
|
||||
dist=gck_vector3_length(&L);
|
||||
dist=gimp_vector3_length(&L);
|
||||
|
||||
if (dist!=0.0)
|
||||
gck_vector3_mul(&L,1.0/dist);
|
||||
gimp_vector3_mul(&L,1.0/dist);
|
||||
|
||||
NL=2.0*gck_vector3_inner_product(&N,&L);
|
||||
NL=2.0*gimp_vector3_inner_product(&N,&L);
|
||||
|
||||
if (NL>=0.0)
|
||||
{
|
||||
/* Compute (R*V)^alpha term of Phong's equation */
|
||||
/* ============================================ */
|
||||
|
||||
gck_vector3_sub(&V,viewpoint,pos);
|
||||
gck_vector3_normalize(&V);
|
||||
gimp_vector3_sub(&V,viewpoint,pos);
|
||||
gimp_vector3_normalize(&V);
|
||||
|
||||
gck_vector3_mul(&N,NL);
|
||||
gck_vector3_sub(&NN,&N,&L);
|
||||
RV=gck_vector3_inner_product(&NN,&V);
|
||||
gimp_vector3_mul(&N,NL);
|
||||
gimp_vector3_sub(&NN,&N,&L);
|
||||
RV=gimp_vector3_inner_product(&NN,&V);
|
||||
RV=pow(RV,mapvals.material.highlight);
|
||||
|
||||
/* Compute diffuse and specular intensity contribution */
|
||||
|
@ -82,7 +82,7 @@ GckRGB phong_shade(GckVector3 *pos,GckVector3 *viewpoint,GckVector3 *normal,GckV
|
|||
return(ambientcolor);
|
||||
}
|
||||
|
||||
gint plane_intersect(GckVector3 *dir,GckVector3 *viewp,GckVector3 *ipos,gdouble *u,gdouble *v)
|
||||
gint plane_intersect(GimpVector3 *dir,GimpVector3 *viewp,GimpVector3 *ipos,gdouble *u,gdouble *v)
|
||||
{
|
||||
static gdouble det,det1,det2,det3,t;
|
||||
|
||||
|
@ -141,18 +141,18 @@ gint plane_intersect(GckVector3 *dir,GckVector3 *viewp,GckVector3 *ipos,gdouble
|
|||
/* These routines computes the color of the surface of the plane at a given point */
|
||||
/**********************************************************************************/
|
||||
|
||||
GckRGB get_ray_color_plane(GckVector3 *pos)
|
||||
GckRGB get_ray_color_plane(GimpVector3 *pos)
|
||||
{
|
||||
GckRGB color=background;
|
||||
static gint inside=FALSE;
|
||||
static GckVector3 ray,spos;
|
||||
static GimpVector3 ray,spos;
|
||||
static gdouble vx,vy;
|
||||
|
||||
/* Construct a line from our VP to the point */
|
||||
/* ========================================= */
|
||||
|
||||
gck_vector3_sub(&ray,pos,&mapvals.viewpoint);
|
||||
gck_vector3_normalize(&ray);
|
||||
gimp_vector3_sub(&ray,pos,&mapvals.viewpoint);
|
||||
gimp_vector3_normalize(&ray);
|
||||
|
||||
/* Check for intersection. This is a quasi ray-tracer. */
|
||||
/* =================================================== */
|
||||
|
@ -186,19 +186,19 @@ GckRGB get_ray_color_plane(GckVector3 *pos)
|
|||
/* the conversion from spherical oordinates to image space coordinates */
|
||||
/***********************************************************************/
|
||||
|
||||
void sphere_to_image(GckVector3 *normal,gdouble *u,gdouble *v)
|
||||
void sphere_to_image(GimpVector3 *normal,gdouble *u,gdouble *v)
|
||||
{
|
||||
static gdouble alpha,fac;
|
||||
static GckVector3 cross_prod;
|
||||
static GimpVector3 cross_prod;
|
||||
|
||||
alpha=acos(-gck_vector3_inner_product(&mapvals.secondaxis,normal));
|
||||
alpha=acos(-gimp_vector3_inner_product(&mapvals.secondaxis,normal));
|
||||
|
||||
*v=alpha/M_PI;
|
||||
|
||||
if (*v==0.0 || *v==1.0) *u=0.0;
|
||||
else
|
||||
{
|
||||
fac=gck_vector3_inner_product(&mapvals.firstaxis,normal)/sin(alpha);
|
||||
fac=gimp_vector3_inner_product(&mapvals.firstaxis,normal)/sin(alpha);
|
||||
|
||||
/* Make sure that we map to -1.0..1.0 (take care of rounding errors) */
|
||||
/* ================================================================= */
|
||||
|
@ -210,9 +210,9 @@ void sphere_to_image(GckVector3 *normal,gdouble *u,gdouble *v)
|
|||
|
||||
*u=acos(fac)/(2.0*M_PI);
|
||||
|
||||
cross_prod=gck_vector3_cross_product(&mapvals.secondaxis,&mapvals.firstaxis);
|
||||
cross_prod=gimp_vector3_cross_product(&mapvals.secondaxis,&mapvals.firstaxis);
|
||||
|
||||
if (gck_vector3_inner_product(&cross_prod,normal)<0.0)
|
||||
if (gimp_vector3_inner_product(&cross_prod,normal)<0.0)
|
||||
*u=1.0-*u;
|
||||
}
|
||||
}
|
||||
|
@ -221,15 +221,15 @@ void sphere_to_image(GckVector3 *normal,gdouble *u,gdouble *v)
|
|||
/* Compute intersection point with sphere (if any) */
|
||||
/***************************************************/
|
||||
|
||||
gint sphere_intersect(GckVector3 *dir,GckVector3 *viewp,GckVector3 *spos1,GckVector3 *spos2)
|
||||
gint sphere_intersect(GimpVector3 *dir,GimpVector3 *viewp,GimpVector3 *spos1,GimpVector3 *spos2)
|
||||
{
|
||||
static gdouble alpha,beta,tau,s1,s2,tmp;
|
||||
static GckVector3 t;
|
||||
static GimpVector3 t;
|
||||
|
||||
gck_vector3_sub(&t,&mapvals.position,viewp);
|
||||
gimp_vector3_sub(&t,&mapvals.position,viewp);
|
||||
|
||||
alpha=gck_vector3_inner_product(dir,&t);
|
||||
beta=gck_vector3_inner_product(&t,&t);
|
||||
alpha=gimp_vector3_inner_product(dir,&t);
|
||||
beta=gimp_vector3_inner_product(&t,&t);
|
||||
|
||||
tau=alpha*alpha-beta+mapvals.radius*mapvals.radius;
|
||||
|
||||
|
@ -263,12 +263,12 @@ gint sphere_intersect(GckVector3 *dir,GckVector3 *viewp,GckVector3 *spos1,GckVec
|
|||
/* These routines computes the color of the surface of the sphere at a given point */
|
||||
/***********************************************************************************/
|
||||
|
||||
GckRGB get_ray_color_sphere(GckVector3 *pos)
|
||||
GckRGB get_ray_color_sphere(GimpVector3 *pos)
|
||||
{
|
||||
GckRGB color=background;
|
||||
static GckRGB color2;
|
||||
static gint inside=FALSE;
|
||||
static GckVector3 normal,ray,spos1,spos2;
|
||||
static GimpVector3 normal,ray,spos1,spos2;
|
||||
static gdouble vx,vy;
|
||||
|
||||
/* Check if ray is within the bounding box */
|
||||
|
@ -280,8 +280,8 @@ GckRGB get_ray_color_sphere(GckVector3 *pos)
|
|||
/* Construct a line from our VP to the point */
|
||||
/* ========================================= */
|
||||
|
||||
gck_vector3_sub(&ray,pos,&mapvals.viewpoint);
|
||||
gck_vector3_normalize(&ray);
|
||||
gimp_vector3_sub(&ray,pos,&mapvals.viewpoint);
|
||||
gimp_vector3_normalize(&ray);
|
||||
|
||||
/* Check for intersection. This is a quasi ray-tracer. */
|
||||
/* =================================================== */
|
||||
|
@ -291,8 +291,8 @@ GckRGB get_ray_color_sphere(GckVector3 *pos)
|
|||
/* Compute spherical to rectangular mapping */
|
||||
/* ======================================== */
|
||||
|
||||
gck_vector3_sub(&normal,&spos1,&mapvals.position);
|
||||
gck_vector3_normalize(&normal);
|
||||
gimp_vector3_sub(&normal,&spos1,&mapvals.position);
|
||||
gimp_vector3_normalize(&normal);
|
||||
sphere_to_image(&normal,&vx,&vy);
|
||||
color=get_image_color(vx,vy,&inside);
|
||||
|
||||
|
@ -315,15 +315,15 @@ GckRGB get_ray_color_sphere(GckVector3 *pos)
|
|||
|
||||
gck_rgba_clamp(&color);
|
||||
|
||||
gck_vector3_sub(&normal,&spos2,&mapvals.position);
|
||||
gck_vector3_normalize(&normal);
|
||||
gimp_vector3_sub(&normal,&spos2,&mapvals.position);
|
||||
gimp_vector3_normalize(&normal);
|
||||
sphere_to_image(&normal,&vx,&vy);
|
||||
color2=get_image_color(vx,vy,&inside);
|
||||
|
||||
/* Make the normal point inwards */
|
||||
/* ============================= */
|
||||
|
||||
gck_vector3_mul(&normal,-1.0);
|
||||
gimp_vector3_mul(&normal,-1.0);
|
||||
|
||||
color2=phong_shade(&spos2,
|
||||
&mapvals.viewpoint,
|
||||
|
@ -382,9 +382,9 @@ GckRGB get_ray_color_sphere(GckVector3 *pos)
|
|||
|
||||
void compute_bounding_box(void)
|
||||
{
|
||||
GckVector3 p1,p2;
|
||||
GimpVector3 p1,p2;
|
||||
gdouble t;
|
||||
GckVector3 dir;
|
||||
GimpVector3 dir;
|
||||
|
||||
p1=mapvals.position;
|
||||
p1.x-=(mapvals.radius+0.01);
|
||||
|
@ -394,8 +394,8 @@ void compute_bounding_box(void)
|
|||
p2.x+=(mapvals.radius+0.01);
|
||||
p2.y+=(mapvals.radius+0.01);
|
||||
|
||||
gck_vector3_sub(&dir,&p1,&mapvals.viewpoint);
|
||||
gck_vector3_normalize(&dir);
|
||||
gimp_vector3_sub(&dir,&p1,&mapvals.viewpoint);
|
||||
gimp_vector3_normalize(&dir);
|
||||
|
||||
if (dir.z!=0.0)
|
||||
{
|
||||
|
@ -404,8 +404,8 @@ void compute_bounding_box(void)
|
|||
p1.y=(mapvals.viewpoint.y+t*dir.y);
|
||||
}
|
||||
|
||||
gck_vector3_sub(&dir,&p2,&mapvals.viewpoint);
|
||||
gck_vector3_normalize(&dir);
|
||||
gimp_vector3_sub(&dir,&p2,&mapvals.viewpoint);
|
||||
gimp_vector3_normalize(&dir);
|
||||
|
||||
if (dir.z!=0.0)
|
||||
{
|
||||
|
@ -427,7 +427,7 @@ void compute_bounding_box(void)
|
|||
/* about the given axis. */
|
||||
/* ============================================================ */
|
||||
|
||||
void vecmulmat(GckVector3 *u,GckVector3 *v,gfloat m[16])
|
||||
void vecmulmat(GimpVector3 *u,GimpVector3 *v,gfloat m[16])
|
||||
{
|
||||
gfloat v0=v->x, v1=v->y, v2=v->z;
|
||||
#define M(row,col) m[col*4+row]
|
||||
|
@ -437,7 +437,7 @@ void vecmulmat(GckVector3 *u,GckVector3 *v,gfloat m[16])
|
|||
#undef M
|
||||
}
|
||||
|
||||
void rotatemat(gfloat angle,GckVector3 *v,gfloat m[16])
|
||||
void rotatemat(gfloat angle,GimpVector3 *v,gfloat m[16])
|
||||
{
|
||||
/* This function contributed by Erich Boleyn (erich@uruk.org) */
|
||||
gfloat mag, s, c;
|
||||
|
@ -575,7 +575,7 @@ void ident_mat(gfloat m[16])
|
|||
}
|
||||
|
||||
gboolean intersect_rect(gdouble u,gdouble v,gdouble w,
|
||||
GckVector3 viewp,GckVector3 dir,
|
||||
GimpVector3 viewp,GimpVector3 dir,
|
||||
FaceIntersectInfo *face_info)
|
||||
{
|
||||
gboolean result = FALSE;
|
||||
|
@ -603,18 +603,18 @@ gboolean intersect_rect(gdouble u,gdouble v,gdouble w,
|
|||
return(result);
|
||||
}
|
||||
|
||||
gboolean intersect_box(GckVector3 scale, GckVector3 viewp, GckVector3 dir,
|
||||
gboolean intersect_box(GimpVector3 scale, GimpVector3 viewp, GimpVector3 dir,
|
||||
FaceIntersectInfo *face_intersect)
|
||||
{
|
||||
GckVector3 v,d,tmp,axis[3];
|
||||
GimpVector3 v,d,tmp,axis[3];
|
||||
FaceIntersectInfo face_tmp;
|
||||
gboolean result = FALSE;
|
||||
gfloat m[16];
|
||||
gint i = 0;
|
||||
|
||||
gck_vector3_set(&axis[0], 1.0,0.0,0.0);
|
||||
gck_vector3_set(&axis[1], 0.0,1.0,0.0);
|
||||
gck_vector3_set(&axis[2], 0.0,0.0,1.0);
|
||||
gimp_vector3_set(&axis[0], 1.0,0.0,0.0);
|
||||
gimp_vector3_set(&axis[1], 0.0,1.0,0.0);
|
||||
gimp_vector3_set(&axis[2], 0.0,0.0,1.0);
|
||||
|
||||
/* Front side */
|
||||
/* ========== */
|
||||
|
@ -622,7 +622,7 @@ gboolean intersect_box(GckVector3 scale, GckVector3 viewp, GckVector3 dir,
|
|||
if (intersect_rect(scale.x,scale.y,scale.z/2.0,viewp,dir,&face_intersect[i])==TRUE)
|
||||
{
|
||||
face_intersect[i].face = 0;
|
||||
gck_vector3_set(&face_intersect[i++].n, 0.0,0.0,1.0);
|
||||
gimp_vector3_set(&face_intersect[i++].n, 0.0,0.0,1.0);
|
||||
result = TRUE;
|
||||
}
|
||||
|
||||
|
@ -632,7 +632,7 @@ gboolean intersect_box(GckVector3 scale, GckVector3 viewp, GckVector3 dir,
|
|||
if (intersect_rect(scale.x,scale.y,-scale.z/2.0,viewp,dir,&face_intersect[i])==TRUE)
|
||||
{
|
||||
face_intersect[i].face = 1;
|
||||
gck_vector3_set(&face_intersect[i++].n, 0.0,0.0,-1.0);
|
||||
gimp_vector3_set(&face_intersect[i++].n, 0.0,0.0,-1.0);
|
||||
face_intersect[i].u = 1.0 - face_intersect[i].u;
|
||||
face_intersect[i].v = 1.0 - face_intersect[i].v;
|
||||
result = TRUE;
|
||||
|
@ -658,7 +658,7 @@ gboolean intersect_box(GckVector3 scale, GckVector3 viewp, GckVector3 dir,
|
|||
vecmulmat(&tmp, &face_intersect[i].s, m);
|
||||
face_intersect[i].s = tmp;
|
||||
|
||||
gck_vector3_set(&face_intersect[i++].n, 0.0,-1.0,0.0);
|
||||
gimp_vector3_set(&face_intersect[i++].n, 0.0,-1.0,0.0);
|
||||
result = TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -686,7 +686,7 @@ gboolean intersect_box(GckVector3 scale, GckVector3 viewp, GckVector3 dir,
|
|||
|
||||
face_intersect[i].v = 1.0 - face_intersect[i].v;
|
||||
|
||||
gck_vector3_set(&face_intersect[i++].n, 0.0,1.0,0.0);
|
||||
gimp_vector3_set(&face_intersect[i++].n, 0.0,1.0,0.0);
|
||||
|
||||
result = TRUE;
|
||||
}
|
||||
|
@ -712,7 +712,7 @@ gboolean intersect_box(GckVector3 scale, GckVector3 viewp, GckVector3 dir,
|
|||
vecmulmat(&tmp, &face_intersect[i].s, m);
|
||||
face_intersect[i].s = tmp;
|
||||
|
||||
gck_vector3_set(&face_intersect[i++].n, 1.0,0.0,0.0);
|
||||
gimp_vector3_set(&face_intersect[i++].n, 1.0,0.0,0.0);
|
||||
result = TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -738,7 +738,7 @@ gboolean intersect_box(GckVector3 scale, GckVector3 viewp, GckVector3 dir,
|
|||
|
||||
face_intersect[i].u = 1.0 - face_intersect[i].u;
|
||||
|
||||
gck_vector3_set(&face_intersect[i++].n, -1.0,0.0,0.0);
|
||||
gimp_vector3_set(&face_intersect[i++].n, -1.0,0.0,0.0);
|
||||
result = TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -756,9 +756,9 @@ gboolean intersect_box(GckVector3 scale, GckVector3 viewp, GckVector3 dir,
|
|||
return(result);
|
||||
}
|
||||
|
||||
GckRGB get_ray_color_box(GckVector3 *pos)
|
||||
GckRGB get_ray_color_box(GimpVector3 *pos)
|
||||
{
|
||||
GckVector3 lvp,ldir,vp,p,dir,ns,nn;
|
||||
GimpVector3 lvp,ldir,vp,p,dir,ns,nn;
|
||||
GckRGB color, color2;
|
||||
gfloat m[16];
|
||||
gint i;
|
||||
|
@ -783,8 +783,8 @@ GckRGB get_ray_color_box(GckVector3 *pos)
|
|||
/* Compute direction */
|
||||
/* ================= */
|
||||
|
||||
gck_vector3_sub(&dir,&p,&vp);
|
||||
gck_vector3_normalize(&dir);
|
||||
gimp_vector3_sub(&dir,&p,&vp);
|
||||
gimp_vector3_normalize(&dir);
|
||||
|
||||
/* Compute inverse of rotation matrix and apply it to */
|
||||
/* the viewpoint and direction. This transforms the */
|
||||
|
@ -854,7 +854,7 @@ GckRGB get_ray_color_box(GckVector3 *pos)
|
|||
/* Make the normal point inwards */
|
||||
/* ============================= */
|
||||
|
||||
gck_vector3_mul(&face_intersect[1].n,-1.0);
|
||||
gimp_vector3_mul(&face_intersect[1].n,-1.0);
|
||||
|
||||
color2=phong_shade(
|
||||
&face_intersect[1].s,
|
||||
|
@ -908,7 +908,7 @@ GckRGB get_ray_color_box(GckVector3 *pos)
|
|||
return(color);
|
||||
}
|
||||
|
||||
gboolean intersect_circle(GckVector3 vp,GckVector3 dir,gdouble w,
|
||||
gboolean intersect_circle(GimpVector3 vp,GimpVector3 dir,gdouble w,
|
||||
FaceIntersectInfo *face_info)
|
||||
{
|
||||
gboolean result = FALSE;
|
||||
|
@ -976,7 +976,7 @@ gdouble compute_angle(gdouble x,gdouble y)
|
|||
return(a);
|
||||
}
|
||||
|
||||
gboolean intersect_cylinder(GckVector3 vp,GckVector3 dir,FaceIntersectInfo *face_intersect)
|
||||
gboolean intersect_cylinder(GimpVector3 vp,GimpVector3 dir,FaceIntersectInfo *face_intersect)
|
||||
{
|
||||
gdouble a,b,c,d,e,f,tmp,l;
|
||||
gboolean result = FALSE;
|
||||
|
@ -1016,7 +1016,7 @@ gboolean intersect_cylinder(GckVector3 vp,GckVector3 dir,FaceIntersectInfo *face
|
|||
|
||||
face_intersect[i].n = face_intersect[i].s;
|
||||
face_intersect[i].n.y = 0.0;
|
||||
gck_vector3_normalize(&face_intersect[i].n);
|
||||
gimp_vector3_normalize(&face_intersect[i].n);
|
||||
|
||||
l = mapvals.cylinder_length/2.0;
|
||||
|
||||
|
@ -1043,7 +1043,7 @@ gboolean intersect_cylinder(GckVector3 vp,GckVector3 dir,FaceIntersectInfo *face
|
|||
else
|
||||
{
|
||||
face_intersect[i].face = 1;
|
||||
gck_vector3_set(&face_intersect[i].n, 0.0, 1.0, 0.0);
|
||||
gimp_vector3_set(&face_intersect[i].n, 0.0, 1.0, 0.0);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1053,7 +1053,7 @@ gboolean intersect_cylinder(GckVector3 vp,GckVector3 dir,FaceIntersectInfo *face
|
|||
else
|
||||
{
|
||||
face_intersect[i].face = 2;
|
||||
gck_vector3_set(&face_intersect[i].n, 0.0, -1.0, 0.0);
|
||||
gimp_vector3_set(&face_intersect[i].n, 0.0, -1.0, 0.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1079,9 +1079,9 @@ GckRGB get_cylinder_color(gint face, gdouble u, gdouble v)
|
|||
return(color);
|
||||
}
|
||||
|
||||
GckRGB get_ray_color_cylinder(GckVector3 *pos)
|
||||
GckRGB get_ray_color_cylinder(GimpVector3 *pos)
|
||||
{
|
||||
GckVector3 lvp,ldir,vp,p,dir,ns,nn;
|
||||
GimpVector3 lvp,ldir,vp,p,dir,ns,nn;
|
||||
GckRGB color, color2;
|
||||
gfloat m[16];
|
||||
gint i;
|
||||
|
@ -1102,8 +1102,8 @@ GckRGB get_ray_color_cylinder(GckVector3 *pos)
|
|||
/* Compute direction */
|
||||
/* ================= */
|
||||
|
||||
gck_vector3_sub(&dir,&p,&vp);
|
||||
gck_vector3_normalize(&dir);
|
||||
gimp_vector3_sub(&dir,&p,&vp);
|
||||
gimp_vector3_normalize(&dir);
|
||||
|
||||
/* Compute inverse of rotation matrix and apply it to */
|
||||
/* the viewpoint and direction. This transforms the */
|
||||
|
@ -1165,7 +1165,7 @@ GckRGB get_ray_color_cylinder(GckVector3 *pos)
|
|||
/* Make the normal point inwards */
|
||||
/* ============================= */
|
||||
|
||||
gck_vector3_mul(&face_intersect[1].n,-1.0);
|
||||
gimp_vector3_mul(&face_intersect[1].n,-1.0);
|
||||
|
||||
color2=phong_shade(
|
||||
&face_intersect[1].s,
|
||||
|
|
|
@ -10,17 +10,17 @@
|
|||
#include "mapobject_main.h"
|
||||
#include "mapobject_image.h"
|
||||
|
||||
typedef GckRGB (*get_ray_color_func)(GckVector3 *pos);
|
||||
typedef GckRGB (*get_ray_color_func)(GimpVector3 *pos);
|
||||
|
||||
extern get_ray_color_func get_ray_color;
|
||||
extern GckRGB get_ray_color_plane (GckVector3 *pos);
|
||||
extern GckRGB get_ray_color_sphere (GckVector3 *pos);
|
||||
extern GckRGB get_ray_color_box (GckVector3 *pos);
|
||||
extern GckRGB get_ray_color_cylinder (GckVector3 *pos);
|
||||
extern GckRGB get_ray_color_plane (GimpVector3 *pos);
|
||||
extern GckRGB get_ray_color_sphere (GimpVector3 *pos);
|
||||
extern GckRGB get_ray_color_box (GimpVector3 *pos);
|
||||
extern GckRGB get_ray_color_cylinder (GimpVector3 *pos);
|
||||
extern void compute_bounding_box (void);
|
||||
|
||||
extern void vecmulmat (GckVector3 *u,GckVector3 *v,gfloat m[16]);
|
||||
extern void rotatemat (gfloat angle,GckVector3 *v,gfloat m[16]);
|
||||
extern void vecmulmat (GimpVector3 *u,GimpVector3 *v,gfloat m[16]);
|
||||
extern void rotatemat (gfloat angle,GimpVector3 *v,gfloat m[16]);
|
||||
extern void transpose_mat (gfloat m[16]);
|
||||
extern void matmul (gfloat a[16],gfloat b[16],gfloat c[16]);
|
||||
extern void ident_mat (gfloat m[16]);
|
||||
|
|
|
@ -6,21 +6,14 @@ lib_LTLIBRARIES = libgck.la
|
|||
|
||||
libgck_la_SOURCES = \
|
||||
gckcolor.c \
|
||||
gcklistbox.c \
|
||||
gckmath.c \
|
||||
gckui.c \
|
||||
gckvector.c
|
||||
gckui.c
|
||||
|
||||
gckinclude_HEADERS = \
|
||||
gck.h \
|
||||
gckcolor.h \
|
||||
gckcommon.h \
|
||||
gckimage.h \
|
||||
gcklistbox.h \
|
||||
gckmath.h \
|
||||
gcktypes.h \
|
||||
gckui.h \
|
||||
gckvector.h
|
||||
gckui.h
|
||||
|
||||
libgck_la_LDFLAGS = \
|
||||
-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) -release $(LT_RELEASE)
|
||||
|
|
|
@ -22,27 +22,13 @@
|
|||
#ifndef __GCK_H__
|
||||
#define __GCK_H__
|
||||
|
||||
#include <glib.h>
|
||||
#include <gdk/gdk.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define g_function_enter(fname)
|
||||
#define g_function_leave(fname)
|
||||
|
||||
#include <gck/gckcommon.h>
|
||||
#include <gck/gcktypes.h>
|
||||
#include <gck/gckcolor.h>
|
||||
#include <gck/gckmath.h>
|
||||
#include <gck/gckvector.h>
|
||||
#include <gck/gckui.h>
|
||||
#include <gck/gcklistbox.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif /* __GCK_H__ */
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
/***************************************************************************/
|
||||
/* GCK - The General Convenience Kit. Generally useful conveniece routines */
|
||||
/* for GIMP plug-in writers and users of the GDK/GTK libraries. */
|
||||
/* Copyright (C) 1996 Tom Bech */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 2 of the License, or */
|
||||
/* (at your option) any later version. */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program; if not, write to the Free Software */
|
||||
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, */
|
||||
/* USA. */
|
||||
/***************************************************************************/
|
||||
|
||||
#ifndef __GCKCOMMON_H__
|
||||
#define __GCKCOMMON_H__
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
#ifndef M_PI_2
|
||||
#define M_PI_2 1.57079632679489661923
|
||||
#endif
|
||||
|
||||
#define EPSILON 1.0e-5
|
||||
|
||||
#endif
|
|
@ -1,896 +0,0 @@
|
|||
/***************************************************************************/
|
||||
/* GCK - The General Convenience Kit. Generally useful conveniece routines */
|
||||
/* for GIMP plug-in writers and users of the GDK/GTK libraries. */
|
||||
/* Copyright (C) 1996 Tom Bech */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 2 of the License, or */
|
||||
/* (at your option) any later version. */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program; if not, write to the Free Software */
|
||||
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, */
|
||||
/* USA. */
|
||||
/***************************************************************************/
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <gdk/gdk.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <gck/gck.h>
|
||||
|
||||
extern gint _GckAutoShowFlag;
|
||||
|
||||
/*******************/
|
||||
/* Disable signals */
|
||||
/*******************/
|
||||
|
||||
void gck_listbox_disable_signals(GckListBox *listbox)
|
||||
{
|
||||
g_function_enter("gck_listbox_disable_signals");
|
||||
g_assert(listbox!=NULL);
|
||||
|
||||
listbox->disable_signals=TRUE;
|
||||
|
||||
g_function_leave("gck_listbox_disable_signals");
|
||||
}
|
||||
|
||||
/******************/
|
||||
/* Enable signals */
|
||||
/******************/
|
||||
|
||||
void gck_listbox_enable_signals(GckListBox *listbox)
|
||||
{
|
||||
g_function_enter("gck_listbox_enable_signals");
|
||||
g_assert(listbox!=NULL);
|
||||
|
||||
listbox->disable_signals=FALSE;
|
||||
|
||||
g_function_leave("gck_listbox_enable_signals");
|
||||
}
|
||||
|
||||
/*********************************************************************/
|
||||
/* Get listbox field of the first element of the given list of items */
|
||||
/*********************************************************************/
|
||||
|
||||
GckListBox *gck_listbox_get(GList *itemlist)
|
||||
{
|
||||
g_function_enter("gck_listbox_get");
|
||||
g_assert(itemlist!=NULL);
|
||||
g_assert(itemlist->data!=NULL);
|
||||
g_function_leave("gck_listbox_get");
|
||||
|
||||
return(((GckListBoxItem *)itemlist->data)->listbox);
|
||||
}
|
||||
|
||||
/********************************/
|
||||
/* Prepend one item to the list */
|
||||
/********************************/
|
||||
|
||||
void gck_listbox_prepend_item(GckListBox *listbox,GckListBoxItem *item)
|
||||
{
|
||||
g_function_enter("gck_listbox_prepend_item");
|
||||
g_assert(listbox!=NULL);
|
||||
g_assert(item!=NULL);
|
||||
|
||||
gck_listbox_insert_item(listbox,item,0);
|
||||
|
||||
g_function_leave("gck_listbox_prepend_item");
|
||||
}
|
||||
|
||||
/***************************************/
|
||||
/* Prepend a list of items to the list */
|
||||
/***************************************/
|
||||
|
||||
void gck_listbox_prepend_items(GckListBox *listbox,GList *itemlist)
|
||||
{
|
||||
GList *current;
|
||||
|
||||
g_function_enter("gck_listbox_prepend_items");
|
||||
g_assert(listbox!=NULL);
|
||||
g_assert(itemlist!=NULL);
|
||||
|
||||
current=g_list_last(itemlist);
|
||||
while (current!=NULL)
|
||||
{
|
||||
gck_listbox_insert_item(listbox,(GckListBoxItem *)current->data,0);
|
||||
current=current->prev;
|
||||
}
|
||||
|
||||
g_function_leave("gck_listbox_prepend_items");
|
||||
}
|
||||
|
||||
/*******************************/
|
||||
/* Append one item to the list */
|
||||
/*******************************/
|
||||
|
||||
void gck_listbox_append_item(GckListBox *listbox,GckListBoxItem *item)
|
||||
{
|
||||
g_function_enter("gck_listbox_append_item");
|
||||
g_assert(listbox!=NULL);
|
||||
g_assert(item!=NULL);
|
||||
|
||||
gck_listbox_insert_item(listbox,item,listbox->num_items);
|
||||
|
||||
g_function_leave("gck_listbox_append_item");
|
||||
}
|
||||
|
||||
/**************************************/
|
||||
/* Append a list of items to the list */
|
||||
/**************************************/
|
||||
|
||||
void gck_listbox_append_items(GckListBox *listbox,GList *itemlist)
|
||||
{
|
||||
GList *current;
|
||||
|
||||
g_function_enter("gck_listbox_append_items");
|
||||
g_assert(listbox!=NULL);
|
||||
g_assert(itemlist!=NULL);
|
||||
|
||||
current=g_list_first(itemlist);
|
||||
while (current!=NULL)
|
||||
{
|
||||
gck_listbox_insert_item(listbox,(GckListBoxItem *)current->data,listbox->num_items);
|
||||
current=current->next;
|
||||
}
|
||||
|
||||
g_function_leave("gck_listbox_append_items");
|
||||
}
|
||||
|
||||
/*****************************************/
|
||||
/* Insert one item at the given position */
|
||||
/*****************************************/
|
||||
|
||||
void gck_listbox_insert_item(GckListBox *listbox,GckListBoxItem *item,gint position)
|
||||
{
|
||||
GckListBoxItem *newlistboxitem;
|
||||
GtkWidget *newitem,*hbox,*align;
|
||||
GList *glist=NULL;
|
||||
|
||||
g_function_enter("gck_listbox_insert_item");
|
||||
g_assert(listbox!=NULL);
|
||||
g_assert(item!=NULL);
|
||||
|
||||
if (position>listbox->num_items)
|
||||
position=listbox->num_items;
|
||||
if (position<0)
|
||||
position=0;
|
||||
|
||||
newlistboxitem=(GckListBoxItem *)malloc(sizeof(GckListBoxItem));
|
||||
if (newlistboxitem!=NULL)
|
||||
{
|
||||
*newlistboxitem=*item;
|
||||
newlistboxitem->listbox=listbox;
|
||||
listbox->itemlist=g_list_append(listbox->itemlist,newlistboxitem);
|
||||
|
||||
if (newlistboxitem->widget != NULL)
|
||||
{
|
||||
newitem = gtk_list_item_new ();
|
||||
hbox = gck_hbox_new (newitem, FALSE,FALSE,FALSE, 0,0,0);
|
||||
gtk_box_pack_start(GTK_BOX (hbox), newlistboxitem->widget, FALSE,FALSE,0);
|
||||
align=gtk_alignment_new(0.0,0.5,0.0,0.0);
|
||||
gck_label_new (newlistboxitem->label, align);
|
||||
gtk_widget_show(align);
|
||||
gtk_box_pack_start(GTK_BOX (hbox), align, FALSE,FALSE,0);
|
||||
}
|
||||
else
|
||||
newitem = gtk_list_item_new_with_label(newlistboxitem->label);
|
||||
|
||||
glist=g_list_append(glist,newitem);
|
||||
gtk_object_set_data(GTK_OBJECT(newitem),"_GckListBoxItem",(gpointer)newlistboxitem);
|
||||
gtk_widget_show(newitem);
|
||||
gtk_list_insert_items(GTK_LIST(listbox->list),glist,position);
|
||||
|
||||
listbox->num_items++;
|
||||
}
|
||||
|
||||
g_function_leave("gck_listbox_insert_item");
|
||||
}
|
||||
|
||||
/**************************************************/
|
||||
/* Insert the list of items at the given position */
|
||||
/**************************************************/
|
||||
|
||||
void gck_listbox_insert_items(GckListBox *listbox,GList *itemlist,gint position)
|
||||
{
|
||||
GList *current;
|
||||
|
||||
g_function_enter("gck_listbox_insert_items");
|
||||
g_assert(listbox!=NULL);
|
||||
g_assert(itemlist!=NULL);
|
||||
|
||||
current=g_list_last(itemlist);
|
||||
while (current!=NULL)
|
||||
{
|
||||
gck_listbox_insert_item(listbox,(GckListBoxItem *)current->data,position);
|
||||
current=current->prev;
|
||||
}
|
||||
|
||||
g_function_leave("gck_listbox_insert_items");
|
||||
}
|
||||
|
||||
/*************************************************/
|
||||
/* Return a list of the currently selected items */
|
||||
/*************************************************/
|
||||
|
||||
GList *gck_listbox_get_current_selection(GckListBox *listbox)
|
||||
{
|
||||
GList *list=NULL,*current;
|
||||
|
||||
g_function_enter("gck_listbox_get_current_selection");
|
||||
g_assert(listbox!=NULL);
|
||||
|
||||
current=g_list_first(listbox->current_selection);
|
||||
while (current!=NULL)
|
||||
{
|
||||
list=g_list_append(list,current->data);
|
||||
current=current->next;
|
||||
}
|
||||
|
||||
g_function_leave("gck_listbox_get_current_selection");
|
||||
return(list);
|
||||
}
|
||||
|
||||
/**************************************************************/
|
||||
/* Rebuild position array and current selection list based on */
|
||||
/* the current selection of the list in the listbox */
|
||||
/**************************************************************/
|
||||
|
||||
void gck_listbox_set_current_selection(GckListBox *listbox)
|
||||
{
|
||||
GList *current,*selection;
|
||||
gint position=0;
|
||||
GtkWidget *widget;
|
||||
|
||||
g_function_enter("gck_listbox_set_current_selection");
|
||||
g_assert(listbox!=NULL);
|
||||
|
||||
if (listbox->current_selection!=NULL)
|
||||
g_list_free(listbox->current_selection);
|
||||
|
||||
selection=g_list_first(GTK_LIST(listbox->list)->selection);
|
||||
|
||||
listbox->current_selection=NULL;
|
||||
|
||||
while (selection!=NULL)
|
||||
{
|
||||
widget=(GtkWidget *)selection->data;
|
||||
position=gtk_list_child_position(GTK_LIST(listbox->list),widget);
|
||||
|
||||
current=g_list_nth(listbox->itemlist,position);
|
||||
listbox->current_selection=g_list_append(listbox->current_selection,current->data);
|
||||
|
||||
selection=selection->next;
|
||||
}
|
||||
|
||||
g_function_leave("gck_listbox_set_current_selection");
|
||||
}
|
||||
|
||||
/**************************************/
|
||||
/* Get the item at the given position */
|
||||
/**************************************/
|
||||
|
||||
GList *gck_listbox_item_find_by_position(GckListBox *listbox,gint position)
|
||||
{
|
||||
GList *item=NULL;
|
||||
|
||||
g_function_enter("gck_listbox_item_find_by_position");
|
||||
|
||||
if (position>=0 && position<=listbox->num_items)
|
||||
item=g_list_nth(listbox->itemlist,position);
|
||||
|
||||
g_function_leave("gck_listbox_item_find_by_position");
|
||||
return(item);
|
||||
}
|
||||
|
||||
/********************************************************/
|
||||
/* Find and return the first item with a matching label */
|
||||
/********************************************************/
|
||||
|
||||
GList *gck_listbox_item_find_by_label(GckListBox *listbox,char *label,gint *position)
|
||||
{
|
||||
GList *current=NULL;
|
||||
gint pos=0;
|
||||
|
||||
g_function_enter("gck_listbox_item_find_by_label");
|
||||
g_assert(listbox!=NULL);
|
||||
|
||||
pos=0;
|
||||
current=g_list_first(listbox->itemlist);
|
||||
while (current!=NULL && strcmp(((GckListBoxItem *)current->data)->label,label)!=0)
|
||||
{
|
||||
current=current->next;
|
||||
pos++;
|
||||
}
|
||||
|
||||
if (position!=NULL)
|
||||
*position=pos;
|
||||
|
||||
g_function_leave("gck_listbox_item_find_by_label");
|
||||
return(current);
|
||||
}
|
||||
|
||||
/*********************************************************/
|
||||
/* Find and return the first item with a user_data field */
|
||||
/*********************************************************/
|
||||
|
||||
GList *gck_listbox_item_find_by_user_data(GckListBox *listbox,gpointer user_data,gint *position)
|
||||
{
|
||||
GList *current=NULL;
|
||||
gint pos=0;
|
||||
|
||||
g_function_enter("gck_listbox_item_find_by_user_data");
|
||||
g_assert(listbox!=NULL);
|
||||
|
||||
pos=0;
|
||||
current=g_list_first(listbox->itemlist);
|
||||
while (current!=NULL && ((GckListBoxItem *)current->data)->user_data!=user_data)
|
||||
{
|
||||
current=current->next;
|
||||
pos++;
|
||||
}
|
||||
|
||||
if (position!=NULL)
|
||||
*position=pos;
|
||||
|
||||
g_function_leave("gck_listbox_item_find_by_user_data");
|
||||
return(current);
|
||||
}
|
||||
|
||||
/***************************/
|
||||
/* Delete item by position */
|
||||
/***************************/
|
||||
|
||||
void gck_listbox_delete_item_by_position(GckListBox *listbox,gint position)
|
||||
{
|
||||
GList *current,*selection;
|
||||
|
||||
g_function_enter("gck_listbox_delete_item_by_position");
|
||||
g_assert(listbox!=NULL);
|
||||
|
||||
/* Traverse item list and check for first matching label */
|
||||
/* ===================================================== */
|
||||
|
||||
current=gck_listbox_item_find_by_position(listbox,position);
|
||||
|
||||
if (current!=NULL)
|
||||
{
|
||||
/* Clear all (other) selected items and select the one we found */
|
||||
/* ============================================================= */
|
||||
|
||||
gck_listbox_unselect_all(listbox);
|
||||
gtk_list_select_item(GTK_LIST(listbox->list),position);
|
||||
|
||||
/* Now, get selection (duh!) and remove it from the GtkList */
|
||||
/* ======================================================== */
|
||||
|
||||
selection=g_list_first(GTK_LIST(listbox->list)->selection);
|
||||
gtk_list_remove_items(GTK_LIST(listbox->list),selection);
|
||||
|
||||
listbox->itemlist=g_list_remove_link(listbox->itemlist,current);
|
||||
listbox->num_items--;
|
||||
|
||||
/* Update current selection item list */
|
||||
/* ================================== */
|
||||
|
||||
gck_listbox_set_current_selection(listbox);
|
||||
}
|
||||
|
||||
g_function_leave("gck_listbox_delete_item_by_position");
|
||||
}
|
||||
|
||||
/************************/
|
||||
/* Delete item by label */
|
||||
/************************/
|
||||
|
||||
void gck_listbox_delete_item_by_label(GckListBox *listbox,char *label)
|
||||
{
|
||||
GList *current,*selection;
|
||||
gint position;
|
||||
|
||||
g_function_enter("gck_listbox_delete_item_by_label");
|
||||
g_assert(listbox!=NULL);
|
||||
|
||||
/* Traverse item list and check for first matching label */
|
||||
/* ===================================================== */
|
||||
|
||||
current=gck_listbox_item_find_by_label(listbox,label,&position);
|
||||
|
||||
if (current!=NULL)
|
||||
{
|
||||
/* Clear all (other) selected items and select the one we found */
|
||||
/* ============================================================= */
|
||||
|
||||
gck_listbox_unselect_all(listbox);
|
||||
gtk_list_select_item(GTK_LIST(listbox->list),position);
|
||||
|
||||
/* Now, get selection (duh!) and remove it from the GtkList */
|
||||
/* ======================================================== */
|
||||
|
||||
selection=g_list_first(GTK_LIST(listbox->list)->selection);
|
||||
gtk_list_remove_items(GTK_LIST(listbox->list),selection);
|
||||
|
||||
listbox->itemlist=g_list_remove_link(listbox->itemlist,current);
|
||||
listbox->num_items--;
|
||||
|
||||
/* Update current selection item list */
|
||||
/* ================================== */
|
||||
|
||||
gck_listbox_set_current_selection(listbox);
|
||||
}
|
||||
|
||||
g_function_leave("gck_listbox_delete_item_by_label");
|
||||
}
|
||||
|
||||
/****************************************************/
|
||||
/* Delete a list of items according to their labels */
|
||||
/****************************************************/
|
||||
|
||||
void gck_listbox_delete_items_by_label(GckListBox *listbox,GList *itemlist)
|
||||
{
|
||||
GList *current;
|
||||
|
||||
g_function_enter("gck_listbox_delete_items_by_label");
|
||||
g_assert(listbox!=NULL);
|
||||
|
||||
current=g_list_first(itemlist);
|
||||
while (current!=NULL)
|
||||
{
|
||||
gck_listbox_delete_item_by_label(listbox,((GckListBoxItem *)current->data)->label);
|
||||
current=current->next;
|
||||
}
|
||||
|
||||
g_function_leave("gck_listbox_delete_items_by_label");
|
||||
}
|
||||
|
||||
/****************************************/
|
||||
/* Delete a item by its user_data field */
|
||||
/****************************************/
|
||||
|
||||
void gck_listbox_delete_item_by_user_data(GckListBox *listbox,gpointer user_data)
|
||||
{
|
||||
GList *current,*selection;
|
||||
gint position;
|
||||
|
||||
g_function_enter("gck_listbox_delete_item_by_user_data");
|
||||
g_assert(listbox!=NULL);
|
||||
|
||||
/* Traverse item list and check for first matching user_data field */
|
||||
/* =============================================================== */
|
||||
|
||||
current=gck_listbox_item_find_by_user_data(listbox,user_data,&position);
|
||||
|
||||
if (current!=NULL)
|
||||
{
|
||||
/* Clear all (other) selected items and select the one we found */
|
||||
/* ============================================================= */
|
||||
|
||||
gck_listbox_unselect_all(listbox);
|
||||
gtk_list_select_item(GTK_LIST(listbox->list),position);
|
||||
|
||||
/* Now, get selection (duh!) and remove it from the GtkList */
|
||||
/* ======================================================== */
|
||||
|
||||
selection=g_list_first(GTK_LIST(listbox->list)->selection);
|
||||
gtk_list_remove_items(GTK_LIST(listbox->list),selection);
|
||||
|
||||
listbox->itemlist=g_list_remove_link(listbox->itemlist,current);
|
||||
listbox->num_items--;
|
||||
|
||||
/* Update current selection item list */
|
||||
/* ================================== */
|
||||
|
||||
gck_listbox_set_current_selection(listbox);
|
||||
}
|
||||
|
||||
g_function_leave("gck_listbox_delete_item_by_user_data");
|
||||
}
|
||||
|
||||
/**************************************************************/
|
||||
/* Remove a list of items according to their user_data fields */
|
||||
/**************************************************************/
|
||||
|
||||
void gck_listbox_delete_items_by_user_data(GckListBox *listbox,GList *itemlist)
|
||||
{
|
||||
GList *current;
|
||||
|
||||
g_function_enter("gck_listbox_delete_items_by_user_data");
|
||||
g_assert(listbox!=NULL);
|
||||
g_assert(itemlist!=NULL);
|
||||
|
||||
current=g_list_first(itemlist);
|
||||
while (current!=NULL)
|
||||
{
|
||||
gck_listbox_delete_item_by_user_data(listbox,((GckListBoxItem *)current->data)->user_data);
|
||||
current=current->next;
|
||||
}
|
||||
|
||||
g_function_leave("gck_listbox_delete_items_by_user_data");
|
||||
}
|
||||
|
||||
/********************************************************/
|
||||
/* Clear all selected items between pos #start and #end */
|
||||
/********************************************************/
|
||||
|
||||
void gck_listbox_clear_items(GckListBox *listbox,gint start,gint end)
|
||||
{
|
||||
g_function_enter("gck_listbox_clear_items");
|
||||
g_assert(listbox!=NULL);
|
||||
|
||||
if (start<0) start=0;
|
||||
if (end>listbox->num_items) end=listbox->num_items;
|
||||
|
||||
gtk_list_clear_items(GTK_LIST(listbox->list),start,end);
|
||||
gck_listbox_set_current_selection(listbox);
|
||||
|
||||
g_function_leave("gck_listbox_clear_items");
|
||||
}
|
||||
|
||||
/*************************************/
|
||||
/* Select item at the given position */
|
||||
/*************************************/
|
||||
|
||||
GList *gck_listbox_select_item_by_position(GckListBox *listbox,gint position)
|
||||
{
|
||||
GList *current;
|
||||
|
||||
g_function_enter("gck_listbox_select_item_by_position");
|
||||
g_assert(listbox!=NULL);
|
||||
|
||||
current=gck_listbox_item_find_by_position(listbox,position);
|
||||
if (current!=NULL)
|
||||
{
|
||||
gtk_list_select_item(GTK_LIST(listbox->list),position);
|
||||
|
||||
/* Update current selection item list */
|
||||
/* ================================== */
|
||||
|
||||
gck_listbox_set_current_selection(listbox);
|
||||
}
|
||||
|
||||
g_function_leave("gck_listbox_select_item_by_position");
|
||||
return(current);
|
||||
}
|
||||
|
||||
/******************************************/
|
||||
/* Select first item with the given label */
|
||||
/******************************************/
|
||||
|
||||
GList *gck_listbox_select_item_by_label(GckListBox *listbox,char *label)
|
||||
{
|
||||
GList *current;
|
||||
gint position;
|
||||
|
||||
g_function_enter("gck_listbox_select_item_by_label");
|
||||
g_assert(listbox!=NULL);
|
||||
|
||||
current=gck_listbox_item_find_by_label(listbox,label,&position);
|
||||
if (current!=NULL)
|
||||
{
|
||||
gtk_list_select_item(GTK_LIST(listbox->list),position);
|
||||
|
||||
/* Update current selection item list */
|
||||
/* ================================== */
|
||||
|
||||
gck_listbox_set_current_selection(listbox);
|
||||
}
|
||||
|
||||
g_function_leave("gck_listbox_select_item_by_label");
|
||||
return(current);
|
||||
}
|
||||
|
||||
/****************************************************/
|
||||
/* Select first item with the given user_data field */
|
||||
/****************************************************/
|
||||
|
||||
GList *gck_listbox_select_item_by_user_data(GckListBox *listbox,gpointer user_data)
|
||||
{
|
||||
GList *current;
|
||||
gint position;
|
||||
|
||||
g_function_enter("gck_listbox_select_item_by_user_data");
|
||||
g_assert(listbox!=NULL);
|
||||
|
||||
current=gck_listbox_item_find_by_user_data(listbox,user_data,&position);
|
||||
if (current!=NULL)
|
||||
{
|
||||
gtk_list_select_item(GTK_LIST(listbox->list),position);
|
||||
|
||||
/* Update current selection item list */
|
||||
/* ================================== */
|
||||
|
||||
gck_listbox_set_current_selection(listbox);
|
||||
}
|
||||
|
||||
g_function_leave("gck_listbox_select_item_by_user_data");
|
||||
return(current);
|
||||
}
|
||||
|
||||
/*****************************/
|
||||
/* Unselect item by position */
|
||||
/*****************************/
|
||||
|
||||
GList *gck_listbox_unselect_item_by_position(GckListBox *listbox,gint position)
|
||||
{
|
||||
GList *current;
|
||||
|
||||
g_function_enter("gck_listbox_unselect_item_by_position");
|
||||
g_assert(listbox!=NULL);
|
||||
|
||||
current=gck_listbox_item_find_by_position(listbox,position);
|
||||
if (current!=NULL)
|
||||
{
|
||||
gtk_list_unselect_item(GTK_LIST(listbox->list),position);
|
||||
|
||||
/* Update current selection item list */
|
||||
/* ================================== */
|
||||
|
||||
gck_listbox_set_current_selection(listbox);
|
||||
}
|
||||
|
||||
g_function_leave("gck_listbox_unselect_item_by_position");
|
||||
return(current);
|
||||
}
|
||||
|
||||
/**************************/
|
||||
/* Unselect item by label */
|
||||
/**************************/
|
||||
|
||||
GList *gck_listbox_unselect_item_by_label(GckListBox *listbox,char *label)
|
||||
{
|
||||
GList *current;
|
||||
gint position;
|
||||
|
||||
g_function_enter("gck_listbox_unselect_item_by_label");
|
||||
g_assert(listbox!=NULL);
|
||||
|
||||
current=gck_listbox_item_find_by_label(listbox,label,&position);
|
||||
if (current!=NULL)
|
||||
{
|
||||
gtk_list_unselect_item(GTK_LIST(listbox->list),position);
|
||||
|
||||
/* Update current selection item list */
|
||||
/* ================================== */
|
||||
|
||||
gck_listbox_set_current_selection(listbox);
|
||||
}
|
||||
|
||||
g_function_leave("gck_listbox_unselect_item_by_label");
|
||||
return(current);
|
||||
}
|
||||
|
||||
/******************************/
|
||||
/* Unselect item by user_data */
|
||||
/******************************/
|
||||
|
||||
GList *gck_listbox_unselect_item_by_user_data(GckListBox *listbox,gpointer user_data)
|
||||
{
|
||||
GList *current;
|
||||
gint position;
|
||||
|
||||
g_function_enter("gck_listbox_unselect_item_by_user_data");
|
||||
g_assert(listbox!=NULL);
|
||||
|
||||
current=gck_listbox_item_find_by_user_data(listbox,user_data,&position);
|
||||
if (current!=NULL)
|
||||
{
|
||||
gtk_list_unselect_item(GTK_LIST(listbox->list),position);
|
||||
|
||||
/* Update current selection item list */
|
||||
/* ================================== */
|
||||
|
||||
gck_listbox_set_current_selection(listbox);
|
||||
}
|
||||
|
||||
g_function_leave("gck_listbox_unselect_item_by_user_data");
|
||||
return(current);
|
||||
}
|
||||
|
||||
/********************************/
|
||||
/* Select all items in the list */
|
||||
/********************************/
|
||||
|
||||
void gck_listbox_select_all(GckListBox *listbox)
|
||||
{
|
||||
gint position;
|
||||
|
||||
g_function_enter("gck_listbox_select_all");
|
||||
g_assert(listbox!=NULL);
|
||||
|
||||
gck_listbox_unselect_all(listbox);
|
||||
|
||||
for (position=0;position<listbox->num_items;position++)
|
||||
gtk_list_select_item(GTK_LIST(listbox->list),position);
|
||||
|
||||
/* Update current selection item list */
|
||||
/* ================================== */
|
||||
|
||||
gck_listbox_set_current_selection(listbox);
|
||||
g_function_leave("gck_listbox_select_all");
|
||||
}
|
||||
|
||||
/**********************************/
|
||||
/* Unselect all items in the list */
|
||||
/**********************************/
|
||||
|
||||
void gck_listbox_unselect_all(GckListBox *listbox)
|
||||
{
|
||||
GList *selection;
|
||||
|
||||
g_function_enter("gck_listbox_unselect_all");
|
||||
g_assert(listbox!=NULL);
|
||||
|
||||
selection=g_list_first(GTK_LIST(listbox->list)->selection);
|
||||
|
||||
while (selection!=NULL)
|
||||
{
|
||||
gtk_list_unselect_child(GTK_LIST(listbox->list),(GtkWidget *)selection->data);
|
||||
selection=g_list_first(GTK_LIST(listbox->list)->selection);
|
||||
}
|
||||
gck_listbox_set_current_selection(listbox);
|
||||
|
||||
g_function_leave("gck_listbox_unselect_all");
|
||||
}
|
||||
|
||||
/**************************************************************/
|
||||
/* Event handler. Filters out uninteresting events and stores */
|
||||
/* the even, so we can use it when the list signal comes */
|
||||
/**************************************************************/
|
||||
|
||||
void _gck_listbox_signalhandler(GtkWidget *widget,GtkListItem *item,gpointer user_data)
|
||||
{
|
||||
GckListBox *listbox;
|
||||
|
||||
listbox=(GckListBox *)gtk_object_get_data(GTK_OBJECT(widget),"_GckListBox");
|
||||
|
||||
if (listbox->disable_signals==TRUE)
|
||||
return;
|
||||
|
||||
/* Update selected items */
|
||||
/* ===================== */
|
||||
|
||||
gck_listbox_set_current_selection(listbox);
|
||||
|
||||
/* If a user event_handler is defined, call it */
|
||||
/* =========================================== */
|
||||
|
||||
if (listbox->event_handler!=NULL)
|
||||
(*listbox->event_handler)(widget,&listbox->last_event,user_data);
|
||||
}
|
||||
|
||||
gint _gck_listbox_eventhandler(GtkWidget *widget,GdkEvent *event,gpointer user_data)
|
||||
{
|
||||
GckListBox *listbox;
|
||||
GtkWidget *event_widget;
|
||||
|
||||
/* First, check if the issuing widget is a list_item, if not we'll */
|
||||
/* get the last selection and not the new. */
|
||||
/* =============================================================== */
|
||||
|
||||
event_widget=gtk_get_event_widget(event);
|
||||
|
||||
if (GTK_IS_LIST_ITEM(event_widget))
|
||||
{
|
||||
if (event->type==GDK_BUTTON_PRESS || event->type==GDK_2BUTTON_PRESS)
|
||||
{
|
||||
/* Ok, get listbox */
|
||||
/* =============== */
|
||||
|
||||
listbox=(GckListBox *)gtk_object_get_data(GTK_OBJECT(widget),"_GckListBox");
|
||||
listbox->last_event=*event;
|
||||
|
||||
if (listbox->disable_signals==TRUE)
|
||||
return(FALSE);
|
||||
|
||||
if (event->type==GDK_2BUTTON_PRESS)
|
||||
{
|
||||
if (listbox->event_handler!=NULL)
|
||||
(*listbox->event_handler)(widget,&listbox->last_event,user_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
/*******************/
|
||||
/* Create list box */
|
||||
/*******************/
|
||||
|
||||
GckListBox *gck_listbox_new(GtkWidget *container,gint expand,gint fill,gint padding,
|
||||
gint width,gint height,GtkSelectionMode selection_mode,
|
||||
GckListBoxItem *list_items,
|
||||
GckEventFunction event_handler)
|
||||
{
|
||||
GckListBox *listbox;
|
||||
gint i=0;
|
||||
|
||||
g_function_enter("gck_listbox_new");
|
||||
g_assert(container!=NULL);
|
||||
|
||||
listbox=(GckListBox *)malloc(sizeof(GckListBox));
|
||||
if (listbox==NULL)
|
||||
{
|
||||
g_function_leave("gck_listbox_new");
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
listbox->itemlist=NULL;
|
||||
listbox->current_selection=NULL;
|
||||
listbox->selected_items=NULL;
|
||||
listbox->num_selected_items=0;
|
||||
listbox->num_items=0;
|
||||
listbox->width=width;
|
||||
listbox->height=height;
|
||||
listbox->event_handler=event_handler;
|
||||
listbox->disable_signals=FALSE;
|
||||
|
||||
listbox->widget=gtk_scrolled_window_new(NULL,NULL);
|
||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(listbox->widget),
|
||||
GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
|
||||
gtk_widget_set_usize(listbox->widget,width,height);
|
||||
|
||||
if (GTK_WIDGET_TYPE(container) == gtk_vbox_get_type() ||
|
||||
GTK_WIDGET_TYPE(container) == gtk_hbox_get_type())
|
||||
gtk_box_pack_start(GTK_BOX(container), listbox->widget, expand, fill, padding);
|
||||
else
|
||||
gtk_container_add(GTK_CONTAINER(container),listbox->widget);
|
||||
|
||||
listbox->list=gtk_list_new();
|
||||
gtk_list_set_selection_mode(GTK_LIST(listbox->list),selection_mode);
|
||||
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(listbox->widget),listbox->list);
|
||||
gtk_object_set_data(GTK_OBJECT(listbox->list),"_GckListBox",(gpointer)listbox);
|
||||
gtk_widget_show(listbox->list);
|
||||
|
||||
if (list_items!=NULL)
|
||||
{
|
||||
while (list_items[i].label!=NULL)
|
||||
gck_listbox_append_item(listbox,&list_items[i++]);
|
||||
gck_listbox_unselect_all(listbox);
|
||||
}
|
||||
|
||||
if (_GckAutoShowFlag==TRUE)
|
||||
gtk_widget_show(listbox->widget);
|
||||
|
||||
/* Make sure we're done with stuff, before we attach any handlers */
|
||||
/* ============================================================== */
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT(listbox->list),"button_press_event",
|
||||
(GtkSignalFunc)_gck_listbox_eventhandler,(gpointer)listbox->list);
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT(listbox->list),"selection_changed",
|
||||
(GtkSignalFunc)_gck_listbox_signalhandler,(gpointer)listbox->list);
|
||||
|
||||
g_function_leave("gck_listbox_new");
|
||||
return(listbox);
|
||||
}
|
||||
|
||||
/************************************************************/
|
||||
/* Free the memory associated with the GckListBox structure */
|
||||
/************************************************************/
|
||||
|
||||
void gck_listbox_destroy(GckListBox *listbox)
|
||||
{
|
||||
g_function_enter("gck_listbox_destroy");
|
||||
g_assert(listbox!=NULL);
|
||||
|
||||
if (listbox->itemlist!=NULL)
|
||||
g_list_free(listbox->itemlist);
|
||||
|
||||
if (listbox->current_selection!=NULL)
|
||||
g_list_free(listbox->current_selection);
|
||||
|
||||
if (listbox->selected_items!=NULL)
|
||||
free(listbox->selected_items);
|
||||
|
||||
g_function_leave("gck_listbox_destroy");
|
||||
}
|
||||
|
|
@ -1,126 +0,0 @@
|
|||
/***************************************************************************/
|
||||
/* GCK - The General Convenience Kit. Generally useful conveniece routines */
|
||||
/* for GIMP plug-in writers and users of the GDK/GTK libraries. */
|
||||
/* Copyright (C) 1996 Tom Bech */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 2 of the License, or */
|
||||
/* (at your option) any later version. */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program; if not, write to the Free Software */
|
||||
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, */
|
||||
/* USA. */
|
||||
/***************************************************************************/
|
||||
|
||||
#ifndef __GCKLISTBOX_H__
|
||||
#define __GCKLISTBOX_H__
|
||||
|
||||
#include "gcktypes.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
GckListBox *gck_listbox_new (GtkWidget *container,
|
||||
gint expand, gint fill, gint padding,
|
||||
gint width, gint height,
|
||||
GtkSelectionMode selection_mode,
|
||||
GckListBoxItem *list_items,
|
||||
GckEventFunction event_handler);
|
||||
|
||||
void gck_listbox_destroy (GckListBox *listbox);
|
||||
|
||||
GckListBox *gck_listbox_get (GList *itemlist);
|
||||
|
||||
void gck_listbox_prepend_item (GckListBox *listbox,
|
||||
GckListBoxItem *item);
|
||||
|
||||
void gck_listbox_prepend_items (GckListBox *listbox,
|
||||
GList *itemlist);
|
||||
|
||||
void gck_listbox_append_item (GckListBox *listbox,
|
||||
GckListBoxItem *item);
|
||||
|
||||
void gck_listbox_append_items (GckListBox *listbox,
|
||||
GList *itemlist);
|
||||
|
||||
void gck_listbox_insert_item (GckListBox *listbox,
|
||||
GckListBoxItem *item,
|
||||
gint position);
|
||||
|
||||
void gck_listbox_insert_items (GckListBox *listbox,
|
||||
GList *itemlist,
|
||||
gint position);
|
||||
|
||||
GList *gck_listbox_get_current_selection (GckListBox *listbox);
|
||||
|
||||
void gck_listbox_set_current_selection (GckListBox *listbox);
|
||||
|
||||
GList *gck_listbox_item_find_by_position (GckListBox *listbox,
|
||||
gint position);
|
||||
|
||||
GList *gck_listbox_item_find_by_label (GckListBox *listbox,
|
||||
char *label,
|
||||
gint *position);
|
||||
|
||||
GList *gck_listbox_item_find_by_user_data (GckListBox *listbox,
|
||||
gpointer user_data,
|
||||
gint *position);
|
||||
|
||||
void gck_listbox_delete_item_by_position (GckListBox *listbox,
|
||||
gint position);
|
||||
|
||||
void gck_listbox_delete_item_by_label (GckListBox *listbox,
|
||||
char *label);
|
||||
|
||||
void gck_listbox_delete_items_by_label (GckListBox *listbox,
|
||||
GList *itemlist);
|
||||
|
||||
void gck_listbox_delete_item_by_user_data (GckListBox *listbox,
|
||||
gpointer user_data);
|
||||
|
||||
void gck_listbox_delete_items_by_user_data (GckListBox *listbox,
|
||||
GList *itemlist);
|
||||
|
||||
void gck_listbox_clear_items (GckListBox *listbox,
|
||||
gint start, gint end);
|
||||
|
||||
GList *gck_listbox_select_item_by_position (GckListBox *listbox,
|
||||
gint position);
|
||||
|
||||
GList *gck_listbox_select_item_by_label (GckListBox *listbox,
|
||||
char *label);
|
||||
|
||||
GList *gck_listbox_select_item_by_user_data (GckListBox *listbox,
|
||||
gpointer user_data);
|
||||
|
||||
GList *gck_listbox_unselect_item_by_position (GckListBox *listbox,
|
||||
gint position);
|
||||
|
||||
GList *gck_listbox_unselect_item_by_label (GckListBox *listbox,
|
||||
char *label);
|
||||
|
||||
GList *gck_listbox_unselect_item_by_user_data (GckListBox *listbox,
|
||||
gpointer user_data);
|
||||
|
||||
void gck_listbox_select_all (GckListBox *listbox);
|
||||
|
||||
void gck_listbox_unselect_all (GckListBox *listbox);
|
||||
|
||||
void gck_listbox_disable_signals (GckListBox *listbox);
|
||||
|
||||
void gck_listbox_enable_signals (GckListBox *listbox);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
|
@ -1,125 +0,0 @@
|
|||
/***************************************************************************/
|
||||
/* GCK - The General Convenience Kit. Generally useful conveniece routines */
|
||||
/* for GIMP plug-in writers and users of the GDK/GTK libraries. */
|
||||
/* Copyright (C) 1996 Tom Bech */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 2 of the License, or */
|
||||
/* (at your option) any later version. */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program; if not, write to the Free Software */
|
||||
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, */
|
||||
/* USA. */
|
||||
/***************************************************************************/
|
||||
|
||||
/***************************/
|
||||
/* Misc. useful math stuff */
|
||||
/***************************/
|
||||
|
||||
#include <math.h>
|
||||
#include <gck.h>
|
||||
|
||||
double gck_deg_to_rad(double angle)
|
||||
{
|
||||
return((angle/360.0)*(2.0*M_PI));
|
||||
}
|
||||
|
||||
double gck_rad_to_deg(double angle)
|
||||
{
|
||||
return((angle/(2.0*M_PI))*360.0);
|
||||
}
|
||||
|
||||
void gck_mat_to_deg(double mat[4][4],double *a,double *b,double *c)
|
||||
{
|
||||
*a=180*(asin(mat[1][0])/M_PI_2);
|
||||
*b=180*(asin(mat[2][0])/M_PI_2);
|
||||
*c=180*(asin(mat[2][1])/M_PI_2);
|
||||
}
|
||||
|
||||
/*************************************************/
|
||||
/* Quick and dirty (and slow) line clip routine. */
|
||||
/* The function returns FALSE if the line isn't */
|
||||
/* visible according to the limits given. */
|
||||
/*************************************************/
|
||||
|
||||
int gck_clip_line(double *x1,double *y1,double *x2,double *y2,
|
||||
double minx,double miny,double maxx,double maxy)
|
||||
{
|
||||
double tmp;
|
||||
|
||||
g_function_enter("gck_clip_line");
|
||||
g_assert(x1!=NULL);
|
||||
g_assert(y1!=NULL);
|
||||
g_assert(x2!=NULL);
|
||||
g_assert(y2!=NULL);
|
||||
|
||||
/* First, check if line is visible at all */
|
||||
/* ====================================== */
|
||||
|
||||
if (*x1<minx && *x2<minx) return(FALSE);
|
||||
if (*x1>maxx && *x2>maxx) return(FALSE);
|
||||
if (*y1<miny && *y2<miny) return(FALSE);
|
||||
if (*y1>maxy && *y2>maxy) return(FALSE);
|
||||
|
||||
/* Check for intersection with the four edges. Sort on x first. */
|
||||
/* ============================================================ */
|
||||
|
||||
if (*x2<*x1)
|
||||
{
|
||||
tmp=*x1;
|
||||
*x1=*x2;
|
||||
*x2=tmp;
|
||||
tmp=*y1;
|
||||
*y1=*y2;
|
||||
*y2=tmp;
|
||||
}
|
||||
|
||||
if (*x1<minx)
|
||||
{
|
||||
if (*y1<*y2) *y1=*y1+(minx-*x1)*((*y2-*y1)/(*x2-*x1));
|
||||
else *y1=*y1-(minx-*x1)*((*y1-*y2)/(*x2-*x1));
|
||||
*x1=minx;
|
||||
}
|
||||
|
||||
if (*x2>maxx)
|
||||
{
|
||||
if (*y1<*y2) *y2=*y2-(*x2-maxx)*((*y2-*y1)/(*x2-*x1));
|
||||
else *y2=*y2+(*x2-maxx)*((*y1-*y2)/(*x2-*x1));
|
||||
*x2=maxx;
|
||||
}
|
||||
|
||||
if (*y1<miny)
|
||||
{
|
||||
*x1=*x1+(miny-*y1)*((*x2-*x1)/(*y2-*y1));
|
||||
*y1=miny;
|
||||
}
|
||||
|
||||
if (*y2<miny)
|
||||
{
|
||||
*x2=*x2-(miny-*y2)*((*x2-*x1)/(*y1-*y2));
|
||||
*y2=miny;
|
||||
}
|
||||
|
||||
if (*y1>maxy)
|
||||
{
|
||||
*x1=*x1+(*y1-maxy)*((*x2-*x1)/(*y1-*y2));
|
||||
*y1=maxy;
|
||||
}
|
||||
|
||||
if (*y2>maxy)
|
||||
{
|
||||
*x2=*x2-(*y2-maxy)*((*x2-*x1)/(*y2-*y1));
|
||||
*y2=maxy;
|
||||
}
|
||||
|
||||
g_function_leave("gck_clip_line");
|
||||
return(TRUE);
|
||||
}
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
/***************************************************************************/
|
||||
/* GCK - The General Convenience Kit. Generally useful conveniece routines */
|
||||
/* for GIMP plug-in writers and users of the GDK/GTK libraries. */
|
||||
/* Copyright (C) 1996 Tom Bech */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 2 of the License, or */
|
||||
/* (at your option) any later version. */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program; if not, write to the Free Software */
|
||||
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, */
|
||||
/* USA. */
|
||||
/***************************************************************************/
|
||||
|
||||
#ifndef __GCKMATH_H__
|
||||
#define __GCKMATH_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
double gck_deg_to_rad(double angle);
|
||||
double gck_rad_to_deg(double angle);
|
||||
void gck_mat_to_deg(double mat[4][4],double *a,double *b,double *c);
|
||||
|
||||
int gck_clip_line(double *x1,double *y1,double *x2,double *y2,
|
||||
double minx,double miny,double maxx,double maxy);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -194,21 +194,6 @@ typedef struct {
|
|||
GdkImage *buffer;
|
||||
} _GckBackBuffer;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
double x,y;
|
||||
} GckVector2;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
double x,y,z;
|
||||
} GckVector3;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
double x,y,z,w;
|
||||
} GckVector4;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,388 +0,0 @@
|
|||
/***************************************************************************/
|
||||
/* GCK - The General Convenience Kit. Generally useful conveniece routines */
|
||||
/* for GIMP plug-in writers and users of the GDK/GTK libraries. */
|
||||
/* Copyright (C) 1996 Tom Bech */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 2 of the License, or */
|
||||
/* (at your option) any later version. */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program; if not, write to the Free Software */
|
||||
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, */
|
||||
/* USA. */
|
||||
/***************************************************************************/
|
||||
|
||||
/**********************************************/
|
||||
/* A little collection of useful vector stuff */
|
||||
/**********************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <gck/gck.h>
|
||||
|
||||
/*************************/
|
||||
/* Some useful constants */
|
||||
/*************************/
|
||||
|
||||
const GckVector2 gck_vector2_zero = {0.0,0.0};
|
||||
const GckVector2 gck_vector2_unit_x = {1.0,0.0};
|
||||
const GckVector2 gck_vector2_unit_y = {0.0,1.0};
|
||||
|
||||
const GckVector3 gck_vector3_zero = {0.0,0.0,0.0};
|
||||
const GckVector3 gck_vector3_unit_x = {1.0,0.0,0.0};
|
||||
const GckVector3 gck_vector3_unit_y = {0.0,1.0,0.0};
|
||||
const GckVector3 gck_vector3_unit_z = {0.0,0.0,1.0};
|
||||
|
||||
/**************************************/
|
||||
/* Three dimensional vector functions */
|
||||
/**************************************/
|
||||
|
||||
double gck_vector2_inner_product(GckVector2 *a,GckVector2 *b)
|
||||
{
|
||||
g_function_enter("gck_vector2_inner_product");
|
||||
g_assert(a!=NULL);
|
||||
g_assert(b!=NULL);
|
||||
g_function_leave("gck_vector2_inner_product");
|
||||
return(a->x*b->x+a->y*b->y);
|
||||
}
|
||||
|
||||
GckVector3 gck_vector2_cross_product(GckVector2 *a,GckVector2 *b)
|
||||
{
|
||||
GckVector3 normal;
|
||||
|
||||
g_function_enter("gck_vector2_cross_product");
|
||||
g_assert(a!=NULL);
|
||||
g_assert(b!=NULL);
|
||||
|
||||
/* normal.x=a->y*b->z-a->z*b->y;
|
||||
normal.y=a->z*b->x-a->x*b->z;
|
||||
normal.z=a->x*b->y-a->y*b->x;*/
|
||||
|
||||
g_function_leave("gck_vector2_cross_product");
|
||||
return(normal);
|
||||
}
|
||||
|
||||
double gck_vector2_length(GckVector2 *a)
|
||||
{
|
||||
g_function_enter("gck_vector2_length");
|
||||
g_assert(a!=NULL);
|
||||
g_function_leave("gck_vector2_length");
|
||||
return(sqrt(a->x*a->x+a->y*a->y));
|
||||
}
|
||||
|
||||
void gck_vector2_normalize(GckVector2 *a)
|
||||
{
|
||||
double len;
|
||||
|
||||
g_function_enter("gck_vector2_normalize");
|
||||
g_assert(a!=NULL);
|
||||
|
||||
len=gck_vector2_length(a);
|
||||
if (len!=0.0)
|
||||
{
|
||||
len=1.0/len;
|
||||
a->x=a->x*len;
|
||||
a->y=a->y*len;
|
||||
}
|
||||
else *a=gck_vector2_zero;
|
||||
|
||||
g_function_leave("gck_vector2_normalize");
|
||||
}
|
||||
|
||||
void gck_vector2_mul(GckVector2 *a,double b)
|
||||
{
|
||||
g_function_enter("gck_vector2_mul");
|
||||
g_assert(a!=NULL);
|
||||
|
||||
a->x=a->x*b;
|
||||
a->y=a->y*b;
|
||||
|
||||
g_function_leave("gck_vector2_mul");
|
||||
}
|
||||
|
||||
void gck_vector2_sub(GckVector2 *c,GckVector2 *a,GckVector2 *b)
|
||||
{
|
||||
g_function_enter("gck_vector2_sub");
|
||||
g_assert(a!=NULL);
|
||||
g_assert(b!=NULL);
|
||||
g_assert(c!=NULL);
|
||||
|
||||
c->x=a->x-b->x;
|
||||
c->y=a->y-b->y;
|
||||
|
||||
g_function_leave("gck_vector2_sub");
|
||||
}
|
||||
|
||||
void gck_vector2_set(GckVector2 *a, double x,double y)
|
||||
{
|
||||
g_function_enter("gck_vector2_set");
|
||||
g_assert(a!=NULL);
|
||||
|
||||
a->x=x;
|
||||
a->y=y;
|
||||
|
||||
g_function_leave("gck_vector2_set");
|
||||
}
|
||||
|
||||
void gck_vector2_add(GckVector2 *c,GckVector2 *a,GckVector2 *b)
|
||||
{
|
||||
g_function_enter("gck_vector2_add");
|
||||
g_assert(a!=NULL);
|
||||
g_assert(b!=NULL);
|
||||
g_assert(c!=NULL);
|
||||
|
||||
c->x=a->x+b->x;
|
||||
c->y=a->y+b->y;
|
||||
|
||||
g_function_leave("gck_vector2_add");
|
||||
}
|
||||
|
||||
void gck_vector2_neg(GckVector2 *a)
|
||||
{
|
||||
g_function_enter("gck_vector2_neg");
|
||||
g_assert(a!=NULL);
|
||||
|
||||
a->x*=-1.0;
|
||||
a->y*=-1.0;
|
||||
|
||||
g_function_leave("gck_vector2_neg");
|
||||
}
|
||||
|
||||
void gck_vector2_rotate(GckVector2 *v,double alpha)
|
||||
{
|
||||
GckVector2 s;
|
||||
|
||||
g_function_enter("gck_vector2_rotate");
|
||||
g_assert(v!=NULL);
|
||||
|
||||
s.x=cos(alpha)*v->x+sin(alpha)*v->y;
|
||||
s.y=cos(alpha)*v->y-sin(alpha)*v->x;
|
||||
|
||||
*v=s;
|
||||
|
||||
g_function_leave("gck_vector2_rotate");
|
||||
}
|
||||
|
||||
/**************************************/
|
||||
/* Three dimensional vector functions */
|
||||
/**************************************/
|
||||
|
||||
double gck_vector3_inner_product(GckVector3 *a,GckVector3 *b)
|
||||
{
|
||||
g_function_enter("gck_vector3_inner_product");
|
||||
g_assert(a!=NULL);
|
||||
g_assert(b!=NULL);
|
||||
g_function_leave("gck_vector3_inner_product");
|
||||
|
||||
return(a->x*b->x+a->y*b->y+a->z*b->z);
|
||||
}
|
||||
|
||||
GckVector3 gck_vector3_cross_product(GckVector3 *a,GckVector3 *b)
|
||||
{
|
||||
GckVector3 normal;
|
||||
|
||||
g_function_enter("gck_vector3_cross_product");
|
||||
g_assert(a!=NULL);
|
||||
g_assert(b!=NULL);
|
||||
|
||||
normal.x=a->y*b->z-a->z*b->y;
|
||||
normal.y=a->z*b->x-a->x*b->z;
|
||||
normal.z=a->x*b->y-a->y*b->x;
|
||||
|
||||
g_function_leave("gck_vector3_cross_product");
|
||||
return(normal);
|
||||
}
|
||||
|
||||
double gck_vector3_length(GckVector3 *a)
|
||||
{
|
||||
g_function_enter("gck_vector3_length");
|
||||
g_assert(a!=NULL);
|
||||
g_function_leave("gck_vector3_length");
|
||||
return(sqrt(a->x*a->x+a->y*a->y+a->z*a->z));
|
||||
}
|
||||
|
||||
void gck_vector3_normalize(GckVector3 *a)
|
||||
{
|
||||
double len;
|
||||
|
||||
g_function_enter("gck_vector3_normalize");
|
||||
g_assert(a!=NULL);
|
||||
|
||||
len=gck_vector3_length(a);
|
||||
if (len!=0.0)
|
||||
{
|
||||
len=1.0/len;
|
||||
a->x=a->x*len;
|
||||
a->y=a->y*len;
|
||||
a->z=a->z*len;
|
||||
}
|
||||
else *a=gck_vector3_zero;
|
||||
|
||||
g_function_leave("gck_vector3_normalize");
|
||||
}
|
||||
|
||||
void gck_vector3_mul(GckVector3 *a,double b)
|
||||
{
|
||||
g_function_enter("gck_vector3_mul");
|
||||
g_assert(a!=NULL);
|
||||
|
||||
a->x=a->x*b;
|
||||
a->y=a->y*b;
|
||||
a->z=a->z*b;
|
||||
|
||||
g_function_leave("gck_vector3_mul");
|
||||
}
|
||||
|
||||
void gck_vector3_sub(GckVector3 *c,GckVector3 *a,GckVector3 *b)
|
||||
{
|
||||
g_function_enter("gck_vector3_sub");
|
||||
g_assert(a!=NULL);
|
||||
g_assert(b!=NULL);
|
||||
g_assert(c!=NULL);
|
||||
|
||||
c->x=a->x-b->x;
|
||||
c->y=a->y-b->y;
|
||||
c->z=a->z-b->z;
|
||||
|
||||
g_function_leave("gck_vector3_sub");
|
||||
}
|
||||
|
||||
void gck_vector3_set(GckVector3 *a, double x,double y,double z)
|
||||
{
|
||||
g_function_enter("gck_vector3_set");
|
||||
g_assert(a!=NULL);
|
||||
|
||||
a->x=x;
|
||||
a->y=y;
|
||||
a->z=z;
|
||||
|
||||
g_function_leave("gck_vector3_set");
|
||||
}
|
||||
|
||||
void gck_vector3_add(GckVector3 *c,GckVector3 *a,GckVector3 *b)
|
||||
{
|
||||
g_function_enter("gck_vector3_add");
|
||||
g_assert(a!=NULL);
|
||||
g_assert(b!=NULL);
|
||||
g_assert(c!=NULL);
|
||||
|
||||
c->x=a->x+b->x;
|
||||
c->y=a->y+b->y;
|
||||
c->z=a->z+b->z;
|
||||
|
||||
g_function_leave("gck_vector3_add");
|
||||
}
|
||||
|
||||
void gck_vector3_neg(GckVector3 *a)
|
||||
{
|
||||
g_function_enter("gck_vector3_neg");
|
||||
g_assert(a!=NULL);
|
||||
|
||||
a->x*=-1.0;
|
||||
a->y*=-1.0;
|
||||
a->z*=-1.0;
|
||||
|
||||
g_function_leave("gck_vector3_neg");
|
||||
}
|
||||
|
||||
void gck_vector3_rotate(GckVector3 *v,double alpha,double beta,double gamma)
|
||||
{
|
||||
GckVector3 s,t;
|
||||
|
||||
g_function_enter("gck_vector3_rotate");
|
||||
g_assert(v!=NULL);
|
||||
|
||||
/* First we rotate it around the Z axis (XY plane).. */
|
||||
/* ================================================= */
|
||||
|
||||
s.x=cos(alpha)*v->x+sin(alpha)*v->y;
|
||||
s.y=cos(alpha)*v->y-sin(alpha)*v->x;
|
||||
|
||||
/* ..then around the Y axis (XZ plane).. */
|
||||
/* ===================================== */
|
||||
|
||||
t=s;
|
||||
|
||||
v->x=cos(beta)*t.x+sin(beta)*v->z;
|
||||
s.z=cos(beta)*v->z-sin(beta)*t.x;
|
||||
|
||||
/* ..and at last around the X axis (YZ plane) */
|
||||
/* ========================================== */
|
||||
|
||||
v->y=cos(gamma)*t.y+sin(gamma)*s.z;
|
||||
v->z=cos(gamma)*s.z-sin(gamma)*t.y;
|
||||
|
||||
g_function_leave("gck_vector3_rotate");
|
||||
}
|
||||
|
||||
/******************************************************************/
|
||||
/* Compute screen (sx,sy)-(sx+w,sy+h) to 3D unit square mapping. */
|
||||
/* The plane to map to is given in the z field of p. The observer */
|
||||
/* is located at position vp (vp->z!=0.0). */
|
||||
/******************************************************************/
|
||||
|
||||
void gck_2d_to_3d(int sx,int sy,int w,int h,int x,int y,GckVector3 *vp,GckVector3 *p)
|
||||
{
|
||||
double t=0.0;
|
||||
|
||||
g_function_enter("gck_2d_to_3d");
|
||||
g_assert(vp!=NULL);
|
||||
g_assert(p!=NULL);
|
||||
|
||||
if (vp->x!=0.0) t=(p->z-vp->z)/vp->z;
|
||||
|
||||
if (t!=0.0)
|
||||
{
|
||||
p->x=vp->x+t*(vp->x-((double)(x-sx)/(double)w));
|
||||
p->y=vp->y+t*(vp->y-((double)(y-sy)/(double)h));
|
||||
}
|
||||
else
|
||||
{
|
||||
p->x=(double)(x-sx)/(double)w;
|
||||
p->y=(double)(y-sy)/(double)h;
|
||||
}
|
||||
|
||||
g_function_leave("gck_2d_to_3d");
|
||||
}
|
||||
|
||||
/*********************************************************/
|
||||
/* Convert the given 3D point to 2D (project it onto the */
|
||||
/* viewing plane, (sx,sy,0)-(sx+w,sy+h,0). The input is */
|
||||
/* assumed to be in the unit square (0,0,z)-(1,1,z). */
|
||||
/* The viewpoint of the observer is passed in vp. */
|
||||
/*********************************************************/
|
||||
|
||||
void gck_3d_to_2d(int sx,int sy,int w,int h,double *x,double *y,GckVector3 *vp,GckVector3 *p)
|
||||
{
|
||||
double t;
|
||||
GckVector3 dir;
|
||||
|
||||
g_function_enter("gck_3d_to_2d");
|
||||
g_assert(vp!=NULL);
|
||||
g_assert(p!=NULL);
|
||||
|
||||
gck_vector3_sub(&dir,p,vp);
|
||||
gck_vector3_normalize(&dir);
|
||||
|
||||
if (dir.z!=0.0)
|
||||
{
|
||||
t=(-1.0*vp->z)/dir.z;
|
||||
*x=(double)sx+((vp->x+t*dir.x)*(double)w);
|
||||
*y=(double)sy+((vp->y+t*dir.y)*(double)h);
|
||||
}
|
||||
else
|
||||
{
|
||||
*x=(double)sx+(p->x*(double)w);
|
||||
*y=(double)sy+(p->y*(double)h);
|
||||
}
|
||||
|
||||
g_function_leave("gck_3d_to_2d");
|
||||
}
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
/***************************************************************************/
|
||||
/* GCK - The General Convenience Kit. Generally useful conveniece routines */
|
||||
/* for GIMP plug-in writers and users of the GDK/GTK libraries. */
|
||||
/* Copyright (C) 1996 Tom Bech */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 2 of the License, or */
|
||||
/* (at your option) any later version. */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program; if not, write to the Free Software */
|
||||
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, */
|
||||
/* USA. */
|
||||
/***************************************************************************/
|
||||
|
||||
#ifndef __GCKVECTOR_H__
|
||||
#define __GCKVECTOR_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Two dimensional vector functions */
|
||||
/* ================================ */
|
||||
|
||||
double gck_vector2_inner_product (GckVector2 *a,GckVector2 *b);
|
||||
GckVector3 gck_vector2_cross_product (GckVector2 *a,GckVector2 *b);
|
||||
double gck_vector2_length (GckVector2 *a);
|
||||
void gck_vector2_normalize (GckVector2 *a);
|
||||
void gck_vector2_mul (GckVector2 *a,double b);
|
||||
void gck_vector2_sub (GckVector2 *c,GckVector2 *a,GckVector2 *b);
|
||||
void gck_vector2_set (GckVector2 *a, double x,double y);
|
||||
void gck_vector2_add (GckVector2 *c,GckVector2 *a,GckVector2 *b);
|
||||
void gck_vector2_neg (GckVector2 *a);
|
||||
void gck_vector2_rotate (GckVector2 *v,double alpha);
|
||||
|
||||
/* Three dimensional vector functions */
|
||||
/* ================================== */
|
||||
|
||||
double gck_vector3_inner_product (GckVector3 *a,GckVector3 *b);
|
||||
GckVector3 gck_vector3_cross_product (GckVector3 *a,GckVector3 *b);
|
||||
double gck_vector3_length (GckVector3 *a);
|
||||
void gck_vector3_normalize (GckVector3 *a);
|
||||
void gck_vector3_mul (GckVector3 *a,double b);
|
||||
void gck_vector3_sub (GckVector3 *c,GckVector3 *a,GckVector3 *b);
|
||||
void gck_vector3_set (GckVector3 *a, double x,double y,double z);
|
||||
void gck_vector3_add (GckVector3 *c,GckVector3 *a,GckVector3 *b);
|
||||
void gck_vector3_neg (GckVector3 *a);
|
||||
void gck_vector3_rotate (GckVector3 *v,double alpha,double beta,double gamma);
|
||||
|
||||
void gck_2d_to_3d(int sx,int sy,int w,int h,int x,int y,GckVector3 *vp,GckVector3 *p);
|
||||
void gck_3d_to_2d(int sx,int sy,int w,int h,double *x,double *y,GckVector3 *vp,GckVector3 *p);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -984,7 +984,7 @@ HELP
|
|||
vars => [ 'GimpImage *gimage', 'TileManager *float_tiles, *new_tiles',
|
||||
'Layer *layer', 'gboolean new_layer', 'double cx, cy',
|
||||
'double scalex, scaley', 'double trans_info[8]',
|
||||
'GimpMatrix m, matrix' ],
|
||||
'GimpMatrix3 m, matrix' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
gimage = drawable_gimage (GIMP_DRAWABLE (drawable));
|
||||
|
@ -1010,10 +1010,10 @@ HELP
|
|||
scaley = 1.0 / float_tiles->height;
|
||||
|
||||
/* Assemble the transformation matrix */
|
||||
gimp_matrix_identity (matrix);
|
||||
gimp_matrix_translate (matrix, -cx, -cy);
|
||||
gimp_matrix_scale (matrix, scalex, scaley);
|
||||
gimp_matrix_mult (m, matrix);
|
||||
gimp_matrix3_identity (matrix);
|
||||
gimp_matrix3_translate (matrix, -cx, -cy);
|
||||
gimp_matrix3_scale (matrix, scalex, scaley);
|
||||
gimp_matrix3_mult (m, matrix);
|
||||
|
||||
/* Perspective the buffer */
|
||||
new_tiles = perspective_tool_perspective (gimage, drawable, NULL,
|
||||
|
@ -1106,7 +1106,7 @@ HELP
|
|||
headers => [ qw("rotate_tool.h" "transform_core.h") ],
|
||||
vars => [ 'GimpImage *gimage', 'TileManager *float_tiles, *new_tiles',
|
||||
'Layer *layer', 'gboolean new_layer', 'double cx, cy',
|
||||
'GimpMatrix matrix' ],
|
||||
'GimpMatrix3 matrix' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
gimage = drawable_gimage (GIMP_DRAWABLE (drawable));
|
||||
|
@ -1121,10 +1121,10 @@ HELP
|
|||
cy = float_tiles->y + float_tiles->height / 2.0;
|
||||
|
||||
/* Assemble the transformation matrix */
|
||||
gimp_matrix_identity (matrix);
|
||||
gimp_matrix_translate (matrix, -cx, -cy);
|
||||
gimp_matrix_rotate (matrix, angle);
|
||||
gimp_matrix_translate (matrix, +cx, +cy);
|
||||
gimp_matrix3_identity (matrix);
|
||||
gimp_matrix3_translate (matrix, -cx, -cy);
|
||||
gimp_matrix3_rotate (matrix, angle);
|
||||
gimp_matrix3_translate (matrix, +cx, +cy);
|
||||
|
||||
/* Rotate the buffer */
|
||||
new_tiles = rotate_tool_rotate (gimage, drawable, NULL, angle,
|
||||
|
@ -1189,7 +1189,7 @@ HELP
|
|||
"tile_manager_pvt.h") ],
|
||||
vars => [ 'GimpImage *gimage', 'TileManager *float_tiles, *new_tiles',
|
||||
'Layer *layer', 'gboolean new_layer', 'double scalex, scaley',
|
||||
'double trans_info[4]', 'GimpMatrix matrix' ],
|
||||
'double trans_info[4]', 'GimpMatrix3 matrix' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
if (trans_info[X0] < trans_info[X1] &&
|
||||
|
@ -1212,10 +1212,10 @@ HELP
|
|||
(double) float_tiles->height;
|
||||
|
||||
/* Assemble the transformation matrix */
|
||||
gimp_matrix_identity (matrix);
|
||||
gimp_matrix_translate (matrix, float_tiles->x, float_tiles->y);
|
||||
gimp_matrix_scale (matrix, scalex, scaley);
|
||||
gimp_matrix_translate (matrix, trans_info[X0], trans_info[Y0]);
|
||||
gimp_matrix3_identity (matrix);
|
||||
gimp_matrix3_translate (matrix, float_tiles->x, float_tiles->y);
|
||||
gimp_matrix3_scale (matrix, scalex, scaley);
|
||||
gimp_matrix3_translate (matrix, trans_info[X0], trans_info[Y0]);
|
||||
|
||||
/* Scale the buffer */
|
||||
new_tiles = scale_tool_scale (gimage, drawable, NULL, trans_info,
|
||||
|
@ -1280,7 +1280,7 @@ HELP
|
|||
"tile_manager_pvt.h") ],
|
||||
vars => [ 'GimpImage *gimage', 'TileManager *float_tiles, *new_tiles',
|
||||
'Layer *layer', 'gboolean new_layer', 'double cx, cy',
|
||||
'GimpMatrix matrix' ],
|
||||
'GimpMatrix3 matrix' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
gimage = drawable_gimage (GIMP_DRAWABLE (drawable));
|
||||
|
@ -1294,18 +1294,18 @@ HELP
|
|||
cx = float_tiles->x + float_tiles->width / 2.0;
|
||||
cy = float_tiles->y + float_tiles->height / 2.0;
|
||||
|
||||
gimp_matrix_identity (matrix);
|
||||
gimp_matrix_translate (matrix, -cx, -cy);
|
||||
gimp_matrix3_identity (matrix);
|
||||
gimp_matrix3_translate (matrix, -cx, -cy);
|
||||
/* Shear matrix */
|
||||
shear_type = shear_type == HORIZONTAL ? ORIENTATION_HORIZONTAL :
|
||||
shear_type == VERTICAL ? ORIENTATION_VERTICAL :
|
||||
ORIENTATION_UNKNOWN;
|
||||
|
||||
if (shear_type == ORIENTATION_HORIZONTAL)
|
||||
gimp_matrix_xshear (matrix, magnitude / float_tiles->height);
|
||||
gimp_matrix3_xshear (matrix, magnitude / float_tiles->height);
|
||||
else if (shear_type == ORIENTATION_VERTICAL)
|
||||
gimp_matrix_yshear (matrix, magnitude / float_tiles->width);
|
||||
gimp_matrix_translate (matrix, +cx, +cy);
|
||||
gimp_matrix3_yshear (matrix, magnitude / float_tiles->width);
|
||||
gimp_matrix3_translate (matrix, +cx, +cy);
|
||||
|
||||
/* Shear the buffer */
|
||||
new_tiles = shear_tool_shear (gimage, drawable, NULL, float_tiles,
|
||||
|
|
|
@ -984,7 +984,7 @@ HELP
|
|||
vars => [ 'GimpImage *gimage', 'TileManager *float_tiles, *new_tiles',
|
||||
'Layer *layer', 'gboolean new_layer', 'double cx, cy',
|
||||
'double scalex, scaley', 'double trans_info[8]',
|
||||
'GimpMatrix m, matrix' ],
|
||||
'GimpMatrix3 m, matrix' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
gimage = drawable_gimage (GIMP_DRAWABLE (drawable));
|
||||
|
@ -1010,10 +1010,10 @@ HELP
|
|||
scaley = 1.0 / float_tiles->height;
|
||||
|
||||
/* Assemble the transformation matrix */
|
||||
gimp_matrix_identity (matrix);
|
||||
gimp_matrix_translate (matrix, -cx, -cy);
|
||||
gimp_matrix_scale (matrix, scalex, scaley);
|
||||
gimp_matrix_mult (m, matrix);
|
||||
gimp_matrix3_identity (matrix);
|
||||
gimp_matrix3_translate (matrix, -cx, -cy);
|
||||
gimp_matrix3_scale (matrix, scalex, scaley);
|
||||
gimp_matrix3_mult (m, matrix);
|
||||
|
||||
/* Perspective the buffer */
|
||||
new_tiles = perspective_tool_perspective (gimage, drawable, NULL,
|
||||
|
@ -1106,7 +1106,7 @@ HELP
|
|||
headers => [ qw("rotate_tool.h" "transform_core.h") ],
|
||||
vars => [ 'GimpImage *gimage', 'TileManager *float_tiles, *new_tiles',
|
||||
'Layer *layer', 'gboolean new_layer', 'double cx, cy',
|
||||
'GimpMatrix matrix' ],
|
||||
'GimpMatrix3 matrix' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
gimage = drawable_gimage (GIMP_DRAWABLE (drawable));
|
||||
|
@ -1121,10 +1121,10 @@ HELP
|
|||
cy = float_tiles->y + float_tiles->height / 2.0;
|
||||
|
||||
/* Assemble the transformation matrix */
|
||||
gimp_matrix_identity (matrix);
|
||||
gimp_matrix_translate (matrix, -cx, -cy);
|
||||
gimp_matrix_rotate (matrix, angle);
|
||||
gimp_matrix_translate (matrix, +cx, +cy);
|
||||
gimp_matrix3_identity (matrix);
|
||||
gimp_matrix3_translate (matrix, -cx, -cy);
|
||||
gimp_matrix3_rotate (matrix, angle);
|
||||
gimp_matrix3_translate (matrix, +cx, +cy);
|
||||
|
||||
/* Rotate the buffer */
|
||||
new_tiles = rotate_tool_rotate (gimage, drawable, NULL, angle,
|
||||
|
@ -1189,7 +1189,7 @@ HELP
|
|||
"tile_manager_pvt.h") ],
|
||||
vars => [ 'GimpImage *gimage', 'TileManager *float_tiles, *new_tiles',
|
||||
'Layer *layer', 'gboolean new_layer', 'double scalex, scaley',
|
||||
'double trans_info[4]', 'GimpMatrix matrix' ],
|
||||
'double trans_info[4]', 'GimpMatrix3 matrix' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
if (trans_info[X0] < trans_info[X1] &&
|
||||
|
@ -1212,10 +1212,10 @@ HELP
|
|||
(double) float_tiles->height;
|
||||
|
||||
/* Assemble the transformation matrix */
|
||||
gimp_matrix_identity (matrix);
|
||||
gimp_matrix_translate (matrix, float_tiles->x, float_tiles->y);
|
||||
gimp_matrix_scale (matrix, scalex, scaley);
|
||||
gimp_matrix_translate (matrix, trans_info[X0], trans_info[Y0]);
|
||||
gimp_matrix3_identity (matrix);
|
||||
gimp_matrix3_translate (matrix, float_tiles->x, float_tiles->y);
|
||||
gimp_matrix3_scale (matrix, scalex, scaley);
|
||||
gimp_matrix3_translate (matrix, trans_info[X0], trans_info[Y0]);
|
||||
|
||||
/* Scale the buffer */
|
||||
new_tiles = scale_tool_scale (gimage, drawable, NULL, trans_info,
|
||||
|
@ -1280,7 +1280,7 @@ HELP
|
|||
"tile_manager_pvt.h") ],
|
||||
vars => [ 'GimpImage *gimage', 'TileManager *float_tiles, *new_tiles',
|
||||
'Layer *layer', 'gboolean new_layer', 'double cx, cy',
|
||||
'GimpMatrix matrix' ],
|
||||
'GimpMatrix3 matrix' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
gimage = drawable_gimage (GIMP_DRAWABLE (drawable));
|
||||
|
@ -1294,18 +1294,18 @@ HELP
|
|||
cx = float_tiles->x + float_tiles->width / 2.0;
|
||||
cy = float_tiles->y + float_tiles->height / 2.0;
|
||||
|
||||
gimp_matrix_identity (matrix);
|
||||
gimp_matrix_translate (matrix, -cx, -cy);
|
||||
gimp_matrix3_identity (matrix);
|
||||
gimp_matrix3_translate (matrix, -cx, -cy);
|
||||
/* Shear matrix */
|
||||
shear_type = shear_type == HORIZONTAL ? ORIENTATION_HORIZONTAL :
|
||||
shear_type == VERTICAL ? ORIENTATION_VERTICAL :
|
||||
ORIENTATION_UNKNOWN;
|
||||
|
||||
if (shear_type == ORIENTATION_HORIZONTAL)
|
||||
gimp_matrix_xshear (matrix, magnitude / float_tiles->height);
|
||||
gimp_matrix3_xshear (matrix, magnitude / float_tiles->height);
|
||||
else if (shear_type == ORIENTATION_VERTICAL)
|
||||
gimp_matrix_yshear (matrix, magnitude / float_tiles->width);
|
||||
gimp_matrix_translate (matrix, +cx, +cy);
|
||||
gimp_matrix3_yshear (matrix, magnitude / float_tiles->width);
|
||||
gimp_matrix3_translate (matrix, +cx, +cy);
|
||||
|
||||
/* Shear the buffer */
|
||||
new_tiles = shear_tool_shear (gimage, drawable, NULL, float_tiles,
|
||||
|
|
|
@ -984,7 +984,7 @@ HELP
|
|||
vars => [ 'GimpImage *gimage', 'TileManager *float_tiles, *new_tiles',
|
||||
'Layer *layer', 'gboolean new_layer', 'double cx, cy',
|
||||
'double scalex, scaley', 'double trans_info[8]',
|
||||
'GimpMatrix m, matrix' ],
|
||||
'GimpMatrix3 m, matrix' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
gimage = drawable_gimage (GIMP_DRAWABLE (drawable));
|
||||
|
@ -1010,10 +1010,10 @@ HELP
|
|||
scaley = 1.0 / float_tiles->height;
|
||||
|
||||
/* Assemble the transformation matrix */
|
||||
gimp_matrix_identity (matrix);
|
||||
gimp_matrix_translate (matrix, -cx, -cy);
|
||||
gimp_matrix_scale (matrix, scalex, scaley);
|
||||
gimp_matrix_mult (m, matrix);
|
||||
gimp_matrix3_identity (matrix);
|
||||
gimp_matrix3_translate (matrix, -cx, -cy);
|
||||
gimp_matrix3_scale (matrix, scalex, scaley);
|
||||
gimp_matrix3_mult (m, matrix);
|
||||
|
||||
/* Perspective the buffer */
|
||||
new_tiles = perspective_tool_perspective (gimage, drawable, NULL,
|
||||
|
@ -1106,7 +1106,7 @@ HELP
|
|||
headers => [ qw("rotate_tool.h" "transform_core.h") ],
|
||||
vars => [ 'GimpImage *gimage', 'TileManager *float_tiles, *new_tiles',
|
||||
'Layer *layer', 'gboolean new_layer', 'double cx, cy',
|
||||
'GimpMatrix matrix' ],
|
||||
'GimpMatrix3 matrix' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
gimage = drawable_gimage (GIMP_DRAWABLE (drawable));
|
||||
|
@ -1121,10 +1121,10 @@ HELP
|
|||
cy = float_tiles->y + float_tiles->height / 2.0;
|
||||
|
||||
/* Assemble the transformation matrix */
|
||||
gimp_matrix_identity (matrix);
|
||||
gimp_matrix_translate (matrix, -cx, -cy);
|
||||
gimp_matrix_rotate (matrix, angle);
|
||||
gimp_matrix_translate (matrix, +cx, +cy);
|
||||
gimp_matrix3_identity (matrix);
|
||||
gimp_matrix3_translate (matrix, -cx, -cy);
|
||||
gimp_matrix3_rotate (matrix, angle);
|
||||
gimp_matrix3_translate (matrix, +cx, +cy);
|
||||
|
||||
/* Rotate the buffer */
|
||||
new_tiles = rotate_tool_rotate (gimage, drawable, NULL, angle,
|
||||
|
@ -1189,7 +1189,7 @@ HELP
|
|||
"tile_manager_pvt.h") ],
|
||||
vars => [ 'GimpImage *gimage', 'TileManager *float_tiles, *new_tiles',
|
||||
'Layer *layer', 'gboolean new_layer', 'double scalex, scaley',
|
||||
'double trans_info[4]', 'GimpMatrix matrix' ],
|
||||
'double trans_info[4]', 'GimpMatrix3 matrix' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
if (trans_info[X0] < trans_info[X1] &&
|
||||
|
@ -1212,10 +1212,10 @@ HELP
|
|||
(double) float_tiles->height;
|
||||
|
||||
/* Assemble the transformation matrix */
|
||||
gimp_matrix_identity (matrix);
|
||||
gimp_matrix_translate (matrix, float_tiles->x, float_tiles->y);
|
||||
gimp_matrix_scale (matrix, scalex, scaley);
|
||||
gimp_matrix_translate (matrix, trans_info[X0], trans_info[Y0]);
|
||||
gimp_matrix3_identity (matrix);
|
||||
gimp_matrix3_translate (matrix, float_tiles->x, float_tiles->y);
|
||||
gimp_matrix3_scale (matrix, scalex, scaley);
|
||||
gimp_matrix3_translate (matrix, trans_info[X0], trans_info[Y0]);
|
||||
|
||||
/* Scale the buffer */
|
||||
new_tiles = scale_tool_scale (gimage, drawable, NULL, trans_info,
|
||||
|
@ -1280,7 +1280,7 @@ HELP
|
|||
"tile_manager_pvt.h") ],
|
||||
vars => [ 'GimpImage *gimage', 'TileManager *float_tiles, *new_tiles',
|
||||
'Layer *layer', 'gboolean new_layer', 'double cx, cy',
|
||||
'GimpMatrix matrix' ],
|
||||
'GimpMatrix3 matrix' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
gimage = drawable_gimage (GIMP_DRAWABLE (drawable));
|
||||
|
@ -1294,18 +1294,18 @@ HELP
|
|||
cx = float_tiles->x + float_tiles->width / 2.0;
|
||||
cy = float_tiles->y + float_tiles->height / 2.0;
|
||||
|
||||
gimp_matrix_identity (matrix);
|
||||
gimp_matrix_translate (matrix, -cx, -cy);
|
||||
gimp_matrix3_identity (matrix);
|
||||
gimp_matrix3_translate (matrix, -cx, -cy);
|
||||
/* Shear matrix */
|
||||
shear_type = shear_type == HORIZONTAL ? ORIENTATION_HORIZONTAL :
|
||||
shear_type == VERTICAL ? ORIENTATION_VERTICAL :
|
||||
ORIENTATION_UNKNOWN;
|
||||
|
||||
if (shear_type == ORIENTATION_HORIZONTAL)
|
||||
gimp_matrix_xshear (matrix, magnitude / float_tiles->height);
|
||||
gimp_matrix3_xshear (matrix, magnitude / float_tiles->height);
|
||||
else if (shear_type == ORIENTATION_VERTICAL)
|
||||
gimp_matrix_yshear (matrix, magnitude / float_tiles->width);
|
||||
gimp_matrix_translate (matrix, +cx, +cy);
|
||||
gimp_matrix3_yshear (matrix, magnitude / float_tiles->width);
|
||||
gimp_matrix3_translate (matrix, +cx, +cy);
|
||||
|
||||
/* Shear the buffer */
|
||||
new_tiles = shear_tool_shear (gimage, drawable, NULL, float_tiles,
|
||||
|
|
|
@ -984,7 +984,7 @@ HELP
|
|||
vars => [ 'GimpImage *gimage', 'TileManager *float_tiles, *new_tiles',
|
||||
'Layer *layer', 'gboolean new_layer', 'double cx, cy',
|
||||
'double scalex, scaley', 'double trans_info[8]',
|
||||
'GimpMatrix m, matrix' ],
|
||||
'GimpMatrix3 m, matrix' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
gimage = drawable_gimage (GIMP_DRAWABLE (drawable));
|
||||
|
@ -1010,10 +1010,10 @@ HELP
|
|||
scaley = 1.0 / float_tiles->height;
|
||||
|
||||
/* Assemble the transformation matrix */
|
||||
gimp_matrix_identity (matrix);
|
||||
gimp_matrix_translate (matrix, -cx, -cy);
|
||||
gimp_matrix_scale (matrix, scalex, scaley);
|
||||
gimp_matrix_mult (m, matrix);
|
||||
gimp_matrix3_identity (matrix);
|
||||
gimp_matrix3_translate (matrix, -cx, -cy);
|
||||
gimp_matrix3_scale (matrix, scalex, scaley);
|
||||
gimp_matrix3_mult (m, matrix);
|
||||
|
||||
/* Perspective the buffer */
|
||||
new_tiles = perspective_tool_perspective (gimage, drawable, NULL,
|
||||
|
@ -1106,7 +1106,7 @@ HELP
|
|||
headers => [ qw("rotate_tool.h" "transform_core.h") ],
|
||||
vars => [ 'GimpImage *gimage', 'TileManager *float_tiles, *new_tiles',
|
||||
'Layer *layer', 'gboolean new_layer', 'double cx, cy',
|
||||
'GimpMatrix matrix' ],
|
||||
'GimpMatrix3 matrix' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
gimage = drawable_gimage (GIMP_DRAWABLE (drawable));
|
||||
|
@ -1121,10 +1121,10 @@ HELP
|
|||
cy = float_tiles->y + float_tiles->height / 2.0;
|
||||
|
||||
/* Assemble the transformation matrix */
|
||||
gimp_matrix_identity (matrix);
|
||||
gimp_matrix_translate (matrix, -cx, -cy);
|
||||
gimp_matrix_rotate (matrix, angle);
|
||||
gimp_matrix_translate (matrix, +cx, +cy);
|
||||
gimp_matrix3_identity (matrix);
|
||||
gimp_matrix3_translate (matrix, -cx, -cy);
|
||||
gimp_matrix3_rotate (matrix, angle);
|
||||
gimp_matrix3_translate (matrix, +cx, +cy);
|
||||
|
||||
/* Rotate the buffer */
|
||||
new_tiles = rotate_tool_rotate (gimage, drawable, NULL, angle,
|
||||
|
@ -1189,7 +1189,7 @@ HELP
|
|||
"tile_manager_pvt.h") ],
|
||||
vars => [ 'GimpImage *gimage', 'TileManager *float_tiles, *new_tiles',
|
||||
'Layer *layer', 'gboolean new_layer', 'double scalex, scaley',
|
||||
'double trans_info[4]', 'GimpMatrix matrix' ],
|
||||
'double trans_info[4]', 'GimpMatrix3 matrix' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
if (trans_info[X0] < trans_info[X1] &&
|
||||
|
@ -1212,10 +1212,10 @@ HELP
|
|||
(double) float_tiles->height;
|
||||
|
||||
/* Assemble the transformation matrix */
|
||||
gimp_matrix_identity (matrix);
|
||||
gimp_matrix_translate (matrix, float_tiles->x, float_tiles->y);
|
||||
gimp_matrix_scale (matrix, scalex, scaley);
|
||||
gimp_matrix_translate (matrix, trans_info[X0], trans_info[Y0]);
|
||||
gimp_matrix3_identity (matrix);
|
||||
gimp_matrix3_translate (matrix, float_tiles->x, float_tiles->y);
|
||||
gimp_matrix3_scale (matrix, scalex, scaley);
|
||||
gimp_matrix3_translate (matrix, trans_info[X0], trans_info[Y0]);
|
||||
|
||||
/* Scale the buffer */
|
||||
new_tiles = scale_tool_scale (gimage, drawable, NULL, trans_info,
|
||||
|
@ -1280,7 +1280,7 @@ HELP
|
|||
"tile_manager_pvt.h") ],
|
||||
vars => [ 'GimpImage *gimage', 'TileManager *float_tiles, *new_tiles',
|
||||
'Layer *layer', 'gboolean new_layer', 'double cx, cy',
|
||||
'GimpMatrix matrix' ],
|
||||
'GimpMatrix3 matrix' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
gimage = drawable_gimage (GIMP_DRAWABLE (drawable));
|
||||
|
@ -1294,18 +1294,18 @@ HELP
|
|||
cx = float_tiles->x + float_tiles->width / 2.0;
|
||||
cy = float_tiles->y + float_tiles->height / 2.0;
|
||||
|
||||
gimp_matrix_identity (matrix);
|
||||
gimp_matrix_translate (matrix, -cx, -cy);
|
||||
gimp_matrix3_identity (matrix);
|
||||
gimp_matrix3_translate (matrix, -cx, -cy);
|
||||
/* Shear matrix */
|
||||
shear_type = shear_type == HORIZONTAL ? ORIENTATION_HORIZONTAL :
|
||||
shear_type == VERTICAL ? ORIENTATION_VERTICAL :
|
||||
ORIENTATION_UNKNOWN;
|
||||
|
||||
if (shear_type == ORIENTATION_HORIZONTAL)
|
||||
gimp_matrix_xshear (matrix, magnitude / float_tiles->height);
|
||||
gimp_matrix3_xshear (matrix, magnitude / float_tiles->height);
|
||||
else if (shear_type == ORIENTATION_VERTICAL)
|
||||
gimp_matrix_yshear (matrix, magnitude / float_tiles->width);
|
||||
gimp_matrix_translate (matrix, +cx, +cy);
|
||||
gimp_matrix3_yshear (matrix, magnitude / float_tiles->width);
|
||||
gimp_matrix3_translate (matrix, +cx, +cy);
|
||||
|
||||
/* Shear the buffer */
|
||||
new_tiles = shear_tool_shear (gimage, drawable, NULL, float_tiles,
|
||||
|
|
Loading…
Reference in New Issue