How to create imitation of the flexible stick.
I must influence upon one edge and stick must be bent..
How to create imitation of the flexible stick.
Well, bending equation for a beam is:
d=PL^3/(3EI)
Where d is the displacement (in millimeters), P is the force (in Newtons), L is the length to the point of bending (ie, in your image, you would calculate this at four points), E is the modulus of elasticity of the material (steel = 210,000 MPa), and I is the moment of inertia.
To calculate the moment of inertia, you need the cross-section of the stick. Lets say it's round, then we use:
I=pi*r^4/4
Where r is the radius of the cross-section.
Cheers,
Pinky
d=PL^3/(3EI)
Where d is the displacement (in millimeters), P is the force (in Newtons), L is the length to the point of bending (ie, in your image, you would calculate this at four points), E is the modulus of elasticity of the material (steel = 210,000 MPa), and I is the moment of inertia.
To calculate the moment of inertia, you need the cross-section of the stick. Lets say it's round, then we use:
I=pi*r^4/4
Where r is the radius of the cross-section.
Cheers,
Pinky
Intellectuals solve problems - geniuses prevent them. -- Einstein
#irrlicht on irc.freenode.net
#irrlicht on irc.freenode.net
That is assuming that the force applied is always perpendicular to the tip of the stick. If the vector of the force is constant ( like for example gravity on a stick hanging out sideways) then as the stick deforms, the angle of the force applied to the tip of the stick will change. You may or may not want to correct for this depending on how accurate you want your simulation to be.
With a force that is aways perpendicular to the tip and given enough force applied, the stick will form a spiral. This is not the case if the vector of the force remains constant.
With a force that is aways perpendicular to the tip and given enough force applied, the stick will form a spiral. This is not the case if the vector of the force remains constant.
Start with:
http://irrlicht.sourceforge.net/tut004.html
This will show you how to move nodes.
sgt_pinky gave you the math you need.
It's up to you to write the C++ that uses the math.
http://irrlicht.sourceforge.net/tut004.html
This will show you how to move nodes.
sgt_pinky gave you the math you need.
It's up to you to write the C++ that uses the math.
if you want to use bones, you can set bone positions using acki's x custom bones patch.
but for such a simple mesh as a stick it would be just as easy to move the vertices of your mesh manually.
use smgr->getMeshManipulator()->createMeshCopy(IAnimatedMesh->getMesh(0)) to get an SMesh from your model file, then you can access the SMeshBuffer and deform it by setting the positions of the vertices.
start your journey into the docs at the mesh manipulator and finish somewhere around SMeshBuffer. (you'll need to cast SMesh->getMeshBuffer to an SMeshBuffer)
but for such a simple mesh as a stick it would be just as easy to move the vertices of your mesh manually.
use smgr->getMeshManipulator()->createMeshCopy(IAnimatedMesh->getMesh(0)) to get an SMesh from your model file, then you can access the SMeshBuffer and deform it by setting the positions of the vertices.
start your journey into the docs at the mesh manipulator and finish somewhere around SMeshBuffer. (you'll need to cast SMesh->getMeshBuffer to an SMeshBuffer)