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 ... 13 14 [15] 16 17 ... 20

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

Thanos

  • Full Member
  • ***
  • Posts: 104
  • -.-
    • View Profile
Re: WEEHEEEE oh, oh wait its dead, I thought it was dancing (CRE8OR NOTICE)
« Reply #210 on: April 26, 2013, 10:34:03 am »

It works perfectly. Makes no sense. Are you sure the error is in the line - triangle collision code?
I remember writing some code for 2d collision back then... the problem wasn't in the collision detection method, but in the code that was using it. I mean, maybe it's not a matter of how you find the collision, but what you do afterwards.
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 #211 on: April 29, 2013, 12:25:31 pm »

AH HA, I figured out why certain triangles worked, and other did not
Apparently certain sizes and angles in certain locations just don't work at all.
Now beyond that I have no clue why that is.

EDIT: did some more testing, and quite literally this is the opposite of floating point in inaccuracies, it's literally just the size of the triangle that causes issues
« Last Edit: April 29, 2013, 09:27:55 pm by cooldude234 »
Logged
¼

cooldude234

  • Sr. Member
  • ****
  • Posts: 902
  • You know what I realized, I dont have an avatar :\
    • View Profile

Long time no screens :P
So I've somewhat gotten polygonal distribution (this is what I'm calling it, there's not really any name for it) working. I can distribute objects onto a polygon of any size at any angle, however it doesn't want to stay inside of the triangle (so I guess I still have some bugs to work out).

It does run decently fast (and there's a lot of things I did which slowed it down, meaning there's lots of room for optimization).
I can distribute a 1000 random objects and have the engine run at about 20 - 30 frames a second. Distributing 200 objects was around 80 - 95 frames, and it probably would have ran much faster if I didn't render the object (I could also optimized the way they're being rendered to speed it up).

So here's the screens,
Logged
¼

cooldude234

  • Sr. Member
  • ****
  • Posts: 902
  • You know what I realized, I dont have an avatar :\
    • View Profile

I fixed it a bit... err maybe?

It seems to work, except the one corner has more of a probability to have objects near it than others. I believe this has to do something with the scalar value I am using in my algorithm. But non the less it is a much better result than previous attempts.

EDIT: getting 130 - 150 frames a second, whilst calculating 250 random positions on the triangle every frame
« Last Edit: May 04, 2013, 03:32:13 am by cooldude234 »
Logged
¼

cooldude234

  • Sr. Member
  • ****
  • Posts: 902
  • You know what I realized, I dont have an avatar :\
    • View Profile

okay so maybe I don't really know whats going on beyond the code.
I replaced the distance variable (which is supposed to define the size of the triangle and later be used for picking a random point inside that) with a value of 10.
This is what happen.

I think I'll look over everything again :P
Logged
¼

cooldude234

  • Sr. Member
  • ****
  • Posts: 902
  • You know what I realized, I dont have an avatar :\
    • View Profile

5th post in a row? eeeh I wasn't expecting this much progress all at once :P
Well doing some debugging and some math in my head I finally realized the full picture of the mess I had made ;)

See the image below for reference.

(get ready for not that much math :P)
The way I had designed this algorithm is so that you would get the distance of the edge, 1&2.
Generate a random number between that value and zero. Find the scalar of that value (so if the number was half of the distance of edge 1&2 the scalar would be 0.5), apply that to the second edge (by multiplying the distance of 1&3 by the scalar). So that way there would be a random point on both edges with the equivalent scale. I would then find a random point on the distance between the scaled lines, find the scalar from that, and project one of the scaled lines (depending on the order) by that number (scaled line multiplied by new scalar).

I'm doing what seems to be half of that, because of the way I implemented the U and V coordinate system (to fit a triangle instead of a square), I kinda made a interesting matrix operation for triangles :P (once again just look at the image below).

Sorry if you don't understand, I just suck at explaining things without making a picture book about it :D

NOTE: the matrix operations part was a joke, I'm just too tired to decipher whats funny and whats not
« Last Edit: May 04, 2013, 05:29:12 am by cooldude234 »
Logged
¼

cooldude234

  • Sr. Member
  • ****
  • Posts: 902
  • You know what I realized, I dont have an avatar :\
    • View Profile

