examples: allow for v run examples/sokol/06_obj_viewer /full/path/to/model.obj

This commit is contained in:
Delyan Angelov 2024-04-04 19:52:35 +03:00
parent cd0e0b18ea
commit 2c646bfadd
No known key found for this signature in database
GPG key ID: 66886C0F12D595ED
5 changed files with 9980 additions and 6 deletions

View file

@ -0,0 +1,26 @@
# Blender MTL File: 'None'
# Material Count: 2
newmtl Material.001
Ns 96.078443
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd apple.png
newmtl Material.002
Ns 96.078443
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd apple.png

File diff suppressed because it is too large Load diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View file

@ -14,7 +14,11 @@ pub fn read_lines_from_file(file_path string) []string {
}
rows = bts.bytestr().split_into_lines()
} $else {
path = os.resource_abs_path('assets/models/' + file_path)
path = if os.exists(file_path) {
file_path
} else {
os.resource_abs_path('assets/models/${file_path}')
}
rows = os.read_lines(path) or {
eprintln('File [${path}] NOT FOUND! file_path: ${file_path}')
return rows
@ -34,7 +38,11 @@ pub fn read_bytes_from_file(file_path string) []u8 {
exit(0)
}
} $else {
path = os.resource_abs_path('assets/models/' + file_path)
path = if os.exists(file_path) {
file_path
} else {
os.resource_abs_path('assets/models/${file_path}')
}
buffer = os.read_bytes(path) or {
eprintln('Texture file: [${path}] NOT FOUND!')
exit(0)

View file

@ -274,10 +274,10 @@ fn main() {
$if !android {
if os.args.len > 3 || (os.args.len >= 2 && os.args[1] in ['-h', '--help', '\\?', '-?']) {
eprintln('Usage:\nshow_obj [file_name:string] [single_material_flag:(true|false)]\n')
eprintln('file_name : name of the .obj file, it must be in the folder "assets/models"')
eprintln(' if no file name is passed the default V logo will be showed.')
eprintln(' if you want custom models you can put them in the folder "assets/models".')
eprintln("single_material_flag: if true the viewer use for all the model's parts the default material\n")
eprintln('file_name : name of the .obj file.')
eprintln(' If no file name is passed the default V logo will be showed.')
eprintln(' Try one of the .obj files in the "assets/models/" folder.')
eprintln("single_material_flag: if true the viewer use for all the model's parts the default material")
exit(0)
}