Shard Posted December 30, 2009 Share Posted December 30, 2009 Hey guys. Been a while since I've posted. Hope ya'll are having great holidays. So my question is about zooming. In my game, the player can go into overhead view, which allows the camera to fly above the battlefield so that the players can see more of the field. Then they can hit a key and zoom back into their character bodies. While I have the most if it figured out, I'm not sure how to do the transition. Currently, I'm using the code below but that just sends the camera flying away from the screen. Has anyone ever tried this before? What should I do? void Switch() { switching = true; TVec3 newPos = EntityPosition(player->player); cameraPos = EntityPosition(world->frameWerk.GetMain().GetCamera()); newPos.Y += 5; newPos.Z -= 10; if(cameraPos == newPos) { switching = false; } else { MoveEntity(world->frameWerk.GetMain().GetCamera(), Vec3(0,5,10)); } } void Update() { if(switching) { Switch(); } else { //Do other stuff } } 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...
TheoLogic Posted December 30, 2009 Share Posted December 30, 2009 To get this smoothed out use Curve. Now you are using some linear movement, if you want some swifty side movement you'll need to use some math. Quote Follow me Link to comment Share on other sites More sharing options...
Canardia Posted December 30, 2009 Share Posted December 30, 2009 You can use the Curve() function of LE to smoothly interpolate to a certain coordinate, or you can parent the camera to a physics sphere and move the sphere with force commands. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Shard Posted December 30, 2009 Author Share Posted December 30, 2009 To get this smoothed out use Curve. Now you are using some linear movement, if you want some swifty side movement you'll need to use some math. For the time being, linear motion is just fine. How do I use the curve? From what I've seen, MoveEntity just sends the camera flying away from the map, not stopping. 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...
Laurens Posted December 30, 2009 Share Posted December 30, 2009 You basically supply the Curve method a destination value, the previous value and a smoothing value. Curve is used in the "Camera Controls" tutorial at http://www.leadwerks.com/files/Tutorials/CPP/Camera_Controls.pdf. Check out page 6, "Fine Tuning". 1 Quote Link to comment Share on other sites More sharing options...
Shard Posted December 31, 2009 Author Share Posted December 31, 2009 You basically supply the Curve method a destination value, the previous value and a smoothing value. Curve is used in the "Camera Controls" tutorial at http://www.leadwerks.com/files/Tutorials/CPP/Camera_Controls.pdf. Check out page 6, "Fine Tuning". Curve only takes in a float as its parameters. How would I give it a Vec3() destination coordinates? 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...
Canardia Posted December 31, 2009 Share Posted December 31, 2009 Each component of Vec3 seperately. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Shard Posted December 31, 2009 Author Share Posted December 31, 2009 Each component of Vec3 seperately. After making every component switch by itself, it seemed to work fine until the angle was changed. When facing north, it works just fine. But if I face any other direction, it jumps to the wrong direction. void Switch() { switching = true; TVec3 newPos = cameraPos; cameraPos = EntityPosition(world->frameWerk.GetMain().GetCamera()); newPos.Y += 5; newPos.Z -= 10; if(cameraPos == newPos) { switching = false; } else { cameraPos.X = Curve(cameraPos.X,newPos.X,3); cameraPos.Y = Curve(cameraPos.Y,newPos.Y,3); cameraPos.Z = Curve(cameraPos.Z,newPos.Z,3); PositionEntity(world->frameWerk.GetMain().GetCamera(),cameraPos); } } I think this means that I need to adjust which component I'm changing based on direction, but I have no idea how to do that. Note: This particular piece of code is just supposed to switch between first person and third person. The RTS/FPS switch I will code later by using the same principles. 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...
Niosop Posted December 31, 2009 Share Posted December 31, 2009 That symptom is indicative of mixing world rotation and local rotation. Make sure you're always using either local space or world space or translating properly between them. Quote Windows 7 x64 - Q6700 @ 2.66GHz - 4GB RAM - 8800 GTX ZBrush - Blender Link to comment Share on other sites More sharing options...
Shard Posted January 1, 2010 Author Share Posted January 1, 2010 That symptom is indicative of mixing world rotation and local rotation. Make sure you're always using either local space or world space or translating properly between them. After about a weeks time to trying to make this work I've come up with nothing that works properly. I hate to have to ask this, but could someone post an example or sample code of how I should be doing it? 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.