PhysX: Joint friction/"stiff" joints - c++

I'm working with physx (trying to add ik to ragdoll) at the moment. For some reason, all ragdoll joints are frictionless, and as a result, ragdoll tend to "wobble", especially when it is hung in the air and is connected to several moving kinematic actors.
I would like to add friction to the joints and make them "stiff". Imagine a door (with extremely rusty hinge) that needs to be kicked several times to be open - i.e. it rotates around the hinge, but not much, quickly stops, and large force is required to make it rotate.
Or think about art manikins (see google images for pictures) - their limbs move around, but they do not swing around freely.
Unfortunately, I can't find anything related to joint friction in physx. I've checked documentation, google, and headers, and couldn't find anything useful.
So, how do I implement stiff joints/joint friction with physx? (I think) I've seen physx games without that problem, so apparently there should be some way to do that.
P.S. I'm not talking about joint/solver instability here. Ragdoll is stable (more or less), and joints honor degrees of freedom(joint limits), but joints have no friction, and I would like to add friction to them.

I've asked a question on the nvidia forums recently which might be related to this: link
Unfortunately I didn't get a real answer to my questions but managed to do what I want to do, using a spring in the joint might help you here if you only add a damping constant without a spring constant. This works in my case but I can't explain why so while I'm happy to use it I'm not totally sure whether to recommend it.
I don't know whether you could also add angular damping to all of the individual parts of the ragdoll, that would make them slow down quicker after they've started moving but it might not look right. Probably one of those things you will have to experiment with.

I found this forum thread about wobbly joints in Physx, dont know if you've seen it but I hope it helps.

Why don't you try that:
d6Desc.swingDrive.driveType.raiseFlagMask(NX_D6JOINT_DRIVE_VELOCITY);
d6Desc.swingDrive.forceLimit = 0.1f;
d6Desc.twistDrive.driveType.raiseFlagMask(NX_D6JOINT_DRIVE_VELOCITY);
d6Desc.twistDrive.forceLimit = 0.1f;
d6Desc.driveAngularVelocity.x = 0;
d6Desc.driveAngularVelocity.y = 0;
d6Desc.driveAngularVelocity.z = 0;
You drive the velocity to 0 with a small force, this way movement will be reduced and you objets will stop moving on the floor. It's not exactly like friction but near.

Related

After Effects Camera Solve crashing?

I am using the camera tracker on a clip of roughly 10000 frames 740x360, 50fps, prores codec. There are a lot of trackable features in the clip.
When I use the tracker on only a part of the video the tracking completes in less than a minute. But when I try to camera solve the whole clip solving is not done even after 10 hours (I let it run over night).
I was thinking that maybe there is a hard to solve part of the video, so I cut the clip up into multiple parts and solved each of them separately, they all got solved just fine in a few minutes, so I don't think that is the case.
Do any of you know of similar occurrences or of a way to solve that problem?
Something that helps a lot is using super high shadow/highlight and contrast in a pre-comp so that ae has more clarity between different parts of the shot and therefore tracks better.
Pre-compose your shot (right click and select pre-compose)
Apply Shadow/Highlights using Shadow/Highlights and/or lumetri color
Apply contrast once, twice, or more if needed to get strong edges for ae to see everything and track the shot.
Note: You can remove these effects later, this is just to help ae "see" better to track the shot.
Hmm not sure if I understand but the tracker is not supposed to be over the whole image. You need to chose one specific part that is in a contrast to the surroundings and chose that as the tracking point.

Handling inverse kinematics: animation blending or math?

I've been working for the past four days on inverse kinematics for my game engine. I'm working on a game with a shoestring budget so when the idea of inverse kinematics came up I knew I had to make it such that the 3D models bones would be mathematically changed to appear to be stepping on objects.
This is causing some serious problems with my animation, after it was technically implemented the animations started looking quite bad when the character was wlaking up inclines or steps even though mathematically the stepping was correct and was even smoothly interpolating.
So I was wondering, is it actually possible to get a smooth efficient inverse kinematic system based exclusively on math where bones are changed or is this just a wild goose chase and I should either solve the inverse kinematics problem with animation blending or don't do it at all?
Definitely solve it with animation blending. Its far easier. Also bear in mind that you may have to enforce limits on what is acceptable because sometime you may break the animations through outrageous IK movements. Constraints are your friend.
Alas, I can't go into much more detail as the maths behind IK has always left me dribbling ;)
First you have to study how everything works. Take a look at Assassin's creed. Correct me if I'm wrong but I think it was the first game to ever implement inverse kinematics. It uses a piece of software from autodesk to do that.
As Goz said, using constraints can very much improve the quality of your animation blending but you should also use inverse kinematics only when necessary.

