bone animations

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Until now I have no bugs encountered...
But I didn't check everything, yet...

Report any bugs and suggestions to me, please !!! ;)

Next I try to create a bone animated ragdoll with Newton !!! 8)
Maybe this will cause some problems, but I don't think so.... ;))

CU, Acki
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Guest

Post by Guest »

@omaremad: ...but you cannot use standard animations with this method, you'll have to use custom ones.
Maybe Acki could add another feature to his code: the modified CXAnimationPlayer can copy the transformations of the joints of current animation in the list of custom matrices in the IAnimatedMeshSceneNode.

@Acki: My method with callbacks works properly too, I can animate shared meshes differently for each node.
I noticed something that can be problematic: in CAnimatedMeshSceneNode::render you do a typecast of the mesh, but if the mesh isn't an IAnimatedMeshX this will probably lead to an error.
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Yes, maybe this could cause probs... :shock:

But it should not cause any probs, if you're using the 2 new functions only on bone animated DirectX files !!!

If you don't use this 2 functions, the mesh and node will be handlet like a normal Irrlicht mesh/node...

Just be sure you're using this functions on an bone animated DX file !!! ;)

CU, Acki
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
fear

Post by fear »

WOW, congratulatoins for your works, i thing it must include in irrlitch, if you can finish the code and it is ok for ragdolls ( bones and joints) it would fantastic for the engine.

Tell it to NIKO!!!!
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

:!::lol::!: !!! New Version aviable !!! :!::lol::!:

Now with Newton - ragdoll demo !!!
The ragdoll is animated over the bones !!!

check this out
http://people.freenet.de/abusoft

CU, Acki
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
fear

Post by fear »

I see demo 2, WOW, WoW and WOW

Congratualtion. I think the bones animation is very good for irrlitch, and it is very easy of include it the next version of irrlicht

Where is NIKO ? what does he think about this bone animation and the pathfinding of CZest ??
fear

Post by fear »

I have a question :

In this code :

---------------------------------------------------
vector3df hipSize(2.5, 1.5, 1.0);
int nrB = 1; // current bone number
pivot.setTranslation(vector3df(-1.25, 0.0, 0.0));
pivot.setRotationDegrees(vector3df(0.0, 0.0, 0.0));
collision = NewtonCreateBox(nWorld, hipSize.X, hipSize.Y, hipSize.Z,&pivot.M[0]);
NewtonRagDollBone* hip_DollBone = addDollBone(ragDoll, NULL, &(*mat1)[nrB], hipSize, collision, nrB);
-----------------------------------------------------

Is it posible change hipSize by a Bounding Box listing every "vertex" of the model and look if they are of that bone ??

Example : For head , i listing every vertes and i look if the vertex is of that bone (head), if it is of that bone i include it in a AABB , right?
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Well the body part sizes are for the Newton collision primitives...
Of course you can add complex shapes (vertex by vertex) to a Newton collision, but I did it this very simple way, just for testings...
So I used only box collisions and a sphere collision for the head...
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Guest

Post by Guest »

Thnx aki this is great

put it on the wiki so it doesnt get lost as the forum grows

btw
what is the function that draws newton collision shapes since it is hard to use trial and error
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Well, there is no function for drawing the collision shape in Newton...
But you can do something like this:

Code: Select all

static void  PhysicsApplyForceAndTorque(const NewtonBody* body);
static void  PhysicsSetTransform(const NewtonBody* body, const dFloat* matrix);

int main(){
  initScene();
  while(device->run()){
    driver->beginScene(true, true, SColor(255,100,101,140));
    smgr->drawAll();
    NewtonWorldForEachBodyDo(nWorld, DebugShowBodyCollision);
    driver->endScene();
    // updatePhysics(); // don't update
  }
  device->drop();
  return 0;
}

void  DebugShowBodyCollision(const NewtonBody* body){
  dFloat Ixx;
  dFloat Iyy;
  dFloat Izz;
  dFloat mass;
  // only show collision for dynamics objects
  NewtonBodyGetMassMatrix(body, &mass, &Ixx, &Iyy, &Izz);
  if(mass > 0.0)
    NewtonBodyForEachPolygonDo(body, DebugShowGeometryCollision);
}

