WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 03-17-2009, 01:30 AM
nlfrnassimi nlfrnassimi is offline
Member
 
Join Date: Feb 2009
Posts: 37
hotspot

I have created a character and a view is connected to it. There is a hot spot defined for the car. When view gets close a page appears. How can I define that when it comes out of the hotspot the page disappears again?

here is the code:

Code:
import viz

viz.go()

viz.clearcolor(0.5,0.5,1) 
  
MOVE_SPEED = 5 # how fast the viewpoint move
TURN_SPEED = 60 # how fast the view point rotate

viz.add('tut_ground.wrl')
char = viz.add('vcc_male.cfg') 
char.state(1)

intro = viz.add('front.3Ds')
intro.translate(0,0,100)
intro.visible(viz.OFF)

view = viz.MainView
view.setPosition(0,1.7,0)
car = viz.add('mini.osgx')
car.setPosition(5,0,10)

def mytimer(num):
	if viz.iskeydown(viz.KEY_DOWN):
		view.move(0,0,-MOVE_SPEED*viz.elapsed(),viz.BODY_ORI)
	elif viz.iskeydown(viz.KEY_UP):
		view.move(0,0,MOVE_SPEED*viz.elapsed(),viz.BODY_ORI)
	elif viz.iskeydown(viz.KEY_RIGHT):
		view.rotate(0,1,0,TURN_SPEED*viz.elapsed(),viz.BODY_ORI,viz.REL_PARENT)
	elif viz.iskeydown(viz.KEY_LEFT):
		view.rotate(0,1,0,-TURN_SPEED*viz.elapsed(),viz.BODY_ORI,viz.REL_PARENT)
	updatechar()		
viz.callback(viz.TIMER_EVENT,mytimer) 

viz.starttimer(0,0.01,viz.FOREVER)

def updatechar():

#translate the character to the position of the viewpoint
#  char.translate(view.get(viz.HEAD_POS)) 
#rotate the character to the same orientation as the BODY_ORI.
  char.rotate(view.get(viz.BODY_AXISANGLE))
#move the character beside the view.
  char.translate(1,0,0,viz.REL_LOCAL) #viz.REL_LOCAL. This tells vizard to translate the car relative to its local coordinate system (i.e. relative to the direction the car is facing).


def mousemove(e):
	#gets the Euler angle rotation of the HEAD_ORI
	euler = view.get(viz.HEAD_EULER)
	#adding the x movement of the mouse to the current yaw(we multiply the x movement by 0.1.  This is to decrease the sensitivity of the movement)
	euler[0] += e.dx*0.1
	#adds the y movement of the mouse to the current pitch. We need to negate the value since a positive pitch value means rotating down, but moving the mouse down means having a negative y movement. 
	euler[1] += -e.dy*0.1
	#clamping the pitch value between -90 and 90, since we don't want to let the user look down or up so much that they end up upside down.
	euler[1] = viz.clamp(euler[1],-90.0,90.0)
	#rotating the HEAD_ORI of the viewpoint by the new euler angle rotation
	view.rotate(euler,viz.HEAD_ORI) 
	
viz.callback(viz.MOUSE_MOVE_EVENT,mousemove)
#Turn off built in  mouse
viz.setMouseOverride()
#Hide cursor
viz.cursor(viz.OFF) 

def mousedown(button):
	if button == viz.MOUSEBUTTON_LEFT:
		view.reset(viz.HEAD_ORI)

	elif button == viz.MOUSEBUTTON_RIGHT:
		view.reset(viz.BODY_ORI|viz.HEAD_POS)
	updatechar()

viz.callback(viz.MOUSEBUTTON_EVENT,mousedown)

VIEW = 1

def onHotspot (id,x,y,z):
	if id == VIEW :
		intro.visible(viz.ON)
	else :
		intro.visible(viz.OFF)

#Callback the hotspot event.
viz.callback(viz.HOTSPOT_EVENT,onHotspot)
#Attach a hotspot to the duck.
car.starthotspot(VIEW, viz.CIRCLE_HOTSPOT_IN, 5,0,10)
Reply With Quote
  #2  
Old 03-17-2009, 01:34 AM
nlfrnassimi nlfrnassimi is offline
Member
 
Join Date: Feb 2009
Posts: 37
can any one please tell me how to do the same thing by using getPOsition instead of hotspot?
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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
physics nlfrnassimi Vizard 3 03-18-2009 09:47 PM
Hotspots and Video eirc Vizard 3 01-29-2008 09:58 AM
Coldspots? codexter Vizard 1 02-20-2007 04:11 PM
triggering actions on proximity exhale Vizard 3 03-14-2005 03:26 AM
A hotspot id of -1 will never trigger. jrodman Vizard 1 01-27-2004 04:22 PM


All times are GMT -7. The time now is 02:24 PM.


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