New animation system is finally in

Improving the artwork in Warzone2100 - not for mod discussions
User avatar
MaNGusT
Art contributor
Posts: 1152
Joined: 22 Sep 2006, 10:31
Location: Russia

Re: New animation system is finally in

Post by MaNGusT »

After looking in docs, I found that that is not quite useful to apply global event to a whole model by replacing the animated model. Also, it's a bit complicated to control models in seperate pies.
In my head it looks something like this - each level has an optional list of animation events that can be triggered in any time. So, we could split our models into levels and animate them easily, we could also add some type of gfx animation, like smoke after firing or dust while moving.
Keeping all the data in one file is a good idea, imho.
As for the global events, there are only two that come to my mind. Buildings must have construction and dying animations, while units must have only dying global event. For those events would be better to create separate pies.
Image
User avatar
MaNGusT
Art contributor
Posts: 1152
Joined: 22 Sep 2006, 10:31
Location: Russia

Re: New animation system is finally in

Post by MaNGusT »

Per, what're the units used here? I saw that you used time=60 and frames=25, how can I calculate it for my usage? :)
Also, does a new firing animation replace the hard-coded recoil animation if used on weapons? same question for dying animation. :)
Last edited by MaNGusT on 26 Jan 2018, 12:42, edited 1 time in total.
Image
User avatar
MaNGusT
Art contributor
Posts: 1152
Joined: 22 Sep 2006, 10:31
Location: Russia

Re: New animation system is finally in

Post by MaNGusT »

Well, spent some time to test animation in latest master build. And... can't get it working :(
I made a test mod that adds all the 3 events to viper, light wheels and light cannon(gun+turret). The animobject data I copied from derrick's pie(just for testing to see if it works).
In game nothing happens, events don't play the animations. In log I see only these:

Code: Select all

