GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — libprocessing/examples/lights.rs at python-api · processing/libprocessing Expand file tree/ Copy pathlights.rsMore file actions 107 lines (90 loc) · 3.22 KB / Copy pathlights.rsFile metadata and controls107 lines (90 loc) · 3.22 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 use processing_glfw::GlfwContext; use bevy::math::Vec3; use processing::prelude::*; use processing_render::render::command::DrawCommand; fn main() { match sketch() { Ok(_) => { eprintln!("Sketch completed successfully"); exit(0).unwrap(); } Err(e) => { eprintln!("Sketch error: {:?}", e); exit(1).unwrap(); } }; } fn sketch() -> error::Result<()> { let mut glfw_ctx = GlfwContext::new(400, 400, false)?; init(Config::default())?; let width = 400; let height = 400; let surface = glfw_ctx.create_surface(width, height, false)?; let graphics = graphics_create(surface, width, height, TextureFormat::Rgba16Float)?; let box_geo = geometry_box(100.0, 100.0, 100.0)?; let pbr_mat = material_create_pbr()?; material_set(pbr_mat, "roughness", shader_value::ShaderValue::Float(0.0))?; // We will only declare lights in `setup` // rather than calling some sort of `light()` method inside of `draw` // create a directional light let _dir_light = light_create_directional(graphics, bevy::color::Color::srgb(0.35, 0.25, 0.5), 500.0)?; // create a point light let point_light_a = light_create_point( graphics, bevy::color::Color::srgb(1.0, 0.5, 0.25), 1_000_000.0, 200.0, 0.5, )?; transform_set_position(point_light_a, Vec3::new(-25.0, 5.0, 51.0))?; transform_look_at(point_light_a, Vec3::new(0.0, 0.0, 0.0))?; // create another point light let point_light_b = light_create_point( graphics, bevy::color::Color::srgb(0.0, 0.5, 0.75), 2_000_000.0, 200.0, 0.25, )?; transform_set_position(point_light_b, Vec3::new(0.0, 5.0, 50.5))?; transform_look_at(point_light_b, Vec3::new(0.0, 0.0, 0.0))?; // and a spot light, too! let spot_light = light_create_spot( graphics, bevy::color::Color::srgb(0.25, 0.8, 0.19), 15.0 * 1_000_000.0, 200.0, 0.84, 0.0, core::f32::consts::FRAC_PI_4, )?; transform_set_position(spot_light, Vec3::new(40.0, 0.0, 70.0))?; transform_look_at(spot_light, Vec3::new(0.0, 0.0, 0.0))?; graphics_mode_3d(graphics)?; transform_set_position(graphics, Vec3::new(100.0, 100.0, 300.0))?; transform_look_at(graphics, Vec3::new(0.0, 0.0, 0.0))?; let mut angle = 0.0; while glfw_ctx.poll_events() { graphics_begin_draw(graphics)?; graphics_record_command( graphics, DrawCommand::BackgroundColor(bevy::color::Color::srgb(0.18, 0.20, 0.15)), )?; graphics_record_command(graphics, DrawCommand::Fill(bevy::color::Color::WHITE))?; graphics_record_command(graphics, DrawCommand::Material(pbr_mat))?; graphics_record_command(graphics, DrawCommand::PushMatrix)?; graphics_record_command( graphics, DrawCommand::Rotate { angle, axis: Vec3::Z, }, )?; graphics_record_command(graphics, DrawCommand::Geometry(box_geo))?; graphics_record_command(graphics, DrawCommand::PopMatrix)?; graphics_end_draw(graphics)?; angle += 0.02; } Ok(()) } |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |