Author: cjcollier
Date: 2006-01-09 20:20:57 -0500 (Mon, 09 Jan 2006)
New Revision: 55276

Removed:
   trunk/gtkglarea-sharp/examples/rotate-buttons/EulerRotation.cs
   trunk/gtkglarea-sharp/examples/rotate-buttons/GLObjectBase.cs
   trunk/gtkglarea-sharp/examples/rotate-buttons/GLWidget.cs
   trunk/gtkglarea-sharp/examples/rotate-buttons/IGLObject.cs
   trunk/gtkglarea-sharp/examples/rotate-buttons/Quaternion.cs
   trunk/gtkglarea-sharp/examples/rotate-buttons/RotationMatrix.cs
   trunk/gtkglarea-sharp/examples/rotate-buttons/Teapot.cs
   trunk/gtkglarea-sharp/examples/rotate-buttons/Vector.cs
Modified:
   trunk/gtkglarea-sharp/examples/rotate-buttons/rotateButtonTest.mdp
Log:
- moved all of the "utility" classes to ../util


Deleted: trunk/gtkglarea-sharp/examples/rotate-buttons/EulerRotation.cs
===================================================================
--- trunk/gtkglarea-sharp/examples/rotate-buttons/EulerRotation.cs      
2006-01-10 01:20:23 UTC (rev 55275)
+++ trunk/gtkglarea-sharp/examples/rotate-buttons/EulerRotation.cs      
2006-01-10 01:20:57 UTC (rev 55276)
@@ -1,197 +0,0 @@
-
-namespace GtkGL {
-    using System;
-    
-    
-    public class EulerRotation {
-        double x, y, z;
-
-        GtkGL.RotationMatrix rotMatrix;
-        GtkGL.Quaternion quat;
-        
-        public static EulerRotation operator -(EulerRotation rot1, 
EulerRotation rot2)
-        {
-               EulerRotation newRotation = new EulerRotation(0.0, 0.0, 0.0);
-
-               newRotation.X = Math.Abs( rot1.X - rot2.X );
-               newRotation.Y = Math.Abs( rot1.Y - rot2.Y );
-               newRotation.Z = Math.Abs( rot1.Z - rot2.Z );
-               
-               return newRotation;
-        }
-        
-        public static EulerRotation operator +(EulerRotation rot1, 
EulerRotation rot2)
-        {
-               if(rot1 == null)
-                       if(rot2 == null)
-                               return null;
-                       else
-                               return rot2;
-                       
-                       if(rot2 == null)
-                       return rot1;
-        
-               EulerRotation newRotation = new EulerRotation(0.0, 0.0, 0.0);
-
-               newRotation.X = ( (rot1.X + rot2.X) % 360 );
-               newRotation.Y = ( (rot1.Y + rot2.Y) % 360 );
-               newRotation.Z = ( (rot1.Z + rot2.Z) % 360 );
-
-               return newRotation;
-        }
-        
-        public static bool operator ==(EulerRotation rot1, EulerRotation rot2)
-        {
-               if(Object.Equals(rot1, null))
-                       if(Object.Equals(rot2, null))
-                               return true;
-                       else
-                               return false;
-                               
-               if(Object.Equals(rot2, null))
-                       return false;
-                               
-                       // We consider values within 0.001 of each other to be 
equal
-                       if(Math.Abs(rot1.X - rot2.X) <= 0.001 &&
-                          Math.Abs(rot1.Y - rot2.Y) <= 0.001 &&
-                          Math.Abs(rot1.Z - rot2.Z) <= 0.001 )
-                               return true;
-                               
-                       return false;
-        }
-
-        public static bool operator !=(EulerRotation rot1, EulerRotation rot2) 
{
-                       bool isEqual = (rot1 == rot2);
-                       
-                       if(isEqual)
-                               return false;
-                       else
-                               return true;
-
-        }
-        
-        // An event that gets triggered when X, Y or Z are updated
-        public event EventHandler Updated;    
-        
-               public double X {
-                       get { return x; }
-                       set { x = value; if(Updated != null) Updated(this, 
null); }
-               }
-        
-               public double Y {
-                       get { return y; }
-                       set { y = value; if(Updated != null) Updated(this, 
null); }
-               }
-
-               public double Z {
-                       get { return z; }
-                       set { z = value; if(Updated != null) Updated(this, 
null); }
-               }
-
-               void ClearCache(object o, EventArgs e)
-               {
-                       // This should happen when the Updated handler fires
-                       quat = null;
-                       rotMatrix = null;
-               }
-
-               public class GimbalLock : System.Exception {
-               GimbalLock() : base() {}
-           }
-
-        static EulerRotation identity = null;
-        
-               // This represents a null rotation
-        public static EulerRotation Identity
-        {
-               get {
-                       identity = new EulerRotation(0.0, 0.0, 0.0);
-                       return identity;
-               }
-        }
-        
-        void ConnectHandlers()
-        {
-               // When we are updated, clear the cached Quaternion and 
Rotation matrix
-               this.Updated += this.ClearCache;
-        }
-        
-        public EulerRotation()
-        {
-               x = 0.0;
-               y = 0.0;
-               z = 0.0;
-               
-               ConnectHandlers();
-        }
-        
-        public EulerRotation(double x, double y, double z)
-        {
-               this.x = x;
-               this.y = y;
-               this.z = z;
-               
-               ConnectHandlers();              
-        }
-        
-        public GtkGL.RotationMatrix ToRotMatrix()
-        {
-               if(rotMatrix != null)
-                       return this.rotMatrix;
-                       
-               double[] matrix = GtkGL.RotationMatrix.Identity.Matrix;
-               
-               // Convert to radians
-               double Xradians = x * 2 * Math.PI / 360.0;
-               double Yradians = y * 2 * Math.PI / 360.0;
-               double Zradians = z * 2 * Math.PI / 360.0;
-               
-                   double ch = Math.Cos(Xradians);
-                   double sh = Math.Sin(Xradians);
-                   
-                   double ca = Math.Cos(Yradians);
-                   double sa = Math.Sin(Yradians);
-                   
-                   double cb = Math.Cos(Zradians);
-                   double sb = Math.Sin(Zradians); 
-
-                   matrix[0*4 + 0] = ch * ca;
-                   matrix[0*4 + 1] = sh*sb - ch*sa*cb;
-                   matrix[0*4 + 2] = ch*sa*sb + sh*cb;
-                   matrix[1*4 + 0] = sa;
-                   matrix[1*4 + 1] = ca*cb;
-                   matrix[1*4 + 2] = -ca*sb;
-                   matrix[2*4 + 0] = -sh*ca;
-                   matrix[2*4 + 1] =  sh*sa*cb + ch*sb;
-                   matrix[2*4 + 2] = -sh*sa*sb + ch*cb;
-                   
-                   rotMatrix = new GtkGL.RotationMatrix(matrix); 
-                   
-                   return rotMatrix;
-        }
-        
-        public GtkGL.Quaternion ToQuaternion()
-        {
-               if(quat != null)
-                       return quat;
-       
-                       // Assuming the angles are in radians.
-                   double c1 = Math.Cos(x/2);
-                   double s1 = Math.Sin(x/2);
-                   double c2 = Math.Cos(y/2);
-                   double s2 = Math.Sin(y/2);
-                   double c3 = Math.Cos(z/2);
-                   double s3 = Math.Sin(z/2);
-                   double c1c2 = c1*c2;
-                   double s1s2 = s1*s2;
-               
-               quat = new GtkGL.Quaternion(c1c2*c3 - s1s2*s3,
-                                                                       c1c2*s3 
+ s1s2*c3,
-                                                                       
s1*c2*c3 + c1*s2*s3,
-                                                                       
c1*s2*c3 - s1*c2*s3);
-               
-               return quat;
-        }
-    }
-    
-}

Deleted: trunk/gtkglarea-sharp/examples/rotate-buttons/GLObjectBase.cs
===================================================================
--- trunk/gtkglarea-sharp/examples/rotate-buttons/GLObjectBase.cs       
2006-01-10 01:20:23 UTC (rev 55275)
+++ trunk/gtkglarea-sharp/examples/rotate-buttons/GLObjectBase.cs       
2006-01-10 01:20:57 UTC (rev 55276)
@@ -1,113 +0,0 @@
-namespace GtkGL {
-    using System;
-    using System.Collections;
-    using GtkGL;
-    using gl=Tao.OpenGl.Gl;
-    
-    abstract class GLObjectBase {
-
-        protected ArrayList GLAreaList = null;
-        
-        protected int shapeID;
-        
-        protected GtkGL.RotationMatrix rotMatrix = null;
-        protected GtkGL.EulerRotation eRot = null;
-        protected GtkGL.Quaternion quat = null;
-        
-        // Make setting of euler, quat and matrix an atomic action
-        private GtkGL.EulerRotation ERot {
-               get { return eRot; }
-               set {
-                       if(value == null)
-                               eRot = GtkGL.EulerRotation.Identity;
-                       else
-                               eRot = value;
-               
-                       eRot = value;
-                       quat = eRot.ToQuaternion();
-                       rotMatrix = eRot.ToRotMatrix();
-               }
-        }
-        
-        // Make setting of euler, quat and matrix an atomic action
-        private GtkGL.Quaternion Quat {
-               get { return quat; }
-               set {
-                       if(value == null)
-                               quat = GtkGL.Quaternion.Identity;
-                       else
-                               quat = value;
-
-                       eRot = quat.ToEulerRotation();
-                       rotMatrix = quat.ToRotMatrix();
-               }
-        }
-        
-        // Make setting of euler, quat and matrix an atomic action
-        private GtkGL.RotationMatrix RotMatrix {
-               get { return rotMatrix; }
-               set {
-                       if(value == null)
-                               rotMatrix = GtkGL.RotationMatrix.Identity;
-                               else
-                               rotMatrix = value;
-                       
-                       eRot = rotMatrix.ToEulerRotation();
-                       quat = rotMatrix.ToQuaternion();
-               }
-        }
-        
-        public void Rotate(GtkGL.Quaternion q)
-        {
-               Quat *= q;
-        }
-        
-        public void Rotate(GtkGL.EulerRotation er)
-        {
-                       ERot += er;     
-        }
-        
-        
-        public void Rotate(GtkGL.RotationMatrix rm)
-        {
-               RotMatrix += rm;
-        }
-        
-               public void ResetRotation()
-               {
-                       ERot = GtkGL.EulerRotation.Identity;
-               }
-               
-               public EulerRotation GetEulerRotation()
-               {
-                       if(eRot != null)
-                               return eRot;
-
-                       ERot = GtkGL.EulerRotation.Identity;
-
-                       return ERot; 
-               }
-               
-               public Quaternion GetQuaternion()
-               {
-                       if(quat != null)
-                               return quat;
-                       
-                       Quat = GtkGL.Quaternion.Identity;
-                       
-                       return Quat;
-               }
-               
-               public RotationMatrix GetRotationMatrix()
-               {
-                       if(rotMatrix != null)
-                               return rotMatrix;
-                               
-                       RotMatrix = GtkGL.RotationMatrix.Identity;
-                       
-                       return RotMatrix;
-               }
-        
-    }
-    
-}

