how to model an open tin can?

7 views
Skip to first unread message

jordi polo

unread,
Jun 26, 2009, 11:34:22 AM6/26/09
to ode-users

I have to simulate an empty can, something like this:
http://www.istockphoto.com/file_thumbview_approve/4717111/2/istockphoto_4717111-empty-metallic-open-can-3.jpg
Yes, been empty and open is important, is all about a ball entering
there.

This kind of object looks like horrible to simulate. So I wonder what
may give better results:

- Triangle mesh
- Convex object (how to use that I dont have it any clear)
- Composing other objects, one cylinder and 16 planes or something
like that ?

If there is any other easier or not manual (setting points by hand)
way of doing it, I will be more that grateful to hear it.



Daniel K. O.

unread,
Jun 26, 2009, 12:29:01 PM6/26/09
to ode-...@googlegroups.com
2009/6/26 jordi polo <mum...@gmail.com>:

> I have to simulate an empty can, something like this:
> http://www.istockphoto.com/file_thumbview_approve/4717111/2/istockphoto_4717111-empty-metallic-open-can-3.jpg
> Yes, been empty and open is important, is all about a ball entering
> there.
>
> This kind of object looks like horrible to simulate. So I wonder what
> may give better results:

Simulation itself is trivial. Detecting collisions is the hard part.

But, if you restrict the scope, it might be doable to do your own
collision tests. For example, if the only objects interacting with the
can are spheres and a ground plane, you probably can derive the
intersection tests with easy to moderate effort.

Otherwise, use a trimesh.


--
Daniel K. O.
"The only way to succeed is to build success yourself"

jordi polo

unread,
Jun 26, 2009, 12:40:20 PM6/26/09
to ode-users

Using trimesh I still need to write my own collision code?

Yes it will only have an sphere as collistion object, it is attached
(with fixed joint) to a robot that tries to catch the ball with the
tin can.




On Jun 27, 1:29 am, "Daniel K. O." <danielko.lis...@gmail.com> wrote:
> 2009/6/26 jordi polo <mumi...@gmail.com>:
>
> > I have to simulate an empty can, something like this:
> >http://www.istockphoto.com/file_thumbview_approve/4717111/2/istockpho...

Daniel K. O.

unread,
Jun 26, 2009, 12:52:08 PM6/26/09
to ode-...@googlegroups.com
2009/6/26 jordi polo <mum...@gmail.com>:

> Using trimesh I still need to write my own collision code?

No.

Martijn Buijs

unread,
Jun 27, 2009, 7:54:55 AM6/27/09
to ode-...@googlegroups.com
jordi polo wrote:
>
> Using trimesh I still need to write my own collision code?
>
> Yes it will only have an sphere as collistion object, it is attached
> (with fixed joint) to a robot that tries to catch the ball with the
> tin can.

If the 'roundness' of the tin can walls is not absolutely critical to the simulation, use trimesh.
Sphere-trimesh is pretty robust in ODE. It is possible for objects to 'tunnel' through trimesh
triangles though, this may happen if the objects is moving very fast or the step size is very large.
ODE does 'discrete' collision detection, not 'continuous'. Usually this is not a problem though.

/Martijn

jordi polo

unread,
Jun 28, 2009, 11:00:39 AM6/28/09
to ode-users

I guess I have reinvented the wheel but the following script will
transform a blender model exported as COLLADA with the "triangles"
option on to a .h readable by dGeomTriMeshDataBuildSingle.


#!/usr/bin/ruby
require 'rubygems'
require 'xmlsimple'

Collada_file = ARGV[0] ||= "untitled.dae"
H_file = ARGV[1] ||= "model.h"

model = XmlSimple.xml_in(Collada_file)

indices = model['library_geometries'][0]['geometry'][0]['mesh'][0]
['triangles'][0]['p'][0]
vertices = model['library_geometries'][0]['geometry'][0]['mesh'][0]
['source'][0]['float_array'][0]['content']
indices_data = indices.split(' ')
vertices_data = vertices.split(' ')

File.open(H_file, 'w') do |f|

f.write("const int VertexCount = " + (vertices_data.count / 3).to_s
+ ";\n\n")
f.write("const int IndexCount = " + indices_data.count.to_s + ";\n
\n")
f.write("float Vertices[VertexCount * 3] = {")
count = 0
vertices_data.each do |v|
if (count % 3 == 0)
f.write("\n")
end
data = v.to_f
f.write data.to_s
f.write ', ' unless (count + 1 ) == vertices_data.count
count += 1
end
f.write("};\n\n\n")


f.write("dTriIndex Indices[IndexCount / 3][3] = {")
count = 0
indices_data.each do |v|
if (count % 3 == 0)
f.write("\n{")
end
f.write v
if (count % 3 == 2)
f.write( "}")
end
f.write(', ') unless (count + 1) == indices_data.count
count += 1
end
f.write("};\n\n\n")
end

pebble

unread,
Jun 29, 2009, 2:22:51 AM6/29/09
to ode-users
I extended the cylinder class with an inner radius (makes hollow
cylinder possible) and modified the cylinder <-> sphere collider.
Probably better to use existing trimesh functionality in your case
though.

Stein

On Jun 26, 5:34 pm, jordi polo <mumi...@gmail.com> wrote:
> I have to simulate an empty can, something like this:http://www.istockphoto.com/file_thumbview_approve/4717111/2/istockpho...
Reply all
Reply to author
Forward
0 new messages