initial commit
This commit is contained in:
commit
8caddafdaa
20 changed files with 6288 additions and 0 deletions
14
orthros-server/Cargo.toml
Normal file
14
orthros-server/Cargo.toml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
[package]
|
||||
name = "orthros-server"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
bevy = "0.17"
|
||||
rand = "0.9.1"
|
||||
# rusqlite = "0.37.0"
|
||||
statrs = "0.18.0"
|
||||
orthros_network = {path = "../orthros-network"}
|
||||
|
||||
[[bin]]
|
||||
name = "orthros-server"
|
||||
BIN
orthros-server/assets/fonts/quantum/quantfh.ttf
Normal file
BIN
orthros-server/assets/fonts/quantum/quantfh.ttf
Normal file
Binary file not shown.
BIN
orthros-server/assets/fonts/quantum/quantflt.ttf
Normal file
BIN
orthros-server/assets/fonts/quantum/quantflt.ttf
Normal file
Binary file not shown.
BIN
orthros-server/assets/fonts/quantum/quantrh.ttf
Normal file
BIN
orthros-server/assets/fonts/quantum/quantrh.ttf
Normal file
Binary file not shown.
BIN
orthros-server/assets/fonts/quantum/quantrnd.ttf
Normal file
BIN
orthros-server/assets/fonts/quantum/quantrnd.ttf
Normal file
Binary file not shown.
BIN
orthros-server/assets/fonts/quantum/quanttap.ttf
Normal file
BIN
orthros-server/assets/fonts/quantum/quanttap.ttf
Normal file
Binary file not shown.
74
orthros-server/assets/fonts/quantum/quantum.txt
Normal file
74
orthros-server/assets/fonts/quantum/quantum.txt
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
______________________________
|
||||
Quantum Created by Brian Kent
|
||||
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
|
||||
Thanks for Downloading Quantum.
|
||||
|
||||
-Quantum Round
|
||||
-Quantum Round Hollow
|
||||
-Quantum Flat
|
||||
-Quantum Flat Hollow
|
||||
-Quantum Taper
|
||||
|
||||
If you have any questions or comments, you can e-mail me at
|
||||
aefonts[AT]frontiernet[DOT]net
|
||||
|
||||
You can visit my Homepage <ÆNIGMA GAMES & FONTS> at
|
||||
http://www.aenigmafonts.com/
|
||||
|
||||
____________
|
||||
!!! NOTE !!!
|
||||
¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
This font has been updated! I've edited the (BRK) in the font name
|
||||
to just BRK. It seems that Adobe Illustrator and web pages with CSS
|
||||
don't like fonts with ( and ) in their name.
|
||||
|
||||
________________
|
||||
INSTALLING FONTS
|
||||
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
There's a couple of ways to install Fonts. The 'easy' way to
|
||||
install fonts is to just Unzip/place the font file [.ttf] into your
|
||||
Windows\Fonts directory (I always use this method). If you're unable
|
||||
to do it the 'easy' way, then try to do it this way (for Windows
|
||||
95/98/NT):
|
||||
|
||||
1] Unzip the Font(s) to a folder (or somewhere, just remember where
|
||||
you unzipped it) on your Computer.
|
||||
|
||||
2] Next, click on the START button, then select SETTINGS then
|
||||
CONTROL PANEL.
|
||||
|
||||
3] When the Control Panel Window pops up, Double Click on FONTS.
|
||||
|
||||
4] When the FONTS window pops up, select File then Install New Font...
|
||||
|
||||
5] A Add Fonts window will pop up, just go to the folder that you
|
||||
unzipped the Font(s) to, select the Font(s) and then click on OK.
|
||||
Now the Font(s) are installed.
|
||||
|
||||
Now you can use the Font(s) in programs the utilize Fonts. Make
|
||||
sure that you install the font(s) first, then open up your apps
|
||||
(so the app will recognize the font). Sometimes you'll have to
|
||||
wait until you computer 'auto-refreshes' for programs to recognize
|
||||
fonts (Windows is sometimes slow to do that). You can refresh your
|
||||
computer quicker by going into Windows Explorer -or- My Computer and
|
||||
press F5 (or in the menubar select VIEW then REFRESH).
|
||||
|
||||
|
||||
__________
|
||||
DISCLAIMER
|
||||
¯¯¯¯¯¯¯¯¯¯
|
||||
-The font(s) in this zip file were created by me (Brian Kent). All
|
||||
of my Fonts are Freeware, you can use them any way you want to
|
||||
(Personal use, Commercial use, or whatever).
|
||||
|
||||
-If you have a Font related site and would like to offer my fonts on
|
||||
your site, go right ahead. All I ask is that you keep this text file
|
||||
intact with the Font.
|
||||
|
||||
-You may not Sell or Distribute my Fonts for profit or alter the font
|
||||
file(s) [.ttf .fon] in any way without asking me first. I can be
|
||||
reached at:
|
||||
aefonts[AT]frontiernet[DOT]net
|
||||
|
||||
(make sure you replace the [AT] and [DOT] with the proper characters) .
|
||||
12
orthros-server/assets/shaders/g-type-star.wgsl
Normal file
12
orthros-server/assets/shaders/g-type-star.wgsl
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#import bevy_pbr::forward_io::VertexOutput
|
||||
|
||||
struct WireframeMaterial {
|
||||
color: vec4<f32>,
|
||||
};
|
||||
|
||||
@group(2) @binding(0)
|
||||
var<uniform> material: WireframeMaterial;
|
||||
@fragment
|
||||
fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
|
||||
return material.color;
|
||||
}
|
||||
300
orthros-server/src/main.rs
Normal file
300
orthros-server/src/main.rs
Normal file
|
|
@ -0,0 +1,300 @@
|
|||
pub mod temporal_management;
|
||||
use bevy::{
|
||||
asset::RenderAssetUsages,
|
||||
camera::RenderTarget,
|
||||
color::palettes::css::*,
|
||||
core_pipeline::tonemapping::Tonemapping,
|
||||
math::ops,
|
||||
pbr::wireframe::{Wireframe, WireframeMaterial, WireframePlugin},
|
||||
post_process::bloom::{Bloom, BloomCompositeMode},
|
||||
prelude::*,
|
||||
render::{render_resource::*, view::Hdr},
|
||||
};
|
||||
use orthros_network::starchart::star::{STARS, StarClass, StarInfo, star_diameter_range};
|
||||
use rand::{
|
||||
Rng,
|
||||
distr::{Distribution, Uniform},
|
||||
rng,
|
||||
};
|
||||
use std::{
|
||||
collections::hash_map::DefaultHasher,
|
||||
f32::consts::PI,
|
||||
hash::{Hash, Hasher},
|
||||
};
|
||||
// use temporal_management::database::{ObjectState, TemporalVector};
|
||||
// const SHADER_ASSET_PATH: &str = "shaders/g-type-star.wgsl";
|
||||
|
||||
// #[derive(Asset, TypePath, AsBindGroup, Debug, Clone)]
|
||||
// struct WireframeMaterial {}
|
||||
|
||||
// impl Material for WireframeMaterial {
|
||||
// fn fragment_shader() -> ShaderRef {
|
||||
// SHADER_ASSET_PATH.into()
|
||||
// }
|
||||
// }
|
||||
|
||||
#[derive(Component)]
|
||||
struct StarInfoComp(StarInfo);
|
||||
fn main() {
|
||||
App::new()
|
||||
.add_plugins((DefaultPlugins, WireframePlugin::default()))
|
||||
.add_systems(Startup, setup_scene)
|
||||
// .add_systems(Update, (update_bloom_settings))
|
||||
.run();
|
||||
}
|
||||
fn create_star_system_annotation(
|
||||
commands: &mut Commands,
|
||||
asset_server: &Res<AssetServer>,
|
||||
images: &mut ResMut<Assets<Image>>,
|
||||
meshes: &mut ResMut<Assets<Mesh>>,
|
||||
materials: &mut ResMut<Assets<StandardMaterial>>,
|
||||
star_info: &StarInfo,
|
||||
) -> (Handle<Mesh>, Handle<StandardMaterial>) {
|
||||
let size = Extent3d {
|
||||
width: 1024,
|
||||
height: 1024,
|
||||
..default()
|
||||
};
|
||||
|
||||
// This is the texture that will be rendered to.
|
||||
let mut image = Image::new_fill(
|
||||
size,
|
||||
TextureDimension::D2,
|
||||
&[0, 0, 0, 0],
|
||||
TextureFormat::Bgra8UnormSrgb,
|
||||
RenderAssetUsages::default(),
|
||||
);
|
||||
// You need to set these texture usage flags in order to use the image as a render target
|
||||
image.texture_descriptor.usage =
|
||||
TextureUsages::TEXTURE_BINDING | TextureUsages::COPY_DST | TextureUsages::RENDER_ATTACHMENT;
|
||||
|
||||
let image_handle = images.add(image);
|
||||
|
||||
// Light
|
||||
|
||||
let texture_camera = commands
|
||||
.spawn((
|
||||
Camera2d,
|
||||
Camera {
|
||||
target: RenderTarget::Image(image_handle.clone().into()),
|
||||
clear_color: ClearColorConfig::None,
|
||||
..default()
|
||||
},
|
||||
))
|
||||
.id();
|
||||
let border = UiRect::all(Val::Px(40.));
|
||||
let non_zero = |x, y| x != Val::Px(0.) && y != Val::Px(0.);
|
||||
let border_size = |x, y| if non_zero(x, y) { f32::MAX } else { 0. };
|
||||
commands
|
||||
.spawn((
|
||||
Node {
|
||||
// Cover the whole image
|
||||
width: Val::Percent(100.),
|
||||
height: Val::Percent(100.),
|
||||
flex_direction: FlexDirection::Column,
|
||||
justify_content: JustifyContent::Center,
|
||||
align_items: AlignItems::Center,
|
||||
..default()
|
||||
},
|
||||
BackgroundColor(Color::Srgba(Srgba {
|
||||
red: 0.0,
|
||||
green: 0.0,
|
||||
blue: 0.0,
|
||||
alpha: 0.0,
|
||||
})),
|
||||
Text::new(format!("{}", star_info.name)),
|
||||
TextFont {
|
||||
font: asset_server.load("fonts/quantum/quantflt.ttf"),
|
||||
// This font is loaded and will be used instead of the default font.
|
||||
font_size: 60.0,
|
||||
..default()
|
||||
},
|
||||
TextShadow::default(),
|
||||
// Set the justification of the Text
|
||||
TextLayout::new_with_justify(Justify::Center),
|
||||
UiTargetCamera(texture_camera),
|
||||
))
|
||||
.with_children(|parent| {
|
||||
// parent.spawn((
|
||||
// // Accepts a `String` or any type that converts into a `String`, such as `&str`
|
||||
// Text::new("hello\nbevy!"),
|
||||
// TextFont {
|
||||
// // This font is loaded and will be used instead of the default font.
|
||||
// font_size: 60.0,
|
||||
// ..default()
|
||||
// },
|
||||
// TextShadow::default(),
|
||||
// // Set the justification of the Text
|
||||
// TextLayout::new_with_justify(JustifyText::Center),
|
||||
// // Set the style of the Node itself.
|
||||
// Node {
|
||||
// // position_type: PositionType::Relative,
|
||||
// align_self: AlignSelf::FlexStart,
|
||||
|
||||
// // top: Val::Px(5.0),
|
||||
// // right: Val::Px(5.0),
|
||||
// ..default()
|
||||
// },
|
||||
// ));
|
||||
parent.spawn((
|
||||
Node {
|
||||
width: Val::Px(400.),
|
||||
height: Val::Px(400.),
|
||||
border,
|
||||
margin: UiRect::AUTO,
|
||||
align_self: AlignSelf::Center,
|
||||
// align_items: AlignItems::Center,
|
||||
// justify_content: JustifyContent::Center,
|
||||
// align_content: AlignContent::Center,
|
||||
..default()
|
||||
},
|
||||
BackgroundColor(Color::Srgba(Srgba {
|
||||
red: 0.0,
|
||||
green: 0.0,
|
||||
blue: 0.0,
|
||||
alpha: 0.0,
|
||||
})),
|
||||
BorderColor::all(RED),
|
||||
BorderRadius::px(
|
||||
border_size(border.left, border.top),
|
||||
border_size(border.right, border.top),
|
||||
border_size(border.right, border.bottom),
|
||||
border_size(border.left, border.bottom),
|
||||
),
|
||||
// Outline {
|
||||
// width: Val::Px(6.),
|
||||
// offset: Val::Px(6.),
|
||||
// color: Color::WHITE,
|
||||
// },
|
||||
));
|
||||
});
|
||||
let material_handle = materials.add(StandardMaterial {
|
||||
// base_color: Color::srgba(1.0, 1.0, 1.0, 0.0),
|
||||
base_color_texture: Some(image_handle),
|
||||
unlit: true,
|
||||
alpha_mode: AlphaMode::Blend,
|
||||
|
||||
..default()
|
||||
});
|
||||
let aspect = 1.0;
|
||||
|
||||
// create a new quad mesh. this is what we will apply the texture to
|
||||
let quad_width = 10.0;
|
||||
let quad_handle = meshes.add(Rectangle::new(quad_width, quad_width * aspect));
|
||||
return (quad_handle, material_handle);
|
||||
}
|
||||
fn setup_scene(
|
||||
mut commands: Commands,
|
||||
mut asset_server: Res<AssetServer>,
|
||||
mut meshes: ResMut<Assets<Mesh>>,
|
||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||
mut custom_materials: ResMut<Assets<WireframeMaterial>>,
|
||||
mut images: ResMut<Assets<Image>>,
|
||||
mut time: ResMut<Time<Virtual>>,
|
||||
) {
|
||||
commands.spawn((
|
||||
Camera3d::default(),
|
||||
Camera {
|
||||
clear_color: ClearColorConfig::Custom(Color::from(BLACK)),
|
||||
..default()
|
||||
},
|
||||
Hdr,
|
||||
Tonemapping::TonyMcMapface, // 2. Using a tonemapper that desaturates to white is recommended
|
||||
Transform::from_xyz(0.0, 100.0, 0.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
Bloom::OLD_SCHOOL, // 3. Enable bloom for the camera
|
||||
));
|
||||
|
||||
let material_emissive1 = materials.add(StandardMaterial {
|
||||
base_color: Color::srgba(0.0, 0.0, 1.0, 1.0),
|
||||
emissive: LinearRgba::rgb(0.0, 0.0, 2000.0), // 4. Put something bright in a dark environment to see the effect
|
||||
..default()
|
||||
});
|
||||
let material_emissive2 = materials.add(StandardMaterial {
|
||||
emissive: LinearRgba::rgb(1000.0, 1000.0, 1000.0),
|
||||
..default()
|
||||
});
|
||||
let material_emissive3 = materials.add(StandardMaterial {
|
||||
base_color: Color::srgba(1.0, 0.0, 0.0, 1.0),
|
||||
emissive: LinearRgba::rgb(2000.0, 0.0, 0.0),
|
||||
..default()
|
||||
});
|
||||
let material_non_emissive = materials.add(StandardMaterial {
|
||||
base_color: Color::BLACK,
|
||||
emissive: LinearRgba::rgb(500.0, 0.0, 2000.0),
|
||||
..default()
|
||||
});
|
||||
|
||||
let mesh = meshes.add(Sphere::new(0.4).mesh().ico(5).unwrap());
|
||||
for _ in 0..4 {
|
||||
let x = Uniform::try_from(-2000..2000).unwrap().sample(&mut rng());
|
||||
let z = Uniform::try_from(-8000..8000).unwrap().sample(&mut rng());
|
||||
let mut rand = rng().random::<i32>() % 6;
|
||||
if rand < 0 {
|
||||
rand *= -1;
|
||||
}
|
||||
// println!("{rand}");
|
||||
|
||||
let (material, scale) = match rand {
|
||||
0 => (material_emissive1.clone(), 1.5),
|
||||
1 => (material_emissive2.clone(), 1.8),
|
||||
2 => (material_emissive3.clone(), 3.0),
|
||||
3..=5 => (material_non_emissive.clone(), 1.5),
|
||||
_ => unreachable!(),
|
||||
};
|
||||
let star_class: StarClass = match rng().random_range(0..2) {
|
||||
0 => StarClass::MType,
|
||||
1 => StarClass::BType,
|
||||
2 => StarClass::GType,
|
||||
_ => todo!(),
|
||||
};
|
||||
info!("{:?}", star_diameter_range(&star_class));
|
||||
let star_info = StarInfo {
|
||||
name: STARS[(rng().random_range(0..100)) as usize].to_string(),
|
||||
diameter: rng().random_range(star_diameter_range(&star_class)),
|
||||
class: star_class,
|
||||
};
|
||||
let (quad_handle, material_handle) = create_star_system_annotation(
|
||||
&mut commands,
|
||||
&asset_server,
|
||||
&mut images,
|
||||
&mut meshes,
|
||||
&mut materials,
|
||||
&star_info,
|
||||
);
|
||||
|
||||
commands
|
||||
.spawn((
|
||||
Mesh3d(mesh.clone()),
|
||||
MeshMaterial3d(material.clone()),
|
||||
Transform::from_xyz(x as f32 / 100.0, z as f32 / 20000.0, z as f32 / 100.0)
|
||||
.with_scale(Vec3::splat(scale)),
|
||||
StarInfoComp(star_info),
|
||||
Wireframe,
|
||||
// TemporalVector(vec![ObjectState {
|
||||
// object_id: rng().random::<u32>(),
|
||||
// time: time.elapsed_secs(),
|
||||
// }]),
|
||||
))
|
||||
.with_children(|parent| {
|
||||
parent.spawn((
|
||||
Mesh3d(quad_handle),
|
||||
MeshMaterial3d(material_handle.clone()),
|
||||
Transform::from_xyz(0.0, 0.0, 0.0)
|
||||
// .with_scale(Vec3::splat(scale))
|
||||
.with_rotation(Quat::from_euler(EulerRot::XYZ, -PI / 2.0, 0.0, PI / 2.0)),
|
||||
// Wireframe,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
// example instructions
|
||||
commands.spawn((
|
||||
Text::default(),
|
||||
Node {
|
||||
position_type: PositionType::Absolute,
|
||||
bottom: Val::Px(12.0),
|
||||
left: Val::Px(12.0),
|
||||
..default()
|
||||
},
|
||||
));
|
||||
}
|
||||
1
orthros-server/src/temporal_management.rs
Normal file
1
orthros-server/src/temporal_management.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
// pub mod database;
|
||||
Loading…
Add table
Add a link
Reference in a new issue