initial commit
This commit is contained in:
commit
d663c3619a
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/target
|
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"rust-analyzer.linkedProjects": [
|
||||
".\\Cargo.toml"
|
||||
]
|
||||
}
|
3870
Cargo.lock
generated
Normal file
3870
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
9
Cargo.toml
Normal file
9
Cargo.toml
Normal file
|
@ -0,0 +1,9 @@
|
|||
[package]
|
||||
name = "vvu"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
bevy = "0.12"
|
60
src/main.rs
Normal file
60
src/main.rs
Normal file
|
@ -0,0 +1,60 @@
|
|||
use bevy::app::*;
|
||||
use bevy::ecs::component::*;
|
||||
use bevy::time::*;
|
||||
use bevy::ecs::query::*;
|
||||
use bevy::ecs::system::*;
|
||||
use bevy::DefaultPlugins;
|
||||
mod vvum;
|
||||
use vvum::mesh_plugin;
|
||||
|
||||
#[derive(Component)]
|
||||
struct Person;
|
||||
#[derive(Component)]
|
||||
struct Name(String);
|
||||
|
||||
fn add_people(mut commands: Commands) {
|
||||
commands.spawn((Person, Name("Elaina Proctor".to_string())));
|
||||
commands.spawn((Person, Name("Renzo Hume".to_string())));
|
||||
commands.spawn((Person, Name("Zayna Nieves".to_string())));
|
||||
}
|
||||
|
||||
pub struct HelloPlugin;
|
||||
|
||||
impl Plugin for HelloPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.insert_resource(GreetTimer(Timer::from_seconds(2.0, TimerMode::Repeating)))
|
||||
.add_systems(Startup, add_people)
|
||||
.add_systems(Update, greet_people);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Resource)]
|
||||
struct GreetTimer(Timer);
|
||||
|
||||
fn greet_people(
|
||||
time: Res<Time>,
|
||||
mut timer: ResMut<GreetTimer>,
|
||||
query: Query<&Name, With<Person>>
|
||||
) {
|
||||
// update our timer with the time elapsed since the last update
|
||||
// if that caused the timer to finish, we say hello to everyone
|
||||
if timer.0.tick(time.delta()).just_finished() {
|
||||
for name in &query {
|
||||
println!("hello {}!", name.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
fn main() {
|
||||
App::new()
|
||||
.add_plugins(
|
||||
(DefaultPlugins, HelloPlugin)
|
||||
)
|
||||
.add_plugins(
|
||||
vvum::mesh_plugin::MeshPlugin
|
||||
)
|
||||
.run();
|
||||
}
|
105
src/vvum.rs
Normal file
105
src/vvum.rs
Normal file
|
@ -0,0 +1,105 @@
|
|||
pub mod mesh_plugin {
|
||||
use bevy::{
|
||||
prelude::*,
|
||||
render::{
|
||||
mesh::{
|
||||
Indices, VertexAttributeValues
|
||||
},
|
||||
render_resource::PrimitiveTopology,
|
||||
},
|
||||
};
|
||||
|
||||
#[derive(Event)]
|
||||
pub struct SendMeshEvent {
|
||||
|
||||
}
|
||||
|
||||
pub struct MeshPlugin;
|
||||
impl Plugin for MeshPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_systems(
|
||||
Startup, setup
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn emit_cube_at(
|
||||
pos: Vec3,
|
||||
mut subject: Vec<[f64; 3]>,
|
||||
render_px: bool,
|
||||
render_nx: bool,
|
||||
render_py: bool,
|
||||
render_ny: bool,
|
||||
render_pz: bool,
|
||||
render_nz: bool,
|
||||
) {
|
||||
|
||||
if render_px {
|
||||
subject.push([0.5, -0.5, -0.5]);
|
||||
subject.push([0.5, -0.5, 0.5]);
|
||||
subject.push([0.5, 0.5, 0.5]);
|
||||
subject.push([0.5, 0.5, -0.5]);
|
||||
}
|
||||
|
||||
if render_nx {
|
||||
subject.push([-0.5, -0.5, -0.5]);
|
||||
subject.push([-0.5, -0.5, 0.5]);
|
||||
subject.push([-0.5, 0.5, 0.5]);
|
||||
subject.push([-0.5, 0.5, -0.5]);
|
||||
}
|
||||
|
||||
if render_py {
|
||||
subject.push([-0.5, 0.5, -0.5]);
|
||||
subject.push([0.5, 0.5, -0.5]);
|
||||
subject.push([0.5, 0.5, 0.5]);
|
||||
subject.push([-0.5, 0.5, 0.5]);
|
||||
}
|
||||
|
||||
if render_ny {
|
||||
subject.push([-0.5, -0.5, -0.5]);
|
||||
subject.push([0.5, -0.5, -0.5]);
|
||||
subject.push([0.5, -0.5, 0.5]);
|
||||
subject.push([-0.5, -0.5, 0.5]);
|
||||
}
|
||||
|
||||
if render_pz {
|
||||
subject.push([-0.5, -0.5, 0.5]);
|
||||
subject.push([-0.5, 0.5, 0.5]);
|
||||
subject.push([0.5, 0.5, 0.5]);
|
||||
subject.push([0.5, -0.5, 0.5]);
|
||||
}
|
||||
|
||||
if render_nz {
|
||||
subject.push([-0.5, -0.5, -0.5]);
|
||||
subject.push([-0.5, 0.5, -0.5]);
|
||||
subject.push([0.5, 0.5, -0.5]);
|
||||
subject.push([0.5, -0.5, -0.5]);
|
||||
}
|
||||
}
|
||||
|
||||
fn listen_send_mesh_event(
|
||||
mut events: EventReader<SendMeshEvent>,
|
||||
mut commands: Commands,
|
||||
mut meshes: ResMut<Assets<Mesh>>,
|
||||
mut asset_server: ResMut<AssetServer>
|
||||
) {
|
||||
/*
|
||||
in the send mesh event will be the handle of what we update if it is already present, and the mesh data in an octtree or other voxel format
|
||||
*/
|
||||
|
||||
let mut verts = Vec::new();
|
||||
|
||||
emit_cube_at(Vec3::ZERO, verts, true, true, true, true, true, true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
fn setup(
|
||||
mut commands: Commands,
|
||||
asset_server: ResMut<AssetServer>,
|
||||
mut material: ResMut<Assets<StandardMaterial>>,
|
||||
mut meshes: ResMut<Assets<Mesh>>,
|
||||
) {
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue