yesJorzi wrote:With frame animation do you mean texture animation
Custom ANIM3DTRANS animation - working.
Re: Custom ANIM3DTRANS animation - working.
Re: Custom ANIM3DTRANS animation - working.
Send me your test case and I'll look into it.MaNGusT wrote:Last time I tested it on propulsion model and it didn't work. I just splitted the new model of wheels propulsion onto 3 levels (as oil derrick have) and renamed derrick's anim to correct propulsion name.
Re: Custom ANIM3DTRANS animation - working.
Hi, time is a luxury also for me. But i was able to invest some time into the development.
Jorzi, i have tested your python script, but it crashes. See attached image. Now to continue on export script development discussion. Here are my main points:
Location precision & rotation in degrees The obj.location limits the result to 4 decimal places. It is not enough, we need to export 5 decimal places to have the same precision like in ani files. You have stated:
So thanks to kastoria and CoDEmanX now we are able to get high precision location values, outputs degrees right away and it gets rid of the vector and euler text in output. Here is the example script:
Jorzi do you think the to_tuple() method could be incorporated in the script (see CoDEmanX post in the blenderartist link above) to round and cut of the rest?
Also is it ok to get the degrees right away or do you think your recalculation works better?
Values and formatting
The rotation in blender has negative value and in the ani file positive value. Is it possible to change negative and positive values to opposite when exporting?
Now to the formatting. As i state above,
Please let me know if you know some or all answers to the questions.
If not, i have to dig for them elsewhere. But i am sure not to give up until the script works
BR Astorian
EDIT:
@ Jorzi - I stand corrected on one thing from the above. Changing to pos = obj.location * 100000 actually gives a correct rounded position value.
Jorzi, i have tested your python script, but it crashes. See attached image. Now to continue on export script development discussion. Here are my main points:
Location precision & rotation in degrees The obj.location limits the result to 4 decimal places. It is not enough, we need to export 5 decimal places to have the same precision like in ani files. You have stated:
Unfortunately, that would add one zero at the end, but we need to export the real value 0~9. I have posted on blenderartists.org to ask for help getting more precise readings. (See the post: http://blenderartists.org/forum/showthr ... lp-request)astorian wrote: gues you can just change the factor 1000 to 10000
So thanks to kastoria and CoDEmanX now we are able to get high precision location values, outputs degrees right away and it gets rid of the vector and euler text in output. Here is the example script:
Code: Select all
import bpy
scn = bpy.context.scene
obj = bpy.context.active_object
for f in range(scn.frame_start, scn.frame_end+1):
scn.frame_set(f)
print(scn.frame_current, obj.location.x, obj.location.y, obj.location.z, degrees(obj.rotation_euler.x), degrees(obj.rotation_euler.y), degrees(obj.rotation_euler.z))
Also is it ok to get the degrees right away or do you think your recalculation works better?
Values and formatting
The rotation in blender has negative value and in the ani file positive value. Is it possible to change negative and positive values to opposite when exporting?
Now to the formatting. As i state above,
Is it possible to use a 8 character column and align the text in it to the right side?First there are two tabulators, than 3 characters for frame number, which theoretically should allow 999 frames maximum.
Than one tabulator and now the values - 8 characters for each x, y, z, xrot, yrot, zrot, xscale, yscale, zscale value. Since the values can be also negative defined by “-” minus sign it leaves 7 characters for each value, which theoretically should allow maximum 9999999 values. It is important to use the correct spacing - all values are aligned to the right in the 8 character space, so all remaining characters to the left have to be empty space “ ”. I recommend tools like notepad++ to check the structure.
Please let me know if you know some or all answers to the questions.
If not, i have to dig for them elsewhere. But i am sure not to give up until the script works
BR Astorian
EDIT:
@ Jorzi - I stand corrected on one thing from the above. Changing to pos = obj.location * 100000 actually gives a correct rounded position value.
Re: Custom ANIM3DTRANS animation - working.
Hi
The degrees() function does the same as my formula, but yeah, do use it, it's neater and more explanatory. Also, if you want to change the sign, just multiply by -1.
When it comes to scaling, this is tricky. What you want is to make sure your exported mesh and your exported animation use the exact same scaling. This gets even more tricky since you are also able to animate the scale. Also the default scale (one wz square = 256) is way too big to work with unless you reconfigure blender's depth buffer
When it comes to the formatting:
I'm pretty sure the parser doesn't require fixed widths on the numbers, just integers with whitespace inbetween should suffice, unless you have received more specific information from someone working with the code. (This guess is based on my experience of writing text parsers). Also, the two-tab indentation at the start of the row should be just for readability.
When it comes to number precision, remember: all the numbers have a huge load of decimals, it's just a matter of how you want to print them on screen. What I do in my code is to use the %d formatting tag which formats them as ordinary integers, simply dropping all the decimals when printing. The reason why they are scaled by 1000 and converted into integers is that the game was originally made for the playstation 1 which could only handle integers. The scaling by 1000 is simply a way to get 3 decimals of precision.
I couldn't find out why my .py file didn't work, what blender version do you use? Also, don't be afraid of the lots of extra code it has. All the stuff you're working on is inside the first function, the rest is just formalities you don't have to worry about. The only difference is I use f.write instead of print, so stuff gets written into a file instead of the console. I cut out the essential code for you if you don't get it to work otherwise
The degrees() function does the same as my formula, but yeah, do use it, it's neater and more explanatory. Also, if you want to change the sign, just multiply by -1.
When it comes to scaling, this is tricky. What you want is to make sure your exported mesh and your exported animation use the exact same scaling. This gets even more tricky since you are also able to animate the scale. Also the default scale (one wz square = 256) is way too big to work with unless you reconfigure blender's depth buffer
When it comes to the formatting:
I'm pretty sure the parser doesn't require fixed widths on the numbers, just integers with whitespace inbetween should suffice, unless you have received more specific information from someone working with the code. (This guess is based on my experience of writing text parsers). Also, the two-tab indentation at the start of the row should be just for readability.
When it comes to number precision, remember: all the numbers have a huge load of decimals, it's just a matter of how you want to print them on screen. What I do in my code is to use the %d formatting tag which formats them as ordinary integers, simply dropping all the decimals when printing. The reason why they are scaled by 1000 and converted into integers is that the game was originally made for the playstation 1 which could only handle integers. The scaling by 1000 is simply a way to get 3 decimals of precision.
I couldn't find out why my .py file didn't work, what blender version do you use? Also, don't be afraid of the lots of extra code it has. All the stuff you're working on is inside the first function, the rest is just formalities you don't have to worry about. The only difference is I use f.write instead of print, so stuff gets written into a file instead of the console. I cut out the essential code for you if you don't get it to work otherwise
Code: Select all
print("exporting file...")
f = open("testfile.ani", 'w', encoding='utf-8') # filename goes here
# start with file header
f.write("/* header format: anim3d [filename] [frames][framerate] [num objects] */\n")
f.write("/* anim line: [frame] [x] [y] [z] [xrot] [yrot] [zrot][xscale] [yscale] [zscale] */\n")
scn = bpy.context.scene
if selectedOnly:
objectList = bpy.context.selected_objects
else:
objectList = bpy.context.visible_objects
numberOfFrames = scn.frame_end+1-scn.frame_start
f.write('ANIM3DTRANS "placeholder.pie" %d %d %d\n' % (numberOfFrames, scn.render.fps, len(objectList)))
f.write("{\n")
# create the data blocks for each animated object
objIndex = 0
for obj in objectList:
if obj.type == "MESH":
f.write('ANIMOBJECT %d "%s"\n' % (objIndex, obj.name))
objIndex += 1
f.write("\t{\n")
for frame in range(scn.frame_start, scn.frame_end+1):
# use frame_set() so that keyed values are updated
scn.frame_set(frame)
pos = obj.location * 1000
rotx = obj.rotation_euler.x * 1000 * 360 / (2*math.pi)
roty = obj.rotation_euler.y * 1000 * 360 / (2*math.pi)
rotz = obj.rotation_euler.z * 1000 * 360 / (2*math.pi)
scale = obj.scale * 1000
f.write("\t\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n" % (scn.frame_current, pos.x, pos.y, pos.z, rotx, roty, rotz, scale.x, scale.y, scale.z))
f.write("\t}\n")
f.write("}\n")
f.close()
-insert deep philosophical statement here-
Re: Custom ANIM3DTRANS animation - working.
Per wrote:Send me your test case and I'll look into it.MaNGusT wrote:Last time I tested it on propulsion model and it didn't work. I just splitted the new model of wheels propulsion onto 3 levels (as oil derrick have) and renamed derrick's anim to correct propulsion name.
Re: Custom ANIM3DTRANS animation - working.
After some serious debugging, I was able to make my script work much better.
I replaced obj.rotation, obj.location and obj.scale with obj.matrix_world.decompose().
This takes parent transformations & stuff into account so you can use all of blender's rigging tools.
One known bug is that if you select non-mesh objects when exporting it will count them into the number of pie levels and the animation will malfunction (it will not, however, create any entries for the non-mesh objects)
I made a small demo mod that turns the derrick into a steam engine just to show off the capabilities of the script.
I replaced obj.rotation, obj.location and obj.scale with obj.matrix_world.decompose().
This takes parent transformations & stuff into account so you can use all of blender's rigging tools.
One known bug is that if you select non-mesh objects when exporting it will count them into the number of pie levels and the animation will malfunction (it will not, however, create any entries for the non-mesh objects)
I made a small demo mod that turns the derrick into a steam engine just to show off the capabilities of the script.
- Attachments
-
- wz_anim_export.py
- (3.75 KiB) Downloaded 217 times
-
- steamengine.wz
- (6.75 KiB) Downloaded 248 times
-insert deep philosophical statement here-
Re: Custom ANIM3DTRANS animation - working.
The texture file names need a .png suffix.MaNGusT wrote:
What is supposed to happen?
Testing it on propulsions is perhaps the worst test case, since these are special cased in the code, and this special casing might override whatever you are doing.
Finally, there is no .ani file? And anim.cfg is not modified? Not sure how this was supposed to work.
Re: Custom ANIM3DTRANS animation - working.
I just gave you model with 3 levels. Animation stuff I used was from oil derrick. Yeah, I created this package inaccuratelely but if you'd fix png typos, add wheels' model to cfg and fix ani file, you'd see that engine shows only 1st mesh from model file. So, no animation either.Per wrote:The texture file names need a .png suffix.MaNGusT wrote:
What is supposed to happen?
Testing it on propulsions is perhaps the worst test case, since these are special cased in the code, and this special casing might override whatever you are doing.
Finally, there is no .ani file? And anim.cfg is not modified? Not sure how this was supposed to work.
Also, could we get a list of models that are special cased?
Re: Custom ANIM3DTRANS animation - working.
Hi Jorzi,
i have blender 2.72 on windows 8.1 and blender 2.69 on Ubuntu.
On both environments has gives the script an error:
will it help to find the cause?
I did not have time to test your custom animated model in wz2100, but i do it in the next days.
Astorian
i have blender 2.72 on windows 8.1 and blender 2.69 on Ubuntu.
On both environments has gives the script an error:
Code: Select all
bpy.context.area.type = 'GRAPH_EDITOR'
Traceback (most recent call last):
File "C:\Program Files\Blender Foundation\Blender\2.72\scripts\modules\bpy_extras\io_utils.py", line 76, in invoke
self.filepath = blend_filepath + self.filename_ext
File "C:\Program Files\Blender Foundation\Blender\2.72\scripts\modules\bpy_types.py", line 593, in __getattribute__
return super().__getattribute__(attr)
AttributeError: 'ExportANI' object has no attribute 'filename_ext'
location: <unknown location>:-1
bpy.ops.object.select_all(action='TOGGLE')
Traceback (most recent call last):
File "C:\Program Files\Blender Foundation\Blender\2.72\scripts\modules\bpy_extras\io_utils.py", line 76, in invoke
self.filepath = blend_filepath + self.filename_ext
File "C:\Program Files\Blender Foundation\Blender\2.72\scripts\modules\bpy_types.py", line 593, in __getattribute__
return super().__getattribute__(attr)
AttributeError: 'ExportANI' object has no attribute 'filename_ext'
location: <unknown location>:-1
Please set your User Preferences' 'Translation Branches Directory' path to a valid directory
will it help to find the cause?
I did not have time to test your custom animated model in wz2100, but i do it in the next days.
Astorian
Re: Custom ANIM3DTRANS animation - working.
My first advice is to install 2.73a, although the error report doesn't really indicate that.
I'm currently installing 2.72 to see if the syntax is somehow different...
I'm currently installing 2.72 to see if the syntax is somehow different...
-insert deep philosophical statement here-
Re: Custom ANIM3DTRANS animation - working.
Downloaded 2.72 and it works fine for me...
How are you running the script?
Your error log says 'ExportANI' object has no attribute 'filename_ext' but it's very clearly defined in the script
How are you running the script?
Your error log says 'ExportANI' object has no attribute 'filename_ext' but it's very clearly defined in the script
-insert deep philosophical statement here-
Re: Custom ANIM3DTRANS animation - working.
I have tested your steam engine model - its seampunky awesome
Now to the script. I am running it two ways. First is to paste from clipboard into the Blenders python console. The second is to install the addon in user preferences (install from file)
Astorian
Now to the script. I am running it two ways. First is to paste from clipboard into the Blenders python console. The second is to install the addon in user preferences (install from file)
Astorian
Re: Custom ANIM3DTRANS animation - working.
There's a third way, you can open the text file in blender's text editor and press alt+p to run it.
Anyway, installing it as an addon should have worked...
Gotta try the script on some other computer, at least on the two computers I usually use it works just fine, although both of them use windows 7 of course...
Anyway, installing it as an addon should have worked...
Gotta try the script on some other computer, at least on the two computers I usually use it works just fine, although both of them use windows 7 of course...
-insert deep philosophical statement here-
Re: Custom ANIM3DTRANS animation - working.
Running the script from Blenders text editor worked like a charm I made only one adjustment:
pos = pos * 100000 -to get the correct values
I like the script really much. The number of object was +1 but i solved that by deleting the camera.
Thank you for the script Jorzi.
Astorian
pos = pos * 100000 -to get the correct values
I like the script really much. The number of object was +1 but i solved that by deleting the camera.
Thank you for the script Jorzi.
Astorian
Re: Custom ANIM3DTRANS animation - working.
The reason for the scale being off is that I like working in 1/10 scale in blender, then upscaling by 10 in WMIT before exporting
When it comes to scaling I think the perfect workflow is not yet achieved, but good to know you got it to work.
The bug with the number of objects could be fixed by doing another for loop over all the objects and counting only meshes, or alternatively removing all non-mesh objects from the list before writing to the file.
When it comes to scaling I think the perfect workflow is not yet achieved, but good to know you got it to work.
The bug with the number of objects could be fixed by doing another for loop over all the objects and counting only meshes, or alternatively removing all non-mesh objects from the list before writing to the file.
-insert deep philosophical statement here-