Okay, Great news to share to you I have!
I have fixed it and now it works perfectly.
What I did was a made an exponential value based on the V value (or U on the whiteboard). So the smaller V gets the more spacing there is between each segment. (now there's a lot of overlapping in this next image because I'm drawing about 500 objects in place, but that's just because I was too lazy to remove the random function part :P)
And I can easily change the distance between each segment (I guess that's what I could call it, segment that is).
Just take a look :D

EDIT: okay my exponent isn't working like I initially thought (I need to find the formula to scale it properly when changing the distance between each segment) but I am on the right track (I hope :P )

EDIT2: lol I know why my exponent is not working, duh the triangle is variable in shape and size, so I should't be working making the exponential decrease based on one edge (basically I need the size to be relevant to the world space in this case).

EDIT3: heheheh my post count is 555 :D
« Last Edit: May 04, 2013, 09:08:05 am by cooldude234 »
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 #217 on: June 05, 2013, 02:11:20 am »

Okay so collision is slightly back to the title of slightly working.
Apparently the collision works, but the position of the physical triangle and the visual triangle are very off, and in a non constant manor. Meaning that one triangle has it's collision below, meanwhile another has it's collision to the right of it?

A least I got a taste of some sort of accomplishment.

Also working on making font's look nicer and less pixelated.

EDIT: Also it seems that closer to the origin of the world (x0,y0,z0) the less distance there is to the polygon and it's collision and the further away the more distance there is. (reason why the large polygons seemed to have issues over the smaller ones, because the smaller ones were near the center :| )

EDIT: I've pinpointed it down to the fact that the physical polygon and the visual polygon are displaced on its normal. IE take the visual polygon, go backwards along it's normal and at some point you will hit it's collision.
Also it seems that the end section (checking to see if the collision is inside the triangle) isn't wrong, nor the part for calculating where the collision is on a plane, but rather somewhere in between that. THIS IS GOOD though, because now I know where in the code this headache educing poop is dwelling.
« Last Edit: June 05, 2013, 03:40:56 am 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 #218 on: June 07, 2013, 10:53:16 am »

You're seeing some light about the collision issue? That's great! It was making me feel kinda down.
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 #219 on: June 07, 2013, 06:19:32 pm »

I know that feels bro ;)
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 #220 on: July 27, 2013, 01:10:56 am »

Well still can't figure it out, so I'm going to freely post the code for anyone to take a look at it.
NOTE: this doesn't make the project open source ;) and this is only the portion of the code that checks a ray and plane collision (which is the part not working).

Quote from: code
bool CheckLineTriangle(vector3f Vert1, vector3f Vert2, vector3f Vert3, vector3f Ray1, vector3f Ray2, vector3f &ContactPoint)
{
   vector3f Normal;
   vector3f IntersectPos;

   // Finding Triangle Normal (by using crossproduct)
   Normal = crossproduct (subtract_vector(Vert2,Vert1),subtract_vector(Vert3,Vert1));

   // Find distance from ray1 and ray2 to the plane defined by the triangle
   double Dist1 = dot_product(subtract_vector(Ray1,Vert1),Normal);
   double Dist2 = dot_product(subtract_vector(Ray2,Vert1),Normal);

   if ( (Dist1 * Dist2) >= 0.0f)
   {
      // line doesn't cross the triangle.
      return false;
   }
   if ( Dist1 == Dist2)
   {
      // line and plane are parallel
      return false;
   }
   // Find point on the line that intersects with the plane
   IntersectPos.x = Ray1.x + (Ray2.x - Ray1.x) * (-Dist1/(Dist2-Dist1));
   IntersectPos.y = Ray1.y + (Ray2.y - Ray1.y) * (-Dist1/(Dist2-Dist1));
   IntersectPos.z = Ray1.z + (Ray2.z - Ray1.z) * (-Dist1/(Dist2-Dist1));
   ContactPoint = IntersectPos;

}
And here's the math functions used in it
Quote
float dot_product (vector3f A, vector3f B)
{
   return ( (A.x * B.x) + (A.y * B.y) + (A.z * B.z));
}

vector3f crossproduct(vector3f A, vector3f B)
{
   vector3f vector;
   vector.x = (A.y*B.z)-(A.z*B.y);
   vector.y = (A.x*B.z)-(A.z*B.x);
   vector.z = (A.x*B.y)-(A.y*B.x);
   return vector;
}
Also vector3f are just a 3 floating point vectors (in other words they are a variable that contains a x y and z)
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 #221 on: July 30, 2013, 05:46:11 pm »

First off I just noticed this topic has 10901 views (wholy craps :o)
Now onto the original reason for posting; just a little bit on what I plan to do.

So I plan on making this engine module based. Meaning you can take out and add in parts to fit your needs.
Because games (and programing) in general don't have one specific way of doing things and instead they have algorithms that they use to fit their specific needs; I'm not going to take a 'one size fits all' motto. However I do want the engine itself to be a universal tool to make a wide range and variety of games (from FPSs to RPGs, 2D plat-formers and even text adventures :D).

So module based is the way to go, and a good example of this would be shadows. For instance you wouldn't compute shadows the same way you would in a 3D First person shoot than a 2D rpg game would you? Of course not. So what I would do is I would make two algorithms for shadows, one that would take 3D space coordinates and one that would take 2D Coordinates and then compute them efficiently for each case.

Now there's a bit more to it than that (on the technical side), and I don't exactly know what direction I want to take this moduleness in :P. I might use separate DLLs for things like 2D physics and 3D lighting, 3D rendering etc. That way you can exclude whatever parts you are not using from the exe folder and it would run fine. However this is truly dependent on how big the exe is in the end (right now all the functions are compiled inside the exe). If the exe is something like 30 megabytes then I will make separate dlls for it.
 
Now you may be thinking but 30 megabytes is nothing for a hard drive (or ram) but that's not the issue. You see when you run a program, like an exe that program doesn't actually go into the ram (or is ran from the hard drive). It is put onto your CPU, well your CPU's built in memory anyway. And if your exe is too big and can't fit onto the cpu then it will go onto your ram card (and this SLOWS things down BIG time, it's not good to have). So in short the smaller the exe the better.

Well that's the small update I can give you, it's not much but it's a little insight to my plans for the future of this project.
« Last Edit: July 30, 2013, 05:48:32 pm by cooldude234 »
Logged
¼

NickE

  • Full Member
  • ***
  • Posts: 167
    • View Profile
Re: WEEHEEEE oh, oh wait its dead, I thought it was dancing (CRE8OR NOTICE)
« Reply #222 on: July 30, 2013, 07:23:55 pm »

cooldude234,

Whenever I have tried to determine whether a line segment (like an edge) intersects a polygon, I have done it in two steps:
1) determine if and where the line segment intersects the plane of the polygon
2) determine if that intersection is actually inside the polygon

