[QUESTION] ZMD File parse

This forum is for Graphics and 3D objects discussions.

Moderators: osRose dev team, ospRose dev team, osiRose dev team, Moderators

Forum rules
Client Editing is a delicate subject. osRose and osiRose will not support or use any Client Editing tool or results as a standard. So you are free to experiment, test, and develop there on Client Editing, but at your own risk

[QUESTION] ZMD File parse

Postby cssvb94 on Mon Oct 20, 2008 9:47 am

Hi guys,

Slowly working on a full editing solution for the 3D models for ROSE in Blender3D.
ZMS files are imported and exported correctly now and the next milestone is importing/exporting ZMD (bones) for the models.
Thanks to all guys from RoseDevSource.com reading ZMD file is OK.
For each bone we have vector3d offset coordinates in format (x,y,z) and rotation quaternion in format (w, x, y, z).
According the explanation on the website each bone position is determined by relative offset from it's parent.
A guy from the ROSE forums, provided 3DS Max import plugin for ZMS/ZMD/ZMO, so I'm using it as additional reference during the Blender plug-in scripting.
As working model I took ALLIGATOR_BONE.ZMD file.
The first read bone is:
  1. Bone ID#: 0
  2. Parent bone ID#: 0
  3. Name: b1_pelvis
  4. Offset: Vector(0.0000, -0.0062, 0.7296)
  5. Rotation: Quaternion(0.0000, -0.7071, -0.0000, -0.7071) 


Having this information the real position and rotation for this bone point should be:
  1. Position = Parent.Pos + ( Offset * Quaternion )

For the first bone there is no parent, so the Parent.Pos vector is Vector(0.0, 0.0, 0.0):
  1. Position = Offset * Quaternion = Vector(0.0000, -0.0062, 0.7296) * Quaternion(0.0000, -0.7071, -0.0000, -0.7071)
  2. Position = Vector(0.729586, 0.006200, 0.000000)

Which looks reasonable, but when I checked in 3DS Max with the same ZMD file the result is totally different:
  1. Position = Vector(0.0000, 0.7296, -0.0062)


I'm fighting with that for almost 4 days and still the same - different result.
If there is somebody here that can help I'll appreciate it.
I have a .... ,hm, strong knowledge in vector mathematics.
And .... I'm ashamed :oops:
Help guys .... :D
Last edited by cssvb94 on Fri Oct 24, 2008 1:12 pm, edited 1 time in total.
aka Spark (ZMSViewer, Blender ZMS plug-in, RoseOnline ZMS/ZMD/ZMO to SMD and vice versa converter)
User avatar
cssvb94
Pomic
Pomic
 
Posts: 109
Joined: Thu May 01, 2008 7:22 am
Location: GMT +1

Re: [QUESTION] ZMD File parse

Postby Sethanye on Mon Oct 20, 2008 11:25 am

its because rose has rotation issues serious ones, ummm i dont remember which it was exactly, but we dealt with that in the map editor, ill ask maxxon for sure then ill drop a post again.
~ Learning Flash ~ Anyone Know Any Good Tutorial DVDs? ~
Image
"Come Into My Dream, Let Me Show You Where I've Been.
Its You And Me I've Seen, Let Me Tell You What I Mean."
User avatar
Sethanye
Neko Chan
Neko Chan
 
Posts: 2603
Joined: Fri Jan 18, 2008 11:23 am
Location: ~ Resident Graphics Artist ~

Re: [QUESTION] ZMD File parse

Postby Sethanye on Mon Oct 20, 2008 12:03 pm

