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/primitives_3d.rs at python-api · processing/libprocessing Expand file tree/ Copy pathprimitives_3d.rsMore file actions 129 lines (114 loc) · 3.77 KB / Copy pathprimitives_3d.rsFile metadata and controls129 lines (114 loc) · 3.77 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 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 use processing_glfw::GlfwContext; use bevy::math::{Vec2, Vec3}; use processing::prelude::*; use processing_render::render::command::DrawCommand; fn main() { sketch().unwrap(); exit(0).unwrap(); } fn sketch() -> error::Result<()> { let mut glfw_ctx = GlfwContext::new(900, 400, false)?; init(Config::default())?; let surface = glfw_ctx.create_surface(900, 400, false)?; let graphics = graphics_create(surface, 900, 400, TextureFormat::Rgba16Float)?; graphics_mode_3d(graphics)?; transform_set_position(graphics, Vec3::new(0.0, 80.0, 800.0))?; transform_look_at(graphics, Vec3::new(0.0, 0.0, 0.0))?; let _light = light_create_directional(graphics, bevy::color::Color::srgb(0.9, 0.85, 0.8), 300.0)?; let pbr = material_create_pbr()?; material_set(pbr, "roughness", shader_value::ShaderValue::Float(0.35))?; let mut t: f32 = 0.0; while glfw_ctx.poll_events() { graphics_begin_draw(graphics)?; graphics_record_command( graphics, DrawCommand::BackgroundColor(bevy::color::Color::srgb(0.06, 0.06, 0.08)), )?; graphics_record_command(graphics, DrawCommand::Fill(bevy::color::Color::WHITE))?; graphics_record_command(graphics, DrawCommand::Material(pbr))?; let shapes: Vec<(f32, Box<dyn Fn(f32) -> DrawCommand>)> = vec![ ( -315.0, Box::new(|_| DrawCommand::Box { width: 50.0, height: 50.0, depth: 50.0, }), ), ( -225.0, Box::new(|_| DrawCommand::Sphere { radius: 30.0, sectors: 24, stacks: 16, }), ), ( -135.0, Box::new(|_| DrawCommand::Cylinder { radius: 25.0, height: 60.0, detail: 24, }), ), ( -45.0, Box::new(|_| DrawCommand::Cone { radius: 25.0, height: 60.0, detail: 24, }), ), ( 45.0, Box::new(|_| DrawCommand::Torus { radius: 30.0, tube_radius: 10.0, major_segments: 24, minor_segments: 16, }), ), ( 135.0, Box::new(|_| DrawCommand::Capsule { radius: 15.0, length: 40.0, detail: 24, }), ), ( 225.0, Box::new(|_| DrawCommand::ConicalFrustum { radius_top: 15.0, radius_bottom: 25.0, height: 60.0, detail: 24, }), ), ( 315.0, Box::new(|_| DrawCommand::Tetrahedron { radius: 30.0 }), ), ]; for (x_offset, make_cmd) in &shapes { graphics_record_command(graphics, DrawCommand::PushMatrix)?; graphics_record_command( graphics, DrawCommand::Translate(Vec2::new(*x_offset, 0.0).extend(0.0)), )?; graphics_record_command( graphics, DrawCommand::Rotate { angle: t, axis: Vec3::Z, }, )?; graphics_record_command(graphics, make_cmd(t))?; graphics_record_command(graphics, DrawCommand::PopMatrix)?; } graphics_end_draw(graphics)?; t += 0.015; } Ok(()) } |
| You are visitor 01402520 — 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. |