Irme wrote:okay... now that the thread has been successfully hijacked by "Guest" lets get back to the topic...
my goal again is to be able to mouse move the camera around the "player node" i had this working before without the glitch in version 12 - is there something that has changed in the update that would affect this?? also, what are any soloutions out there that are .net compatable i'm willing to take..
Thanks..
well this is no .NET but it should work (you need some changes I guess), here is some code of my 3rd person cam... here are the private members of the class (for an overview).
Code: Select all
// irrlicht container
scene::ICameraSceneNode* mCamera;
scene::ISceneNode* mChase;
// kamera einstellungen
f32 mDegree;
f32 mZoom;
f32 mPitch;
// kamera einstellungen
f32 mDegreeTo;
f32 mZoomTo;
f32 mPitchTo;
// min/max werte
f32 mZoomMax;
f32 mZoomMin;
f32 mPitchMax;
f32 mPitchMin;
(sorry for german comments Im too lazy to remove them). Basically you have 3 value (zoom, rotate and pitch) and 3 target value (zoomTo, pitchTo etc.). mChase is the scenen node you want to follow. Now your class should have functions for handling the movement.... I use something like Pitch() and PitchTo(), they look like this (nearly the same for all 3 types)
Code: Select all
void CCamera::Pitch(f32 pValue)
{
mPitch+=pValue;
if(( mPitch < mPitchMin) || ( mPitch > mPitchMax ))
mPitch-=pValue;
mPitchTo=mPitch;
}
void CCamera::PitchTo(f32 pValue)
{
mPitchTo+=pValue;
if(( mPitchTo < mPitchMin) || ( mPitchTo > mPitchMax ))
mPitchTo-=pValue;
}
note how PitchTo only changes the target value (and not mPitch which is the current pitch of your cam). Now the last thing is an update method which caclulates and updates the position of the camera.... here it comes
Code: Select all
void CCamera::Update(u32 pTime)
{
if(( mCamera ) && ( mChase ))
{
// kamera auf ziele testen
// ----------------------------------------------------
// zoom target testen
if( mZoom != mZoomTo)
{
f32 dir = f32(mZoomTo - mZoom);
if( dir < 0 )
{
mZoom -= pTime * ZOOMTO_SPEED;
if( mZoom < mZoomTo )
mZoom = mZoomTo;
}
else
{
mZoom += pTime * ZOOMTO_SPEED;
if( mZoom > mZoomTo )
mZoom = mZoomTo;
}
}
// rotation target testen
if( mDegree != mDegreeTo)
{
f32 dir = f32(mDegreeTo - mDegree);
if( dir < 0 )
{
mDegree -= pTime * ROTATETO_SPEED;
if( mDegree < mDegreeTo )
mDegree = mDegreeTo;
}
else
{
mDegree += pTime * ROTATETO_SPEED;
if( mDegree > mDegreeTo )
mDegree = mDegreeTo;
}
}
// winkel target testen
if( mPitch != mPitchTo)
{
f32 dir = f32(mPitchTo - mPitch);
if( dir < 0 )
{
mPitch -= pTime * PITCHTO_SPEED;
if( mPitch < mPitchTo )
mPitch = mPitchTo;
}
else
{
mPitch += pTime * PITCHTO_SPEED;
if( mPitch > mPitchTo )
mPitch = mPitchTo;
}
}
// kamera neu ausrichten
// ----------------------------------------------------
// verfolger position holen
core::vector3df camPos = mChase->getPosition();
core::vector3df tmpPos = camPos;
// vertikalen abstand hinzurechnen
tmpPos.X += mZoom;
// tmpPos um camPos rotieren
tmpPos.rotateXYBy(mPitch, camPos);
tmpPos.rotateXZBy(mDegree, camPos);
// positionieren
mCamera->setPosition( tmpPos );
// lookat festlegen
mCamera->setTarget( camPos );
}
}
Well thats is basically, dont forget to add a camera scene node to irrlicht in the constructor (and place it in mCamera) and also initialize the values (like mMax.. and mMin). PITCHTO_SPEED etc. are just macros, simply type your favorit speed there (like I said before, you need to find the "good" center).
You now can move your cam with mouse, keys and so on.. this is what my event receiver looks like..
Code: Select all
static f32 x = 0;
static f32 y = 0;
// maus bewegung für kamera
if (event.EventType == irr::EET_MOUSE_INPUT_EVENT)
{
switch(event.MouseInput.Event)
{
// mausaxen
case EMIE_MOUSE_MOVED:
{
// kamera drehen
f32 tempx = (f32)event.MouseInput.X;
Camera->Rotate( x-tempx );
// kamera neigen
f32 tempy = (f32)event.MouseInput.Y;
Camera->Pitch( (y-tempy)/2 );
x=tempx;
y=tempy;
}
return true;
// mausrad
case EMIE_MOUSE_WHEEL:
{
// kamera zoomen
Camera->ZoomTo(-event.MouseInput.Wheel*400);
}
return true;
}
I think i've posted enough code, now its up to you