Jump to content

MouseZ()


Dozz
 Share

Recommended Posts

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;

}

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

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.

 Share

×
×
  • Create New...