Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement current functionality in an ECS. #41

Closed
6 tasks done
Tracked by #35
kanerogers opened this issue Aug 9, 2021 · 2 comments
Closed
6 tasks done
Tracked by #35

Implement current functionality in an ECS. #41

kanerogers opened this issue Aug 9, 2021 · 2 comments
Assignees

Comments

@kanerogers
Copy link
Collaborator

kanerogers commented Aug 9, 2021

Overview

Great! We picked an ECS, legion. Now comes the fun part - implementing it.

I think the best place to start is Hotham::Program. Ultimately one of the most important things in hotham is making sure that the interface a developer will use to create an app is as simple as possible.

The asteroid could look something like:

struct Asteroid {
  model: Model,
  transform: Transform,
  // new functionality like physics, sound etc. will go here
}

struct Transform {
  position: Vector3<f32>,
  rotation: Quaternion<f32>,
  scale: Vector3<f32>,
}

let mut world = World::new();
let asteroid = Asteroid {
  model: asteroid_model,
  transform: Transform {
    position: vec3(0.0, 1.0, 0.0),
    rotation: Default::default(),
    scale: vec3(1.0, 1.0, 1.0),
  }
}

world.push(asteroid);

That's pretty straightforward. The refinery is the same, except we need to make sure its parent is the asteroid, somehow.

struct Refinery {
  model: Model,
  transform: Transform,
}

struct Transform {
  position: Vector3<f32>,
  rotation: Quaternion<f32>,
  scale: Vector3<f32>,
  parent: Option<Box<Transform>>, // ??
}

This is pretty different from our current Node based structure, which is just lifted from gltf. We'll need to approach the migration of Node to legion based components separately.

What's even trickier is things like Hands, for instance.

struct Hand {
   model: Model,
   transform: Transform,
   animation: Animation,
}

We'd then have something like a HandsSystem that takes the current XR state and updates the Animation and Transform components accordingly.

TODO

@kanerogers kanerogers mentioned this issue Aug 9, 2021
4 tasks
@kanerogers kanerogers self-assigned this Aug 9, 2021
@kanerogers kanerogers added this to the Deploy Phase milestone Aug 9, 2021
@kanerogers
Copy link
Collaborator Author

Well, this is fun. legion only lets us have Components as 'static + Sized + Send + Sync. 😄

In essence, we'll have to break Node apart. Right now it's acting as its own ECS, really, and we don't want that.

@kanerogers
Copy link
Collaborator Author

We'll come back to audio later!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant