General Category > General Anim8or Forum

WEEHEEEE oh, oh wait its dead, I thought it was dancing (CRE8OR NOTICE)

<< < (38/58) > >>

cre8orexpert:
Lol (i hate you :P), i don't know of this will change anything, but try normalizing the ray direction (Ray2 in your code dude). Also PM me with the code you're using to build the ray.

cooldude234:
I'm just using two points for my ray, as shown in my code. From that you can could make a ray and normal direction from it if you really wanted to.
So all I'm doing to do build the ray is define two points in 3 dimensions (x,y,z), those two points form a line, or in this case a ray.


--- Quote from: cre8orexpert on February 23, 2013, 05:39:24 pm ---try normalizing the ray direction

--- End quote ---
That wont do any good, because then you'd be colliding with stuff way after you went through it.

cre8orexpert:
Got it!. I'll take another look here, it would help a lot to have a compiler :P.

Thanos:
When you say you don't understand half of my code, you mean the first half (finding the collision point) or the second half (checking if it's in the triangle)?

Also, did you try rti v3 and it still doesn't work? Because I think it works ok for me (see the example file in the zip).

I'm checking your code now.

EDIT: See image, red are what I call 'points at corners', blue what I call 'points at midways' (actually called midpoints  ::) )
...and, what I call 'internal product' is uh, the dot product.

EDIT 2: Ok, I think I start to see what is different between the codes. Here:

--- Code: --- if ( (Dist1 * Dist2) >= 0.0f)
{
// line doesn't cross the triangle.

--- End code ---
I thought you meant that the two points define an infinite line. It now seems you meant just the line part between them, right?

EDIT 3: Wait a minute... you don't have to invert x,z, do you? I think it should work without problem anyway.
Can you give me an input to test? (one you know it doesn't work)

cooldude234:

--- Quote from: Thanos on February 24, 2013, 06:00:18 am ---When you say you don't understand half of my code, you mean the first half (finding the collision point) or the second half (checking if it's in the triangle)?
--- End quote ---
I refer to all of it, although I am using my code for finding the collision point only because I understand it and I know it works.


--- Quote from: Thanos on February 24, 2013, 06:00:18 am ---Also, did you try rti v3 and it still doesn't work? Because I think it works ok for me (see the example file in the zip).
--- End quote ---
Yes I did try it, still doesn't work.


--- Quote from: Thanos on February 24, 2013, 06:00:18 am ---I thought you meant that the two points define an infinite line. It now seems you meant just the line part between them, right?
--- End quote ---
Well I'm getting the collision point on a line that is formed between two points (so I can do area ray casting, I.e. a ray can be "fired" and take time to reach from one end of the world to the other by moving)
But that shouldn't affect checking to see if the collision point belongs inside the triangle should it?


--- Quote from: Thanos on February 24, 2013, 06:00:18 am ---EDIT 3: Wait a minute... you don't have to invert x,z, do you? I think it should work without problem anyway.
--- End quote ---
well for some reason I had to invert the x and z because what visually was being shown (the triangle) and where the collision was occurring was on the separate sides from the words origin. However I don't see how that would effect the math, only the outcome.


--- Quote from: Thanos on February 24, 2013, 06:00:18 am ---Can you give me an input to test? (one you know it doesn't work)
--- End quote ---
What do you mean input to test? Like compiled code, like an exe?

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version