GTA5: Animation files (YCD)

GTA:V Modding with ZModeler3 discussion.
Post Reply
User avatar
Oleg
Site Admin
Posts: 13971
Joined: Fri Feb 06, 2004 3:54 am
Contact:

GTA5: Animation files (YCD)

Post by Oleg »

Got some cute update for ZModeler3 released.
Image
Since I've been making this all on a laptop device, I can't make a video guide, so a brief forum guide topic will be added later.

It took a really long even though the main decode work was done years ago - you've seen animations in OpenIV already. Another major step was done in CodeWalker that is able to decode YCD files to XML. To my surprise I haven't found a "YCD from XML" recreation feature there, as this would make the task much easier (an XML import/export).

Well, using the native YCD files was always a preferred choice for me, so I pinned to this approach.

YCD files can be imported with automatic parts/bones assignment. Playback is quite natural. A set of YCD features can not be mapped onto ZModeler's available tools set, so some data is ignored and lost on import. This is still a subject to decide whether this is an important data or not. Additionally, I've added user-defined options in animations and tracks, so they can hold some unknown data for later use. In particular, user-defined options are utilized for audio binding.
Image

Features list:
  • Import of full YCD file or individual clips from a package.
  • Export of full YCD file only (several annimations in one YCD in a single export run). One clip (replacement/injection mode) will be added later.
  • Animation files do not contain bone names, so the model file (YFT) have to be loaded first, so you get a properly named tracks.
  • Animations use hashes all around, there is no any text references there except the clip name itself. Some hashes are resolved to object names from the scene, some have evaluated hashes coded in the filter already. However, you might have some settings that will still contain hash instead of a text representation. Hash could be either "Hash_2345DF01" or "0x2345DF01" (leading Hash_ and 0x are equivalent).
  • Animation events (key frame with event and event number in ZModeler) are used to insert properties and tags onto animation. Meanwhile, only tags (a property at some key time) is available, general-purpose properties are currently ignored. See a section about "Tags" below.
  • Animation quality and performance is not optimized. The file size of animation can increase because ZModeler does not utilize all possible packing and optimization of animation data, only some techniques are used. Performance can suffer too, as natural game's animation are made "low-resolution" with additional "high-resolution" (e.g. feet, hands and fingers movements are additional hi-res animation). ZModeler merges them together into a single high-resolution animation.
  • Key frames could be interpolated, it's not a must to create smooth curves with a dozen of key frames. Use available ZModeler animation features to create curves, exporter will do the rest.
  • Root (skeleton base) animation is also imported/exported as a "[root]" track. However, importer disables it by default on import, so playback will not affect skeleton position, only bones are animated. Most of ped's movement animations do use root animation (e.g. walking, start and stop of walking).
  • Some unknown properties are moved into animation's (and track's) User-defined options. So far I've seen them on "SKEL_ROOT" bone and unknown bone with ID "0x3cd2". The latest one has no animation keys, just property assigned.
My laptop dies of overheat while game is loading, so I run in-game test for just few seconds only and, in particular, have no idea how to test ped animations.

Video guides
Video guides on YCD Animations (by C.Stewart Gaming).

(1/3). Importing animations to ZModeler:
https://www.youtube.com/watch?v=F8rQAU0VR3I

(2/3). Exporting animations from ZModeler:
https://www.youtube.com/watch?v=eFewZ-M7fqE

(3/3). Create a GTA 5 Animation using ZModeler3
https://www.youtube.com/watch?v=jxWz4wcYM0E
lol200004
Posts: 4
Joined: Tue Nov 01, 2016 2:30 am

Re: GTA5: Animation files (YCD)

Post by lol200004 »

It took a really long even though the main decode work was done years ago - you've seen animations in OpenIV already. Another major step was done in CodeWalker that is able to decode YCD files to XML. To my surprise I haven't found a "YCD from XML" recreation feature there, as this would make the task much easier (an XML import/export).
Hi Oleg, the latest version of CodeWalker supports import and export ycd.xml via RPF Explorer
Join the CodeWalker Discord server at and check #release section: https://discord.gg/BxfKHkk
Source code on github: https://github.com/dexyfex/CodeWalker
User avatar
Oleg
Site Admin
Posts: 13971
Joined: Fri Feb 06, 2004 3:54 am
Contact:

Re: GTA5: Animation files (YCD)

Post by Oleg »

Hmm.. this could help me several months ago while I was decoding the .ycd and testing my guess and thoughts on some details. So far, I expect ZModeler-generated .ycd files to work fine. However, I still need to consider whether some unknown properties are really important or not. I see most of them named as "unknown" inside generated XML file, so I suppose CodeWalker guys don't know the purpose of this data.
lol200004
Posts: 4
Joined: Tue Nov 01, 2016 2:30 am

Re: GTA5: Animation files (YCD)

Post by lol200004 »

Thanks for your hard work. In the #animations section of the CW discord there are some clarifications regarding character animation and some unknows hashes.
To play animations for characters in the game, you can use the Scripthook and use it in conjunction with the Simple-trainer in which you can play animation for ped and yourself
Dromsis
Posts: 10
Joined: Thu Nov 11, 2021 7:18 am

Re: GTA5: Animation files (YCD)

