g3n/engine

Collision detection angle calculation

Semj0n opened this issue · 3 comments

Hi,

i'd like to calc an angle of an vector relative to a box.
is there a way to split a box into faces (or planes) to check for intersection and by calc the norm vector of the plane beeing able to calc the angle of inclination?

Any documentation available on this?

You'd need to do all the intersection calculations manually.
Once you instantiate a Box, then you know exactly the sizes and positions of the face planes (they are arguments for the box creation function).
What are you trying to accomplish?

Hi,

i'd like to use the engine for optical raytracing.
For that i need to get the faces of the object and test the triangulated mesh for intersection ...

i tried:
box := geometry.NewSegmentedCube(1, 2)
box.ReadFaces(func(vA, vB, vC math32.Vector3) bool {
for _,r := range new_rays{
var loc *math32.Vector3
found := r.IntersectTriangle(&vA,&vB,&vC,true,loc)
if found{
log.Println(vA,vB,vC,loc )
}
}
return true
})

but it just run one... i was expecting to get all vertices?

How to accomplish that ?
Best Regards,
Semjon

You need to return false to continue looping over the faces. Returning true halts the loop.