WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 03-15-2009, 09:13 PM
nlfrnassimi nlfrnassimi is offline
Member
 
Join Date: Feb 2009
Posts: 37
physics

Hi again, I'm doing a project and I'll need a lot of help.

I want an object to move in y axis and define a hotspot for it, then have another object which moves in x axis and at a point (hotspot) they will meet and collide.

I've been able to make them collide but my hotspot starts when I use my mouse, I want when my first ball reaches the hotspot the second ball goes to that position and collide.

I've done some things but it doesn't seem professional.

Please help me

here is my code:

Code:
import viz

viz.go()

viz.clearcolor( viz.GRAY )

viz.phys.enable()
viz.phys.setGravity(0,0,0)

ground = viz.add('tut_ground.wrl')
ground.disable(viz.PHYSICS)


ball1 = viz.add( 'ball.wrl')
ball1StartPos = ball1.translate(0,0.2,9)
ball1.collideSphere()

ball2 = viz.add( 'ball.wrl' )
ball2StartPos = ball2.translate(4,0.2,9)
ball2.collideSphere()

BALL = 1

def onHotspot(id,x,y,z):
	if id == BALL:
		ball1.applyForce( dir = [ 0, 0, 1 ], duration=0.01, pos = ball2StartPos )
		ball2.applyForce( dir = [ -1, 0, 0 ], duration=0.1, pos = ball1StartPos )

#def animation ():
#	
#	ball1.applyForce( dir = [ 0, 0, 1 ], duration=0.01, pos = ball2StartPos )
#	ball2.applyForce( dir = [ -1, 0, 0 ], duration=0.1, pos = ball1StartPos )
#	
#animation()

viz.callback(viz.HOTSPOT_EVENT,onHotspot)
#Attach a hotspot to the duck.
ball1.starthotspot(BALL, viz.CIRCLE_HOTSPOT_IN, 0,0,20)


viz.MainView.translate( 0, 2, -10 )
Reply With Quote
  #2  
Old 03-16-2009, 10:59 AM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
A hotspot is triggered when the viewpoint enters or leaves it. Here you have a hotspot that will be triggered when you enter it
Code:
ball1.starthotspot(BALL, viz.CIRCLE_HOTSPOT_IN, 0,0,20)
The radius of this circular hotspot is 20 meters so the viewpoint triggers it from the start.

It seems like a hotspot is not what you want here. Get the position of the first ball within a timer function and when it's at the position you want move the second ball towards it.
Reply With Quote
  #3  
Old 03-16-2009, 10:32 PM
nlfrnassimi nlfrnassimi is offline
Member
 
Join Date: Feb 2009
Posts: 37
Thanks for your help, but what I want is something like proximity, instead of view entering a hotspot I want my object to enter that section and another action take place. Is there anything like proximity in vizard?
Reply With Quote
  #4  
Old 03-18-2009, 08:47 PM
nlfrnassimi nlfrnassimi is offline
Member
 
Join Date: Feb 2009
Posts: 37
Question Help With Physics

please help me with the above problem
Reply With Quote
Reply


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
RE:Slide Joints and physics optimization nige777 Vizard 4 06-22-2009 04:21 PM
physics engine exception ad_astra Vizard 3 03-25-2009 11:31 AM
Physics and Haptics jalvarez Vizard 3 07-16-2008 03:03 PM
collision with physics enabled joeymax Vizard 2 04-17-2008 02:49 PM
Physics engine question adimov Vizard 2 07-22-2004 12:33 PM


All times are GMT -7. The time now is 07:06 PM.


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