This is what I have so far:
camera.h
#ifndef _CAMERA_#define _CAMERA_#include <d3d9.h>#include <d3dx9.h>#include <vector>using namespace std;struct camera{ D3DVIEWPORT9 viewport; D3DXVECTOR3 pos; int width, height;};class cameraSystem{public: cameraSystem( LPDIRECT3DDEVICE9 device,int width, int height); ~cameraSystem(); int create_camera( int width, int height); void set_camera( int cam){ view_current = cam;} void set_position( D3DXVECTOR3 &pos); void set_zoom( float zoom) { view_zoom = zoom;} D3DXMATRIX &get_View_matrix(){ return matView;} inline int get_view_current(){ return view_current;} void applyView();private: LPDIRECT3DDEVICE9 pDevice; D3DXMATRIX matPerspective; D3DXMATRIX matView; D3DXMATRIX matWorld; vector<camera*> camera_list; int screen_width, screen_height; int view_current; float view_zoom;};#endif
camera.cpp
#include "camera.h"cameraSystem::cameraSystem( LPDIRECT3DDEVICE9 device,int width, int height): pDevice(device), screen_width(width), screen_height(height){ //Setup orthographic projection matrix D3DXMatrixOrthoLH (&matPerspective, screen_width, screen_height, 1.0f, 10.0f); D3DXMatrixIdentity (&matWorld); D3DXMatrixIdentity (&matView); pDevice->SetTransform (D3DTS_PROJECTION, &matPerspective); pDevice->SetTransform (D3DTS_WORLD, &matWorld); pDevice->SetTransform (D3DTS_VIEW, &matView); view_current=0; view_zoom=0; create_camera( width, height);}cameraSystem::~cameraSystem(){ for (UINT i =0; i < camera_list.size(); ++i) { delete camera_list; } camera_list.clear();}int cameraSystem::create_camera( int width, int height){ int i = camera_list.size(); camera *tmp = new camera(); tmp->viewport.X = 0; tmp->viewport.Y = 0; tmp->viewport.Width = width; tmp->viewport.Height = height; tmp->viewport.MinZ = 0.0f; tmp->viewport.MaxZ = 1.0f; tmp->width = width; tmp->height = height; tmp->pos = D3DXVECTOR3( 0.0f, 0.0f, 0.0f); camera_list.push_back( tmp); return i;}void cameraSystem::set_position( D3DXVECTOR3 &pos){ camera_list[view_current]->pos = pos; //camera_list[view_current]->pos.z = view_zoom; //D3DXMatrixLookAtLH( &matView, &camera_list[view_current]->pos, &camera_list[view_current]->pos, &D3DXVECTOR3( 0.0f, 1.0f, 0.0f)); D3DXMatrixTranslation( &matView, pos.x, pos.y, 0);}void cameraSystem::applyView(){ //pDevice->SetTransform( D3DTS_WORLD, &matWorld); pDevice->SetTransform( D3DTS_VIEW, &matView);}
It doesn't seem to move anything. I use a bunch of D3DXSPRITEs, so is there something I have to set to make it work with those?
[Edited by - justin12343 on August 26, 2010 9:39:07 PM]