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.
IndexProgramming Questions & HelpPrograms › Rotating text
Page Index Toggle Pages: 1
Rotating text (Read 1761 times)
Rotating text
May 11th, 2007, 2:50pm
 
Hi all,

I'm trying to rotate text in a 3D environment. Every new frame it rotates a certain amount of degrees.

The problem I have is that the letters flicker. Frame rate and the amount of degrees the text rotates every frame don't seem to make a difference.
Any suggestions?

Thanks in advance, BEnm
Re: Rotating text
Reply #1 - May 11th, 2007, 4:39pm
 
Hi BEnm, Be welcome on processing board..

IF you could post your code here, or a link to your sketch online, it would help to understand your problem.

Let guest something: You might get unSmooth effect (steps) because the value you send in your rotation is not a fraction (a float). You need to make sure that the value is a float type.

rotateX(INT)    would give steps
rotateX(FLOAT)  would be smooth

if you make something like this (INT)/(INT) = (INT)
and (INT)/(FLOAT) = (FLOAT)

Try this here:


Code:

PFont font;

void setup(){
size(400,200,P3D); //Your window should use 3D (OpenGL could be used as well)

font = loadFont("ArialNarrow-Bold-48.vlw"); //Load your font
textFont(font, 48); //Setup the font
}

void draw(){

background(100);

//Create values for rotations
float myRatioX = mouseX/(float)width; //Note that we must be shure that the value should be a float (fraction)
float myRatioY = mouseY/(float)height; //Idem

float myRatioF;

if(mousePressed) myRatioF = frameCount/10; //If the mouse is Pressed, it will be a Int
else myRatioF = frameCount/10f; //Otherwise, it will be a ratio (Float)

//Make the transformations
pushMatrix();

translate(width/2f, height/(float)2, 0); //Two equivalent ways to get a float

rotateX(myRatioF);
rotateY(myRatioX*2*PI);
rotateZ(myRatioY*2*PI);

text("iLoveP5", 15, 50);

popMatrix();
}
Online Example
Reply #2 - May 11th, 2007, 5:00pm
 
http://labelle.spacekit.ca/P55/Test/TestRot/
(Here's the example uploaded)
Re: Rotating text
Reply #3 - May 11th, 2007, 7:21pm
 
goo, tanks for replying so fast!

you're totally right; i should have provided some code. i really appreciate your elaborate explanation.

i now send floats to the rotate method, at least i think so, but the text still flickers.

i've uploaded my sketch to http://home.tiscali.nl/laboratorium

by the way, your layout is really nice.

/BEnm
Re: Rotating text
Reply #4 - May 11th, 2007, 7:54pm
 
Code:

pushMatrix();
translate(0, 32.5, 0);
rotateX(radians(180f));
translate(0, -32.5, 0.1); <--(put something for Z
text(letter, 15, 47.5);
popMatrix();


Why?
It's a problem when to faces (polygons) are placed exactly at the same position. It will flick in a strange way. When you explicitly decide wich one is on the top, you resolve your problem.

translate(0, -32.5, -0.1);  <--(Will make it disappear

You could try something smaller, like 0.001f...
Re: Rotating text
Reply #5 - May 11th, 2007, 8:23pm
 
goo, thank you very much!

i thought somehow the letters would 'overwrite' the texture beneath them. why i'd reasoned that way i don't know.

the nice thing about programming is that every idee has to be made explicit i guess.

thanks again.

/BEmn
Page Index Toggle Pages: 1