/* Project the cursor's current location onto the plane specified by the normal * vector 'normal' and a perpendicular distance 'dist' from the origin. */ vector mousebase::project1( vector normal, double dist) { double ndc = normal.dot(cam) - dist; double ndr = normal.dot(get_ray()); double t = -ndc / ndr; vector v = cam + get_ray()*t; return v; }
void draw (void) { int i; ray_t *r; for (i = FIRST_RAY_INDEX; i <= LAST_RAY_INDEX; ++i) { r = get_ray(i); if (!r->dirty) { continue; } draw_device (r->devices[0]); draw_device (r->devices[1]); draw_device (r->devices[2]); r->dirty = 0; } }
void render() { log("Begin rendering"); printf("%d %d\n", width, height); if (width == 0 || rendered) { return; } buffer = std::vector<std::vector<Color> >(width, std::vector<Color>(height)); int x, y; #pragma omp parallel for default(shared) private(x, y) schedule(dynamic) collapse(2) num_threads(4) for (x = 0; x < width; ++x) { for (y = 0; y < height; ++y) { buffer[x][y] = scene.trace_ray(get_ray(x, y)); } } enchance_balance(); exit(0); smoothen(); rendered = true; log("End rendering"); }
void draw(t_tool *t, double x, double y) { t_ray *ray; double x0; double y0; t_color *final_color; final_color = new_color(); x0 = x; while (x0 <= x + 0.5) { y0 = y; while (y0 <= y + 0.5) { ray = get_ray(t, x0, y0); add_color(final_color, draw_suite(ray, t)); y0 += 0.5; } x0 += 0.5; } div_color(final_color, 4); normalize_color(final_color); pixel_put_to_image(t, x, y, final_color); }
OSL::ShaderGlobals& ShadingPoint::get_osl_shader_globals() const { assert(hit()); if (!(m_members & HasOSLShaderGlobals)) { const ShadingRay& ray(get_ray()); m_shader_globals.P = Vector3f(get_point()); m_shader_globals.dPdx = OSL::Vec3(0, 0, 0); m_shader_globals.dPdy = OSL::Vec3(0, 0, 0); m_shader_globals.dPdz = OSL::Vec3(0, 0, 0); m_shader_globals.I = Vector3f(normalize(ray.m_dir)); m_shader_globals.dIdx = OSL::Vec3(0, 0, 0); m_shader_globals.dIdy = OSL::Vec3(0, 0, 0); m_shader_globals.N = Vector3f(get_shading_normal()); m_shader_globals.Ng = Vector3f(get_geometric_normal()); m_shader_globals.u = get_uv(0).x; m_shader_globals.dudx = 0; m_shader_globals.dudy = 0; m_shader_globals.v = get_uv(0).y; m_shader_globals.dvdx = 0; m_shader_globals.dvdy = 0; m_shader_globals.dPdu = Vector3f(get_dpdu(0)); m_shader_globals.dPdv = Vector3f(get_dpdv(0)); m_shader_globals.time = ray.m_time; m_shader_globals.dtime = 0; m_shader_globals.dPdtime = OSL::Vec3(0, 0, 0); m_shader_globals.Ps = OSL::Vec3(0, 0, 0); m_shader_globals.dPsdx = OSL::Vec3(0, 0, 0); m_shader_globals.dPsdy = OSL::Vec3(0, 0, 0); m_shader_globals.renderstate = 0; m_shader_globals.tracedata = 0; m_shader_globals.objdata = 0; m_obj_transform_info.m_assembly_instance_transform = &get_assembly_instance().cumulated_transform_sequence(); m_obj_transform_info.m_object_instance_transform = &get_object_instance().get_transform(); m_shader_globals.object2common = reinterpret_cast<OSL::TransformationPtr>(&m_obj_transform_info); m_shader_globals.shader2common = 0; m_shader_globals.surfacearea = 0; m_shader_globals.raytype = static_cast<int>(ray.m_type); m_shader_globals.flipHandedness = 0; m_shader_globals.backfacing = get_side() == ObjectInstance::FrontSide ? 0 : 1; m_shader_globals.context = 0; m_shader_globals.Ci = 0; m_members |= HasOSLShaderGlobals; } else { // Update always the raytype, as it might have changed from the previous run. m_shader_globals.raytype = static_cast<int>(get_ray().m_type); } return m_shader_globals; }