kvark / claymore Goto Github PK
View Code? Open in Web Editor NEWJust another tactical RPG in dark fantasy setting
License: Apache License 2.0
Just another tactical RPG in dark fantasy setting
License: Apache License 2.0
Related to #18
Featuring no additional vertices or faces, it's got to make our exporter code smaller.
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.
https://github.com/PistonDevelopers/dev_menu
In Forest example, we could switch sorting and culling on/off for fun.
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.
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
}
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:
https://github.com/PistonDevelopers/gfx-debug-draw
Can be used to draw bones, spatial nodes, lights, and other stuff.
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,
}
Could use the old claymore code as a basis.
Also related to #16
https://github.com/PistonDevelopers/skeletal_animation
It's a nice library with data-driver animations, blend trees, and collada import support. It should be possible to hook it up for an alternative World
implementation.
Cargo changes the current dir, but @cmr proposed to use CARGO_MANIFEST_DIR
. Sounds like a plan!
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.
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:
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.
Helpful link: http://www.cs.unc.edu/~dm/CODE/GEM/chapter.html
At least for bind poses, assuming the animation doesn't go too wild.
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.
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)
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.
Basically, we need to ensure these properties:
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.
https://github.com/PistonDevelopers/window
It's a new window abstraction that is compatible with gfx::Canvas
. Transitioning to it would unlock the path to dev_menu in #27
cc @bvssvni
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.