I'm working on some directX
, started from tutorial code and have gradually been converting it into their own class systems and cpp files etc.
Everything has been going well until now, but I just started modifying the "Camera.h" and "Camera.cpp". I've got the class function In the header, and when I place it in its class file it comes up with an error. I've got header blockers and so on but I cant see the flaw.
camera.h before editing
https://i.stack.imgur.com/Evxof.png
camera.h after editing
#ifndef CAMERA_H_
#define CAMERA_H_
#include "Player.h"
#include "RandomVariables.h"
class Camera {
public:
void UpdateCamera();
float camPitch;
float camYaw;
float Zoom_Amount; //zoom amount from Model_1.Player
float charCamDist; //distance from Model_1.Player
XMVECTOR camPosition;
XMVECTOR camTarget;
XMVECTOR camUp;
XMVECTOR camRight;
XMVECTOR camForward;
XMMATRIX camRotationMatrix;
XMMATRIX Rotationx;
XMMATRIX Rotationy;
XMMATRIX Rotationz;
XMMATRIX camView;
XMMATRIX camProjection;
};
Camera MainCamera;
#endif
I remove void Camera::UpdateCamera() and put it in the camera.cpp and it comes up with undefined errors and so on which don't happen if void Camera::UpdateCamera() is in the header file so I'm baffled :S
error list
https://i.stack.imgur.com/7G21V.png
Camera.cpp after moving updatecamera
#include "Camera.h"
void Camera::UpdateCamera(){
MainCamera.charCamDist = 135.0f;
MainCamera.camTarget = mainPlayer.playerPos;
MainCamera.camTarget = XMVectorSetY(MainCamera.camTarget, XMVectorGetY(MainCamera.camTarget)+5.0f);
MainCamera.camTarget = XMVectorSetX(MainCamera.camTarget, XMVectorGetX(MainCamera.camTarget) -MainCamera.Zoom_Amount);
MainCamera.camRotationMatrix = XMMatrixRotationRollPitchYaw(-MainCamera.camPitch, MainCamera.camYaw, 0);
MainCamera.camPosition = XMVector3TransformNormal(DefaultForward, MainCamera.camRotationMatrix );
MainCamera.camPosition = XMVector3Normalize(MainCamera.camPosition);
MainCamera.camPosition = (MainCamera.camPosition * MainCamera.charCamDist) + MainCamera.camTarget;
MainCamera.camForward = XMVector3Normalize(MainCamera.camTarget - MainCamera.camPosition); // Get forward vector based on target
MainCamera.camForward = XMVectorSetY(MainCamera.camForward, 0.0f); // set forwards y component to 0 so it lays only on
// the xz plane
MainCamera.camForward = XMVector3Normalize(MainCamera.camForward);
MainCamera.camRight = XMVectorSet(-XMVectorGetZ(MainCamera.camForward), 0.0f, XMVectorGetX(MainCamera.camForward), 0.0f);
MainCamera.camUp =XMVector3Normalize(XMVector3Cross(XMVector3Normalize(MainCamera.camPosition - MainCamera.camTarget), MainCamera.camRight));
MainCamera.camView = XMMatrixLookAtLH( MainCamera.camPosition, MainCamera.camTarget, MainCamera.camUp );
};
RandomVariables.cpp
//Global Declarations - Interfaces//
#ifndef RAND_H
#define RAND_H
#include "Models.h"
#include "Player.h"
#include "Camera.h"
///start
My_Player mainPlayer;
XMMATRIX WVP;
XMVECTOR DefaultForward = XMVectorSet(0.0f,0.0f,1.0f, 0.0f);
XMVECTOR DefaultRight = XMVectorSet(1.0f,0.0f,0.0f, 0.0f);
float tilt_X = 0.0f;
int NumSphereVertices;
int NumSphereFaces;
XMMATRIX sphereWorld;
XMMATRIX Scale;
XMMATRIX Translation;
///end
IDXGISwapChain* SwapChain;
ID3D11Device* d3d11Device;
ID3D11DeviceContext* d3d11DevCon;
ID3D11RenderTargetView* renderTargetView;
ID3D11DepthStencilView* depthStencilView;
ID3D11Texture2D* depthStencilBuffer;
ID3D11VertexShader* VS;
ID3D11PixelShader* PS;
ID3D11PixelShader* D2D_PS;
ID3D10Blob* D2D_PS_Buffer;
ID3D10Blob* VS_Buffer;
ID3D10Blob* PS_Buffer;
ID3D11InputLayout* vertLayout;
ID3D11Buffer* cbPerObjectBuffer;
ID3D11BlendState* d2dTransparency;
ID3D11RasterizerState* CCWcullMode;
ID3D11RasterizerState* CWcullMode;
ID3D11SamplerState* CubesTexSamplerState;
ID3D11Buffer* cbPerFrameBuffer;
ID3D10Device1 *d3d101Device;
IDXGIKeyedMutex *keyedMutex11;
IDXGIKeyedMutex *keyedMutex10;
ID2D1RenderTarget *D2DRenderTarget;
ID2D1SolidColorBrush *Brush;
ID3D11Texture2D *BackBuffer11;
ID3D11Texture2D *sharedTex11;
ID3D11Buffer *d2dVertBuffer;
ID3D11Buffer *d2dIndexBuffer;
ID3D11ShaderResourceView *d2dTexture;
IDWriteFactory *DWriteFactory;
IDWriteTextFormat *TextFormat;
IDirectInputDevice8* DIKeyboard;
IDirectInputDevice8* DIMouse;
ID3D11Buffer* sphereIndexBuffer;
ID3D11Buffer* sphereVertBuffer;
ID3D11VertexShader* SKYMAP_VS;
ID3D11PixelShader* SKYMAP_PS;
ID3D10Blob* SKYMAP_VS_Buffer;
ID3D10Blob* SKYMAP_PS_Buffer;
ID3D11ShaderResourceView* smrv;
ID3D11DepthStencilState* DSLessEqual;
ID3D11RasterizerState* RSCullNone;
ID3D11BlendState* Transparency;
#endif