Deleted: trunk/gtkglarea-sharp/examples/rotate-buttons/GLWidget.cs
===================================================================
--- trunk/gtkglarea-sharp/examples/rotate-buttons/GLWidget.cs   2006-01-10 
01:20:23 UTC (rev 55275)
+++ trunk/gtkglarea-sharp/examples/rotate-buttons/GLWidget.cs   2006-01-10 
01:20:57 UTC (rev 55276)
@@ -1,172 +0,0 @@
-namespace GtkGL {
-
-       using System;
-       using System.Collections;
-
-       using Tao.OpenGl;
-
-       using Gtk;
-       using Gdk;
-
-       using gl=Tao.OpenGl.Gl;
-       using glu=Tao.OpenGl.Glu;
-
-
-       public class GLWidget : GLArea {
-               
-               static System.Int32[] attrlist = {
-                   (int)GtkGL._GDK_GL_CONFIGS.Rgba,
-                   (int)GtkGL._GDK_GL_CONFIGS.RedSize,1,
-                   (int)GtkGL._GDK_GL_CONFIGS.GreenSize,1,
-                   (int)GtkGL._GDK_GL_CONFIGS.BlueSize,1,
-                   (int)GtkGL._GDK_GL_CONFIGS.DepthSize,1,
-                   (int)GtkGL._GDK_GL_CONFIGS.Doublebuffer,
-                   (int)GtkGL._GDK_GL_CONFIGS.None,
-               };
-               
-               protected ArrayList GLObjectList;
-               
-               public void AddGLObject(IGLObject ob)
-               {
-                       ob.Updated += OnExposed;
-
-                       GLObjectList.Add(ob);
-               }
-               
-               private void Init()
-               {
-                       // The GL widget is a minimum of 300x300 pixels 
-                       this.SetSizeRequest(300,300);
-                       
-                       // Initialize the GLObjectList
-                       GLObjectList = new ArrayList();
-                       
-                       // Connect some other signals           
-                       this.ExposeEvent += OnExposed;
-                       this.Realized += OnRealized;
-                       this.SizeAllocated += OnSizeAllocated;
-                       this.ConfigureEvent += OnConfigure;
-               }
-               
-               public GLWidget() : base(attrlist) {
-                       this.Init();
-               }
-               
-               public GLWidget(System.Int32[] attrList) : base(attrList)
-               {
-                       this.Init();                    
-               }
-               
-               // This handler gets fired when the glArea widget is re-sized
-               void OnSizeAllocated (object o, Gtk.SizeAllocatedArgs e)
-               {
-                       int height = e.Allocation.Height, width = 
e.Allocation.Width;
-                       
-                       // Avoid devide-by-zero error
-                       if(height == 0){
-                               height = 1;
-                       }
-                       
-                       // Set our Viewport size
-                       gl.glViewport(0, 0, width, height);
-                       
-                       gl.glMatrixMode(gl.GL_PROJECTION);                      
        // Select The Projection Matrix
-                       gl.glLoadIdentity();                                    
                // Reset The Projection Matrix
-
-                       // Calculate The Aspect Ratio Of The Window
-                       // 
http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/glu/perspective.html
-                       
glu.gluPerspective(45.0f,(float)width/(float)height,0.1f,100.0f);
-                       
-                       gl.glMatrixMode(gl.GL_MODELVIEW);                       
        // Select The Modelview Matrix
-                       gl.glLoadIdentity();                                    
                // Reset The Modelview Matrix
-               }
-               
-               // Drawing of pretty objects happens here
-               protected void OnExposed (object o, EventArgs e)
-               {
-                       if (this.MakeCurrent() == 0)
-                         return;
-                       
-                       // Clear the scene
-                       gl.glClear (gl.GL_COLOR_BUFFER_BIT | 
gl.GL_DEPTH_BUFFER_BIT);
-                       
-                       // Replace current matrix with the identity matrix
-                       gl.glLoadIdentity ();
-                       gl.glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
-
-                       // Translate a bit...
-                       gl.glLoadIdentity();
-                       gl.glTranslatef(0.0f,0.0f,-3.0f);                       
        // Move away from the drawing area 3.0
-                       
-                       // Draw the GLObjects associated with this GLArea
-                       System.Collections.IEnumerator enumerator = 
GLObjectList.GetEnumerator();
-       
-                       while(enumerator.MoveNext()){
-                               ( (GtkGL.IGLObject) enumerator.Current ).Draw();
-                       }
-                                       
-                       // bring back buffer to front, put front buffer in back
-                       this.SwapBuffers ();
-               }
-
-               // One-time configuration of opengl states happens here
-               void OnRealized (object o, EventArgs e)
-               {
-                       if (this.MakeCurrent() == 0)
-                         return;
-
-                       gl.glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
-                       gl.glClearDepth (1.0f);
-
-                       float[] materialSpecular = {1.0f, 1.0f, 1.0f, 0.15f};
-                       float[] materialShininess = {100.0f};
-                       float[] position = {-2.0f, 2.0f, 2.0f, 0.5f};
-
-                       Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_SPECULAR, 
materialSpecular);
-                       Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_SHININESS, 
materialShininess);
-                       Gl.glLightfv(Gl.GL_LIGHT0, Gl.GL_POSITION, position);
-
-                       Gl.glFrontFace (Gl.GL_CW);
-
-                       Gl.glEnable (Gl.GL_LIGHTING);
-                       Gl.glEnable (Gl.GL_LIGHT0);
-                       Gl.glEnable (Gl.GL_AUTO_NORMAL);
-                       Gl.glEnable (Gl.GL_NORMALIZE);
-                       Gl.glEnable (Gl.GL_DEPTH_TEST);
-                       Gl.glDepthFunc (Gl.GL_LEQUAL);
-                       gl.glShadeModel (gl.GL_SMOOTH);
-                       // Really Nice Perspective Calculations
-                       gl.glHint(gl.GL_PERSPECTIVE_CORRECTION_HINT, 
gl.GL_NICEST);
-                       
-                       // Iterate over associated IGLObject objects, calling 
Init() on each
-                       System.Collections.IEnumerator enumerator = 
GLObjectList.GetEnumerator();
-       
-                       while(enumerator.MoveNext()){
-                               ( (GtkGL.IGLObject) enumerator.Current ).Init();
-                       }
-               }
-
-               // This handler gets fired when the glArea widget is re-sized
-               // This method is called "ReSizeGLScene" in the NeHe lessons
-               void OnConfigure (object o, EventArgs e)
-               {       
-                       if( this.MakeCurrent() == 0)
-                               return;
-                               
-                       gl.glViewport (0, 0, this.Allocation.Width, 
this.Allocation.Height);                    
-               }
-               
-               // Bound in glwidget.glade              
-               private void OnQuit (object o, System.EventArgs e){
-                       Application.Quit();
-               }
-
-               // Bound in glwidget.glade
-               private void OnWindowDeleteEvent (object sender, 
DeleteEventArgs a) 
-               {
-                       Application.Quit ();
-                       a.RetVal = true;
-               }
-
-       }
-}
\ No newline at end of file

