gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] gzz Documentation/misc/bricks.txt gfx/demo/buoy...


From: Tuomas J. Lukka
Subject: [Gzz-commits] gzz Documentation/misc/bricks.txt gfx/demo/buoy...
Date: Wed, 05 Feb 2003 03:14:48 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Tuomas J. Lukka <address@hidden>        03/02/05 03:14:46

Modified files:
        Documentation/misc: bricks.txt 
        gfx/demo       : buoyoing.py 
        gfx/libcoords  : Coords.cxx 
        gfx/util       : demo.py 
        gzz/gfx/gl     : GLVobCoorder.java 
        gzz/view/buoy  : buoymanager.py 

Log message:
        Add two new coordsys types to help with nadirs.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/Documentation/misc/bricks.txt.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/buoyoing.py.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libcoords/Coords.cxx.diff?tr1=1.64&tr2=1.65&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/util/demo.py.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/gfx/gl/GLVobCoorder.java.diff?tr1=1.63&tr2=1.64&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/view/buoy/buoymanager.py.diff?tr1=1.2&tr2=1.3&r1=text&r2=text

Patches:
Index: gzz/Documentation/misc/bricks.txt
diff -u gzz/Documentation/misc/bricks.txt:1.1 
gzz/Documentation/misc/bricks.txt:1.2
--- gzz/Documentation/misc/bricks.txt:1.1       Mon Feb  3 02:05:07 2003
+++ gzz/Documentation/misc/bricks.txt   Wed Feb  5 03:14:45 2003
@@ -39,6 +39,12 @@
     2x3
     2x2
 
+Round bricks:
+    2x2 with axlehole - good for thick, round levers !
+
+Round tiles:
+    2x2 - top for previous
+
 Standard plates:
     large and small
 
Index: gzz/gfx/demo/buoyoing.py
diff -u gzz/gfx/demo/buoyoing.py:1.2 gzz/gfx/demo/buoyoing.py:1.3
--- gzz/gfx/demo/buoyoing.py:1.2        Tue Feb  4 16:24:10 2003
+++ gzz/gfx/demo/buoyoing.py    Wed Feb  5 03:14:45 2003
@@ -24,7 +24,8 @@
 zzNodes.viewcontext.setDims(jarray.array(
     [space.getDim(i) for i in [Ids.d_1, Ids.d_2, Ids.d_3]], gzz.Dim))
 
-span = sb.getCurrent().subSpan(0,1).subArea(10, 10, 200, 200)
+wholepage = sb.getCurrent().subSpan(0,1)
+span = wholepage.subArea(10, 10, 400, 400)
 
 # Put a piece of the pagespan into it
 cell = space.getHomeCell()
@@ -45,3 +46,5 @@
     def __init__(self):
        buoymanager.RealBuoyManager.__init__(self,
                adaptor, None, cell)
+
+currentScene = Scene()
Index: gzz/gfx/libcoords/Coords.cxx
diff -u gzz/gfx/libcoords/Coords.cxx:1.64 gzz/gfx/libcoords/Coords.cxx:1.65
--- gzz/gfx/libcoords/Coords.cxx:1.64   Thu Jan 30 13:30:14 2003
+++ gzz/gfx/libcoords/Coords.cxx        Wed Feb  5 03:14:45 2003
@@ -597,6 +597,101 @@
        }
     };
 
