Changed to a right hand cord system

This commit is contained in:
InventorXtreme 2023-12-04 08:15:04 -05:00
parent 0862f6ddcb
commit e90f1e6b62

22
c3d.c
View file

@ -46,6 +46,10 @@ Vector3 Vector3Sum(Vector3 v1, Vector3 v2) {
return retvec;
}
void Vector3Print(Vector3 v) {
printf("VX: %f, VY: %f, FZ: %f\n",v.x,v.y,v.z);
}
Vector3 Vector3Scale(Vector3 v1, float scale) {
Vector3 retvec;
retvec.x = v1.x * scale;
@ -86,15 +90,17 @@ void CtrlLocalCam(LocalCam *cam, float time) {
cam->angleVelocity.z = 0;
if (IsKeyDown(KEY_W)) {
Vector3 forceForward = (Vector3){0,0,500};
Vector3 forceForward = (Vector3){0,0,-500};
Vector3 rotatedforce = RotateAboutY(forceForward,cam->angles.y);
printf("%f", cam->angles.y);
Vector3Print(rotatedforce);
cam->velocity = Vector3Sum(cam->velocity,rotatedforce);
//cam->velocity.z = cam->velocity.z + 50000*time*sin(cam->angles.y);
//cam->velocity.x = cam->velocity.x + 500*time*cos(cam->angles.y);
}
if (IsKeyDown(KEY_S)) {
Vector3 forceForward = (Vector3){0,0,-500};
Vector3 forceForward = (Vector3){0,0,500};
Vector3 rotatedforce = RotateAboutY(forceForward,cam->angles.y);
cam->velocity = Vector3Sum(cam->velocity,rotatedforce);
@ -156,8 +162,8 @@ void LocalCamApplyVelo(LocalCam *cam,float time){
Vector2 Conv3Dto2D(Vector3 v) {
Vector2 returnvector;
returnvector.x = proj * v.x / v.z;
returnvector.y = proj * v.y / v.z;
returnvector.x = proj * v.x / (-v.z);
returnvector.y = proj * v.y / (-v.z);
return returnvector;
}
@ -175,8 +181,8 @@ Vector3 TransformWithCam(Vector3 v, LocalCam * cam) {
returnvector.z = v.z - cam->position.z;
returnvector = RotateAboutZ(returnvector,cam->angles.z);
returnvector = RotateAboutY(returnvector,cam->angles.y);
returnvector = RotateAboutZ(returnvector,cam->angles.z);
returnvector = RotateAboutY(returnvector,-cam->angles.y);
returnvector = RotateAboutX(returnvector,-cam->angles.x);
//printf("Before: %f %f %f, After: %f %f %f\n", v.x, v.y, v.z, returnvector.x, returnvector.y, returnvector.z);
return returnvector;
@ -215,7 +221,7 @@ int main() {
camera.velocity = (Vector3){0,0,0};
camera.angleVelocity = (Vector3){0,0,0};
Vector3 point = (Vector3){0,0,10};
Vector3 point = (Vector3){0,0,-10};
@ -228,9 +234,11 @@ int main() {
DrawText("Congrats! You created your first window!", 190, 200, 20,
BLACK);
Vector3 TransVector = TransformWithCam(point,&camera);
if (TransVector.z < 0) {
Vector2 MPos = Conv3Dto2D(TransVector);
Vector2 FinPos = Conv2DCenteredToScreen(MPos);
DrawCircleV(FinPos,100,BLACK);
}
EndTextureMode();
//Copytexture to main display :0