WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 08-30-2011, 03:40 AM
andrewjworz andrewjworz is offline
Member
 
Join Date: Apr 2011
Posts: 11
Collision detection with InfiniteTerrain Generator

I am wondering if there is anyway to activate collision detection with the infinite terrain generator (InfiniteTerrain.dlc). Given below is a simple example of code, and if you copy/paste and run it in vizard you will see that the ball falls straight through the infinite plane without colliding with it. Anyone Have any suggestions?

import viz

viz.go()
#Turn on the physics engine
viz.phys.enable()

viz.MainView.setPosition([0,180,0])
viz.MainView.setEuler( [0,40,0] )

viz.MainView.getHeadLight().disable()
#add sun-like directional light
l = viz.addLight()
l.position(0, 1, -.2, 0) #sets light direction

terrain = viz.add('InfiniteTerrain.dlc',1,'300',6,7,15000,0. 001)
grass = viz.addTexture('gb_noise.jpg')
terrain.texture(grass)
terrain.collideMesh()

ball = viz.add('ball.wrl')
ball.collideBox(density=5)
ball.setScale([50,50,50])
ball.setPosition([0,100,100])[/COLOR]
Reply With Quote
  #2  
Old 08-30-2011, 04:13 AM
andrewjworz andrewjworz is offline
Member
 
Join Date: Apr 2011
Posts: 11
Also, I am trying to have the view point "walk" along the surface of the terrain generated by the InfiniteTerrain.dlc at a fixed height (let's say, the height of an avatar). I would like to move in the x and z directions with the arrows on the keyboard, while the viewpoint adjusts to the proper height about the terrain. Does anyone have any idea how to do this? Given below is the viewpoint controls that I have been using.

# Viewpoint keyboard controls
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%

## Turn off built-in mouse navigation
#viz.mouse(viz.OFF)
## Hide mouse cursor
#viz.mouse.setVisible(False)

MOVE_SPEED = 19
TURN_SPEED = 60

male = viz.addAvatar( 'vcc_male.cfg' )
male.scale([10,10,10])
#male.collideCapsule()

viz.MainView.setPosition(0,terrainmaker.terrainfun c(0,0)+17,0)
viz.MainView.setEuler([0,0,0])
## Extract the main viewpoint
view = viz.MainView

## Make function which calls back for keyboard event
pos_init = view.getPosition()

def updatemale():
if viz.key.isDown('d'):
view.move([0,-MOVE_SPEED*viz.elapsed(),0],viz.BODY_ORI)
if viz.key.isDown('f'):
view.move([0,MOVE_SPEED*viz.elapsed(),0],viz.BODY_ORI)
if viz.key.isDown(viz.KEY_UP):
male.state(2)
view.move([0,0,MOVE_SPEED*viz.elapsed()],viz.BODY_ORI)
if viz.key.isDown(viz.KEY_RIGHT):
view.setEuler([TURN_SPEED*viz.elapsed(),0,0],viz.BODY_ORI,viz.REL_PARENT)
elif viz.key.isDown(viz.KEY_LEFT):
view.setEuler([-TURN_SPEED*viz.elapsed(),0,0],viz.BODY_ORI,viz.REL_PARENT)

elif viz.key.isDown(viz.KEY_DOWN):
male.state(2)
view.move([0,0,-MOVE_SPEED*viz.elapsed()],viz.BODY_ORI)
if viz.key.isDown(viz.KEY_RIGHT):
view.setEuler([TURN_SPEED*viz.elapsed(),0,0],viz.BODY_ORI,viz.REL_PARENT)
elif viz.key.isDown(viz.KEY_LEFT):
view.setEuler([-TURN_SPEED*viz.elapsed(),0,0],viz.BODY_ORI,viz.REL_PARENT)

elif viz.key.isDown(viz.KEY_RIGHT):
view.setEuler([TURN_SPEED*viz.elapsed(),0,0],viz.BODY_ORI,viz.REL_PARENT)
if viz.key.isDown(viz.KEY_UP):
male.state(2)
view.move([0,0,MOVE_SPEED*viz.elapsed()],viz.BODY_ORI)
elif viz.key.isDown(viz.KEY_DOWN):
male.state(2)
view.move([0,0,-MOVE_SPEED*viz.elapsed()],viz.BODY_ORI)
elif viz.key.isDown(viz.KEY_LEFT):
view.setEuler([-TURN_SPEED*viz.elapsed(),0,0],viz.BODY_ORI,viz.REL_PARENT)
if viz.key.isDown(viz.KEY_UP):
male.state(2)
view.move([0,0,MOVE_SPEED*viz.elapsed()],viz.BODY_ORI)
elif viz.key.isDown(viz.KEY_DOWN):
male.state(2)
view.move([0,0,-MOVE_SPEED*viz.elapsed()],viz.BODY_ORI)

# Attach the male to the viewpoint BODY_ORI
male.setPosition(view.getPosition())
male.setEuler(view.getEuler(viz.BODY_ORI))
male.setPosition([0,0,25],viz.REL_LOCAL) #[0.35,-1.7,-0.13]
Reply With Quote
  #3  
Old 08-30-2011, 05:19 AM
nige777 nige777 is offline
Member
 
Join Date: Nov 2007
Location: UK
Posts: 78
Hi Andrew,

The walkTo function accepts an object (node) as the 'y' argument allowing the avatar to follow it precisely - as explained in this post:

http://forum.worldviz.com/showthread...ghlight=walkTo
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
Collision detection Moh200jo Vizard 1 01-27-2010 07:39 AM
Collision detection with specific models just alex Vizard 1 02-06-2009 11:02 AM
Collision Detection and Nearest Point to Probe xabbu Vizard 2 01-06-2009 03:01 AM
Collision detection with haptic pen mjabon Vizard 3 01-17-2008 06:35 PM
Walking avatars --> collision detection? sjroorda Vizard 3 10-13-2005 04:47 AM


All times are GMT -7. The time now is 05:31 PM.


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