Post by Dromsis »

Hi Oleg.
Is there a way to create a UV animation thank to zmodeler.
I've tried several thing, but unfortunately nothing has worked.
thanks!
User avatar
Oleg
Site Admin
Posts: 13971
Joined: Fri Feb 06, 2004 3:54 am
Contact:

Re: GTA5: Animation files (YCD)

Post by Oleg »

what do you mean by UV animation? there are models with UV animating on them, but this is generally a "slideshow" animation: the texture is a set of rendered frames and uv "window" jumps from one frame to another.
Dromsis
Posts: 10
Joined: Thu Nov 11, 2021 7:18 am

Re: GTA5: Animation files (YCD)

Post by Dromsis »

Seem pretty clear for.
I mean, insteed of animating a 3d part whe animate a texture.

I got a new question.
I've made an animation from scratch an everything work well.
But a struggled with making COLISION move with my 3d part. The collision linked to the 3d moving part seem to be ignore by the game, but it still visible in Open4 or CodeWalker.
Any idea or suggestion?
User avatar
Oleg
Site Admin
Posts: 13971
Joined: Fri Feb 06, 2004 3:54 am
Contact:

Re: GTA5: Animation files (YCD)

Post by Oleg »

This was discussed here:
viewtopic.php?f=31&t=13792
pnwparksfan
Posts: 55
Joined: Wed Feb 14, 2018 7:24 pm

Re: GTA5: Animation files (YCD)

Post by pnwparksfan »

I have been doing some research to figure out how to add custom animation events to be used with the HAS_ANIM_EVENT_FIRED native in scripts.

Per the native documentation, it says:

Code: Select all

Some events are instantaneous (so this will only return true once). Others may have duration, which means that this function may continuously return true for a range of values.
I have figured out how to make custom instantaneous events which can be detected by a script using the [tags] track with events; however, I don't think zmodeler supports setting an event that lasts for more than a single frame. Is there currently a way to do this? If not, could it be added? There basically needs to be a way to set events turning on and then turning off. For an example of a default R* animation that does this, see the "exit" clip in "anim@amb@clubhouse@boss@male@.ycd". It has an event "block_interrupt" which remains on from 0% to 80% phase of the animation duration.

Note that the event label should be "VisibleToScript:Event" in user defined options for an animation to make it visible to this native.
User avatar
Oleg
Site Admin
Posts: 13971
Joined: Fri Feb 06, 2004 3:54 am
Contact:

Re: GTA5: Animation files (YCD)

Post by Oleg »

Code: Select all

//
// Since tags could be a "lasting event" (continuous) - they have
// start time and end time. Becasue of this issue, tags "duration"
// can overlap. Even more, identical tags events could overlap, 
// causing troubles detecting where each of tag starts and where it
// ends.
// To prevent problems, I accumulate tags/events data in array that
// contains evaluated event ID, event number (positive number is a
// start of tag, negative is the end of tag). Tags could have no
// negative event number, meaning its start/end times are matching.
// Once tags are accumulated, I create a Track and try to put all
// the tags that can be added with NO COLLISION. Tags with collisions
// over created tags are not added onto the track. Instead, I create
// another "[tags]" track and put them there. I continue until all
// tags are laid down with no overlaps. In the worst scenario, each
// tag will have its own track.
//
// Tag collision is when it's start point or end point appears inside
// a range of another lasting-tag that has the same eventID and 
// event number. Lasting tag is determined by availability of closing
// time tag (negative event number) on a time frame after the opening
// time tag (it's opening time tag is the nearest one).
// 
// So the algo to place the new tag is to check the "start time" and
// "end-time" points for in-range hit. The in-range hit is detected
// as follows: locate the same eventID and negative event number on
// the right of insertion point; if it's found, locate the nearest
// opening tag time for it going from found tag to the left. Then 
// compare start-end tag time range whether the insertion point is in.
If I get it right, you can create a "lasting" events on [tags] track by setting an event number on an event. A positive number to indicate a start of the event and the matching negative number to set the end of the event. Literally: "Lasting tag is determined by availability of closing time tag (negative event number) on a time frame after the opening time tag".

P.S. "Per the native documentation, it says..." what native documentation are you referring to?
pnwparksfan
Posts: 55
Joined: Wed Feb 14, 2018 7:24 pm

Re: GTA5: Animation files (YCD)

Post by pnwparksfan »

Oleg wrote: Mon Jan 22, 2024 9:38 am If I get it right, you can create a "lasting" events on [tags] track by setting an event number on an event. A positive number to indicate a start of the event and the matching negative number to set the end of the event. Literally: "Lasting tag is determined by availability of closing time tag (negative event number) on a time frame after the opening time tag".
OK, I have given this a try and it seems to work. I did have to update to the latest version for this to work at all; in 3.2.1 it gives an error when trying to export with negative event values. Would be nice if there were a way to visually distinguish between "on" and "off" events on the track, or even between different event IDs. Maybe eventually there could be a different visualization with a line for each event ID used in the [tags] track, with on/off indicated.
Oleg wrote: Mon Jan 22, 2024 9:38 am P.S. "Per the native documentation, it says..." what native documentation are you referring to?
Some additional information was found last year about natives, I will DM you.
Post Reply