# grhodes_at_work

Moderators

3418

1385 Excellent

• Rank
Contributor
1. ## How to get sliding response to collisions (voxel terrain, mini-voxel camera)

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

3. ## 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. ## 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. ## 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. ## 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. ## 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. ## 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. ## 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. ## 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. ## My approach to physics

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