Re: Custom ANIM3DTRANS animation - working.
Posted: 24 Feb 2015, 01:13
yesJorzi wrote:With frame animation do you mean texture animation
Strategy by Design
https://forums.wz2100.net/
yesJorzi wrote:With frame animation do you mean texture animation
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.
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
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))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.
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()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.
The texture file names need a .png suffix.MaNGusT wrote:
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.
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