Page 7 of 8

Re: Star Wars The Force Unleashed - PC Version .z files

Posted: Sat Jan 29, 2011 12:14 am
by reappper
so is the tool ready? can we now take models out of tfu????

Re: Star Wars The Force Unleashed - PC Version .z files

Posted: Sat Jan 29, 2011 3:13 am
by reappper
any body? so is the tool ready yet? and be so kind as to tell how to use it too

Re: Star Wars The Force Unleashed - PC Version .z files

Posted: Sat Jan 29, 2011 3:26 am
by Tosyk
reappper wrote:any body? so is the tool ready yet? and be so kind as to tell how to use it too
Yes, in this post.

And please, don't dubleposting here.
Szkaradek123 wrote:Blender importer for models from Star Wars The Force Unleashed .
(Blender 249 and Python 2.6.)
Hi, Szkaradek123. Please tell me more detail how to automatically apply textures, because when i jointing (ctrl+J, maybe?) all objects and then importing in 3ds max (trough the psk), i gets only one material.

Re: Star Wars The Force Unleashed - PC Version .z files

Posted: Sun Jan 30, 2011 12:25 am
by reappper
ok so I manage to get the models out of tfu now have we work on getting the rigs out? like the bones?

Re: Star Wars The Force Unleashed - PC Version .z files

Posted: Sun Jan 30, 2011 8:39 am
by Ryan7259
You wait for the experts to make a script.

Re: Star Wars The Force Unleashed - PC Version .z files

Posted: Tue Feb 01, 2011 5:50 pm
by UberBlack
I am posting this link because I have had many requests for the tutorial I have made about extracting a Storm Trooper from Star Wars The Force Unleashed. Your suggestions and comments would be greatly appreciated.

http://uberblack3d.com/articles/storm-t ... -tutorial/

Re: Star Wars The Force Unleashed - PC Version .z files

Posted: Wed Jun 15, 2011 1:15 am
by reappper
so is this project dead or what? have we finally got bones no?? tired of waiting

Re: Star Wars The Force Unleashed - PC Version .z files

Posted: Tue Mar 20, 2012 11:49 pm
by revelation
The Force Unleashed plugin for Noesis has been updated: http://oasis.xentax.com/index.php?content=plugins

Fixes a bug with gto models and adds support for the .animations files.

If i get the chance i will try and put together documentation to supplement rogueclarkey's description earlier in the thread.

Have fun.

Re: Star Wars The Force Unleashed - PC Version .z files

Posted: Wed Mar 21, 2012 12:56 am
by Tosyk
revelation wrote:The Force Unleashed plugin for Noesis has been updated
thank you revelation

Re: Star Wars The Force Unleashed - PC Version .z files

Posted: Wed Mar 21, 2012 1:16 am
by UberBlack
revelation wrote:The Force Unleashed plugin for Noesis has been updated: http://oasis.xentax.com/index.php?content=plugins

Fixes a bug with gto models and adds support for the .animations files.

If i get the chance i will try and put together documentation to supplement rogueclarkey's description earlier in the thread.

Have fun.
It's been a long time coming.. thanks for letting me test it.

Re: Star Wars The Force Unleashed - PC Version .z files

Posted: Fri Jun 08, 2012 12:41 am
by revelation
Well i was asked about how to interpret the information within the .animations file, and i had not gotten around to coming back to this thread, so i guess i shal do a quick and dirty explaination of things. Hopefully it will be enough to get those interested started in looking into the data (assuming i can express it clearly enough).

The animations files are structured into the following sections:

Code: Select all

HEADERS
DATA
-JOINT_KEYFRAME_DATA
-JOINT_KEYFRAME_INFO
-JOINT_KEYFRAME_INDICES
-NAME_DATA
The HEADERS section can consist of up to 4 different headers:

Code: Select all

struct R2D2pack_HEADER
{
	// 0x00
	char   fileTag[8]   <format = hex>; // 'R2D2pack'
	uint32 fileVersion;
	uint32 dataSize     <format = hex>;
	// 0x10
};

struct PACK_HEADER
{
	// 0x00
	uint32 dataTag           <format = hex>; // 'pack'
	uint32 unknown0x14[2]    <format = hex>; // [1] resource crc
	uint32 dataFlags         <format = hex>;
	// 0x10
	uint32 unknown0x20[4]    <format = hex>;
	// 0x20
};

struct R2D2mult_HEADER
{
	// 0x00
	char   fileTag[8]   <format = hex>; // 'R2D2mult'
	uint32 fileVersion;
	uint32 dataSize     <format = hex>;
	// 0x10
};

struct ANIM_HEADER
{
	// 0x00
	uint32 dataTag           <format = hex>; // 'mina'
	uint32 unknown0x04[3]    <format = hex>; // [1] resource crc
	// 0x10
	uint32 unknown0x10       <format = hex>;
	uint32 jointCount;
	float  duration;
	uint32 unknown0x1C       <format = hex>;
	// 0x20
	uint32 unknown0x20       <format = hex>;
	uint32 unknownSize0x24   <format = hex>; // sub-header/data alignment size?
	uint32 dataSize          <format = hex>; // animation name offset?
	uint32 unknown0x2C       <format = hex>;
	// 0x30
	uint32 jointInfoOffset   <format = hex>; // joint data?
	uint32 jointFramesOffset <format = hex>; // keyframe data?
	uint32 unknownSize0x38   <format = hex>; // base data offset?
	uint32 nameOffset        <format = hex>; // name offset?
	// 0x40
};
The PACK_HEADER follows the R2D2pack header if it is present.

The ANIM_HEADER follows the R2D2mult header.

The data sizes in the R2D2pack and R2D2mult headers is used to access the name strings in a slightly peculiar way in the code. Using the the values starting from the begining of the data blocks that follow these headers actually takes you to the end of the string. But if you read the byte prior to this point, add 2, and subtract it from this end offset you can obtain an offset to the beginning of the string that specifies the name of the animations file and the animation pack file (.r2a) respectively.

The ANIM_HEADER is treated as somewhat of a split data structure in the code, the second portion starting at the location of the unknownSize0x24 value. This value contains an offset from this point to the beginning of the data section that follows. In all of the files i have investigated so far this has always been 0x1C, but my assumption is that the data section may have alignment requirements (on a 32-byte boundary?) and this value would contain the offset to the aligned position of the data should it not follow directly after the ANIM_HEADER. But for the most part i have not seen this needed, so i mention it solely to be complete.

The ANIM_HEADER jointInfoOffet and jointFramesOffset are relative to the beginning of the JOINT_KEYFRAME_DATA that follows the header.

The layout of the JOINT_KEYFRAME_DATA relies heavily on the flags specified in the JOINT_KEYFRAME_INFO structure that follows it, as does the JOINT_KEYFRAME_INDICEIS. So i will describe that first:

Code: Select all

struct JOINT_KEYFRAME_INFO
{
	// 0x00
	uint32 jointHash    <format = hex>; // crc
	uint32 framesOffset <format = hex>; // keyframe indices?
	uint32 dataOffset   <format = hex>;
	uint16 framesCount  <format = hex>;
	uint16 formatFlags  <format = hex>; // flags?
	// 0x10
};
This section is a list of ANIM_HEADER.jointCount structure that define the data layout of each joints keyframe data and indices. Joints do not have to be present for every one that is in the model file. Since the animation it initialized with the base pose transforms, these joint will just not be modified.

The framesOffset and dataOffset values are relative to the JOINT_KEYFRAME_INDICES and JOINT_KEYFRAME_DATA sections respectively. The jointHash is a simple crc value based on the actual joint name from the model file.

The real important piece of information in this structure are the formatFlags. They specify whether or not the keyframe data is bit packed or not, whether it is 32-bit floats or 16-bit short values, whether position or rotation data is even present, which components of the position and rotation are valid, as well as what form the keyframe indices are in (8-bit byte, 16-bit short, 32-bit float).

The formatFlags can be assumed to have this format:

Code: Select all

union FORMAT_FLAGS
{
	// 0x00
	uint16 flags;
	struct
	{
		uint16 posLayout : 3;
		uint16 posFlag   : 1;
		uint16 rotLayout : 3;
		uint16 rotFlag   : 1;
		
		uint16 dataFlag  : 2;
		uint16 rotFormat : 2;
		uint16 posFormat : 2;
		uint16 idxFormat : 2;
	};
	// 0x02
};
The idxFormat determines the data size of the individual elements of the joints keyframe indices and can have the following values:

Code: Select all

3 - 8-bit frame index
2 - 16-bit frame index
else - 32-bit float frame time (in seconds)
Animations are 30 frames per second, so for the non-float frame index values simply divide by 30 to get the float time in seconds, or the reverse by multiplying the float frame times by 30 to get the fram index.

The posFormat and rotFormat specify the data type of the position and roation values (if present):

Code: Select all

3 - bit-packed data (big endian)
2 - 32-bit float data
1 - 16-bit short data
16-bit data values are normalized by dividing by 32767.

The dataFlag specifies if position, rotation, or both of them are present:

Code: Select all

3 - position and rotation data present
2 - rotation data present
1 - position data present
The rotFlag and posFlag specify how to interpres the rotLayout and posLayout respectively;

Code: Select all

0 - the Layout values specify fully vector/quaternion layout formats
1 - the Layout values are treated as a 3-bit mask for each of the x,y,z components to determine which of them are present in the data
When the rotFlag or posFlag bits are not set (0) then the respective Layout values can be:

Code: Select all

posLayout:
2 - (3) 16-bit short values (x,y,z)
1 - (3) 32-bit float values (x,y,z) - NOTE: when the dataFlag specifies rotations are present and the rotLayout is also 32-bit float, an extra float for the w component is present for alignment purposes.

rotLayout:
3 - (3) 16-bit short values (x,y,z) -> w = 1 - sqrt(x^2 + y^2 + z^2)
2 - (4) 16-bit short values (x,y,z,w)
1 - (4) 32-bit float values (x,y,z,w)
The Layout values should match the Format values for their respective components.

When the rotFlag or posFlag are set the rotLayout and posLayout are 3 separate bit values each for the x, y, and/or z component that is present in the data.

Code: Select all

The bits are ordered:
210
xyz
With 0 being the least significant bit, etc.

When data is bit-packed the rot- and pos- Flag bits should be set if the dataFlag specifies they are present.

Reading the data from the JOINT_KEYFRAME_DATA section requires the information above. When the data is not bit-packed the process if fairly straight forward. Rotation and position components are packed ones after the other: pos0,rot0,pos1,rot1,...etc. Assuming the dataFlag specifies they are present.

The skeleton for an animation is initialized using the base pose information from the model. If data is not specified for a joint based on the flags information, then the values are not overwritten during processing.


- Bit Packed Data -

Bit-packed data complicates things slightly as the data is tightly packed into a big-ending ordered bit stream, where the components of the position and rotation components can be variable bit sizes which are specified in the data itself.

If position data is present the first 4 bytes are a 32-bit floating point scaling value for the position information.

Following this are up to (18) bytes of data used to specify the base values and bit-sizes for the position and rotation xyz components. The presence of these values is controlled by the xyz bits in the posLayout and rotLayout respectively.

The values are used to specify the base values and bit sizes of each component of the position and rotation values.

The order is as follows:

Code: Select all

[basePosX : 16], [basePosY : 16], [basePosZ : 16], [bitSizeX : 8], [bitSizeY : 8], [bitSizeZ : 8], [baseRotX : 16], [baseRotY : 16], [baseRotZ : 16], [bitSizeX : 8], [bitSizeY : 8], [bitSizeZ : 8]
These are specified for both the position and rotation data if specified as present. The 'base' values are 16-bits each, the 'bitSize' values are 8-bits each (3 * 2-bytes + 3 * 1-byte == up to 9 bytes each for position and rotation == up to 18-bytes).

The individial components will not be present if the corresponding bit is not set in the respective Layout values from the joint data flags.

So if bit 0 is not set for posLayout, then the z-component of the positions are not present (basePosX, basePosY, bitSizeX, bitSizeY). The rotation values are handled in the same manner using the respective flags and format information.

Following this information is framesCount number of bit packed values for the components specified as being present. The bit stream is read a big-endian data in x,y,z order for position then rotation for the compoents that are valid. The bitSize values specify the number of bits to read for each component from the stream.

The final value for each component is calculated using the following function:

Code: Select all

((packedValue - (0xFFFF >> (0x11 - bitSize))) + baseValue) * valueScale

packedValue == value read from bit-stream
bitSize == bit size for the component being read
baseValue == base value for the component being read
valueScale == scale for the component type being read (for positions this is the 32-bit float at the beginning of the data, for rotations this is 1/32767 to normalize into the range 0...1)
All the values are treated as signed 16-bit values.

Since only 3 components of the rotation are specified the w value is found through standard normalized quaternion methods.



Well that was simply a brain dump of how to interpret the animation data. i am not entirely sure if it will make sense to anyone as i have written it, so feel free to ask for clarification on anything if needed.

Hope it helps.

Re: Star Wars The Force Unleashed - PC Version .z files

Posted: Fri Jun 08, 2012 10:13 am
by Hamster Jovial
Thanks a lot revelation

Re: Star Wars The Force Unleashed - PC Version .z files

Posted: Sat Feb 01, 2014 1:37 pm
by luke9511
UberBlack wrote:Image

Quick Render in Maya
quick question if thats ok how did you get it in a T-pose? when i import they are A-pose

Re: Star Wars The Force Unleashed - PC Version .z files

Posted: Sun Aug 16, 2015 12:59 am
by turkgamer
Hi, i want to translate game. How can i do this?

Re: Star Wars The Force Unleashed - PC Version .z files

Posted: Mon May 08, 2017 6:50 am
by iambosh
so we ever figure out how to edit the xml.z files?