Code Monkey home page Code Monkey logo

claymore's People

Contributors

csherratt avatar kvark avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

claymore's Issues

Debug GUI

It would be useful to be able to tweak some stuff or change the game logic during the play in dev mode. Several ways to get this:

  1. Off-screen GUI. rgtk might be helpful.
  2. In-game GUI. Conrod is worth evaluating as long as it doesn't drag too many dependencies in.
  3. Our own bicycle aka Love.

Configurable lights

This issue affects gfx_pipeline, which currently just have a hard-coded light sources. Instead, it should be configurable, and the game should pick one from the imported scenes.

Detect vertex value bounds and pack the attributes adaptively

Currently, we only check for index bounds. Texture coordinates are assumed to be in [0,1] range, and this is not always the case in practice. We could detect the range of not only the coordinates, but also vertex positions, and choose the proper representation:

  • [-1,1] => h
  • [0,1] => H
  • _ =. f

In the future, we could also export an AABB of each attribute, allowing us to encode it in the (un)signed normalized format regardless of the range. This would require shaders to adapt though.

Sample grid code

pub type Coordinate = (int,int,int);
static MaxSize : uint = 20;

struct Point(float,float,float);
impl core::ops::Add<Point,Point> for Point  {
    fn add( &self, rhs: &Point )-> Point    {
        let Point(x1,y1,z1) = *self;
        let Point(x2,y2,z2) = *rhs;
        Point( x1+x2, y1+y2, z1+z2 )
    }
}
impl core::ops::Mul<float,Point> for Point  {
    fn mul( &self, rhs: &float )-> Point    {
        let Point(x,y,z) = *self;
        Point( x**rhs, y**rhs, z**rhs )
    }
}

pub enum Cell<Unit> {
    CellEmpty,
    CellObstacle,
    CellUnit(Unit),
}
impl<Unit:Copy> Copy for Cell<Unit>;

//TODO: use new iterators
trait PureGrid  {
    fn get_neighbours( c : Coordinate )-> ~[Coordinate];
    fn get_center( &self, c : Coordinate )-> Point;
    fn get_coordinate( &self, p : Point )-> Coordinate;
    fn is_out_bounds( &self, c : Coordinate )-> bool;
}

trait Grid<Unit> : PureGrid {
    fn mut_cell( &mut self, c : Coordinate, fun : &fn(&mut Cell<Unit>) )-> bool;
}


struct Grid2D<Unit> {
    corner  : Point,
    side    : float,
    dim     : (uint,uint),
    cells   : [[Cell<Unit>, ..MaxSize], ..MaxSize],
}


//  Quad    //

pub struct GridQuad<Unit>( Grid2D<Unit> );

impl<Unit> PureGrid for GridQuad<Unit>  {
    fn get_neighbours( c : Coordinate )-> ~[Coordinate] {
        let (i,j,k) = c;
        ~[ (i+1,j,k), (i,j+1,k), (i-1,j,k), (i,j-1,k) ]
    }
    fn get_center( &self, c : Coordinate )-> Point  {
        let (i,j,_) = c;
        self.corner + Point(i as float,j as float,0f) * self.side
    }
    fn get_coordinate( &self, p : Point )-> Coordinate  {
        let Point(x,y,_) = (p + self.corner*-1f) * (1f/self.side);
        (x as int, y as int, 0)
    }
    fn is_out_bounds( &self, c : Coordinate )-> bool    {
        let (i,j,_) = c, (dx,dy) = self.dim;
        i<0 || j<0 || i>=dx as int || j>=dy as int
    }
}

impl<Unit> Grid<Unit> for GridQuad<Unit>    {
    fn mut_cell( &mut self, c : Coordinate, fun : &fn(&mut Cell<Unit>) )-> bool {
        if self.is_out_bounds( c )  {
            false
        }else   {
            let (i,j,_) = c;
            fun( &mut self.cells[i][j] );
            true
        }
    }
}


//  Triangle    //
pub struct GridTriangle<Unit>( Grid2D<Unit> );

impl<Unit> PureGrid for GridTriangle<Unit>  {
    fn get_neighbours( c : Coordinate )-> ~[Coordinate] {
        let (i,j,k) = c;
        match j&3   {
            0   => ~[ (i,j+1,k), (i-1,j+1,k), (i,j-1,k) ],
            1   => ~[ (i+1,j-1,k), (i,j+1,k), (i,j-1,k) ],
            2   => ~[ (i+1,j+1,k), (i,j+1,k), (i,j-1,k) ],
            3   => ~[ (i,j-1,k), (i,j+1,k), (i-1,j-1,k) ],
            _   => fail!(~"")
        }
    }
    fn get_center( &self, c : Coordinate )-> Point  {
        let (i,j,_) = c;
        let ho3 = self.side * float::sqrt(3f) / 6f;
        let x = (i as float)*self.side +
            if (j+1)&2==0   {0f} else {0.5f*self.side};
        let y = (((j+1)/2) as float)*ho3*3f +
            if j&1==0   {ho3} else {-ho3};
        self.corner + Point(x,y,0f)
    }
    fn get_coordinate( &self, p : Point )-> Coordinate  {
        let Point(x,y,_) = p;
        let h = self.side * float::sqrt(3f) / 2f;
        let jt = (y/h) as int;
        let y0 = (jt as float) * h;
        let xt = x - (y-y0) * self.side / h;
        let i = (xt/self.side) as int;
        let x0 = (i as float) * self.side;
        let j = 2*jt + (if x-x0+y-y0 > self.side {1} else {0});
        (i,j,0)
    }
    fn is_out_bounds( &self, c : Coordinate )-> bool    {
        let (i,j,_) = c, (dx,dy) = self.dim;
        i<0 || j<0 || i>=dx as int || j>=dy as int
    }
}

