summaryrefslogtreecommitdiffstats
path: root/src/gleem/linalg/Rotf.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/gleem/linalg/Rotf.java')
-rw-r--r--src/gleem/linalg/Rotf.java309
1 files changed, 309 insertions, 0 deletions
diff --git a/src/gleem/linalg/Rotf.java b/src/gleem/linalg/Rotf.java
new file mode 100644
index 0000000..4e39c21
--- /dev/null
+++ b/src/gleem/linalg/Rotf.java
@@ -0,0 +1,309 @@
+/*
+ * gleem -- OpenGL Extremely Easy-To-Use Manipulators.
+ * Copyright (C) 1998-2003 Kenneth B. Russell ([email protected])
+ *
+ * Copying, distribution and use of this software in source and binary
+ * forms, with or without modification, is permitted provided that the
+ * following conditions are met:
+ *
+ * Distributions of source code must reproduce the copyright notice,
+ * this list of conditions and the following disclaimer in the source
+ * code header files; and Distributions of binary code must reproduce
+ * the copyright notice, this list of conditions and the following
+ * disclaimer in the documentation, Read me file, license file and/or
+ * other materials provided with the software distribution.
+ *
+ * The names of Sun Microsystems, Inc. ("Sun") and/or the copyright
+ * holder may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS," WITHOUT A WARRANTY OF ANY
+ * KIND. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
+ * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, NON-INTERFERENCE, ACCURACY OF
+ * INFORMATIONAL CONTENT OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. THE
+ * COPYRIGHT HOLDER, SUN AND SUN'S LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL THE
+ * COPYRIGHT HOLDER, SUN OR SUN'S LICENSORS BE LIABLE FOR ANY LOST
+ * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
+ * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
+ * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
+ * INABILITY TO USE THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGES. YOU ACKNOWLEDGE THAT THIS SOFTWARE IS NOT
+ * DESIGNED, LICENSED OR INTENDED FOR USE IN THE DESIGN, CONSTRUCTION,
+ * OPERATION OR MAINTENANCE OF ANY NUCLEAR FACILITY. THE COPYRIGHT
+ * HOLDER, SUN AND SUN'S LICENSORS DISCLAIM ANY EXPRESS OR IMPLIED
+ * WARRANTY OF FITNESS FOR SUCH USES.
+ */
+
+package gleem.linalg;
+
+/** Represents a rotation with single-precision components */
+
+public class Rotf {
+ private static float EPSILON = 1.0e-7f;
+
+ // Representation is a quaternion. Element 0 is the scalar part (=
+ // cos(theta/2)), elements 1..3 the imaginary/"vector" part (=
+ // sin(theta/2) * axis).
+ private float q0;
+ private float q1;
+ private float q2;
+ private float q3;
+
+ /** Default constructor initializes to the identity quaternion */
+ public Rotf() {
+ init();
+ }
+
+ public Rotf(Rotf arg) {
+ set(arg);
+ }
+
+ /** Axis does not need to be normalized but must not be the zero
+ vector. Angle is in radians. */
+ public Rotf(Vec3f axis, float angle) {
+ set(axis, angle);
+ }
+
+ /** Creates a rotation which will rotate vector "from" into vector
+ "to". */
+ public Rotf(Vec3f from, Vec3f to) {
+ set(from, to);
+ }
+
+ /** Re-initialize this quaternion to be the identity quaternion "e"
+ (i.e., no rotation) */
+ public void init() {
+ q0 = 1;
+ q1 = q2 = q3 = 0;
+ }
+
+ /** Test for "approximate equality" -- performs componentwise test
+ to see whether difference between all components is less than
+ epsilon. */
+ public boolean withinEpsilon(Rotf arg, float epsilon) {
+ return ((Math.abs(q0 - arg.q0) < epsilon) &&
+ (Math.abs(q1 - arg.q1) < epsilon) &&
+ (Math.abs(q2 - arg.q2) < epsilon) &&
+ (Math.abs(q3 - arg.q3) < epsilon));
+ }
+
+ /** Axis does not need to be normalized but must not be the zero
+ vector. Angle is in radians. */
+ public void set(Vec3f axis, float angle) {
+ float halfTheta = angle / 2.0f;
+ q0 = (float) Math.cos(halfTheta);
+ float sinHalfTheta = (float) Math.sin(halfTheta);
+ Vec3f realAxis = new Vec3f(axis);
+ realAxis.normalize();
+ q1 = realAxis.x() * sinHalfTheta;
+ q2 = realAxis.y() * sinHalfTheta;
+ q3 = realAxis.z() * sinHalfTheta;
+ }
+
+ public void set(Rotf arg) {
+ q0 = arg.q0;
+ q1 = arg.q1;
+ q2 = arg.q2;
+ q3 = arg.q3;
+ }
+
+ /** Sets this rotation to that which will rotate vector "from" into
+ vector "to". from and to do not have to be the same length. */
+ public void set(Vec3f from, Vec3f to) {
+ Vec3f axis = from.cross(to);
+ if (axis.lengthSquared() < EPSILON) {
+ init();
+ return;
+ }
+ float dotp = from.dot(to);
+ float denom = from.length() * to.length();
+ if (denom < EPSILON) {
+ init();
+ return;
+ }
+ dotp /= denom;
+ set(axis, (float) Math.acos(dotp));
+ }
+
+ /** Returns angle (in radians) and mutates the given vector to be
+ the axis. */
+ public float get(Vec3f axis) {
+ // FIXME: Is this numerically stable? Is there a better way to
+ // extract the angle from a quaternion?
+ // NOTE: remove (float) to illustrate compiler bug
+ float retval = (float) (2.0f * Math.acos(q0));
+ axis.set(q1, q2, q3);
+ float len = axis.length();
+ if (len == 0.0f) {
+ axis.set(0, 0, 1);
+ } else {
+ axis.scale(1.0f / len);
+ }
+ return retval;
+ }
+
+ /** Returns inverse of this rotation; creates new rotation */
+ public Rotf inverse() {
+ Rotf tmp = new Rotf(this);
+ tmp.invert();
+ return tmp;
+ }
+
+ /** Mutate this quaternion to be its inverse. This is equivalent to
+ the conjugate of the quaternion. */
+ public void invert() {
+ q1 = -q1;
+ q2 = -q2;
+ q3 = -q3;
+ }
+
+ /** Length of this quaternion in four-space */
+ public float length() {
+ return (float) Math.sqrt(lengthSquared());
+ }
+
+ /** This dotted with this */
+ public float lengthSquared() {
+ return (q0 * q0 +
+ q1 * q1 +
+ q2 * q2 +
+ q3 * q3);
+ }
+
+ /** Make this quaternion a unit quaternion again. If you are
+ composing dozens of quaternions you probably should call this
+ periodically to ensure that you have a valid rotation. */
+ public void normalize() {
+ float len = length();
+ q0 /= len;
+ q1 /= len;
+ q2 /= len;
+ q3 /= len;
+ }
+
+ /** Returns this * b, in that order; creates new rotation */
+ public Rotf times(Rotf b) {
+ Rotf tmp = new Rotf();
+ tmp.mul(this, b);
+ return tmp;
+ }
+
+ /** Compose two rotations: this = A * B in that order. NOTE that
+ because we assume a column vector representation that this
+ implies that a vector rotated by the cumulative rotation will be
+ rotated first by B, then A. NOTE: "this" must be different than
+ both a and b. */
+ public void mul(Rotf a, Rotf b) {
+ q0 = (a.q0 * b.q0 - a.q1 * b.q1 -
+ a.q2 * b.q2 - a.q3 * b.q3);
+ q1 = (a.q0 * b.q1 + a.q1 * b.q0 +
+ a.q2 * b.q3 - a.q3 * b.q2);
+ q2 = (a.q0 * b.q2 + a.q2 * b.q0 -
+ a.q1 * b.q3 + a.q3 * b.q1);
+ q3 = (a.q0 * b.q3 + a.q3 * b.q0 +
+ a.q1 * b.q2 - a.q2 * b.q1);
+ }
+
+ /** Turns this rotation into a 3x3 rotation matrix. NOTE: only
+ mutates the upper-left 3x3 of the passed Mat4f. Implementation
+ from B. K. P. Horn's <u>Robot Vision</u> textbook. */
+ public void toMatrix(Mat4f mat) {
+ float q00 = q0 * q0;
+ float q11 = q1 * q1;
+ float q22 = q2 * q2;
+ float q33 = q3 * q3;
+ // Diagonal elements
+ mat.set(0, 0, q00 + q11 - q22 - q33);
+ mat.set(1, 1, q00 - q11 + q22 - q33);
+ mat.set(2, 2, q00 - q11 - q22 + q33);
+ // 0,1 and 1,0 elements
+ float q03 = q0 * q3;
+ float q12 = q1 * q2;
+ mat.set(0, 1, 2.0f * (q12 - q03));
+ mat.set(1, 0, 2.0f * (q03 + q12));
+ // 0,2 and 2,0 elements
+ float q02 = q0 * q2;
+ float q13 = q1 * q3;
+ mat.set(0, 2, 2.0f * (q02 + q13));
+ mat.set(2, 0, 2.0f * (q13 - q02));
+ // 1,2 and 2,1 elements
+ float q01 = q0 * q1;
+ float q23 = q2 * q3;
+ mat.set(1, 2, 2.0f * (q23 - q01));
+ mat.set(2, 1, 2.0f * (q01 + q23));
+ }
+
+ /** Turns the upper left 3x3 of the passed matrix into a rotation.
+ Implementation from Watt and Watt, <u>Advanced Animation and
+ Rendering Techniques</u>.
+ @see gleem.linalg.Mat4f#getRotation */
+ public void fromMatrix(Mat4f mat) {
+ // FIXME: Should reimplement to follow Horn's advice of using
+ // eigenvector decomposition to handle roundoff error in given
+ // matrix.
+
+ float tr, s;
+ int i, j, k;
+
+ tr = mat.get(0, 0) + mat.get(1, 1) + mat.get(2, 2);
+ if (tr > 0.0) {
+ s = (float) Math.sqrt(tr + 1.0f);
+ q0 = s * 0.5f;
+ s = 0.5f / s;
+ q1 = (mat.get(2, 1) - mat.get(1, 2)) * s;
+ q2 = (mat.get(0, 2) - mat.get(2, 0)) * s;
+ q3 = (mat.get(1, 0) - mat.get(0, 1)) * s;
+ } else {
+ i = 0;
+ if (mat.get(1, 1) > mat.get(0, 0))
+ i = 1;
+ if (mat.get(2, 2) > mat.get(i, i))
+ i = 2;
+ j = (i+1)%3;
+ k = (j+1)%3;
+ s = (float) Math.sqrt( (mat.get(i, i) - (mat.get(j, j) + mat.get(k, k))) + 1.0f);
+ setQ(i+1, s * 0.5f);
+ s = 0.5f / s;
+ q0 = (mat.get(k, j) - mat.get(j, k)) * s;
+ setQ(j+1, (mat.get(j, i) + mat.get(i, j)) * s);
+ setQ(k+1, (mat.get(k, i) + mat.get(i, k)) * s);
+ }
+ }
+
+ /** Rotate a vector by this quaternion. Implementation is from
+ Horn's <u>Robot Vision</u>. NOTE: src and dest must be different
+ vectors. */
+ public void rotateVector(Vec3f src, Vec3f dest) {
+ Vec3f qVec = new Vec3f(q1, q2, q3);
+ Vec3f qCrossX = qVec.cross(src);
+ Vec3f qCrossXCrossQ = qCrossX.cross(qVec);
+ qCrossX.scale(2.0f * q0);
+ qCrossXCrossQ.scale(-2.0f);
+ dest.add(src, qCrossX);
+ dest.add(dest, qCrossXCrossQ);
+ }
+
+ /** Rotate a vector by this quaternion, returning newly-allocated result. */
+ public Vec3f rotateVector(Vec3f src) {
+ Vec3f tmp = new Vec3f();
+ rotateVector(src, tmp);
+ return tmp;
+ }
+
+ public String toString() {
+ return "(" + q0 + ", " + q1 + ", " + q2 + ", " + q3 + ")";
+ }
+
+ private void setQ(int i, float val) {
+ switch (i) {
+ case 0: q0 = val; break;
+ case 1: q1 = val; break;
+ case 2: q2 = val; break;
+ case 3: q3 = val; break;
+ default: throw new IndexOutOfBoundsException();
+ }
+ }
+}
72 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939
<?xml version="1.0" encoding="UTF-8"?>
<!--
   - Ant build for the NativeWindow package.  This build has been tested with ANT 1.7.0.  The
   - optional.jar that contains the optional ANT tasks must be in the ANT
   - classpath (typically the ant/lib directory).
   -
   - A clean download of the NativeWindow sources is required for this build.
   -
   - This build has no dependence on environment variables; the needed
   - ones (e.g. java.home, ANT_HOME) are all set by the Ant wrapper shell
   - script, by the virtual machine, or elsewhere. However, on all platforms,
   - the C compiler and linker should be in the path. All other paths that
   - need to be set are in host.properties.
   -
   - NOTE:  because the GlueGen config files have their own relative paths
   -        which cannot be overridden by GlueGen, GlueGen MUST be run from
   -        the "make" directory. This also means that this build.xml MUST
   -        be run from the "make" directory.
   -
   - Public targets:
   -   all: (default; autodetects OS and chooses C compiler from gluegen.properties)
   -   clean:        clean all built
   -   javadoc:      create the standard developer Javadoc (recommended)
   -                 (Note: should build all first - may be dependence in the future)
   -   javadoc.spec: create the standard developer Javadoc but exclude com.jogamp.* classes
   -   javadoc.dev:  create the internal developer Javadoc.  This includes the
   -                       Java and C file generators. Note that it is only supported
   -                       to create the Javadoc for the platform on which you are
   -                       currently running.
   - 
   - Note: on Windows the "win32.c.compiler" property in gluegen.properties
   - is required to select the appropriate C compiler. See the example
   - gluegen.properties in the gluegen workspace for valid values. On Mac OS X
   - universal binaries may also be built by setting the "macosxfat"
   - property in gluegen.properties; again see the example file in this
   - directory.
   -   
   - Thanks to Rob Grzywinski and Artur Biesiadowski for the bulk of the
   - ANT build, including the GlueGen tasks, the building of
   - the Java generated sources, the first and second phase Java compiles, and
   - the building of the jar file. Thanks to Alex Radeski for the bulk of the
   - port to the ant-contrib CPPTask framework. Thanks to Athomas Goldberg for
   - the original OS detection code.
   -
   - Some environment defs affecting native compilation
       setup.noNativeAWT

   - Internal settings, may not be necessary to set them manually,
     since all JAR archives are orthogonal.
       setup.noAWT
   -->