Deleted: trunk/gtkglarea-sharp/examples/rotate-buttons/IGLObject.cs
===================================================================
--- trunk/gtkglarea-sharp/examples/rotate-buttons/IGLObject.cs  2006-01-10 
01:20:23 UTC (rev 55275)
+++ trunk/gtkglarea-sharp/examples/rotate-buttons/IGLObject.cs  2006-01-10 
01:20:57 UTC (rev 55276)
@@ -1,38 +0,0 @@
-namespace GtkGL {
-    using System;
-    using System.Collections;
-    using GtkGL;
-    
-    public interface IGLObject {
-       // An event handler to notify folks of updates
-               event EventHandler Updated;    
-    
-       // A hook for initialization tasks
-        void Init();
-        
-        // Draw the object
-        bool Draw();
-
-               // Rotate the object by passing a quaternion
-               void Rotate(GtkGL.Quaternion quat);
-               
-               // Rotate the object by passing an Euler rotation
-               void Rotate(GtkGL.EulerRotation eRot);
-               
-               // Reset the rotation to the identity, and fire the 'Updated' 
handlers if 'doUpdate'
-               void ResetRotation(bool doUpdate);
-               
-               // Reset the rotation to the identity
-               void ResetRotation();
-                       
-               // Return the rotation as Euler angles
-               EulerRotation GetEulerRotation();
-               
-               // Return the rotation as a Quaternion
-               Quaternion GetQuaternion();
-               
-               // Return the RotationMatrix
-               RotationMatrix GetRotationMatrix();
-    }
-    
-}

Deleted: trunk/gtkglarea-sharp/examples/rotate-buttons/Quaternion.cs
===================================================================
--- trunk/gtkglarea-sharp/examples/rotate-buttons/Quaternion.cs 2006-01-10 
01:20:23 UTC (rev 55275)
+++ trunk/gtkglarea-sharp/examples/rotate-buttons/Quaternion.cs 2006-01-10 
01:20:57 UTC (rev 55276)
@@ -1,182 +0,0 @@
-namespace GtkGL {
-    using System;
-    
-    public class Quaternion {
-        double x, y, z, w;
-        
-        // our Updated event handler
-               public new event EventHandler Updated;
-        
-        public double X {
-               set { x = value; if(Updated != null) Updated(this, null); }
-               get { return x; }
-        }
-
-        public double Y {
-               set { y = value; if(Updated != null) Updated(this, null); }
-               get { return y; }
-        }
-
-        public double Z {
-               set { z = value; if(Updated != null) Updated(this, null); }
-               get { return z; }
-        }
-
-        public double W {
-               set { w = value; if(Updated != null) Updated(this, null); }
-               get { return w; }
-        }
-        
-        static Quaternion identity = null;
-        
-        public static Quaternion Identity {
-                       get {
-                               if (identity == null)
-                                       identity =
-                                               new Quaternion(0,0,0,1);
-                                               
-                               return identity;
-                       }
-        }
-               
-        const int RENORMCOUNT = 97;
-        static int count = 0;
-        
-        public static Quaternion operator *(Quaternion q1, Quaternion q2)
-        {
-               if(q1 == null) return null;
-                       
-               if(q2 == null) return null;
-
-               Vector v1 = new Vector(q1.x, q1.y, q1.z);
-               Vector v2 = new Vector(q2.x, q2.y, q2.z);
-               
-               double angle = ((q1.w * q2.w) - Vector.Dot(v1, v2));
-               
-               Vector cross = Vector.Cross(v1, v2);
-               
-               v1 *= q2.w;
-               v2 *= q1.w;
-               
-               Quaternion result = new Quaternion(angle,
-                                                                               
  (v1.x + v2.x + cross.x),
-                                                                               
  (v1.y + v2.y + cross.y),
-                                                                               
  (v1.z + v2.z + cross.z)
-                                                                               
          );
- 
-                       return result;
-        }
-        
-        
-        public Quaternion(float[] q)
-        {
-               this.w = (double) q[0];
-               this.x = (double) q[1];
-               this.y = (double) q[2];
-               this.z = (double) q[3];
-        }
-        
-        public Quaternion(double[] q)
-        {
-               this.w = q[0];
-               this.x = q[1];
-               this.y = q[2];
-               this.z = q[3];
-        }
-        
-        public Quaternion(double w, double x, double y, double z)
-        {
-               this.w = w;
-               this.x = x;
-               this.y = y;
-               this.z = z;
-        }
-        
-        double GetMagnitude()
-        {
-               return (w*w + x*x + y*y + z*z);
-        }
-        
-               /*
-                * Quaternions always obey:  a^2 + b^2 + c^2 + d^2 = 1.0
-                * If they don't add up to 1.0, dividing by their magnitued will
-                * renormalize them.
-                *
-                * Note: See the following for more information on quaternions:
-                *
-                * - Shoemake, K., Animating rotation with quaternion curves, 
Computer
-                *   Graphics 19, No 3 (Proc. SIGGRAPH'85), 245-254, 1985.
-                * - Pletinckx, D., Quaternion calculus as a basic tool in 
computer
-                *   graphics, The Visual Computer 5, 2-13, 1989.
-                */
-
-        public Quaternion Normalize()
-        {
-                   double mag = GetMagnitude();
-
-                   w /= mag;
-                   x /= mag;
-                   y /= mag;
-                   z /= mag;
-                   
-                   return this;
-               }
-
-               public GtkGL.EulerRotation ToEulerRotation()
-               {
-                       double heading;
-                       double attitude;
-                       double bank;
-                   
-                       double magnitude = GetMagnitude(); // 1.0 if 
normalised, otherwise is correction factor
-               double test = x*y + z*w;
-               
-                   if (test > 0.499 * magnitude) { // singularity at north pole
-                     heading = 2 * Math.Atan2(x,w);
-                     attitude = Math.PI/2;
-                     bank = 0;
-                         Console.WriteLine("Eep!  Singularity at north pole!");
-                     return new GtkGL.EulerRotation(heading, attitude, bank);
-                   }
-                   
-                   if (test < -0.499 * magnitude) { // singularity at south 
pole
-                     heading = -2 * Math.Atan2(x,w);
-                     attitude = - Math.PI/2;
-                     bank = 0;
-                     Console.WriteLine("Eep!  Singularity at south pole!");
-                     return new GtkGL.EulerRotation(heading, attitude, bank);
-                   }
-                   
-                   heading = Math.Atan2(2*y*w-2*x*z , 1 - 2*y*y - 2*z*z);
-                   attitude = Math.Asin(2*test/magnitude);
-                   bank = Math.Atan2(2*x*w-2*y*z , 1 - 2*x*x - 2*z*z);
-
-                       return new GtkGL.EulerRotation(heading, attitude, bank);
-               }
-               
-               public GtkGL.RotationMatrix ToRotMatrix()
-               {
-                       double[] rotMatrix = new double[16];
-                       
-               rotMatrix[4 * 0 + 0] = 1.0 - 2.0f * (y * y + z * z);
-                   rotMatrix[4 * 0 + 1] = 2.0 * (x * y - z * w);
-                   rotMatrix[4 * 0 + 2] = 2.0 * (z * x + y * w);
-
-                   rotMatrix[4 * 1 + 0] = 2.0 * (x * y + z * w);
-                   rotMatrix[4 * 1 + 1]= 1.0 - 2.0f * (z * z + x * x);
-                   rotMatrix[4 * 1 + 2] = 2.0 * (y * z - x * w);
-
-                   rotMatrix[4 * 2 + 0] = 2.0 * (z * x - y * w);
-               rotMatrix[4 * 2 + 1] = 2.0 * (y * z + x * w);
-                   rotMatrix[4 * 2 + 2] = 1.0 - 2.0f * (y * y + x * x);
-
-                       rotMatrix[3] = rotMatrix[7] = rotMatrix[11] =
-                       rotMatrix[12] = rotMatrix[13] = rotMatrix[14] = 0.0;
-                       
-                       rotMatrix[15] = 1.0;
-                   
-                   return new GtkGL.RotationMatrix(rotMatrix);
-               }
-    }
-    
-}

