Struct turbine_scene3d::Scene

source ·
pub struct Scene {
    pub settings: SceneSettings,
    pub projection: Matrix4<f32>,
    pub camera: Matrix4<f32>,
    pub model: Matrix4<f32>,
    /* private fields */
}
Expand description

Stores scene data.

Fields§

§settings: SceneSettings

Scene settings.

§projection: Matrix4<f32>

Projection transform.

§camera: Matrix4<f32>

Camera transform.

§model: Matrix4<f32>

Model transform.

Implementations§

source§

impl Scene

source

pub fn new(settings: SceneSettings) -> Scene

Create new scene.

source

pub fn projection(&mut self, p: Matrix4<f32>)

Set projection matrix.

source

pub fn camera(&mut self, c: Matrix4<f32>)

Set camera matrix.

source

pub fn model(&mut self, m: Matrix4<f32>)

Set model matrix.

source

pub fn load_texture<P: AsRef<Path>>( &mut self, path: P ) -> Result<Texture, ImageError>

Load texture from path.

source

pub fn vertex_shader( &mut self, vertex_shader_src: &str ) -> Result<VertexShader, String>

Create vertex shader from source.

source

pub fn fragment_shader( &mut self, fragment_shader_src: &str ) -> Result<FragmentShader, String>

Create fragment shader from source.

source

pub fn program_from_vertex_fragment( &mut self, vertex_shader: VertexShader, fragment_shader: FragmentShader ) -> Program

Create program from vertex and fragment shader.

source

pub fn matrix4_uniform( &mut self, program: Program, name: &str ) -> Result<Matrix4Uniform, String>

Create 4D matrix uniform.

source

pub fn vector2_uniform( &mut self, program: Program, name: &str ) -> Result<Vector2Uniform, String>

Create 2D vector uniform.

source

pub fn vector3_uniform( &mut self, program: Program, name: &str ) -> Result<Vector3Uniform, String>

Create 3D vector uniform.

source

pub fn f32_uniform( &mut self, program: Program, name: &str ) -> Result<F32Uniform, String>

Create f32 uniform.

source

pub fn vertex_array(&mut self) -> VertexArray

Create vertex array.

source

pub fn uv_buffer( &mut self, vertex_array: VertexArray, attribute: u32, data: &[f32] ) -> UVBuffer

Create uv buffer.

source

pub fn color_buffer( &mut self, vertex_array: VertexArray, attribute: u32, data: &[f32] ) -> ColorBuffer

Create color buffer.

source

pub fn vertex_buffer2( &mut self, vertex_array: VertexArray, attribute: u32, data: &[f32] ) -> VertexBuffer2

Create vertex buffer for 2D coordinates.

source

pub fn vertex_buffer3( &mut self, vertex_array: VertexArray, attribute: u32, data: &[f32] ) -> VertexBuffer3

Create vertex buffer for 3D coordinates.

source

pub fn normal_buffer( &mut self, vertex_array: VertexArray, attribute: u32, data: &[f32] ) -> NormalBuffer

Create normal buffer.

source

pub fn use_program(&self, program: Program)

Use program.

source

pub fn set_model_view_projection(&self, matrix_id: Matrix4Uniform)

Set model-view-projection transform uniform.

source

pub fn set_view(&self, matrix_id: Matrix4Uniform)

Set view transform uniform.

source

pub fn set_model(&self, matrix_id: Matrix4Uniform)

Set model transform uniform.

source

pub fn set_matrix4(&self, matrix_id: Matrix4Uniform, val: Matrix4<f32>)

Set matrix uniform.

source

pub fn set_vector2(&self, v_id: Vector2Uniform, v: Vector2<f32>)

Set 2D vector uniform.

source

pub fn set_vector3(&self, v_id: Vector3Uniform, v: Vector3<f32>)

Set 3D vector uniform.

source

pub fn set_f32(&self, f_id: F32Uniform, v: f32)

Set f32 uniform.

source

pub fn set_texture(&self, texture_id: Texture)

Set texture.

source

pub fn translate(&mut self, v: Vector3<f32>)

Translate model.

source

pub fn translate_global(&mut self, v: Vector3<f32>)

Translate model in global coordinates.

source

pub fn scale(&mut self, v: Vector3<f32>)

Scale model.

source

pub fn rotate_x_deg(&mut self, deg: f32)

Rotate model around x axis with degrees.

source

pub fn rotate_y_deg(&mut self, deg: f32)

Rotate model around y axis with degrees.

source

pub fn rotate_z_deg(&mut self, deg: f32)

Rotate model around z axis with degrees.

source

pub fn rotate_axis_deg(&mut self, axis: Vector3<f32>, deg: f32)

Rotate model around axis with degrees.

source

pub fn push_transform(&mut self)

Push model transfrom to transform stack.

source

pub fn pop_transform(&mut self)

Pop model transform from transform stack.

source

pub fn clear(&self, bg_color: [f32; 4])

Clear background with color.

source

pub fn enable_framebuffer_srgb(&self)

Enable framebuffer sRGB.

source

pub fn disable_framebuffer_srgb(&self)

Disable framebuffer sRGB.

source

pub fn enable_blend(&self)

Enable blend.

source

pub fn disable_blend(&self)

Disable blend.

source

pub fn enable_cull_face(&self)

Enable cull face.

source

pub fn disable_cull_face(&self)

Disable cull face.

source

pub fn cull_face_front(&self)

Cull front face.

source

pub fn cull_face_back(&self)

Cull back face.

source

pub fn cull_face_front_and_back(&self)

Cull both front and back face.

source

pub fn draw_triangles(&self, vertex_array: VertexArray, len: usize)

Draws triangles.

source

pub fn draw_triangle_strip(&self, vertex_array: VertexArray, len: usize)

Draws triangle strip.

source

pub fn draw_points(&self, vertex_array: VertexArray, len: usize)

Draws points.

source

pub fn draw_lines(&self, vertex_array: VertexArray, len: usize)

Draws lines.

source

pub fn submit(&mut self, commands: &[Command], frame_graph: &FrameGraph)

Executes commands in command list.

source

pub fn draw(&mut self, command_list: CommandList, frame_graph: &FrameGraph)

Draws a command list from frame graph.

Trait Implementations§

source§

impl Drop for Scene

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for Scene

§

impl Send for Scene

§

impl Sync for Scene

§

impl Unpin for Scene

§

impl UnwindSafe for Scene

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.