armory3d / armortools

3D Content Creation Tools
https://armorpaint.org
Other
3.22k stars 334 forks source link

Armorpaint - live link locks up armorpaint with Blender 3.0+ #1310

Closed ronh991 closed 2 years ago

ronh991 commented 2 years ago

ArmorPaint version:

0.9 development

OS/device including version:

Windows 10

Issue description:

Using live link from https://github.com/PiloeGAO/Blender-ArmorPaintLiveLink seems to lock up armorpaint (latest dev version). This has been reported and verified on the armorpaint live git issues and the author suggested posting here.

Steps to reproduce:

Install live link in blender 3.0+, open cube and stretch it - just to make different from set project folder and click on open armorpaint -

Armorpaint opens but the obj file is not correct and armorpaint mouse will not allow for the panning and moving the "cube"

IS this an armorpaint issue or armorpaint live issue??

ronh991 commented 2 years ago

added research:

seems blender has two version of the obj exporter. as they produce different files. I traced it down to the s parameter. With live link program blender has s off - while the manual Wavefront obj export from the menu has s 0

DA40CGDFQ_March 2, 2022_12h52m49s

changing the from s off to s 0 allows the obj file to work.

ronh991 commented 2 years ago

further research - s is the smoothing group and valid values are off and integers.

from http://paulbourke.net/dataformats/obj/

s group_number

Polygonal and free-form geometry statement.

Sets the smoothing group for the elements that follow it. If you do
not want to use a smoothing group, specify off or a value of 0.

To display with smooth shading in Model and PreView, you must
create vertex normals after you have assigned the smoothing groups.
You can create vertex normals with the vn statement or with the
Model program.

To smooth polygonal geometry for rendering with Image, it is
sufficient to put elements in some smoothing group. However, vertex
normals override smoothing information for Image.

group_number is the smoothing group number. To turn off smoothing
groups, use a value of 0 or off. Polygonal elements use group
numbers to put elements in different smoothing groups. For
free-form surfaces, smoothing groups are either turned on or off;
there is no difference between values greater than 0.
ronh991 commented 2 years ago

ObjParser.hx - does not seem to have a parsing for the s variable??

MathemanFlo commented 2 years ago

I do not use the live link but loading this file

# Blender v2.83.4 OBJ File: ''
# www.blender.org
mtllib untitled.mtl
o Cube
v 1.000000 1.000000 -1.000000
v 1.000000 -1.000000 -1.000000
v 1.000000 1.000000 1.000000
v 1.000000 -1.000000 1.000000
v -1.000000 1.000000 -1.000000
v -1.000000 -1.000000 -1.000000
v -1.000000 1.000000 1.000000
v -1.000000 -1.000000 1.000000
vt 0.625000 0.500000
vt 0.875000 0.500000
vt 0.875000 0.750000
vt 0.625000 0.750000
vt 0.375000 0.750000
vt 0.625000 1.000000
vt 0.375000 1.000000
vt 0.375000 0.000000
vt 0.625000 0.000000
vt 0.625000 0.250000
vt 0.375000 0.250000
vt 0.125000 0.500000
vt 0.375000 0.500000
vt 0.125000 0.750000
vn 0.0000 1.0000 0.0000
vn 0.0000 0.0000 1.0000
vn -1.0000 0.0000 0.0000
vn 0.0000 -1.0000 0.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
s 0
usemtl Material
f 1/1/1 5/2/1 7/3/1 3/4/1
f 4/5/2 3/4/2 7/6/2 8/7/2
f 8/8/3 7/9/3 5/10/3 6/11/3
f 6/12/4 2/13/4 4/5/4 8/14/4
f 2/13/5 1/1/5 3/4/5 4/5/5
f 6/11/6 5/10/6 1/1/6 2/13/6

works with s 0 and s off. Can you load both versions using File -> Import mesh. If not could you provide the mesh that does not work for you this way?

ronh991 commented 2 years ago

Ok trying this again this is a blender issue as it keeps the temp file open and Armorpaint does not seem to like that. The blender live link creates a obj and mtl file in the windows temp folder. but does not seem to release it. (Or armorpaint wants rw oon an open file)

I mistakenly thought the s was an issue a when I changed it it loaded. Sorry for the confusion. Let me know if this issue should be closed.

Trying a third tome the temp folder is the issue, perhaps a windows security thing I cannot open the file wjhen on APPData/Local/Temp

ronh991 commented 2 years ago

This error is due to the use of mkstemp to make a temp file, it remains open in the Armorpaint cannot reopen the file. Live link program needs to change to:

        # Create a temporary file to store the .obj
        path_tmp = tempfile.NamedTemporaryFile(suffix=".obj", dir=projP, delete=False)
        path_tmp_1 = path_tmp.name
        path_tmp.close()