add text to sphere
hi,
I am very new to Vizard. I am facing difficulties with adding a 2D text to a sphere. I want the text to appear on the top of the sphere when the user enters 't' ,for example, from the keyboard. I have tried many tutorials but I did not know how to do it. your help is appreciated. |
You can set the sphere to be the parent of the text:
Code:
import viz |
thanks a lot it worked.
I have another question, how can I calculate the distance between 2 objects? for example, lets say that the position of the sphere is (0,0,20) and when the avatar reaches a distance 1 meter far from the sphere, I want the text to appear. |
Hi Maya,
Sounds like you can use a proximity sensor. If you set your sphere as the source of the sensor in the example below, you can do something when someone enters the area (or leaves the area). See http://docs.worldviz.com/vizard/vizproximity.htm for more info. Code:
import viz |
hi,
thanks for ur replay. I get an error when I ran the example. this is the error: HTML Code:
sensor = vizproximity.Sensor( vizproximity.CircleArea(1),source=male) |
Make sure you have the latest version of Vizard. Go to Help > Check for Updates.
|
I installed the latest version and the code worked. thanx a lot.
I added this code in a multi user environment with 1 server and 2 clients. I added the code in client 1 specifically, but once I run the client, the message appears immediately even though the avatar is very far from the target (radiation source). could you help me with this issue plz? this is my code for client: Code:
import viz thanx in advance. |
Hi Maya,
You forgot to make text_2D invisible in the beginning. Code:
text_2D = viz.addText('radiation source area', viz.SCREEN ) |
hi Frank,
thanx for ur replay. I made the text invisible. but now, the text does not appear at all. am I doing something wrong? one more thing. in my case I have 1 server and 2 clients, I want the text to appear when either one of the clients (or both) reaches the radiation source. where do u recommend me to add the code for the proximity? (in client1 and client2 or in server side)? |
I have tested it with the code below. With that code, the text appears when you enter the small red sphere.
Code:
import viz Either way, the code for making the text appear should be on every party that needs to see the text. For instance, if the text has to appear on both clients, then both clients need the code for making the text visible and invisible. It seems like the condition to show the text on any machine is that one of the two clients enter the radiation zone. So in that case, you should at least communicate the state of each client to each other, and make the text appear when either one of them enters the radiation zone. You could also let each client communicate to the server whether they are in the radiation zone or not, and if one of the clients enters the radiation zone, you could let the server send a message to both clients. In both cases, you need a proximity sensor in client1 and client2, and somehow communicate the states of those clients to each other (either directly, or through the server). Please elaborate more on your specific problem if these suggestions do not point you in the desired direction. |
uh ok it's working. but, I wanted the text to appear when the avatar is for example 1 meter far from the radiation source. this is supposed to be a dangerous area and the message is there to warn the avatar that this is an affected area with radiation. so, he is not supposed to get close from it.
I am using only 1 PC, it is the server and the 2 clients at the same time. there is a communication between server and clients: 1. server can communicate with client 1 2.server can communicate with client 2, but client 2 can't read its messages 3. client1 can communicate with client 2, but client 2 does not c the messages 4. client 1 communicate with 2, but again client2 can't c the messages client 2 can't c messages sent by server and client 1. mmm.. I think I will just add the text code in both clients and i want them to communicate with each other. thanx |
Quote:
Code:
sensor = vizproximity.Sensor( vizproximity.CircleArea(0.1),source=sphere) Code:
sensor = vizproximity.Sensor( vizproximity.CircleArea(1),source=sphere) |
Thanx a lot. It worked.
|
hi Frank,
I have one more question related to the proximity sensor. I want the 2 clients (avatars) to see each other in the multi user environment. also, I want to calculate the distance between the 2 clients and make them do some thing when they are 5 meters far from each other. thanx. I appreciate ur help. |
I think you can just apply a vizproximity sensor with a circlearea of 5 (meters) to one (moving) avatar, and add a vizproximity target to the other (moving) avatar. When the avatars are within 5 meters from each other, the sensor (avatar1) should sense the target (avatar), and then you can respond to that event.
See the example below Code:
import viz |
thanx for ur replay.
I have tried the example. but, the problem is that client1 can't see client2 in its environment. I only can see the 2 clients in the server environment. is there a way that I can make client2 appears in client1's environment? I hope that my question is clear. thanx. |
If I understand correctly, avatar2 is not updated in client1, and avatar1 is not updated in client2?
If avatar1 is controlled by client1 and avatar2 is controlled by client2, then you should pass information about the position of avatar1 to client2, and of avatar2 to client1. I don't understand the part of client2 not visible in client1's environment. At every client side, you should render 2 avatars (avatar1 & avatar2), and also get the information to make them move. Apparently, both avatars are rendered on the server side. So you should use similar code on both clients to make both avatars visible for both clients. I cannot help you further without more information, e.g. sample code showing the example without the need for extra files/models/setups. |
basically, what I have is a multi user environment that consists of 1 server and 2 clients. what I mean by a client is the avatar. and I am using 1 pc as the server and the client.
client 1 will do a specific task (search for radiation source) where as client2 will identify the radiation source. both clients can exchange messages between them and with the server. I, as client1, while performing my task and navigating through the environment, I want to c client 2 (avatar2). this is the code: just run the server and then the 2 clients. try to control the movement of avatar1 and c if u can find avatar2 while navigating. ######server code############# Code:
import viz Code:
import viz hope it is clear now. thanx |
the replay is too long so I had to divided into 2. sorry for that.
######client2####### Code:
import viz |
All times are GMT -7. The time now is 06:21 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC