Dozz Posted May 14, 2011 Share Posted May 14, 2011 Camera looking & moving below are as in the tutorials, I added zooming with the mouse wheel this afternoon, but having set the min and max zoom levels to 2 and 20 I now find that if I roll below 2, lets say -20, I need to roll forward 22 units before I can zoom in. Similar if I roll to value 40, I need to roll back 20 units before I can zoom out. Can the MouseZ() be set or is it just read only? mx = Curve(MouseX()-winCX,mx,5); my = Curve(MouseY()-winCY,my,5); // camera look MoveMouse(winCX,winCY); camrotation.X = camrotation.X+my/(12.0*mzLast*mzLast); camrotation.Y = camrotation.Y-mx/(12.0*mzLast*mzLast); // *mzLast*mzLast better sensitivity when zoomed RotateEntity(cam,camrotation); move = Curve(KeyDown(KEY_W)-KeyDown(KEY_S),move,5); // camera fly strafe = Curve(KeyDown(KEY_D)-KeyDown(KEY_A),strafe,5); MoveEntity(cam,Vec3(strafe/strafeSpeed,0,move/moveSpeed)); mzNow = MouseZ(); // camera zooming if (mzNow < 2) { mzNow = 2; } if (mzNow > 20) { mzNow = 20; } if (mzNow != mzLast) { mz = Curve(mzNow - mzLast,mz,100); CameraZoom(cam,mz*mz); mzLast = mz; } Quote Link to comment Share on other sites More sharing options...
macklebee Posted May 14, 2011 Share Posted May 14, 2011 Use FlushMouse() to reset the value to zero. 1 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Canardia Posted May 15, 2011 Share Posted May 15, 2011 You can also use only the difference of MouseZ() between two frames. 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...
Dozz Posted May 15, 2011 Author Share Posted May 15, 2011 Thanks guys, I tried FlushMouse() and it didnt seem to reset MouseZ()? maybe I'm not applying it correctly. I will try the difference approach. Next on my todo list is multiple selections using shift and/or ctrl. I'm thinking an array with pointers of the selected entities, before I start on that I would lke to ask what method of managing the selections is typically used? Thanks Paul Quote Link to comment Share on other sites More sharing options...
Canardia Posted May 15, 2011 Share Posted May 15, 2011 The selection flag should be part of the entities, so you don't need to make a seperate list for selected entities. You should make a vector or map with the entities you want to loop and access quickly. 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...
Rick Posted May 15, 2011 Share Posted May 15, 2011 The selection flag should be part of the entities, so you don't need to make a seperate list for selected entities. You should make a vector or map with the entities you want to loop and access quickly. Your second statement is why your first statement doesn't make sense. The reason he wants to add selections to a list is so he can loop through them quickly. Dozz, an stl list works just fine. Quote Link to comment Share on other sites More sharing options...
Dozz Posted May 15, 2011 Author Share Posted May 15, 2011 thanks a lot Quote Link to comment Share on other sites More sharing options...
Canardia Posted May 15, 2011 Share Posted May 15, 2011 I meant with a own vector or map you don't have to loop all entities in the 3 worlds of the engine. Since every game has somekind of loop which loops through all wanted entities, adding a seperate selection list would only cause more looping. 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...
Rick Posted May 15, 2011 Share Posted May 15, 2011 adding a seperate selection list would only cause more looping I guess the question would then be is a function call (to get the keys) and an if statement (to check the keys) for every loaded entity more expensive than storing your own list that probably has just a handful of entities in it for the selection list more costly or not? I would venture to say looping through 5 or so entities in a separate list is cheaper than checking every loaded entity for a specific key value. Of course the more entities you have loaded the better the separate list way is. Quote Link to comment Share on other sites More sharing options...
Dozz Posted May 16, 2011 Author Share Posted May 16, 2011 Chuffed with zooming working correctly now using the difference method, didn't take long, thanks for the advice Quote Link to comment Share on other sites More sharing options...
Canardia Posted May 16, 2011 Share Posted May 16, 2011 You need also a special logic for AppSuspended(), because when the user Alt-Tabs out and back of the window, the MouseZ() is set to 0 and you will get a wrong difference. You can copy the logic from GameLib, see the functions Game::IsSuspended() (this is where the Alt-Tab bug is handled) and Game::PositionCamera() (where the camera is moved with the MouseZ() diff). 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...
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.