What about a method that will set
initially the camera with the position and angle(target) of the camera. Take the position entered, calculate the proper distance,set it and ajust the target if needed so the camera is positionned at the given coordinates and is looking at the given target.
That exactly what I have in mind. Using this could define the initial position of the camera when the input receiver activate. Would solve all my problems. If that method would be there. I could disable the input receiver, use the method, activate back the input receiver and the camera would be positionned and looking exactly where I want.
Thanks for the infos about how to create a patch!
EDIT: Hi, I quickly looked at the last SVN code for this camera. This cam is really different from the FPS cam, but I have some suggestions:
- Easy way to add mouse button binding customisation to the maya camera:
From the current SVN code from lines 50 to 89: (CSceneNodeAnimatorCameraMaya.cpp)
Code: Select all
bool CSceneNodeAnimatorCameraMaya::OnEvent(const SEvent& event)
{
if (event.EventType != EET_MOUSE_INPUT_EVENT)
return false;
switch(event.MouseInput.Event)
{
case EMIE_LMOUSE_PRESSED_DOWN:
MouseKeys[0] = true;
break;
case EMIE_RMOUSE_PRESSED_DOWN:
MouseKeys[2] = true;
break;
case EMIE_MMOUSE_PRESSED_DOWN:
MouseKeys[1] = true;
break;
case EMIE_LMOUSE_LEFT_UP:
MouseKeys[0] = false;
break;
case EMIE_RMOUSE_LEFT_UP:
MouseKeys[2] = false;
break;
case EMIE_MMOUSE_LEFT_UP:
MouseKeys[1] = false;
break;
case EMIE_MOUSE_MOVED:
MousePos = CursorControl->getRelativePosition();
break;
case EMIE_MOUSE_WHEEL:
case EMIE_LMOUSE_DOUBLE_CLICK:
case EMIE_RMOUSE_DOUBLE_CLICK:
case EMIE_MMOUSE_DOUBLE_CLICK:
case EMIE_LMOUSE_TRIPLE_CLICK:
case EMIE_RMOUSE_TRIPLE_CLICK:
case EMIE_MMOUSE_TRIPLE_CLICK:
case EMIE_COUNT:
return false;
}
return true;
}
I would like to propose adding 6 new variables as: (I'm sure there could be a better way to make this), with their "current" default values. Perhaps with an even better idea it could also be mapped to a mouse/keyboard key. At least with this proposed method, we could have lots of alternate workflows with the mouse. So we could mimic more the behavior of the mouse to match applications with the maya camera.
u32 keyRotationBindingUp = EMIE_LMOUSE_PRESSED_DOWN ---> For containing the current enum of the mouse key that would be used for rotation in the scene
u32 keyTranslationBindingUp = EMIE_RMOUSE_PRESSED_DOWN --> For containing the current enum of the mouse key that would be used to translate the camera in the scene
u32 keyZoomBindingUp = EMIE_MMOUSE_PRESSED_DOWN--> For containing the current enum of the mouse key that would be used to set the camera zoom
u32 keyRotationBindingDn = EMIE_LMOUSE_LEFT_UP;
u32 keyTranslationBindingDn = EMIE_RMOUSE_LEFT_UP;
u32 keyZoomBindingDn = EMIE_MMOUSE_LEFT_UP;
So the code would look like this now:
Code: Select all
bool CSceneNodeAnimatorCameraMaya::OnEvent(const SEvent& event)
{
if (event.EventType != EET_MOUSE_INPUT_EVENT)
return false;
switch(event.MouseInput.Event)
{
case keyRotationBindingUp:
MouseKeys[0] = true;
break;
case keyTranslationBindingUp:
MouseKeys[2] = true;
break;
case keyZoomBindingDn:
MouseKeys[1] = true;
break;
case keyRotationBindingDn:
MouseKeys[0] = false;
break;
case keyTranslationBindingDn:
MouseKeys[2] = false;
break;
case keyZoomBindingDn:
MouseKeys[1] = false;
break;
case EMIE_MOUSE_MOVED:
MousePos = CursorControl->getRelativePosition();
break;
case EMIE_MOUSE_WHEEL:
case EMIE_LMOUSE_DOUBLE_CLICK:
case EMIE_RMOUSE_DOUBLE_CLICK:
case EMIE_MMOUSE_DOUBLE_CLICK:
case EMIE_LMOUSE_TRIPLE_CLICK:
case EMIE_RMOUSE_TRIPLE_CLICK:
case EMIE_MMOUSE_TRIPLE_CLICK:
case EMIE_COUNT:
return false;
}
return true;
}
With this in place, and putting the "defaults" in the constructor, the camera would work exactly as before, but by adding the proper methods (Almost 1 liner each), we could be able to define the mouse button for the specific action we would like to do. (So it would be similar as the current FPS camera to have the ability to map keys to the camera movement)
-- Camera initial position: my real problem with this camera
You were right the default distance is fixed at 70.0 units from the camera. But in the code I have found this, it seem to relate to the current camera position (camera->getPosition()) to translate it:
Code: Select all
core::vector3df translate(OldTarget);
const core::vector3df upVector(camera->getUpVector());
const core::vector3df target = camera->getTarget();
core::vector3df pos = camera->getPosition();
core::vector3df tvectX = pos - target;
tvectX = tvectX.crossProduct(upVector);
tvectX.normalize();
const SViewFrustum* const va = camera->getViewFrustum();
core::vector3df tvectY = (va->getFarLeftDown() - va->getFarRightDown());
tvectY = tvectY.crossProduct(upVector.Y > 0 ? pos - target : target - pos);
tvectY.normalize();
I see the variable pos that use the current camera position here, and get also the current camera target position. So perhaps having the current distance between the camera position and the target position would position the camera when events are enabled at the same place as when it was initilized (I hope). I would have to check if only giving it the proper distance would fix the problem...
If not, then if I found something I will have to modify something in that block. (Lines 216-234) Adding something like in the FPS Camera (firstupdate?) That will use the current position of the camera as a base to start then (so the 'pos' at initialisation is the one that was set on the camera.)
Code: Select all
// Set pos ------------------------------------
pos = translate;
pos.X += nZoom;
pos.rotateXYBy(nRotY, translate);
pos.rotateXZBy(-nRotX, translate);
camera->setPosition(pos);
camera->setTarget(translate);
// Rotation Error ----------------------------
// jox: fixed bug: jitter when rotating to the top and bottom of y
pos.set(0,1,0);
pos.rotateXYBy(-nRotY);
pos.rotateXZBy(-nRotX+180.f);
camera->setUpVector(pos);
LastCameraTarget = camera->getTarget();