Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
blender-addons
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
blender
blender-addons
Commits
f915b348
Commit
f915b348
authored
12 years ago
by
Campbell Barton
Browse files
Options
Downloads
Patches
Plain Diff
OBJ now reads MTL using the float_func(), so materials can use commas in floating point values too.
parent
ab73e1f5
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
io_scene_obj/import_obj.py
+8
-8
8 additions, 8 deletions
io_scene_obj/import_obj.py
with
8 additions
and
8 deletions
io_scene_obj/import_obj.py
+
8
−
8
View file @
f915b348
...
@@ -68,7 +68,7 @@ def obj_image_load(imagepath, DIR, recursive):
...
@@ -68,7 +68,7 @@ def obj_image_load(imagepath, DIR, recursive):
return
load_image
(
imagepath
,
DIR
,
recursive
=
recursive
,
place_holder
=
True
)
return
load_image
(
imagepath
,
DIR
,
recursive
=
recursive
,
place_holder
=
True
)
def
create_materials
(
filepath
,
material_libs
,
unique_materials
,
unique_material_images
,
use_image_search
):
def
create_materials
(
filepath
,
material_libs
,
unique_materials
,
unique_material_images
,
use_image_search
,
float_func
):
"""
"""
Create all the used materials in this obj,
Create all the used materials in this obj,
assign colors and images to the materials from all referenced material libs
assign colors and images to the materials from all referenced material libs
...
@@ -203,17 +203,17 @@ def create_materials(filepath, material_libs, unique_materials, unique_material_
...
@@ -203,17 +203,17 @@ def create_materials(filepath, material_libs, unique_materials, unique_material_
line_split
=
line
.
split
()
line_split
=
line
.
split
()
line_lower
=
line
.
lower
().
lstrip
()
line_lower
=
line
.
lower
().
lstrip
()
if
line_lower
.
startswith
(
b
'
ka
'
):
if
line_lower
.
startswith
(
b
'
ka
'
):
context_material
.
mirror_color
=
float
(
line_split
[
1
]),
float
(
line_split
[
2
]),
float
(
line_split
[
3
])
context_material
.
mirror_color
=
float
_func
(
line_split
[
1
]),
float
_func
(
line_split
[
2
]),
float
_func
(
line_split
[
3
])
elif
line_lower
.
startswith
(
b
'
kd
'
):
elif
line_lower
.
startswith
(
b
'
kd
'
):
context_material
.
diffuse_color
=
float
(
line_split
[
1
]),
float
(
line_split
[
2
]),
float
(
line_split
[
3
])
context_material
.
diffuse_color
=
float
_func
(
line_split
[
1
]),
float
_func
(
line_split
[
2
]),
float
_func
(
line_split
[
3
])
elif
line_lower
.
startswith
(
b
'
ks
'
):
elif
line_lower
.
startswith
(
b
'
ks
'
):
context_material
.
specular_color
=
float
(
line_split
[
1
]),
float
(
line_split
[
2
]),
float
(
line_split
[
3
])
context_material
.
specular_color
=
float
_func
(
line_split
[
1
]),
float
_func
(
line_split
[
2
]),
float
_func
(
line_split
[
3
])
elif
line_lower
.
startswith
(
b
'
ns
'
):
elif
line_lower
.
startswith
(
b
'
ns
'
):
context_material
.
specular_hardness
=
int
((
float
(
line_split
[
1
])
*
0.51
))
context_material
.
specular_hardness
=
int
((
float
_func
(
line_split
[
1
])
*
0.51
))
elif
line_lower
.
startswith
(
b
'
ni
'
):
# Refraction index
elif
line_lower
.
startswith
(
b
'
ni
'
):
# Refraction index
context_material
.
raytrace_transparency
.
ior
=
max
(
1
,
min
(
float
(
line_split
[
1
]),
3
))
# between 1 and 3
context_material
.
raytrace_transparency
.
ior
=
max
(
1
,
min
(
float
_func
(
line_split
[
1
]),
3
))
# between 1 and 3
elif
line_lower
.
startswith
((
b
'
d
'
,
b
'
tr
'
)):
elif
line_lower
.
startswith
((
b
'
d
'
,
b
'
tr
'
)):
context_material
.
alpha
=
float
(
line_split
[
1
])
context_material
.
alpha
=
float
_func
(
line_split
[
1
])
context_material
.
use_transparency
=
True
context_material
.
use_transparency
=
True
context_material
.
transparency_method
=
'
Z_TRANSPARENCY
'
context_material
.
transparency_method
=
'
Z_TRANSPARENCY
'
elif
line_lower
.
startswith
(
b
'
tf
'
):
elif
line_lower
.
startswith
(
b
'
tf
'
):
...
@@ -1080,7 +1080,7 @@ def load(operator, context, filepath,
...
@@ -1080,7 +1080,7 @@ def load(operator, context, filepath,
time_sub
=
time_new
time_sub
=
time_new
print
(
'
\t
loading materials and images...
'
)
print
(
'
\t
loading materials and images...
'
)
create_materials
(
filepath
,
material_libs
,
unique_materials
,
unique_material_images
,
use_image_search
)
create_materials
(
filepath
,
material_libs
,
unique_materials
,
unique_material_images
,
use_image_search
,
float_func
)
time_new
=
time
.
time
()
time_new
=
time
.
time
()
print
(
"
%.4f sec
"
%
(
time_new
-
time_sub
))
print
(
"
%.4f sec
"
%
(
time_new
-
time_sub
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment