This commit is contained in:
2023-05-18 16:19:54 +02:00
parent e366c5830a
commit f2736c87fa
9 changed files with 165 additions and 4 deletions

View File

@@ -3,8 +3,6 @@ name = "powerrender-3d"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
binrw = "0.11.1"
half = "2.2.1"

View File

@@ -0,0 +1 @@
pub mod pro;

View File

@@ -51,9 +51,9 @@ impl PrVertices {
*index
} else {
surface.vertices.push([
f32::from_ne_bytes(point.pos[0].to_ne_bytes()),
f32::from_ne_bytes(point.pos[1].to_ne_bytes()),
f32::from_ne_bytes(point.pos[2].to_ne_bytes()),
f32::from_ne_bytes(point.pos[1].to_ne_bytes()),
f32::from_ne_bytes(point.pos[0].to_ne_bytes()),
]);
surface.normals.push([
point.normal[0] as f32 / 1024.0,

View File

@@ -8,7 +8,9 @@ use binrw::BinRead;
use binrw::BinResult;
use binrw::Endian;
use std::fmt::Debug;
use std::fs::File;
use std::io::{Read, Seek};
use std::path::Path;
pub(crate) mod chunk;
pub(crate) mod internal;
@@ -57,6 +59,13 @@ pub struct PowerRenderMaterial {
pub vert_shader: Option<String>,
}
impl PowerRenderObject {
pub fn from_file<P: AsRef<Path>>(path: P) -> BinResult<Self> {
let mut file = File::open(path).map_err(binrw::Error::Io)?;
Self::read(&mut file)
}
}
impl ReadEndian for PowerRenderObject {
const ENDIAN: EndianKind = EndianKind::Endian(Endian::Little);
}