WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   How can I apply physics to Donut or Ring? (https://forum.worldviz.com/showthread.php?t=4271)

goro 06-18-2012 01:41 AM

How can I apply physics to Donut or Ring?
 
In Vizard we have collide shapes for our physical objects
collideBox
collideSphere
collideCapsule
collideMesh
collidePlane


collideBox, collideSphere & collideCapsule can get affected by dynamic forces like gravity but collideMesh objects are unaffected by forces and can only provide a solid collision area for other objects. I want inner side of donut or ring too to have physical properties. Can you help me with the logic to get this thing done?

farshizzo 06-27-2012 01:32 PM

There is no built-in torus shape in the physics engine, but you can approximate one using multiple sphere shapes. Here is a sample script that simulates a torus using 18 spheres:
Code:

import viz
import math
import vizact
import vizshape

viz.go()

viz.phys.enable()

ground = viz.addChild('ground.osgb')
ground.collidePlane()

RADIUS = 1.0
TUBE_RADIUS = 0.5

torus = vizshape.addTorus(radius=RADIUS,tubeRadius=TUBE_RADIUS)
for deg in range(0,360,20):
        x = math.sin(viz.radians(deg)) * RADIUS
        z = math.cos(viz.radians(deg)) * RADIUS
        torus.collideSphere(radius=TUBE_RADIUS,pos=(x,0,z))

ball = vizshape.addSphere(radius=0.6)
ball.collideSphere()

def Reset():
        torus.setPosition([0,2,10])
        ball.setPosition([0.6,5,10.6])

vizact.onkeydown('r',Reset)

Reset()



All times are GMT -7. The time now is 07:28 AM.

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