Shard Posted May 9, 2010 Share Posted May 9, 2010 I've been trying to parent the camera to the head of my character (after failed attempts with my model, I'm now testing with Crawler from the tutorial) and after some debugging, I've found that the position and rotation for the child head is all messed up. The Y and Z positions are all off. This is code from the tutorial with my debug code in it. Using break points you'll see that the head pos and rotations are all off. #include "engine.h" int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nShowCmd ) { Initialize(); //Create a graphics context Graphics(800,600); //Create a world if (!CreateWorld()) { MessageBoxA(0,"Error","Failed to create world.",0); goto exitapp; } //Create a camera TCamera cam=CreateCamera(); CameraClearColor(cam,Vec4(0,0,1,1)); MoveEntity(cam,Vec3(0,0.85,-2)); //Create a render buffer for lighting TBuffer buffer=CreateBuffer(800,600,BUFFER_COLOR|BUFFER_DEPTH|BUFFER_NORMAL); //Create a spot light TLight light=CreateSpotLight(); RotateEntity(light,Vec3(20,45,0)); EntityColor(light,Vec4(2,2,2,1)); MoveEntity(light,Vec3(0,0,-5)); SetShadowmapSize(light,1024); AmbientLight(Vec3(0.1)); //Load the animated mesh TMesh mesh=LoadMesh("abstract::crawler.gmf"); TEntity head=FindChild(mesh,"Bip01 Head"); //Main loop while(!KeyHit(KEY_ESCAPE)) { TVec3 pos2 = EntityPosition(mesh); TVec3 pos = EntityPosition(head); TVec3 rot = EntityRotation(head); if (KeyDown(KEY_LEFT)) { TurnEntity(head,Vec3(0,0.5,0));} if (KeyDown(KEY_RIGHT)) { TurnEntity(head,Vec3(0,-0.5,0));} if (KeyDown(KEY_UP)) { TurnEntity(head,Vec3(0.5,0,0));} if (KeyDown(KEY_DOWN)) { TurnEntity(head,Vec3(-0.5,0,0));} //Animate the mesh //Animate(mesh,AppTime()/100.0,1.0,0,true); UpdateWorld(); SetBuffer(buffer); RenderWorld(); SetBuffer(BackBuffer()); RenderLights(buffer); Flip(); } exitapp: return Terminate(); } Please see the related thread here: http://leadwerks.com/werkspace/index.php?/topic/1916-parent-entity-screwing-up-entity-rotation/ Quote Programmer/Engineer/Student www.reikumar.com 2.6 GHz Intel Core Duo - nVidia GeForce 8600 GT - Windows 7 64-bit - 4 Gigs RAM C++ - Visual Studio Express - Dark GDK - Leadwerks SDK 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.