void setUpReference() { // Light lights[numLights++] = light_new(point_new(3, 5, -15), 0); // Reflective material color_t color = rgb(0, 0, 0); material_t refl = material_new(color, 1); // Red material color = rgb(255, 0, 0); material_t red = material_new(color, 0); // Blue material color = rgb(0, 0, 255); material_t blue = material_new(color, 0); // White material color = rgb(255, 255, 255); material_t white = material_new(color, 0); // Spheres point_t s = point_new(0, 0, -16); spheres[numSpheres++] = sphere_new(s, 2, refl); s = point_new(3, -1, -14); spheres[numSpheres++] = sphere_new(s, 1, refl); s = point_new(-3, -1, -14); spheres[numSpheres++] = sphere_new(s, 1, red); // Back blue wall point_t a = point_new(-8, -2, -20); point_t b = point_new(8, -2, -20); point_t c = point_new(8, 10, -20); triangles[numTriangles++] = triangle_new3(a, b, c, blue); a = point_new(-8, -2, -20); b = point_new(8, 10, -20); c = point_new(-8, 10, -20); triangles[numTriangles++] = triangle_new3(a, b, c, blue); // White floor a = point_new(-8, -2, -20); b = point_new(8, -2, -10); c = point_new(8, -2, -20); triangles[numTriangles++] = triangle_new3(a, b, c, white); a = point_new(-8, -2, -20); b = point_new(-8, -2, -10); c = point_new(8, -2, -10); triangles[numTriangles++] = triangle_new3(a, b, c, white); // Right red wall a = point_new(8, -2, -20); b = point_new(8, -2, -10); c = point_new(8, 10, -20); triangles[numTriangles++] = triangle_new3(a, b, c, red); }
static void init_lighting (View *view) { gint i; glGetIntegerv (GL_MAX_LIGHTS, &view->nlights); view->lights = g_new (Light*, view->nlights); for (i = 0; i < view->nlights; i++) { view->lights[i] = light_new (GL_LIGHT0 + i); } default_lighting (view); }
static void *ctor(renderer_t r, void *common) { struct _world *world = NULL; vec3_t spawn; world = calloc(1, sizeof(*world)); if ( NULL == world ) goto out; world->render = r; renderer_viewangles(r, 45.0, 45.0, 0.0); world->map = map_load(r, "data/maps/level1"); if ( NULL == world->map ) goto out_free; spawn[0] = 0.0; spawn[1] = CHOPPER_HEIGHT; spawn[2] = 0.0; world->apache = chopper_comanche(spawn, 0.785); if ( NULL == world->apache ) goto out_free_map; world->light = light_new(r, LIGHT_CAST_SHADOWS); if ( NULL == world->light ) { goto out_free_chopper; } world->font = font_load(r, "data/font/carbon.png", 16, 16); if ( NULL == world->font ) goto out_free_light; world->lightRate = 1440; world->light_ticks = 10; world->cvars = cvar_ns_new("world"); if ( NULL == world->cvars ) goto out_free_font; cvar_register_float(world->cvars, "time", CVAR_FLAG_SAVE_ALWAYS, &world->lightAngle); cvar_register_float(world->cvars, "lightRate", CVAR_FLAG_SAVE_NOTDEFAULT, &world->lightRate); cvar_register_uint(world->cvars, "tpf", CVAR_FLAG_SAVE_NOTDEFAULT, &world->light_ticks); cvar_ns_load(world->cvars); world->fcnt = (world->lightAngle / (M_PI / world->lightRate)); world->fcnt *= world->light_ticks; /* success */ goto out; out_free_font: font_free(world->font); out_free_light: light_free(world->light); out_free_chopper: chopper_free(world->apache); out_free_map: map_free(world->map); out_free: free(world); world = NULL; out: return world; }
void setUpCustom() { // Light lights[numLights++] = light_new(point_new(0, 2, -6), 0.5); // Reflective material color_t color = rgb(0, 0, 0); material_t refl = material_new(color, 1); // Red material color = rgb(231, 76, 60); material_t red = material_new(color, 0); // Green material color = rgb(46, 204, 113); material_t green = material_new(color, 0); // Purple material color = rgb(155, 89, 182); material_t purple = material_new(color, 0); // White material color = rgb(255, 255, 255); material_t white = material_new(color, 0); // Spheres point_t s = point_new(-1, -1, -8); spheres[numSpheres++] = sphere_new(s, 1, refl); s = point_new(1, -1, -7); spheres[numSpheres++] = sphere_new(s, 1, purple); // White back wall point_t a = point_new(-2.5, -2, -10); point_t b = point_new(2.5, -2, -10); point_t c = point_new(-2.5, 2, -10); triangles[numTriangles++] = triangle_new3(a, b, c, white); a = point_new(2.5, -2, -10); b = point_new(2.5, 2, -10); c = point_new(-2.5, 2, -10); triangles[numTriangles++] = triangle_new3(a, b, c, white); // White ceiling (it has a hole in it...) a = point_new(-2.5, 2, -2); b = point_new(2.5, 2, -2); c = point_new(2.5, 2, -5.5); triangles[numTriangles++] = triangle_new3(a, b, c, white); a = point_new(-2.5, 2, -2); b = point_new(2.5, 2, -5.5); c = point_new(-2.5, 2, -5.5); triangles[numTriangles++] = triangle_new3(a, b, c, white); a = point_new(-2.5, 2, -10); b = point_new(2.5, 2, -6.5); c = point_new(-2.5, 2, -6.5); triangles[numTriangles++] = triangle_new3(a, b, c, white); a = point_new(-2.5, 2, -10); b = point_new(2.5, 2, -10); c = point_new(2.5, 2, -6.5); triangles[numTriangles++] = triangle_new3(a, b, c, white); a = point_new(-2.5, 2, -6.5); b = point_new(-0.5, 2, -6.5); c = point_new(-0.5, 2, -5.5); triangles[numTriangles++] = triangle_new3(a, b, c, white); a = point_new(-2.5, 2, -6.5); b = point_new(-0.5, 2, -5.5); c = point_new(-2.5, 2, -5.5); triangles[numTriangles++] = triangle_new3(a, b, c, white); a = point_new(0.5, 2, -6.5); b = point_new(2.5, 2, -6.5); c = point_new(2.5, 2, -5.5); triangles[numTriangles++] = triangle_new3(a, b, c, white); a = point_new(0.5, 2, -6.5); b = point_new(2.5, 2, -5.5); c = point_new(0.5, 2, -5.5); triangles[numTriangles++] = triangle_new3(a, b, c, white); // White floor a = point_new(-2.5, -2, -2); b = point_new(2.5, -2, -2); c = point_new(2.5, -2, -10); triangles[numTriangles++] = triangle_new3(a, b, c, white); a = point_new(-2.5, -2, -2); b = point_new(2.5, -2, -10); c = point_new(-2.5, -2, -10); triangles[numTriangles++] = triangle_new3(a, b, c, white); // Red left wall a = point_new(-2.5, -2, -2); b = point_new(-2.5, -2, -10); c = point_new(-2.5, 2, -10); triangles[numTriangles++] = triangle_new3(a, b, c, red); a = point_new(-2.5, -2, -2); b = point_new(-2.5, 2, -10); c = point_new(-2.5, 2, -2); triangles[numTriangles++] = triangle_new3(a, b, c, red); // Green right wall a = point_new(2.5, -2, -2); b = point_new(2.5, -2, -10); c = point_new(2.5, 2, -10); triangles[numTriangles++] = triangle_new3(a, b, c, green); a = point_new(2.5, -2, -2); b = point_new(2.5, 2, -10); c = point_new(2.5, 2, -2); triangles[numTriangles++] = triangle_new3(a, b, c, green); }