New lighting, new spheres

This commit is contained in:
Vulpovile
2021-03-04 13:07:04 -08:00
parent fb966e0b82
commit 20c18c6f9b
3 changed files with 31 additions and 161 deletions

View File

@@ -137,9 +137,9 @@ Application::Application(HWND parentWindow) : _propWindow(NULL) { //: GApp(setti
webBrowser = new IEBrowser(_hwndToolbox);
SetWindowLongPtr(_hwndToolbox,GWL_USERDATA+1,(LONG)webBrowser);
//webBrowser->navigateSyncURL(L"http://androdome.com/res/ClientToolbox.php");
webBrowser->navigateSyncURL(L"http://androdome.com/res/ClientToolbox.php");
//navigateToolbox(GetFileInPath("/content/page/controller.html"));
//navigateToolbox(GetFileInPath("/content/page/controller.html"));
navigateToolbox(GetFileInPath("/content/page/surface.html"));
}
@@ -643,6 +643,7 @@ void Application::onGraphics(RenderDevice* rd) {
}
LightingParameters lighting(G3D::toSeconds(2, 00, 00, PM));
lighting.ambient = Color3(0.6F,0.6F,0.6F);
renderDevice->setProjectionAndCameraMatrix(*cameraController.getCamera());
// Cyan background
@@ -659,8 +660,19 @@ void Application::onGraphics(RenderDevice* rd) {
renderDevice->setShadeMode(RenderDevice::SHADE_SMOOTH);
renderDevice->setAmbientLightColor(Color3(1,1,1));
renderDevice->setLight(0, GLight::directional(lighting.lightDirection, lighting.lightColor));
renderDevice->setLight(0, GLight::directional(lighting.lightDirection, lighting.lightColor, true, true));
renderDevice->setAmbientLightColor(lighting.ambient);
renderDevice->setShininess(70);
renderDevice->setSpecularCoefficient(Color3(0.1F, 0.1F, 0.1F));
//float lightAmbient[] = { 0.5F, 0.6F, 0.9F, 1.0F };
//float lightDiffuse[] = { 0.6F, 0.4F, 0.9F, 1.0F };
//float lightSpecular[] = { 0.8F, 0.6F, 1.0F, 1.0F };
//glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, lightAmbient);
//glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, lightDiffuse);
//glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, lightSpecular);
//glMateriali(GL_FRONT_AND_BACK, GL_SHININESS, 70);
rd->beforePrimitive();
CoordinateFrame forDraw = rd->getObjectToWorldMatrix();

View File

@@ -478,6 +478,9 @@ bool PartInstance::isUniqueVertex(Vector3 pos)
//int rings = 15;
//int sectors = 15;
void PartInstance::render(RenderDevice* rd) {
int sectorCount = 12;
int stackCount = 12;
float radius = 0.5F;
//if(nameShown)
//postRenderStack.push_back(this);
if (changed)
@@ -493,161 +496,17 @@ void PartInstance::render(RenderDevice* rd) {
{
case Enum::Shape::Ball:
{
/*float radius = renderSize.y / 2;
float const R = 1./(float)(rings-1);
float const S = 1./(float)(sectors-1);
int r, s;
double M_PI = pi();
double M_PI_2 = M_PI/2;
_vertices.resize(rings * sectors * 3);
_normals.resize(rings * sectors * 3);
std::vector<GLfloat>::iterator v = _vertices.begin();
std::vector<GLfloat>::iterator n = _normals.begin();
//std::vector<GLfloat>::iterator t = texcoords.begin();
for(r = 0; r < rings; r++) for(s = 0; s < sectors; s++) {
float const y = sin( -M_PI_2 + M_PI * r * R );
float const x = cos(2*M_PI * s * S) * sin( M_PI * r * R );
float const z = sin(2*M_PI * s * S) * sin( M_PI * r * R );
*v++ = x * radius;
*v++ = y * radius;
*v++ = z * radius;
*n++ = x;
*n++ = y;
*n++ = z;
}
_indices.resize(rings * sectors * 4);
std::vector<GLushort>::iterator i = _indices.begin();
for(r = 0; r < rings; r++) for(s = 0; s < sectors; s++) {
*i++ = r * sectors + s;
*i++ = r * sectors + (s+1);
*i++ = (r+1) * sectors + (s+1);
*i++ = (r+1) * sectors + s;
}
//*/
float sphFace = this->size.y / 3.14159F;
// Front
addSmoothTriangle(Vector3(renderSize.x-sphFace,renderSize.y-sphFace,renderSize.z),
Vector3(-renderSize.x+sphFace,-renderSize.y+sphFace,renderSize.z),
Vector3(renderSize.x-sphFace,-renderSize.y+sphFace,renderSize.z)
);
addSmoothTriangle(Vector3(-renderSize.x+sphFace,renderSize.y-sphFace,renderSize.z),
Vector3(-renderSize.x+sphFace,-renderSize.y+sphFace,renderSize.z),
Vector3(renderSize.x-sphFace,renderSize.y-sphFace,renderSize.z)
);
// Top
addSmoothTriangle(Vector3(renderSize.x-sphFace,renderSize.y,renderSize.z-sphFace),
Vector3(renderSize.x-sphFace,renderSize.y,-renderSize.z+sphFace),
Vector3(-renderSize.x+sphFace,renderSize.y,renderSize.z-sphFace)
);
addSmoothTriangle(Vector3(-renderSize.x+sphFace,renderSize.y,renderSize.z-sphFace),
Vector3(renderSize.x-sphFace,renderSize.y,-renderSize.z+sphFace),
Vector3(-renderSize.x+sphFace,renderSize.y,-renderSize.z+sphFace)
);
// Back
addSmoothTriangle(Vector3(renderSize.x-sphFace,renderSize.y-sphFace,-renderSize.z),
Vector3(renderSize.x-sphFace,-renderSize.y+sphFace,-renderSize.z),
Vector3(-renderSize.x+sphFace,-renderSize.y+sphFace,-renderSize.z)
);
addSmoothTriangle(Vector3(renderSize.x-sphFace,renderSize.y-sphFace,-renderSize.z),
Vector3(-renderSize.x+sphFace,-renderSize.y+sphFace,-renderSize.z),
Vector3(-renderSize.x+sphFace,renderSize.y-sphFace,-renderSize.z)
);
// Bottom
addSmoothTriangle(Vector3(renderSize.x-sphFace,-renderSize.y,-renderSize.z+sphFace),
Vector3(renderSize.x-sphFace,-renderSize.y,renderSize.z-sphFace),
Vector3(-renderSize.x+sphFace,-renderSize.y,renderSize.z-sphFace)
);
addSmoothTriangle(Vector3(-renderSize.x+sphFace,-renderSize.y,renderSize.z-sphFace),
Vector3(-renderSize.x+sphFace,-renderSize.y,-renderSize.z+sphFace),
Vector3(renderSize.x-sphFace,-renderSize.y,-renderSize.z+sphFace)
);
// Left
addSmoothTriangle(Vector3(-renderSize.x,renderSize.y-sphFace,-renderSize.z+sphFace),
Vector3(-renderSize.x,-renderSize.y+sphFace,renderSize.z-sphFace),
Vector3(-renderSize.x,renderSize.y-sphFace,renderSize.z-sphFace)
);
addSmoothTriangle(Vector3(-renderSize.x,-renderSize.y+sphFace,renderSize.z-sphFace),
Vector3(-renderSize.x,renderSize.y-sphFace,-renderSize.z+sphFace),
Vector3(-renderSize.x,-renderSize.y+sphFace,-renderSize.z+sphFace)
);
// Right
addSmoothTriangle(Vector3(renderSize.x,renderSize.y-sphFace,renderSize.z-sphFace),
Vector3(renderSize.x,-renderSize.y+sphFace,renderSize.z-sphFace),
Vector3(renderSize.x,renderSize.y-sphFace,-renderSize.z+sphFace)
);
addSmoothTriangle(Vector3(renderSize.x,-renderSize.y+sphFace,-renderSize.z+sphFace),
Vector3(renderSize.x,renderSize.y-sphFace,-renderSize.z+sphFace),
Vector3(renderSize.x,-renderSize.y+sphFace,renderSize.z-sphFace)
);
// Bevel Top Front
makeSmoothFace(0,36,48);
makeSmoothFace(48,18,0);
// Bevel Left Front Corner
makeSmoothFace(18,156,162);
makeSmoothFace(24,18,162);
// Bevel Left Front Top Corner
makeSmoothFace(48,156,18);
// Bevel Left Front Bottom Corner
makeSmoothFace(120,6,150);
// Bevel Left Top
makeSmoothFace(48,66,156);
makeSmoothFace(144,156,66);
// Bevel Bottom
makeSmoothFace(6,120,114);
makeSmoothFace(114,12,6);
// Left Bottom
makeSmoothFace(120,150,174);
makeSmoothFace(174,132,120);
// Right Front Top Corner
makeSmoothFace(36,0,180);
// Right Front Corner
makeSmoothFace(180,0,12);
makeSmoothFace(186,180,12);
// Right Front Bottom Corner
makeSmoothFace(186,12,114);
// Right Bottom
makeSmoothFace(186,114,108);
makeSmoothFace(108,198,186);
// Right Top Corner
makeSmoothFace(180,192,36);
makeSmoothFace(192,42,36);
// Right Back Top Corner
makeSmoothFace(72,42,192);
// Right Back Bottom Corner
makeSmoothFace(78,198,108);
// Right Back Corner
makeSmoothFace(72,192,198);
makeSmoothFace(198,78,72);
// Back Bottom Corner
makeSmoothFace(78,108,132);
makeSmoothFace(132,84,78);
// Back Top
makeSmoothFace(42,72,102);
makeSmoothFace(102,66,42);
// Back Left Top Corner
makeSmoothFace(144,66,102);
// Back Left Corner
makeSmoothFace(144,102,84);
makeSmoothFace(84,174,144);
// Back Left Bottom Corner
makeSmoothFace(174,84,132);
for (unsigned short i=0;i<_vertices.size()/6;i++) {
_indices.push_back(i);
}
glNewList(glList, GL_COMPILE);
glColor(this->color);
glPushMatrix();
glScalef(renderSize.x, renderSize.y, renderSize.z);
gluSphere(gluNewQuadric(), 1, 20, 20);
glPopMatrix();
glEndList();
rd->setObjectToWorldMatrix(cFrame);
glCallList(glList);
changed = false;
return;
}
break;
case Enum::Shape::Block:
@@ -962,10 +821,10 @@ void PartInstance::render(RenderDevice* rd) {
glVertexPointer(3, GL_FLOAT,6 * sizeof(GLfloat), &_vertices[0]);
glColorPointer(3, GL_FLOAT,6 * sizeof(GLfloat), &_vertices[3]);
glNormalPointer(GL_FLOAT,3 * sizeof(GLfloat), &_normals[0]);
glPushMatrix();
//glPushMatrix();
//glTranslatef(2,7,0);
glDrawElements(GL_TRIANGLES, _indices.size(), GL_UNSIGNED_SHORT, &_indices[0]);
glPopMatrix();
//glPopMatrix();
glEndList();
}
rd->setObjectToWorldMatrix(cFrame);

View File

@@ -229,7 +229,6 @@ int main(int argc, char** argv) {
hThisInstance,
NULL
);
if(hwndMain == NULL)
{
MessageBox(NULL, "Critical error loading: Failed to create HWND, must exit", (g_PlaceholderName + " Crash").c_str() , MB_OK);