Advertisement Jump to content
  • Advertisement

Roming22

Member
  • Content Count

    76
  • Joined

  • Last visited

Community Reputation

122 Neutral

About Roming22

  • Rank
    Member
  1. Hi, I would like some info about glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); and vertex arrays. I assume that size is the number of texture coordinate in *pointer, that type is the type of *pointer (GL_FLOAT for exemple), that stride is 2 (since I only have a UV map) and that pointer is the array holding the texture coordinates. Please correct if I'm wrong. Now I would like to know how a vertex retrieve it's texture coordinate. Is it just "the i-th vertex gets the i-th texture coordinate" or can I specify something else, like "for the i-th face, the textures coordinates of each vertex are the i-th, i+1-th, and i+2-th of the array" ? What I'm doing: I'm coding an ASE loader, and the ASE file gives me for each face a pointer to a table of UV coordinates. This means that a vertex can have different UV coordinates depending of which face is drawn. Thus, I'm wondering how do I have to handle it in order to put it into an array and do a glDrawElements(...). Thanks for any help, Roming22
  2. If you need 3D then use ellipsoids. But start with sphere-sphere collision (and represent your people as sphere). Once this works, you'll be able to change it to ellipsoid, by "scalling" your spheres unevenly on each axis when doing collision detection. isColliding(sphere1,sphere2){ distance = sq(sphere1.x-sphere2.x); distance = sq(sphere1.y-sphere2.y); distance = sq(sphere1.z-sphere2.z); if(distance <= sq(sphere1.radius+sphere2.radius)) return true; else return false; } // Not sure about what I'm writing here. // The idea, is to add the radii of the ellipsoids on each axis // to make a *big* ellipsoid centered on ellipsoid1, then to // scale the world so that the big ellipsoid become a unit sphere, // and then test if the unit sphere is colliding with the scaled // center of ellipsoid2. // I'm assuming that the ellipsoids cannot rotate, but if // radiusX=radiusY, you can have rotation around the Z axis. isColliding(ellipsoid1,ellipsoid2){ Sphere sphere1; Sphere sphere2; sphere1.x = ellispoid1.x/(ellipsoid1.radiusX+ellipsoid2.radiusX) sphere1.y = ellispoid1.x/(ellipsoid1.radiusY+ellipsoid2.radiusY) sphere1.z = ellispoid1.z/(ellipsoid1.radiusZ+ellipsoid2.radiusZ) sphere1.radius = 1; sphere2.x = ellispoid1.x/(ellipsoid2.radiusX+ellipsoid2.radiusX) sphere2.y = ellispoid1.x/(ellipsoid2.radiusY+ellipsoid2.radiusY) sphere2.z = ellispoid1.z/(ellipsoid2.radiusZ+ellipsoid2.radiusZ) sphere2.radius = 0; return isColliding(sphere1,sphere2); } So start with spheres, then when you're sure it works, add the scaling to have ellipsoid. You will even be able to simulate overweight/skinny people by changing the scaling. Don't use cylinders, it's more difficult (although I think it's a nicer representation). However, the way you describe your program, it seems that your world is a 2D world (although it is represented in 3D). You don't seem to have different floors, stairs, people jumping, etc... So, you could use a simple 2D circle-circle collision (similar to the sphere-sphere collision), where the radius of the circle is the radius of the area covered by your character. That wouldn't prevent you from displaying your world in 3D.
  3. You need to know how to do sphere-sphere collision. Once you know how to do it, you'll need to add just a few line of code to do ellipse-ellipse collision (assuming the ellipses cannot rotate, and their axis are along the X,Y and Z axis). If you world can be assimilated as being 2D (ie the map of your world can be represented in 2D), then all you need is circle-circle collision, which is very simple once you have a vector2D class. I might be able to help you if you give me some more info.
  4. Roming22

    Dynamic ray-sphere collision

    Sorry for the late reply, but I've been away for some time. I used your solution in another program, but I'm not satisfied when I have such equations in my programs, as it is more "mathematical" (or theorical) than "physical" (or practical), thus making it a little harder to for someone else to understand. ... and your solution has a square root whereas mine don't ;) but I still don't know if it works...
  5. Roming22

    Vehicle shoots self

    Just shoot the missile from a short distance in front of the vehicle (so it does not collide on the fist step). The velocity of the projectile should be missile.speed+vehicle.speed (because "at rest" the missile already has the speed of the vehicle carrying it). Normally you shouldn't have to add anything else to your code. Since the missile will go faster than the vehicle, the only ways the vehicle will be harmed by the missile are: - missile exploding too close, - vehicle getting in the trajectory of the missile (if it's a homing missile, or if the missile slows down and the vehicle can catch it).
  6. Roming22

    Dynamic ray-sphere collision

    Thanks for helping. To answer your questions: - the sphere has a constant motion during the step I'm calculating. - I'm working in 3D. The algorithm you gave me wouldn't work in 3D (since the line would become plane), so I'm still trying to work out the solution. Something tells me that I should find a way to summarize it as a 2D circle/point collision, looking at the objects in the line's direction (thus see the line only as a point). A good start seems to change the sphere's speed and getting the point in the plane. Line: defined by a point and a normalized vector Sphere: defined by a center, a radius, and its speed speed2D = speed3D-speed3D.dot(line.vector)*line.vector; //speed2D isn't really in 2D, but seems to be from our point of view, since we removed the speeed's colinear component to the line direction. closestPoint = point+((center-point)*vector)*vector //closest point from the center belonging to the line Now everything should be set up to work in 2D, although everything is still 3D (the sphere can't pass in front or behind the point). So now I have some kind of sphere-point collision... *thinling as typing* and it's something I know how to do! So I guess that would work. Anyone can confirm what I wrote? Thanks for taking the time, Roming22
  7. Hi, I'm having trouble figuring out how to calculate the time a moving sphere will intersect an infinite static line. I already have a function that calculates if a line is intersecting a sphere, but it's no use for this... :( Could someone explain me how to do or post me a link toward the equation I need to use (using vector and not parametric equations if possible)? Thanks for any help, Roming22
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!