Can someone help me with reactive sword IK for VR? - physics

The Goal: To have a sword that collides with the environment, but most importantly, other swords.
the sword is attached to the hand that is driven by the motion controller
The issue: Can't figure out how to calculate hit into wrist/arm IK.(any info on how to do it would be helpful)
Hello here's the rundown. I am trying to make a VR sword mechanic where the sword can interact with terrain and change the hand/arm bone rotations based on the hit. Do not worry about immersion because we plan to do a ghost for when the arm isn't at the same transform as the real arm.
I tried to do a few calculations for sword hit to get the wrist to rotate dependent on how the sword hits a wall/weapon. Also decided I'm not going to do physics for a arm.

You can Easily use the two bone IK node or the older fabrik node in animation bp to change the transform of bones while in animation

Related

Interpolating rotation around an axis - quaternions and slerp vs linear interpolation of angles

Im making a simple 3d game where Ive got some boats colliding and changing directions to avoid eachother.
Part of the collision handling is built around bouncing and then diverting the heading direction slightly (boat A hit boat B, A bounces back then rotates say 10 degrees to the left and resumes movement)
So far, Ive just updated the heading direction, which looks a bit abrupt. I intend to interpolate from the old heading to the new one. It is very simple, the heading is always just an angle around one axis. So basically its going from say 90 degs to 110 degs.
Im aware of quaternions and slerp, which would give me a constant velocity (my rotation should be silky smooth). But I just end up feeling like its using a sledge hammer to kill a fly. What is really the consequence of just doing a regular vanilla linear interpolation from 90 to 110 for the rotation angle? Will it even be visually noticeable that I have used quaternions instead of the much simpler and much cheaper linear interpolation of angle values? I have no special important "key frames" that need to be hit - there is no "animational data" at all, the 3d models are static.
So if someone could shed some light of what potential problems I could run into if I just interpolate the rotation degrees instead of using slerp, it would be much appreciated.
Thanks
/Jim

Create and use a target for SCNCamera

I come from 3D software use, wherein most cameras have a target, which makes moving the camera and its view point much easier, generally speaking, then using a "free camera" that's not got a target.
How would this be done in Scene Kit?
e.g. my first thought was to use an SCNNode as a dummy sort of target, fixed in the world space, connected via a physics joint to the camera.
When wanting to pan the camera, release the dummy from its lock in world space. All other operations (rotate, dolly, roll) the camera moves around/to the fixed dummy. And moving the dummy causes the camera to track it.
Is there a better way? Or easier way? Or more sensible way?

opengl es 2.0 drawing imprecision

Im having a weird issue in opengl, it goes like this: im designing a 2d engine, so far i coded the routines that let's you draw sprites, rectangle, boxes, translate and scale them... however when i run a small demo of my engine i notice when scaling gradually rectangles in an animation (drawn using 4 vertices and GL_LINE_LOOP), the rectangle edeges seems to bounce between the two neighboring pixels.
I can't determine the source of the problem or even formulate a proper search query in google, if someone can shed some light on this matter. If my question is not understood please let me know.
Building a 2D library on OpenGL ES is going to be problematic for several reasons. First of all, the Khronos specifications state that it is not intended to produce "pixel perfect" rendering. Every OpenGL ES renderer is allowed some variation in rendered results. This is because the actual rendering is implemented in hardware and floating point rounding can be a little different from platform to platform. Even the shader compilers are completely different from one GPU to the next.
Another issue is that most of the GPUs on mobile devices today are tile-based deferred renderers, and they do not typically support partial screen rendering. In other words, every screen update requires replacing the entire frame.

Make rectangle fall when being hit by ball (different outcomes depending on properties)

I've just got started with physics. I'm using Java, though language does not matter obviously. Now I though I'd do something like this:
A ball with a certain speed, radius and mass hits a rectangle with a certain mass, width and height. Depending on where the ball hits the rectangle (how high up), and all the properties the ball and the rectangle have that i just mentioned, there will be different outcomes of the situation.
These are the four possible outcomes:
The ball bounces back because the rectangle was too heavy
The rectangle starts to wobble, but then goes back to normal
The rectangle falls to the right
The ball strikes through making the rectangle fall to the left
Please note, I don't expect you to write a program for me. I understand it is a lot to think off. But I have no idea how to start. I would really appreciated some guide lines and links to further reading about this (I was not sure what to google to find info about this.)
And also, I'm doing this to learn, so don't tell me to use an engine or anything like that.
You are trying to build a simple physics simulator. This is a pretty involved problem, and you'll have to learn a certain amount of physics along the way.
I suggest you develop the simulator to handle these situations, roughly in this order:
An object moves through space (constant velocity, no gravity).
An object moves under the influence of a constant force (such as gravity).
An object moves with a constraint (e.g. a pendulum, a rolling square).
An object slides across a surface, with friction (both static and kinetic).
Two objects collide inelastically (they stick).
Two objects collide elastically (they bounce).
Once you have all of these, you will be able to simulate your ball and rectangle.

Sand Physics for iOS

What is the best way to make sand particles animate in a view?
Essentially, I would like to half fill the iOS device's screen with small sand-like particles, then allow a user to rotate and shake the device to dictate the sand's position.
Assuming I have never done any physics programming before, can anyone recommend a tutorial or show me how it's done?
Thank you,
Query.
UPDATE:
I have now come across this (mine should be 2D though) - how can I bring something similar into my app?
Using spatial indexing for finding the nearest-particles to check for collision and using an integration technique for the transition between force(acceleration)-velocity-position and using only gravity force as an outer-fource would give you your sand-box.
You will need to select a good exclusion-force derived from a particle-potential if you use post-collision detection.
I advise you to use the Truncated Lennar-Jones potential and Verlet-Integrator. Easier than Runge-Kutta's and more precise than Euler's. Because it is used in molecular-dynamics. You dont need to use other forces . Just use exclusion force, gravity and wall forces.
If you have bullets in your simulator, you can use Euler-Integration for them. I think this is acceptable for free-falling but not colliding sand particles. After they close each-other, it would be good to use Verlet or Runge-Kutta.
All i mentioned above assumes your integration step is so big that energy is not conserved and even decreased. If your integration is good enough to conserve energy, you will need to give your particles friction force to make sands slow or you will get your particles exploding everwhere.
If you like to make it on iphone then you have to think of certain optimizations and tricks as iPhone can't really simulate water or sand.
Your trick is that most of your work is to draw scene.
Create scene in Box2D with balls at size 10-20 times bigger then sand particle.
iPhone would be able to simulate it.
Then you should draw 10-20 sand particle per ball.
Every frame you may check if ball collides with other balls or not.
If balls is not colliding then these sand particles are in the air and you should draw them on certain distance one from each other.
If ball collides with other balls then particles should be rendered together
You may also detect margin and render glider sand border on top.