#1
|
|||
|
|||
Placing Text onto another object???
I want to know how to place some text (in this case a single letter) "on" a specific place in another object in the world. In other words, let's say I have a .wrl file with some model in my world. And let's say within that .wrl file there are six "boxes" and each "box" needs to have a unique letter in it.
I tried using A = viz.add(viz.TEXT3D, 'A') and I also tried using A = viz.add(viz.TEXT3D, 'A', viz.ABSOLUTE WORLD) because I can't have the text tied to the screen. (The viewpoint will be moving and I want the letters to stay put in each of their respective boxes). Also, each box is in a different place in the environment so I'm assuming I'd have to just monkey with the translation of each of the letters until I got it inside it's appropriate box? Or is there an easier way? (I.e. is there a way to turn on "coordinates" within Vizard so I could see where each box lies and then translate each letter accordingly? I'm going to try a couple more ideas but plainly speaking I'm running out and I'm stuck. Any help? Any ideas? Thanks for the help in advance |
#2
|
|||
|
|||
I think I might have figure out to do the text thing but now when I try to add a second letter it won't even show up
so I have: A = viz.add(viz.TEXT3D,'A', viz.RELATIVE_LOCAL) A.translate(.17,.985,4.2) A.color(0,0,0) A.scale(.2, .2, 2) H = viz.add(viz.TEXT3D,'H', viz.RELATIVE_LOCAL) H.translate(0,.95,4.2) H.color(0,0,0) H.scale(.2, .2, 2) But the H won't show up and I don't know why. I tried it with something much more random like 'quibeqf' as the text but that didn't show up either. Any ideas??? I need to be able to use 11 letters total |
#3
|
|||
|
|||
Another point of interest:
I tried just creating a blank script with the letters and here's what I have: import viz viz.go() A = viz.add(viz.TEXT3D,'A', viz.RELATIVE_LOCAL) A.translate(.17,.985,4.2) A.color(1,0,0) A.scale(.2, .2, 2) H = viz.add(viz.TEXT3D,'H', viz.RELATIVE_LOCAL) H.translate(0,.95,4.2) H.color(0,0,1) H.scale(.2, .2, 2) I = viz.add(viz.TEXT3D, 'I', viz.RELATIVE_LOCAL) I.translate(0,.80,4.2) I.color(0,1,0) I.scale(.2,.2,.2) Now in this case, I can get H and A to appear but not I. And I've added others like Q and R and they won't appear either. Is there some limit to how many I can add? And if this is true then why in my actual script (where I need the letters to appear) won't A or H or I appear at all!!??? What's going on? |
#4
|
|||
|
|||
You need to remove the viz.RELATIVE_LOCAL from the viz.add command. When adding text the 3rd parameter is the parent the text should be attached to. By default it is viz.WORLD. If you want to attach some text to an existing object try the following example:
Code:
import viz viz.go() box = viz.add('box.wrl') box.add(vizact.spin(0,1,0,90,viz.FOREVER)) box.translate(0,1,5) #Add text as child of box A = viz.add(viz.TEXT3D,'A', box) A.alignment(viz.TEXT_CENTER_CENTER) #Text translation will be relative to boxes local coordinate system A.translate(0,.985,0) A.color(0,0,0) A.scale(.2, .2, 2) viz.clearcolor(viz.GRAY) In your case, are the boxes static or will they be moving around? If the boxes are static, then you don't need set the parent of the text. Just add the text to viz.WORLD and place it where the boxes are. If the boxes will be moving around then add the text as children of the boxes and position the text locally, relative to the box. |
#5
|
|||
|
|||
thank you for the help. I got it figured out now
|
Thread Tools | |
Display Modes | Rate This Thread |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
retrieve Object names | Geoffrey | Vizard | 11 | 12-11-2009 05:26 AM |
Child Object Rotation | paulgoldberg | Vizard | 5 | 09-05-2006 12:33 PM |
adding 2D text via script | V.shazzle | Vizard | 3 | 09-19-2005 03:45 PM |
rotate to object | jargon | Vizard | 1 | 08-08-2005 01:20 PM |
3d Text with Transparent Borders | vjosh | Vizard | 3 | 12-01-2004 11:50 AM |