Anim8or Community

Please login or register.

Login with username, password and session length
Advanced search  

News:

Ian Ross has just released a book on Anim8or. It's perect for a beginner and a good reference for experienced users. It contains detailed chapters on every aspect, with many examples. Get your own copy here: "Anim8or Tutorial Book"

Pages: 1 ... 11 12 [13] 14 15 ... 20

Author Topic: WEEHEEEE oh, oh wait its dead, I thought it was dancing (CRE8OR NOTICE)  (Read 247080 times)

cre8orexpert

  • Newbie
  • *
  • Posts: 19
  • "Not enough characters"
    • View Profile
Re: WEEHEEEE oh, oh wait its dead, I thought it was dancing (CRE8OR NOTICE)
« Reply #180 on: February 22, 2013, 05:05:39 pm »

Hey dude, it's great to see your engine progressing  ;D. I will start to help you again soon, not so soon, right now i'm studying tcp/udp to able to build multiplayer games (including an online card game, that will certainly be my first completed game, i hope :P). So give your best and don't forget to rest! :D.

Off-topic: I was a bit worried about you, but it looks like both your personality and thinking is intact  ;).
Logged

cooldude234

  • Sr. Member
  • ****
  • Posts: 902
  • You know what I realized, I dont have an avatar :\
    • View Profile
Re: WEEHEEEE oh, oh wait its dead, I thought it was dancing (CRE8OR NOTICE)
« Reply #181 on: February 22, 2013, 09:18:53 pm »

lol, why would you say that, I'm not the one that went missing of the face of the earth :P
Logged
¼

Thanos

  • Full Member
  • ***
  • Posts: 104
  • -.-
    • View Profile
Re: WEEHEEEE oh, oh wait its dead, I thought it was dancing (CRE8OR NOTICE)
« Reply #182 on: February 23, 2013, 10:22:00 am »

RTI V3.
I changed the equations. This solves a lot of bugs, and also gives a simpler code.
If it still makes a bug, give me your input and I'll try to reproduce it.


EDIT 27/2/2013: Another bug. DOH
Removed attachment, look for v4.
« Last Edit: February 27, 2013, 07:49:25 am by Thanos »
Logged

cre8orexpert

  • Newbie
  • *
  • Posts: 19
  • "Not enough characters"
    • View Profile
Re: WEEHEEEE oh, oh wait its dead, I thought it was dancing (CRE8OR NOTICE)
« Reply #183 on: February 23, 2013, 04:07:25 pm »

Looking at the code and equations, it's well written and should work now. In case this doesn't work, you should give a look at how you're constructing the ray ie: converting mouse (window) coords to 3d. Mixing degrees and radians can also lead to errors and wrong output.

PS: I didn't test your code Thanos, i've just formatted my machine and my super 128k dial-down disconnection makes me unable to download a compiler  ;D.
Logged

cooldude234

  • Sr. Member
  • ****
  • Posts: 902
  • You know what I realized, I dont have an avatar :\
    • View Profile
Re: WEEHEEEE oh, oh wait its dead, I thought it was dancing (CRE8OR NOTICE)
« Reply #184 on: February 23, 2013, 04:31:42 pm »

Hey your back cre8oristhe (I'm still going to call you that :D )

Anyways, I sent you my code through PM thanos, also I noticed an error in my code, fixed it and it didn't change anything  ??? (I had    y5 = (Vert2.y+Vert2.y)/2; intead of y5 = (Vert2.y+Vert3.y)/2;)

And I still don't really understand any of this code, like what are the triangles midways?
What is half of this code even doing, I have no clue?

Also I would like to add, that the collision also doesn't work on 90 degree angles as well, it's just less noticeable.
What happens is around the edges of where 2 lines on the triangle meet (at the vertices) you can just go straight through them, but at the center of the triangle you can't.
« Last Edit: February 23, 2013, 04:36:37 pm by cooldude234 »
Logged
¼

cre8orexpert

  • Newbie
  • *
  • Posts: 19
  • "Not enough characters"
    • View Profile
Re: WEEHEEEE oh, oh wait its dead, I thought it was dancing (CRE8OR NOTICE)
« Reply #185 on: February 23, 2013, 05:39:24 pm »

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.
Logged

cooldude234

  • Sr. Member
  • ****
  • Posts: 902
  • You know what I realized, I dont have an avatar :\
    • View Profile
Re: WEEHEEEE oh, oh wait its dead, I thought it was dancing (CRE8OR NOTICE)
« Reply #186 on: February 23, 2013, 05:52:36 pm »

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.

try normalizing the ray direction
That wont do any good, because then you'd be colliding with stuff way after you went through it.
Logged
¼

cre8orexpert

  • Newbie
  • *
  • Posts: 19
  • "Not enough characters"
    • View Profile
Re: WEEHEEEE oh, oh wait its dead, I thought it was dancing (CRE8OR NOTICE)
« Reply #187 on: February 23, 2013, 05:54:47 pm »

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

Thanos

  • Full Member
  • ***
  • Posts: 104
  • -.-
    • View Profile
Re: WEEHEEEE oh, oh wait its dead, I thought it was dancing (CRE8OR NOTICE)
« Reply #188 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)?

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: [Select]
if ( (Dist1 * Dist2) >= 0.0f)
{
// line doesn't cross the triangle.
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)
« Last Edit: February 24, 2013, 07:18:01 am by Thanos »
Logged

cooldude234

  • Sr. Member
  • ****
  • Posts: 902
  • You know what I realized, I dont have an avatar :\
    • View Profile
Re: WEEHEEEE oh, oh wait its dead, I thought it was dancing (CRE8OR NOTICE)
« Reply #189 on: February 24, 2013, 01:18:00 pm »

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)?
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.

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).
Yes I did try it, still doesn't work.

