WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Placing Text onto another object??? (https://forum.worldviz.com/showthread.php?t=1432)

Elittdogg 04-03-2008 07:58 AM

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

Elittdogg 04-03-2008 08:33 AM

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

Elittdogg 04-03-2008 10:21 AM

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?

farshizzo 04-03-2008 10:42 AM

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)

All text object transformations (translate,rotate,scale) will now be relative to the local coordinate system of the box.

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.

Elittdogg 04-08-2008 02:15 PM

thank you for the help. I got it figured out now


All times are GMT -7. The time now is 05:01 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC