fenfire-commits
[Top][All Lists]
Advanced

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

[ff-cvs] libvob include/vob/jni/Types.hxx include/vob/li...


From: Matti Katila
Subject: [ff-cvs] libvob include/vob/jni/Types.hxx include/vob/li...
Date: Fri, 22 Aug 2003 08:33:40 -0400

CVSROOT:        /cvsroot/libvob
Module name:    libvob
Branch:         
Changes by:     Matti Katila <address@hidden>   03/08/22 08:33:40

Modified files:
        include/vob/jni: Types.hxx 
        include/vob/lines: Lines.hxx 
        include/vob/vobs: Lines.hxx 
        org/nongnu/libvob/vobs: ContinuousLineVob.java 
        src/lines      : Lines.cxx 
        vob/demo       : lines.py 
Added files:
        include/vob/jni: Floats.hxx 

Log message:
        more lines

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/jni/Floats.hxx?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/jni/Types.hxx.diff?tr1=1.30&tr2=1.31&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/lines/Lines.hxx.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/vobs/Lines.hxx.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/vobs/ContinuousLineVob.java.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/src/lines/Lines.cxx.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/demo/lines.py.diff?tr1=1.4&tr2=1.5&r1=text&r2=text

Patches:
Index: libvob/include/vob/jni/Types.hxx
diff -u libvob/include/vob/jni/Types.hxx:1.30 
libvob/include/vob/jni/Types.hxx:1.31
--- libvob/include/vob/jni/Types.hxx:1.30       Fri Aug 15 14:53:38 2003
+++ libvob/include/vob/jni/Types.hxx    Fri Aug 22 08:33:40 2003
@@ -36,6 +36,7 @@
 
 #include <vob/jni/Stats.hxx>
 #include <vob/jni/Strings.hxx>
+#include <vob/jni/Floats.hxx>
 
 
 
@@ -122,6 +123,8 @@
     typedef ::Vob::Font::RealFont RF;
     extern ObjectStorer<RF> textrenderers;
 
