Jump to content

Recommended Posts

Posted

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

Posted

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.

Posted

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 :/

Posted

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.

Posted

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..

Posted

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();
}

Posted

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 ?

Posted

Thanks I git it now :D 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 :D

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...