ParaToxic Posted February 10, 2013 Share Posted February 10, 2013 Hey ya, I would like to ask if it is possible to rotate a bone of a animated mesh white the animation. I have positioned and rotated my camera to the Head bone of a character and wants to rotate it while the running/idle animation ... but I doesn't work, I can only do that when the character isn't animated ( so without the Animate() function ). Can somebody help me ? Thanks Quote Link to comment Share on other sites More sharing options...
Furbolg Posted February 11, 2013 Share Posted February 11, 2013 Hi Guys, dont know if it works but have you tried to animate() and then move the headbone ? Quote Link to comment Share on other sites More sharing options...
ParaToxic Posted February 11, 2013 Author Share Posted February 11, 2013 Well it doesn't work I deleted all rotation keys for the head bone but I still can't rotate it Quote Link to comment Share on other sites More sharing options...
Rick Posted February 11, 2013 Share Posted February 11, 2013 I'm with Furblog, you have to get the head bone entity, animate the model as normal, and then move the head bone with your own logic. I did something like this a few years ago and it works. Quote Link to comment Share on other sites More sharing options...
ParaToxic Posted February 11, 2013 Author Share Posted February 11, 2013 Look at my code: [/size] TEntity mesh = LoadMesh("abstract::mesh.gmf"); ..... Update Animate(mesh,AppTime()/40.0,1.0,0); TurnEntity(FindChild(mesh,"Bip_Head"),Vec3(1,0,0)); It doesn't work for me :/ Quote Link to comment Share on other sites More sharing options...
Rick Posted February 11, 2013 Share Posted February 11, 2013 The first thing I would do is make sure FindChild is getting the right bone. Just make a small example program where you aren't animating the entire thing, and just mess around with that bone to make sure you visually see the results. Also, I think there is a tutorial about this. The animating one. Quote Link to comment Share on other sites More sharing options...
Rick Posted February 11, 2013 Share Posted February 11, 2013 http://www.leadwerks.com/werkspace/page/Documentation/le2/_/tutorials/introduction-to-animation-r474 Look around the middle of this tutorial and Josh does what you are trying to do. Quote Link to comment Share on other sites More sharing options...
ParaToxic Posted February 11, 2013 Author Share Posted February 11, 2013 Thanks for the answer.I mean it isn't the problem of the child.When I get the child and move it around without the Animate function everything works fine but with the Animate function it doesn't effect anything.. Quote Link to comment Share on other sites More sharing options...
ParaToxic Posted February 11, 2013 Author Share Posted February 11, 2013 Look at that.I tried with the soldier mesh and the animation sequences: #include "engine.h" #include <iostream> #include <string> const int ScreenWidth = 800; const int ScreenHeight = 600; const char* MediaDir = "D:/Leadwerks Engine SDK 2.5 V2"; const char* AppTitle = "Anim"; void ErrOut( const std::string& message ) { std::cerr << message << std::endl; } // ------------------------------- int main( int argn, char* argv[] ) { // Initialize if( !Initialize() ) return 1; SetAppTitle( AppTitle ) ; RegisterAbstractPath( MediaDir ); // Set graphics mode if( !Graphics(ScreenWidth,ScreenHeight) ) { ErrOut( "Failed to set graphics mode." ); return 1; } // Create framework object and set it to a global object so other scripts can access it TFramework fw = CreateFramework(); if( fw == NULL ) { ErrOut( "Failed to initialize engine." ); return 1; } // Set Lua framework object SetGlobalObject( "fw", fw ); // Set Lua framework variable BP lua = GetLuaState(); lua_pushobject( lua, fw ); lua_setglobal( lua, "fw" ); lua_pop( lua, 1 ); // Get framework main camera TCamera camera = GetLayerCamera( GetFrameworkLayer(0) ); PositionEntity( camera, Vec3(0,2,-2) ); // Create cube TMaterial material = LoadMaterial( "abstract::cobblestones.mat" ); TEntity mesh = LoadMesh("abstract::soldier.gmf"); int seq = LoadAnimation(mesh,"abstract::animidle.gmf"); TEntity child = FindChild(mesh,"Bip01 Head"); SetBloom(1); SetHDR(1); SetSSAO(1); // Create ground TMesh ground = CreateCube(); ScaleEntity( ground, Vec3(10,1,10) ); PositionEntity( ground, Vec3(0,-2,0) ); PaintEntity( ground, material ); // Add some light TLight light = CreateDirectionalLight(); RotateEntity( light, Vec3(45,45,45) ); // Spin cube until user hits Escape while( !KeyHit() && !AppTerminate() ) { if( !AppSuspended() ) { Animate(mesh,AppTime()/70.0,1.0,seq); if(KeyDown(KEY_UP)) TurnEntity(child,Vec3(1,0,0)); UpdateFramework(); RenderFramework(); Flip( 0 ); } } return Terminate(); } Quote Link to comment Share on other sites More sharing options...
Furbolg Posted February 11, 2013 Share Posted February 11, 2013 The Animate() then Child thing works for me Quote Link to comment Share on other sites More sharing options...
ParaToxic Posted February 11, 2013 Author Share Posted February 11, 2013 The same code ? Can you send me your project? Quote Link to comment Share on other sites More sharing options...
Furbolg Posted February 11, 2013 Share Posted February 11, 2013 Im sorry, i can't send you my project because it has some unnecessary stuff for your problem in it (gamestate, world, some prototype ai management etc). I did the following (pseudo code) // Loading LEO::Mesh* dragon = new LEO::Mesh("abstract::dragon.gmf"); // its from 3d foin LEO::Entity* dragonhead = new LEO::Entity(dragon->findChild("Bip01_Head")); // Update dragon->Animate(frame, 1, 0); dragonhead->SetRotation(Vec3(0, -90, 0)); I dont use LoadAnimation, maybe it causes problems ? Quote Link to comment Share on other sites More sharing options...
ParaToxic Posted February 11, 2013 Author Share Posted February 11, 2013 Thanks I git it now Well the TurnEntity function doesn't work here, the result is the same as with 'RotateEntity, so the TurnEntity(...Vec3(1,0,0)) causes only a 1 degrees rotation and not 1 degrees per frame. When I call first the animate function an then the rotateentity function it works well....so thanks Quote Link to comment Share on other sites More sharing options...
Furbolg Posted February 11, 2013 Share Posted February 11, 2013 Yea,TurnEntity dont work here. Animate seems to calculate local matrices new every time. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.