mirror of
https://github.com/minetest/irrlicht.git
synced 2025-06-28 14:26:06 +02:00
a) debug Camera Matrices. enable with _IRR_COMPILE_WITH_90_DEGREE_CAMERA.
- allow ICameraSceneNode to accept any values and correct in buildCameraLookAtMatrixLH with normalize_camera_direction. if disabled defaults to the current v1.9 normalize b) add initial Rotation to MayaCamera Constructor default 0,0 c) switchToMayaCamera in Examples. Clones FPSCamera default disabled git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6366 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
@ -616,7 +616,9 @@ namespace scene
|
||||
virtual ICameraSceneNode* addCameraSceneNodeMaya(ISceneNode* parent=0,
|
||||
f32 rotateSpeed=-1500.f, f32 zoomSpeed=200.f,
|
||||
f32 translationSpeed=1500.f, s32 id=-1, f32 distance=70.f,
|
||||
bool makeActive=true) =0;
|
||||
bool makeActive=true
|
||||
, f32 rotX = 0.f, f32 rotY = 0.f
|
||||
) =0;
|
||||
|
||||
//! Adds a camera scene node with an animator which provides mouse and keyboard control appropriate for first person shooters (FPS).
|
||||
/** This FPS camera is intended to provide a demonstration of a
|
||||
|
@ -862,4 +862,11 @@ precision will be lower but speed higher. currently X86 only
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//! Solve Camera errors - Debug Feature
|
||||
/* - Allow Camera 90 degree up, Target==Position,buildCameraLookAtMatrixLH
|
||||
- pre v1.9 CCameraSceneNode moved the up non-particular in the positive x-Direction. not compatible
|
||||
- Enabled is not compatible with Irrlicht Collision and Response.
|
||||
*/
|
||||
//#define _IRR_COMPILE_WITH_90_DEGREE_CAMERA
|
||||
|
||||
#endif // IRR_COMPILE_CONFIG_H_INCLUDED
|
||||
|
@ -50,6 +50,42 @@ namespace irr
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
For using an alternative camera in the examples.
|
||||
Try to translate the viewpoint (Maya internal CameraRotation)
|
||||
*/
|
||||
static inline void switchToMayaCamera(IrrlichtDevice* device)
|
||||
{
|
||||
#if 1
|
||||
return;
|
||||
#else
|
||||
if (!device) return;
|
||||
|
||||
scene::ICameraSceneNode* camera = device->getSceneManager()->getActiveCamera();
|
||||
if (!camera || camera->getID() == 54321) return;
|
||||
|
||||
|
||||
core::vector3df target = camera->getTarget() - camera->getPosition();
|
||||
core::vector3df relativeRotation = target.getHorizontalAngle();
|
||||
|
||||
scene::ICameraSceneNode* maya = device->getSceneManager()->addCameraSceneNodeMaya(
|
||||
0, -1500, 1000, 1500,
|
||||
54321,
|
||||
target.getLength(),
|
||||
true,
|
||||
relativeRotation.X + 90, relativeRotation.Y
|
||||
);
|
||||
if (maya)
|
||||
{
|
||||
maya->setNearValue(camera->getNearValue());
|
||||
maya->setFarValue(camera->getFarValue());
|
||||
}
|
||||
|
||||
device->getCursorControl()->setVisible(true);
|
||||
device->setResizable(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
@ -1908,10 +1908,10 @@ namespace core
|
||||
const vector3df& upVector)
|
||||
{
|
||||
vector3df zaxis = target - position;
|
||||
zaxis.normalize();
|
||||
zaxis.normalize_z();
|
||||
|
||||
vector3df xaxis = upVector.crossProduct(zaxis);
|
||||
xaxis.normalize();
|
||||
vector3df xaxis = normalize_y(upVector).crossProduct(zaxis);
|
||||
xaxis.normalize_x();
|
||||
|
||||
vector3df yaxis = zaxis.crossProduct(xaxis);
|
||||
|
||||
|
@ -195,6 +195,36 @@ namespace core
|
||||
return (*this *= newlength);
|
||||
}
|
||||
|
||||
#if defined(_IRR_COMPILE_WITH_90_DEGREE_CAMERA)
|
||||
vector3d<T>& normalize_camera_direction(const vector3d<T>& def)
|
||||
{
|
||||
f64 l = (f64)X * X + (f64)Y * Y + (f64)Z * Z;
|
||||
if (::fabs(l) < 0.000000001)
|
||||
{
|
||||
X = def.X;
|
||||
Y = def.Y;
|
||||
Z = def.Z;
|
||||
}
|
||||
else
|
||||
{
|
||||
l = 1.0 / ::sqrt(l);
|
||||
f64 v;
|
||||
v = X * l; X = ::fabs(v) < 0.00000001 ? (T)0 : (T)v;
|
||||
v = Y * l; Y = ::fabs(v) < 0.00000001 ? (T)0 : (T)v;
|
||||
v = Z * l; Z = ::fabs(v) < 0.00000001 ? (T)0 : (T)v;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
#define normalize_x() normalize_camera_direction(core::vector3df(1.f, 0.f, 0.f))
|
||||
#define normalize_z() normalize_camera_direction(core::vector3df(0.f, 0.f, 1.f))
|
||||
#define normalize_y(v) core::vector3df(v).normalize_camera_direction(core::vector3df(0.f, 1.f, 0.f))
|
||||
#else
|
||||
#define normalize_x() normalize()
|
||||
#define normalize_z() normalize()
|
||||
#define normalize_y(v) v
|
||||
#endif
|
||||
|
||||
|
||||
//! Inverts the vector.
|
||||
vector3d<T>& invert()
|
||||
{
|
||||
|
Reference in New Issue
Block a user