We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
text and ortho (Read 2148 times)
text and ortho
Mar 17th, 2010, 3:11am
 
Hi

I am using ortho to draw my scene, and now I want to display Text. The P3D renderer displays crappy characters, so I wantet to use OPENGL. But ortho does not work with openGL renderer.
Embarrassed

Is there a way to let the letters look better in P3D, or to replace the buggy ortho call in OPENGL with something that works?


edit:
i want that this code works:
Code:
import processing.opengl.*;

void setup(){
size(320,240,OPENGL);
ortho();
}

int i = 0;

void draw(){
background(127);
rect(10,10,30,40);
}
Re: text and ortho
Reply #1 - Mar 18th, 2010, 12:17pm
 
Re: text and ortho
Reply #2 - Mar 18th, 2010, 2:41pm
 
sorry, but it is not about drawing big letters, the problem is more that tiny letters are completely unreadable in P3D, but OPENGL draws them very sharp. I give you an example:

...
Re: text and ortho
Reply #3 - Mar 18th, 2010, 3:45pm
 
Rather than use ortho() in setup try this
Code:

import processing.opengl.*;

void setup(){
size(320,240,OPENGL);

}

int i = 0;

void draw(){
background(127);
pushMatrix();
ortho();

// draw ortho stuff here
popMatrix();

perspective();
rect(10,10,30,40);
}



At least you will see the rectangle.  Smiley
Re: text and ortho
Reply #4 - Mar 21st, 2010, 7:33am
 
nice try, but it does not solve the problem, that i cant draw anything with ortographic projection.
Re: text and ortho
Reply #5 - Mar 21st, 2010, 10:51am
 
You need the Shapes3D library (http://processing.org/reference/libraries/#3d)
and then create the following sketch

Code:
/**
* Simple program to demonstrate the shape picking feature
* of this library.
* Click on the slowly revolving cubes to change their colour.
*
* This demo uses the off-screen buffer version of the pick
* shape algorithm.
*
* created by Peter Lager 2010
*/

import shapes3d.utils.*;
import shapes3d.*;

import processing.opengl.*;


Box[] box = new Box[10];
float a;
boolean mouseClicked = false;
boolean orthoOn = false;
PMatrix3D orgMat;

void setup(){
 size(200,200,OPENGL);
 orgMat = (PMatrix3D)g.getMatrix();
 cursor(CROSS);
 float size;
 for (int i = 0; i < box.length; i++) {
   size = 5 + (int)random(15);
   box[i] = new Box(this,size,size,size);
   box[i].moveTo(random(-18,18), random(-18,18), random(-18,18));
   box[i].fill(randomColor());
 }
 translate(width/2, height/2);
}

void draw(){
 background(255);
 pushMatrix();
 if(orthoOn){
   background(255,200,200);
   ortho(-width/6,width/6,-height/6,height/6,-100,100);
 }
 else {
   background(200,2550,200);
   perspective();
 }

 camera(70 * sin(a), 10, 70 * cos(a), 0, 0, 0, 0, 1, 0);
 ambientLight(200,200,200);
 directionalLight(128, 128, 128, -1, 0, -1);

 for (int i = 0; i < box.length; i++) {
   box[i].draw();
 }

 if(mouseClicked){
   Shape3D picked = Shape3D.pickShapeB(this,mouseX, mouseY);
   if(picked != null)
     picked.fill(randomColor());
   mouseClicked = false;    
 }
 popMatrix();
 a += 0.002;
 g.setMatrix(orgMat);
 perspective();

 fill(0);
 if(orthoOn)
   text("Orthoganal View",10,30);
 else
   text("Perspective View",10,30);
}

void mouseClicked(){
 mouseClicked = true;
 orthoOn = !orthoOn;
}

int randomColor(){
 return color(random(60,200), random(60,200), random(60,200));
}


Re: text and ortho
Reply #6 - Mar 22nd, 2010, 3:15am
 
@Quark: maybe it is something obvious but do you know why this example looks rather ugly with P3D in perspective mode?:

...

I think the z-ordering of the boxes relative to each other is wrong and it seems one can see the inside rather than the outside.

Andreas
Re: text and ortho
Reply #7 - Mar 22nd, 2010, 11:49am
 
Weird one!

I also noticed that the cubes changed direction (incorrectly) in perspective mode. It looks like the 3D axis orientation is different between OPENGL and P3D (i.e. one is left handed and the other right handed).

This problem seems to be associated with changes made moving Processing from 1.0.9 to 1.1 because I tried it in 1.0.9 with no problems.
Sad

Page Index Toggle Pages: 1