info    |11:41:48: [openLoadFile:148] file mods/autoload\components.wz could not be opened: Insecure filename
info    |11:41:48: [openLoadFile:148] Assert in Warzone: frame.cpp:148 (!"unable to open file"), last script event: '<none>'
components.wz
test mod
(59.62 KiB) Downloaded 436 times
What am I doing wrong? (
Image
Forgon
Code contributor
Code contributor
Posts: 298
Joined: 07 Dec 2016, 22:23

Re: New animation system is finally in

Post by Forgon »

MaNGusT wrote:In game nothing happens, events don't play the animations. In log I see only these:

Code: Select all

info    |11:41:48: [openLoadFile:148] file mods/autoload\components.wz could not be opened: Insecure filename
info    |11:41:48: [openLoadFile:148] Assert in Warzone: frame.cpp:148 (!"unable to open file"), last script event: '<none>'
components.wz
What am I doing wrong? (
My hypothesis is that you are using Windows and, through an oversight by the developers, the forward slash after "mods" becomes part of the filename Physfs tries to access instead of a directory separator. Forward slashes are not allowed in Windows filenames, which causes the error.
User avatar
MaNGusT
Art contributor
Posts: 1152
Joined: 22 Sep 2006, 10:31
Location: Russia

Re: New animation system is finally in

Post by MaNGusT »

moved mod from autoload to global mod dir and tried to launch with cmd option, got same error (
If I put files without the archive in main wz dir like /base/components/...etc, I get no errors but animation still doesn't work :|
same errors with 3.2.3 build...
btw, I use win10 x64.
Image
Forgon
Code contributor
Code contributor
Posts: 298
Joined: 07 Dec 2016, 22:23

Re: New animation system is finally in

Post by Forgon »

MaNGusT wrote:[...] I get no errors but animation still doesn't work :| [...]
Are you sure that you put all files in the right place and the instructions of your mod were executed?

I use a different operating system, but would like to help you debugging. How could I test whether the animation works or not? I loaded your mod without problems and during games all cyborgs properly moved their legs.
User avatar
MaNGusT
Art contributor
Posts: 1152
Joined: 22 Sep 2006, 10:31
Location: Russia

Re: New animation system is finally in

Post by MaNGusT »

Forgon wrote: How could I test whether the animation works or not?
MaNGusT wrote:I made a test mod that adds all the 3 events to viper, light wheels and light cannon(gun+turret). The animobject data I copied from derrick's pie(just for testing to see if it works).(
it must play ugly(oil derrick's) animation if moves, fires or dies.
If I did all things right then at least viper body will play animations, idk were propulsions and weapons added in code to support event animation or not.
Image
User avatar
Berg
Regular
Regular
Posts: 2204
Joined: 02 Sep 2007, 23:25
Location: Australia

Re: New animation system is finally in

Post by Berg »

This is from doc written by per.
PIE 2
=====

Description
-----------

The PIE format is a custom model format created by Pumpkin.

It has gone through two iterations since the original commercial release. PIE2 was
used until version 2.3 and is still supported. PIE3 is the latest version and is
described here.

The big change between PIE2 and PIE3 is that values are floating point in the latter,
whereas values in PIE2 are scaled up 256 times.

Format
------

### PIE

> PIE 3

The first line specifies the version number (3) and MUST read like that.

### TYPE

> TYPE X

This indicates the type of the file through a hexadecimal combination of flags. The following values can be used:
* 0x00200 - Reserved for backward compatibility.
* 0x01000 - Specifies that the model should not be stretched to fit terrain. For defensive buildings that have a deep foundation.
* 0x10000 - Specifies the usage of TCMask feature (Replacement for the old team coloration methods. Check ticket #851).

### TEXTURE

> TEXTURE 0 page-7-barbarians-arizona.png 0 0

This sets the texture page for the model. The second value gives you the filename of the texture page, which must end with ".png". The PIE file MUST contain exactly one TEXTURE line. The filename MUST only contain [a-zA-Z0-9._\-]. The file name SHOULD start with "page-NN-" for correct handling of dynamic texture replacement. The first, third and fourth values are ignored, and should be zero.

### NORMALMAP

> NORMALMAP 0 page-7-barbarians-arizona_normal.png 0 0

Optional. As above, but this sets the normal map texture page for the model.

### SPECULARMAP

> SPECULARMAP 0 page-7-barbarians-arizona.png 0 0

Optional. As above, but this sets the specular map texture page for the model.

### EVENT

> EVENT type filename.pie

An animation event associated with this model. If the event type is triggered, the model is
replaced with the specified model for the duration of the event. The following event types are defined:

* 1 - Active event. What this means depends on the type of model. For droids this means movement,
while for power generators it means they are linked to a power source.
* 2 - Firing. The model is firing at some enemy.
* 3 - Dying. The model is dying. You (almost) always want to make sure animation cycles for this model is set to 1
for the specified model - if it is zero, it will never die!

### LEVELS

> LEVELS 1

This gives the number of meshes that are contained in this model. Each mesh can be animated separately in ANI files.

### LEVEL

> LEVEL 1

This starts the model description for mesh 1. Repeat the below as necessary while incrementing the value above as needed.

### SHADERS

> SHADERS 2 vertex.vert fragment.vert

Optional. Create a specific shader program for this mesh. The number '2' is not parsed but should always be '2'.

### POINTS

> POINTS n

This starts a list of vertex coordinates (points) that is ''n'' lines long. ''n'' MUST be less than or equal to 768. This is followed by the list of points.

#### Point

> -4.0 4.0 8.0

Each point MUST be on a separate line and MUST be indented with a tab. It MUST contain exactly 3 floating-point values in the order ''x y z''. Y denotes "up".

### POLYGONS

> POLYGONS n

This starts a list of polygon faces. ''n'' MUST be less than or equal to 512.

#### Polygon

> 200 3 3 2 1 0.82 0.78 0.186 0.78 0.199 0.82

Each polygon MUST be on a separate line and MUST be indented with a tab.

It is made out of following sections:

> Flags Points Texture_coordinates

''' Flags '''
* +200 means the polygon is textured. Each entry in POLYGONS MUST have this flag.
* No other flags are supported. Note that if you want a surface to display something on both sides, make two polygons, one for each side.

''' Points '''
* First number is the number of points for this polygon. Each entry MUST be between 3 and 6 points, however using triangles only is STRONGLY RECOMMENDED. At some later point, only triangles will be supported, and other polygons will be tessellated.
* Then follows a list of indexes to the points list.

''' Texture coordinates '''
* Give texture coordinates for each point. There are two texture floating-point coordinates for each point, hence this list should be twice as long as the number of points. The coordinate is given in UV 0.0-1.0 range.

### CONNECTORS

> CONNECTORS n

This starts a list of connectors for the model. These are used to place other components against this one. For each line following this, you should indent by a tab, then give the x, y, and z coordinates of a connector. Z denotes "up." The meaning of each connector is special and hard-coded. Some models do not need connectors.

The exact purpose of each connector is hard-coded for each model type. TODO: List these purposes here.

### ANIMOBJECT

> ANIMOBJECT time cycles frames

If the mesh is animated, this directive will tell the game how to animate it. The values
are the total animation time (of all frames), the number of cycles to render the animation,
where zero is infinitely many, and finally the number of animation frames that follows.

#### Animation frame

> frame xpos ypos zpos xrot yrot zrot xscale yscale zscale

Each animation line starts with the serially increasing frame number, followed by
three (x, y, z) vectors, one for position, one for rotation, and one for scaling.

If the scaling values are negative, they indicate that the animation is a legacy
keyframe animation sequence. Do not use this in future content.
Just bringing it to for this topic to move forward.
I did change the xanaX mech warriors to use the new format I was wondering if any stats needed to be change to allow firing animation or do we just make a similar pie.
User avatar
Berg
Regular
Regular
Posts: 2204
Joined: 02 Sep 2007, 23:25
Location: Australia

Re: New animation system is finally in

Post by Berg »

Per wrote:> CONNECTORS n

This starts a list of connectors for the model. These are used to place other components against this one. For each line following this, you should indent by a tab, then give the x, y, and z coordinates of a connector. Z denotes "up." The meaning of each connector is special and hard-coded. Some models do not need connectors.

The exact purpose of each connector is hard-coded for each model type. TODO: List these purposes here.
Any update on this proposal.
Some sequence or list needs to be published as to what each connector relates too per model for example smoke on the factories (do note they only have one connector) they need 3 one for each exhaust for each upgrade.
Random timing for each too would be good

Anyway good stuff Berg
User avatar
Xenon
Trained
Trained
Posts: 62
Joined: 18 Sep 2009, 13:06
Location: Russia

Re: New animation system is finally in

Post by Xenon »

I read this topic and realized that a new animation system was added, but no one can create a new animation because there are no tools for this. Or maybe there are already tools to create a new animation? If so, please give a link to such tools. Particularly interested in the ability to transfer the animation model to the game from a program like 3ds max
Sorry for my english
Jorzi
Regular
Regular
Posts: 2063
Joined: 11 Apr 2010, 00:14

Re: New animation system is finally in

Post by Jorzi »

Hi
I tried animating the factory fan using a blender script, but since the fan is slightly tilted, animation will be around all three axes.
Unfortunately I can't get the Euler angles right, so the fan ends up being wobbly :P . Also, my version of WMIT flips the model on the x axis when exporting to pie, which certainly doesn't help. Overall, getting the coordinate system right is pure hell.
Please help :)
Attachments
blfact0.pie
(82.79 KiB) Downloaded 342 times
ImageImage
-insert deep philosophical statement here-
cybersphinx
Inactive
Inactive
Posts: 1695
Joined: 01 Sep 2006, 19:17

Re: New animation system is finally in

Post by cybersphinx »

Jorzi wrote: 17 Feb 2019, 20:58my version of WMIT flips the model on the x axis when exporting to pie
I had a fix for that, no idea if it still helps though: https://github.com/cybersphinx/WMIT/com ... eb33fa795a
We want information... information... information.
User avatar
MaNGusT
Art contributor
Posts: 1152
Joined: 22 Sep 2006, 10:31
Location: Russia

Re: New animation system is finally in

Post by MaNGusT »

there is the mirror button in wmit :D afair, this bug caused by importing improper obj. I used a workaround to fix this but do not remember how(
Image
Jorzi
Regular
Regular
Posts: 2063
Joined: 11 Apr 2010, 00:14

Re: New animation system is finally in

Post by Jorzi »

Code: Select all

import bpy
import math

bl_info = {
    "name": "WZ2100 Animation Export",
    "description": "Exporting animation for PIE models",
    "author": "Jorzi, Astorian",
    "version": (1, 1),
    "blender": (2, 79, 0),
    "location": "File > Export > Warzone 2100 Animation (.ani)",
    "warning": "", # used for warning icon and text in addons panel
    "wiki_url": "https://forums.wz2100.net/viewtopic.php?f=5&t=12053"
                "Scripts/My_Script",
    "tracker_url": "",
    "support": "COMMUNITY",
    "category": "Animation"
    }

def write_ani_file(context, filepath, selectedOnly):
    print("exporting file...")
    f = open(filepath, 'w', encoding='utf-8')
    # start with file header
    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 %d %d\n' % (numberOfFrames, 0, numberOfFrames))
            objIndex += 1
            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, rot, scale = obj.matrix_world.decompose()
                pos = pos * 100000 #scaled so that 1 blender unit = 100 warzone units
                rot = rot.to_euler('XYZ')
                rotx = math.degrees(rot.x) * 1000
                roty = math.degrees(rot.y) * -1000
                rotz = math.degrees(rot.z) * 1000
                f.write("\t\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%.1f\t%.1f\t%.1f\n" % (scn.frame_current - scn.frame_start, -pos.x, -pos.y, pos.z, rotx, roty, rotz, scale.x, scale.y, scale.z))
            

    f.close()
    return {'FINISHED'}


# ExportHelper is a helper class, defines filename and
# invoke() function which calls the file selector.
from bpy_extras.io_utils import ExportHelper
from bpy.props import StringProperty, BoolProperty, EnumProperty
from bpy.types import Operator


class ExportANI(Operator, ExportHelper):
    """This appears in the tooltip of the operator and in the generated docs"""
    bl_idname = "export_test.some_data"  # important since its how bpy.ops.import_test.some_data is constructed
    bl_label = "Export .ani (Warzone 2100)"

    # ExportHelper mixin class uses this
    filename_ext = ".ani"

    filter_glob = StringProperty(
            default="*.ani",
            options={'HIDDEN'},
            )

    # List of operator properties, the attributes will be assigned
    # to the class instance from the operator settings before calling.
    use_setting = BoolProperty(
            name="Selected objects only",
            description="Exclude unselected mesh objects, non-mesh objects will always be excluded",
            default=True,
            )

#    type = EnumProperty(
#            name="Example Enum",
#            description="Choose between two items",
#            items=(('OPT_A', "First Option", "Description one"),
#                   ('OPT_B', "Second Option", "Description two")),
#            default='OPT_A',
#            )

    def execute(self, context):
        return write_ani_file(context, self.filepath, self.use_setting)


# Only needed if you want to add into a dynamic menu
def menu_func_export(self, context):
    self.layout.operator(ExportANI.bl_idname, text="WZ2100 animation file (.ani)")


def register():
    bpy.utils.register_class(ExportANI)
    bpy.types.INFO_MT_file_export.append(menu_func_export)


def unregister():
    bpy.utils.unregister_class(ExportANI)
    bpy.types.INFO_MT_file_export.remove(menu_func_export)


if __name__ == "__main__":
    register()

    # test call
    bpy.ops.export_test.some_data('INVOKE_DEFAULT')
Unfortunately .py files are not currently allowed in the forum atm, but here is a blender 2.79 script file for writing the animation data to a text file.
Just import a model and make sure that 1 blender unit equals 100 warzone units. Animate the objects, you can use any rigs and parenting you want. The script simply takes the object transformation for each frame and writes it out as a line.
ImageImage
-insert deep philosophical statement here-
User avatar
Berg
Regular
Regular
Posts: 2204
Joined: 02 Sep 2007, 23:25
Location: Australia

Re: New animation system is finally in

Post by Berg »

Jorzi wrote: 19 Feb 2019, 13:29 Unfortunately .py files are not currently allowed in the forum atm, but here is a blender 2.79 script file for writing the animation data to a text file.
Added the ext .py.
Post Reply