mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
examples: allow for v run examples/sokol/06_obj_viewer /full/path/to/model.obj
This commit is contained in:
parent
cd0e0b18ea
commit
2c646bfadd
5 changed files with 9980 additions and 6 deletions
26
examples/sokol/06_obj_viewer/assets/models/apple.mtl
Normal file
26
examples/sokol/06_obj_viewer/assets/models/apple.mtl
Normal 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
|
9940
examples/sokol/06_obj_viewer/assets/models/apple.obj
Normal file
9940
examples/sokol/06_obj_viewer/assets/models/apple.obj
Normal file
File diff suppressed because it is too large
Load diff
BIN
examples/sokol/06_obj_viewer/assets/models/apple.png
Normal file
BIN
examples/sokol/06_obj_viewer/assets/models/apple.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 34 KiB |
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue