Jump to content

  • Log In with Google      Sign In   
  • Create Account


Anyone guess what exactly all these mean?

  • You cannot reply to this topic
6 replies to this topic

#1 lucky6969b   Members   -  Reputation: 537

Like
0Likes
Like

Posted 21 July 2014 - 02:01 AM

I've got the book AI Programming Wisdom 3, in the CD-ROM, I've got Bourne and Sattar source code on Autonomous Camera Control, when I see these 2 lines and having not any comments, I am not sure if mvFacing actually means look at vector or look at target, and not sure what mvView and mvCross means? Does anyone here have the same book with me know what these are all about? Thanks Jack

// Autonomous camera class.
class Camera
{
public:
	Vector3		mvPosition, mvView, mvUp;
	Vector3		mvFacing, mvCross;

Update:

I dug a little bit deeper, but found out that mvFacing is actually the lookat vector, but mvCross and mvView has no idea what that is.

Thanks

Jack



Sponsor:

#2 TiagoCosta   Crossbones+   -  Reputation: 1870

Like
3Likes
Like

Posted 21 July 2014 - 04:04 AM

Assuming that mvFacing is the look direction, then mvCross is probably the right (or left) vector because it can be calculated by calculating the cross product of mvUp and mvFacing.

 

I'm not sure about mvView. My guess about mvView is that it is the position the camera is looking at. So mvFacing = mvView - mvPosition.

 

Can you post the code where those vectors are initialized? 


Edited by TiagoCosta, 21 July 2014 - 04:07 AM.

Tiago Costa
Aqua Engine - my DirectX 11 game "engine" - In development

#3 JoeyDewd   Members   -  Reputation: 306

Like
1Likes
Like

Posted 21 July 2014 - 04:11 AM

mvCross is most likely the right or left vector of the camera that represents its x-axis. mvCross is obtained by a cross-product between the camera's direction vector and the up vector; that's why it's called mvCross. By moving along this vector you can create the so called strafe effect of a camera.

 

To create the lookAt matrix (most cameras calculate this matrix) you need a direction vector and a target vector. The direction vector is the vector that's pointing in the direction your camera is facing and this one is usually obtained from subtracting the position vector from the target vector. Based on the way the variables are set up I assume the first 3 vectors are the user-supplied vectors thus mvView is most likely the target vector (e.g. the coordinate a camera is looking at like (0,0,0)) while the mvFacing and mvCross are then later calculated thus mvFacing is then probably the camera's direction vector.



#4 Matias Goldberg   Crossbones+   -  Reputation: 3007

Like
0Likes
Like

Posted 21 July 2014 - 10:22 AM

I found this old interactive tutorial (written in Java, you will proably have to lower your security settings from Control Panel -> Java -> Security tab in order to execute it) to be very useful in understanding how cross products work and how two vectors form a plane (the cross product is always perpendicular to that plane).

 

You can click on the plane to move it around, or you can click on the arrows A and B to see how the cross product is affected.



#5 Jason Z   Crossbones+   -  Reputation: 4691

Like
0Likes
Like

Posted 21 July 2014 - 08:18 PM


Can you post the code where those vectors are initialized?
This is really the only way to know for sure - the names could be misleading, so unless you check the code that is using these objects then you are really only guessing!

#6 lucky6969b   Members   -  Reputation: 537

Like
0Likes
Like

Posted 22 July 2014 - 02:39 AM

I don't know if the original authors are willing to let me disclose the source code...
But here is the constructor method

 

//
//    Camera::Camera()
//
//    Default constructor.
//
Camera::Camera()
{
    mnCurrentProfile = 0;
    mnNumOfProfiles = 0;

    mvPosition = Vector3::origin;
    mvView = Vector3::origin;
    mvUp = Vector3::yAxis;
    mvFacing = Vector3::origin;
    mvCross = Vector3::origin;
    
    mfSecondsUntilEnd = 1.0f;

    mnRayCastingMethod = kCameraCurrent;
    mnSafePointMethod = kSafePoint_targetrelative;

    mfFrameTime = 0.0f;

}


//
//    Camera::~Camera()
//
//    Default destructor.
//
Camera::~Camera()
{
}


#7 lucky6969b   Members   -  Reputation: 537

Like
0Likes
Like

Posted Yesterday, 08:02 PM

Hello friends,
I've tried to connect the camera from the book to an Ogre camera, this's what I got so far

 

Ogre::Vector3 BourneVec3ToOgreVec3(Dolly_Cam::Vector3 vec) {
    Ogre::Vector3 vec3;
    vec3.x = vec.x;
    vec3.y = vec.y;
    vec3.z = vec.z;
    return vec3;
}

Dolly_Cam::Vector3 OgreVec3ToBourneVec3(Ogre::Vector3 vec) {
    Dolly_Cam::Vector3 vec3;
    vec3.x = vec.x;
    vec3.y = vec.y;
    vec3.z = vec.z;
    return vec3;
}
cam.mvPosition = OgreVec3ToBourneVec3(mSceneMgr->getSceneNode("Worker00001Node")->getPosition() + Ogre::Vector3(0, 5, 5));
cam.mvFacing = cam.mvPosition - OgreVec3ToBourneVec3(mSceneMgr->getSceneNode("Worker00001Node")->getPosition());
changeDollyCam(cam);

void OgreRecastApplication::changeDollyCam(const Dolly_Cam::Camera& cam) {  
  
        Ogre::Camera* camera = mSceneMgr->createCamera("Dolly_Cam");
        mWindow->removeViewport(0);
        camera->setPosition(BourneVec3ToOgreVec3(cam.mvPosition));
        camera->lookAt(BourneVec3ToOgreVec3(cam.mvView));
        Ogre::Radian R = Ogre::Math::ATan(Ogre::Math::Tan(Ogre::Degree((float)45/2))/mCamera->getAspectRatio())*2;
        camera->setFOVy(R);
    

        mViewport = mWindow->addViewport( mCamera );
        mViewport->setCamera(camera);

        delete mCameraMan;
        mCameraMan = new OgreBites::SdkCameraMan(mCamera);
    

}
 

 

But it looks perhaps at the opposite direction. But I have tried to reverse the order of subtraction to no avail.
To my understanding of vectors, the look at vector should be camera's position substracting the position of look at target.
Correct me if I am any wrong.
Thanks
Jack


Edited by lucky6969b, Yesterday, 08:12 PM.






PARTNERS