View Full Version : Early black box preview of ray-mesh collisions
Petr Schreiber
19-10-2008, 00:01
Dear all,
as you know I am writing library, which would allow us to cast rays against various objects.
The release date is somewhere in fog :), but to not torture you too much I attach executable of my thinBasic script using the early library.
Hope you will like it. What I must work on now is speed speed speed.
Current performance is like 1 ray colliding with 1 200 000 polygons takes second to calculate.
That is far from ideal, as it means about 20 000 polygons to get 60FPS ... and that is for one ray.
But I still have lot of space for optimization, don't worry :)
Hope the demo will entertain you.
Petr
ErosOlmi
19-10-2008, 00:32
All seems working fine here.
What is this application doing in reality? You know, I'm quite bad in understanding all those 3D complexities.
Ciao
Eros
Petr Schreiber
19-10-2008, 00:35
Hi Eros,
- set of triangles ( 3d object ) is passed to module
- I create random rays around the object, pointing to 0,0,0
- I put point at intersection of ray and the object
That is all :) You can simply cast a ray on mesh and ask for distance or point of collision.
I should have explained better in first post, I am now half alive, half sleeping :)
Petr
ErosOlmi
19-10-2008, 00:37
:o now I got it.
It is like a a laser hitting a surface and at the intersection point you see the light.
Michael Hartlef
19-10-2008, 00:40
Nice one. Its a dino but I don't know it's name. :)
Petr Schreiber
19-10-2008, 00:48
Yes Eros,
exactly :)
Mike, it is triceratops, but that is not important :)
Good thing is I got it working, now I have to add the boxes and some nice external interface.
I started to design module in different way, less hacky, more maintainable ... but still fast.
The speed problem is not caused by the general design but by the function itself.
Once I get ray-box working, I will organize triangle groups in sub spaces, first test for box hit and then for triangles only when needed.
Petr
Hey Petr, thanks a great start!
About your idea for sub spaces, would that be octrees that I keep reading about?
Michael Clease
19-10-2008, 09:33
http://www.permadi.com/tutorial/raycast/index.html
I am not sure about these
http://www.daimi.au.dk/~trier/?page_id=98
http://www.vrvis.at/via/resources/PR-HScharsach-1/index.htm#source
and this is quite fun http://lab.zupko.info/RayCasting/
Petr Schreiber
19-10-2008, 11:29
Hi Michael,
thanks for those links, I will check them in more depth.
Some of them have fantastic results, but they need quite modern hardware and are GPU based.
I will do classic safe CPU routines first, and then jump for this.
The cow is nice :)
Kent, I will try to do octree, as long is it will not be slowing down the calculation :) But I was thinking of it. Must do some tests.
Petr