![]() | ||
Views: 24,290,915 |
Home
| Forums
| Uploader
| Wiki
| Object databases
| IRC
Rules/FAQ | Memberlist | Calendar | Stats | Online users | Last posts | Search |
03-28-25 06:29 AM |
Guest: |
0 users reading Model formats - A better understanding | 1 bot |
Main - Archived forums - SMG documentations and tutorials - Model formats - A better understanding | Hide post layouts | New reply |
element3260 |
| ||
Normal user Level: 7 Posts: 2/7 EXP: 1223 Next: 225 Since: 04-13-13 Last post: 4361 days ago Last view: 3545 days ago |
Sounds like a good start. I figured out a partially correct way to set up the 2x4 texture matrices. If you're familiar with Thakis' bmdviewer2 then this might look familiar:
TexMtxInfo mtx { mtx.scaleU, 0, 0, mtx.scaleCenterX, 0, mtex.scaleV, 0, mtx.scaleCenterY }; This produces correct results for WW Link's eyes and other models in that .rarc. I think/know there are more parameters that models are going to use. At least one model in that rarc wants a 3x4 matrix. With the info we have now it would be exactly the same as a 2x4, so there must be more! |
blank |
| ||
Normal user Level: 26 Posts: 57/129 EXP: 99864 Next: 2411 Since: 07-08-12 Last post: 3678 days ago Last view: 2651 days ago |
struct TexMtxInfo
{ u8 projection; u8 type; u16 paddding0; // 0xFFFF f32 center_s,center_t; f32 unknown0; f32 scale_s,scale_t; u16 rotate; // -32768 = -180 deg, 32768 = 180 deg u16 padding1; // 0xFFFF f32 translate_s,translate_t; f32 prematrix[4][4]; }; The projection field can be either GX_TG_MTX3x4 and GX_TG_MTX2x4. The type field specifies which texture matrix type to use. I've found 6 different types in SMG2: type=0x00 Always combined with projection=GX_TG_MTX2x4 and has regular texture coordinates as source. This is the simplest and most common type. The texture coordinates is first rotated and scaled about (center_s,center_t) and then translated. type=0x06 Always combined with projection=GX_TG_MTX2x4 and has transformed normals as source. The normals are first projected with the matrix [[0.5, 0, 0, 0.5], [0, 0.5, 0, 0.5]] and then the same transformations as for type=0x00 are applied. NOTE: It is possible that the matrix prematrix is applied to the normals before they are projected. type=0x07 Always combined with projection=GX_TG_MTX3x4 and has transformed normals as source. Same as for type=0x06 except the projection matrix is [[0.5, 0, -0.5, 0], [0, 0.5, -0.5, 0], [0, 0, -1, 0]]. type=0x08 Always combined with projection=GX_TG_MTX3x4 and has untransformed position coordinates as source. First the matrix prematrix is applied to the coordinates, then the coordinates is projected by the matrix [[0.5, 0, 0.5, 0], [0, -0.5, 0.5, 0], [0, 0, 1, 0]] and then the same transformations as for type=0x00 are applied. type=0x09 Always combined with projection=GX_TG_MTX3x4 and has transformed position coordinates as source. I don't know how this works, but I think it's just like type=0x08 but with transformed position coordinates. type=0x80 Always combined with projection=GX_TG_MTX2x4 and has regular texture coordinates as source. I don't know how this works either, but it seems to be like type=0x00 except it uses unknown0 in some way. |
element3260 |
| ||
Normal user Level: 7 Posts: 3/7 EXP: 1223 Next: 225 Since: 04-13-13 Last post: 4361 days ago Last view: 3545 days ago |
Awesome. Thank you blank.
How can you generate a single texture matrix that can rotate a point around a center point? It seems like we would need at least two matrices to do it. Do they make use of the premultiply matrix in this way? Can you share any code on how to convert the TexMtxInfo structure to a matrix? I'm having trouble. |
blank |
| ||
Normal user Level: 26 Posts: 58/129 EXP: 99864 Next: 2411 Since: 07-08-12 Last post: 3678 days ago Last view: 2651 days ago |
This is the python code I use to generate texture matrix commands for the MDL3 section
def SetTexMatrix(self,slot,args):
c = cos(args.rotate) s = sin(args.rotate) R = numpy.matrix([[c,-s,0],[s,c,0],[0,0,1]]) S = numpy.matrix([[args.scale_s,0,0],[0,args.scale_t,0],[0,0,1]]) C = numpy.matrix([[1,0,args.center_s],[0,1,args.center_t],[0,0,1]]) T = numpy.matrix([[1,0,args.translate_s],[0,1,args.translate_t],[0,0,1]]) if args.type == 0 or args.type == 0x80: P = numpy.matrix([[1,0,0,0],[0,1,0,0],[0,0,0,1]]) elif args.type == 6: P = numpy.matrix([[0.5,0,0,0.5],[0,0.5,0,0.5],[0,0,0,1]]) elif args.type == 7: P = numpy.matrix([[0.5,0,-0.5,0],[0,0.5,-0.5,0],[0,0,-1,0]]) elif args.type == 8 or args.type == 9: P = numpy.matrix([[0.5,0,0.5,0],[0,-0.5,0.5,0],[0,0,1,0]]) M = T*C*S*R*C.I*P*numpy.matrix(args.premtx) if args.projection == gx.TG_MTX2x4: self.texmatrix[slot][:] = (M[i,j] for j in range(4) for i in range(2)) elif args.projection == gx.TG_MTX3x4: self.texmatrix[slot][:] = (M[i,j] for j in range(4) for i in range(3)) C.I is the inverse of the C matrix. As you can see, I have chosen to apply the prematrix for all types, but I am not sure this is correct. It will need some more testing. |
element3260 |
| ||
Normal user Level: 7 Posts: 4/7 EXP: 1223 Next: 225 Since: 04-13-13 Last post: 4361 days ago Last view: 3545 days ago |
Excellent, thanks again blank! I'm working on Link's eyes, and I'm realllly close, but not quite there. The eyes are drawn three times. One pass has blending disabled, and lays down 0's for all 3 color channels and 1.0 for the alpha channel where the eye should be drawn (like an alpha mask). The second pass seems to do exactly the same thing, but with blending enabled. But since the first pass wrote 0's to the color channels, it blends with the 0's (which is how you get Zorro link). The third pass has blending enabled but the srcFactor is dstAlpha, so it uses the alpha mask laid down by the first two passes.
So I believe that the first pass is supposed to have color writes disabled, ala GxSetColorUpdate(false). I've been hunting for that boolean (and it's brother, the boolean for GxSetAlphaUpdate) in the .bdl/.bmd file but I haven't had any luck. Is it in there? Am I barking up the wrong tree? |
blank |
| ||
Normal user Level: 26 Posts: 59/129 EXP: 99864 Next: 2411 Since: 07-08-12 Last post: 3678 days ago Last view: 2651 days ago |
I'm pretty sure those values aren't there. They definitely aren't in the MDL3 section and I haven't found anything that looks like them in the MAT3 section. |
element3260 |
| ||
Normal user Level: 7 Posts: 5/7 EXP: 1223 Next: 225 Since: 04-13-13 Last post: 4361 days ago Last view: 3545 days ago |
Hmmm. Has anyone figured out how his eyes work? Maybe thakis is grabbing some incorrect blending information? |
blank |
| ||
Normal user Level: 26 Posts: 60/129 EXP: 99864 Next: 2411 Since: 07-08-12 Last post: 3678 days ago Last view: 2651 days ago |
I don't have the Link model from Wind Waker, so I don't even know what the exact problem is. How does his eyes look as it is now? |
JwopDk |
| ||
Based King Potato Level: 13 ![]() Posts: 6/28 EXP: 9800 Next: 467 Since: 04-05-13 From: Melbourne, Australia Last post: 3567 days ago Last view: 3410 days ago |
Hi guys,
Vaguely off-topic, but I made this command-line tool for patching single files to a RARC file which can be found here: http://www.sendspace.com/file/q37gv4 The main reason for doing this is that I haven't been able to get Wiimm's tools working on my Linux computer (I run the windows port of tcc in wine to make my programs for windows computers), because apparently it can't find libpng14 even though I installed correctly. I also wanted to get a better understanding of how the RARC format works, and also this program fits nicely with the set of tools that Thakis and Shevious made, which is how I've been testing new models in Super Mario Galaxy. Finally, I just want to say, even if you don't really care what I'm posting on this thread, I'm still going to go ahead and make my own BDL to BMD converter, because despite the time it's taking to make, I'd rather make my own converter than try to set up a python environment that requires some external libraries just to convert a level file from a Nintendo game, which I concede would be much easier, but again, I like to know how these things work. No offense, blank, your tools are awesome and you know so much more than I do about this stuff, but I feel that for the average user it might be simpler just to drag a level file on top of an exe that only uses core Windows DLLs found in System32. Also, a 1.6MB exe from a 5KB python script is slightly ridiculous ![]() |
element3260 |
| ||
Normal user Level: 7 Posts: 6/7 EXP: 1223 Next: 225 Since: 04-13-13 Last post: 4361 days ago Last view: 3545 days ago |
Blank, which tools did you develop? |
blank |
| ||
Normal user Level: 26 Posts: 61/129 EXP: 99864 Next: 2411 Since: 07-08-12 Last post: 3678 days ago Last view: 2651 days ago |
A BMD to BDL converter and a OBJ to BDL converter. |
element3260 |
| ||
Normal user Level: 7 Posts: 7/7 EXP: 1223 Next: 225 Since: 04-13-13 Last post: 4361 days ago Last view: 3545 days ago |
Are they publicly available? I'd really like to get a look at the source. I'd like to tackle indirect texturing soon, and I don't think Thakis really solved it. |
blank |
| ||
Normal user Level: 26 Posts: 62/129 EXP: 99864 Next: 2411 Since: 07-08-12 Last post: 3678 days ago Last view: 2651 days ago |
The OBJ to BDL converter is here and the BMD to BDL converter you can get here (it's some pretty crappy code, though).
As for indirect texturing, thakis almost had it. Here is how it should be: struct IndTexOrder { u8 texcoord; u8 texmap; u16 padding0; }; struct IndTexMatrix { f32 offset_matrix[2][3]; s8 scale_exponent; u8 padding0[3]; }; struct IndTexCoordScale { u8 scale_s; u8 scale_t; u16 padding0; }; struct TevIndirect { u8 indtex; u8 format; u8 bias; u8 mtx; u8 wrap_s; u8 wrap_t; u8 addprev; u8 utclod; u8 a; u8 padding0[3]; }; struct IndirectEntry { u8 unknown0; // always 0 or 1 u8 unknown1; // unknown1 = unknown0, one of these is the argument to GXSetNumIndStages u16 padding0; IndTexOrder indtexorder[4]; // arguments to GXSetIndTexOrder IndTexMatrix indtexmatrix[3]; // arguments to GXSetIndTexMatrix IndTexCoordScale indtexcoordscale[4]; // arguments to GXSetIndTexCoordScale TevIndirect tevindirect[16]; // arguments to GXSetTevIndirect }; |
Main - Archived forums - SMG documentations and tutorials - Model formats - A better understanding | Hide post layouts | New reply |
Page rendered in 0.040 seconds. (2048KB of memory used) MySQL - queries: 25, rows: 129/129, time: 0.014 seconds. ![]() © 2005-2008 Acmlm, Xkeeper, blackhole89 et al. |