+
+    /** 2D Rotation clockwise around a given point.
+     * Parameter layout: angle (degrees), x, y
+     */
+    class RotateXYCenteredCoords {
+       float a, s, c;
+       float ox, oy;
+    public:
+       enum { NParams = 3,
+               TransId = 16 };
+       template<class Ptr> void setParams(Ptr p, CoordSys *super) {
+           a = p[0];
+           ox = p[1];
+           oy = p[2];
+           angleWasSet();
+       }
+       void angleWasSet() {
+           s = sin(a * M_PI / 180);
+           c = cos(a * M_PI / 180);
+       }
+       /** Perform the internal transformation of this 
+        * coordsys.
+        */
+       void tr(const ZPt &from, ZPt &to) const {
+           float x = from.x - ox;
+           float y = from.y - oy;
+           to.x = c * x + -s * y + ox; 
+           to.y = s * x + c * y + oy; 
+           to.z = from.z;
+       }
+       float tr_radius(const ZPt &from, float radius) const {
+           return radius;
+       }
+       bool canPerformGL() { return true; }
+        bool performGL() {
+           glTranslatef(ox, oy, 0);
+           glRotatef(a, 0, 0, 1);
+           glTranslatef(-ox, -oy, 0);
+           return true;
+       }
+       typedef RotateXYCenteredCoords InverseType;
+       RotateXYCenteredCoords inverseTransform() {
+           RotateXYCenteredCoords inv;
+           inv.a = -a;
+           inv.ox = ox;
+           inv.oy = oy;
+           inv.angleWasSet();
+           return inv;
+       }
+       float nonlinearity(const ZPt &p, float radius) { 
+           return 0;
+       }
+    };
+
+    /** Rotate the downwards vector at the origin
+     * towards the given point.
+     * XXX Document somewhere why!
+     * XXX Think: to make more flexible, need separate parent,
+     * nadirorigin, nadirpoint, rotatearoundpoint.
+     * I.e. the point where the downwards vector needs to face
+     * the nadir might not be the center of rotation.
+     * This gets quite hairy then.
+     */
+    class NadirUniSqCoords {
+    public:
+       typedef RotateXYCenteredCoords BaseTransform;
+       enum { NParams = 0,
+               NDetermining = 1 };
+       void derivedParams(CoordSys *super, CoordSys **nadirCSp,
+                           float *params, float *newparams) {
+           CoordSys *nadirCS = *nadirCSp;
+
+           Pt usq = super->getSqSize();
+           float ox = usq.x / 2;
+           float oy = usq.y / 2;
+
+           ZPt origin = super->transform(ZPt(ox,oy,0));
+
+           ZPt nadir = nadirCS->transform(ZPt(0,0,0));
+
+
+           float x = origin.x - nadir.x;
+           float y = origin.y - nadir.y;
+           float angle = atan2(x, -y);
+
+           newparams[0] = angle * 180 / M_PI;
+           newparams[1] = ox;
+           newparams[2] = oy;
+       }
+       bool shouldBeDrawn() {
+           return true;
+       }
+    };
+
+
     /** Translation.
      * Parameter layout: x, y, z
      */
@@ -1282,6 +1377,8 @@
        new TransFactory<OrthoCoords>(), // 13
        new WHTransFactory<OrthoBoxCoords>(), // 14
        new NoTransFactory<InverseCoordSys>(), // 15
+       new TransFactory<RotateXYCenteredCoords>(), // 16
+       new DerTransFactory<NadirUniSqCoords>(), // 17
        0
     };
 
Index: gzz/gfx/util/demo.py
diff -u gzz/gfx/util/demo.py:1.12 gzz/gfx/util/demo.py:1.13
--- gzz/gfx/util/demo.py:1.12   Sat Jan 25 08:45:03 2003
+++ gzz/gfx/util/demo.py        Wed Feb  5 03:14:45 2003
@@ -80,6 +80,7 @@
     print "RELOAD"
     global globalScenes
     global globalHelp, globalSceneMap, globalSceneHelp
+    global currentScene
 
     if 1:
        reloadmod.reloadModules()
@@ -88,6 +89,8 @@
        demowindow.w = w
        if "." not in scenefile or "/" in scenefile:
            exec open(scenefile) in globals(), globals()