ok im too lazy to explain so just posting the whole convo about it, ull sort it out lol


  1. I say:
  2.  
  3. hey what was that rotation issue in rose
  4. I say:
  5.  
  6. like instead of w x y z it was what w x z y?
  7. I say:
  8.  
  9. oh cool osrose crashed
  10. I say:
  11.  
  12. General Error
  13. SQL ERROR [ mysqli ]
  14.  
  15. Too many connections [1040]
  16.  
  17. An sql error occurred while fetching this page. Please contact an administrator if this problem persists.
  18. Lt says:
  19.  
  20. it was xyzw
  21. Lt says:
  22.  
  23. why?
  24. Lt says:
  25.  
  26. the interpreation of xyz depends on how you render it
  27. I say:
  28.  
  29. spark has problems with rotation in bones, im pretty sure thats the issue
  30. I say:
  31.  
  32. i dont mind helping spark lol
  33. Lt says:
  34.  
  35. mData.TransMatrix *= Matrix.RotationQuaternion(
  36. new Quaternion(
  37. ((ZSCSubEntryFlagRotation)flag).f4,
  38. ((ZSCSubEntryFlagRotation)flag).f3,
  39. ((ZSCSubEntryFlagRotation)flag).f2,
  40. ((ZSCSubEntryFlagRotation)flag).f1
  41. ));
  42. Lt says:
  43.  
  44. this how we do it
  45. Lt says:
  46.  
  47. but
  48. I say:
  49.  
  50. if show u his problem if osrose wasnt dead lol
  51. I say:
  52.  
  53. he basically has this issue, vector (1,2,3) but in max he gets vector (3,1,2) or something
  54. Lt says:
  55.  
  56. we do this at the end
  57. Lt says:
  58.  
  59. mData.TransMatrix *= Matrix.RotationX((float)Math.PI / -2);
  60. Lt says:
  61.  
  62. yeah.
  63. Lt says:
  64.  
  65. its because nomally you have an xyz coordinate system where y is the height and z the depth
  66. Lt says:
  67.  
  68. and in rose z is the height and y the "depth"
  69. I say:
  70.  
  71. yeah cos rose is made by a bunch of drunk idiots lol
  72. Lt says:
  73.  
  74. so you can either read the data in different to compensate that
  75. Lt says:
  76.  
  77. or just render the crap and rotate it 90° later to make it look right
  78. I say:
  79.  
  80. well since he needs to get a result in max, you have to read it upside down
  81. Lt says:
  82.  
  83. doesnt matter. i was reading in the internet about that and rose way is commonly used as well
  84. I say:
  85.  
  86. cos he isnt rendering an end result
  87. I say:
  88.  
  89. yeah but rose are still idiots lol
  90. Lt says:
  91.  
  92. the problem is still you have to apply the different read methods to all
  93. I say:
  94.  
  95. well im sure spark isnt stupid lol
  96. Lt says:
  97.  
  98. if you flip the vertex data readin to match in max
  99. I say:
  100.  
  101. he did make a converter after all
  102. Lt says:
  103.  
  104. the rotation is fucked up if you dont apply your changes there as well
  105. Lt says:
  106.  
  107. well for the converter you dont need to look at the actual data
  108. I say:
  109.  
  110. well if osrose comes back ill just post him the whole convo and let him deal with it
  111. Lt says:
  112.  
  113. lol ok
  114. Lt says:
  115.  
  116. maybe someone ddoses it lol
  117. I say:
  118.  
  119. idk lol
  120. I say:
  121.  
  122. too many connections can mean that
  123. I say:
  124.  
  125. cos i was pretty much alone at that time
  126. I say:
  127.  
  128. ooo new error lol
  129. I say:
  130.  
  131. lmao
  132. I say:
  133.  
  134. MySQL server has gone away [2006]
  135. I say:
  136.  
  137. mysql went out to lunch
  138. Lt says:
  139.  
  140. narose is firewalling whole contries now lol
  141. Lt says:
  142.  
  143. countries*
  144. I say:
  145.  
  146. lol
  147. Lt says:
  148.  
  149. they dont need players from malaysia or china because of the high amount of hackers and zulie sellers within that players coming from there so they blocked some ip ranges
  150. Lt says:
  151.  
  152. and ppl complain already lol+
  153. I say:
  154.  
  155. proxy lol
  156. I say:
  157.  
  158. they cant ban the whole world
  159. Lt says:
  160.  
  161. psst. they dont know about proxies lol
  162. Lt says:
  163.  
  164. dont tell em or they will ban everyone except their local network lol
  165. I say:
  166.  
  167. lol
  168. I say:
  169.  
  170. and play them selves?
  171. Lt says:
  172.  
  173. and they removed my rant thread
  174. Lt says:
  175.  
  176. i dunno
  177. Lt says:
  178.  
  179. i did only tell the truth about their incompetence lol
  180. I say:
  181.  
  182. lol
  183. I say:
  184.  
  185. i got the main page up, but now it stopped loading at all
  186. I say:
  187.  
  188. ddos for sure
  189. Lt says:
  190.  
  191. like
  192. Lt says:
  193.  
  194. mr burns apes would do a better job in coding as you
  195. Lt says:
  196.  
  197. I say:
  198.  
  199. lmao
  200. I say:
  201.  
  202. did mr burn have apes?
  203. I say:
  204.  
  205. **rubs head**
  206. Lt says:
  207.  
  208. yeah. in some episoded he has
  209. Lt says:
  210.  
  211. episodes
  212. Lt says:
  213.  
  214. for storywriting or so
  215. I say:
  216.  
  217. oh yeah i remember
  218. Lt says:
  219.  
  220. at least krusty has some
  221. I say:
  222.  
  223. crusty has one
  224. I say:
  225.  
  226. that acting monkey
~ Learning Flash ~ Anyone Know Any Good Tutorial DVDs? ~
Image
"Come Into My Dream, Let Me Show You Where I've Been.
Its You And Me I've Seen, Let Me Tell You What I Mean."
User avatar
Sethanye
Neko Chan
Neko Chan
 
