Anyone out there that has made this change that feel OK with sharing it?
I have tried a few things like moving 'dir' to the class header in the Camera class but I end up with
- Code: Select all
1>camera.cpp(94) : error C2677: binary '+=' : no global operator found which takes type 'D3DXVECTOR3' (or there is no acceptable conversion)
1>camera.cpp(96) : error C2677: binary '-=' : no global operator found which takes type 'D3DXVECTOR3' (or there is no acceptable conversion)
1>camera.cpp(98) : error C2677: binary '+=' : no global operator found which takes type 'D3DXVECTOR3' (or there is no acceptable conversion)
1>camera.cpp(100) : error C2677: binary '-=' : no global operator found which takes type 'D3DXVECTOR3' (or there is no acceptable conversion)
1>camera.cpp(102) : error C2276: '&' : illegal operation on bound member function expression
1>camera.cpp(102) : error C2276: '&' : illegal operation on bound member function expression
1>camera.cpp(103) : error C3867: 'Camera::dir': function call missing argument list; use '&Camera::dir' to create a pointer to member
1>camera.cpp(103) : error C2296: '*' : illegal, left operand has type 'D3DXVECTOR3 (__thiscall Camera::* )(float,float,float)'
I have tried with this
- Code: Select all
#ifndef _CAMERA_H_
#define _CAMERA_H_
#include <d3dx9.h>
#include "d3dApp.h"
class Camera
{
public:
Camera();
const D3DXMATRIX& view() const;
const D3DXMATRIX& proj() const;
const D3DXMATRIX& viewProj() const;
const D3DXVECTOR3& right() const;
const D3DXVECTOR3& up() const;
const D3DXVECTOR3& look() const;
D3DXVECTOR3& pos();
void lookAt(D3DXVECTOR3& pos, D3DXVECTOR3& target, D3DXVECTOR3& up);
void setLens(float fov, float aspect, float nearZ, float farZ);
void setSpeed(float s);
void update(float dt);
/////////////////////////////////////////////////////////////////
// READ ME !!! This is what I have tried, without success.
/////////////////////////////////////////////////////////////////
D3DXVECTOR3 dir(float x, float y, float z);
D3DXVECTOR3& dir(float x, float y, float z);
////////////////////////////////////////////////////////////////
// After moving this I tried to access dir in the msgProc function to be able
// to pass the variables to Camera function 'update' and get the change
// that way instead. But I cant get it to work :(
///////////////////////////////////////////////////////////////
protected:
void buildView();
D3DXMATRIX mView;
D3DXMATRIX mProj;
D3DXMATRIX mViewProj;
D3DXVECTOR3 mPosW;
D3DXVECTOR3 mRightW;
D3DXVECTOR3 mUpW;
D3DXVECTOR3 mLookW;
float mCamSpeed;
};
#endif
- Code: Select all
LRESULT d3dApp::msgProc(UINT msg, WPARAM wParam, LPARAM lParam)
{
// Some code before ...
case WM_KEYDOWN:
{
int vCode = (int)wParam;
int keyState = (int)lParam;
// Movement
switch(vCode)
{
case VK_UP:
break;
case VK_DOWN:
break;
case VK_LEFT:
break;
case VK_RIGHT:
break;
}
if( wParam == VK_ESCAPE )
enableFullScreenMode(false);
else if( wParam == 'F' )
enableFullScreenMode(true);
return 0;
}
// some code after ...
}
Instead of poking around in parts I shouldn't poke in trying to figure this one out.
I guess I am doing this the wrong way, so anyone know how I can do this?