<project name="NativeWindow" basedir="." default="all">

    <import file="build-common.xml"/>

	<!-- needed for outofdate task -->
    <taskdef resource="net/sf/antcontrib/antlib.xml">
      <classpath> <pathelement location="${ant-contrib.jar}"/> </classpath>
    </taskdef>

	<!-- ================================================================== -->
    <!-- 
       - Base initialization and detection of operating system.
      -->
    <target name="base.init" depends="common.init">

        <!-- partitioning -->

        <property name="java.part.core"
                  value="javax/media/nativewindow/* javax/media/nativewindow/util/* com/jogamp/nativewindow/* com/jogamp/nativewindow/egl/* com/jogamp/nativewindow/swt/** jogamp/nativewindow/*"/>

        <property name="java.part.awt"
                  value="com/jogamp/nativewindow/awt/* jogamp/nativewindow/jawt/** jogamp/nativewindow/**/awt/**"/>

        <property name="java.part.x11"
                  value="com/jogamp/nativewindow/x11/* jogamp/nativewindow/x11/*" />

        <property name="java.part.windows"
                  value="com/jogamp/nativewindow/windows/* jogamp/nativewindow/windows/*" />

        <property name="java.part.macosx"
                  value="com/jogamp/nativewindow/macosx/* jogamp/nativewindow/macosx/*" />

        <!-- condition excludes -->

        <condition property="java.excludes.awt"
                   value="${java.part.awt}">
           <isset property="setup.noAWT"/> 
        </condition>

        <property name="java.excludes.all" value="${java.excludes.awt}" />
        <echo message="java.excludes.all: ${java.excludes.all}" />
    </target>


    <!-- ================================================================== -->
    <!-- 
       - Declare all paths and user defined variables.
      -->
    <target name="declare.common" description="Declare properties" depends="base.init">

        <property name="config.nativewindow" value="${config}/nativewindow" />

        <property name="rootrel.src" value="src/nativewindow" />
        <property name="rootrel.src.java" value="${rootrel.src}/classes" />
        <property name="rootrel.src.c" value="${rootrel.src}/native" />

        <property name="rootrel.src.generated" value="${rootrel.build}/nativewindow/gensrc" />
        <property name="rootrel.generated.c" value="${rootrel.src.generated}/native" />

        <!-- The source directories. -->
        <property name="src.java" value="${project.root}/${rootrel.src.java}" />
        <property name="src.c"    value="${project.root}/${rootrel.src.c}" />
        
        <!-- The generated source directories. -->
        <property name="src.generated" value="${build.nativewindow}/gensrc" />
        <property name="src.generated.java" value="${src.generated}/classes" />
        <property name="src.generated.c" value="${src.generated}/native" />
        
        <!-- The compiler output directories. -->
        <property name="classes" value="${build.nativewindow}/classes" />

        <property name="javah.classpath" value="${gluegen-rt.jar}:${classes}" />

        <!-- The headers from which Java files are generated -->
        <dirset id="stub.includes.fileset.all" dir=".">
            <include name="${stub.includes}/macosx/**" />
            <include name="${stub.includes}/win32/**" />
            <include name="${stub.includes}/x11/**" />
            <include name="${stub.includes}/gluegen/**" />
            <include name="${stub.includes}/khr/**" />
            <include name="${stub.includes}/jni/**" />
        </dirset>
        <fileset id="stub.includes.dependencies.fileset.1" dir="${stub.includes}">
            <include name="macosx/**" />
            <include name="win32/**" />
            <include name="x11/**" />
            <include name="common/**" />
            <include name="jni/**" />
        </fileset>
        <fileset id="stub.includes.dependencies.fileset.2" file="${gluegen.jar}" />
        <fileset id="stub.includes.dependencies.fileset.3" dir="${config.nativewindow}">
            <include name="*.cfg" />
            <include name="*.java" />
            <include name="*.c" />
        </fileset>

        <!-- The javadoc dirs. -->
        <property name="javadoc" value="${project.root}/javadoc_nativewindow_public" />
        <property name="javadoc.spec" value="${project.root}/javadoc_nativewindow_spec" />
        <property name="javadoc.dev" value="${project.root}/javadoc_nativewindow_dev" />
        <property name="javadoc.windowtitle" value="Native Windowing Interface (NativeWindow) API -- ${jogamp.version.base} Specification" />
        <property name="javadoc.overview" value="../src/nativewindow/classes/javax/media/nativewindow/package.html" />
        <property name="javadoc.spec.packagenames" value="javax.media.nativewindow.*" />

        <property name="javadoc.packagenames" value="${javadoc.spec.packagenames}" />

        <property name="javadoc.dev.packagenames" value="${javadoc.packagenames},com.jogamp.nativewindow.util.*,jogamp.nativewindow.*,com.jogamp.gluegen,com.jogamp.gluegen.runtime" />
    <property name="javadoc.bottom" value="Copyright 2005 Sun Microsystems, Inc. All rights reserved. Use is subject to &lt;a href=&quot;http://jcp.org/en/jsr/detail?id=231&quot;&gt;license terms&lt;/a&gt;." />
    </target>
    
    <!-- ================================================================== -->
    <!-- 
       - Initialize all parameters required for the build and create any
       - required directories.
      -->
    <target name="init" depends="declare.common">
        <!-- Create the required output directories. -->
        <mkdir dir="${src.generated.java}" />
        <mkdir dir="${src.generated.c}" />
        <mkdir dir="${src.generated.c}/MacOSX" />
        <mkdir dir="${src.generated.c}/Windows" />
        <mkdir dir="${src.generated.c}/X11" />
        <mkdir dir="${classes}" />
        <mkdir dir="${obj.nativewindow}" />
    </target>

    <!--
       - Check to see whether we need to rebuild the generated sources.
      -->
    <target name="java.generate.check">
        <!-- Blow away all target files if any dependencies are violated
             (the uptodate task doesn't allow arbitrary source and target filesets but should) -->
             <!--
        <dependset>
            <srcfileset refid="stub.includes.dependencies.fileset.1" />
            <srcfileset refid="stub.includes.dependencies.fileset.2" />
            <srcfileset refid="stub.includes.dependencies.fileset.3" />
            <targetfileset dir="${src.generated}">
                <include name="**/*.java" />
                <include name="**/*.c" />
            </targetfileset>
        </dependset>
        -->

        <!-- Now check for the presence of one well-known file -->
        <uptodate property="java.generate.skip.x11windowlib"
                  targetfile="${src.generated.java}/jogamp/nativewindow/x11/X11Lib.java">
            <srcfiles refid="stub.includes.dependencies.fileset.1" />
            <srcfiles refid="stub.includes.dependencies.fileset.2" />
            <srcfiles refid="stub.includes.dependencies.fileset.3" />
        </uptodate>
        <uptodate property="java.generate.skip.jawt"
                  targetfile="${src.generated.java}/jogamp/nativewindow/jawt/JAWT.java">
            <srcfiles refid="stub.includes.dependencies.fileset.1" />
            <srcfiles refid="stub.includes.dependencies.fileset.2" />
            <srcfiles refid="stub.includes.dependencies.fileset.3" />
        </uptodate>

        <condition property="java.generate.skip">
          <and>
              <isset property="java.generate.skip.x11windowlib"/>
              <isset property="java.generate.skip.jawt"/>
          </and>
        </condition>

        <!--property name="java.generate.skip" value="true"/-->
    </target>

    <target name="java.generate.windowlib" if="windowlib.os.cfg">
        <echo message="Generating Windowing Lib implementation class" />
        <antcall target="java.generate.copy2temp" inheritRefs="true" />
        <gluegen src="${stub.includes}/${window.os.system}/window-lib.c"
                 outputRootDir="${build.nativewindow}"
                 config="${windowlib.os.cfg}"
                 includeRefid="stub.includes.fileset.platform"
                 literalInclude="${stub.includes.gluegen.gg}, ${src.c}/${window.os.system}"
                 emitter="com.jogamp.gluegen.JavaEmitter"
                 debug="false"
                 dumpCPP="false">
            <classpath refid="gluegen.classpath" />
        </gluegen>
    </target>

    <target name="java.generate.jawt" unless="setup.noAWT">
        <!-- NOTE:  the "literalInclude" in this GlueGen call is simply to
           -        get around the fact that neither FileSet nor DirSet can
           -        handle different drives in an effective manner. -->
        <echo message="Generating JAWT interface class" />
        <echo message="java.home.dir=${java.home.dir}" />
        <antcall target="java.generate.copy2temp" inheritRefs="true" />
        <gluegen src="${jawt.platform.header}"
                 outputRootDir="${build.nativewindow}"
                 config="${jawt.cfg}"
                 includeRefid="stub.includes.fileset.platform"
                 literalInclude="${stub.includes.gluegen.gg}, ${stub.includes}/jni"
                 emitter="com.jogamp.gluegen.JavaEmitter"
                 debug="false"
                 dumpCPP="false">
            <classpath refid="gluegen.classpath" />
        </gluegen>
    </target>

    <target name="java.generate.platforms" >
        <echo message="Generating platform-specifics: os: ${window.os.system}, cfgs: ${windowlib.os.cfg}, ${jawt.cfg}" />
        <dirset id="stub.includes.fileset.platform" dir="." includes="${stub.includes}/${window.os.system}/** ${stub.includes}/gluegen/** ${stub.includes}/khr/**" />
        <antcall target="java.generate.windowlib" inheritRefs="true" />
        <antcall target="java.generate.jawt" inheritRefs="true" />
    </target>

    <!--
       - Setup the generating ANT tasks and use it to generate the Java files 
       - from the C GL headers.  This involves setting the taskdef and creating
       - the classpath reference id then running the task on each header.
      -->
    <target name="java.generate" depends="init, common.gluegen.build, java.generate.check" unless="java.generate.skip">

        <!-- Add the GlueGen task to ANT -->
        <taskdef name="gluegen" classname="com.jogamp.gluegen.ant.GlueGenTask"
                 classpathref="gluegen.classpath" />
                 
        <!-- Use the GlueGen task to generate the Java files -->

        <antcall target="java.generate.cleantemp" inheritRefs="true" />

        <echo message="Generating platform-specifics: X11" />
        <antcall target="java.generate.platforms" inheritRefs="true">
            <param name="window.os.system"                       value="x11"/>
            <param name="windowlib.os.cfg"                       value="${config.nativewindow}/x11-lib.cfg" />
            <param name="jawt.cfg"                               value="${config.nativewindow}/jawt-x11.cfg" />
            <param name="jawt.platform.header"                   value="${stub.includes}/jni/x11/jawt_md.h" />
        </antcall>

        <echo message="Generating platform-specifics: Win32" />
        <antcall target="java.generate.platforms" inheritRefs="true">
            <param name="window.os.system"                       value="win32"/>
            <param name="windowlib.os.cfg"                       value="${config.nativewindow}/win32-lib.cfg" />
            <param name="jawt.cfg"                               value="${config.nativewindow}/jawt-win32.cfg" />
            <param name="jawt.platform.header"                   value="${stub.includes}/jni/win32/jawt_md.h" />
        </antcall>          

        <echo message="Generating platform-specifics: MacOSX" />
        <antcall target="java.generate.platforms" inheritRefs="true">
          <param name="window.os.system"                     value="macosx"/>
          <param name="jawt.cfg"                             value="${config.nativewindow}/jawt-macosx.cfg" />
          <param name="jawt.platform.header"                 value="${stub.includes}/jni/macosx/jawt_md.h" />
        </antcall>
    
        <!-- Inform the user that the generators have successfully created 
           - the necessary Java files -->
        <echo message="" />
        <echo message="GlueGen has successfully generated files." />
    
    </target>      

    <!-- ================================================================== -->
    <!-- 
       - Compile the original and generated source.  The composable pipelines
       - will be generated.
      -->
    <target name="java.compile.javase" depends="java.generate">
        <!-- Perform the second pass Java compile; everything. -->
        <javac destdir="${classes}"
               excludes="${java.excludes.all}"
               fork="yes"
               includeAntRuntime="false"
               memoryMaximumSize="${javac.memorymax}"
               encoding="UTF-8"
               source="${target.sourcelevel}" 
               target="${target.targetlevel}" 
               bootclasspath="${target.rt.jar}"
               debug="${javacdebug}" debuglevel="${javacdebuglevel}">
            <classpath refid="swt_gluegen.classpath"/>
            <src path="${src.java}" />
            <src path="${src.generated.java}" />
        </javac>
    </target>

    <target name="java.compile" depends="java.compile.javase" />

    <!-- ================================================================== -->
    <!-- 
       - Compile the native C code for JOGL (and optionally the Cg binding).
      -->

    <target name="c.configure.1" depends="gluegen.cpptasks.detect.os,gluegen.cpptasks.setup.compiler">
      <!-- compiler configuration -->

      <!-- Note that we can use the base setups in the gluegen-cpptasks for most of these -->
      <compiler id="compiler.cfg.freebsd.nativewindow" extends="compiler.cfg.freebsd">
        <!-- Need to force X11R6 headers on to include path after stub_includes -->
        <includepath path="/usr/local/include" />
      </compiler>

      <compiler id="compiler.cfg.linux.armv6.nativewindow.x11" extends="compiler.cfg.linux.armv6">
        <!-- Need to force /usr/include headers on to include path (after all others), due to crosscompiler usage -->
        <compilerarg value="-idirafter" />
        <compilerarg value="/usr/include" />
      </compiler>

      <compiler id="compiler.cfg.solaris.nativewindow.x11" extends="compiler.cfg.solaris">
        <compilerarg value="-I/usr/X11R6/include" />
      </compiler>

      <compiler id="compiler.cfg.solaris.nativewindow.x11.sparcv9" extends="compiler.cfg.solaris.sparcv9">
        <compilerarg value="-I/usr/X11R6/include" />
      </compiler>

      <compiler id="compiler.cfg.solaris.nativewindow.x11.amd64" extends="compiler.cfg.solaris.amd64">
        <compilerarg value="-I/usr/X11R6/include" />
      </compiler>

      <compiler id="compiler.cfg.macosx.nativewindow" extends="compiler.cfg.macosx">
      </compiler>

      <!-- linker configuration -->

      <linker id="linker.cfg.freebsd.nativewindow.x11" extends="linker.cfg.freebsd">
        <syslibset dir="/usr/local/lib" libs="X11"/>
        <syslibset dir="/usr/local/lib" libs="Xxf86vm" />
        <syslibset dir="/usr/local/lib" libs="Xrender"/>
      </linker>

      <linker id="linker.cfg.freebsd.amd64.nativewindow.x11" extends="linker.cfg.freebsd.amd64">
        <syslibset dir="/usr/local/lib" libs="X11" />
        <syslibset dir="/usr/local/lib" libs="Xxf86vm" />
        <syslibset dir="/usr/local/lib" libs="Xrender"/>
      </linker>

      <linker id="linker.cfg.linux.nativewindow.x11" extends="linker.cfg.linux">