Deleted: trunk/gtkglarea-sharp/examples/rotate-buttons/RotationMatrix.cs
===================================================================
--- trunk/gtkglarea-sharp/examples/rotate-buttons/RotationMatrix.cs     
2006-01-10 01:20:23 UTC (rev 55275)
+++ trunk/gtkglarea-sharp/examples/rotate-buttons/RotationMatrix.cs     
2006-01-10 01:20:57 UTC (rev 55276)
@@ -1,123 +0,0 @@
-
-namespace GtkGL {
-    using System;
-    
-    public class RotationMatrix {
-       private double[] matrix;
-       
-       public double[] Matrix
-       {
-               get { if(matrix != null) return matrix; matrix = 
Identity.Matrix; return matrix; }
-               set { if(value.Length == 16) matrix = value; }
-       }
-       
-               
-        public static RotationMatrix operator +(RotationMatrix m1, 
RotationMatrix m2)
-        {
-               double[] newRot = new double[16];
-               
-               for(int i = 0; i < 16; i++){
-                       newRot[i] = m1.Matrix[i] + m2.Matrix[i];
-               }
-               
-               return new GtkGL.RotationMatrix(newRot);
-        }
-       
-        void Clear()
-        {
-               matrix = new double[16];
-               for(int i = 0; i < 16; i++){
-                       matrix[i] = 0.0;
-               }   
-        }
-        
-       static RotationMatrix identity;
-       // The identity matrix:
-       /*
-       
-       | 1.0 0.0 0.0 0.0 |
-       | 0.0 1.0 0.0 0.0 |
-       | 0.0 0.0 1.0 0.0 |
-       | 0.0 0.0 0.0 1.0 |
-       
-       */
-       
-       public static RotationMatrix Identity
-       {
-               get { 
-                       if(identity != null)
-                               return identity;
-                                               
-                       double[] identityMatrix = new double[16];
-                       
-                       for(int i = 0; i < 16; i++){
-                               if(i % 5 == 0)
-                                       identityMatrix[i] = 1;
-                               else
-                                       identityMatrix[i] = 0;
-                       }   
-                       
-                       identity = new RotationMatrix(identityMatrix);
-                       
-                       return identity;
-               }
-       }
-       
-       GtkGL.Quaternion quat;
-        
-        public RotationMatrix() {
-                       matrix = Identity.Matrix;
-        }
-        
-        public RotationMatrix(double[] rotMatrix)
-        {
-               Matrix = rotMatrix;
-        }
-        
-        public GtkGL.EulerRotation ToEulerRotation()
-        {
-               GtkGL.EulerRotation eRot;
-               
-               double angle_x, angle_y, angle_z;
-               double C, RADIANS = 57.2999999999999;
-               double trX, trY;                
-               
-            angle_y     =  Math.Asin( matrix[2]);        /* Calculate Y-axis 
angle */
-               C           =  Math.Cos( angle_y );
-               angle_y    *=  RADIANS;
-               
-                       // Throw an exception if we have encountered Gimbal Lock
-               if ( Math.Abs( C ) <= 0.005 )
-                       throw new GtkGL.EulerRotation.GimbalLock();
-               
-               trX      =  matrix[10] / C;           
-               trY      = -matrix[6]  / C;
-               angle_x  = Math.Atan2( trY, trX ) * RADIANS;
-               trX      =  matrix[0] / C;            /* Get Z-axis angle */
-               trY      = -matrix[1] / C;
-               angle_z  = Math.Atan2( trY, trX ) * RADIANS;
-
-               /* return only positive angles in [0,360] */
-               if (angle_x < 0) angle_x += 360.0;
-               if (angle_y < 0) angle_y += 360.0;
-               if (angle_z < 0) angle_z += 360.0;
-               
-               eRot = new EulerRotation();
-               
-               eRot.X = angle_x;
-               eRot.Y = angle_y;
-               eRot.Z = angle_z;
-               
-               return eRot;
-        }
-        
-        public GtkGL.Quaternion ToQuaternion()
-        {
-               double qx, qy, qz, qw;
-               qx = qy = qz = qw = 0.0;
-               // Create a quaternion
-                       return new GtkGL.Quaternion(qw, qx, qy, qz);
-        }
-    }
-    
-}

