Visible Wireframe Sphere, need some camera rotation to see it properly though.
All checks were successful
Run ReCI Build Test / Explore-Gitea-Actions (push) Successful in 6m44s

This commit is contained in:
2024-10-22 13:46:59 -04:00
parent 68ba438433
commit 686a4be0c9
2 changed files with 50 additions and 5 deletions

View File

@@ -137,11 +137,14 @@ public:
bool fov_increasing = true;
void display() {
float dt = 1.f / fps;
JGL::Update(getSize());
if (fov_increasing)
fov += 0.25;
fov += 0.025;
else
fov -= 0.50;
fov -= 0.050;
if (fov >= 120)
fov_increasing = false;
@@ -149,8 +152,8 @@ public:
fov_increasing = true;
J3D::ChangeFOV(fov);
sprite_radians += 0.05;
textAngle.y += 2.0f;
sprite_radians += 0.005;
textAngle.y += .05f;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
@@ -163,7 +166,7 @@ public:
J3D::DrawLine(Colors::Red, {-0.33,-0.125,1}, {-1,-0.125,1});
J3D::DrawLine(Colors::Red, {-0.33,-0.125,1}, {-0.33,0.25,1});
J3D::DrawString(Colors::Red, "JGL Sample Text", {-0.33, -0.1, 1.0f}, 1.f, 32, FreeSans, textAngle, true);
//J3D::WireframeSphere(Colors::Green, {0,0,0}, 0.25f, 1.f);
J3D::WireframeSphere(Colors::Green, {0,0,0.05f}, 0.01f, 0.5f);
J3D::End();
J2D::Begin(j2d_render_target, true);

View File

@@ -1065,8 +1065,50 @@ namespace JGL {
if (!inJ3D)
Logger::Error("Drawing J3D element before J3D begin.");
float r = radius;
int lats = 50;
int longs = 50;
int i, j;
for(i = 0; i <= lats; i++) {
double lat0 = M_PI * (-0.5 + (double) (i - 1) / lats);
double z0 = sin(lat0);
double zr0 = cos(lat0);
double lat1 = M_PI * (-0.5 + (double) i / lats);
double z1 = sin(lat1);
double zr1 = cos(lat1);
glLineWidth(thickness);
glBegin(GL_LINE_LOOP);
for(j = 0; j <= longs; j++) {
double lng = 2 * M_PI * (double) (j - 1) / longs;
double x = cos(lng);
double y = sin(lng);
float pos_x = r * x * zr0;
float pos_y = r * y * zr0;
float pos_z = r * z0;
pos_x += position.x;
pos_y += position.y;
pos_z += position.z;
//glNormal3f(x * zr0, y * zr0, z0);
glVertex3f(pos_x, pos_y, pos_z);
float pos2_x = r * x * zr1;
float pos2_y = r * y * zr1;
float pos2_z = r * z1;
pos2_x += position.x;
pos2_y += position.y;
pos2_z += position.z;
//glNormal3f(x * zr1, y * zr1, z1);
glVertex3f(pos2_x, pos2_y, pos2_z);
}
glEnd();
}
}
#pragma endregion