[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] libvob org/nongnu/libvob/util/TexManip.java tes...
From: |
Tuomas J. Lukka |
Subject: |
[Gzz-commits] libvob org/nongnu/libvob/util/TexManip.java tes... |
Date: |
Thu, 17 Apr 2003 01:21:41 -0400 |
CVSROOT: /cvsroot/libvob
Module name: libvob
Changes by: Tuomas J. Lukka <address@hidden> 03/04/17 01:21:40
Modified files:
org/nongnu/libvob/util: TexManip.java
test/vob/gl : glvobcoorder.test
vob/demo : fpfont.py
Log message:
(as per jvk's idea:) symmetric distances from fonts outlines, they
really *do* make it easier
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/util/TexManip.java.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/test/vob/gl/glvobcoorder.test.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/demo/fpfont.py.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
Patches:
Index: libvob/org/nongnu/libvob/util/TexManip.java
diff -u libvob/org/nongnu/libvob/util/TexManip.java:1.1
libvob/org/nongnu/libvob/util/TexManip.java:1.2
--- libvob/org/nongnu/libvob/util/TexManip.java:1.1 Wed Apr 9 06:59:30 2003
+++ libvob/org/nongnu/libvob/util/TexManip.java Thu Apr 17 01:21:40 2003
@@ -10,22 +10,43 @@
*/
static private void wipe(float[] d, int[] mx, int[] my, int x, int y, int
dx, int dy, int n, int w) {
int cmx = -10000, cmy = -10000;
+ int clx = -10000, cly = -10000;
for(int i = 0; i<n; i++) {
int cx = x + i*dx;
int cy = y + i*dy;
int ind = cx + w * cy;
- float dix = cx - cmx;
- float diy = cy - cmy;
- float dcur = (float)Math.sqrt(dix*dix + diy*diy);
-
- if(d[ind] < dcur) {
- cmx = mx[ind];
- cmy = my[ind];
+ if(d[ind] < 0) {
+ float dix = cx - clx;
+ float diy = cy - cly;
+ float dcur = - (float)Math.sqrt(dix*dix + diy*diy);
+
+ if(d[ind] > dcur) {
+ clx = mx[ind];
+ cly = my[ind];
+ } else {
+ d[ind] = dcur;
+ mx[ind] = clx;
+ my[ind] = cly;
+ }
+ cmx = cx;
+ cmy = cy;
+
} else {
- d[ind] = dcur;
- mx[ind] = cmx;
- my[ind] = cmy;
+ float dix = cx - cmx;
+ float diy = cy - cmy;
+ float dcur = (float)Math.sqrt(dix*dix + diy*diy);
+
+ if(d[ind] < dcur) {
+ cmx = mx[ind];
+ cmy = my[ind];
+ } else {
+ d[ind] = dcur;
+ mx[ind] = cmx;
+ my[ind] = cmy;
+ }
+ clx = cx;
+ cly = cy;
}
}
}
@@ -36,13 +57,13 @@
int[] my = new int[w*h];
for(int ind = 0; ind < w*h; ind++) {
- d[ind] = (from[ind] != 0 ? 0 : 1000000);
+ d[ind] = (from[ind] != 0 ? -1000000 : 1000000);
mx[ind] = ind % w;
my[ind] = ind / w;
}
// Reasonable approximation
- for(int i=0; i<5; i++) {
+ for(int i=0; i<4; i++) {
for(int x = 0; x < w; x++)
wipe(d, mx, my, x, 0, 0, 1, w, w);
for(int y = 0; y < h; y++)
@@ -63,10 +84,12 @@
}
- static public void b2s(short[] from, byte[] to) {
+ static public void b2s(short[] from, byte[] to, int spacing) {
for(int i=0; i<from.length; i++) {
- to[i*2] = (byte)(from[i] % 256);
- to[i*2+1] = (byte)(from[i] / 256);
+ to[i*spacing] = (byte)(from[i] % 256);
+ to[i*spacing+1] = (byte)(from[i] / 256);
+ if(to[i*spacing+1] == 0 && from[i] < 0)
+ to[i*spacing+1] = (byte)255;
}
}
}
Index: libvob/test/vob/gl/glvobcoorder.test
diff -u libvob/test/vob/gl/glvobcoorder.test:1.12
libvob/test/vob/gl/glvobcoorder.test:1.13
--- libvob/test/vob/gl/glvobcoorder.test:1.12 Wed Apr 16 06:37:57 2003
+++ libvob/test/vob/gl/glvobcoorder.test Thu Apr 17 01:21:40 2003
@@ -310,9 +310,18 @@
def testBox():
cs1 = vs.orthoBoxCS(0, "A", 1, 2, 3, 4, 5, 6, 7)
+ cs2 = vs.translateCS(0, "B", 100,100,100)
wh = zeros(2, 'f')
vs.coords.getSqSize(cs1, wh)
failUnlessEqual(wh[0], 6);
failUnlessEqual(wh[1], 7);
+ cs3 = vs.coords.nadirUnitSq(cs1, cs2)
+
+
+ wh = zeros(2, 'f')
+ vs.coords.getSqSize(cs3, wh)
+ failUnlessEqual(wh[0], 6);
+ failUnlessEqual(wh[1], 7);
+
# : vim: set syntax=python :
Index: libvob/vob/demo/fpfont.py
diff -u libvob/vob/demo/fpfont.py:1.5 libvob/vob/demo/fpfont.py:1.6
--- libvob/vob/demo/fpfont.py:1.5 Tue Apr 15 09:54:20 2003
+++ libvob/vob/demo/fpfont.py Thu Apr 17 01:21:40 2003
@@ -26,6 +26,17 @@
fn2 = jarray.zeros(10*10, 'h')
fn[15] = 1
+ fn[14] = 1
+ fn[13] = 1
+ fn[12] = 1
+ fn[25] = 1
+ fn[24] = 1
+ fn[23] = 1
+ fn[22] = 1
+ fn[35] = 1
+ fn[34] = 1
+ fn[33] = 1
+ fn[32] = 1
for i in range(0,20): # exercise JVM
print "Exercise ",i
vob.util.TexManip.minDist(fn, fn2, 10, 10, 10)
@@ -44,6 +55,7 @@
fn = jarray.zeros(2*w*h, 'b')
fn2 = jarray.zeros(w*h, 'h')
+ fn3 = jarray.zeros(4*w*h, 'b')
t.getTexImage(0, "ALPHA", "UNSIGNED_BYTE", fn)
# for i in range(0, w*h, 5):
@@ -56,7 +68,7 @@
# Distance * 16
vob.util.TexManip.minDist(fn, fn2, w, h, 16)
print "Maniped1"
- vob.util.TexManip.b2s(fn2, fn)
+ vob.util.TexManip.b2s(fn2, fn3, 4)
print "Maniped"
@@ -66,7 +78,9 @@
t.setTexParameter("TEXTURE_2D", "GENERATE_MIPMAP_SGIS", "TRUE");
- t.texImage2D(0, "LUMINANCE_ALPHA", w, h, 0, "LUMINANCE_ALPHA",
"UNSIGNED_BYTE", fn)
+ for y in range(0,50):
+ print " ".join([str(fn3[1000*y + i]) for i in range(0,30)])
+ t.texImage2D(0, "SIGNED_HILO16_NV", w, h, 0, "HILO_NV", "SHORT", fn3)
fonttexs.append(t)
@@ -95,7 +109,8 @@
from vob.putil import cg
-fp = [GL.createProgram(cg.compile("""
+fp = [
+GL.createProgram(cg.compile("""
void main(
float2 t : TEXCOORD0,
uniform float2 meas: register(c0),
@@ -119,7 +134,7 @@
// * 512 = texture width
// / 2 = half, for radius
// / 2 = half, for x-sampling pattern
- half maxrad = l * 512 / 2 / 2 * meas.y;
+ half4 maxrad = l * 512 / 2 / 2 * meas.y;
half4 c0 = tex2D(t0, t + meas.x*(dx+dy));
@@ -128,18 +143,16 @@
half4 c2 = tex2D(t0, t + meas.x*(-dx+dy));
half4 c3 = tex2D(t0, t + meas.x*(-dx-dy));
- half4 dists = half4(
- // c0.x + c0.w * 256,
- c0.w + c0.x * 256,
- c1.x + c1.w * 256,
- c2.x + c2.w * 256,
- c3.x + c3.w * 256);
+ half4 dists = 256 * 16 * half4(
+ c0.x,
+ c1.x,
+ c2.x,
+ c3.x);
- dists *= 16;
- fixed c = dot(1-smoothstep(float4(0,0,0,0), maxrad, dists),
fixed4(1,1,1,1)) / 4;
+ fixed c = dot(1-smoothstep(-maxrad, maxrad, dists), fixed4(1,1,1,1)) / 4;
fixed rgb = (1 - c);
@@ -152,6 +165,27 @@
""", "fp30")),
+GL.createProgram(cg.compile("""
+void main(
+ float2 t : TEXCOORD0,
+ uniform float2 meas: register(c0),
+ uniform sampler2D t0: TEXUNIT0,
+ out half4 color: COLOR) {
+ float4 tx = tex2D(t0,t);
+ float x = tx.x * 256 * 16;
+ float tex = 5;
+ if(x > tex)
+ color = float4(1,0,1,0);
+ else if(x > 0)
+ color = float4(0,1,0,1);
+ else if(x > -tex)
+ color = float4(0,0,1,1);
+ else
+ color = float4(1,0,0,1);
+}
+
+
+""", "fp30")),
GL.createProgram("""!!FP1.0
DECLARE meas;
MOV R10, f[TEX0].xyzw;
@@ -513,7 +547,7 @@
cs = vs.rotateCS(cs, "b", self.a)
- if self.prognum == 0:
+ if self.prognum < 2:
f = font
else:
f = font2
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gzz-commits] libvob org/nongnu/libvob/util/TexManip.java tes...,
Tuomas J. Lukka <=