+    typedef std::vector<float> floatvector;
+
 #define START_VOB_JNI_CONVERSION(type, javaName_, jnitype_)    \
     struct JParameter<type> {                                  \
        typedef jnitype_ jniType;                               \
@@ -232,16 +235,8 @@
        out = jstr2stdstr(env, in);
     END_VOB_JNI_CONVERSION
 
-    START_VOB_JNI_CONVERSION(std::vector<float>, "float []", jfloatArray) 
-      jsize len = env->GetArrayLength(in);
-      int i = 0;
-      std::vector<float> floats;
-      jfloat *f = env->GetFloatArrayElements(in, 0);
-      for (i=0; i<len; i++) {
-       floats.push_back(f[i]);
-      }
-      env->ReleaseFloatArrayElements(in, f, 0);
-      out = floats;
+    START_VOB_JNI_CONVERSION(floatvector, "float []", jfloatArray) 
+      jfloats2floatvector(env, in, out);
     END_VOB_JNI_CONVERSION
 
 
Index: libvob/include/vob/lines/Lines.hxx
diff -u libvob/include/vob/lines/Lines.hxx:1.4 
libvob/include/vob/lines/Lines.hxx:1.5
--- libvob/include/vob/lines/Lines.hxx:1.4      Mon Aug  4 09:47:50 2003
+++ libvob/include/vob/lines/Lines.hxx  Fri Aug 22 08:33:40 2003
@@ -52,31 +52,13 @@
     class SimpleLine {
         GLuint textureId;
         float linewidth;
-    public:
-        SimpleLine(GLuint textId, float l, vector<float> points): 
-            textureId(textId), linewidth(l)
-        { 
-         if (textId <= 0) {
-           cout << "Error in SimpleLine - TextId under or zero!"<< textId 
<<"\n";
-           return;
-         }
-         if (points.size() != 6) {
-           cout << "Errorr in SimpleLine - not enough points!"<< points.size() 
<<"\n";
-           return;
-         } else {
-
-           // You have to transform a and b before hand.
-           // XXX can z coord be zero?!
-           draw(ZPt( points[0],points[1], points[2]) , 
-                ZPt( points[3], points[4], points[5]) );
-         }
-
-        }
-        ~SimpleLine() { }
-
+    private:
         /** Draws a line from point a to b.
          */
         void draw(ZPt a, ZPt b);
+    public:
+        SimpleLine(GLuint textId, float lineWidth, vector<ZPt> points);
+        ~SimpleLine() { }
     };
 
 
@@ -98,12 +80,18 @@
      */
     class ContinuousLine {
     private:
-        vector<float> points;
         GLuint textureId;
-        bool drawDone;
-        bool chain;
         float lineWidth;
+        vector<ZPt> points;
         int joinStyle;
+        bool chain;
+
+    private:
+
+        /** Draw the continuous line on the screen.
+         */ 
+        void draw();
+
     public:
         /** ContinuousLine is line constructed from various points. 
          *  It bends in given points.
@@ -113,39 +101,12 @@
          * @param joinStyle "Bevel", "Miter" or "Round"
          * @param lineWidth line's width
          * @param chain join first and last point
-         * @param points float vector of points a,b,c etc. 
+         * @param points ZPt points a,b,c etc. 
          *          { ax,ay,az, bx,by,bz, cx,cy,cz, etc.. }
          */
         ContinuousLine(GLuint textId, float lineWidth,
-                      int joinStyle, bool chain,
-                       vector<float> points);
-
-
-        /** ContinuousLine is line constructed from various points. 
-         *  It bends in given points.
-         * http://www.xaraxone.com/webxealot/xealot19/page_4.htm
-         * @param textId texture's id - must be > 0.
-         * @param joinStyle "Bevel", "Miter" or "Round" 
-         * @param lineWidth line's width
-         * @param chain join first and last point
-         */
-        ContinuousLine(GLuint textId, float lineWidth,
-                      int joinStyle, bool chain);
-        ~ContinuousLine();
-
-        /** Add the first point or 
-         * add a new last point at the end previous points.
-         */
-        void add(float x, float y, float z);
-
-        /** Joins first and last point.
-         * Additional points can't be added after this.
-         */
-        void makeChain();
-
-        /** Draw the continuous line on the screen.
-         */ 
-        void draw();
+                       vector<ZPt> points, int joinStyle, bool chain);
+        ~ContinuousLine() { }
     };
 }
 
