WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 07-18-2008, 08:38 AM
fc2008 fc2008 is offline
Member
 
Join Date: Jul 2008
Posts: 6
object in information box

Heya, I have an object - draft_text

I want to be included within an information box that pops up, how would I do this?

This is so when a user types a message it appears within that box

Also, how would I get the information box to follow an avatar around the screen?


The code i am using to create a networked chat box is below

Thanks in advance, FC

Code:
sent_message.visible(0)
typing_message.visible(0)


#Use a prompt to ask the user the network name of the other computer.
target_machine = viz.input('Enter the name of the other machine').upper()

#Add a mailbox from which to send messages. This is your outbox.
target_mailbox = viz.addNetwork(target_machine) 

 

#Start with sending_text as a blank space.
out_text = ''


def SendData(): 
    #Retrieve current transform of viewpoint
    mat = viz.MainView.getMatrix()
    
    #Apply offsets so duck model matches viewpoint
    mat.preEuler(180,0,0)
    mat.preTrans(0,-1,0)
 
 #Send position/rotation to target network object
    target_mailbox.send(quat=mat.getQuat(),pos=mat.getPosition(),message=out_text)

# Start a timer that sends out data over the network every frame
vizact.ontimer(0,SendData) 

# Listens for any incomming messages
def onNetwork(e):
    avatar.setPosition(e.pos)
    avatar.setQuat(e.quat)
    inbox.message(e.message)

# Register network to listen from incoming messages
viz.callback(viz.NETWORK_EVENT, onNetwork) 


#Create a variable for the draft of the outgoing message.
draft_text = ' '

def mykeyboard(key):
    global out_text, draft_text
    #If the length of the key is 1 then
    #add the character to the string.
    if draft_text == '':
        sent_message.visible(0)
        typing_message.visible(0)

    if len(key) == 1:
        draft_text += key
        sent_message.visible(0)
        typing_message.visible(1)
#If the key is a character return, end the line, make the 
#outgoing message equal to the draft message, and set the draft equal 
    # to a blank space.
    elif key == viz.KEY_RETURN:
        out_text = draft_text
        sent_message.visible(1)
        typing_message.visible(0)
        
    #If the key is the backspace key then remove the last character of the string.
    elif key == viz.KEY_BACKSPACE: 
        draft_text = draft_text[:-1]
    #Update the input text field so that you can see what you're typing.
    outbox.message(draft_text)
    print draft_text

Last edited by fc2008; 07-18-2008 at 08:44 AM.
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
retrieve Object names Geoffrey Vizard 11 12-11-2009 04:26 AM
Child Object Rotation paulgoldberg Vizard 5 09-05-2006 11:33 AM
when collision mode is on, can i "turn it off" for an individual object? Vdoug Vizard 1 09-22-2005 12:14 PM
rotate to object jargon Vizard 1 08-08-2005 12:20 PM
Moving view with object Xliben Vizard 2 07-25-2005 05:36 PM


All times are GMT -7. The time now is 03:09 AM.


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