Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

1385 Excellent

About grhodes_at_work

  • Rank

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Are the cubes all the same size (as in, say, a voxel representation)? Let's say your player cubes are larger than some of your terrain cubes. Then, your test that only checks the containment of the corners will be insufficient. The player cube could entirely surround a terrain cube such that no corner is inside a terrain cube but the cubes would still volumetrically overlap. For example, see below....the player cube corners denoted by 'p', and terrain by 't':                                         p---------------------------------------p                                       |                                                |                                       |              t--------------t               |                                       |              |                 |               |                                       p-----------|--------------|------------p                                                      |                 |                                   t---------------t--------------t---------------t                                   |                  |                 |                  |                                   |                  |                 |                  |                                   t---------------t--------------t---------------t   One approach to deciding which plane to slide against would be to consider the outward-facing surface normal of all the faces of the colliding cubes. The collision/contact plane will be a plane between two cube faces whose normals point in opposite directions. The bottom plane of the black cube points down and the top plane of the red cube points up....opposite directions, so the bottom plane of the black cube would be your collision/contact plane.   grhodes_at_work
  2. grhodes_at_work

    OBB calculating extents

    Thank you for the additional background information. I now understand better what you are doing, and what your references are.   I hope I'm not overstepping your bounds to make additional suggestions and send additional references.   With respect to the separate transform object, I agree that you wouldn't want to create a new transform class. And, certainly, it does not necessarily make sense for OBB to inherit from transform. The OBB could have a property that is a transform object, and I wonder if it might still make sense to take advantage of the existing scene graph transform class. If you do something like this in your collision detection engine, then it might make it easier to sync your collision detection with the scene graph to be rendered. Or, the OBB shape could be a child of a transform object...making it easier to support compound shapes or different types of collision shapes. Many physics engines are set up sort of like this. I realize that rendering engines and collision detection/physics engines often have separate representations of the scene, but the collision/physics engines usually provide helpful built-in mechanisms to point back to a rendered scene graph.   I can think of another OBB reference, which might be useful if you can find a copy online. It is the OBBTree paper written by researchers at UNC Chapel Hill many years ago. Yes, its really old now, but is one of the early presentations of OBB for collision detection, and still useful. Here is a link to the paper. (I admit that I haven't ready it in a long, long time.)   http://www.cs.unc.edu/~walk/papers/gottscha/sig96.pdf   Pierre Terdiman also has done some work that you might find useful:   http://www.codercorner.com/Coder.htm - see OPCODE for example http://www.codercorner.com/RAPID_Hack.htm   Graham
  3. grhodes_at_work

    New version of ColDet

    Thank you for the post! I wonder if you would be willing to write a description of ColDet here, ideally something that is a bit more detailed than the short summary on the sourceforge page. And maybe link to some projects or YouTube videos demonstrating it use?   grhodes_at_work
  4. grhodes_at_work

    OBB calculating extents

    There are some things about your presentation that are worrisome to me, in terms of language use, variable names, and coding style. I offer some suggestions, which you can use if you find them useful.   First, you say that your OBB's having "3 perpendicular normals," but I wonder why you call them normals. Is it because the faces of the OBB are perpendicular to these vectors that you called them "normals?" Why not call them just local coordinate frame axes, or basis vectors, or basis directions, all of which are more general and more appropriate for vectors that define the rotation of a generalized shape? I would also suggest that you completely separate the dimensions of the OBB from the basis vectors in the constructor, for clarity. Embedding the size of the OBB inside the incoming basis vectors...is confusing. There is nothing in the variable names of the OBB constructor parameters that indicates the length of the edges is equal to the length of those vectors.   If I were to write a simple OBB class, it'd look something like this. This is just quickly written code, incomplete, not really designed, not tested, and not exactly what I'd use for a project. This code illustrates an idea. The idea is to suggest building your transformation (location and orientation) as a separate object and just include it in the OBB class. By building the transformation separately, you can re-use it to represent other things in the scene, too. Not just OBB's.   /// simple 3x3 matrix class, to be used to store orientation as a 3x3 /// rotation matrix class RotationMatrix3x3 { public: RotationMatrix3x3(const vec3 &xDir, const vec3 &yDir, const vec3 &zDir) { m_basisVectors[0] = xDir; m_basisVectors[1] = yDir; m_basisVectors[2] = zDir; } protected: vec3 m_basisVectors[3]; ///< x, y, and z direction basis vectors }; /// transformation class to be used to store translation and rotation /// relative to a parent or world Cartesian coordinate frame class Transform { public: Transform(const vec3 &translation, const vec3 &xDir, const vec3 &yDir, const vec3 &zDir): m_translation(translation), m_orientation(xDir, yDir, zDir) { } protected: /// translation vector, represented in a parent or world coordinate frame vec3 m_translation; /// orientation as a 3x3 rotation matrix, represented in a parent or world /// coordinate frame RotationMatrix3x3 m_orientation; }; /// Oriented Bounding Box class, which inherits its location and orientation /// relative to a parent or world coordinate frame via the Transform class class OBB : public Transform { OBB(const vec3 &translation, const vec3 &xDir, const vec3 &yDir, const vec3 &zDir, const vec3 &extent) : Transform(translation, xDir, yDir, zDir), m_extent(extent) { } protected: /// extent along local object basis directions vec3 m_extent; };   I hope this is somehow useful.   grhodes_at_work
  5. grhodes_at_work

    A Daft Statement

    I'm going to move this thread to the lounge. The discussion is somewhat interesting, philosophically, and there's been some meaningful interaction. But the thread is not in fact about math or physics, or game development. Therefore, it doesn't belong in the math and physics forum.   grhodes_at_work
  6. grhodes_at_work

    normals in tangent space question

    There is some very good discussion here, and I appreciate all of the contributions. There are a couple of points that I think are worth restating, or clarifying, so that people might understand more deeply.   With regard to which aspect of geometry the TBN is associated, the TBN exists for any point on the surface, not only at each face, and also not only at each vertex. It may be computed at each vertex, or each pixel, or once per face for that matter, depending on how it is to be used (vertex or fragment shader or just asset calculations on the CPU) or what is convenient, but strictly speaking it exists continuously across the surface.   With regard to the tangent direction, it is not in general true that it is defined to point in the direction of change of the u coordinate. A tangent vector can be any vector that is located in the tangent plane at a point on the surface (the tangent plane being the plane that is orthogonal to the local surface normal at that point, er, for a surface that is continuously differentiable). So, as Bacterius noted, it is true that there are infinitely many possible tangent space choices at any point on the surface.   It happens that computing the tangent along the curve of the u direction is quite convenient, and, since it aligns with texture coordinates, this choice fits very nicely with computer rendering use cases. Also, on a mesh, standardizing on this choice enables continuity of the tangent spaces across the entire mesh surface. As for the bitangent (which is a more appropriate term than binormal, when dealing with surfaces), it is in fact just like the tangent in that it lies in the tangent plane. It is a tangent vector, just a different one than the T in TBN. In computer graphics the bitangent is often computed along the v direction, again in order to align with texture coordinate directions and provide for TBN continuity, but there is that issue of the u and v directions being nonorthogonal in model/world space (vs. tangent space), as discussed in prior posts. The terathon page linked above discusses this orthogonality issue with a workable solution, concisely.   I know many resources out there explicitly define the tangent to be computed along the u direction and bitangent to be computed along the v direction, but to understand deeply you should recognize that these choices are made merely to achieve the alignment with the texture directions with the happy bonus of TBN continuity. I hope this reply helps someone understand more deeply, if only a little.   Graham
  7. grhodes_at_work

    Problem with construction of two vectors from one [opengl]

    apatriarca,   Thank you for the comment. Its interesting how we come to learn different terminologies. Somehow my path just never crossed with versor. The Wikipedia page specific to versor, http://en.wikipedia.org/wiki/Versor, introduces the quaternion use case, but also mentions the unit vector use case. There has to be some origin point for this word! I think I agree with your view.   Graham
  8. grhodes_at_work

    multiply defined symbols when compiling physx 3.2.4

    I'm glad you solved your problem! Thank you for the follow up. It could be useful for other people, in the future. Graham
  9. grhodes_at_work

    Havok Physics

    By the way, shapes are often used in physics engines to compute mass and inertia tensor....so unless you happen to have specific mass/inertia properties that you want to assign explicitly, you may need to leverage a shape anyway to setup your non-colliding dynamic object!   On to the question at hand.   I'm not familiar with the current Havok API, but there may in fact be a custom shape that is intended to create objects that won't collide. You might be able to, for example, create a sphere with a radius of zero, and Havok might have logic to consider that zero radius sphere as being a "no collide" shape. Although that is hacky. If this is the way it is, hopefully the documentation will tell you. More likely, in addition to a shape, the object can have a flag that says "NO_COLLIDE_FOR_THIS_OBJECT" or something like that....so the shape can be there (and may be useful for debug visualization...who knows), but isn't actually used for collision detection.   Some more thoughts... Many physics engines support the concept of collision groups. Collision groups enable you to explicitly set up objects that may interact over part of the game level. You may have 10 objects over here that can interact, and another 9 over there, but the 10 can never inteact with the 9. It is cheaper to treat them as two separate groups. The idea is that collisions are detected between objects within a common collision group, but not between objects in different collision groups. So, you could created a dedicated collision group for your object that you don't want to collide with anything. If you want to have many objects like this, it may be impractical to have a separate collision group for each. You could in that case add some custom user data to the objects and write a collision callback function that would ignore any detected collision between objects that you do not wish to allow to collide. That approach would still incur the cost of doing some collision detection...it would only avoid the collision response, effectively ignoring the collision. The cost could be mitigated somewhat if Havok allows separate callbacks for broad phase collision detection, which is the first and cheapest phase...basically do the bare minimal collision detection before it gets to the expensive narrow phase and collision response parts.   Graham
  10. grhodes_at_work

    Licensing Code Releases using Bullet 3D

    Open source licensing can be tricky. I would at least be careful to understand ALL of the licenses involved, not just the main Bullet license. (For example, the full Bullet distribution includes binaries for GLUT, which is not open source, and GLEW, and maybe other things...I don't know what the license are for those.) One safe approach would be to release your code without Bullet, but include a README file that has a URL link where people can go to find Bullet and its dependencies for themselves. Just make sure you cover all your bases and make sure you know about everything that is there, what the exact terms and requirements are, before you release anything. And keep GOOD documentation on what you are doing and why. If you had good funding for your project, it wouldn't hurt to consult with an open source/intellectual property rights lawyer, just in case. But of course lots of people release open source without legal council.   Graham
  11. grhodes_at_work

    My approach to physics

    I am surprised that you were unable to find satisfactory discussions of handling multiple simultaneous collisions with multiple collision points. In my view, there is quite a lot of discussions and documentation freely available about how the constraint solvers in modern game physics engines work, and address exactly these problems. This has been continuously worked and improved in the games industry for more than a decade.   For example, here's an intermediate level presentation from an annual tutorial series on physics simulation, from the Game Developer's Conference in 2012, discussing the implementation of a multi-body, multi-contact rigid body contact/constraint solver. The first half focuses on a single contact, but the last half delves into multiple bodies and multiple contacts. There are many such presentations and technical documents out there. The GDC tutorials on math and physics for games have been going on for nearly a decade:   http://www.essentialmath.com/GDC2012/Richard_Tonge_solvingRigidBodyContacts.pdf   And here is one of Erwin Coumans' presentations on rigid body dynamics simulation. The last 25% of this talk discusses using the GPU to accelerate constraint solving. (He presented a new one this year at GDC, back in March, describing new advances in GPU-accelerated rigid body dynamics).   https://github.com/downloads/erwincoumans/experiments/Accelerating%20game%20physics%20for%20heterogeneous%20CPUGPUs.pdf   I bet there are some excellent presentations available at the following link. These are presentations from Erin Catto's physics tutorial at GDC back in March:   https://code.google.com/p/box2d/downloads/list   You would be wise to look at some of these materials, because there are a lot of lessons learned, and practical implementation experience (LOTS of this) in those presentations. Many of these folks have worked on real time physics simulation as their full time job, for years.   The conservation of energy problem is also discussed in the game physics literature, though from a games perspective (fast, stable with large time steps and over long simulation times and for very diverse scenarios, realistic-looking), and not a perfect math/engineering/simulation perspective. For practical problems, even the engineering solutions don't have perfect solutions that satisfy conservation of energy. (In simulating fluid dynamics, there is a class of theoretical problems that can be solved with "perfect shift," numerical solutions of wave-like equations that generate prefectly zero error...but these are only contrived theortical problems...not in practice.) As others have written, physics is hard. But, you knew that! Graham
  12. grhodes_at_work

    Problem with construction of two vectors from one [opengl]

    I realize this is a late reply, and you may have moved on from this post. In any case...   I would first comment that the term versor isn't that commonly used, and it can mean different things. A versor is a unit quaternion. But sometimes, for some reason, versor is used to denote a set of unit length basis vectors aligned with the axes of a coordinate system...and this is how you are using the term. I've been involved in modeling and geometric representations and coordinate space representations for some 30 years, on the practical side rather than theoretical, and I had never seen the word used before in this context. Not that this is a problem, but it confused me.   So, I would like to help on this problem, but your code isn't particularly intuitive. It would help to better understand the outcome that you are looking for. Can you repost your video? It does not seem to exist on YouTube. I can envision a much simpler way to create such a box, but it would help to know what you expect to happen as you move the mouse around.   Graham
  13. grhodes_at_work

    basic collisions

    Perhaps you could ask a specific technical question? Also, it is unclear what we are meant to be paying attention to in your video. If you want to illustrate a specific problem with your collision detection, it would be better to show one simple collision example that shows the problem you're concerned about.   Graham
  14. grhodes_at_work

    Composing the concave hull of a textured sprite

    There's a fancy technqiue called Active Contours, or snakes, that could be used. I'll let you google it. Non-trivial to implement. You would prime the algorithm by computing the convex hull around the sprite.   You could use a flood fill algorithm to find the outer boundary pixels ignorning the holes, Set your seed point to be the upper-left pixel. Run the flood fill to produce a mask, which will not show the holes. Then construct your concave outer boundary from the mask.   Graham
  15. grhodes_at_work

    Fluid Dynamics Books

    I will post a couple of recommendations of fluid dynamics books that I like, although I doubt you would choose them because they focused more on engineering that animation and games, are more classics than very current, and because they are uber pricey. (You may get lucky at a used college bookstore and find a cheap used copy.) But they are very good if you have any desire to understand the nature of fluids and the equations used to simulate them. I personally think it is better to have a good understanding of the physics you are trying to simulate, than just have a loose understanding. Harder to fix problems in the code if you don't understand the physics.   The first one is an excellent book for learning about the nature of fluid flow as it appears in the equations we use to model fluids. It is an undergraduate level CFD book. Highly recommended for those who are good at math and want to understand the physics deeply. I had not realized how pricey these books had gotten. I bought a copy new for US$50 ten years ago. Now it is US$200? Crazy.   http://www.amazon.com/Computational-Fluid-Dynamics-John-Anderson/dp/0070016852/ref=sr_1_1?s=books&ie=UTF8&qid=1367247111&sr=1-1&keywords=computational+fluid+dynamics   The other one is similar, but is more in depth. Graduate school level. This one does get into some semi-modern techniques, such as artificial compressibility (to accelerate solutions for incompressible/elliptic flows), and things like essentially non-oscillatory (ENO) techniques with flux limiters for transonic and supersonic fluids. It is a bit less expensive. Plus, you can rent it for US$40. (WTF? Rent a book from amazon. Crazy.)   http://www.amazon.com/Computational-Mechanics-Transfer-Physical-Processes/dp/1591690374/ref=sr_1_1?s=books&ie=UTF8&qid=1367247513&sr=1-1&keywords=computational+fluid+mechanics   Here is one reason why those books might not be so interesting from the point-of-view of implementing fluids for games. Those books do focus more on the Eulerian approach to fluids, in which you have a fixed volume tracking fluid properties at fixed points or cells within the volume, which is good for designing machines, pipes, airplanes in normal operating conditions...sometimes games. But these days many games solve fluids using the Lagrangian approach, which tracks the motion of individual fluid particles. This enables modeling of, for example, splashes, water collecting into an emergent pool after dynamic changes to the environment, puffs of smoke, etc. More interesting fluid motion for interactive applications and games. For example, the smoothed particle hydrodynamics (SPH) technique implemented in some game physics engines is a Lagrangian fluid solver. But they are very good if you want to understand the nature of fluids and have a deeper understanding of what the terms in the governing equations mean.   http://en.wikipedia.org/wiki/Lagrangian_and_Eulerian_specification_of_the_flow_field   Graham
  • 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!