how can i zoom in/out with orbit camera
by Enel · in Torque 3D Professional · 02/03/2010 (9:33 pm) · 7 replies
how can i do zoom in/out when useing orbit camera?
im use this code
but i dont know how to zoom in/out..
and i think 'mCurOrbitDist' dosent work..
im use this code
%this.camera.setOrbitObject(%player, mDegToRad(50) @ " 0 0", 0, 10, 5);
but i dont know how to zoom in/out..
and i think 'mCurOrbitDist' dosent work..
About the author
Recent Threads
#2
above code so stiff zoom in/out :(...
02/04/2010 (1:02 am)
but anyone mouse zoom change to smooth?above code so stiff zoom in/out :(...
#3
02/04/2010 (2:34 am)
I was wondering why you didn't just change the setFOV() .... though that's also "stiff zoom in/out".
#4
amm.. i have make RPG game whth click move
What are you talk about?.. i dont understand
and.. im from korean sry my bed english :)
02/04/2010 (2:38 am)
@Steveamm.. i have make RPG game whth click move
What are you talk about?.. i dont understand
and.. im from korean sry my bed english :)
#5
Don't worry, your English is better than my Korean ;)
02/04/2010 (11:35 am)
default.bind.cs ---- zoom in stock/normal Torque. But this is not smooth either...// Zoom and FOV functions
//------------------------------------------------------------------------------
if($Pref::player::CurrentFOV $= "")
$Pref::player::CurrentFOV = $pref::Player::DefaultFOV / 2;
// toggleZoomFOV() works by dividing the CurrentFOV by 2. Each time that this
// toggle is hit it simply divides the CurrentFOV by 2 once again. If the
// FOV is reduced below a certain threshold then it resets to equal half of the
// DefaultFOV value. This gives us 4 zoom levels to cycle through.
function toggleZoomFOV()
{
$Pref::Player::CurrentFOV = $Pref::Player::CurrentFOV / 2;
if($Pref::Player::CurrentFOV < 5)
$Pref::Player::CurrentFOV = $Pref::Player::DefaultFov / 2;
if($ZoomOn)
setFOV($Pref::Player::CurrentFOV);
else
setFOV($Pref::Player::DefaultFOV);
}
function setZoomFOV(%val)
{
if(%val)
toggleZoomFOV();
}
$ZoomOn = false;
function toggleZoom(%val)
{
if (%val)
{
if (!$ZoomOn)
commandToServer('getZoomReticle');
}
else
{
clientCmdUnSetZoom();
}
}
moveMap.bind(keyboard, f, setZoomFOV); // f for field of view
moveMap.bind(keyboard, z, toggleZoom); // z for zoomDon't worry, your English is better than my Korean ;)
#6
02/04/2010 (8:11 pm)
Thx Steve! :)
#7
11/20/2012 (2:06 pm)
Edit: nvm, my solution apparently only works in the shapeeditor window.
Torque Owner Enel
ENEL Indie studio
in camera.h add public function
in camera.cpp find function
Camera::validateEyePoint(F32 pos, MatrixF *mat)
// replace this if (pos != 0) { // Use the eye transform to orient the camera Point3F dir; mat->getColumn(1, &dir); if (mMaxOrbitDist < mCurOrbitDist) pos *= mMaxOrbitDist; else if (mMinOrbitDist > mCurOrbitDist) pos *= mMinOrbitDist; else pos *= mCurOrbitDist;and add end of line
void Camera::setAddOrbitDistance(F32 distance) { if(mMaxOrbitDist < mCurOrbitDist + distance) return; else if(mMinOrbitDist > mCurOrbitDist + distance) return; else mCurOrbitDist += distance; } ConsoleMethod( Camera, setAddOrbitDistance, void, 3, 3, "(F32)distance" "- distance camera ") { object->setAddOrbitDistance(dAtof(argv[2])); }in scripts/client/default.bind.cs
function mouseZoom(%val) { // If wheel was scrolled forward // move camera closer to the ground %CCamera = LocalClientConnection.camera; if(%val > 0) { %CCamera.setAddOrbitDistance(0.5); } // If wheel was scrolled back // move camera away from the ground else { %CCamera.setAddOrbitDistance(-0.5); } } moveMap.bind(mouse0, "zaxis", mouseZoom);thx :)