SolidWorks API - Electromagnetic Dynamics

Is it possible to simulate custom forces (in my case, electromagnetic) using the SolidWorks API for Animator/Motion Study/COSMOS/EMS?
I'm looking for any combination of API's that would expose the required data to be able to simulate the dynamics of either electrical positive/negative or magnetic north/south forces.
The very basics of what I need to be able to do is:
Model two cubes
Mark a point on one as having positive charge and the point on the other as negative charge (or north/south magnetism)
Press "Go"
Watch them come together and stick
Once I can figure out how to do this, I can go through with the more complicated code that I'm trying to write (that's not the problem). I'm simply stuck on where to begin. I have searched and searched but cannot find a definitive answer, the documentation is sparse and hard to grasp.
If this is definitely not possible or not worth it to attempt in SolidWorks, then that's an acceptable answer. I never would have chosen SolidWorks if I was left free to pick the platform, but it was chosen for me.
EDIT
It seems COSMOSMotion API's IDDMActionReactionForce class is what I was looking for. Can anyone point me to an example of using it to define a custom force between two objects?
I can't speak about SolidWorks, so my answer may be irrelevant — BUT I have used ray-tracing software to model dynamic systems.
I my case, I was simulating the circumstances of lunar and solar eclipses. The ray-tracing software (POVRay) took care of generating an image of the scene including the Sun, Earth and Moon, but I had to calculate the positions of the various bodies for each frame of the animation.
I suspect this may be the case with modelling Electromagnetic Dynamics, and you will have to calculate the positions of the bodies involved at intervals, so that Solidworks will render the scenes of an animation.
I may be all wrong about the capabilities of SolidWorks, so I wish you luck.
I was tempted to say that "it's impossible" because you said it would be "an acceptable answer", but that would be too easy.
After much trying, my conclusion is SolidWorks is not the appropriate platform for this. It doesn't let you hook into its internal physics calculations and the Force object I spoke of is way too inefficient for the problem I needed to model. Theoretically, it will work to bring two cubes together along side SolidWorks' built in gravity/collision detection simulation elements but when confronted with an n-body problem, it was apparent that it wasn't made for that.

Simple 3D graphics project? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I'm looking for some good ideas for a simple 3d graphics program as my final project for an intro to computer graphics class. As for some background information, we'll be using opengl and will have a little over a month to work on it, so nothing too far-fetched. The simpler and "prettier" looking, the better. It does, however, require some sort of interface that the user can interact with (so a very simple game or similar is a good idea) and must be 3D.
My only idea so far is maybe a 3D version of Tetris (google for some examples).
Edit: I ended up going with 3D Tetris. For a less than a month's worth of time, you can see what I came up with here.
A 3D text/code editor. Text is 3D, errors stand out, code indentations not only indent, but protrude on z axis, pages/files are 3D and can be flipped like a ringpad.
Probably not useful, but fun and more interesting than a game IMO.
In university, for my parallel programming course, I did an openGL/MPI implementation of Conway's Game of Life. It was quite interesting. Wish I still had the code around somewhere. The advantage of using open GL is that you can lay out the grid in different orientations rather than a flat grid. Remember, code doesn't exist until it's checked into source control.
Putting some physics in makes it more interesting. How about implementing Labyrinth (the maze toy where you are supposed to guide a ball from the starting point to the goal by tilting it).
EDIT: Erik told me it's called Labyrinth.
A 3D minesweeper game similar to this one.
Rubik's cube.
Look at http://www.contextfreeart.org/ ... write something similar, but for 3d.
If you've ever played Missile Command I belive that this could be a good project to '3d-ify'.
Try a chicken crossing the road game.
You will probably need to demonstrate the bare minimum of:
textures
lighting
animation
interaction
collision detection
Do not include even simple physics if there are no marks for it. Prioritise tasks based on the marking scheme. Get something simple working first and back it up :)
Honestly it's actually pretty easy to load up a bunch of animated models and set up a simple first person shooter. I mean, to get a generic thing working you don't need all that much:
Either load and display a heightmap or a BSP tree as the level.
Load and render some simple MD2 models (keyframe animation, low amount of polys and simple format).
Draw a simple hud.
Ray/AABB intersection, every time the user clicks you'll need to cast a ray from the center of the screen and see if it intersects an the bounding boxes of the enemies.
Simple FPS camera system.
The above is pretty doable in a month for as far as I'm concerned. (It's probably doable in a week if you already know some of the stuff).
I tried to do a 3D Asteroids for a class once. I never completed the gameplay part, since it was a graphics class. The ship could move around, as could the asteroids, but there was no collision detection. The ship and the asteroids had 3D textures applied to them, and the asteroids were built out of ellipsoids, so they were actually 3D. The gameplay was all 2D, though.
How about one of those games that are a wooden maze with a ball rolling around the top. You tilt the board and try to get the ball round the maze without falling down the hole? It has the advantage that it's relatively simple to get started, but you could probably think of some extensions if you have time.
If you're looking for a true university size task, mine was to produce a small helicopter "game" where you could take off from an aircraft carrier in an ocean and fly around with some environmental effects, moving water etc. i.e. nothing too complicated. As another example, the task set for the year previous to mine was a little sans-opponent racing game.
I would worry that you may loose marks with tetris as it sounds like little would be done on the z-axis and may come across a little too 2d though it obviously depends on your brief.
Anyway, these will give you the chance to experiment with the basic OpenGL features such as fog, lighting, geometry, textures and some basic movement physics & collision detection/response.
Further on this, though often beyond the scope of such a university sized task you could then take this further add nicities such as animated geometry (e.g. people), environment mapping, reflections, shadows, particle systems, shaders, perhaps a heightmapped island.
Rewrite Blocks 3D. The graphics on this project look horrible now. I remember playing this game (or one like it) on a 386 with wireframe graphics... awesome. The game is basically 3D tetris.
I would check Panda3D or Pygame.
Panda3D is probably close to what you are looking for, and one idea that always works is to put the user's face in the main character or object. 3d-pong with the player's face? Use something unexpected... like a tetris made of burgers instead of bricks.
I love little self-organising alife applications like boids. They can be fun to code and always benefit from a nice UI, especially 3D ones. User input can modify aspects of the environment as well as moving around/through the environment.
I like exoplanets. Go read up on them. On Wikipedia and http://exoplanet.eu there's a lot of information. Astronomers and public outreach people could always use fresh 3D animations showing how the Doppler effect works, or how the planet transiting in front of the star makes it for example 0.5% dimmer.
Or, what I work on, is how when the planet passes behind its star. At Earth we receive just a teeny bit less infrared from that star. The user could adjust the orbit, size of planet, etc. and see how that affects what astronomers see. It could be fun, simple enough to do, and unlimited potential in extending the work for nicer textures, slick lighting effects, etc., and you could end up with something to contribute to science education.
I'd be making such 3D animations myself, if I weren't busy helping crunch numbers for the actual science. I'll be jealous!

