cuve de gaz
This commit is contained in:
69
main.c
69
main.c
@ -16,6 +16,8 @@ typedef struct {
|
||||
float lambda;
|
||||
float angleM1;
|
||||
Vector2 center;
|
||||
bool gaz;
|
||||
float nGaz;
|
||||
} Michelson;
|
||||
|
||||
Color WavelengthToColor(float lambda) {
|
||||
@ -47,9 +49,9 @@ bool GuiButtonRepeat(Rectangle bounds, const char* text, bool shouldRepeat) {
|
||||
return clicked || held;
|
||||
}
|
||||
|
||||
/*
|
||||
void DrawInterferenceViewCPU(Michelson *mic, Rectangle rec) {
|
||||
DrawRectangleRec((Rectangle){rec.x - 4, rec.y - 30, rec.width + 8, rec.height + 34}, COLOR_PANEL);
|
||||
//DrawText("ECRAN", rec.x, rec.y - 30, 20, WHITE);
|
||||
DrawText("ECRAN", rec.x, rec.y - 26, 20, COLOR_TEXT_DIM);
|
||||
|
||||
DrawRectangleRec(rec, BLACK);
|
||||
@ -57,8 +59,14 @@ void DrawInterferenceViewCPU(Michelson *mic, Rectangle rec) {
|
||||
|
||||
Color baseColor = WavelengthToColor(mic->lambda);
|
||||
|
||||
float extraPath = 0.0f;
|
||||
if (mic->gaz)
|
||||
extraPath = 2.0f * 100.0f * (mic->nGaz - 1.0f);
|
||||
|
||||
float d2_effective = mic->d2 + (extraPath / 2.0f);
|
||||
|
||||
// Diff de marche du à l'axe (2 * e) + micro -> nano
|
||||
float deltaLnm = 2.0f * (mic->d1 - mic->d2) * 1000.0f;
|
||||
float deltaLnm = 2.0f * (mic->d1 - d2_effective) * 1000.0f;
|
||||
|
||||
int cx = rec.x + rec.width / 2;
|
||||
int cy = rec.y + rec.height / 2;
|
||||
@ -98,6 +106,7 @@ void DrawInterferenceViewCPU(Michelson *mic, Rectangle rec) {
|
||||
DrawLine(cx - 10, cy, cx + 10, cy, Fade(WHITE, 0.5f));
|
||||
DrawLine(cx, cy - 10, cx, cy + 10, Fade(WHITE, 0.5f));
|
||||
}
|
||||
*/
|
||||
|
||||
void DrawInterferenceViewGPU(Michelson *mic, Rectangle rec, Shader shader, bool *isFullscreen) {
|
||||
|
||||
@ -119,12 +128,17 @@ void DrawInterferenceViewGPU(Michelson *mic, Rectangle rec, Shader shader, bool
|
||||
float scrHeight = (float)GetScreenHeight();
|
||||
float zoom = *isFullscreen ? 0.7 : 1;
|
||||
|
||||
//
|
||||
float addedOpticalPathOneWay = 0.0f;
|
||||
if (mic->gaz) {
|
||||
addedOpticalPathOneWay = 100.0f * (mic->nGaz - 1.0f);
|
||||
}
|
||||
float d2_effective = mic->d2 + addedOpticalPathOneWay;
|
||||
|
||||
SetShaderValue(shader, GetShaderLocation(shader, "center"), center, SHADER_UNIFORM_VEC2);
|
||||
SetShaderValue(shader, GetShaderLocation(shader, "screenHeight"), &scrHeight, SHADER_UNIFORM_FLOAT);
|
||||
|
||||
SetShaderValue(shader, GetShaderLocation(shader, "d1"), &mic->d1, SHADER_UNIFORM_FLOAT);
|
||||
SetShaderValue(shader, GetShaderLocation(shader, "d2"), &mic->d2, SHADER_UNIFORM_FLOAT);
|
||||
SetShaderValue(shader, GetShaderLocation(shader, "d2"), &d2_effective, SHADER_UNIFORM_FLOAT);
|
||||
SetShaderValue(shader, GetShaderLocation(shader, "lambda"), &mic->lambda, SHADER_UNIFORM_FLOAT);
|
||||
SetShaderValue(shader, GetShaderLocation(shader, "angleM1"), &mic->angleM1, SHADER_UNIFORM_FLOAT);
|
||||
SetShaderValue(shader, GetShaderLocation(shader, "zoom"), &zoom, SHADER_UNIFORM_FLOAT);
|
||||
@ -183,6 +197,18 @@ void DrawMichelsonSchema (Michelson *mic) {
|
||||
DrawRectangleLines(startSource.x - 30, startSource.y - 20, 30, 40, GRAY);
|
||||
DrawText("Source", startSource.x - 50, startSource.y - 50, 20, LIGHTGRAY);
|
||||
|
||||
if (mic->gaz) {
|
||||
float cellDist = 80.0f;
|
||||
float cellW = 60.0f;
|
||||
float cellH = 40.0f;
|
||||
Rectangle cellRect = {c.x + cellDist, c.y - cellH / 2, cellW, cellH};
|
||||
|
||||
DrawRectangleRec(cellRect, Fade(BLUE, 0.15f + (mic->nGaz - 1.0f) * 2.0f));
|
||||
DrawRectangleLinesEx(cellRect, 2, SKYBLUE);
|
||||
|
||||
DrawText(TextFormat("n=%.3f", mic->nGaz), c.x + cellDist, c.y + 25, 10, SKYBLUE);
|
||||
}
|
||||
|
||||
// M2
|
||||
DrawRectangle(posM2.x, posM2.y - (mirrorSize / 2), 12, mirrorSize, LIGHTGRAY);
|
||||
DrawRectangle(posM2.x, posM2.y - (mirrorSize / 2) + 2, 4, mirrorSize - 4, WHITE);
|
||||
@ -269,27 +295,40 @@ void DrawControlPanel(Michelson *mic) {
|
||||
// Angle M1
|
||||
startY += 90;
|
||||
DrawText(TextFormat("Inclinaison M1: %.3f deg", mic->angleM1), startX, startY, 20, ORANGE);
|
||||
|
||||
float stepAngle = speedMode ? 0.05f : 0.001f;
|
||||
|
||||
if (GuiButtonRepeat((Rectangle){startX, startY + 30, btnSize, 25}, "-", shouldRepeat)) mic->angleM1 -= stepAngle;
|
||||
GuiSlider((Rectangle){startX + btnSize + 5, startY + 30, sliderWidth - 75, 25}, 0, 0, &mic->angleM1, -1.0f, 1.0f);
|
||||
if (GuiButtonRepeat((Rectangle){startX + btnSize + sliderWidth - 65, startY + 30, btnSize, 25}, "+", shouldRepeat)) mic->angleM1 += stepAngle;
|
||||
if (GuiButton((Rectangle){startX + contentWidth - 60, startY + 30, 60, 25}, "Zero")) mic->angleM1 = 0.0f;
|
||||
|
||||
|
||||
|
||||
// Status
|
||||
startY += 70;
|
||||
bool isLameAir = (fabs(mic->angleM1) < 0.001f);
|
||||
const char* modeTxt = isLameAir ? "MODE: LAME D'AIR" : "MODE: COIN D'AIR";
|
||||
const char* modeTxt = isLameAir ? "LAME D'AIR" : "COIN D'AIR";
|
||||
Color modeColor = isLameAir ? SKYBLUE : GREEN;
|
||||
|
||||
DrawRectangle(startX, startY + 70, contentWidth, 30, Fade(modeColor, 0.2f));
|
||||
DrawRectangleLines(startX, startY + 70, contentWidth, 30, modeColor);
|
||||
DrawText(modeTxt, startX + 10, startY + 78, 18, modeColor);
|
||||
|
||||
DrawRectangle(startX, startY, contentWidth, 30, Fade(modeColor, 0.2f));
|
||||
DrawRectangleLines(startX, startY, contentWidth, 30, modeColor);
|
||||
DrawText(modeTxt, startX + 10, startY + 8, 20, modeColor);
|
||||
|
||||
// Cuve de gaz
|
||||
startY += 50;
|
||||
DrawLine(startX, startY - 10, startX + contentWidth, startY - 10, Fade(GRAY, 0.3f));
|
||||
DrawText("Cuve de Gaz (Indice n)", startX, startY, 20, SKYBLUE);
|
||||
GuiCheckBox((Rectangle){startX, startY + 30, 20, 20}, "Cuve", &mic->gaz);
|
||||
if (mic->gaz) {
|
||||
DrawText(TextFormat("n = %.4f", mic->nGaz), startX + 150, startY + 30, 20, WHITE);
|
||||
float stepN = speedMode ? 0.001f : 0.0001f;
|
||||
if (GuiButtonRepeat((Rectangle){startX, startY + 55, btnSize, 25}, "-", shouldRepeat)) mic->nGaz -= stepN;
|
||||
GuiSlider((Rectangle){startX + btnSize + 5, startY + 55, sliderWidth - 10, 25}, NULL, NULL, &mic->nGaz, 1.000f, 1.100f);
|
||||
if (GuiButtonRepeat((Rectangle){startX + btnSize + sliderWidth, startY + 55, btnSize, 25}, "+", shouldRepeat)) mic->nGaz += stepN;
|
||||
if (mic->nGaz < 1.0f) mic->nGaz = 1.0f;
|
||||
//startY += 90;
|
||||
}
|
||||
|
||||
// Données
|
||||
startY += 150;
|
||||
DrawLine(startX, startY - 20, startX + contentWidth, startY - 20, GRAY);
|
||||
startY += 100;
|
||||
DrawLine(startX, startY - 10, startX + contentWidth, startY - 10, GRAY);
|
||||
DrawText("DONNEES TEMPS REEL", startX, startY, 20, GRAY);
|
||||
|
||||
float delta = 2 * (mic->d1 - mic->d2);
|
||||
|
||||
Reference in New Issue
Block a user