nimo New.Internet.Master.Operator | Salut
Je fais une simulation en 3d, j'ai mis en place 3 different camera, the boutton S fais avancer mon caracter ds la simulation, je voudrai aussi que les 3 camera change un par un quand le caracter avance ?
Es ce que vous pouvai m'aider please ?
Peu etre une loop avec les 3 cameras, quand la person appui sur S ca fais avancer le caracter mais aussi changes un par un les vue de camera (je voudrai faire cela pour montrer que le caracter marche)
Voici le code:
Code :
- #define SHOULDER 0
- #define SIDE 1
- #define TOP 2
- ....
- void SetShoulderCamera()
- {
- float distz=50,disty=20;
- DXUMatrixLookAtRH(&matCamera1, &DXUVECTOR3D
- (
- car.x-(car.matrix(2,0)*distz)+(car.matrix(1,0)*disty),
- car.y-(car.matrix(2,1)*distz)+(car.matrix(1,1)*disty),
- car.z-(car.matrix(2,2)*distz)+(car.matrix(1,2)*disty)
- ),
- &DXUVECTOR3D(car.x, car.y,car.z ), &DXUVECTOR3D( car.matrix(1,0), car.matrix(1,1),car.matrix(1,2) ));
- DXUSetDeviceCameraMatrix(&matCamera1);
- vLookatPt.x=car.x; vLookatPt.y=car.y; vLookatPt.z=car.z;
- vEyePt.x= car.x-(car.matrix(2,0)*distz)+(car.matrix(1,0)*disty);
- vEyePt.y= car.y-(car.matrix(2,1)*distz)+(car.matrix(1,1)*disty);
- vEyePt.z= car.z-(car.matrix(2,2)*distz)+(car.matrix(1,2)*disty);
- }
- void SetTopCamera()
- {
- float disty=990,distx=100;
- DXUMatrixLookAtRH(&matCamera1, &DXUVECTOR3D
- (
- car.x+(car.matrix(1,0)*disty),
- car.y+(car.matrix(1,1)*disty),
- car.z+(car.matrix(1,2)*disty)
- ),
- &DXUVECTOR3D(car.x, car.y,car.z ), &DXUVECTOR3D( car.matrix(2,0), car.matrix(2,1),car.matrix(2,2) ));
- DXUSetDeviceCameraMatrix(&matCamera1);
- vLookatPt.x=car.x; vLookatPt.y=car.y; vLookatPt.z=car.z;
- vEyePt.x= car.x-(car.matrix(2,0)*disty)+(car.matrix(1,0)*distx);
- vEyePt.y= car.y-(car.matrix(2,1)*disty)+(car.matrix(1,1)*distx);
- vEyePt.z= car.z-(car.matrix(2,2)*disty)+(car.matrix(1,2)*distx);
- }
- void SetSideCamera()
- {
- float disty=50,distx=100;
- DXUMatrixLookAtRH(&matCamera1,&DXUVECTOR3D
- (
- car.x+(car.matrix(0,0)*distx)+(car.matrix(1,0)*disty),
- car.y+(car.matrix(0,1)*distx)+(car.matrix(1,1)*disty),
- car.z+(car.matrix(0,2)*distx)+(car.matrix(1,2)*disty)
- ),
- &DXUVECTOR3D(car.x, car.y,car.z ), &DXUVECTOR3D( car.matrix(1,0), car.matrix(1,1),car.matrix(1,2) ));
- DXUSetDeviceCameraMatrix(&matCamera1);
- vLookatPt.x=car.x; vLookatPt.y=car.y; vLookatPt.z=car.z;
- vEyePt.x= car.x-(car.matrix(2,0)*disty)+(car.matrix(1,0)*distx);
- vEyePt.y= car.y-(car.matrix(2,1)*disty)+(car.matrix(1,1)*distx);
- vEyePt.z= car.z-(car.matrix(2,2)*disty)+(car.matrix(1,2)*distx);
- }
- ...............
- VOID UpdateWorld()
- {
- ...
- static camera =SHOULDER;
- ...
- if( dxuKeyState[DIK_A])
- {
- car.Advance();
- // camera =SHOULDER;
- // camera =TOP;
- // camera =SIDE;
- for( i=0;i<ARRAYSIZE;i++)
- {
- for( j=0;j<ARRAYSIZE;j++)
- {
- if (OverlayMap[i][j]!=0)
- {
- if(collider.SimpleCollision(20,car.x,car.y,car.z,i*45,0,j*45))
- {
- car.Reverse();
- }
- }
- }
- }
- }
- if( dxuKeyState[DIK_S])
- {
- car.Reverse();
- for( i=0;i<ARRAYSIZE;i++)
- {
- for( j=0;j<ARRAYSIZE;j++)
- {
- if (OverlayMap[i][j]!=0)
- {
- if(collider.SimpleCollision(20,car.x,car.y,car.z,i*45,0,j*45))
- {
- car.Advance();
- }
- }
- }
- }
- }
- if(dxuKeyState[DIK_F1])
- {
- camera=SIDE;
- }
- if(dxuKeyState[DIK_F2])
- {
- camera=TOP;
- }
- if(dxuKeyState[DIK_F3])
- {
- camera=SHOULDER;
- }
- ...
- switch (camera)
- {
- case 0:{
- SetShoulderCamera();
- break;
- }
- case 1:{
- SetSideCamera();
- break;
- }
- case 2:{
- SetTopCamera();
- break;
- }
- }
- }
|
Merci d'avance ---------------
NEC 3500 | YAMADA 6600 | NIMO_CORP
|