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 › Has anyone done text in 3D well
Page Index Toggle Pages: 1
Has anyone done text in 3D well? (Read 2177 times)
Has anyone done text in 3D well?
Nov 26th, 2008, 8:32pm
 
Hey up

I'm just making an interactive visualisation of an economic function (the CES):

http://www.personal.leeds.ac.uk/~gy06do/processing/ces_function/

I'm going to want to add labels, but no method I know in Processing will work well. Fonts appear oddly, for example.

I'm thinking of making some classes to turn text strings into appropriately positioned text (i.e. facing the virtual viewer), with various options e.g. facing viewer, but retaining perspective (small = far away, as Father Ted might say, vs. consistent size regardless of point they're 'labelling.')

It'd use a vector font - crappy but at least informative.

Question, though: has someone already done this? As I say, I could rotate / translate and use a normal font - but they never draw quite right in 3D. So I suppose two questions:

1. Anyone got any tricks / know any generated fonts with particular sizes that work perfectly? I could then just translate / rotate appropriately to get em facing the viewer.

2. Anyone know of any other approaches to this?

p.s for the CES function:

Click and drag to rotate / zoom.

Three changeable parameters: click and drag up / down to change each.

1. The substitution parameter: p and drag

2. returns to scale: s and drag

3. share parameter: s and drag

Also on keyboard:

1 changes p to 1 (perfect substitutes)
2 change p to -1 (cobb-douglas, I think)
3 changes p to 0 (ish)
4 changes p to -60 (perfect complements e.g. with utility, that'd be 'it doesn't matter how many more right shoes I have, I can't be any happier with this pair of shoes.')

The equation: output / utility = (a*k^p+(1-a)*l^p)^(s/p)

Details at wikipedia:

http://en.wikipedia.org/wiki/Constant_elasticity_of_substitution

Bye for now,

Dan
Re: Has anyone done text in 3D well?
Reply #1 - Nov 28th, 2008, 6:28pm
 
Problem solved, I reckon. A normal font is pretty fine, actually, and if you align rotateX and rotateY with OCD's attitude() method, the text faces the viewer:

http://www.personal.leeds.ac.uk/~gy06do/processing/ces_function/

Note: I had to call the attitude() method directly after drawing the text so that it got the most up-to-date attitude numbers. If I place this call anywhere else the text jitters.

Note2: rotateX (pitch) - negative first, then positive when rotating back.

See code via link above. (The drawText method - amazingly brief. By God, I love Processing!)
Re: Has anyone done text in 3D well?
Reply #2 - Nov 28th, 2008, 10:33pm
 
Great project, Dan.

Also try the Vertext library for more easily scalable type:

http://www.ghost-hack.com/p5/vertext/
Re: Has anyone done text in 3D well?
Reply #3 - Dec 2nd, 2008, 4:35am
 
i love the way you have handled that text - that said, I can't figure out what is going on, I'm a total noob. Do I have to limit the movement of the camera to a circle, as you have, in order to get that "billboard" (always facing the camera) effect?

I looked at the ocd reference at the attitude function and it didnt' clarify things...help?

such inspiring work!
Re: Has anyone done text in 3D well?
Reply #4 - Dec 2nd, 2008, 10:07am
 
In this example, if you hold down space and drag the mouse, you can also arc over - the text will stay facing.

I was actually surprised that it worked when I coded it. If you draw three lines on a piece of paper for x,y and z axes, you'd think that if you circle round the y axis ('circle' in OCD) your relation to the x axis would shift and you'd have to compensate accordingly. I presume I must have a wrong mental picture: the axes rotations must take place independently, judging by the fact that this code worked!

Anyway - the code here will work for circle and arc changes, but not for others e.g. rolling. That may just mean rotating about the z axis first.

My method of working with this tends to be: draw it on paper, maybe do some trig, try it, discover it doesn't work, change the order and polarity of some of the translates and rotates until it does! If that fails, back to the paper and think it through again.
Re: Has anyone done text in 3D well?
Reply #5 - Dec 2nd, 2008, 10:18am
 
Oh -also, the attitude method that assigns three values to an array: it calls those values yaw, pitch and roll. At least for the first two that's:

Yaw: 'circle' distance around the y axis [attitude[0]]
Pitch:  'arc' distance around the x axis [attitude[1]]

I'm guessing 'roll' will be the same for the Z axis, but haven't tried it.

If that makes no sense, as I say, pencil and paper are your best friend!
Re: Has anyone done text in 3D well?
Reply #6 - Dec 6th, 2008, 12:01am
 
Cool app.. I don't really get what it represents but cool.

Why don't you just use textMode(SCREEN)?
Re: Has anyone done text in 3D well?
Reply #7 - Dec 7th, 2008, 9:45am
 
Ah ha - because I hadn't seen there was such a function.

The only advantage to the way I do it, then, is that the text continues to have z-axis perspective whilst still facing the viewer. If you didn't need that, I imagine you could just use a 3D point, get its screen co-ordinates with screenX() and screenY().

Thanks for pointing that out!
Re: Has anyone done text in 3D well?
Reply #8 - Mar 4th, 2009, 9:39pm
 
Scott Murray wrote on Nov 28th, 2008, 10:33pm:
Great project, Dan.

Also try the Vertext library for more easily scalable type:

http://www.ghost-hack.com/p5/vertext/


I gave this a try but I couldn't get it to work.  I only got the last string.
Page Index Toggle Pages: 1