WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 10-25-2006, 08:13 AM
Chandan Chandan is offline
Member
 
Join Date: Oct 2006
Posts: 6
Unhappy error while setting material properties.

Hi,

I get the following error while trying to set material attributes like sethardness()

the function is called as follows an example code:

import viz
import vizmat

viz.go()

viz.translate(viz.HEAD_POS,0,5,-10)
viz.lookat(0,0,0)

ground = viz.add('ground.wrl')
ground.collideplane()

ball = viz.add('ball.wrl')
ball.collidesphere()
ball.sethardness(0.1)


ball.reset()
ground.reset()

ball.translate(0,10,0)
ball.scale(0.6,0.6,0.6)

viz.phys.enable()


When I try to run this code, I get the following error:


Scaling image 'worlds/yellow.GIF' from (640,400) to (512,512)
Traceback (most recent call last):
File "<string>", line 11, in ?
File "myproj.py", line 14, in ?
ball.sethardness(0.1)
AttributeError: 'VizChild' object has no attribute 'sethardness'
Scaling image 'worlds/blue.GIF' from (640,400) to (512,512)
Reply With Quote
  #2  
Old 10-25-2006, 09:31 AM
Gladsomebeast Gladsomebeast is offline
Member
 
Join Date: Mar 2005
Location: Isla Vizta, CA
Posts: 397
setHardness is a method of VizPhysicsShape, not of VizNode/VizChild. Check the example again. In addition, the case of the letters in the method mater.

Code:
ball = viz.add('ball.wrl')
shape = ball.collideBox()
shape.setHardness(.5)
As we see here, setHardness is called on the object that returns from the collideBox() function. This is because you can have multiple collide shapes assosated with one node, such as the ball.

Check out this code to see multiple collide shapes:

Code:
box = viz.add('box.wrl')
box.collideBox()

ball = box.add('ball.wrl')
ball.scale(2,2,2)
ball.translate(0.5,-0.5,0)
box.collideSphere(pos=(0.5,-0.5,0))
__________________
Paul Elliott
WorldViz LLC
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


All times are GMT -7. The time now is 08:22 PM.


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