Vertex check inside a:Sphere,Cone,Cilinder ...
I need the maths for all those 3 things...for lightmaps...what I have now checks only
inside a cube and I couldn`t get around cheking inside a sphere...
Oh and..by the way...what do you think of this lightmap pic ?
http://www.geocities.com/cippyboy_7/lightmap.jpg
PS:It uses no multitexturing,it`s computed at runtime and it`s used per vertex .
Relative Games - My apps
I haven''t gotten to that stuff yet, sorry.
As for the pic, I like the effect, first-person RPG quality.
As for the pic, I like the effect, first-person RPG quality.
Bookmark this, for it is your friend when it comes to 3d intersections:
http://www.magic-software.com/Intersection3D.html
http://www.magic-software.com/Intersection3D.html
I got around a sphere...
It was like:
float D=sqrt(V.x*V.x+V.y*V.y+V.z*V.z);
if (D//Does Range mean anything ? I wrote: i f ( D < R a n g e )
return true;
for a cilinder I would do a x and z circle...check distance and then for y only check if it is on it`s bounds...
For teh Cone I would do as for cilinder and restrict it more a little bit...
[edited by - cippyboy on May 12, 2003 7:59:12 AM]
It was like:
float D=sqrt(V.x*V.x+V.y*V.y+V.z*V.z);
if (D
return true;
for a cilinder I would do a x and z circle...check distance and then for y only check if it is on it`s bounds...
For teh Cone I would do as for cilinder and restrict it more a little bit...
[edited by - cippyboy on May 12, 2003 7:59:12 AM]
Relative Games - My apps
I checked that site out...it only has some calculations for different stuff regarding collisions...collsiion of a sphere with a line/triangle/cone/cylinder and all other shit...
I need to see if a point/vertex is inside one!!!not collision detection with anything like that...I`m probably not making any sense huh ? I did this(http://www.geocities.com/cippyboy7/lightmap.jpg) with that sphere thing..now I wanna do upgrades and stuff to ... cone, and more after raytracing if I could do it...by the way any idea for how I could do any kind of stuff per-pixel ? like pixel shaders do...?
I need to see if a point/vertex is inside one!!!not collision detection with anything like that...I`m probably not making any sense huh ? I did this(http://www.geocities.com/cippyboy7/lightmap.jpg) with that sphere thing..now I wanna do upgrades and stuff to ... cone, and more after raytracing if I could do it...by the way any idea for how I could do any kind of stuff per-pixel ? like pixel shaders do...?
Relative Games - My apps
Well, for the sphere it is very easy... You have the radius of the sphere, so check if the position of the vertex is less than the sphere''s radius.
if ((vertex.position < sphere.position + sphere.radius) && (vertex.position > sphere.position - sphere.radius))
PointInSphere = true;
Or something like that.. I''m sorry, but I''m very tired right now, so I''m not thinking right, there might be errors in what I wrote.
Hope this helps!
if ((vertex.position < sphere.position + sphere.radius) && (vertex.position > sphere.position - sphere.radius))
PointInSphere = true;
Or something like that.. I''m sorry, but I''m very tired right now, so I''m not thinking right, there might be errors in what I wrote.
Hope this helps!
off my head,
using vector notation, (ie, dot products, etc)
where p is the centre point of the object, and v is the vertex. r is the radius, a is the angle
sphere:
if ( (p -v ) . (p - v ) < r * r )
collision;
box:
already mentioned,
cone:
assumping p is the centre vertex of the cone, and d is the direction down the centre of the cone. d must be length of 1. D is the length of the cone.
if ( ( acos( ( (v -p ) / (|| (p - v ) ||) . d ) ) < a ) && ( d . (v - p ) < D )
collision;
[edit]
it would make a lot of sense to remove the acos and simply precompute cos(D ). be a good deal simpler.
[edit2]
It could probably actually be done without the normalization too... hmm
thats off my head so no guarentees the maths is right.
| - Project-X - my mega project.. close...
- | - adDeath - | - email me - |
[edited by - RipTorn on May 13, 2003 6:01:33 AM]
using vector notation, (ie, dot products, etc)
where p is the centre point of the object, and v is the vertex. r is the radius, a is the angle
sphere:
if ( (p -v ) . (p - v ) < r * r )
collision;
box:
already mentioned,
cone:
assumping p is the centre vertex of the cone, and d is the direction down the centre of the cone. d must be length of 1. D is the length of the cone.
if ( ( acos( ( (v -p ) / (|| (p - v ) ||) . d ) ) < a ) && ( d . (v - p ) < D )
collision;
[edit]
it would make a lot of sense to remove the acos and simply precompute cos(D ). be a good deal simpler.
[edit2]
It could probably actually be done without the normalization too... hmm
thats off my head so no guarentees the maths is right.
| - Project-X - my mega project.. close...

[edited by - RipTorn on May 13, 2003 6:01:33 AM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement