Module obj stdlib

Dependencies from vmod:
Imported by:
Show selected OS-specific symbols.
Show selected Backend-specific symbols.

Dependencies defined in v.mod

This section is empty.


Imported by

This section is empty.


This section is empty.


This section is empty.

Sum types

This section is empty.


#fn create_texture

fn create_texture(w int, h int, buf &u8) sokol.gfx.Image

#fn destroy_texture

fn destroy_texture(sg_img sokol.gfx.Image)

#fn load_texture

fn load_texture(file_name string) sokol.gfx.Image

#fn read_bytes_from_file

fn read_bytes_from_file(file_path string) []u8

read a file as []u8

#fn read_lines_from_file

fn read_lines_from_file(file_path string) []string

read a file as single lines

#fn tst

fn tst()

debug test function, do not remove.


#struct Vertex_pnct

pub struct Vertex_pnct {
pub mut:
	x  f32 // poistion
	y  f32
	z  f32
	nx f32 // normal
	ny f32
	nz f32
	// color u32 = 0xFFFFFFFF // color
	u f32 // uv
	v f32
	// u u16   // for compatibility with D3D11
	// v u16   // for compatibility with D3D11

vertex data struct

#struct Skl_buffer

pub struct Skl_buffer {
pub mut:
	vbuf     []Vertex_pnct
	ibuf     []u32
	n_vertex u32

struct used to pass the data to the sokol calls

#struct Part

pub struct Part {
pub mut:
	faces    [][][3]int // v n t index order, if -1 not available
	name     string
	material string

part struct mantain the fae indexes list

#fn (&Part) parse_faces

fn (mut p &Part) parse_faces(row string, start_index int, obj ObjPart)

read and manage all the faes from an .obj file data

#struct Material

pub struct Material {
pub mut:
	name string
	ks   map[string]m4.Vec4
	ns   map[string]f32
	maps map[string]string

materias struct, all Ks and Ns are stored as maps of string

#struct Render_data

pub struct Render_data {
pub mut:
	pipeline gfx.Pipeline
	bind     gfx.Bindings
	n_vert   u32
	material string

render data used for the rendering

#struct ObjPart

pub struct ObjPart {
pub mut:
	v  []m4.Vec4 // position
	vn []m4.Vec4 // normals
	vp []m4.Vec4 // vertex params
	vt []m4.Vec4 // textures

	name          string
	part          []Part               // parts of the ObjPart
	mat           []Material           // list of the materials of the ObjPart
	mat_map       map[string]int       // maping material name to its material index
	texture       map[string]gfx.Image // GPU loaded texture map
	material_file string // .mtl file name for the .obj

	rend_data []Render_data // render data used for the rendering

	t_m m4.Mat4 = m4.unit_m4() // transform matrix for this ObjPart
	// child []ObjPart           // childs
	// stats
	min    m4.Vec4 // min 3d position in the ObjPart
	max    m4.Vec4 // max 3d position in the ObjPart
	radius f32     // bounding circle radius of the ObjPart

base object parts struct

#fn (&ObjPart) parse_floats

fn (mut m &ObjPart) parse_floats(row string, start_index int) gg.m4.Vec4

reas a sequence of f32 from a string

#fn (&ObjPart) parse_obj_buffer

fn (mut obj_part &ObjPart) parse_obj_buffer(rows []string, single_material bool)

parse the obj file, if single_material is true it use only one default material

#fn (&ObjPart) load_materials

fn (mut obj_part &ObjPart) load_materials()

load the materials if found the .mtl file

#fn (&ObjPart) get_buffer

fn (mut obj_part &ObjPart) get_buffer(in_part_list []int) Skl_buffer

transforms data from .obj format to buffer ready to be used in the render

#fn (ObjPart) summary

fn (obj_part ObjPart) summary()

============================================================================== Utility ============================================================================== print on the console the summary of the .obj model loaded

#fn (&ObjPart) create_pipeline

fn (mut obj_part &ObjPart) create_pipeline(in_part []int, shader sokol.gfx.Shader, texture sokol.gfx.Image) Render_data

#fn (&ObjPart) init_render_data

fn (mut obj_part &ObjPart) init_render_data(texture sokol.gfx.Image)

agregate all the part by materials

#fn (ObjPart) bind_and_draw

fn (obj_part ObjPart) bind_and_draw(rend_data_index int, in_data Shader_data) u32

#fn (ObjPart) bind_and_draw_all

fn (obj_part ObjPart) bind_and_draw_all(in_data Shader_data) u32

#fn (&ObjPart) calc_bbox

fn (mut obj_part &ObjPart) calc_bbox()

#struct Mats

pub struct Mats {
pub mut:
	mv  m4.Mat4
	mvp m4.Mat4
	nm  m4.Mat4

used in to pass the matrices to the shader

#struct Tmp_vs_param

pub struct Tmp_vs_param {
pub mut:
	mv  m4.Mat4
	mvp m4.Mat4
	nm  m4.Mat4

data passed to the vertex shader

#struct Tmp_fs_param

pub struct Tmp_fs_param {
pub mut:
	ligth m4.Vec4
	ka    m4.Vec4 = m4.Vec4{
		e: [f32(0.1), 0.0, 0.0, 1.0]!
	kd m4.Vec4 = m4.Vec4{
		e: [f32(0.5), 0.5, 0.5, 1.0]!
	ks m4.Vec4 = m4.Vec4{
		e: [f32(1.0), 1.0, 1.0, 1.0]!

data passed to the pixel shader

#struct Shader_data

pub struct Shader_data {
pub mut:
	vs_data &Tmp_vs_param = unsafe { nil }
	vs_len  int
	fs_data &Tmp_fs_param = unsafe { nil }
	fs_len  int

shader data for the rendering


This section is empty.


This section is empty.