2d game physics?

Can anyone point me to a library for 2D game physics, etc for programming gravity, jumping actions, etc for a 2d platform/sidescrolling game ?
Or could you suggest some algorithms for side scroller like mario, sonic etc?
It sounds like Chipmunk might meet your needs.
Your best bet is most likely Box2D. It does 2D physics, has tons of options, and is very easy to integrate into an existing project. It does CCD by default for fixed bodies, but any rigid body can be selectively included in the CCD calculation.
If all you need is gravity, you can program that yourself in 5 minutes. Free-falling objects accelerate down at 9.8 meters per second per second - that is, an object's downward velocity increases by 9.8 meters per second of free-fall. For a game, you'll want to divide that 9.8 by whatever your frame rate is. For jumping, just pick a significant negative vertical velocity, apply that to the character at the instant they jump, and decrement it by your per-frame gravity increment. That's really all you need for something like Mario, unless you're looking for a 3d background for your 2d side scroller.
If you want to get fancier, you can try to take an object's impact force into account, making falling objects hurt people or crack pavement or something. For this, use the formula for Kinetic Energy: KE = 1/2 * M * V^2, where M is mass and V is velocity.
What platform are you looking for? What library you use will depend on this.
For the XNA framework, Farseer is pretty nice.
To answer the second part of your question, if you want to get a handle on how a simple 2D platformer works, take a read through the tutorials for N. Yes, N is a flash-based game but that doesn't mean it isn't constructed like a "real" game, so the collision detection (and response) tutorials are very much applicable. They're a straightforward read with some intuitive demos embedded in the page to show off the geometric concepts.
You could look at the Havok engine. I believe they released a free version for non-commerical use. There is a constraint kit for it that will allow you to constrain the physics to 2 planes, in your case, x and y.
The physics in most 2D side-scrolling platform games are so simple that you could easily implement them yourself. What kind of effects are you looking for?
If you got the time you could use PhysX but its likely an over kill for 2D.
Besides that if you plan on having your game work on a PC and want some cool physics, try googling for "verlet integration" I know there are quite a few verlet implementations around (nice for particles and 2D rag-dolls).
I've used Box2D in personal projects. It is a 2D physic simulation API. But, it might be overkill if what you want is more a game/graphic API.
This guy has done a lot of work with Javascript games:
http://blog.nihilogic.dk/
You can do 2d physics with opende as well