Deleted: trunk/gtkglarea-sharp/examples/rotate-buttons/Teapot.cs
===================================================================
--- trunk/gtkglarea-sharp/examples/rotate-buttons/Teapot.cs     2006-01-10 
01:20:23 UTC (rev 55275)
+++ trunk/gtkglarea-sharp/examples/rotate-buttons/Teapot.cs     2006-01-10 
01:20:57 UTC (rev 55276)
@@ -1,251 +0,0 @@
-// created on 11/25/2005 at 11:13 AM
-using Tao.OpenGl;
-using gl=Tao.OpenGl.Gl;
-using System;
-using System.Collections;
-
-namespace GtkGL {
-       class Teapot : GLObjectBase,IGLObject { 
-                 /* 
-                  * Teapot
-                  */
-
-                 /* Rim, body, lid, and bottom data must be reflected in x and
-                    y; handle and spout data across the y axis only.  */
-
-                 static int[,] patchdata =
-                   {
-                     /* rim */
-                     {102, 103, 104, 105, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 
14, 15},
-                     /* body */
-                     {12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 
26, 27},
-                     {24, 25, 26, 27, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 
39, 40},
-                     /* lid */
-                     {96, 96, 96, 96, 97, 98, 99, 100, 101, 101, 101, 101, 0, 
1, 2, 3,},
-                     {0, 1, 2, 3, 106, 107, 108, 109, 110, 111, 112, 113, 114, 
115, 116, 117},
-                     /* bottom */
-                     {118, 118, 118, 118, 124, 122, 119, 121, 123, 126, 125, 
120, 40, 39, 38, 37},
-                     /* handle */
-                     {41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 
55, 56},
-                     {53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 28, 65, 
66, 67},
-                     /* spout */
-                     {68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 
82, 83},
-                     {80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 
94, 95}
-                   };
-                 /* *INDENT-OFF* */
-
-                 static double[,] cpdata =
-                   {
-                     {0.2, 0, 2.7}, {0.2, -0.112, 2.7}, {0.112, -0.2, 2.7},
-                     {0,-0.2, 2.7}, {1.3375, 0, 2.53125}, {1.3375, -0.749, 
2.53125},
-                     {0.749, -1.3375, 2.53125}, {0, -1.3375, 2.53125}, 
{1.4375,0, 2.53125},
-                     {1.4375, -0.805, 2.53125}, {0.805, -1.4375,2.53125}, {0, 
-1.4375, 2.53125},
-                     {1.5, 0, 2.4}, {1.5, -0.84, 2.4}, {0.84, -1.5, 2.4},
-                     {0, -1.5, 2.4}, {1.75, 0, 1.875},
-                     {1.75, -0.98, 1.875}, {0.98, -1.75, 1.875}, {0, -1.75, 
1.875},
-                     {2, 0, 1.35}, {2, -1.12, 1.35}, {1.12, -2, 1.35},
-                     {0, -2, 1.35}, {2, 0, 0.9}, {2, -1.12, 0.9},
-                     {1.12, -2, 0.9}, {0, -2, 0.9}, {-2, 0, 0.9},
-                     {2, 0, 0.45}, {2, -1.12, 0.45}, {1.12, -2, 0.45},
-                     {0, -2, 0.45}, {1.5, 0, 0.225},
-                     {1.5, -0.84, 0.225}, {0.84, -1.5, 0.225}, {0, -1.5, 
0.225},
-                     {1.5, 0, 0.15}, {1.5, -0.84, 0.15}, {0.84, -1.5, 0.15},
-                     {0, -1.5, 0.15}, {-1.6, 0, 2.025}, {-1.6, -0.3, 2.025},
-                     {-1.5, -0.3, 2.25}, {-1.5, 0, 2.25}, {-2.3, 0, 2.025},
-                     {-2.3, -0.3, 2.025}, {-2.5, -0.3, 2.25}, {-2.5, 0, 2.25},
-                     {-2.7, 0, 2.025}, {-2.7, -0.3, 2.025}, {-3, -0.3, 2.25},
-                     {-3, 0, 2.25}, {-2.7, 0, 1.8}, {-2.7, -0.3, 1.8},
-                     {-3, -0.3, 1.8}, {-3, 0, 1.8}, {-2.7, 0, 1.575},
-                     {-2.7, -0.3, 1.575}, {-3, -0.3, 1.35}, {-3, 0, 1.35},
-                     {-2.5, 0, 1.125}, {-2.5, -0.3, 1.125}, {-2.65, -0.3, 
0.9375},
-                     {-2.65, 0, 0.9375}, {-2, -0.3, 0.9}, {-1.9, -0.3, 0.6},
-                     {-1.9, 0, 0.6}, {1.7, 0, 1.425}, {1.7, -0.66, 1.425},
-                     {1.7, -0.66, 0.6}, {1.7, 0, 0.6}, {2.6, 0, 1.425},
-                     {2.6, -0.66, 1.425}, {3.1, -0.66, 0.825}, {3.1, 0, 0.825},
-                     {2.3, 0, 2.1}, {2.3, -0.25, 2.1},
-                     {2.4, -0.25, 2.025}, {2.4, 0, 2.025}, {2.7, 0, 2.4},
-                     {2.7, -0.25, 2.4}, {3.3, -0.25, 2.4}, {3.3, 0, 2.4},
-                     {2.8, 0, 2.475}, {2.8, -0.25, 2.475}, {3.525, -0.25, 
2.49375},
-                     {3.525, 0, 2.49375}, {2.9, 0, 2.475}, {2.9, -0.15, 2.475},
-                     {3.45, -0.15, 2.5125}, {3.45, 0, 2.5125}, {2.8, 0, 2.4},
-                     {2.8, -0.15, 2.4}, {3.2, -0.15, 2.4}, {3.2, 0, 2.4},
-                     {0, 0, 3.15}, {0.8, 0, 3.15}, {0.8, -0.45, 3.15},
-                     {0.45, -0.8, 3.15}, {0, -0.8, 3.15}, {0, 0, 2.85},
-                     {1.4, 0, 2.4}, {1.4, -0.784, 2.4}, {0.784, -1.4, 2.4},
-                     {0, -1.4, 2.4}, {0.4, 0, 2.55}, {0.4, -0.224, 2.55},
-                     {0.224, -0.4, 2.55}, {0, -0.4, 2.55}, {1.3, 0, 2.55}, 
{1.3, -0.728, 2.55}, {0.728, -1.3, 2.55}, {0, -1.3, 2.55}, {1.3, 0, 2.4}, {1.3, 
-0.728, 2.4},
-                     {0.728, -1.3, 2.4}, {0, -1.3, 2.4}, {0, 0, 0}, {1.425, 
-0.798, 0}, {1.5, 0, 0.075}, {1.425, 0, 0}, {0.798, -1.425, 0}, {0, -1.5, 
0.075}, {0, -1.425, 0}, {1.5, -0.84, 0.075},
-                     {0.84, -1.5, 0.075}
-                   };
-
-                 static float[,,] tex =
-                   {
-                     { {0, 0},
-                       {1, 0}},
-                     { {0, 1},
-                       {1, 1}}
-                   };
-
-                 /* *INDENT-ON* */
-                 
-                       static float[][]
-                               cachedP = new float[10][],
-                               cachedQ = new float[10][],
-                               cachedR = new float[10][],
-                               cachedS = new float[10][];
-
-                       private void DoTeaPot(int grid, double scale, int type)
-                       {
-                       
-                           gl.glPushAttrib(gl.GL_ENABLE_BIT | gl.GL_EVAL_BIT);
-                           gl.glEnable(gl.GL_AUTO_NORMAL);
-                           gl.glEnable(gl.GL_NORMALIZE);
-                           gl.glEnable(gl.GL_MAP2_VERTEX_3);
-                           gl.glEnable(gl.GL_MAP2_TEXTURE_COORD_2);
-                           gl.glPushMatrix();
-                           gl.glRotatef(270.0f, 1.0f, 0.0f, 0.0f);
-                           gl.glScalef((float)(0.5 * scale), (float)(0.5 * 
scale), (float)(0.5 * scale));
-                       gl.glTranslatef(0.0f, 0.0f, -1.5f);
-                   
-                       float[,,]
-                               p = new float[4,4,3],
-                               q = new float[4,4,3],
-                               r = new float[4,4,3],
-                                       s = new float[4,4,3];
-                       int i, j, k, l;
-                           
-                               for (i = 0; i < 10; i++) {
-                               
-                                       if(cachedP[i] == null){
-                                       for (j = 0; j < 4; j++) {
-                                                       for (k = 0; k < 4; k++) 
{
-                                                               for (l = 0; l < 
3; l++) {
-                                                               p[j,k,l] = 
(float)cpdata[patchdata[i,j * 4 + k],l];
-                                                               q[j,k,l] = 
(float)cpdata[patchdata[i,j * 4 + (3 - k)],l];
-                                                               if (l == 1)
-                                                                       
q[j,k,l] *= -1.0f;
-                                                               if (i < 6) {
-                                                                       
r[j,k,l] = (float)cpdata[patchdata[i,j * 4 + (3 - k)],l];
-                                                                       if (l 
== 0)
-                                                                               
        r[j,k,l] *= -1.0f;
-                                                                       
s[j,k,l] = (float)cpdata[patchdata[i,j * 4 + k],l];
-                                                                       if (l 
== 0)
-                                                                               
        s[j,k,l] *= -1.0f;
-                                                                       if (l 
== 1)
-                                                                               
        s[j,k,l] *= -1.0f;
-                                                               }
-                                                               }
-                                                       }
-                                       }
-                                 
-                                       cachedP[i] = new float[4*4*3];
-                                       cachedQ[i] = new float[4*4*3];
-                                       cachedR[i] = new float[4*4*3];
-                                       cachedS[i] = new float[4*4*3];
-
-                                       int pos;
-                                       pos = 0;
-                                               for(int I = 0; I < 4; I++)
-                                               for(int J = 0; J < 4; J++)
-                                                       for(int K = 0; K < 3; 
K++,pos++){
-                                                                       
cachedP[i][pos] = p[I,J,K];
-                                                               cachedQ[i][pos] 
= q[I,J,K];
-                                                               cachedR[i][pos] 
= r[I,J,K];
-                                                               cachedS[i][pos] 
= s[I,J,K];
-                                                       }                       
        
-                               }
-                                               
-                               gl.glMap2f(gl.GL_MAP2_TEXTURE_COORD_2, 0, 1, 2, 
2, 0, 1, 4, 2, ref tex[0,0,0]);
-                               gl.glMap2f(gl.GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 
1, 12, 4, cachedP[i]);
-                               gl.glMapGrid2f(grid, 0.0f, 1.0f, grid, 0.0f, 
1.0f);
-                               gl.glEvalMesh2(type, 0, grid, 0, grid);
-                               gl.glMap2f(gl.GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 
1, 12, 4, cachedQ[i]);
-                               gl.glEvalMesh2(type, 0, grid, 0, grid);
-                               if (i < 6) {
-                                               gl.glMap2f(gl.GL_MAP2_VERTEX_3, 
0, 1, 3, 4, 0, 1, 12, 4, cachedR[i]);
-                                               gl.glEvalMesh2(type, 0, grid, 
0, grid);
-                                               gl.glMap2f(gl.GL_MAP2_VERTEX_3, 
0, 1, 3, 4, 0, 1, 12, 4, cachedS[i]);
-                                               gl.glEvalMesh2(type, 0, grid, 
0, grid);
-                                       }
-                               }
-                       gl.glPopMatrix();
-                       gl.glPopAttrib();
-                       }
-                       
-                       public void DrawTeapot(bool solid, double scale)
-                       {
-                 
-                               if (solid)
-                               DoTeaPot (7, scale, gl.GL_FILL);
-                               else
-                                   DoTeaPot (10, scale, gl.GL_LINE);
-                       }
-                       
-                       // our Updated event handler
-                       public new event EventHandler Updated;
-                       
-                       // Cache the drawing of the object
-                       public new void Init()
-                       {
-                               // Do some genlist magic
-                               shapeID = gl.glGenLists (1);
-
-                               gl.glNewList (shapeID, gl.GL_COMPILE);
-                                       DrawTeapot(true, 0.5f);
-                               gl.glEndList ();
-                       }
-                       
-                       public new void Rotate(GtkGL.Quaternion quat)
-                       {
-                               base.Rotate(quat);
-                               
-                               // Tell our handlers that we have been updated
-                               if (Updated != null)
-                                       Updated (this, null);
-                       }
-                       
-                       public new void Rotate(GtkGL.EulerRotation eRot)
-                       {
-                               base.Rotate(eRot);
-                               
-                               // Tell our handlers that we have been updated
-                               if (Updated != null)
-                                       Updated (this, null);
-                       }
-                       
-                       public new void ResetRotation(bool doUpdate)
-                       {
-                               base.ResetRotation();
-
-                               // Tell our handlers that we have been updated
-                               if (doUpdate && Updated != null)
-                                       Updated (this, null);
-                       }
-                       
-                       public new void ResetRotation()
-                       {
-                               base.ResetRotation();
-
-                               // Tell our handlers that we have been updated
-                               if (Updated != null)
-                                       Updated (this, null);
-                       }
-                       
-                       public bool Draw()
-                       {
-                               if(rotMatrix != null){
-                                       // Apply the rotation matrix
-                                       gl.glMultMatrixd(rotMatrix.Matrix);
-                               }
-                               
-                               // Draw the image from the display list
-                               gl.glCallList (shapeID);
-                                
-                               return true;
-                       }
-
-                       public Teapot()
-                       {
-                       }                 
-               }
-}