Posts: 2603
Joined: Fri Jan 18, 2008 11:23 am
Location: ~ Resident Graphics Artist ~

Re: [QUESTION] ZMD File parse

Postby lmame on Mon Oct 20, 2008 12:07 pm

Well technically speaking it seems your way is fine.
I made the same calculations and I find your result.

Though, do you have the 3DS plugins? Is it a script so we can look at the source or it's build?

@Sethanye:
There is a maintenance on the Mysql servers right now :lol:
The world is full of love and peace ^_^
Image
User avatar
lmame
Admin
Admin
 
Posts: 8997
Joined: Mon Aug 06, 2007 4:42 pm
Location: July City

Re: [QUESTION] ZMD File parse

Postby Sethanye on Mon Oct 20, 2008 12:08 pm

lol ok, still the lag sucks
~ Learning Flash ~ Anyone Know Any Good Tutorial DVDs? ~
Image
"Come Into My Dream, Let Me Show You Where I've Been.
Its You And Me I've Seen, Let Me Tell You What I Mean."
User avatar
Sethanye
Neko Chan
Neko Chan
 
Posts: 2603
Joined: Fri Jan 18, 2008 11:23 am
Location: ~ Resident Graphics Artist ~

Re: [QUESTION] ZMD File parse

Postby lmame on Mon Oct 20, 2008 12:10 pm

Sethanye wrote:lol ok, still the lag sucks


Yeah ^_^ they reboot the mysql servers and doing stuff now :D but it's not DDOS ;)
The world is full of love and peace ^_^
Image
User avatar
lmame
Admin
Admin
 
Posts: 8997
Joined: Mon Aug 06, 2007 4:42 pm
Location: July City

Re: [QUESTION] ZMD File parse

Postby Sethanye on Mon Oct 20, 2008 12:11 pm

still the mysql has gone away error was hillarious lol
~ Learning Flash ~ Anyone Know Any Good Tutorial DVDs? ~
Image
"Come Into My Dream, Let Me Show You Where I've Been.
Its You And Me I've Seen, Let Me Tell You What I Mean."
User avatar
Sethanye
Neko Chan
Neko Chan
 
Posts: 2603
Joined: Fri Jan 18, 2008 11:23 am
Location: ~ Resident Graphics Artist ~

Re: [QUESTION] ZMD File parse

Postby lmame on Mon Oct 20, 2008 12:23 pm

Yeah ^_^
The world is full of love and peace ^_^
Image
User avatar
lmame
Admin
Admin
 
Posts: 8997
Joined: Mon Aug 06, 2007 4:42 pm
Location: July City

Re: [QUESTION] ZMD File parse

Postby cssvb94 on Mon Oct 20, 2008 1:48 pm

lmame wrote:Well technically speaking it seems your way is fine.
I made the same calculations and I find your result.

Though, do you have the 3DS plugins? Is it a script so we can look at the source or it's build?


Mhm, no ... it's a dle , i.e. dll

One more question:
When I read 2nd bone
1. first to rotate it's coordinates using the Quaternion and then add it to parent's position
or
2. first add the offset to parent's position and then apply the Quaternion ?
I guess it is the 1st one, but better to ask you guys. ;)

@Sethanye
Thank you and Lt for the info.
The ZMD i/o script will be released as FREE tool combined of course with ZMS i/o and later ZMO.
According to the pasted conversation, the Quaternions in ZMD file should be read in (x, y, z, w) format, not (w, x, y, z)?
I totally agree which z axis or y axis is used for depth does not matter. The imported model can be easily rotated once constructed in the right way.

That's a developer's forum - so quick responses in the right field ( read it - no noob questions )

Thanks once again, waiting for more info from you.
aka Spark (ZMSViewer, Blender ZMS plug-in, RoseOnline ZMS/ZMD/ZMO to SMD and vice versa converter)
User avatar
cssvb94
Pomic
Pomic
 
Posts: 109
Joined: Thu May 01, 2008 7:22 am
Location: GMT +1

Re: [QUESTION] ZMD File parse

Postby Maxxon on Mon Oct 20, 2008 3:23 pm

i am Lt btw,

as i said rose does not use standart xyz orientation for the coordinate system. in 3dsmax z is depth, in rose world z is height.
so you can either swap that when reading the coordinates from the file OR you can rotate the whole scene later (thats what i do).
its true that rose gives quaternions in zyxw, but in what order you read zyx (or if its even zyx for you) depends on how you did read the position vectors in.

for the other question about the order: in all cased i looked at i had to first scale, then rotate and then translate.
Image
an anymous comment on a program called reloader:
what if a fatal error happens, will it restart it?
User avatar
Maxxon
Hawker's pet
Hawker's pet
 
Posts: 1305
Joined: Sat Nov 10, 2007 12:42 pm

Next

Return to 3D discussions

Who is online

Users browsing this forum: No registered users and 3 guests

cron