mirror of
https://github.com/Theaninova/mhlib.git
synced 2026-01-20 08:52:57 +00:00
pr3d
This commit is contained in:
@@ -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"
|
||||
|
||||
1
rust/powerrender-3d/src/lib.rs
Normal file
1
rust/powerrender-3d/src/lib.rs
Normal file
@@ -0,0 +1 @@
|
||||
pub mod pro;
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user