Deleted: trunk/gtkglarea-sharp/examples/rotate-buttons/Vector.cs
===================================================================
--- trunk/gtkglarea-sharp/examples/rotate-buttons/Vector.cs     2006-01-10 
01:20:23 UTC (rev 55275)
+++ trunk/gtkglarea-sharp/examples/rotate-buttons/Vector.cs     2006-01-10 
01:20:57 UTC (rev 55276)
@@ -1,59 +0,0 @@
-
-namespace GtkGL {
-    using System;
-    
-    public class Vector {
-    
-       public double x, y, z;
-        
-        public Vector(double x, double y, double z) {
-               this.x = x;
-               this.y = y;
-               this.z = z;
-        }
-        
-        public Vector(double[] v) {
-               if(v == null || v.Length < 3)
-                       this.x = this.y = this.z = 0.0;
-               else{
-                       this.x = v[0];
-                       this.y = v[1];
-                       this.z = v[2];
-               }
-        }
-        
-        
-        public static Vector Cross(Vector v1, Vector v2)
-        {
-               return new Vector( (v1.y * v2.z) - (v1.z * v2.y),
-                                                  (v1.z * v2.x) - (v1.x * 
v2.z),
-                                                  (v1.x * v2.y) - (v1.y * v2.x)
-                                                );                             
                                         
-        }
-        
-        public static Vector operator +(Vector v1, Vector v2)
-        {
-               return new Vector(v1.x + v2.x,
-                                                 v1.y + v2.y,
-                                                 v1.z + v2.z
-                                                );
-        }
-        
-        public static Vector operator *(Vector v1, double factor)
-        {
-               Vector result = new Vector( v1.x * factor,
-                                                                       v1.y * 
factor,
-                                                                       v1.z * 
factor
-                                                                  );
-               return result;
-        }
-        
-        public static double Dot(Vector v1, Vector v2)
-        {
-               return (v1.x * v2.x) + (v1.y * v2.y) + (v1.z * v2.z);
-        }
-        
-       
-    }
-    
-}

