lo-th / Oimo.js

Lightweight 3d physics engine for javascript
http://lo-th.github.io/Oimo.js
MIT License
3.05k stars 301 forks source link

adding a hollow cylinder as a body? #12

Closed remoe closed 10 years ago

remoe commented 10 years ago

Hi

I have a bowl as a 3D model and try to add a hollow cylinder as a collision wall on the side. Is this possible? I don't want to add multiple boxes on the side of the bowl. Here are the sample:

image

lo-th commented 10 years ago

yes is possible with the rev version just add static cylinder

remoe commented 10 years ago

thanks, but sorry, I don't get it to work when the other objects are IN the cylinder. They throw out.

lo-th commented 10 years ago

how yes, cylinder only work outside not in the cylinder. you have to use fixe box , you can use many box if fixed. is easy to make simple script for that.

remoe commented 10 years ago

Ok, thanks.

remoe commented 10 years ago

Here is a quick and dirty sample to create some boxes around a circle:

           var r=10.7;
           var box_angle = 20.0;
           var l = Math.abs(r * Math.cos(box_angle)) ;

           for(var a = 0.0; a < 360; a+=box_angle) {
               var a_ = a * (Math.PI/180);
               var x = r * Math.cos(a_);
               var y = r * Math.sin(a_);
               physics.add_static_box(l,2.0,100,[x,y,0],[0,0,a+90]);
           }