It is unclear from your code segment what Ray1 and Ray2 actually are, but if they are points that define a line segment, then this is how I would solve this problem:


   facenormal=normalize(crossproduct(vert3-vert2,vert2-vert1))   //get normal of polygon plane
   rayvector= ray2 - ray1                                        //get vector of ray line segment
        ray_plane_angle=dot(facenormal,rayvector) //actually the arccos of the angle between
        if ray_plane_angle != 0                   //if zero, the two are parallel
            ray_plane_intersection_point = ray2 + ((dot(vert1 - ray2,facenormal) / ray_plane_angle) * rayvector
            //above, calculate the intersection point of vector of the line segment and plane
            //next add angles of intersection point to two of the vertices at a time.
            //if the angles add to 360 deg (or 2*pi rad) then inside, otherwise the intersection point is outside
            total_angles= acos(dot(normalize(vert1-ray_plane_intersection_point),normalize(vert2-ray_plane_intersection_point)))
                         +acos(dot(normalize(vert2-ray_plane_intersection_point),normalize(vert3-ray_plane_intersection_point)))
                         +acos(dot(normalize(vert3-ray_plane_intersection_point),normalize(vert1-ray_plane_intersection_point)))
            if (abs(total_angles - 2*pi) < 0.001) contact_point=ray_plane_intersection_point

If you are actually dealing with a line segment, rather than an endless line, then you need to check whether the intersection point is actually between ray2 and ray1:
           
            if length(ray2-ray_plane_intersection_point)+length(ray1-ray_plane_intersection_point) > length(ray2-ray1)
                //intersection point is not between ray2 and ray1


I wrote the code in pseudo code rather than a particular language.
I hope that helps.
NickE
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 #223 on: July 30, 2013, 09:33:14 pm »

Thanks NickE, I'll try that later. ;) cheers
Logged
¼

VirtuaroidPilot

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: WEEHEEEE oh, oh wait its dead, I thought it was dancing (CRE8OR NOTICE)
« Reply #224 on: September 22, 2013, 01:55:30 pm »

Is there a public beta/alpha release I can try? I'm a cre8or veteran, and I would love to get back to the scene. My best game was Dylan 64.
Logged
Pages: 1 ... 13 14 [15] 16 17 ... 20