+           if currentScene == None:
+               currentScene = Scene()
        else:
            print "No file found, trying module."
            exec """
@@ -118,7 +121,6 @@
 
            print globalScenes, globalSceneHelp, globalSceneMap
 
-           global currentScene
            currentScene = globalSceneMap["F1"]
            GlobalScene.__doc__ = globalHelp
 
Index: gzz/gzz/gfx/gl/GLVobCoorder.java
diff -u gzz/gzz/gfx/gl/GLVobCoorder.java:1.63 
gzz/gzz/gfx/gl/GLVobCoorder.java:1.64
--- gzz/gzz/gfx/gl/GLVobCoorder.java:1.63       Tue Feb  4 16:16:31 2003
+++ gzz/gzz/gfx/gl/GLVobCoorder.java    Wed Feb  5 03:14:45 2003
@@ -30,8 +30,8 @@
 import gzz.client.*;
 import gzz.client.gl.*;
 
-public class GLVobCoorder extends AffineVobCoorder {
-public static final String rcsid = "$Id: GLVobCoorder.java,v 1.63 2003/02/04 
21:16:31 tjl Exp $";
+public final class GLVobCoorder extends AffineVobCoorder {
+public static final String rcsid = "$Id: GLVobCoorder.java,v 1.64 2003/02/05 
08:14:45 tjl Exp $";
     public static boolean dbg = false;
     private static void pa(String s) { System.err.println(s); }
 
@@ -177,6 +177,30 @@
     }
 
 
+    public int rotateCentered(int into, float degrees, float x, float y) {
+       int paramInd = nfloats;
+       nfloats += 3;
+
+       inds[ninds + 0] = 16; // rotationCentered = 16
+       inds[ninds + 1] = into;
+       inds[ninds + 2] = paramInd;
+       int was = ninds;
+       ninds += 3;
+
+       setRotateCenteredParams(was, degrees, x, y);
+
+       return was;
+    }
+
+    public void setRotateCenteredParams(int cs, float degrees, 
+                                           float x, float y) {
+       int ind = inds[cs + 2];
+       floats[ind + 0] = degrees;
+       floats[ind + 1] = x;
+       floats[ind + 2] = y;
+    }
+
+
     public int rotateXYZ(int into, float degrees, float x, float y, float z) {
        floats[nfloats + 0] = x;
        floats[nfloats + 1] = y;
@@ -263,6 +287,23 @@
 
        return was;
     }
+
+    /** Make a nadir rotation around unitsq center towards nadir.
+     */
+    public int nadirUnitSq(int into, int nadir) {
+       int paramInd = nfloats;
+       nfloats += 0;
+
+       inds[ninds + 0] = 17; // nadirUnitSq
+       inds[ninds + 1] = into;
+       inds[ninds + 2] = nadir;
+       inds[ninds + 3] = paramInd;
+       int was = ninds;
+       ninds += 4;
+
+       return was;
+    }
+
 
 
 
Index: gzz/gzz/view/buoy/buoymanager.py
diff -u gzz/gzz/view/buoy/buoymanager.py:1.2 
gzz/gzz/view/buoy/buoymanager.py:1.3
--- gzz/gzz/view/buoy/buoymanager.py:1.2        Tue Feb  4 16:24:10 2003
+++ gzz/gzz/view/buoy/buoymanager.py    Wed Feb  5 03:14:45 2003
@@ -9,6 +9,8 @@
 
 import gzz
 
+print "LOADING BUOYMANAGER"
+
 class RealBuoyManager(BuoyLinkListener):
     """Manage buoys through the new APIs
 
@@ -24,26 +26,41 @@
        """
        self.mainNode = initBuoyviewnodetype.createMainNode(
                            initLinkId, initAnchor, self)
+    def nadir(self, cs):
+       n =  self.vs.coords.nadirUnitSq(cs, self.nadirCS)
+       self.vs.matcher.add(cs, n, "NADIR")
+       return n
     def scene(self, vs):
+       print "SCENE"
        self.vs = vs
+
+       self.nadirCS = vs.translateCS(0, "NADIRORIGIN", 400, 1500)
+
        vs.put(background((.5,.8,.5)))
 
        main = vs.orthoBoxCS(0, "MAINVP", 0, 300, 200, .3, .3, 200, 200)
-       self.mainNode.renderMain(vs, main)
+
+       self.mainNode.renderMain(vs, self.nadir(main))
+
 
     def link(self, direction, anchorCS, otherNode, linkId, otherAnchor):
+       x = 400
+       r = 200
        if dir > 0:
            buoy = self.vs.coords.buoyOnCircle(0, anchorCS,
-                               400, 300, 150, 
-                               250, 300, 
-                               30)
+                               x, 300, r, 
+                               x-r, 300, 
+                               0.1)
        else:
            buoy = self.vs.coords.buoyOnCircle(0, anchorCS,
-                               400, 300, 150, 
-                               550, 300,
-                               30)
+                               x, 300, r, 
+                               x+r, 300,
+                               0.1)
        self.vs.matcher.add(buoy, linkId)
-       otherNode.renderBuoy(self.vs, buoy, linkId, otherAnchor)
+       buoy = self.nadir(buoy)
+       into = self.vs.orthoBoxCS(buoy, "V", 0, 0, 0, .5, .5, 1, 1)
+       otherNode.renderBuoy(self.vs, into, linkId, otherAnchor)
 
     def key(self, key):
+       gzz.client.AbstractUpdateManager.chg()
        pass




reply via email to

[Prev in Thread] Current Thread [Next in Thread]