Jump to content

  • Log In with Google      Sign In   
  • Create Account

Irlan Robson

Member Since 08 May 2012
Offline Last Active Yesterday, 09:55 PM

Posts I've Made

In Topic: How do i find

Yesterday, 09:34 PM

and how to calculate a volume of that shape:


Code for mesh volume integration by Stan Melax: http://melax.github.io/volint.html. Since his code is not much readable I copy pasted here's my version: http://pastebin.com/MBGWQhFz. Also make sure the mesh is actually not a surface. Otherwise the code will assert.


And help us help you by renaming the thread title from "How do i find" to the actual description title of this thread.

In Topic: [Design] Meshes and Vertex buffers

02 February 2016 - 07:36 PM

So, you're asking for an architecture advice for your mesh implementation, right?


In my engine's model library I have, basically:


CVertexBuffer - topology type, strides, offsets, API specific data (this is an interface basically)

CIndexBuffer - format, index offset, API specific data

CMesh - vertices, and faces 

SHADER_PART (a simple structure) - vertex and index buffers, textures, colors

CDrawableMesh - shader parts, bounding volume(s)


Then I share a drawable mesh across mesh instances. I guess I probably shouldn't point out an ideal actor hierarchy here because it varies from engine to engine. But the basic idea (at least for static meshes) is to cache drawable meshes and not graphics buffers (e.g. don't load them more than once!).


When creating vertex/index buffers for shader parts, just after loading the meshes from a stream at initialization, I pass a structure indicating the usage flags you're talking.


- however the shader determines the required vertex attributes <-- I'm not sure what happens when the shader tries to read an attribute which is not currently bound and set properly.


Shader management was quite discussed here previously. Search on the forums. Nevertheless, I don't feel prepared for pointing out any ultimate solution for a shader system. Sorry! But AFAIK, even on your intermediate graphics framework, you definetly must have some kind of shader manager for each object type on your game (e.g. models, terrains, skeletons, etc.). 


Hope that helps.

In Topic: Resting Contact With Friction

01 February 2016 - 10:49 AM

I use a velocity based formulation, with two tangential directions (in 3D). I remove the relative tangential velocities at the contact point, enforcing lo <= Pt <= hi, where 


hi = u * Pn

lo = -hi

Pn = normal impulse

Pt = tangential impulse

u = coefficient of friction (represents both static and dynamic friction)


This way I get automatic static friction.

In Topic: Contact tangents

04 January 2016 - 09:07 AM

I assume you're using EPA or another algorithm for the penetration calculation. I made no good experience with this in the past. Specially for quadratic shapes and degenerate cases. Here, we recommend you to use SAT instead. But keep your GJK. You will definately need it in your engine later.


We get this type of question a lot. For removing duplicate replies, I recommend you to read this thread




Oh, I forgot mentioning that I have an actual contact creation implementation using the SAT if you need some reference code:




This code actually is not fully optimized, and I haven't release the new version of this engine with new features, but it is fundamentally what should be done to get stable manifolds!


Hope that helps.

In Topic: Contact tangents

03 January 2016 - 10:32 PM

Forget about bias velocities and the Baumgarte scheme, since they artificially add more energy to the system.

I think Erin wanted to emphasize the performance of these algorithms in the old slides, which is quite cheap.

If you really want an stable simulation, then use the Full-Non Linear Gauss Seidel, implemented in Box2D.

Contact creation is hard to get it right. You need a combination of frame coherence, stable manifolds, numerical robustness, and so...

At the very end, you will need SAT (for penetrating shapes) and GJK (for overlapping shapes, most of them are symmetric) in your physics engine in order for you to create correct manifolds. So, the adventure can become quite large, if you choose to support various shapes.

For creating contact manifolds between convex shapes, look at Dirk's Gregorius presentations on the Downloads section at box2d.org. You'll find there what you need.