impl<Unit> Grid<Unit> for GridTriangle<Unit>    {
    fn mut_cell( &mut self, c : Coordinate, fun : &fn(&mut Cell<Unit>) )-> bool {
        if self.is_out_bounds( c )  {
            false
        }else   {
            let (i,j,_) = c;
            fun( &mut self.cells[i][j] );
            true
        }
    }
}

// ----- //

pub fn create_grid<Unit:Copy+Owned>( topology : uint, dim : (uint,uint), side : float )-> ~Grid<Unit>   {
    let base : Grid2D<Unit> = Grid2D{
        corner  : Point(0f,0f,0f),
        side    : side,
        dim     : dim,
        cells   : [[CellEmpty, ..MaxSize], ..MaxSize],
    };
    match topology  {
        3   => ~GridTriangle( base ) as ~Grid<Unit>,
        4   => ~GridQuad    ( base ) as ~Grid<Unit>,
        _   => fail!(fmt!( "Unsupported topology %u", topology ))
    }
}

fn main()   {
    //empty
}

Job system

Everything should be a job like explained by Naughty Dog.

The frames are supposed to be fired up by the main thread in a continuous fashion, with multiple frames in flight at every moment. Culling, animation, and command buffer construction are all jobs.

We have multiple choices for the implementation:

  • Servo
  • Cargo?
  • Our own bicycle

Model data format

Current format is custom, which doesn't benefit the community much.
We need something straightforward usable for dynamic animated meshes, something with good exporters and standardized.

Consider:

PBR materials

struct Texture;
type Color = [f32; 3];
type Vector = [f32; 3];
type Scalar = f32;
enum MaybeTexture<T> {
    Texture(Texture),
    Value(T),
}

struct Phong {
    diffuse: MaybeTexture<Color>,
    specular: MaybeTexture<Color>,
    normal: MaybeTexture<Vector>,
    glossiness: Scalar,
}

struct Metal {
    albedo: Color,
    reflection: Texture,
    glossiness: MaybeTexture<Scalar>,
    normal: Texture,
}

struct Dielectric {
    albedo: Texture,
    reflectivity: Scalar,
    transparency: Scalar,
    normal: Texture,
}

Figure out non-uniform scale

For our own scenes, I don't think it's needed at all. But if we need to load external resources, there is a lot of non-uniform scale to deal with.

Library basis

Claymore is a playground for experimental code that is meant to be moved out into several independent libraries. In this issue we can overview the current dependencies and possible candidates for extraction:

  1. (DONE) gfx-rs: graphics abstraction
  2. (DONE) gfx_scene: high-level graphics (scenes, techniques, entities)
  3. (TODO) shader abstraction
  4. (TODO) shader composition
  5. (WIP) gfx_pipeline: standard materials and rendering techniques
  6. (DONE) standard scene loader

Use gfx_pipeline for rendering

Standard materials and shading models should be provided by gfx_pipeline. Claymore should re-use these and perhaps make its own material + technique as an algebraic type sum of the standard models, selected by the shader field of the resource.

Scene viewer example

It would be nice to have an example, which can load arbitrary scene passed in the command line. It could use gfx-debug-draw to visualize nodes.

Game panics when running on OSX

OSX 10.9.2

rustc 1.0.0-nightly (c89de2c56 2015-03-28) (built 2015-03-28)

Initializing the window...
Loading the game...
thread '<main>' panicked at 'called `Result::unwrap()` on an `Err` value: Open(Error { repr: Os(2) })', /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/libcore/result.rs:774
stack backtrace:
   1:        0x10a6d4814 - sys::backtrace::write::he2f5110aad12ae2eoED
   2:        0x10a6d8321 - panicking::on_panic::h98c3c86044131222muJ
   3:        0x10a6c719e - rt::unwind::begin_unwind_inner::h0cd608b3106088c0wcJ
   4:        0x10a6c7666 - rt::unwind::begin_unwind_fmt::h1d0870f077435e7d7aJ
   5:        0x10a6d7c6d - rust_begin_unwind
   6:        0x10a6f7da5 - panicking::panic_fmt::h03d863a7262ceb689qB
   7:        0x10a420be7 - result::Result<T, E>::unwrap::h4287497292149597482
   8:        0x10a416d71 - App<D>::new::h11876743990875996152
   9:        0x10a3f7303 - main::h00b79055961ca762jaa
  10:        0x10a6d9728 - rust_try_inner
  11:        0x10a6d9715 - rust_try
  12:        0x10a6d8e6e - rt::lang_start::h5cc2c8c30c0240caPoJ
  13:        0x10a3f76ae - main
Process didn't exit successfully: `target/debug/claymore` (exit code: 101)

Merge materials on import

This doesn't work well when the user side needs to modify specific materials. At the same time, nothing stops the user from COWing them.

The benefit is arguable though, since gfx_phase will unlikely differentiate between same-content materials, and surely generate the same shader programs for them.

Merge mesh data on export

We could have a Map<VertexFormat, Buffer> in the export, and just append everything to this map with computing the proper slice. This would require changing the mesh reference format and a bit of the import procedures. The benefit would be having less state switches and potentially optimized shadow rendering.

Error when trying to build viewer example

rustc 1.0.0-nightly (d754722a0 2015-03-31) (built 2015-03-31)

$ cargo run --example viewer
    Updating git repository `https://github.com/bjz/cgmath-rs`
    Updating git repository `https://github.com/kvark/gfx_pipeline`
    Updating git repository `https://github.com/PistonDevelopers/gfx-debug-draw`
no matching package named `cgmath` found (required by `claymore-scene`)
location searched: https://github.com/bjz/cgmath-rs#c8db595e
version required: = 0.1.1
versions found: 0.1.2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.