S4L Model Exporting

Post questions about game models here, or help out others!
User avatar
Seyren
advanced
Posts: 63
Joined: Sat Oct 30, 2010 1:39 pm
Has thanked: 18 times
Been thanked: 9 times

Re: [Request]S4 League Model Exporting

Post by Seyren »

Thank you so much!, this couldn't have been done without you :)

I will keep working on the format since there are more things to do, if anyone wants to join will be great :P, i will provide all i can so it's easy for anyone


Things i found today:

Had a hard time about models with 0 textures since some of them had 0 vertex and had to put a check for the number of vertex >_> (not a big deal, solved o:)

So after that little issue of just adding checks i would say that model chunk is 100% completed :keke: :keke: :D

Image


Thank you all for helping, specially fatduck (:, i really appreciate all the effort you put on this thread, because i'm sure no one else would have been so patient with me and helped me to learn to read formats, it's probably something i will never forget ^^, again, thank you so much.

Now i will keep working on Bones, skinning and animation and it should be done :P, in fact, i have already the bones and their respective parents:

Image

For some reason they appear misplaced, and probably has something to do with global and local coordinates of the items, i'll have to look foward for this and how to fix it by maxscript.

At first i did my own bone script:

Code: Select all

		if object_ID == 1832983249 then
		(
			if((findstring BoneName "Bip") != undefined) or ((findstring BoneName "Bone") != undefined) then
			(	
				if((findstring BoneName "Nub") != undefined) then
				(
					BipDummy = dummy name: BoneName
					BipDummy.parent = (GetNodeByName ParentName)
					BipDummy.transform = Transformation
					BipDummy.transform = BipDummy.transform * (BipDummy.parent.transform)
				)
				else
				(
					BipDummy = bone name: BoneName
					BipDummy.parent = (GetNodeByName ParentName)
					BipDummy.transform = Transformation
					BipDummy.transform = BipDummy.transform * (BipDummy.parent.transform)
				)
			)
Since i don't think there is an indication about if it's a bone or a dummy i just did it by names and it totally did the trick.
After this i looked up this thread ( viewtopic.php?f=16&t=10928 ) and used chrrox's code, but i ended up in the same result, so my conclusion is that is not the bone creating script but something else, probably has something to global and local transformations, that might be the key to solve this, the cheap way to fix it is by using parent's transform but that would wreck maps, so it's discarded.

About skinning with the structure this format has should be a piece of cake, select the bone, and then weight all skins according to that bone, i'll look it up tomorrow :P

About the animations i have no idea yet, i'll get some clues tomorrow i guess, it's too late i'll leave it for now :), heading to sleep

I got it fixed by simply removing the transform of the model in case the parent was BONESYSTEM, except the face and hair, i used local transformation on them and although most of the faces and heads seem to be fine:

Image

Also some ones get screwed.

Image

Actually only this one screws up and don't know why... may be different to other for some reason, the name is 09_male_face.scn, it's attached to the post.

What i used:

Code: Select all

				msh = mesh vertices:Vert_array faces:Face_array name:(ModelName)

				msh.parent = (GetNodeByName ParentName)
				
				if ParentName == "Hair_Bone_Dummy" then
				(
					msh.transform = Transformation
					msh.transform = msh.transform * msh.parent.transform
				)
				else if msh.parent != $BONESYSTEM then
				(
					msh.transform = Transformation
					msh.transform = msh.transform * msh.parent.transform
				)
Since both faces and hairs have hair dummy as parent.

Also, anothe real problem here is that if it's not a biped the skeletons get screwed.

Image

In the screenshot i selected the accessory (the two things on the sides and it's supposed skeleton, totally misplaced.
Maybe there is somewhere a tag that defines it as an acessory of the object and moves it to the center of the skeleton, i don't know yet.

Also i got again with the same problem as the katana:

http://puu.sh/8GUT2.png

It starts naming all the animation names as strings and the ocnverter wrecks up, don't know how to fix this yet, it's inside the rar also, the funny thing is that both have their first animation as "000000", so this may be the answer.

I'll keep looking if i get to know how to fix this :C

files: http://puu.sh/8Htz5.rar

looks like rigging was not as easy as i thought...
Image

i used this:

Code: Select all

			if num_Skin_Bone > 1 then
				(
					max modify mode
					skinMod = Skin()
					addModifier msh skinMod
					select msh
					modPanel.setCurrentObject skinMod
					for i = 1 to num_Skin_Bone do
					(
						
						maxbone = (GetNodeByName Skin_Bones[i])

						skinOps.addBone skinMod maxbone 1
						
						
					)
					
					--Skin_Bones =#()
					--Skin_Data=#()
					--Skin_Vert_Index=#()
					--Skin_Vert_Weight=#()
					print Vert_Array.count
					print Skin_Vert_Index.count
					print 
					
					for b = 1 to Skin_Bones.count do
					(
					
						for s = 1 to Skin_Data.count do
						(
							skinOps.ReplaceVertexWeights skinMod s b Skin_Vert_Weight[s]
						)
					
					)		
					
And goes veryr wrong, specially because most of the clothes don't have the hands on their rigged bone list, which makes everything even more annoying.
User avatar
Seyren
advanced
Posts: 63
Joined: Sat Oct 30, 2010 1:39 pm
Has thanked: 18 times
Been thanked: 9 times

Re: [Request]S4 League Model Exporting

Post by Seyren »

Sorry again for double post, new things i found.

Although the bonesfor the biped work, they only work for the bipeds.

Image

This is not a playable character, so the character is pretty much messed up, i don't know the reason of this.

My skeleton buildup:

Code: Select all

					if isvalidnode (GetNodeByName BoneName) == false then
					(
						BipDummy = bone name: BoneName
						BipDummy.parent = (GetNodeByName ParentName)
						BipDummy.transform = Transformation
						BipDummy.transform = BipDummy.transform * (BipDummy.parent.transform)
					)
This only seems to work on Biped characters, the rest are completely messed up and i don't know why, if someone knows how to fix it would be great >_<

Here is the model of the pic
(the maxscript is attached to the post)

Also, with this maxscript, when i try to get the Asteroid.scn model, the whole 3ds max crashes, and i don't know why since logs are useless when it gets frozen.
Asteroid
Also i don't know how to deal with the skinning either, i tried this:
this is how i parse (according to fatduck's structure, thanks again):

Code: Select all

					num_Skin_Bone = readlong f
					--print "Number of Skin Bones:"
					--print num_Skin_Bone
				
					Skin_Bones =#()
					Skin_Data=#()
					Skin_Vert_Index=#()
					Skin_Vert_Weight=#()
				
					for i = 1 to Num_Skin_Bone do
					(
						BoneSkinName = readstring f
						--print "Bone Name:"
						print BoneSkinName
						append Skin_Bones BoneSkinName
						
						for m = 1 to 16 do readfloat f
						
						num_Skin_Data = readlong f
						--print "Number of Skin Data:"
						--print num_Skin_Data
						append Skin_Data num_Skin_Data
						for i = 1 to num_Skin_Data do
						(
							Vert_Index =readlong f #unsigned
							Weight = readfloat f
							append Skin_Vert_Index Vert_Index
							append Skin_Vert_Weight Weight
						)
how did i apply it:

Code: Select all

				if num_Skin_Bone > 1 then
				(
					max modify mode
					skinMod = Skin()
					addModifier msh skinMod
					select msh
					modPanel.setCurrentObject skinMod
					maxbone
					for i = 1 to num_Skin_Bone do
					(
						maxbone = (GetNodeByName Skin_Bones[i])
						skinOps.addBone skinMod maxbone 1
					)
					bone_id = for k=1 to (skinOps.GetNumberBones skinMod) where skinOps.GetBoneName skinMod k 0 == maxbone.name do exit with k 
					ClassOf ObjectToExportt
					
					for j=1 to Skin_Vert_Index.count do
					(
						skinOps.replaceVertexWeights msh.skin (Skin_Vert_Index[j]+1) bone_id Skin_Vert_Weight[j]
					)
				)
I test skinning with this character set.

This is probably wrong, but i really don't know how to deal with skinning and bones, sorry for not being able to do this by myself... this is my very first format ever and i'm still learning :cry:

I tried a lot fo XentaX methods but none of them worked for me, or i applied them wrong

I know i have asked a lot for help and looks like i'm getting the job done... but i'm seriously learning a lot with this ><

I left here all i could if someone wants to check it out

Thanks in advance
-Seyren
Last edited by Seyren on Wed Jun 04, 2014 4:12 am, edited 1 time in total.
fatduck
mega-veteran
mega-veteran
Posts: 315
Joined: Wed Aug 02, 2006 10:07 pm
Has thanked: 10 times
Been thanked: 94 times

Re: [Request]S4 League Model Exporting

Post by fatduck »

You Bones Initial transformation are WRONG!

Remember the struct I post:

Code: Select all

struct Common_Obj_Properties {
  dword	Object_ID
  char[]	Object_Name
  char[]	Parent_Name
  float		??				//always 0.1
  float[16]	Object_Transform_Matrix		//Object_Version = 0.1 parent base, or 0.2 world base
  float	Object_Version
}
if Object_Version is 0.2, the Object_Transform_Matrix is already a world matrix. No need to consider the parent transformation
No more Fatduck, no more FatImporter, Byebye everyone!
User avatar
shakotay2
MEGAVETERAN
MEGAVETERAN
Posts: 4266
Joined: Fri Apr 20, 2012 9:24 am
Location: Nexus, searching for Jim Kirk
Has thanked: 1142 times
Been thanked: 2241 times

Re: [Request]S4 League Model Exporting

Post by shakotay2 »

Seyren wrote:Also, with this maxscript, when i try to get the Asteroid.scn model, the whole 3ds max crashes, and i don't know why [...]
hehehe, the reason is: you're reading a count of 1,324,679,169 here

Code: Select all

		End_Morph=#()
		for i = 1 to num_Morph_Animation do
		(
			Tick_Time = readlong f
			readlong f
			count = readlong f
after address 0x47891 in asteroid.scn (4 bytes at 0x49571 I guess, didn't investigate further)

By the way: nice progress you've made. Wish I had the energy to learn like you do!
fn AnimMesh should be devided up into some sub functions imho. It's a little bit hard to overview.

Maybe you should place your name in the script as the author.
Tuts: a) Bigchillghost, viewtopic.php?f=29&t=17889
b) Extracting simple models: http://forum.xentax.com/viewtopic.php?f=29&t=10894
"Quoting the whole thing. Would u ever stop this nonsense?"
User avatar
Seyren
advanced
Posts: 63
Joined: Sat Oct 30, 2010 1:39 pm
Has thanked: 18 times
Been thanked: 9 times

Re: [Request]S4 League Model Exporting

Post by Seyren »

Thank you so much for your support, i'm happy that you liked my progress :), but this couldn't have be made without this forum, i owe this community a lot =)

Thanks shakotay2 for telling me why, i thought i had the Mesh reading perfectly, but seems that some of them crash, i will have to study this and see what can be wrong... :(


Okay so i have been a bit busy and i couldn't continue,

I got a recommendation from fatduck to use the skinOps.replaceVertexWeight, and although i tried, i didn't manage to get it correctly.

I changed a bit the structure and this is how it is right now the skinning part.

Code: Select all

					Skin_Bones =#()
					Skin_Data=#()
					Skin_Vert_Index=#()
					Skin_Vert_Weight=#()
						
					num_Skin_Bone = readlong f
					--print "Number of Skin Bones:"
					--print num_Skin_Bone
					
					max modify mode
					skinMod = Skin()
					addModifier msh skinMod
					select msh
					modPanel.setCurrentObject skinMod
					for i = 1 to Num_Skin_Bone do
					(
						BoneSkinName = readstring f
						--print "Bone Name:"
						print BoneSkinName
						append Skin_Bones BoneSkinName
						
						for m = 1 to 16 do readfloat f
						
						
						skinOps.addbone skinMod (GetNodeByName BoneSkinName) 1
						bone_id = for k=1 to (skinOps.GetNumberBones skinMod) where skinOps.GetBoneName skinMod k 0 == (GetNodeByName BoneSkinName).name do exit with k 
						  
						ClassOf msh
						UsedVertex = readlong f
						for j=1 to UsedVertex do
						(
							VertexID = readlong f 
							VertexWeight = readfloat f
							skinOps.replaceVertexWeights msh.skin (VertexID) bone_id VertexWeight
						)
						
					)		
Note that the arrays aren't used, since i was trying with them and without them i didn't remove them at all.

So the thing is:

I get the number of bones that are actually rigged and a for loop starts.

BoneSkinName gets me the bone we are going to skin, and i append it into the array, this is not very useful in this case, and after with

Code: Select all

skinOps.addbone skinMod (GetNodeByName BoneSkinName) 1
						bone_id = for k=1 to (skinOps.GetNumberBones skinMod) where skinOps.GetBoneName skinMod k 0 == (GetNodeByName BoneSkinName).name do exit with k
I get the bone in the skin mod.

At this point everything is okay, works fine, now the hard thing is here:

Code: Select all

						ClassOf msh
						UsedVertex = readlong f
						for j=1 to UsedVertex do
						(
							VertexID = readlong f 
							VertexWeight = readfloat f
							skinOps.replaceVertexWeights msh.skin (VertexID) bone_id VertexWeight
						)
						
					)
Since not all the bones use all vertex, they are specified for each bone, so the first thing i thought was to do a loop with the number of used vertex, after that there are floats and ints, One of them specifies the vertex number and the other one the weight, so i finished doing this way.

Although everything seemed to be fine, This doesn't work.
Also the mesh and the bones have been made before the skinning so everything should be okay, but it's not working

If someone knows how to get this fixed Please let me know, i can't figure it out
Thanks again =) (attached latest plugin)
Last edited by Seyren on Wed Jun 04, 2014 4:13 am, edited 1 time in total.
User avatar
Seyren
advanced
Posts: 63
Joined: Sat Oct 30, 2010 1:39 pm
Has thanked: 18 times
Been thanked: 9 times

Re: [Request]S4 League Model Exporting

Post by Seyren »

Hi guys again, in case someone is following up, i'm still stuck in the same place, i didn't expect this to be so hard... i added a TL;DR at the end in case someone doesn't want to eat the Charles Dickens chapter, this is going to be a big post since it's been a while i don't post so i'm gonna spit it all out.
fatduck wrote:You Bones Initial transformation are WRONG!

Remember the struct I post:

Code: Select all

struct Common_Obj_Properties {
  dword	Object_ID
  char[]	Object_Name
  char[]	Parent_Name
  float		??				//always 0.1
  float[16]	Object_Transform_Matrix		//Object_Version = 0.1 parent base, or 0.2 world base
  float	Object_Version
}
if Object_Version is 0.2, the Object_Transform_Matrix is already a world matrix. No need to consider the parent transformation
I know :(, but thank you i managed to get the bones properly... however...
But the problem goes as follows.
I did the follwing check:

Code: Select all

if ObjVer == 0.2 then
							(		
								newBone.transform = Transformation
							)
							else newBone.transform = Transformation * (newBone.parent.transform)
This goes for bones, However i had to do it the other way around in Meshes(Using local transform when it is 0.2)

Although this is supposed to be working most of the times I got forced to do A LOT OF CHECKS on the flags the name has to see if the model needs local or world transformation, because although i thought the 0.1 or 0.2 should be fine, it isn't :cry:

Let's take a look at a "Monster" and the "Player" bones.

I'm going to use 3 examples, the first one is the Player biped, which is in the character folder.

First, our beloved female shirt (Reminding i'm always the piece of code from the upper part)

Image

The version is 0.1, there is not a single object that is 0.2, so we can say that it works.

Next Let's go to the first monster, the little girl.

Image

Looks fine too, and the bones are 0.2, so everything is fine for now

Howeeeeever if we go to the second monster...

Image

:(

So there are two problems here
Image

The first thing is that that is misplaced and should be up, this item is version 0.1, however, why it doesn't work with this object yet with the rest does?

This bug happens when the checks i did on the mesh transform are applied, but however, if i remove the checks and leave it just to the one above (Because i did extra checks on the mesh aside that one) This one will be right and the others won't

So the only thing it comes to my mind is that there must be something else that defines what is local and global transformation

Also as a curious thing The little girl had Bonesystem's version 0.2, while the Shirt and the grim reaper were 0.1, could this mean something? i don't know, but anyway, the only way to get the characters properly displayed is by removing the transformation matrix if their parent is the BONESYSTEM, so this at first shouldn't bother much..., but this is really weird, even though the world and local matrix are stated all the time i am forced to do a lot of checks because it changes too often.

First i have to check if the object has "oct" on it's name, since this is the collision mesh and must be local transformed so it belongs to the mesh, and this is 0.1!

Then, i have to check if the objects belong to the "blast" helper, since this moves a lot of objects in the map and if i don't apply local transformation the objects go all over the place.

Code: Select all

					else if((findstring msh.parent.name "blast") != undefined) then
					(
						msh.transform = Transformation * (msh.parent.transform)
					)
And some of them are parent of parents, so even if i add this, there are some maps like this one that need to get the local matrix applied, so i would have to check the parent's parent if it's "blast" to get the job done.

Buuut if i do this, the following error appears when i try to run the grim reaper:

Code: Select all

 -- Unknown property: "name" in undefined 

in line 440.

Code: Select all

else if((findstring msh.parent.name "blast") != undefined) then
The reason is probably because there is no parent, i guess, or i don't know,

So summing up, the transformation is screwed no matter how hard i try, but i'm sure the 0.2 and 0.1 floats are not enough.

Some screwed weapons.
Image
Image

Also, i'm sorry, i may be too dumb, but i don't know how to get skinning working, i tried a lot of stuff from differen't people's help, and i didn't get with the right key, i thought this could be done easier than the rest but i'm having a REALLY hard time to do skinning, i'm sorry, i am totally lost here and i don't know anymore what to do >_<, i even rewrote the whole script to make it more organized but didn't do the trick. Also fatduck you told me to check your fatimporter's skinning script but it's encrypted so i can't really check it q_q

I tried my best, but skinning beats me, maybe it's easier than i think, but i ran out of ideas and sources..., crawled from all the skinning scripts, (such as Diablo II for example), but got no results.

I belive It's almost done, but something is missing:

Image
Image

It looks like some vertex don't get skinned, but some of them actually get applied.

The last thing i have is from shakotay2, which helped me to point out the follwing issue:

Code: Select all

                 for i = 1 to Num_Skin_Bone do
				(
					BoneSkinName = readstring f
					--print "Bone Name:"
					print BoneSkinName
					--append Skin_Bones BoneSkinName
					
					MaBone = (GetNodeByName BoneSkinName)
					skinOps.addbone skinMod MaBone 1

					
					for m = 1 to 16 do readfloat f
					
					ClassOf ObjectToExportt
					
					kmax = skinOps.GetNumberBones skinMod                  
					k= 0; 
					while k < kmax do
					(
						k = k + 1; --print k
						BN1 = skinOps.GetBoneName skinMod k 0; BN2 = (GetNodeByName BoneSkinName).name
						format "<%> <%>\n" BN1 BN2
						if BN1 == BN2 then
						(   
							bone_id = k
							k = kmax; print "break k-loop"
						)
					)
					
					ClassOf msh
					num_Skin_Data = readlong f
					--print "Number of Skin Data:"
					--print num_Skin_Data
					append Skin_Data num_Skin_Data
					for i = 1 to num_Skin_Data do
					(
						Vert_Index =readlong f #unsigned
						Weight = readfloat f
						skinOps.setVertexWeights skinMod (Vert_Index+1) bone_id Weight
						--append Skin_Vert_Index Vert_Index
						--append Skin_Vert_Weight Weight
					)
				)
So it turns out that if we check at the log, BN1 and BN2 will never met, however i managed to make some of them get met.
Image
which may mean why some of the vertex are never met, but i am not sure how to handle this.

Found out a minor issue, that although is not a big deal, maybe someone knows how to deal with, it has to do with the materials,
in concrete with the MultiMaterial.

In line 483:

Code: Select all

                                                        if((findstring ObjName "alpha") != undefined) then
							(
								map.opacityMap = bitmaptexture name:("Opacity_"+ObjName)
								map.opacityMap.filename = map.diffuseMap.filename
								
								if((findstring ObjName "alphablend1") != undefined) then
								(
									map.opacityMap.monoOutput = 1
								)
								else if((findstring ObjName "Alphatest") != undefined) then
								(
									map.opacityMap.monoOutput = 1
								)
								
							)
The error is: -- Unknown property: "opacityMap" in undefined, so i guess it doesn't identify it, however this only happens in the map
i gave above, ds5_station (in case you missed it, this one)
Again this is not a great deal, but if someone knows what is wrong it will be great :P


Anyways.

Script redone

To do list:

Skinning
Animation

- Fix the Transformation matrix issue (world and local things,there must be something else that tells what to use rather than a lot of checks, or maybe not...)
Some models with multiple objects here.
- Rewrite the material section into something that doesn't make the program throw errors(mostly multi-material issues).
- Fix the mesh import, since there are still models that are not working, these models are packed here.

The errors are mostly in the material section and in the transformation section (the checks are bad and it might crash since it lacks parents probably), and some others make the whole program crash
(As shakotay2 stated before, there is a point that reads a giant count and it crashes, but i am not sure where the problem is.)



For some reason the script stops working everytime i close 3DS so i have to do some random changes and put it back how it was everytime i start, not sure if i'm the only one, would be good to know if osmeone else experiences this, it's like it doesn't open the file, or i don't know, it's a weird bug because it actually works.

I have to rewrite the whole script in another file and when i finish it works on the previous one, i seriously don't understand this.


Other things i found:

Remember the Katana_a.scn, which had a weird animation pattern?, well i never noticed, but we allways got a unknown flag that always was 0, and turns out that in this one the flag is 1, and then it starts naming all the animation names, this can lead to an unknown loop i don't know yet, i will find it out eventually, but thank god i found out that there was a difference, i was so desperate about this issue!

Anyways, in case that you did it, thank you for reading all of this, and if you have any clues on how to get any things fixed, please, let me know, this thing is going to kill me this way :cry:

And that's it for today, heading to the bed, good night :)

TL;DR: Transformation is a mess and I'm getting really annoyed by Skinning, yet i think it's almost done, but i don't know to be honest.
Last edited by Seyren on Wed Jun 04, 2014 4:14 am, edited 1 time in total.
fatduck
mega-veteran
mega-veteran
Posts: 315
Joined: Wed Aug 02, 2006 10:07 pm
Has thanked: 10 times
Been thanked: 94 times

Re: [Request]S4 League Model Exporting

Post by fatduck »

I don't have any of your problem at all?
Remember the whole format is object based. It means every chunk(ID) is a object, and they can have parent/children.
Your "multi-objects" error is possibly missing some "mesh parent"?
Image


And I follow my format post above, everything (transformation, skinning) just fine!


Image
Image

which MOB file give you mis-aligned bones?
No more Fatduck, no more FatImporter, Byebye everyone!
User avatar
Seyren
advanced
Posts: 63
Joined: Sat Oct 30, 2010 1:39 pm
Has thanked: 18 times
Been thanked: 9 times

Re: [Request]S4 League Model Exporting

Post by Seyren »

Oh god it made me so happy look at that for some reason :mrgreen:

This one.

It may be what you mean, some missing parents, it would make sense, but i can't really tell... Specially because i have to apply local when is 0.1 on bones, however i have to apply world when it's a mesh, also i don't know how you check it, but if the parent is the BONESYSTEM the only way i have to apply it properly is by applying NO transformation matrix.

I made sure every single object appeared, even if it was a helper (for helpers, 0.1 is world transformation, since theuy don't have parent at all, not even the .scn header dummy)
It's also curious about the helpers because they have 2 transformation matrix.

If we apply the one from the common_obj_properties:

Image

the position actually looks right, it's where the "ball" spawns, so everything is okay, however the size of the helpers doesn't seem to be that okay.

Image

alpha_limited_area03 helper from /background/ds5_station.scn

this is supposed to be the lower part of the map, if you fall, you are supposed to die, so i thought this should be a big helper that cover the whole floor.

What happens if i apply the matrix from the chunk?
To my surprise:

Image

The helper suddenly fits the floor of the map!, so this means the final transformation matrix should be the postion and rotation of the common_obj_properties, yet the size of the second transformation matrix, this is only an assumption, though, or maybe i am getting all the stuff wrong again...



The reason my mesh importer fails though is probably at the texture part, because the structure is supposed to be 2 strings with a fixed size of 1024 bytes and two long bytes that tells you the start and how many faces does it take in case it's a multi texture (in case it's a single texture, the first long will be 0 and the next one will be the same than the number of faces, that's why it tells you the number of faces TWICE every time we import a mesh, but if we take a multi texture object this number will be different)

And well, to do this i did the following loop:

Code: Select all

NumTex = readlong f
			print "Number of Textures:"
			print NumTex
			
			Texture_array=#()
			Bump_array=#()
			FaceStart_array=#()
			FaceCount_array=#()
			
			for i = 1 to NumTex do
			(
				tex = readstring f
				print tex
				fseek f -1 #seek_cur
				for i = 1 to (1024 - tex.count) do readbyte f
				append Texture_Array tex
				
				tex = readstring f
				print tex
				fseek f -1 #seek_cur
				for i = 1 to (1024 - tex.count) do readbyte f
				append Bump_Array tex
				
				Face_Start = readlong f
				--print Face_Start
				append FaceStart_array Face_Start
				Face_Count = readlong f
				--print Face_Count
				append FaceCount_array Face_Count
			)
since Maxscript is very limited and doesn't have many tools about this i'm afraid (or at least i haven't found anything on the internet or other forums) this was the only way to do the loop correctly, however i'm not very confident about this loop and it probably fails hard at some meshes, making it crash.

Aside from that, i will keep looking about the transformation thing, but i can't really find a solution for this, since i made spawn all the objects even as helpers to make sure not a single parent was missing...

And well, the skinning almost looks done, but as i said before some of the vertex don't get skinned and it wrecks up, i'll keep looking at this...
Image
an almost, yet screwed Skinning.

Attached again, this time it displays helpers.
Last edited by Seyren on Wed Jun 04, 2014 4:15 am, edited 1 time in total.
fatduck
mega-veteran
mega-veteran
Posts: 315
Joined: Wed Aug 02, 2006 10:07 pm
Has thanked: 10 times
Been thanked: 94 times

Re: [Request]S4 League Model Exporting

Post by fatduck »

You are right that "grimreaper.scn" doesn't follow objVer(0.1/0.2), all bones are world transformation.
Are there any models don't follow this objVer!?

For your world/parent transformation problem.
If the object didn't have parent then the transformation is simply world transformation, right?
so you can code it like this:

Code: Select all

obj.transform = common_obj_transform
if (objVer == 0.1) and (obj_parent_String != "" ) then (
 obj.parent = (getNodeByName obj_parent_String)
 obj.transform *= obj.parent.transform
)
In scn, every chunk is an object, and objects have transform (It represent "something" in the world/game coordinate)

For the "Helper" things, ID = 0x25ADF0D1.(I am no sure is it really a helper, I just define it as helper).
There are some data I havn't decoded, maybe that contains area/size/effect etc.
But definately not transformation matters! Since
1> In 3dsMax, helpers object had no volume, the "size" of the helper is for visualisation only.
2> the scale part of "alpha_limited_area03" is [1,1,1](from common_obj_transform), I can't see any reason will fit your scene!?

Lastly, what do you mean have 2 transformation matrix?


this is ds5_station max file (3dsmax 2009) and a log for your reference.
I still using objVer to set the transformation without any problem!?
No more Fatduck, no more FatImporter, Byebye everyone!
User avatar
Seyren
advanced
Posts: 63
Joined: Sat Oct 30, 2010 1:39 pm
Has thanked: 18 times
Been thanked: 9 times

Re: [Request]S4 League Model Exporting

Post by Seyren »

fatduck wrote:You are right that "grimreaper.scn" doesn't follow objVer(0.1/0.2), all bones are world transformation.
Are there any models don't follow this objVer!?

For your world/parent transformation problem.
If the object didn't have parent then the transformation is simply world transformation, right?
so you can code it like this:

Code: Select all

obj.transform = common_obj_transform
if (objVer == 0.1) and (obj_parent_String != "" ) then (
 obj.parent = (getNodeByName obj_parent_String)
 obj.transform *= obj.parent.transform
)
In scn, every chunk is an object, and objects have transform (It represent "something" in the world/game coordinate)

For the "Helper" things, ID = 0x25ADF0D1.(I am no sure is it really a helper, I just define it as helper).
There are some data I havn't decoded, maybe that contains area/size/effect etc.
But definately not transformation matters! Since
1> In 3dsMax, helpers object had no volume, the "size" of the helper is for visualisation only.
2> the scale part of "alpha_limited_area03" is [1,1,1](from common_obj_transform), I can't see any reason will fit your scene!?

Lastly, what do you mean have 2 transformation matrix?


this is ds5_station max file (3dsmax 2009) and a log for your reference.
I still using objVer to set the transformation without any problem!?

If you remember your structure:

Code: Select all

struct Helper {               //?? Object_ID = 0x25ADF0D1
  Common_Obj_Properties
  float[16]   ??
}
I think those 16 floats are a transformation matrix :oops:

I think The first transformation matrix positions the object, and the second rotates it and scales it, since they are not "actually" helpers, depends on how you want to take it, they are spawn positions from the game, places where if you step on it you die, so they can't be just little cubes

So i thought using the scale and rotation from the second matrix aaand looks "more accurate"
Image
but still screwed since probably in the engine Y => Z and Z => Y, but makes more sense.
Image

tested on city_highway.scn

But i'll leave it the way it is since this is not important at all... and the results are more messy, so we can just pass it out.

About other transformations, i tried your code and it works great, thank you ^^, i applied it this way on meshes:

Code: Select all

				if ((msh.parent) != $BONESYSTEM) then
				(
					msh.transform = Transformation
					if (ObjVer == 0.1) and (ParentName != "" ) then 
					(
						msh.transform *= msh.parent.transform
					)
				)
Since if i don't check about the bonesystem the shirt and stuff gets screwed.

I'm going to list the models that don't get the position applied properly:

Image
09_male_face
This face looking up.

The parent is Hair_Bone_Dummy, and this is one of the few faces that don't get the position right, because others do.
Image
07_male_face

Another thing that gets not properly positioned:

Image
07_male_skirt
The mesh is WELL POSITIONED BUUUUT the bones are right here:
Image
You can imagine that more or less they have the same shape
log:http://puu.sh/96IbZ/53dd46bcc8.txt
the bones are called:

07_Male_L_skirt_bone1
07_Male_L_skirt_Dummy1
07_Male_R_skirt_bone1
07_Male_R_skirt_Dummy1

So you don't have to kill yourself while searching on the log :c

Another similar file:
01_female_spine00

Image
This is the skirt from the bottom part of the shirt, and you can see the bones are completely messed.


Now it's weird because grimreaper.scn gets an error in the scythe object, because it doesn't identify the transformation, i'll fix it later
if i manage to.
log: http://puu.sh/96HBm/bdb8555ff5.txt

here are all the ones that are messy that i found:

I added aditional ones that are not actually screwed, but since what is screwed is the accessories and not the base shirt i guess is needed to check if everything is okay.

http://puu.sh/96Jq9/a1a5e75801.zip

Added aside:
One face that gets positioned correctly
07_male_muffler which probably won't work since it has a different animation pattern, but it belongs to the same shirt than the 07_male_skirt, in case you want to test.

Updated script :) Thank you again for your help
:keke:
Last edited by Seyren on Wed Jun 04, 2014 4:15 am, edited 1 time in total.
User avatar
shakotay2
MEGAVETERAN
MEGAVETERAN
Posts: 4266
Joined: Fri Apr 20, 2012 9:24 am
Location: Nexus, searching for Jim Kirk
Has thanked: 1142 times
Been thanked: 2241 times

Re: [Request]S4 League Model Exporting

Post by shakotay2 »

Finally I managed to get your script logging the morphing part of taserplasma.scn without errors.
(Hah, really exhausting, I'm curious how fatduck solved this.)

Since my changes depend on absolute addresses for this one file I'll send the script per PM, Seyren.
(I'm too tired now to search for flags which could help to get rid of the addresses.)

Here's the last logged chunk from file's end:
"32. start: 0x40f2a -----------------------------------"
CHUNK: 135305464 (MESH)
ObjName: Plane77_alphablend2_nocull (Sword_Wea_Dummy)

so the changes seem to be ok.
Tuts: a) Bigchillghost, viewtopic.php?f=29&t=17889
b) Extracting simple models: http://forum.xentax.com/viewtopic.php?f=29&t=10894
"Quoting the whole thing. Would u ever stop this nonsense?"
fatduck
mega-veteran
mega-veteran
Posts: 315
Joined: Wed Aug 02, 2006 10:07 pm
Has thanked: 10 times
Been thanked: 94 times

Re: [Request]S4 League Model Exporting

Post by fatduck »

Updated the Morph_Animation part:

Code: Select all

    dword	num_Morph_Animation			//??
    struct Morph_Animation {
      dword	Tick_Time
      dword	count1
      struct Anim_Data1 {
        dword	 Index
        float[3] value
      }
      dword	count2
      struct Anim_Data2 {
        dword	Index
        word[2]	??					//?
        float	value
      }
    }
You should be able to phasing the animation without any errors now!

For the "grimreaper.scn" and "01_female_spine00.scn" etc, I can't found and special/difference from others scn!? :x
No more Fatduck, no more FatImporter, Byebye everyone!
User avatar
shakotay2
MEGAVETERAN
MEGAVETERAN
Posts: 4266
Joined: Fri Apr 20, 2012 9:24 am
Location: Nexus, searching for Jim Kirk
Has thanked: 1142 times
Been thanked: 2241 times

Re: [Request]S4 League Model Exporting

Post by shakotay2 »

well, the asteroid caused me some headache. Though I manged to get rid of absolute addresses I had to introduce some file specific conditions (if count==x) which make the script hard to read:

Code: Select all

fn horrible startA j jMax= (	
	    nmaAddr= ftell f
		print ("num_morph_anims at "+"0x"+bit.intAsHex(nmaAddr) as string)
		num_Morph_Animation = readlong f
		format "No of Morph Anims: %\n" num_Morph_Animation
		if  num_Morph_Animation > 1000 then num_Morph_Animation = 0 ; -- for debugging purposes only
		End_Morph=#()
		if num_Morph_Animation==0 then cnt=0 else cnt=1
		count = 0
		for k = 1 to num_Morph_Animation do	-- k was i before, a bug, but maxscript didn't mind...
		(
			if k==1 then Tick_Time = readlong f
				else if cnt==0 then  Tick_Time = readlong f
					else if count==9 or count==14 then  Tick_Time = readlong f		-- asteroid only
			cnt = readlong f			
			count = readlong f
			format "%. cnt % %\n" k cnt count
			if cnt !=0 then if count !=jMax then count =jMax		-- for debug only
			if cnt==0 then cntx=cnt else cntx=count				
			if count==9 or count==14 then				-- asteroid only
			for i = 1 to count do (
				a = readlong f; b = readshort f; c = readshort f
				d = readfloat f; 	format "% % %  %\n" a b c d
			)
			else if count==143 or count==58 then				-- asteroid only
			for i = 1 to count do (
				a = readlong f; b = readfloat f; c = readfloat f
				--format "% % %\n" a b c
			)
			else			
			for i = 1 to cntx do (
				a = readfloat f; b = readfloat f; c = readfloat f
				d = readlong f; 	--format "% % % - %\n" a b c d
			)
			if cnt !=0 then ( e = readlong f; print e; print)
		)
		if cnt !=0 then (			
			if j==1 then (
				delta = nmaAddr-startA; print delta
				delta -= 3; g_delta = delta	-- global var (required for j==2)
			)
			print ("before skip "+"0x"+bit.intAsHex(ftell f) as string+", delta= "+g_delta as string)
			if count==9 or count==14 then fseek f -16#seek_cur	-- asteroid only
				else (
					if j !=jMax then fseek f g_delta#seek_cur		-- skipping 79/95 bytes in taserplasma.scn	
					else fseek f -4#seek_cur
				)
		)
)
Though the complete script does a corrrect scan of asteroid.scn now I guess there's a much better solution?

btw:I used Seyren's script where I added my "horrible function" and a modified call:

Code: Select all

			for i = 1 to NumAnim do (
				addr = ftell f -- used in horrible() to calculate delta
				print ("startA: 0x"+bit.intAsHex(addr) as string)
				tmp = readlong f; tmp = readlong f; fseek f -8#seek_cur
				--format "%. tmp: %" i tmp
				if (i==1) or tmp!=0 then Anim() -- parameter Flag removed
				addr = ftell f
				if (addr<fsize) then horrible addr i NumAnim
			)
		)	
		
		--OBJECT LOCATION
		else if object_ID == 632156369 then
		(...
asteroid.JPG
You do not have the required permissions to view the files attached to this post.
Tuts: a) Bigchillghost, viewtopic.php?f=29&t=17889
b) Extracting simple models: http://forum.xentax.com/viewtopic.php?f=29&t=10894
"Quoting the whole thing. Would u ever stop this nonsense?"
fatduck
mega-veteran
mega-veteran
Posts: 315
Joined: Wed Aug 02, 2006 10:07 pm
Has thanked: 10 times
Been thanked: 94 times

Re: [Request]S4 League Model Exporting

Post by fatduck »

If just want to phase the file without animation. Use these codes:

Code: Select all

       num_Trans_Animation = readlong f
       fseek f (num_Trans_Animation*0x10) #seek_cur
       num_Rotate_Animation = readlong f
       fseek f (num_Rotate_Animation*0x14) #seek_cur
       num_Scale_Animation = readlong f
       fseek f (num_Scale_Animation*0x10) #seek_cur
       num_Visibility_Animation = readlong f
       fseek f (num_Visibility_Animation*0x8) #seek_cur

       num_Morph_Animation = readlong f
       for i = 1 to num_Morph_Animation do (
        tm = readlong f
        Cnt1 = readlong f
        fseek f (Cnt1*16) #seek_cur
        Cnt2 = readlong f
        fseek f (Cnt2*12) #seek_cur
       )--end for Manm
And It seems like only "character" and "weapons" files need to consider parent transform!? All "monster", "slaughter" are already in world transformation.

asteroid.scn should look like this:
You do not have the required permissions to view the files attached to this post.
No more Fatduck, no more FatImporter, Byebye everyone!
User avatar
Seyren
advanced
Posts: 63
Joined: Sat Oct 30, 2010 1:39 pm
Has thanked: 18 times
Been thanked: 9 times

Re: [Request]S4 League Model Exporting

Post by Seyren »

fatduck wrote:If just want to phase the file without animation
I'm planning to get animations too, but right now i can't manage to parse the mesh properly, so i can't proceed to animations until i make sure the mesh is properly imported :(

I have been looking for unknown values and there are 2 values we have been ignoring all this time, they are the first two values that we read once we start the mesh chunk.

In case of our asteroid, this is most of the time the values of those two:

Code: Select all

Unknown Values: [8] [1045220557]
I checked other scns and the second value is ALWAYS 1045220557. This may be a "Texture header", the other is unknown.

The value of the first one goes from 8 to 105, and then goes down to 8, and up to 105, it switches between those two numbers.
Grim Reaper for example is 33, 4, 12... can't really tell the value.

However, ALL the weapons have this value in 0, when the monsters don't, so we can't get anything out of here right now.

To my surprise, at the moment that the program crashes (but doesn't freeze the program tho) the value is [32873], i really don't know what it means

AAAaaand i fixed the asteroid, i'm retarded, i'm sorry:

Image

I was reading vw in scale, messing everything up, sorry for bothering this much :cry:
fatduck wrote: And It seems like only "character" and "weapons" files need to consider parent transform!? All "monster", "slaughter" are already in world transformation.
Because of this i'm forced to do the follwing:

Code: Select all

if ((msh.parent) != $BONESYSTEM) then
				(
					msh.transform = Transformation
					if (ObjVer == 0.2) and (ParentName != "" ) then 
					(
						msh.transform *= msh.parent.transform
					)
				)
If you remember you gave me this condition, however it was if ObjVer == 0.1, if i let it in 0.1, maps and characters work fine, but slaughters and weapons are messed up, and if i change it to 0.2 it goes the other way around, you didn't really find any differnce aside the 0.1 and 0.2? because there must be something else that determines it, i can't really tell :c

Things yet to solve:

-Transformation Matrix
-Skinning
-Material application

Skinning:

Code: Select all

-- Unable to convert: undefined to type: <node>
Apparently MaBone = (GetNodeByName BoneSkinName) doesn't get any Bone from the scene and this crashes
Materials(Multi)

Code: Select all

-- Unknown property: "opacityMap" in #Multi/Sub-Object:chaser_ophelia_lock_alphablend1_nocull_Map(Standard:Material #146, Standard:Material #147)
Doesn't locate opacityMap and well, i guess this material coding is really bad, if someone else knows a better way to apply materials let me know :scaredy:
By the way it crashes with this line of code: multimap.opacityMap.monoOutput = 1 (in Line 538)

These are the only 3 things that are wrecking up the converter, Transformation for Position, Skinnin for crashing some models (like Lilith) and MultiMaterial issues, i'll bring some news of what i have done in a few hours

Attached latest version

Again thanks for helping and i'm sorry for doing such mistake :cry:
Last edited by Seyren on Wed Feb 18, 2015 10:27 pm, edited 1 time in total.
Post Reply