mirror of
https://github.com/scurest/apicula.git
synced 2025-06-19 15:15:41 -04:00
Migrate to Rust 2021 edition
This commit is contained in:
parent
75cb088d31
commit
11ca50c0dc
@ -3,6 +3,7 @@ name = "apicula"
|
|||||||
version = "0.1.1-dev"
|
version = "0.1.1-dev"
|
||||||
authors = ["scurest <scurest@users.noreply.github.com>"]
|
authors = ["scurest <scurest@users.noreply.github.com>"]
|
||||||
license = "0BSD"
|
license = "0BSD"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
atty = "0.2"
|
atty = "0.2"
|
||||||
|
@ -6,9 +6,9 @@
|
|||||||
//! call supply the right files to the right calls. That leaves us to figure it
|
//! call supply the right files to the right calls. That leaves us to figure it
|
||||||
//! out for ourselves. This modules contains the heuristics for that.
|
//! out for ourselves. This modules contains the heuristics for that.
|
||||||
|
|
||||||
use cli::Args;
|
use crate::cli::Args;
|
||||||
use db::{Database, AnimationId, TextureId, PaletteId, ModelId, PatternId, MatAnimId};
|
use crate::db::{Database, AnimationId, TextureId, PaletteId, ModelId, PatternId, MatAnimId};
|
||||||
use errors::Result;
|
use crate::errors::Result;
|
||||||
|
|
||||||
/// A Connection records interrelationships between Nitro resources, namely how
|
/// A Connection records interrelationships between Nitro resources, namely how
|
||||||
/// all the other resources relate to the models.
|
/// all the other resources relate to the models.
|
||||||
|
@ -3,16 +3,16 @@ mod xml;
|
|||||||
mod make_invertible;
|
mod make_invertible;
|
||||||
|
|
||||||
use cgmath::{Matrix4, One};
|
use cgmath::{Matrix4, One};
|
||||||
use convert::image_namer::ImageNamer;
|
use crate::convert::image_namer::ImageNamer;
|
||||||
use db::{Database, ModelId};
|
use crate::db::{Database, ModelId};
|
||||||
use skeleton::{Skeleton, Transform, SMatrix};
|
use crate::skeleton::{Skeleton, Transform, SMatrix};
|
||||||
use primitives::{self, Primitives, DynamicState};
|
use crate::primitives::{self, Primitives, DynamicState};
|
||||||
use nitro::Model;
|
use crate::nitro::Model;
|
||||||
use time;
|
use time;
|
||||||
use util::BiVec;
|
use crate::util::BiVec;
|
||||||
use connection::Connection;
|
use crate::connection::Connection;
|
||||||
use self::xml::Xml;
|
use self::xml::Xml;
|
||||||
use util::tree::NodeIdx;
|
use crate::util::tree::NodeIdx;
|
||||||
|
|
||||||
static FRAME_LENGTH: f64 = 1.0 / 60.0; // 60 fps
|
static FRAME_LENGTH: f64 = 1.0 / 60.0; // 60 fps
|
||||||
|
|
||||||
@ -173,7 +173,7 @@ fn library_effects(xml: &mut Xml, ctx: &Ctx) {
|
|||||||
let params = ctx.db.textures[texture_id].params;
|
let params = ctx.db.textures[texture_id].params;
|
||||||
let alpha_type = params.format().alpha_type(params);
|
let alpha_type = params.format().alpha_type(params);
|
||||||
|
|
||||||
use nds::Alpha;
|
use crate::nds::Alpha;
|
||||||
match alpha_type {
|
match alpha_type {
|
||||||
Alpha::Opaque => false,
|
Alpha::Opaque => false,
|
||||||
Alpha::Transparent | Alpha::Translucent => true,
|
Alpha::Transparent | Alpha::Translucent => true,
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
/// three component curve onto their common domain and join them together. And
|
/// three component curve onto their common domain and join them together. And
|
||||||
/// we need to convert the curve of rotation matrices to a curve of quaternions.
|
/// we need to convert the curve of rotation matrices to a curve of quaternions.
|
||||||
|
|
||||||
use nitro::animation::{TRSCurves, Curve};
|
use crate::nitro::animation::{TRSCurves, Curve};
|
||||||
use cgmath::{Vector3, Matrix3, Quaternion, InnerSpace, vec3};
|
use cgmath::{Vector3, Matrix3, Quaternion, InnerSpace, vec3};
|
||||||
|
|
||||||
/// Represents the domain of a Curve.
|
/// Represents the domain of a Curve.
|
||||||
|
@ -3,22 +3,22 @@ mod object_trs;
|
|||||||
mod curve;
|
mod curve;
|
||||||
mod primitive;
|
mod primitive;
|
||||||
|
|
||||||
use nitro::Model;
|
use crate::nitro::Model;
|
||||||
use db::{Database, ModelId};
|
use crate::db::{Database, ModelId};
|
||||||
use connection::Connection;
|
use crate::connection::Connection;
|
||||||
use primitives::{Primitives, PolyType, DynamicState};
|
use crate::primitives::{Primitives, PolyType, DynamicState};
|
||||||
use skeleton::{Skeleton, Transform, SMatrix};
|
use crate::skeleton::{Skeleton, Transform, SMatrix};
|
||||||
use super::image_namer::ImageNamer;
|
use super::image_namer::ImageNamer;
|
||||||
use cgmath::Matrix4;
|
use cgmath::Matrix4;
|
||||||
use json::JsonValue;
|
use json::JsonValue;
|
||||||
use self::gltf::{GlTF, Buffer, ByteVec, VecExt};
|
use self::gltf::{GlTF, Buffer, ByteVec, VecExt};
|
||||||
use self::object_trs::ObjectTRSes;
|
use self::object_trs::ObjectTRSes;
|
||||||
use util::{BiVec, BiMap};
|
use crate::util::{BiVec, BiMap};
|
||||||
use self::curve::{GlTFObjectCurves, CurveDomain};
|
use self::curve::{GlTFObjectCurves, CurveDomain};
|
||||||
use nitro::animation::Curve;
|
use crate::nitro::animation::Curve;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use self::primitive::encode_ngons;
|
use self::primitive::encode_ngons;
|
||||||
use nds::Alpha;
|
use crate::nds::Alpha;
|
||||||
|
|
||||||
static FRAME_LENGTH: f32 = 1.0 / 60.0; // 60 fps
|
static FRAME_LENGTH: f32 = 1.0 / 60.0; // 60 fps
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use nitro::Model;
|
use crate::nitro::Model;
|
||||||
use cgmath::{Vector3, Quaternion, InnerSpace, One, vec3, Matrix4};
|
use cgmath::{Vector3, Quaternion, InnerSpace, One, vec3, Matrix4};
|
||||||
|
|
||||||
pub struct TRS {
|
pub struct TRS {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use primitives::{Primitives, PolyType};
|
use crate::primitives::{Primitives, PolyType};
|
||||||
|
|
||||||
/// Triangulates the quads in a Primitive in the correct way for
|
/// Triangulates the quads in a Primitive in the correct way for
|
||||||
/// FB_ngon_encoding to reconstruct them.
|
/// FB_ngon_encoding to reconstruct them.
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
//! Discovers images in a Connection and assigns them names. We use these for
|
//! Discovers images in a Connection and assigns them names. We use these for
|
||||||
//! image filenames so that models know what the path to a specific image it
|
//! image filenames so that models know what the path to a specific image it
|
||||||
//! uses will be.
|
//! uses will be.
|
||||||
use db::{Database, TextureId, PaletteId};
|
use crate::db::{Database, TextureId, PaletteId};
|
||||||
use nitro::Name;
|
use crate::nitro::Name;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use util::namers::UniqueNamer;
|
use crate::util::namers::UniqueNamer;
|
||||||
use connection::Connection;
|
use crate::connection::Connection;
|
||||||
|
|
||||||
type ImageId = (TextureId, Option<PaletteId>);
|
type ImageId = (TextureId, Option<PaletteId>);
|
||||||
|
|
||||||
|
@ -2,16 +2,16 @@ mod collada;
|
|||||||
mod image_namer;
|
mod image_namer;
|
||||||
mod gltf;
|
mod gltf;
|
||||||
|
|
||||||
use cli::Args;
|
use crate::cli::Args;
|
||||||
use errors::Result;
|
use crate::errors::Result;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use util::namers::UniqueNamer;
|
use crate::util::namers::UniqueNamer;
|
||||||
use util::OutDir;
|
use crate::util::OutDir;
|
||||||
use db::Database;
|
use crate::db::Database;
|
||||||
use convert::image_namer::ImageNamer;
|
use crate::convert::image_namer::ImageNamer;
|
||||||
use connection::{Connection, ConnectionOptions};
|
use crate::connection::{Connection, ConnectionOptions};
|
||||||
|
|
||||||
pub fn main(args: &Args) -> Result<()> {
|
pub fn main(args: &Args) -> Result<()> {
|
||||||
let out_dir_path = PathBuf::from(args.get_opt("output").unwrap());
|
let out_dir_path = PathBuf::from(args.get_opt("output").unwrap());
|
||||||
@ -71,7 +71,7 @@ pub fn main(args: &Args) -> Result<()> {
|
|||||||
let texture = &db.textures[texture_id];
|
let texture = &db.textures[texture_id];
|
||||||
let palette = palette_id.map(|id| &db.palettes[id]);
|
let palette = palette_id.map(|id| &db.palettes[id]);
|
||||||
|
|
||||||
use nds::decode_texture;
|
use crate::nds::decode_texture;
|
||||||
let rgba = match decode_texture(texture, palette) {
|
let rgba = match decode_texture(texture, palette) {
|
||||||
Ok(rgba) => rgba,
|
Ok(rgba) => rgba,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
10
src/db.rs
10
src/db.rs
@ -1,13 +1,13 @@
|
|||||||
use cli::Args;
|
use crate::cli::Args;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use nitro::{
|
use crate::nitro::{
|
||||||
Name, Model, Texture, Palette, Animation, Pattern,
|
Name, Model, Texture, Palette, Animation, Pattern,
|
||||||
MaterialAnimation, Container
|
MaterialAnimation, Container
|
||||||
};
|
};
|
||||||
use errors::Result;
|
use crate::errors::Result;
|
||||||
use util::cur::Cur;
|
use crate::util::cur::Cur;
|
||||||
|
|
||||||
pub type FileId = usize;
|
pub type FileId = usize;
|
||||||
pub type ModelId = usize;
|
pub type ModelId = usize;
|
||||||
@ -93,7 +93,7 @@ impl Database {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
use nitro::container::read_container;
|
use crate::nitro::container::read_container;
|
||||||
match read_container(Cur::new(&buf)) {
|
match read_container(Cur::new(&buf)) {
|
||||||
Ok(cont) => {
|
Ok(cont) => {
|
||||||
self.add_container(file_id, cont);
|
self.add_container(file_id, cont);
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
//! See: DSDecmp (https://github.com/Barubary/dsdecmp)
|
//! See: DSDecmp (https://github.com/Barubary/dsdecmp)
|
||||||
|
|
||||||
use std::{fmt, error, result};
|
use std::{fmt, error, result};
|
||||||
use util::bits::BitField;
|
use crate::util::bits::BitField;
|
||||||
use util::cur::{self, Cur};
|
use crate::util::cur::{self, Cur};
|
||||||
|
|
||||||
pub struct DecompressResult<'a> {
|
pub struct DecompressResult<'a> {
|
||||||
/// The decompressed data.
|
/// The decompressed data.
|
||||||
|
@ -19,10 +19,10 @@ impl Error for ErrorMsg {}
|
|||||||
|
|
||||||
macro_rules! errmsg {
|
macro_rules! errmsg {
|
||||||
($msg:expr) => {
|
($msg:expr) => {
|
||||||
::errors::ErrorMsg { msg: $msg.into() }
|
crate::errors::ErrorMsg { msg: $msg.into() }
|
||||||
};
|
};
|
||||||
($fmt:expr, $($arg:tt)+) => {
|
($fmt:expr, $($arg:tt)+) => {
|
||||||
::errors::ErrorMsg { msg: format!($fmt, $($arg)+) }
|
crate::errors::ErrorMsg { msg: format!($fmt, $($arg)+) }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
//! Extract recognized container files from ROMs or other packed files.
|
//! Extract recognized container files from ROMs or other packed files.
|
||||||
|
|
||||||
use cli::Args;
|
use crate::cli::Args;
|
||||||
use decompress;
|
use crate::decompress;
|
||||||
use errors::Result;
|
use crate::errors::Result;
|
||||||
use nitro::Container;
|
use crate::nitro::Container;
|
||||||
use nitro::container::read_container;
|
use crate::nitro::container::read_container;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use util::cur::Cur;
|
use crate::util::cur::Cur;
|
||||||
use util::OutDir;
|
use crate::util::OutDir;
|
||||||
|
|
||||||
pub fn main(args: &Args) -> Result<()> {
|
pub fn main(args: &Args) -> Result<()> {
|
||||||
let input_file = &args.free_args[0];
|
let input_file = &args.free_args[0];
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use cli::Args;
|
use crate::cli::Args;
|
||||||
use errors::Result;
|
use crate::errors::Result;
|
||||||
use db::Database;
|
use crate::db::Database;
|
||||||
use connection::{Connection, ConnectionOptions, MaterialConnection, Match};
|
use crate::connection::{Connection, ConnectionOptions, MaterialConnection, Match};
|
||||||
|
|
||||||
pub fn main(args: &Args) -> Result<()> {
|
pub fn main(args: &Args) -> Result<()> {
|
||||||
let db = Database::from_cli_args(args)?;
|
let db = Database::from_cli_args(args)?;
|
||||||
@ -160,7 +160,7 @@ fn animation_info(db: &Database, anim_id: usize) {
|
|||||||
for (i, trs_curves) in anim.objects_curves.iter().enumerate() {
|
for (i, trs_curves) in anim.objects_curves.iter().enumerate() {
|
||||||
println!(" Object {}:", i);
|
println!(" Object {}:", i);
|
||||||
|
|
||||||
use nitro::animation::Curve;
|
use crate::nitro::animation::Curve;
|
||||||
fn curve_info<T>(name: &'static str, curve: &Curve<T>) {
|
fn curve_info<T>(name: &'static str, curve: &Curve<T>) {
|
||||||
match *curve {
|
match *curve {
|
||||||
Curve::None => { }
|
Curve::None => { }
|
||||||
|
@ -6,14 +6,8 @@
|
|||||||
extern crate log;
|
extern crate log;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate glium;
|
extern crate glium;
|
||||||
extern crate cgmath;
|
|
||||||
extern crate time;
|
|
||||||
extern crate png;
|
|
||||||
extern crate termcolor;
|
|
||||||
extern crate atty;
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate json;
|
extern crate json;
|
||||||
extern crate wild;
|
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod errors;
|
mod errors;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use nitro::{Texture, Palette};
|
use crate::nitro::{Texture, Palette};
|
||||||
use errors::Result;
|
use crate::errors::Result;
|
||||||
use util::bits::BitField;
|
use crate::util::bits::BitField;
|
||||||
use util::cur::Cur;
|
use crate::util::cur::Cur;
|
||||||
|
|
||||||
/// Pixel data stored in R8G8B8A8 format.
|
/// Pixel data stored in R8G8B8A8 format.
|
||||||
pub struct RGBABuf(pub Vec<u8>);
|
pub struct RGBABuf(pub Vec<u8>);
|
||||||
|
@ -9,11 +9,11 @@
|
|||||||
//! for a reference on the DS's GPU.
|
//! for a reference on the DS's GPU.
|
||||||
|
|
||||||
use cgmath::{Point2, Point3, Vector3, vec3};
|
use cgmath::{Point2, Point3, Vector3, vec3};
|
||||||
use errors::Result;
|
use crate::errors::Result;
|
||||||
use util::bits::BitField;
|
use crate::util::bits::BitField;
|
||||||
use util::fixed::fix16;
|
use crate::util::fixed::fix16;
|
||||||
use util::fixed::fix32;
|
use crate::util::fixed::fix32;
|
||||||
use util::view::View;
|
use crate::util::view::View;
|
||||||
|
|
||||||
/// DS GPU command.
|
/// DS GPU command.
|
||||||
pub enum GpuCmd {
|
pub enum GpuCmd {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use super::TextureFormat;
|
use super::TextureFormat;
|
||||||
use util::bits::BitField;
|
use crate::util::bits::BitField;
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
pub struct TextureParams(pub u32);
|
pub struct TextureParams(pub u32);
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
use cgmath::{Matrix3, Matrix4};
|
use cgmath::{Matrix3, Matrix4};
|
||||||
use util::bits::BitField;
|
use crate::util::bits::BitField;
|
||||||
use util::cur::Cur;
|
use crate::util::cur::Cur;
|
||||||
use util::fixed::{fix16, fix32};
|
use crate::util::fixed::{fix16, fix32};
|
||||||
use nitro::Name;
|
use crate::nitro::Name;
|
||||||
use nitro::rotation::{pivot_mat, basis_mat};
|
use crate::nitro::rotation::{pivot_mat, basis_mat};
|
||||||
use std::ops::{Mul, Add};
|
use std::ops::{Mul, Add};
|
||||||
use errors::Result;
|
use crate::errors::Result;
|
||||||
|
|
||||||
pub struct Animation {
|
pub struct Animation {
|
||||||
pub name: Name,
|
pub name: Name,
|
||||||
|
@ -12,10 +12,10 @@
|
|||||||
//! usually only contains JNT0s (animations), but we don't do anything to
|
//! usually only contains JNT0s (animations), but we don't do anything to
|
||||||
//! enforce this. We'll read any kind of file we can get our hands on!
|
//! enforce this. We'll read any kind of file we can get our hands on!
|
||||||
|
|
||||||
use errors::Result;
|
use crate::errors::Result;
|
||||||
use nitro::{Model, Texture, Palette, Animation, Pattern, MaterialAnimation};
|
use crate::nitro::{Model, Texture, Palette, Animation, Pattern, MaterialAnimation};
|
||||||
use nitro::info_block;
|
use crate::nitro::info_block;
|
||||||
use util::cur::Cur;
|
use crate::util::cur::Cur;
|
||||||
|
|
||||||
const STAMPS: [&[u8]; 5] = [b"BMD0", b"BTX0", b"BCA0", b"BTP0", b"BTA0"];
|
const STAMPS: [&[u8]; 5] = [b"BMD0", b"BTX0", b"BCA0", b"BTP0", b"BTA0"];
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ fn read_section(cont: &mut Container, cur: Cur) -> Result<()> {
|
|||||||
|
|
||||||
// An MDL is a container for models.
|
// An MDL is a container for models.
|
||||||
fn add_mdl(cont: &mut Container, cur: Cur) -> Result<()> {
|
fn add_mdl(cont: &mut Container, cur: Cur) -> Result<()> {
|
||||||
use nitro::model::read_model;
|
use crate::nitro::model::read_model;
|
||||||
|
|
||||||
fields!(cur, MDL0 {
|
fields!(cur, MDL0 {
|
||||||
stamp: [u8; 4],
|
stamp: [u8; 4],
|
||||||
@ -105,7 +105,7 @@ fn add_mdl(cont: &mut Container, cur: Cur) -> Result<()> {
|
|||||||
|
|
||||||
// This work is already done for us in read_tex; see that module for why.
|
// This work is already done for us in read_tex; see that module for why.
|
||||||
fn add_tex(cont: &mut Container, cur: Cur) -> Result<()> {
|
fn add_tex(cont: &mut Container, cur: Cur) -> Result<()> {
|
||||||
use nitro::tex::read_tex;
|
use crate::nitro::tex::read_tex;
|
||||||
|
|
||||||
let (textures, palettes) = read_tex(cur)?;
|
let (textures, palettes) = read_tex(cur)?;
|
||||||
cont.textures.extend(textures.into_iter());
|
cont.textures.extend(textures.into_iter());
|
||||||
@ -116,7 +116,7 @@ fn add_tex(cont: &mut Container, cur: Cur) -> Result<()> {
|
|||||||
|
|
||||||
// A JNT is a container for animations.
|
// A JNT is a container for animations.
|
||||||
fn add_jnt(cont: &mut Container, cur: Cur) -> Result<()> {
|
fn add_jnt(cont: &mut Container, cur: Cur) -> Result<()> {
|
||||||
use nitro::animation::read_animation;
|
use crate::nitro::animation::read_animation;
|
||||||
|
|
||||||
fields!(cur, JNT0 {
|
fields!(cur, JNT0 {
|
||||||
stamp: [u8; 4],
|
stamp: [u8; 4],
|
||||||
@ -138,7 +138,7 @@ fn add_jnt(cont: &mut Container, cur: Cur) -> Result<()> {
|
|||||||
|
|
||||||
// A PAT is a container for pattern animations.
|
// A PAT is a container for pattern animations.
|
||||||
fn add_pat(cont: &mut Container, cur: Cur) -> Result<()> {
|
fn add_pat(cont: &mut Container, cur: Cur) -> Result<()> {
|
||||||
use nitro::pattern::read_pattern;
|
use crate::nitro::pattern::read_pattern;
|
||||||
|
|
||||||
fields!(cur, PAT0 {
|
fields!(cur, PAT0 {
|
||||||
stamp: [u8; 4],
|
stamp: [u8; 4],
|
||||||
@ -160,7 +160,7 @@ fn add_pat(cont: &mut Container, cur: Cur) -> Result<()> {
|
|||||||
|
|
||||||
// An SRT is a container for material animations.
|
// An SRT is a container for material animations.
|
||||||
fn add_srt(cont: &mut Container, cur: Cur) -> Result<()> {
|
fn add_srt(cont: &mut Container, cur: Cur) -> Result<()> {
|
||||||
use nitro::material_animation::read_mat_anim;
|
use crate::nitro::material_animation::read_mat_anim;
|
||||||
|
|
||||||
fields!(cur, SRT0 {
|
fields!(cur, SRT0 {
|
||||||
stamp: [u8; 4],
|
stamp: [u8; 4],
|
||||||
|
@ -4,12 +4,12 @@
|
|||||||
//! data-name pairs, where the data is usually an offset to the location
|
//! data-name pairs, where the data is usually an offset to the location
|
||||||
//! of some struct with the given name.
|
//! of some struct with the given name.
|
||||||
|
|
||||||
use errors::Result;
|
use crate::errors::Result;
|
||||||
use nitro::name::Name;
|
use crate::nitro::name::Name;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::iter::Zip;
|
use std::iter::Zip;
|
||||||
use util::cur::Cur;
|
use crate::util::cur::Cur;
|
||||||
use util::view::{View, Viewable};
|
use crate::util::view::{View, Viewable};
|
||||||
|
|
||||||
pub type Iterator<'a, T> = Zip<View<'a, T>, View<'a, Name>>;
|
pub type Iterator<'a, T> = Zip<View<'a, T>, View<'a, Name>>;
|
||||||
|
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
// HIGHLY INCOMPLETE!!!
|
// HIGHLY INCOMPLETE!!!
|
||||||
|
|
||||||
use super::animation::Curve;
|
use super::animation::Curve;
|
||||||
use util::cur::Cur;
|
use crate::util::cur::Cur;
|
||||||
use util::view::Viewable;
|
use crate::util::view::Viewable;
|
||||||
use util::fixed::fix16;
|
use crate::util::fixed::fix16;
|
||||||
use cgmath::{Matrix4, vec3};
|
use cgmath::{Matrix4, vec3};
|
||||||
use nitro::Name;
|
use crate::nitro::Name;
|
||||||
use errors::Result;
|
use crate::errors::Result;
|
||||||
use super::info_block;
|
use super::info_block;
|
||||||
|
|
||||||
/// Material animation. Does things like UV matrix animation.
|
/// Material animation. Does things like UV matrix animation.
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
use cgmath::{Matrix3, Matrix4, One, vec3, Vector3};
|
use cgmath::{Matrix3, Matrix4, One, vec3, Vector3};
|
||||||
use errors::Result;
|
use crate::errors::Result;
|
||||||
use nitro::info_block;
|
use crate::nitro::info_block;
|
||||||
use nitro::Name;
|
use crate::nitro::Name;
|
||||||
use nds::TextureParams;
|
use crate::nds::TextureParams;
|
||||||
use nitro::render_cmds::Op;
|
use crate::nitro::render_cmds::Op;
|
||||||
use util::bits::BitField;
|
use crate::util::bits::BitField;
|
||||||
use util::cur::Cur;
|
use crate::util::cur::Cur;
|
||||||
use util::fixed::{fix16, fix32};
|
use crate::util::fixed::{fix16, fix32};
|
||||||
|
|
||||||
/// NSBMD model.
|
/// NSBMD model.
|
||||||
pub struct Model {
|
pub struct Model {
|
||||||
@ -360,7 +360,7 @@ fn read_object(mut cur: Cur, name: Name) -> Result<Object> {
|
|||||||
let b = fx16(cur.next::<u16>()?);
|
let b = fx16(cur.next::<u16>()?);
|
||||||
let select = flags.bits(4,8);
|
let select = flags.bits(4,8);
|
||||||
let neg = flags.bits(8,12);
|
let neg = flags.bits(8,12);
|
||||||
use nitro::rotation::pivot_mat;
|
use crate::nitro::rotation::pivot_mat;
|
||||||
rot = Some(pivot_mat(select, neg, a, b));
|
rot = Some(pivot_mat(select, neg, a, b));
|
||||||
} else if r == 0 {
|
} else if r == 0 {
|
||||||
let m = cur.next_n::<u16>(8)?;
|
let m = cur.next_n::<u16>(8)?;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use std::fmt::{self, Write};
|
use std::fmt::{self, Write};
|
||||||
use util::view::Viewable;
|
use crate::util::view::Viewable;
|
||||||
|
|
||||||
/// Sixteen-byte NUL-padded ASCII(?) string, used as human-readable names
|
/// Sixteen-byte NUL-padded ASCII(?) string, used as human-readable names
|
||||||
/// in Nitro files.
|
/// in Nitro files.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use util::cur::Cur;
|
use crate::util::cur::Cur;
|
||||||
use nitro::Name;
|
use crate::nitro::Name;
|
||||||
use errors::Result;
|
use crate::errors::Result;
|
||||||
use super::info_block;
|
use super::info_block;
|
||||||
|
|
||||||
/// A pattern animation changes the images that the materials of a model use as
|
/// A pattern animation changes the images that the materials of a model use as
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//! Render commands for model files.
|
//! Render commands for model files.
|
||||||
|
|
||||||
use errors::Result;
|
use crate::errors::Result;
|
||||||
use util::cur::Cur;
|
use crate::util::cur::Cur;
|
||||||
|
|
||||||
pub struct SkinTerm {
|
pub struct SkinTerm {
|
||||||
pub weight: f32,
|
pub weight: f32,
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
//! actually be a rotation (ie. orthogonal of determinant +1).
|
//! actually be a rotation (ie. orthogonal of determinant +1).
|
||||||
|
|
||||||
use cgmath::{Matrix3, vec3};
|
use cgmath::{Matrix3, vec3};
|
||||||
use util::bits::BitField;
|
use crate::util::bits::BitField;
|
||||||
use util::fixed::fix16;
|
use crate::util::fixed::fix16;
|
||||||
|
|
||||||
pub fn pivot_mat(select: u16, neg: u16, a: f64, b: f64) -> Matrix3<f64> {
|
pub fn pivot_mat(select: u16, neg: u16, a: f64, b: f64) -> Matrix3<f64> {
|
||||||
if select >= 9 {
|
if select >= 9 {
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use nitro::Name;
|
use crate::nitro::Name;
|
||||||
use nitro::info_block;
|
use crate::nitro::info_block;
|
||||||
use errors::Result;
|
use crate::errors::Result;
|
||||||
use util::cur::Cur;
|
use crate::util::cur::Cur;
|
||||||
use nds::{TextureParams, TextureFormat};
|
use crate::nds::{TextureParams, TextureFormat};
|
||||||
|
|
||||||
pub struct Texture {
|
pub struct Texture {
|
||||||
pub name: Name,
|
pub name: Name,
|
||||||
|
@ -8,8 +8,8 @@
|
|||||||
//! This is then further consumed by both the viewer and the COLLADA writer.
|
//! This is then further consumed by both the viewer and the COLLADA writer.
|
||||||
|
|
||||||
use cgmath::{Matrix4, Point2, Transform, InnerSpace, vec4, Zero};
|
use cgmath::{Matrix4, Point2, Transform, InnerSpace, vec4, Zero};
|
||||||
use nitro::Model;
|
use crate::nitro::Model;
|
||||||
use nitro::render_cmds::SkinTerm;
|
use crate::nitro::render_cmds::SkinTerm;
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
use std::ops::Range;
|
use std::ops::Range;
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ implement_vertex!(Vertex, position, texcoord, color, normal);
|
|||||||
impl Primitives {
|
impl Primitives {
|
||||||
pub fn build(model: &Model, poly_type: PolyType, state: DynamicState) -> Primitives {
|
pub fn build(model: &Model, poly_type: PolyType, state: DynamicState) -> Primitives {
|
||||||
let mut b = Builder::new(model, poly_type, state);
|
let mut b = Builder::new(model, poly_type, state);
|
||||||
use nitro::render_cmds::Op;
|
use crate::nitro::render_cmds::Op;
|
||||||
for op in &model.render_ops {
|
for op in &model.render_ops {
|
||||||
match *op {
|
match *op {
|
||||||
Op::LoadMatrix { stack_pos } => b.load_matrix(stack_pos),
|
Op::LoadMatrix { stack_pos } => b.load_matrix(stack_pos),
|
||||||
@ -364,7 +364,7 @@ impl<'a, 'b> Builder<'a, 'b> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn run_gpu_cmds(b: &mut Builder, commands: &[u8]) {
|
fn run_gpu_cmds(b: &mut Builder, commands: &[u8]) {
|
||||||
use nds::gpu_cmds::{CmdParser, GpuCmd};
|
use crate::nds::gpu_cmds::{CmdParser, GpuCmd};
|
||||||
let interpreter = CmdParser::new(commands);
|
let interpreter = CmdParser::new(commands);
|
||||||
|
|
||||||
for cmd_res in interpreter {
|
for cmd_res in interpreter {
|
||||||
|
@ -114,8 +114,8 @@ use cgmath::{Matrix4, SquareMatrix, One, ApproxEq};
|
|||||||
use super::vertex_record::VertexRecord;
|
use super::vertex_record::VertexRecord;
|
||||||
use super::{SMatrix, AMatrix};
|
use super::{SMatrix, AMatrix};
|
||||||
use super::{Skeleton, Joint, Transform, Weight, WeightsOfs};
|
use super::{Skeleton, Joint, Transform, Weight, WeightsOfs};
|
||||||
use nitro::Model;
|
use crate::nitro::Model;
|
||||||
use util::tree::{Tree, NodeIdx};
|
use crate::util::tree::{Tree, NodeIdx};
|
||||||
|
|
||||||
pub fn build_skeleton(vr: &VertexRecord, model: &Model, objects: &[Matrix4<f64>]) -> Skeleton {
|
pub fn build_skeleton(vr: &VertexRecord, model: &Model, objects: &[Matrix4<f64>]) -> Skeleton {
|
||||||
let mut b = Builder::new(model, objects);
|
let mut b = Builder::new(model, objects);
|
||||||
|
@ -56,8 +56,8 @@ mod joint_tree;
|
|||||||
pub use self::symbolic_matrix::{SMatrix, AMatrix};
|
pub use self::symbolic_matrix::{SMatrix, AMatrix};
|
||||||
|
|
||||||
use cgmath::Matrix4;
|
use cgmath::Matrix4;
|
||||||
use nitro::Model;
|
use crate::nitro::Model;
|
||||||
use util::tree::{Tree, NodeIdx};
|
use crate::util::tree::{Tree, NodeIdx};
|
||||||
|
|
||||||
/// Skeleton (or skin) for a model.
|
/// Skeleton (or skin) for a model.
|
||||||
pub struct Skeleton {
|
pub struct Skeleton {
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
//! matrix is applied to each vertex.
|
//! matrix is applied to each vertex.
|
||||||
|
|
||||||
use super::symbolic_matrix::{SMatrix, AMatrix};
|
use super::symbolic_matrix::{SMatrix, AMatrix};
|
||||||
use nitro::Model;
|
use crate::nitro::Model;
|
||||||
use nitro::render_cmds::SkinTerm;
|
use crate::nitro::render_cmds::SkinTerm;
|
||||||
|
|
||||||
type MatrixIdx = u16;
|
type MatrixIdx = u16;
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ pub struct VertexRecord {
|
|||||||
impl VertexRecord {
|
impl VertexRecord {
|
||||||
pub fn build_for_model(model: &Model) -> VertexRecord {
|
pub fn build_for_model(model: &Model) -> VertexRecord {
|
||||||
let mut b = Builder::new(model);
|
let mut b = Builder::new(model);
|
||||||
use nitro::render_cmds::Op;
|
use crate::nitro::render_cmds::Op;
|
||||||
for op in &model.render_ops {
|
for op in &model.render_ops {
|
||||||
match *op {
|
match *op {
|
||||||
Op::LoadMatrix { stack_pos } => b.load_matrix(stack_pos),
|
Op::LoadMatrix { stack_pos } => b.load_matrix(stack_pos),
|
||||||
@ -112,7 +112,7 @@ impl<'a> Builder<'a> {
|
|||||||
|
|
||||||
fn draw(&mut self, piece_idx: u8) {
|
fn draw(&mut self, piece_idx: u8) {
|
||||||
let piece = &self.model.pieces[piece_idx as usize];
|
let piece = &self.model.pieces[piece_idx as usize];
|
||||||
use nds::gpu_cmds::{CmdParser, GpuCmd};
|
use crate::nds::gpu_cmds::{CmdParser, GpuCmd};
|
||||||
let interpreter = CmdParser::new(&piece.gpu_commands);
|
let interpreter = CmdParser::new(&piece.gpu_commands);
|
||||||
|
|
||||||
for cmd_res in interpreter {
|
for cmd_res in interpreter {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use std::{fmt, error};
|
use std::{fmt, error};
|
||||||
use std::ops::Add;
|
use std::ops::Add;
|
||||||
use util::view::{View, Viewable};
|
use crate::util::view::{View, Viewable};
|
||||||
|
|
||||||
/// A pointer into a buffer of bytes. Used for binary file parsing.
|
/// A pointer into a buffer of bytes. Used for binary file parsing.
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
|
@ -30,13 +30,13 @@ macro_rules! field_helper2 {
|
|||||||
($cur:ident, (fix16($s:expr,$i:expr,$f:expr))) => {
|
($cur:ident, (fix16($s:expr,$i:expr,$f:expr))) => {
|
||||||
{
|
{
|
||||||
let x = $cur.next::<u16>()?;
|
let x = $cur.next::<u16>()?;
|
||||||
::util::fixed::fix16(x, $s, $i, $f)
|
crate::util::fixed::fix16(x, $s, $i, $f)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
($cur:ident, (fix32($s:expr,$i:expr,$f:expr))) => {
|
($cur:ident, (fix32($s:expr,$i:expr,$f:expr))) => {
|
||||||
{
|
{
|
||||||
let x = $cur.next::<u32>()?;
|
let x = $cur.next::<u32>()?;
|
||||||
::util::fixed::fix32(x, $s, $i, $f)
|
crate::util::fixed::fix32(x, $s, $i, $f)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
($cur:ident, Cur) => { $cur.clone() };
|
($cur:ident, Cur) => { $cur.clone() };
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
//! Fixed-point to `f64` conversions.
|
//! Fixed-point to `f64` conversions.
|
||||||
|
|
||||||
use util::bits::BitField;
|
use crate::util::bits::BitField;
|
||||||
|
|
||||||
/// Reads a fixed-point number from a `u32`.
|
/// Reads a fixed-point number from a `u32`.
|
||||||
///
|
///
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use std::io::ErrorKind;
|
use std::io::ErrorKind;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use errors::Result;
|
use crate::errors::Result;
|
||||||
|
|
||||||
/// Directory for putting output files in. Will be created lazily when the first
|
/// Directory for putting output files in. Will be created lazily when the first
|
||||||
/// file is created.
|
/// file is created.
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use glium::glutin::{self, dpi::{LogicalSize, PhysicalSize, PhysicalPosition}};
|
use glium::glutin::{self, dpi::{LogicalSize, PhysicalSize, PhysicalPosition}};
|
||||||
use glium::glutin::event_loop::ControlFlow;
|
use glium::glutin::event_loop::ControlFlow;
|
||||||
use super::viewer::Viewer;
|
use super::viewer::Viewer;
|
||||||
use db::Database;
|
use crate::db::Database;
|
||||||
use connection::Connection;
|
use crate::connection::Connection;
|
||||||
|
|
||||||
pub fn main_loop(db: Database, conn: Connection) {
|
pub fn main_loop(db: Database, conn: Connection) {
|
||||||
let window_builder = glutin::window::WindowBuilder::new()
|
let window_builder = glutin::window::WindowBuilder::new()
|
||||||
|
@ -3,10 +3,10 @@ mod main_loop;
|
|||||||
mod viewer;
|
mod viewer;
|
||||||
mod fps;
|
mod fps;
|
||||||
|
|
||||||
use cli::Args;
|
use crate::cli::Args;
|
||||||
use db::Database;
|
use crate::db::Database;
|
||||||
use connection::{Connection, ConnectionOptions};
|
use crate::connection::{Connection, ConnectionOptions};
|
||||||
use errors::Result;
|
use crate::errors::Result;
|
||||||
|
|
||||||
/// Initial window width.
|
/// Initial window width.
|
||||||
pub static WINDOW_WIDTH: u32 = 640;
|
pub static WINDOW_WIDTH: u32 = 640;
|
||||||
|
@ -4,10 +4,10 @@ pub mod texture_cache;
|
|||||||
pub use self::eye::Eye;
|
pub use self::eye::Eye;
|
||||||
|
|
||||||
use cgmath::{PerspectiveFov, Rad, Matrix4};
|
use cgmath::{PerspectiveFov, Rad, Matrix4};
|
||||||
use db::Database;
|
use crate::db::Database;
|
||||||
use glium::{VertexBuffer, IndexBuffer, Frame, Surface, Program, Display};
|
use glium::{VertexBuffer, IndexBuffer, Frame, Surface, Program, Display};
|
||||||
use nitro::Model;
|
use crate::nitro::Model;
|
||||||
use primitives::{Primitives, DrawCall, Vertex};
|
use crate::primitives::{Primitives, DrawCall, Vertex};
|
||||||
use self::texture_cache::{TextureCache, ImageId};
|
use self::texture_cache::{TextureCache, ImageId};
|
||||||
use super::{Z_NEAR, Z_FAR, FOV_Y};
|
use super::{Z_NEAR, Z_FAR, FOV_Y};
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use db::{Database, TextureId, PaletteId};
|
use crate::db::{Database, TextureId, PaletteId};
|
||||||
use glium::{Display, Texture2d, texture::RawImage2d};
|
use glium::{Display, Texture2d, texture::RawImage2d};
|
||||||
use nds;
|
use crate::nds;
|
||||||
|
|
||||||
// TODO: move somewhere more important.
|
// TODO: move somewhere more important.
|
||||||
pub type ImageId = (TextureId, Option<PaletteId>);
|
pub type ImageId = (TextureId, Option<PaletteId>);
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
use std::ops::Range;
|
use std::ops::Range;
|
||||||
use super::model_viewer::{ModelViewer, MaterialTextureBinding};
|
use super::model_viewer::{ModelViewer, MaterialTextureBinding};
|
||||||
use db::{Database, ModelId, AnimationId, PatternId, MatAnimId, FileId};
|
use crate::db::{Database, ModelId, AnimationId, PatternId, MatAnimId, FileId};
|
||||||
use connection::Connection;
|
use crate::connection::Connection;
|
||||||
use glium::Display;
|
use glium::Display;
|
||||||
use glium::{Frame, Surface};
|
use glium::{Frame, Surface};
|
||||||
use glium::glutin::event::{ElementState, ModifiersState};
|
use glium::glutin::event::{ElementState, ModifiersState};
|
||||||
use glium::glutin::event::VirtualKeyCode;
|
use glium::glutin::event::VirtualKeyCode;
|
||||||
use nitro::{Model, Animation, Pattern, MaterialAnimation};
|
use crate::nitro::{Model, Animation, Pattern, MaterialAnimation};
|
||||||
use primitives::{Primitives, PolyType, DynamicState};
|
use crate::primitives::{Primitives, PolyType, DynamicState};
|
||||||
use cgmath::{Matrix4, InnerSpace, Vector3, vec3, vec2};
|
use cgmath::{Matrix4, InnerSpace, Vector3, vec3, vec2};
|
||||||
use super::fps::FpsCounter;
|
use super::fps::FpsCounter;
|
||||||
use super::{FRAMERATE, BG_COLOR};
|
use super::{FRAMERATE, BG_COLOR};
|
||||||
|
Loading…
Reference in New Issue
Block a user