Volumes Of Fun
http://www.volumesoffun.com/phpBB3/

Raycast on scaled mesh.
http://www.volumesoffun.com/phpBB3/viewtopic.php?f=14&t=565
Page 1 of 1

Author:  Neomex [ Sun Jan 05, 2014 5:19 pm ]
Post subject:  Raycast on scaled mesh.

I want to use PolyVox raycasting, but in my project I've scaled my mesh.

Increasing block side lenght to max in simple volume constructor doesn't seem to change anything.

Can't find any other method on changing block size. Are there any other solutions?

Futhermore, it says in docs that it hasn't been tested with marching cubes.

I think one of the solution would be to use custom raycasting against mesh, then somehow translate resulting point down, and then check if it is inside a voxel, but this way I'd have to loop through entire volume.

---

How can we determite where did the ray hit something? Not sure about purpose of callback funtion.

Author:  David Williams [ Mon Jan 06, 2014 11:56 am ]
Post subject:  Re: Raycast on scaled mesh.

PolyVox volumes have no concept of scale, translation, or rotation - they are basically just arrays of numbers representing the voxel values. I guess you can consider them to exist in their own space (we call this 'volume space' in Cubiquity) where voxel (0,0,0) is at position (0,0,0) and voxel x, y, z) is at position (x,y,z). Raycasting should be performed in this same space.

Of course, you may well want to transform volumes in your application, and this can be done by applying transformations to the meshes using your graphics/game engine. You would essentially be defining a mapping from volume space to world space, and if you then want to perform picking with a ray provided by your engine in world space then you will need to convert it back to volume space first.

Actually I've been working on this in Cubiqity recently and it does work... though I haven't finished yet.

Neomex wrote:
Futhermore, it says in docs that it hasn't been tested with marching cubes.


I think it does work (we're using it in Cubiquity). Test it without scaling etc, first though.

Neomex wrote:
I think one of the solution would be to use custom raycasting against mesh...


Yes, this should also be possible.

Neomex wrote:
and then check if it is inside a voxel, but this way I'd have to loop through entire volume.


I don't see why you'd need to loop though the volume - if the intersection point is (x,y,z) then by definition the voxel is also the one at position (x,y,z). Unless I'm misunderstanding your question?

Neomex wrote:
How can we determite where did the ray hit something? Not sure about purpose of callback funtion.


Rather than using the rayasting functions you might want to use the picking functions (actually these are the ones which we use in Cubiquity I think). They wrap the same functionality with a slightly simplified/clearer interface: https://bitbucket.org/volumesoffun/poly ... at=develop

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/