void DebugShowGeometryCollision(const NewtonBody* body, int vertexCount, const dFloat* faceVertec, int id){
  int i = vertexCount - 1;
  vector3df os(10, -1.5, 0);
  vector3df p0(faceVertec[i * 3 + 0], faceVertec[i * 3 + 1], faceVertec[i * 3 + 2]);
  p0 += os;
  for (i = 1; i < vertexCount; i ++) {
    vector3df p1(faceVertec[i * 3 + 0], faceVertec[i * 3 + 1], faceVertec[i * 3 + 2]);
    p1 += os;
    driver->draw3DLine(p0, p1, SColor(255, 0, 0, 255));
    p0 = p1;
  }
}
Maybe the offset from Newton to Irrlicht is different, so the drawings don't share the same place.
But this is irrelevant, you can adjust this by the os vector in the last function...
But dont't update Newton during the adjusting !!! ;)

CU, Acki
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
ThommyE
Posts: 48
Joined: Sun Sep 18, 2005 3:02 pm
Location: germany/badnerlaendle

Post by ThommyE »

hi there,

impressive piece of work. just one question...
why is THAT happening?

Code: Select all

[thomas@localhost 01 - Simple Demo]$ g++ main.cpp -o test -I"../../include" -I"/usr/X11R6/include" -L"/usr/X11R6/lib" -L"../../lib/Linux" -lIrrlicht -lGL -lGLU -lXxf86vm -lXext -lX11
main.cpp: In function »int main(int, char**)«:
main.cpp:34: Fehler: »class irr::scene::IAnimatedMeshSceneNode« hat kein Element namens »makeCustomBones«
main.cpp:35: Fehler: »class irr::scene::IAnimatedMeshSceneNode« hat kein Element namens »useCustomBones«
main.cpp:42: Fehler: »class irr::scene::IAnimatedMeshSceneNode« hat kein Element namens »makeCustomBones«
main.cpp:43: Fehler: »class irr::scene::IAnimatedMeshSceneNode« hat kein Element namens »useCustomBones«
main.cpp:53: Fehler: »Sleep« wurde in diesem Gültigkeitsbereich nicht definiert
sry 4 the german errors^^
i tried to copy'n paste th code over my source, to add the lines manually to the files (no compiler errors during engine compile) and using the pre-compiled stuff(other error but nonsense since i'm using linux).
-same result with my own code.. just the Sleep error isn't there

am i missing something?.. or am i simply to stuipid..
is this code somehow linux-incompatible?

ps:.. well.. seems my compiler needs some glasses.. he wont compile irrlicht anymore,even the original sourcen (he did this already about 20 times without any error)

Code: Select all

cp libIrrlicht.a ../../lib/Linux/
cp: reguläre Datei „../../lib/Linux/libIrrlicht.a“ kann nicht angelegt werden: Datei oder Verzeichnis nicht gefunden
make: *** [staticlib] Fehler 1
well... the file is there. and even if. he sould copy it there..or something in the temp directory?
-strange. but actually im still stuck with the first error
EDIT: never mind the second error... dissapeared after rebooting.(i know it's a crime rebooting linux 4 such a silly reason)
athlon2400xp+,geforce4200ti, 0.2Tb hd+64mb extern, 512mb ram, linux FC5 2.6.16-1.2096, 100%gates-free system
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Hast Du auch die geänderte IAnimatedMeshSceneNode Klasse benutzt !?!?!
Und die Lib und Includes aus meinem Zipfile ???
Es scheint als würde die alte Klasse benutzt, da "hat kein Element namens »makeCustomBones«" Fehler auftreten...


And for those, who don't speak german:
Did you use the changed IAnimatedMeshSceneNode class !?!?!
And the lib and includes from my zip archive ???
It seems you're using the old class, because of the "hat kein Element namens »makeCustomBones«" errors...
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
ThommyE
Posts: 48
Joined: Sun Sep 18, 2005 3:02 pm
Location: germany/badnerlaendle

Post by ThommyE »

i tried using the includes but since i'm using linux only... no chance.
thats y i apllyed the paches manually and recompiled irrlicht. so it should work.
(u also tried to used the includefiles with the rest of the selfcompiled stuff but no sucsees either... like expected)

.. actually i'm no coder but at least the sources of the demo should compile.
but both, demo and my own small code won't compile to the exact same error message.
stupid question .. but ..
the new node class would be:

IAnimatedMeshX* mesh = (IAnimatedMeshX*)smgr->getMesh("mesh/file.x");

and the old one is

IAnimatedMesh* mesh = smgr->getMesh("mesh/file.x");

so using the first one should enable the use of custom bone. since i couldn't figure out an other difference to the normal code.
is there anything non-normal to do to get this working? (excpect patching-compiling-code difference)
athlon2400xp+,geforce4200ti, 0.2Tb hd+64mb extern, 512mb ram, linux FC5 2.6.16-1.2096, 100%gates-free system
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Yes, you're right !!!
With one exception, IAnimatedMeshX is one changed class (not new, it was already in Irrlicht) and IAnimatedMeshSceneNode is the other changed class (althou not new, just edited)

I don't know what the error could cause ???
Maybe it depands on Linux ?!?!?

Any other user tested this with Linux ???
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
ThommyE
Posts: 48
Joined: Sun Sep 18, 2005 3:02 pm
Location: germany/badnerlaendle

Post by ThommyE »

since i added the patch manually (copy&paste the changed parts) i might have missed something.
when i'm trying to aplly the patch like written in the info file i get the following error.

Code: Select all

g++  -c CAnimatedMeshSceneNode.cpp -o CAnimatedMeshSceneNode.o -I"include/" -I"zlib/" -DIRRLICHT_EXPORTS=1
CAnimatedMeshSceneNode.cpp:27: Fehler: Prototyp für »void irr::scene::CAnimatedMeshSceneNode::useCustomBones(bool)« passt zu nichts in Klasse »irr::scene::CAnimatedMeshSceneNode«
CAnimatedMeshSceneNode.h:26: Fehler: candidate is: virtual const void irr::scene::CAnimatedMeshSceneNode::useCustomBones(bool)
CAnimatedMeshSceneNode.cpp:27: Fehler: »void irr::scene::CAnimatedMeshSceneNode::useCustomBones(bool)« cannot be overloaded
CAnimatedMeshSceneNode.h:26: Fehler: with »virtual const void irr::scene::CAnimatedMeshSceneNode::useCustomBones(bool)«
CAnimatedMeshSceneNode.cpp: In member function »virtual const irr::core::array<irr::core::matrix4>* irr::scene::CAnimatedMeshSceneNode::makeCustomBones()«:
CAnimatedMeshSceneNode.cpp:33: Fehler: »class irr::scene::IAnimatedMeshX« hat kein Element namens »getBones«
CAnimatedMeshSceneNode.cpp: In member function »virtual void irr::scene::CAnimatedMeshSceneNode::render()«:
CAnimatedMeshSceneNode.cpp:98: Fehler: »class irr::scene::IAnimatedMeshX« hat kein Element namens »useCMeshBones«
make: *** [CAnimatedMeshSceneNode.o] Fehler 1
well. semms like there is something wrong.
i'm still thinking of this beeing somehow stupid.. your code should be 0.12.0 compatible.. or at least i thaught so.
please correct me if i'm wrong. and if i am. would you mind changing it to be .12. compatible?

PS:a funktion to read out animation data from a 2nd file and add it to the modell-skeleton would be gread. this way you can play 2 animations at once- running+shooting, curching+throwing granades,dieing+reloading^^,etc...

edit:
@Acki: wenns dich ned stört kannst mich mal via icq anschreiben.ich brenne drauf das ding benutzen zu können
athlon2400xp+,geforce4200ti, 0.2Tb hd+64mb extern, 512mb ram, linux FC5 2.6.16-1.2096, 100%gates-free system
Post Reply