Ywa Posted January 25, 2012 Share Posted January 25, 2012 Hi everyone, I've been trying to get a simple camera look at point function working, but I ended up rewriting it 20 times or so. While it's a relatively easy-to-write function. The problem is simple. I have my camera position, and a 3D point to look at. How do I calculate the rotation/angles for the camera? It would be awesome if someone could write an example function (in C++ or any other language), any help is welcome though. Thanks in advance. - Ywa Quote Link to comment Share on other sites More sharing options...
Marleys Ghost Posted January 25, 2012 Share Posted January 25, 2012 The simplest way would be to create a pivot, move that to the x,y,z co-ordinate you want the camera to point at and then use PointEntity: PointEntity(Camera, Pivot, 3, 1.0, 0.0) Quote AMD Bulldozer FX-4 Quad Core 4100 Black Edition 2 x 4GB DDR3 1333Mhz Memory Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5 Windows 7 Home 64 bit BlitzMax 1.50 • Lua 5.1 • MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro 3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET LE 2.5/3.4 • Skyline • UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0 Marleys Ghost's YouTube Channel • Marleys Ghost's Blog "I used to be alive like you .... then I took an arrow to the head" Link to comment Share on other sites More sharing options...
Ywa Posted January 25, 2012 Author Share Posted January 25, 2012 *slaps himself for never seeing PointEntity* Thanks. Quote Link to comment Share on other sites More sharing options...
Clackdor Posted January 25, 2012 Share Posted January 25, 2012 I used to need to know trigonometry to point my camera, but then I took a PointEntity() to the knee. 1 Quote Link to comment Share on other sites More sharing options...
Ywa Posted January 26, 2012 Author Share Posted January 26, 2012 Edit: Solved. I was so stupid for not calling the SetLookAtPoint function. Thanks guys! I must be doing something wrong. I have this code in my SetLookAtPoint function. procedure CCamera.SetLookAtPoint( vecLookAtPos : TVec3D ); var vPivot : TPivot; begin //Hacky method (TODO: Make less hacky) vPivot := CreatePivot(); PositionEntity(vPivot,vecLookAtPos); PointEntity(self.Entity,vPivot,3,1.0,0.0); FreeEntity(vPivot); end; self.Entity is the camera entity The camera doesn't seem to rotate. Quote Link to comment Share on other sites More sharing options...
Canardia Posted January 27, 2012 Share Posted January 27, 2012 Don't delete the pivot. The camera turns smoothly over many frames, so it needs the pivot for long time. 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...
Ywa Posted January 27, 2012 Author Share Posted January 27, 2012 Well deleting it seems to work fine, and I don't want it to turn smoothly (I'll do that on my own). 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.