Files |  Tutorials |  Articles |  Links |  Home |  Team |  Forum |  Wiki |  Impressum

Aktuelle Zeit: Sa Jul 12, 2025 09:37

Foren-Übersicht » Programmierung » Allgemein
Unbeantwortete Themen | Aktive Themen



Ein neues Thema erstellen Auf das Thema antworten  [ 49 Beiträge ]  Gehe zu Seite 1, 2, 3, 4  Nächste
Autor Nachricht
 Betreff des Beitrags: bin neu, nicht boxen
BeitragVerfasst: Mo Nov 03, 2003 20:32 
Offline
DGL Member

Registriert: Mo Nov 03, 2003 20:23
Beiträge: 66
guten tag :)

ich habe schon etwas in dem forum rumgestöbert.

zu mir:
najo, ich bin nicht so netzaktiv und meine mathematischen kenntnisse sind auch nicht sooo die geilsten.

ich habe zuhause ne 3D engine (delphi, opengl) am start und bin grad dabei ne collision detection zu implementieren. die engine selber ist bis jetzt so optisch auf dem stand von Q2.

gfx/snd/input engine ist von der gameengine sauber getrennt.

ich kann in gewissen zeitzyklen die engine mit sourcecode online stellen. der ei oder andere wird da sicher schöne sachen für sich finden :wink:

najo... zurück zum problem. hat jemand ne idee, wie man eine abfrage ob eine traceline ein polygone schneidet sinnvoll gestalten kann ?

bisher benutze ich was selbstgedrehtes, was ich so noch nirgends gefunden habe. ich nehme die POLY-endpunkte und nehme für den ersten durchgang nur die x und z coods. von denen bekomme ich dann einen winken zu den x und z coords des tracestartpoints. und dann muss ich nur noch den winkel von tracestart und traceend wissen und kann fragen ob der winkel zwischen den beiden äussersten winkeln des polys liegt. danach das ganze nochmal mit y und ich habe eine test-scene mit 200.000 polys auf ca. 0.01% colltests geschrumpft.

funzt! ich ahbe es ausgiebig getestet. auch wenn tracestart ganz nahe vorm poly ist.

weiss jemand was besseres ?


ich würde mich freuen, von euch mal was schönes zu hören :)

grx_cyan


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mo Nov 03, 2003 20:35 
Offline
DGL Member
Benutzeravatar

Registriert: Sa Nov 02, 2002 18:06
Beiträge: 299
Wohnort: Dresden
*box*

Guck mal bei sulaco.co.za da gibts ein komplettes Beispiel für Line-Tri-Intersections.

*nochmal box*

Edit: Ach ja, wofür ist das da? Kollision? Dann würde ich's anders machen. (Kollision mit BSP abprüfen). Weil sowas doch ganz schön aufwendig ist (Line-Triangle Intersection)

_________________
"Ich würde ja gern die Welt verändern, aber Gott gibt mir den Quelltext nicht"


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mo Nov 03, 2003 20:41 
Offline
DGL Member

Registriert: Mo Nov 03, 2003 20:23
Beiträge: 66
da war ich schon... hat mal jemand die coordinaten von den dreiecken verändert ? :oops:

:shock:

also bei mir geht der test ab dem moment nicht mehr


ps: ich code ne landscape engine. so kann ich ncith wirklich viel mit BSP anfangen. die tests bei BSP sid mir so auch noch nicht einläuchtend :oops:


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mo Nov 03, 2003 20:48 
Offline
DGL Member
Benutzeravatar

Registriert: Sa Nov 02, 2002 18:06
Beiträge: 299
Wohnort: Dresden
Versuch das mal:
Code:
  1.  
  2. function LineHitsTriangle(Triangle : TTriangle; LineStart, LineEnd : TAffineExtVector) : Boolean;
  3.     const
  4.       // Used to cover up the error in floating point
  5.       MATCH_FACTOR : Extended = 0.9999999999;
  6.       verticeCount = 3;
  7.     var
  8.       Normal : TAffineExtVector;
  9.       Intersection : TAffineExtVector;
  10.       originDistance : Extended;
  11.       distance1 : Extended;
  12.       distance2 : Extended;
  13.       Vector1 : TAffineExtVector;
  14.       Vector2 : TAffineExtVector;
  15.       m_magnitude : Double;
  16.       Point : TAffineExtVector;
  17.       LineDir : TAffineExtVector;
  18.       Numerator : Extended;
  19.       Denominator : Extended;
  20.       dist : Extended;
  21.       Angle,tempangle : Extended;
  22.       vA, vB : TAffineExtVector;
  23.       i : integer;
  24.       dotProduct : Extended;
  25.       vectorsMagnitude : Extended;
  26.     begin
  27.     Normal[0] := 0;
  28.     Normal[1] := 0;
  29.     Normal[2] := 0;
  30.  
  31.     originDistance := 0;
  32.     distance1 := 0;
  33.     distance2 := 0;
  34.     Point[0] := 0;
  35.     Point[1] := 0;
  36.     Point[2] := 0;
  37.  
  38.     LineDir[0] := 0;
  39.     LineDir[1] := 0;
  40.     LineDir[2] := 0;
  41.  
  42.     Numerator := 0.0;
  43.     Denominator := 0.0;
  44.     dist := 0.0;
  45.     Angle := 0.0;
  46.  
  47.     {----------------------------------------------------------------------------}
  48.     { First we check to see if our line intersected the plane.                   }
  49.     { If this isn't true there is no need to go on, so return false immediately. }
  50.     { We pass in address of vNormal and originDistance                           }
  51.     { so we only calculate it once                                               }
  52.     {                                                                            }
  53.     { In order to get a vector from 2 points (a direction) we need to            }
  54.     { subtract the second point from the first point.                            }
  55.     {----------------------------------------------------------------------------}
  56.  
  57.     //vector
  58.     Vector1[0] := Triangle.Verts[2][0] - Triangle.Verts[0][0];
  59.     Vector1[1] := Triangle.Verts[2][1] - Triangle.Verts[0][1];
  60.     Vector1[2] := Triangle.Verts[2][2] - Triangle.Verts[0][2];
  61.     //vector
  62.     Vector2[0] := Triangle.Verts[1][0] - Triangle.Verts[0][0];
  63.     Vector2[1] := Triangle.Verts[1][1] - Triangle.Verts[0][1];
  64.     Vector2[2] := Triangle.Verts[1][2] - Triangle.Verts[0][2];
  65.  
  66.     {----------------------------------------------------------------------------}
  67.     { Once again, if we are given 2 vectors (directions of 2 sides of a polygon) }
  68.     { then we have a plane define.                                               }
  69.     { The cross product finds a vector that is perpendicular to that plane,      }
  70.     { which means it's point straight out of the plane at a 90 degree angle.     }
  71.     {----------------------------------------------------------------------------}
  72.  
  73.     //cross
  74.  
  75.     // The X value for the vector is:  (V1.y * V2.z) - (V1.z * V2.y)
  76.     Normal[0] := ((Vector1[1] * Vector2[2]) - (Vector1[2] * Vector2[1]));
  77.     // The Y value for the vector is:  (V1.z * V2.x) - (V1.x * V2.z)
  78.     Normal[1] := ((Vector1[2] * Vector2[0]) - (Vector1[0] * Vector2[2]));
  79.     // The value for the vector is:  (V1.x * V2.y) - (V1.y * V2.x)
  80.     Normal[2] := ((Vector1[0] * Vector2[1]) - (Vector1[1] * Vector2[0]));
  81.  
  82.     //normalize
  83.  
  84.     {----------------------------------------------------------------------------}
  85.     { This will give us the magnitude or \"Norm\" as some say, of our normal.      }
  86.     { Here is the equation:  magnitude = sqrt(V.x^2 + V.y^2 + V.z^2)             }
  87.     { Where V is the vector                                                      }
  88.     {----------------------------------------------------------------------------}
  89.  
  90.     // Get the magnitude of our normal
  91.     m_magnitude := sqrt((Normal[0] * Normal[0]) +
  92.                         (Normal[1] * Normal[1]) +
  93.                         (Normal[2] * Normal[2]));
  94.  
  95.     {----------------------------------------------------------------------------}
  96.     { Now that we have the magnitude, we can divide our normal by that magnitude.}
  97.     { That will make our normal a total length of 1.                             }
  98.     { This makes it easier to work with too.                                     }
  99.     {----------------------------------------------------------------------------}
  100.  
  101.     Normal[0] := Normal[0]/m_magnitude; // Divide the X value of our normal by it's magnitude
  102.     Normal[1] := Normal[1]/m_magnitude; // Divide the Y value of our normal by it's magnitude
  103.     Normal[2] := Normal[2]/m_magnitude; // Divide the Z value of our normal by it's magnitude
  104.  
  105.     //plane distance
  106.  
  107.     {----------------------------------------------------------------------------}
  108.     { Let's find the distance our plane is from the origin.                      }
  109.     { We can find this value from the normal to the plane (polygon)              }
  110.     { and any point that lies on that plane (Any vertex)                         }
  111.     {                                                                            }
  112.     { Use the plane equation to find the distance (Ax + By + Cz + D = 0)         }
  113.     { We want to find D. So, we come up with D = -(Ax + By + Cz)                 }
  114.     {----------------------------------------------------------------------------}
  115.  
  116.     originDistance := -1 * ((Normal[0] * Triangle.Verts[0][0]) +
  117.                             (Normal[1] * Triangle.Verts[0][1]) +
  118.                             (Normal[2] * Triangle.Verts[0][2]));
  119.  
  120.     // Get the distance from point1 from the plane using:
  121.     //Ax + By + Cz + D = (The distance from the plane)
  122.     distance1 := ((Normal[0] * LineStart[0])  +
  123.                   (Normal[1] * LineStart[1])  +
  124.                   (Normal[2] * LineStart[2])) + originDistance;
  125.  
  126.     // Get the distance from point2 from the plane using
  127.     //Ax + By + Cz + D = (The distance from the plane)
  128.     distance2 := ((Normal[0] * LineEnd[0])  +
  129.                   (Normal[1] * LineEnd[1])  +
  130.                   (Normal[2] * LineEnd[2])) + originDistance;
  131.  
  132.  
  133.     {----------------------------------------------------------------------------}
  134.     { Now that we have 2 distances from the plane,                               }
  135.     { if we times them together we either get a positive or negative number.     }
  136.     { If it's a negative number, that means we collided!                         }
  137.     { This is because the 2 points must be on either side of the plane           }
  138.     { (IE. -1 * 1 = -1).                                                         }
  139.     {----------------------------------------------------------------------------}
  140.  
  141.     // Check to see if both point's distances are both negative or both positive
  142.     if(distance1 * distance2 >= 0) then
  143.       begin
  144.       // Return false if each point has the same sign.
  145.       //-1 and 1 would mean each point is on either side of the plane.
  146.       //-1 -2 or 3 4 wouldn't...
  147.       result := false;
  148.       exit;
  149.       end;
  150.  
  151.     {----------------------------------------------------------------------------}
  152.     { Now that we have our normal and distance,                                  }
  153.     { We can use it to calculate the intersection point.                         }
  154.     { The intersection point is the point that actually is ON the plane.         }
  155.     { It is between the lines points.                                            }
  156.     { We need this point test next, if we are inside the polygon.                }
  157.     { To get the I-Point, we use normal of the plain, the points of the line,    }
  158.     { and the originDistance.                                                    }
  159.     {                                                                            }
  160.     { Here comes the confusing part...                                           }
  161.     { We need to find the 3D point that is actually on the plane.                }
  162.     { Here are some steps to do that:                                            }
  163.     {----------------------------------------------------------------------------}
  164.  
  165.     //vector
  166.  
  167.     {----------------------------------------------------------------------------}
  168.     { (1)                                                                        }
  169.     { First we need to get the vector of our line,                               }
  170.     { Then normalize it so it's a length of 1                                    }
  171.     {----------------------------------------------------------------------------}
  172.     LineDir[0] := LineEnd[0] - LineStart[0];    // Get the X value of our new vector
  173.     LineDir[1] := LineEnd[1] - LineStart[1];    // Get the Y value of our new vector
  174.     LineDir[2] := LineEnd[2] - LineStart[2];    // Get the Z value of our new vector
  175.  
  176.     //normalize
  177.  
  178.     // Get the magnitude of our normal
  179.     m_magnitude := sqrt((LineDir[0] * LineDir[0]) +
  180.                         (LineDir[1] * LineDir[1]) +
  181.                         (LineDir[2] * LineDir[2]));
  182.  
  183.     {----------------------------------------------------------------------------}
  184.     { Now that we have the magnitude, we can divide our normal by that magnitude.}
  185.     { That will make our normal a total length of 1.                             }
  186.     { This makes it easier to work with too.                                     }
  187.     {----------------------------------------------------------------------------}
  188.  
  189.     LineDir[0] := LineDir[0]/m_magnitude;// Divide the X value of our normal by it's magnitude
  190.     LineDir[1] := LineDir[1]/m_magnitude;// Divide the Y value of our normal by it's magnitude
  191.     LineDir[2] := LineDir[2]/m_magnitude;// Divide the Z value of our normal by it's magnitude
  192.  
  193.  
  194.     {----------------------------------------------------------------------------}
  195.     { (2)                                                                        }
  196.     { Use the plane equation (distance = Ax + By + Cz + D)                       }
  197.     { to find the distance from one of our points to the plane.                  }
  198.     { Here I just chose a arbitrary point as the point to find that distance.    }
  199.     { You notice we negate that distance.                                        }
  200.     { We negate the distance because we want to eventually go BACKWARDS          }
  201.     { from our point to the plane.                                               }
  202.     { By doing this is will basically bring us back to the plane                 }
  203.     { to find our intersection point.                                            }
  204.     {----------------------------------------------------------------------------}
  205.  
  206.     // Use the plane equation with the normal and the line
  207.     Numerator := -1 * (Normal[0] * LineStart[0] +
  208.                        Normal[1] * LineStart[1] +
  209.                        Normal[2] * LineStart[2] + originDistance);
  210.  
  211.     {----------------------------------------------------------------------------}
  212.     { (3)                                                                        }
  213.     { We take the dot product between our line vector and normal of the polygon  }
  214.     { This will give us the cosine of the angle between the 2                    }
  215.     { (since they are both normalized - length 1).                               }
  216.     { We will then divide our Numerator by this value,                           }
  217.     { to find the offset towards the plane from our arbitrary point.             }
  218.     {----------------------------------------------------------------------------}
  219.  
  220.     // Get the dot product of the line's vector and the normal of the plane
  221.     Denominator := ( (Normal[0] * LineDir[0]) + (Normal[1] * LineDir[1]) + (Normal[2] * LineDir[2]) );
  222.  
  223.     if( Denominator = 0.0) then  // Check so we don't divide by zero
  224.       begin
  225.       Intersection := LineStart; // Return an arbitrary point on the line
  226.       end
  227.     else
  228.       begin
  229.  
  230.       {----------------------------------------------------------------------------}
  231.       { We divide the (distance from the point to the plane) by (the dot product)  }
  232.       { to get the distance (dist) that we need to move from our arbitrary point.  }
  233.       { We need to then times this distance (dist) by our line's vector (direction)}
  234.       { When you times a scalar (single number)                                    }
  235.       { by a vector you move along that vector. That is what we are doing.         }
  236.       { We are moving from our arbitrary point                                     }
  237.       { we chose from the line BACK to the plane along the lines vector.           }
  238.       { It seems logical to just get the numerator, which is the distance          }
  239.       { from the point to the line,                                                }
  240.       { and then just move back that much along the line's vector.                 }
  241.       { Well, the distance from the plane means the SHORTEST distance.             }
  242.       { What about in the case that the line is almost parallel with the polygon   }
  243.       { but doesn't actually intersect it until half way down the line's length?   }
  244.       { The distance from the plane is short, but the distance from                }
  245.       { the actual intersection point is pretty long.                              }
  246.       { If we divide the distance by the dot product of our line vector            }
  247.       { and the normal of the plane, we get the correct length.  Cool huh?         }
  248.       {----------------------------------------------------------------------------}
  249.  
  250.       // Divide to get the multiplying (percentage) factor
  251.       dist := Numerator / Denominator;
  252.  
  253.       {----------------------------------------------------------------------------}
  254.       { Now, like we said above, we times the dist by the vector,                  }
  255.       { then add our arbitrary point.                                              }
  256.       { This essentially moves the point along the vector to a certain distance.   }
  257.       { This now gives us the intersection point.  Yay!                            }
  258.       {----------------------------------------------------------------------------}
  259.  
  260.       Point[0] := (LineStart[0] + (LineDir[0] * dist));
  261.       Point[1] := (LineStart[1] + (LineDir[1] * dist));
  262.       Point[2] := (LineStart[2] + (LineDir[2] * dist));
  263.  
  264.       Intersection := Point;                                // Return the intersection point
  265.       end;
  266.  
  267.     {----------------------------------------------------------------------------}
  268.     { Now that we have the intersection point,                                   }
  269.     { we need to test if it's inside the polygon.                                }
  270.     { To do this, we use :                                                       }
  271.     {   Our intersection point,                                                  }
  272.     {   The polygon,                                                             }
  273.     {   And the number of vertices our polygon has                               }
  274.     {----------------------------------------------------------------------------}
  275.  
  276.     {----------------------------------------------------------------------------}
  277.     { Just because we intersected the plane,                                     }
  278.     { doesn't mean we were anywhere near the polygon.                            }
  279.     { We need to check our intersection point                                    }
  280.     { to make sure it is inside of the polygon.                                  }
  281.     { This is another tough function to grasp at first,                          }
  282.     { but let me try and explain.                                                }
  283.     { It's a brilliant method really,                                            }
  284.     { what it does is create triangles within the polygon                        }
  285.     { from the intersection point.                                               }
  286.     { It then adds up the inner angle of each of those triangles.                }
  287.     { If the angles together add up to 360 degrees                               }
  288.     { (or 2 * PI in radians) then we are inside!                                 }
  289.     { If the angle is under that value, we must be outside of polygon.           }
  290.     { To further understand why this works,                                      }
  291.     { take a pencil and draw a perfect triangle.                                 }
  292.     { Draw a dot in the middle of the triangle.                                  }
  293.     { Now, from that dot, draw a line to each of the vertices.                   }
  294.     { Now, we have 3 triangles within that triangle right?                       }
  295.     { We know that if we add up all of the angles in a triangle we get 360 right?}
  296.     { Well, that is kinda what we are doing, but the inverse of that.            }
  297.     { Say your triangle is an isosceles triangle, so add up the angles           }
  298.     { and you will get 360 degree angles.  90 + 90 + 90 is 360.                  }
  299.     {----------------------------------------------------------------------------}
  300.  
  301.     // Go in a circle to each vertex and get the angle between
  302.     for i := 0 to verticeCount-1 do
  303.       begin
  304.  
  305.       // Subtract the intersection point from the current vertex
  306.       // Get the X value of our new vector
  307.       vA[0] := Triangle.Verts[i][0] - Intersection[0];
  308.       // Get the Y value of our new vector
  309.       vA[1] := Triangle.Verts[i][1] - Intersection[1];
  310.       // Get the Z value of our new vector
  311.       vA[2] := Triangle.Verts[i][2] - Intersection[2];
  312.  
  313.       // Subtract the point from the next vertex
  314.       // Get the X value of our new vector
  315.       vB[0] := Triangle.Verts[(i + 1) mod verticeCount][0] - Intersection[0];
  316.       // Get the Y value of our new vector
  317.       vB[1] := Triangle.Verts[(i + 1) mod verticeCount][1] - Intersection[1];
  318.       // Get the Z value of our new vector
  319.       vB[2] := Triangle.Verts[(i + 1) mod verticeCount][2] - Intersection[2];
  320.  
  321.       {----------------------------------------------------------------------------}
  322.       { Remember, we said that the Dot Product of returns the cosine of the angle  }
  323.       { between 2 vectors?                                                         }
  324.       { Well, that is assuming they are unit vectors (normalize vectors).          }
  325.       { So, if we don't have a unit vector,                                        }
  326.       { then instead of just saying  arcCos(DotProduct(A, B))                      }
  327.       { We need to divide the dot product                                          }
  328.       { by the magnitude of the 2 vectors multiplied by each other.                }
  329.       { Here is the equation:   arc cosine of (V . W / || V || * || W || )         }
  330.       { the || V || means the magnitude of V.                                      }
  331.       { This then cancels out the magnitudes dot product magnitudes.               }
  332.       { But basically, if you have normalize vectors already,                      }
  333.       { you can forget about the magnitude part.                                   }
  334.       {----------------------------------------------------------------------------}
  335.  
  336.       // Get the dot product of the vectors
  337.       dotProduct := ( (vA[0] * vB[0]) +
  338.                       (vA[1] * vB[1]) +
  339.                       (vA[2] * vB[2]) );
  340.  
  341.       // Get the product of both of the vectors magnitudes
  342.       vectorsMagnitude := sqrt(
  343.                                extended(vA[0] * vA[0]) +
  344.                                extended(vA[1] * vA[1]) +
  345.                                extended(vA[2] * vA[2])
  346.                                )
  347.                             *
  348.                           sqrt(
  349.                                extended(vB[0] * vB[0]) +
  350.                                extended(vB[1] * vB[1]) +
  351.                                extended(vB[2] * vB[2])
  352.                                );
  353.  
  354.       {----------------------------------------------------------------------------}
  355.       { Get the arc cosine of the (dotProduct / vectorsMagnitude)                  }
  356.       { which is the angle in RADIANS.                                             }
  357.       { IE:                                                                        }
  358.       {   PI/2 radians = 90 degrees                                                }
  359.       {   PI radians = 180 degrees                                                 }
  360.       {   2*PI radians = 360 degrees                                               }
  361.       {                                                                            }
  362.       { To convert radians to degress use this equation:   radians * (PI / 180)    }
  363.       { To convert degrees to radians use this equation:   degrees * (180 / PI)    }
  364.       {----------------------------------------------------------------------------}
  365.  
  366.  
  367.       tempangle := arccos( dotProduct / vectorsMagnitude );
  368.  
  369.       {----------------------------------------------------------------------------}
  370.       { Here we make sure that the angle is not a -1.#IND0000000 number,           }
  371.       { which means indefinate.                                                    }
  372.       { acos() thinks it's funny when it returns -1.#IND0000000.                   }
  373.       { If we don't do this check,                                                 }
  374.       { our collision results will sometimes say we are colliding when we aren't.  }
  375.       { I found this out the hard way after MANY hours                             }
  376.       { and already wrong written tutorials <!-- s:) --><img src=\"{SMILIES_PATH}/icon_e_smile.gif\" alt=\":)\" title=\"Lächeln\" /><!-- s:) -->                                     }
  377.       { Usually this value is found when the dot product and the maginitude        }
  378.       { are the same value.                                                        }
  379.       { We want to set tempangle = 0 when this happens.                            }
  380.       {----------------------------------------------------------------------------}
  381.  
  382.       if(isnan(tempangle)) then
  383.         begin
  384.         tempangle := 0;
  385.         end;
  386.  
  387.       // add the current tempangle to Angle in radians
  388.       Angle := Angle + tempangle;
  389.       end;
  390.  
  391.     {----------------------------------------------------------------------------}
  392.     { Now that we have the total angles added up,                                }
  393.     { we need to check if they add up to 360 degrees.                            }
  394.     { Since we are using the dot product, we are working in radians,             }
  395.     { so we check if the angles equals 2*PI.                                     }
  396.     { You will notice that we use MATCH_FACTOR in conjunction with our 2*PI.     }
  397.     { This is because of the inaccuracy when working with floating point numbers.}
  398.     { It usually won't always be perfectly 2 * PI, so we need                    }
  399.     { to use a little twiddling.                                                 }
  400.     { I(Digiben) use .9999,                                                      }
  401.     { but you can change this to fit your own desired accuracy.                  }
  402.     { For the Delphi version I am using 0.9999999999 because im using extended   }
  403.     { and not double (float in c++)                                              }
  404.     {----------------------------------------------------------------------------}
  405.  
  406.     // If the angle is greater than 2 PI, (360 degrees)
  407.     if(Angle >= (MATCH_FACTOR * (2.0 * PI)) ) then
  408.       begin
  409.       result := TRUE;                           // The point is inside of the polygon
  410.       exit;                       // We collided!     Return success
  411.       end;
  412.  
  413.  
  414.     // If we get here, we must have NOT collided
  415.  
  416.     result := false; // There was no collision, so return false
  417.     end;
  418.  
  419.  
  420.  


Brauchst noch die Geometry dafür

Und TTriangle.Verts ist einfach ein array[0..2] of TVertex

_________________
"Ich würde ja gern die Welt verändern, aber Gott gibt mir den Quelltext nicht"


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mo Nov 03, 2003 20:51 
Offline
DGL Member

Registriert: Mo Nov 03, 2003 20:23
Beiträge: 66
aha... wenns läuft bin ich schonmal etwas glücklicher. meine derzeitige abfrage funzt via matrix. und wenn ich auch den code zeige, erschlagt ihr mich sicher mit was ganz hartem :oops:


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mo Nov 03, 2003 20:51 
Offline
DGL Member
Benutzeravatar

Registriert: Sa Nov 02, 2002 18:06
Beiträge: 299
Wohnort: Dresden
Im Anhang ist die Funktion mal drin.

TTRiangles.Verts ist einfach ein array[0..2] of TVector


Du hast keine ausreichende Berechtigung, um die Dateianhänge dieses Beitrags anzusehen.

_________________
"Ich würde ja gern die Welt verändern, aber Gott gibt mir den Quelltext nicht"


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mo Nov 03, 2003 20:53 
Offline
DGL Member

Registriert: Mo Nov 03, 2003 20:23
Beiträge: 66
danke... aber copy & paste hatte ich schneller drin ;)

erm... müssen wir immer gleichzeitig posten ? *fg*
(hab jetzt meine edits dazugerechnet)


Zuletzt geändert von cyanide am Mo Nov 03, 2003 20:54, insgesamt 1-mal geändert.

Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mo Nov 03, 2003 20:53 
Offline
DGL Member
Benutzeravatar

Registriert: Mo Sep 23, 2002 19:27
Beiträge: 5812
Programmiersprache: C++
@HomerS :
Bitte poste keine so großen Quellcodes mehr,zumal obiger ja identisch mit dem von Sulaco ist,da das die Foren-DB nicht mag.

@Cyanide :
Wenn du Spieler-Landschaftskollision machen willst,dann benötigst du definitiv eine Routine die nur die in der Nähe des Spielers liegende Geometrie für einen Kollisionstest in Betracht ziehst.Dazu empfiehlt sich bei einer Landschaft übrigens ein Octree,denn man dafür sowieso bereits zum Rendern nutzen sollten.Danach reicht es wenn du den Spieler als 3 Linien darstellst (seine drei Achsen) und diese dann mit der umliegenden Geometrie auf Kollision testest.Alternativ kannst du den Spieler auch als eine Kugel beschreiben lassen und diese gegen die Polygone testen,was auch recht häufig gemacht wird.

_________________
www.SaschaWillems.de | GitHub | Twitter | GPU Datenbanken (Vulkan, GL, GLES)


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mo Nov 03, 2003 20:58 
Offline
DGL Member

Registriert: Mo Nov 03, 2003 20:23
Beiträge: 66
das ist falsch. ich habe teilweise tests, die von einem ende bis zum anderen ende der map reichen.

meine maps unterteile ich aber später mit einem neuen system. das stelle ich dann hier auch vor. ich will versuchen den skybackground interaktiv zu halten und da dann die weltteile reinrendern, die zu weit entfernt liegen. hierbei ist aber wichtig, dass spieler die hinter der map stehen trotzdem ganz oder durch verdeckung theoritisch daseiender wände nur halb oder garnicht gezeichnet werden. und figuren sollen ab einer gewissen reichweiter nur noch als sprites dargestellt werden. die engine rechnet beim laden einer map die sprites selber aus, indem die die figuren von allen seiten zeichnet und texturen draus macht. ab den entfernungen, wo diese dann statt der normalen figuren gezeichnet werden, merkt man das nicht mehr


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mo Nov 03, 2003 21:01 
Offline
DGL Member

Registriert: Mo Nov 03, 2003 20:23
Beiträge: 66
(sorry für evtl. schreibfehler)

ich brauche solche langen tracelines für sniper und co, welche innerhalb eines frames eine lange traceline produzieren.

wenn das alles theoretisch funktioniert, dann brauche ich kein kompliziertes LOD mehr. dann geht alles viel einfachher und schneller


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mo Nov 03, 2003 21:08 
Offline
DGL Member

Registriert: Mo Nov 03, 2003 20:23
Beiträge: 66
hmpf... ich hätte nciht so mit der tür ins haus fallen sollen. ich hätte viel zu erklären, warum ich solche tests brauche.

- physik
- bullets
- raytracing (ja!)


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Di Nov 04, 2003 12:13 
Offline
DGL Member
Benutzeravatar

Registriert: Mo Sep 23, 2002 19:27
Beiträge: 5812
Programmiersprache: C++
Und trotzdem wäre ein Octree doch ne gute Alternative,selbst wenn du den nicht für dein LODding benutzt.Viele Spiele nutzen ihre BSP-Bäume auch nur zur Kollisionserkennung und nutzen fürs Rendern andere LOD-Techniken.
Denn durch nen Octree kannst du doch ganz einfach testen welche Boundingbox dein Strahl geradet durchschneidet und musst dann nur gegen die zu dieser Box gehörenden Polygone testen.

Ansonsten ist das was du da vorhast recht unklar.Erklär das mal etwas genauer.

_________________
www.SaschaWillems.de | GitHub | Twitter | GPU Datenbanken (Vulkan, GL, GLES)


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Di Nov 04, 2003 18:53 
Offline
DGL Member

Registriert: Mo Nov 03, 2003 20:23
Beiträge: 66
ok... ich weiss jetzt nicht genau, was unklar ist. deswegen werde ich jetzt mal etwas ausholen:

start der entwicklung war vor ca. 4 wochen. ich code aber schon sehr lange, wodurch die engine einen schon recht guten status hat.

ich muss mich aber derzeit leider mit allem beschäftigen, da ich ganz alleine an dem projekt arbeite und unbedingt alle ideen umsetzten will. dadurch sind einige schönheiten auf der strecke geblieben. angefangen hat alles mit einem tutorial von NEHE. darauf habe ich erstmal einen landscapegenerator gesetzt. sah dann alles ganz nett aus und ich war motiviert genug ne gameengine zu schreiben. aös nächstes kam dann ein MD3 modelloader und kurz danach ne (wenn auch total blöde) KI. jetzt konnte ich mich schonmal mir doofen MD3-schwertkämpfern mit toll aussehenden raketen um frags streiten.

toll :oops:

naja... dann kam ich da irgendwie in das ganze rein und habe alles erstmal getrennt. alles was irgendwie nicht so richtig mit einem spielregelwerk zusammenhängt auf die hostseite und die gameengine samt den regeln und co in dei gameengine. ähnlich wie bei Q3/Q2.

grafik:
texturen sind, wenn nicht selbst gemacht, erstmal von anderen spielen geklaut. ebenso wie die MD3 models (irgendwie ansich logisch).als beruflicher grafikdesigner mache ich aber auch vieles schon selbst (aber mir fehlt die zeit). das landscape besteht derzeit aus ca. 80.000 polygonen. ich habe eine Gef2MX und einen AMD950 MHz prozessor. ist immer recht scheisse, wenn ich mir ein schönes tutorial runtergeladen habe und nette fehlermeldungen bekomme, dass meine GraKa zu blind dafür ist :oops:

sound:
OpenAL. ich bin definitiv begeistert, was da geht. davor habe ich mit Direct Sound gebastelt und somancher weiss wie frustrierend die teilweise nicht nachvollziehbaren fehlermeldungen seien können. SDKs habe ich mir bisher nicht holen können, weil ich erst wieder seit kurzem zugang zum i-net habe. ich hoffe jetzt wird alles besser :)

netz:
ich habs mal kurz versucht... aber mit nur einem rechner sind die resultate nicht so doll... kann ja nicht wirklich testen, ob die coordinaten syncronisiert werden, wenn ich das spiel nur einmal laufen lassen kann........ und wenn.... ist die durchsatzrate ok? übermittelt er durchgängig daten? ich lass es erstmal :wink:

input:
naja... keine grosse aufgabe... und das mausrad bekomm ich auch noch abgefragt... (das doofe) ..... vorher brauche ich aber ne maus mit mausrad *grml*

colldet:
hehe... wer DEN code sieht wird mich erschlagen! definitiv...
ich habe ein matrixsystem benutzt, dass ganz toll alles ausrechnet. ich bekomme den genauen schnittpunkt und allesfunktiert super! einziges manko: mehr als 5000 pro sekunde sind nicht drin... :oops: dafür sorgen 400 zeilen 'EquationSolver' code. najo, das ganze konnte ich auch etwas drosseln. mit dem winkelabfragen von möglichen testflächen habe ich einiges rausgeholt. aber die 80.000 polygone schaff ich damit trotzdem nicht wenn ich dabei an eine akzeptable framerate denken will.



noch fragen offen?

grx_cyan

ps: ich bekomme die oben vorgeschlagene abfrage definitiv nicht zum laufen. muss ich noch wirgendwas beachten? ich habe bislang noch nicht mit 'normalen' getestet... kann ich nachher ja nochmal probieren.

pps: meine rechtschreibfehler basieren zumeist darauf, dass ich schneller schreibe als ich mit den augen das geschriebene korrigieren kann. manchma lesen sich meine sätze auch etwas strane... bin zu faul mir das ganze hinterher nochmal durchzulesen. wenn ihr mich genug boxt, dann kann ich mir das mal angewöhnen ^^


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mi Nov 05, 2003 13:06 
Offline
DGL Member

Registriert: Mo Nov 03, 2003 20:23
Beiträge: 66
seid doch etwas gesprächiger :oops: ..bitte...


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mi Nov 05, 2003 13:15 
Offline
DGL Member
Benutzeravatar

Registriert: Mo Sep 23, 2002 19:27
Beiträge: 5812
Programmiersprache: C++
Hab doch bereits mehrere Male erwähnt das ein Octree die beste und performanteste Lösung für das Geschwindigkeitsproblem deiner Kollisionsabfrage sein könnte.Wie gesagt testes du halt nur die Polygone die zu der Octree-Boundingbox gehören durch die dein "Strahl" verläuft.Einfacher und besser gehts nicht.

P.S. : Dein obiger Text war echt quallvoll zu lesen.Die deutsche Sprache bietet dir doch sowas wie Groß-/Kleinschreibung an.

_________________
www.SaschaWillems.de | GitHub | Twitter | GPU Datenbanken (Vulkan, GL, GLES)


Nach oben
 Profil  
Mit Zitat antworten  
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen Auf das Thema antworten  [ 49 Beiträge ]  Gehe zu Seite 1, 2, 3, 4  Nächste
Foren-Übersicht » Programmierung » Allgemein


Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 7 Gäste


Du darfst keine neuen Themen in diesem Forum erstellen.
Du darfst keine Antworten zu Themen in diesem Forum erstellen.
Du darfst deine Beiträge in diesem Forum nicht ändern.
Du darfst deine Beiträge in diesem Forum nicht löschen.
Du darfst keine Dateianhänge in diesem Forum erstellen.

Suche nach:
Gehe zu:  
  Powered by phpBB® Forum Software © phpBB Group
Deutsche Übersetzung durch phpBB.de
[ Time : 0.012s | 16 Queries | GZIP : On ]