pub struct MODEL_MANAGER { /* private fields */ }
Expand description
模型管理器
Methods from Deref<Target = RustCraftWrapper<ModelManager>>§
Sourcepub fn load_from_file(&self, path: &str)
pub fn load_from_file(&self, path: &str)
从文件中载入模型
§参数 Parameters
path
: 模型文件路径
§注解 Note
此函数只有在 OpenGL 上下文激活后才能调用
目前仅支持从 JSON 文件中载入简单几何体模型: 格式:
- 仅顶点数据模型
{
"type": "array",
"vertices": [...],
"description": "..."
}
其中: vertices 为顶点数据,description 为顶点数据描述
- 含索引数据模型
{
"type": "element",
"vertices": [...],
"indices": [...],
"description": "..."
}
其中: vertices 为顶点数据,indices 为索引数据,description 为顶点数据描述
顶点数据结果描述的格式为: [<num><type>;...]
- num: 值个数
- type: 值类型
- f: 单精度浮点数
- i: 整型
- u: 无符号整型
- _: 一字节占位符
例如:"3f;2f"
, "3f;3f;2f"
Sourcepub fn draw_model(&self, name: &str)
pub fn draw_model(&self, name: &str)
Sourcepub fn apply<F>(&self, f: F)
pub fn apply<F>(&self, f: F)
向内部数据应用一个函数 该函数接收内部数据的可变引用,允许对其进行修改
§参数 Parameters
f
: 一个函数,接收内部数据的可变引用作为参数
§注解 Note
在运行函数的过程中,互斥锁处于锁定状态,直至函数执行完毕; 在函数内不应再次调用此函数,否则会导致死锁
§示例 Examples
use rustcraft::RustCraftWrapper;
use lazy_static::lazy_static;
lazy_static! {
static ref RUSTCRAFT: RustCraftWrapper<i32> = RustCraftWrapper::new(42);
}
fn main() {
RUSTCRAFT.apply(|data| {
*data += 1;
});
RUSTCRAFT.apply(|data| {
assert_eq!(*data, 43);
});
}
Trait Implementations§
Source§impl Deref for MODEL_MANAGER
impl Deref for MODEL_MANAGER
Source§type Target = RustCraftWrapper<ModelManager>
type Target = RustCraftWrapper<ModelManager>
The resulting type after dereferencing.
Source§fn deref(&self) -> &RustCraftWrapper<ModelManager>
fn deref(&self) -> &RustCraftWrapper<ModelManager>
Dereferences the value.
impl LazyStatic for MODEL_MANAGER
Auto Trait Implementations§
impl Freeze for MODEL_MANAGER
impl RefUnwindSafe for MODEL_MANAGER
impl Send for MODEL_MANAGER
impl Sync for MODEL_MANAGER
impl Unpin for MODEL_MANAGER
impl UnwindSafe for MODEL_MANAGER
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more