GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — libprocessing/examples/particles_basic.rs at python-particle-api · processing/libprocessing

Expand file tree

/

particles_basic.rs

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
73 lines (61 loc) · 2.31 KB
/

particles_basic.rs

Copy path

File metadata and controls

73 lines (61 loc) · 2.31 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
use processing_glfw::GlfwContext;
use bevy::math::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, 700, false)?;
init(Config::default())?;
let surface = glfw_ctx.create_surface(900, 700, false)?;
let graphics = graphics_create(surface, 900, 700, TextureFormat::Rgba16Float)?;
graphics_mode_3d(graphics)?;
transform_set_position(graphics, Vec3::new(0.0, 0.0, 25.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 sphere = geometry_sphere(0.25, 12, 8)?;
let capacity: u32 = 1000;
let mut floats: Vec<f32> = Vec::with_capacity(capacity as usize * 3);
for x in 0..10 {
for y in 0..10 {
for z in 0..10 {
floats.push((x as f32 - 4.5) * 1.0);
floats.push((y as f32 - 4.5) * 1.0);
floats.push((z as f32 - 4.5) * 1.0);
}
}
}
let bytes: Vec<u8> = floats.iter().flat_map(|f| f.to_le_bytes()).collect();
let position_attr = geometry_attribute_position();
let p = particles_create(capacity, vec![position_attr])?;
let position_buf =
particles_buffer(p, position_attr)?.ok_or(error::ProcessingError::ParticlesNotFound)?;
buffer_write(position_buf, bytes)?;
let pbr = material_create_pbr()?;
material_set(pbr, "roughness", shader_value::ShaderValue::Float(0.4))?;
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::srgb(0.9, 0.5, 0.3)),
)?;
graphics_record_command(graphics, DrawCommand::Material(pbr))?;
graphics_record_command(
graphics,
DrawCommand::Particles {
particles: p,
geometry: Some(sphere),
topology: Default::default(),
},
)?;
graphics_end_draw(graphics)?;
}
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.