I thought you meant that the two points define an infinite line. It now seems you meant just the line part between them, right?
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?

EDIT 3: Wait a minute... you don't have to invert x,z, do you? I think it should work without problem anyway.
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.

Can you give me an input to test? (one you know it doesn't work)
What do you mean input to test? Like compiled code, like an exe?
Logged
¼

Thanos

  • Full Member
  • ***
  • Posts: 104
  • -.-
    • View Profile
Re: WEEHEEEE oh, oh wait its dead, I thought it was dancing (CRE8OR NOTICE)
« Reply #190 on: February 25, 2013, 05:19:27 am »

What do you mean input to test? Like compiled code, like an exe?

No, no... just a test case that produces wrong results, for example something like, triangle points: (0,0,0), (5,0,0), (0,0,5) line: (1,-1,1), (1,1,1). I can put your input in the debugger and see where it stops working correctly.
Logged

cooldude234

  • Sr. Member
  • ****
  • Posts: 902
  • You know what I realized, I dont have an avatar :\
    • View Profile
Re: WEEHEEEE oh, oh wait its dead, I thought it was dancing (CRE8OR NOTICE)
« Reply #191 on: February 25, 2013, 11:14:44 am »

well I have the vertices of the two triangles at
Quote
   Vertex1.x = 0;
   Vertex1.y = 0;
   Vertex1.z = 0;

   Vertex2.x = 6;
   Vertex2.y = 0;
   Vertex2.z = 0;

   Vertex3.x = 6.3;
   Vertex3.y = 9.1;
   Vertex3.z = 5;

   Vertex12.x = 5;
   Vertex12.y = 0;
   Vertex12.z = 0;

   Vertex22.x = 0;
   Vertex22.y = 0;
   Vertex22.z = 0;

   Vertex32.x = 5;
   Vertex32.y = 0;
   Vertex32.z = -5;

It's failing (like I said earlier) near vertices, it works if your dead on with the triangle but not if your close to the vertices.

EDIT: I would suspect floating point inaccuracies could be the cause, but with the size the each triangle, and considering the precision of a 32 bit floating point (which can store up to 7 digits after the decimal) this cannot be the case.
« Last Edit: February 25, 2013, 01:17:43 pm by cooldude234 »
Logged
¼

Thanos

  • Full Member
  • ***
  • Posts: 104
  • -.-
    • View Profile
Re: WEEHEEEE oh, oh wait its dead, I thought it was dancing (CRE8OR NOTICE)
« Reply #192 on: February 27, 2013, 07:47:58 am »

Oh, oh I found the bug. I'll post a new version once I fix it. Thanks for the input, it helped.

(If you're curious, rti3 code was made to work only with equilateral triangles... [What on earth was I thinking?] Anyway, I'll have news soon.)
Logged

Thanos

  • Full Member
  • ***
  • Posts: 104
  • -.-
    • View Profile
Re: WEEHEEEE oh, oh wait its dead, I thought it was dancing (CRE8OR NOTICE)
« Reply #193 on: February 28, 2013, 07:58:11 am »

Ok, fixed...
cooldude234, I PM'd you with your fixed code.  :)

For the rest, rti v4 is attached below.

(Work this time... plz...  ;D)
« Last Edit: February 28, 2013, 08:02:38 am by Thanos »
Logged

cooldude234

  • Sr. Member
  • ****
  • Posts: 902
  • You know what I realized, I dont have an avatar :\
    • View Profile
Re: WEEHEEEE oh, oh wait its dead, I thought it was dancing (CRE8OR NOTICE)
« Reply #194 on: February 28, 2013, 04:40:50 pm »

okay a bunch of stuff has been changed as I can see.
Just a couple of questions, I might do some debugging my self to get another view point on this,
but which is the faster method for getting the plane collision?
Also what method are you using (I really don't understand any the code too much), is it this method you are using?
http://geomalgorithms.com/a06-_intersect-2.html

Right now I'm trying to figure out how a, b and c are being represented as the plane, because the math that you used to make the plane defined by the triangle is exactly the same as the code I used for finding the normal of the triangle (by getting the cross-product). But you cannot have a plane with the normal, you need a point as well to define the position (I use the first vertices read because its quick and easy, it doesn't matter which it is anyways).

But none the less thanks for the code, once I figure out what numbers need to be used, I'll get it in my code and test it out, hopefully it will work.

If you're curious, rti3 code was made to work only with equilateral triangles... [What on earth was I thinking?]
LOL, yea I don't ever think a equilateral only collision algorithm is going to be useful to me :P
Logged
¼
Pages: 1 ... 11 12 [13] 14 15 ... 20