Index: libvob/include/vob/vobs/Lines.hxx
diff -u libvob/include/vob/vobs/Lines.hxx:1.3 
libvob/include/vob/vobs/Lines.hxx:1.4
--- libvob/include/vob/vobs/Lines.hxx:1.3       Mon Aug  4 09:47:50 2003
+++ libvob/include/vob/vobs/Lines.hxx   Fri Aug 22 08:33:40 2003
@@ -55,25 +55,18 @@
     }
 
     template<class T> void render(const T &coords1) const {
-      std::cout << "Foobar, ContinuousLine...\n";
-
-      vector<float> pts;
-      for (unsigned int i=0; i<points.size(); i+=3) {
-         ZPt tmp = coords1.transform( ZPt(points[i], points[i+1], 0) );
-         std::cout << "Argh..";
-         pts.push_back(tmp.x);
-         pts.push_back(tmp.y);
-         pts.push_back(tmp.z);
+      vector<ZPt> pts;
+      for (unsigned int i=0; i+2<points.size(); i+=3) {
+       ZPt p = coords1.transform( ZPt(points[i], points[i+1], points[i+2]) );
+       pts.push_back(p);
       }
 
-      if (pts.size() <= 6) {
+      if (pts.size() <= 2) {
        Lines::SimpleLine l = Lines::SimpleLine(texId, width, pts);
       } else {
        Lines::ContinuousLine l = 
-         Lines::ContinuousLine(texId, width, joinStyle, chain, pts);
+         Lines::ContinuousLine(texId, width, pts, joinStyle, chain);
       }
-
-      std::cout << "Foobar, ContinuousLine DONE...\n";
     };
 
 
Index: libvob/org/nongnu/libvob/vobs/ContinuousLineVob.java
diff -u libvob/org/nongnu/libvob/vobs/ContinuousLineVob.java:1.4 
libvob/org/nongnu/libvob/vobs/ContinuousLineVob.java:1.5
--- libvob/org/nongnu/libvob/vobs/ContinuousLineVob.java:1.4    Mon Aug  4 
09:48:50 2003
+++ libvob/org/nongnu/libvob/vobs/ContinuousLineVob.java        Fri Aug 22 
08:33:40 2003
@@ -36,7 +36,7 @@
 /** Continuous line needs x,y,z points in float array.
  */
 public class ContinuousLineVob extends AbstractVob {
-public static final String rcsid = "$Id: ContinuousLineVob.java,v 1.4 
2003/08/04 13:48:50 mudyc Exp $";
+public static final String rcsid = "$Id: ContinuousLineVob.java,v 1.5 
2003/08/22 12:33:40 mudyc Exp $";
     static private void pa(String s) { 
System.out.println("ContinuousLine::"+s); }
 
     static private GL.Texture tex;
@@ -45,7 +45,6 @@
        if (needInit) {
            String[] texparam = new String[0];
            tex = GL.createTexture(); 
-           pa("texture: "+tex);
            //tex.shade_all_levels(256, 256, 0, 1, "ALPHA", "ALPHA", "line", 
texparam);
            tex.shade(128, 128, 0, 1, "ALPHA", "ALPHA", "line", texparam);
            needInit = false;
@@ -72,6 +71,8 @@
        this(width, points, false, BEVEL, null);
     }
 
+    /** @param points Points in 3D model. One point is x,y and z.
+     */
     public ContinuousLineVob(float width, float[] points, boolean chain, int 
joinStyle, Color color) {
        super();
        this.width = width;
@@ -115,6 +116,7 @@
        GLRen.ContinuousLine cl = 
            GLRen.createContinuousLine(tex.getTexId(), width, joinStyle, chain, 
points);
        vs.map.put(cl, coordsys1);
+       pa("draw line..");
        return  0;
     }
 }
Index: libvob/src/lines/Lines.cxx
diff -u libvob/src/lines/Lines.cxx:1.6 libvob/src/lines/Lines.cxx:1.7
--- libvob/src/lines/Lines.cxx:1.6      Mon Aug  4 09:45:14 2003
+++ libvob/src/lines/Lines.cxx  Fri Aug 22 08:33:40 2003
@@ -21,18 +21,34 @@
  *    
  */
 /*
- * Written by Matti Katila
+ * Written by Matti J. Katila
  */
 
 
 #include <vob/lines/Lines.hxx>
 #include <cmath>
 
-static bool dbg = false;
+static bool dbg = true;
 
 namespace Lines {
 //    DBGVAR(dbg_lines, "Lines.general");
 
+    SimpleLine::SimpleLine(GLuint textId, float lineWidth, vector<ZPt> 
points): 
+      textureId(textId), linewidth(lineWidth)
+    { 
+        if (textId <= 0) {
+         cout << "Error in SimpleLine - TextId under or zero!"<< textId <<"\n";
+         return;
+       }
+       if (points.size() != 2) {
+         cout << "Errorr in SimpleLine - not enough points!"<< points.size() 
<<"\n";
+         return;
+       }
+       draw(points[0], points[1]);
+    }
+
+
+
     /* How texture clipping is count?
      * ------------------------------
      *   line... 
@@ -62,7 +78,7 @@
      */
 
     void SimpleLine::draw(ZPt a, ZPt b) {
-        if (dbg) cout << linewidth;
+        if (dbg) cout << "lineWidth: " <<linewidth << "\n";
         if (dbg) cout <<" x: "<< a.x << ", "<< b.x 
                       <<" y: "<< a.y << ", "<< b.y <<"\n";
 
@@ -116,29 +132,15 @@
      * ===============  
      */
     ContinuousLine::ContinuousLine(GLuint textId, float lineWidth,
-                                  int joinStyle,  bool chain,
-                                   vector<float> points) {
-        ContinuousLine(textId, lineWidth, joinStyle, chain);
-
-        if ( (points.size() % 3) != 0) {
-            cerr << "Lines error:: Size not divisible by three (x,y,z)!\n";
-            return;
-        }
-        for (unsigned int i=0; i+2<points.size(); i+=3){
-            add(points[i], points[i+1], points[i+2]);
-        }
-    }
-
+                                  vector<ZPt> points, int joinStyle,  bool 
chain):
+      chain(chain) 
+    {
+        this->lineWidth = fabs(lineWidth);
 
+        std::cout << "ContinuousLine constructor\n";
 
-    ContinuousLine::ContinuousLine(GLuint textId,
-                                   float lineWidth,
-                                   int joinStyle,
-                                   bool chain): 
-        drawDone(false), chain(chain) 
-    {
-        if (textId < 0) {
-            cerr << "Lines error:: Texture Id < 0 ! \n";
+        if (textId <= 0) {
+            cerr << "Lines error:: Texture Id <= 0 ! \n";
             return;
         }
 
@@ -148,32 +150,14 @@
             this->textureId = textId;
         else {
             cerr << "Lines error:: Not a good joinStyle: " 
-                 << textId <<"\n";
+                 << joinStyle <<"\n";
             return;
         }
-
-        this->lineWidth = fabs(lineWidth);
-    }
-
-    ContinuousLine::~ContinuousLine() { 
-        if (!drawDone) draw();
-    }
-
-    void ContinuousLine::add(float x, float y, float z) {
-        cout << "foo..\n";
-    }
-
-    void ContinuousLine::makeChain() {
-        this->chain = true;
+       draw();
     }
 
     void ContinuousLine::draw() {
-        if (drawDone) {
-            cerr << "Lines error:: Draw has been already made!\n";
-            return;
-        }
-
-        drawDone = true;
+       cout << "Now, if implemented - draw continuousline.\n";
     }
 
 
Index: libvob/vob/demo/lines.py
diff -u libvob/vob/demo/lines.py:1.4 libvob/vob/demo/lines.py:1.5
--- libvob/vob/demo/lines.py:1.4        Fri Aug 22 05:33:22 2003
+++ libvob/vob/demo/lines.py    Fri Aug 22 08:33:40 2003
@@ -22,13 +22,10 @@
 from __future__ import nested_scopes
 import vob
 
-#from vob.putil.misc import *
-#from vob.putil.effects import *
-
 class Scene:
     def __init__(self):
-        self.x = 50
-        self.y = 50
+        self.x = 150
+        self.y = 150
     
     def key(self, k):
        pass
@@ -36,9 +33,11 @@
     def mouse(self, m):
         self.x = m.getX()
         self.y = m.getY()
+        vob.AbstractUpdateManager.chg()
 
     def scene(self, vs):
-       vs.put( background((0.1,0.4,0.5)))
-        vs.put( vob.vobs.ContinuousLineVob( 12.0, [0,0, self.x, self.y]), -1)
-
+       vs.put( background((.9, .8, .6)))
+        cs = vs.coords.orthoBox(0,0, 0,0, 1,1, self.x, self.y)
+        vs.put( vob.vobs.ContinuousLineVob( 1.0, [0,0,0, 1,1,0]), cs)
+        print 'scene done.'
      




reply via email to

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