Modified: trunk/gtkglarea-sharp/examples/rotate-buttons/rotateButtonTest.mdp
===================================================================
--- trunk/gtkglarea-sharp/examples/rotate-buttons/rotateButtonTest.mdp  
2006-01-10 01:20:23 UTC (rev 55275)
+++ trunk/gtkglarea-sharp/examples/rotate-buttons/rotateButtonTest.mdp  
2006-01-10 01:20:57 UTC (rev 55276)
@@ -18,23 +18,16 @@
   </DeploymentInformation>
   <Contents>
     <File name="../resources/glwidget.glade" subtype="Code" 
buildaction="EmbedAsResource" />
-    <File name="./GLObjectBase.cs" subtype="Code" buildaction="Compile" />
     <File name="./ObjectRotationButton.cs" subtype="Code" 
buildaction="Compile" />
     <File name="./rotateButtonTest.cs" subtype="Code" buildaction="Compile" />
-    <File name="./Rotation.cs" subtype="Code" buildaction="Compile" />
-    <File name="./GLWidget.cs" subtype="Code" buildaction="Compile" />
-    <File name="./Teapot.cs" subtype="Code" buildaction="Compile" />
-    <File name="./IGLObject.cs" subtype="Code" buildaction="Compile" />
     <File name="./GLObjectRotationController.cs" subtype="Code" 
buildaction="Compile" />
     <File name="./rotation-controller.glade" subtype="Code" 
buildaction="EmbedAsResource" />
-    <File name="./Quaternion.cs" subtype="Code" buildaction="Compile" />
-    <File name="./RotationMatrix.cs" subtype="Code" buildaction="Compile" />
-    <File name="./EulerRotation.cs" subtype="Code" buildaction="Compile" />
   </Contents>
   <References>
     <ProjectReference type="Gac" localcopy="True" refto="Tao.OpenGl, 
Version=0.0.0.0, Culture=neutral, PublicKeyToken=1ca010269a4501ef" />
     <ProjectReference type="Gac" localcopy="True" refto="Tao.OpenGl.Glu, 
Version=1.5.0.3, Culture=neutral, PublicKeyToken=3661ea75021374b5" />
     <ProjectReference type="Gac" localcopy="True" refto="gtk-sharp, 
Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
     <ProjectReference type="Gac" localcopy="True" refto="gtkglarea-sharp, 
Version=0.0.2.0, Culture=neutral, PublicKeyToken=7df758c0fb49fe62" />
+    <ProjectReference type="Project" localcopy="True" refto="GtkGLAreaUtil" />
   </References>
 </Project>
\ No newline at end of file

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to