Commit a0dfbce3 authored by Manish Singh's avatar Manish Singh

Doh. Actually cvs add the files doofus.

-Yosh
parent 33c01ce5
Makefile.in
Makefile
.deps
_libs
.libs
MapObject
Changes (post 0.31):
====================
-> 0.31 Merged MapPlane and MapSphere. Added support for non-interactive
execution (for script-fu).
-> 0.32 Fixed a bug in the bilinear interpolation function. Added "tile" option.
Added some icons to the material page to illustrate the effects of the
parameters. I'm not sure they help much.
-> 0.40 Some source/algorithm cleanups, fixed gtk+ object refcounting bugs. Some
changes to compile with gtk+ 0.99.4.
-> 1.00 First non-beta release. Replaced GckNotebook with GtkNotebook, fixed a few
annoying bugs. Better support for partial transparency (only filtered
transparency now, perhaps additive later). Compiles without warnings with
-Wall and -ansi.
## Process this file with automake to produce Makefile.in
pluginlibdir = $(gimpplugindir)/plug-ins
pluginlib_PROGRAMS = MapObject
MapObject_SOURCES = \
amb1.xpm amb2.xpm arcball.c arcball.h diffint1.xpm diffint2.xpm diffref1.xpm diffref2.xpm high1.xpm high2.xpm mapobject_apply.c mapobject_apply.h mapobject_image.c mapobject_image.h mapobject_main.c mapobject_main.h mapobject_pixmaps.h mapobject_preview.c mapobject_preview.h mapobject_shade.c mapobject_shade.h mapobject_ui.c mapobject_ui.h specref1.xpm specref2.xpm
INCLUDES = \
# -I$(top_srcdir) \
-I$(top_srcdir)/libgck \
-I$(includedir) \
$(X_CFLAGS)
LDADD = \
# $(top_builddir)/libgimp/libgimpui.la \
# $(top_builddir)/libgimp/libgimp.la \
$(top_builddir)/libgck/gck/libgck.la \
$(X_LIBS) \
-lc
DEPS = \
# $(top_builddir)/libgimp/libgimpui.la \
# $(top_builddir)/libgimp/libgimp.la \
$(top_builddir)/libgck/gck/libgck.la
MapObject_DEPENDENCIES = $(DEPS)
.PHONY: files
files:
@files=`ls $(DISTFILES) 2> /dev/null`; for p in $$files; do \
echo $$p; \
done
@for subdir in $(SUBDIRS); do \
files=`cd $$subdir; $(MAKE) files | grep -v "make\[[1-9]\]"`; \
for file in $$files; do \
echo $$subdir/$$file; \
done; \
done
MapObject 1.00 -- image filter plug-in for The GIMP program
===========================================================
Copyright (C) 1996-98 Tom Bech
Copyright (C) 1996-98 Federico Mena Quintero
You can reach the author(s) via E-mail:
tomb@gimp.org (Tom) or quartic@gimp.org (Federico).
The GIMP was developed by Peter Mattis and Spencer Kimball.
You can contact them at gimp@xcf.berkeley.edu.
There's more GIMP stuff on our home pages:
http://www.ii.uib.no/~tomb/gimp.html (Tom's page)
http://www.nuclecu.unam.mx/~federico/gimp/index.html (Quartic's page)
Legal stuff
===========
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 (see "COPYING" file); if not, write to the Free Software Foundation,
Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
In other words, you can't sue us for whatever happens while using this ;)
Compiling
=========
To compile you'll need The GIMP 0.99.20 and GTK+ 0.99.7 or later.
You'll also need GCK 1.00 (http://www.ii.uib.no/~tomb/gck.html)
1) Edit the Makefile to reflect your system setup.
2) Type "make" and then "make install"
You should now be ready to run. "make install" puts the executable "map_object"
in the standard plug-in directory.
Documentation
=============
Ahem.. right.. ;) ..I'll get around to it eventually.
Please send me a mail if you find any bugs.
Have fun,
Tom
The MapObject plug-in "todo"-list:
=================================
* Interactive positioning of directional light
* Rotation by mouse (doesn't work correctly yet and is disabled).
* Faster mapping code
* Multiple light-sources
* More objects - at least cube and cylinder.
* Presets (including save/load)
* Gray-scale/channels support
* Documentation
* Autoconf/automake stuff?
If there's anything you would like to add, feel free
to send me any suggestions for new stuff or improvements.
Tom
/* XPM */
char * amb1_xpm[] = {
"32 32 53 1",
" c None",
". c #861786178617",
"X c #861782078617",
"o c #69A66DB669A6",
"O c #8E388E388E38",
"+ c #B6DAB2CAB6DA",
"@ c #BEFBBAEABEFB",
"# c #AEBAAEBAAEBA",
"$ c #9E799E799E79",
"% c #8E388A288E38",
"& c #618565956185",
"* c #30C234D330C2",
"= c #A699A699A699",
"- c #CF3CCF3CCF3C",
"; c #D75CD34CD75C",
": c #C71BC30BC71B",
"> c #DF7DDF7DDF7D",
", c #D75CD75CD75C",
"< c #CF3CCB2BCF3C",
"1 c #AEBAAAAAAEBA",
"2 c #965896589658",
"3 c #79E779E779E7",
"4 c #514455555144",
"5 c #18611C711861",
"6 c #E79DE38DE79D",
"7 c #E79DE79DE79D",
"8 c #DF7DDB6CDF7D",
"9 c #BEFBBEFBBEFB",
"0 c #9E799A699E79",
"q c #79E77DF779E7",
"w c #618561856185",
"e c #38E338E338E3",
"r c #000004100000",
"t c #EFBEEFBEEFBE",
"y c #FFFFFBEEFFFF",
"u c #410341034103",
"i c #08200C300820",
"p c #FFFFFFFFFFFF",
"a c #B6DAB6DAB6DA",
"s c #965892489658",
"d c #104014511040",
"f c #71C675D671C6",
"g c #596559655965",
"h c #104010401040",
"j c #000000000000",
"k c #514451445144",
"l c #30C230C230C2",
"z c #59655D755965",
"x c #410345144103",
"c c #208124922081",
"v c #49244D344924",
"b c #208120812081",
"n c #082008200820",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" .Xo ",
" O+@@#$%&* ",
" =-;;-:+$.&* ",
" =;>>>,<@12345 ",
" O->6778-9#0qwer ",
" +;>7tyt-910X&ui ",
" @;>7ypy-a=sqwud ",
" .@-,8ty6:#$Ofgehj ",
" X#:<---:+=2Xoklij ",
" o$+@99a#=2.fzxcrj ",
" %$1#1=$2.f&v*dj ",
" &.200sOXf&kebrj ",
" *&3qXqfozvecnjj ",
" *4w&wgkx*bnjj ",
" 5euuelcdrjj ",
" ridhirjjj ",
" jjj ",
" ",
" ",
" ",
" ",
" ",
" ",
" "};
/* XPM */
char * amb2_xpm[] = {
"32 32 23 1",
" c None",
". c #CF3CCF3CCF3C",
"X c #CF3CCB2BCF3C",
"o c #C71BC30BC71B",
"O c #D75CD75CD75C",
"+ c #DF7DDB6CDF7D",
"@ c #C71BC71BC71B",
"# c #AEBAAEBAAEBA",
"$ c #DF7DDF7DDF7D",
"% c #E79DE38DE79D",
"& c #D75CD34CD75C",
"* c #E79DE79DE79D",
"= c #AEBAAAAAAEBA",
"- c #EFBEEBADEFBE",
"; c #BEFBBEFBBEFB",
": c #A699A289A699",
"> c #F7DEF3CEF7DE",
", c #F7DEF7DEF7DE",
"< c #B6DAB2CAB6DA",
"1 c #FFFFFFFFFFFF",
"2 c #FFFFFBEEFFFF",
"3 c #B6DAB6DAB6DA",
"4 c #BEFBBAEABEFB",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ..X ",
" oO+++O.@# ",
" X$%%$$+O&X# ",
" X%%*%%$$+&.@= ",
" o$%**-*%$+O.@;: ",
" O%**>,,%$+O.Xo< ",
" +%%-,12*+O&.Xo3 ",
" .+$%*,2,%+O&.@;3< ",
" .+$$%%*%+O&.X@;3< ",
" XO+$$$++OO&.@o43< ",
" .O+++OO&&.Xo;3< ",
" @&&OO&&..X@;43# ",
" #X.....X@o;43<: ",
" #@@XX@@o;43<: ",
" =;oo;;433<: ",
" :<3333<#: ",
" <<< ",
" ",
" ",
" ",
" ",
" ",
" ",
" "};
/************************************/
/* ArcBall.c (c) Ken Shoemake, 1993 */
/* Modified by Tom Bech, 1996 */
/************************************/
#include <math.h>
#include <gdk/gdk.h>
#include <libgimp/gimp.h>
#include "arcball.h"
/* Gloval variables */
/* ================ */
HVect center;
double radius;
Quat qNow, qDown, qDrag;
HVect vNow, vDown, vFrom, vTo, vrFrom, vrTo;
HMatrix mNow, mDown;
unsigned int showResult, dragging;
ConstraintSet sets[NSets];
int setSizes[NSets];
AxisSet axisSet;
int axisIndex;
HMatrix mId = {{1,0,0,0},{0,1,0,0},{0,0,1,0},{0,0,0,1}};
double otherAxis[][4] = {{-0.48, 0.80, 0.36, 1}};
Quat qOne = {0, 0, 0, 1};
/* Externally visible methods */
/* ========================== */
void ArcBall_Init();
void ArcBall_Place(HVect Center, double Radius);
void ArcBall_UseSet(AxisSet axis_Set);
void ArcBall_Update(void);
void ArcBall_Value(HMatrix m_Now);
void ArcBall_Values(double *alpha,double *beta,double *gamma);
void ArcBall_BeginDrag(void);
void ArcBall_EndDrag(void);
void ArcBall_Mouse(HVect v_Now);
void ArcBall_CopyMat(HMatrix inm,HMatrix outm);
/* Internal methods */
/* ================ */
HMatrix *Qt_ToMatrix(Quat q,HMatrix out);
Quat Qt_Conj(Quat q);
Quat Qt_Mul(Quat qL, Quat qR);
Quat Qt_FromBallPoints(HVect from, HVect to);
void Qt_ToBallPoints(Quat q, HVect *arcFrom, HVect *arcTo);
HVect V3_(double x, double y, double z);
double V3_Norm(HVect v);
HVect V3_Unit(HVect v);
HVect V3_Scale(HVect v, double s);
HVect V3_Negate(HVect v);
HVect V3_Add(HVect v1, HVect v2);
HVect V3_Sub(HVect v1, HVect v2);
double V3_Dot(HVect v1, HVect v2);
HVect V3_Cross(HVect v1, HVect v2);
HVect V3_Bisect(HVect v0, HVect v1);
HVect MouseOnSphere(HVect mouse, HVect ballCenter, double ballRadius);
HVect ConstrainToAxis(HVect loose, HVect axis);
int NearestConstraintAxis(HVect loose, HVect *axes, int nAxes);
/* Establish reasonable initial values for controller. */
/* =================================================== */
void ArcBall_Init(void)
{
int i;
center = qOne;
radius = 1.0;
vDown = vNow = qOne;
qDown = qNow = qOne;
for (i=15; i>=0; i--) ((double *)mNow)[i] = ((double *)mDown)[i] = ((double *)mId)[i];
showResult = dragging = FALSE;
axisSet = NoAxes;
sets[CameraAxes] = mId[X];
setSizes[CameraAxes] = 3;
sets[BodyAxes] = mDown[X];
setSizes[BodyAxes] = 3;
sets[OtherAxes] = otherAxis[X];
setSizes[OtherAxes] = 1;
}
/* Set the center and size of the controller. */
/* ========================================== */
void ArcBall_Place(HVect Center, double Radius)
{
center = Center;
radius = Radius;
}
/* Incorporate new mouse position. */
/* =============================== */
void ArcBall_Mouse(HVect v_Now)
{
vNow = v_Now;
}
/* Choose a constraint set, or none. */
/* ================================= */
void ArcBall_UseSet(AxisSet axis_Set)
{
if (!dragging) axisSet = axis_Set;
}
/* Using vDown, vNow, dragging, and axisSet, compute rotation etc. */
/* =============================================================== */
void ArcBall_Update(void)
{
int setSize = setSizes[axisSet];
HVect *set = (HVect *)(sets[axisSet]);
vFrom = MouseOnSphere(vDown, center, radius);
vTo = MouseOnSphere(vNow, center, radius);
if (dragging)
{
if (axisSet!=NoAxes)
{
vFrom = ConstrainToAxis(vFrom, set[axisIndex]);
vTo = ConstrainToAxis(vTo, set[axisIndex]);
}
qDrag = Qt_FromBallPoints(vFrom, vTo);
qNow = Qt_Mul(qDrag, qDown);
}
else
{
if (axisSet!=NoAxes) axisIndex = NearestConstraintAxis(vTo, set, setSize);
}
Qt_ToBallPoints(qDown, &vrFrom, &vrTo);
Qt_ToMatrix(Qt_Conj(qNow), mNow); /* Gives transpose for GL. */
}
/* Return rotation matrix defined by controller use. */
/* ================================================= */
void ArcBall_Value(HMatrix m_Now)
{
ArcBall_CopyMat(mNow,m_Now);
}
/* Extract rotation angles from matrix */
/* =================================== */
void ArcBall_Values(double *alpha,double *beta,double *gamma)
{
if ((*beta=asin(-mNow[0][2]))!=0.0)
{
*gamma=atan2(mNow[1][2],mNow[2][2]);
*alpha=atan2(mNow[0][1],mNow[0][0]);
}
else
{
*gamma=atan2(mNow[1][0],mNow[1][1]);
*alpha=0.0;
}
}
/* Begin drag sequence. */
/* ==================== */
void ArcBall_BeginDrag(void)
{
dragging = TRUE;
vDown = vNow;
}
/* Stop drag sequence. */
/* =================== */
void ArcBall_EndDrag(void)
{
dragging = FALSE;
qDown = qNow;
ArcBall_CopyMat(mNow,mDown);
}
/*===================*/
/***** BallAux.c *****/
/*===================*/
/* Return quaternion product qL * qR. Note: order is important! */
/* To combine rotations, use the product Mul(qSecond, qFirst), */
/* which gives the effect of rotating by qFirst then qSecond. */
/* ============================================================= */
Quat Qt_Mul(Quat qL, Quat qR)
{
Quat qq;
qq.w = qL.w*qR.w - qL.x*qR.x - qL.y*qR.y - qL.z*qR.z;
qq.x = qL.w*qR.x + qL.x*qR.w + qL.y*qR.z - qL.z*qR.y;
qq.y = qL.w*qR.y + qL.y*qR.w + qL.z*qR.x - qL.x*qR.z;
qq.z = qL.w*qR.z + qL.z*qR.w + qL.x*qR.y - qL.y*qR.x;
return (qq);
}
/* Construct rotation matrix from (possibly non-unit) quaternion. */
/* Assumes matrix is used to multiply column vector on the left: */
/* vnew = mat vold. Works correctly for right-handed coordinate */
/* system and right-handed rotations. */
/* ============================================================== */
HMatrix *Qt_ToMatrix(Quat q, HMatrix out)
{
double Nq = q.x*q.x + q.y*q.y + q.z*q.z + q.w*q.w;
double s = (Nq > 0.0) ? (2.0 / Nq) : 0.0;
double xs = q.x*s, ys = q.y*s, zs = q.z*s;
double wx = q.w*xs, wy = q.w*ys, wz = q.w*zs;
double xx = q.x*xs, xy = q.x*ys, xz = q.x*zs;
double yy = q.y*ys, yz = q.y*zs, zz = q.z*zs;
out[X][X] = 1.0 - (yy + zz); out[Y][X] = xy + wz; out[Z][X] = xz - wy;
out[X][Y] = xy - wz; out[Y][Y] = 1.0 - (xx + zz); out[Z][Y] = yz + wx;
out[X][Z] = xz + wy; out[Y][Z] = yz - wx; out[Z][Z] = 1.0 - (xx + yy);
out[X][W] = out[Y][W] = out[Z][W] = out[W][X] = out[W][Y] = out[W][Z] = 0.0;
out[W][W] = 1.0;
return ((HMatrix *)&out);
}
/* Return conjugate of quaternion. */
/* =============================== */
Quat Qt_Conj(Quat q)
{
Quat qq;
qq.x = -q.x; qq.y = -q.y; qq.z = -q.z; qq.w = q.w;
return (qq);
}
/* Return vector formed from components */
/* ==================================== */
HVect V3_(double x, double y, double z)
{
HVect v;
v.x = x; v.y = y; v.z = z; v.w = 0;
return (v);
}
/* Return norm of v, defined as sum of squares of components */
/* ========================================================= */
double V3_Norm(HVect v)
{
return ( v.x*v.x + v.y*v.y + v.z*v.z );
}
/* Return unit magnitude vector in direction of v */
/* ============================================== */
HVect V3_Unit(HVect v)
{
static HVect u = {0, 0, 0, 0};
double vlen = sqrt(V3_Norm(v));
if (vlen != 0.0) u.x = v.x/vlen; u.y = v.y/vlen; u.z = v.z/vlen;
return (u);
}
/* Return version of v scaled by s */
/* =============================== */
HVect V3_Scale(HVect v, double s)
{
HVect u;
u.x = s*v.x; u.y = s*v.y; u.z = s*v.z; u.w = v.w;
return (u);
}
/* Return negative of v */
/* ==================== */
HVect V3_Negate(HVect v)
{
static HVect u = {0, 0, 0, 0};
u.x = -v.x; u.y = -v.y; u.z = -v.z;
return (u);
}
/* Return sum of v1 and v2 */
/* ======================= */
HVect V3_Add(HVect v1, HVect v2)
{
static HVect v = {0, 0, 0, 0};
v.x = v1.x+v2.x; v.y = v1.y+v2.y; v.z = v1.z+v2.z;
return (v);
}
/* Return difference of v1 minus v2 */
/* ================================ */
HVect V3_Sub(HVect v1, HVect v2)
{
static HVect v = {0, 0, 0, 0};
v.x = v1.x-v2.x; v.y = v1.y-v2.y; v.z = v1.z-v2.z;
return (v);
}
/* Halve arc between unit vectors v0 and v1. */
/* ========================================= */
HVect V3_Bisect(HVect v0, HVect v1)
{
HVect v = {0, 0, 0, 0};
double Nv;
v = V3_Add(v0, v1);
Nv = V3_Norm(v);
if (Nv < 1.0e-5) v = V3_(0, 0, 1);
else v = V3_Scale(v, 1/sqrt(Nv));
return (v);
}
/* Return dot product of v1 and v2 */
/* =============================== */
double V3_Dot(HVect v1, HVect v2)
{
return (v1.x*v2.x + v1.y*v2.y + v1.z*v2.z);
}
/* Return cross product, v1 x v2 */
/* ============================= */
HVect V3_Cross(HVect v1, HVect v2)
{
static HVect v = {0, 0, 0, 0};
v.x = v1.y*v2.z-v1.z*v2.y;
v.y = v1.z*v2.x-v1.x*v2.z;
v.z = v1.x*v2.y-v1.y*v2.x;
return (v);
}
void ArcBall_CopyMat(HMatrix inm,HMatrix outm)
{
int x=0,y=0;
for (x=0;x<4;x++)
{
for (y=0;y<4;y++)
{
outm[y][x]=inm[y][x];
}
}
}
/*=====================================================*/
/**** BallMath.c - Essential routines for ArcBall. ****/
/*=====================================================*/
/* Convert window coordinates to sphere coordinates. */
/* ================================================= */
HVect MouseOnSphere(HVect mouse, HVect ballCenter, double ballRadius)
{
HVect ballMouse;
register double mag;
ballMouse.x = (mouse.x - ballCenter.x) / ballRadius;
ballMouse.y = (mouse.y - ballCenter.y) / ballRadius;
mag = ballMouse.x*ballMouse.x + ballMouse.y*ballMouse.y;
if (mag > 1.0)
{
register double scale = 1.0/sqrt(mag);
ballMouse.x *= scale; ballMouse.y *= scale;
ballMouse.z = 0.0;
}
else ballMouse.z = sqrt(1 - mag);
ballMouse.w = 0.0;
return (ballMouse);
}
/* Construct a unit quaternion from two points on unit sphere */
/* ========================================================== */
Quat Qt_FromBallPoints(HVect from, HVect to)
{
Quat qu;
qu.x = from.y*to.z - from.z*to.y;
qu.y = from.z*to.x - from.x*to.z;
qu.z = from.x*to.y - from.y*to.x;
qu.w = from.x*to.x + from.y*to.y + from.z*to.z;
return (qu);
}
/* Convert a unit quaternion to two points on unit sphere */
/* ====================================================== */
void Qt_ToBallPoints(Quat q, HVect *arcFrom, HVect *arcTo)
{
double s;
s = sqrt(q.x*q.x + q.y*q.y);
if (s == 0.0) *arcFrom = V3_(0.0, 1.0, 0.0);
else *arcFrom = V3_(-q.y/s, q.x/s, 0.0);
arcTo->x = q.w*arcFrom->x - q.z*arcFrom->y;
arcTo->y = q.w*arcFrom->y + q.z*arcFrom->x;
arcTo->z = q.x*arcFrom->y - q.y*arcFrom->x;
if (q.w < 0.0) *arcFrom = V3_(-arcFrom->x, -arcFrom->y, 0.0);
}
/* Force sphere point to be perpendicular to axis. */
/* =============================================== */
HVect ConstrainToAxis(HVect loose, HVect axis)
{
HVect onPlane;
register double norm;
onPlane = V3_Sub(loose, V3_Scale(axis, V3_Dot(axis, loose)));
norm = V3_Norm(onPlane);
if (norm > 0.0)
{
if (onPlane.z < 0.0) onPlane = V3_Negate(onPlane);
return ( V3_Scale(onPlane, 1/sqrt(norm)) );
}
/* else drop through */
/* ================= */
if (axis.z == 1) onPlane = V3_(1.0, 0.0, 0.0);
else onPlane =