Jump to content
The Dark Mod Forums

Discrepancy if applying a scaling factor to rotation matrix


Recommended Posts

Yes, that's why it's a hack. If you want both a rotation and a scale, you're going to have to multiply the matrices yourself (!).
The trick seems to be to first rescale manually and then rotate using the DR tools in the normal way.

[EDIT] As you were. The above is only true for 90 degree turns.

 

Hmmmmmm... could DR be made to calculate it? :) Then there'd be "official unofficial" support for scaling.

Link to comment
Share on other sites

That's just what I was thinking earlier SD when I was wondering how to calculate it on a calculator. I'm considering doing a short wiki on rescaling with do's and don'ts once I've learnt a bit more about it. I've wasted hours on this when a few sentences on the wiki would have been enough. My wrought iron gates look great now and without this rescaling I would have to do something with brushes and patches. I consider this immensely important.

Link to comment
Share on other sites

There are plenty of tools around that can multiply matrices. I use xmaxima (a free (GPLed) algebra solver), but you need to be comfortable with purely text-based input, and you have to learn the syntax and the quirks. There are probably other tools out there that are easier to use.

 

What do the DR devs think about supporting model scaling within DR? It sounds like a very useful tool. I'm thinking of a design like this:

 

- Instead of rotate operations affecting the D3 "rotation" spawnarg directly, they affect a "rotate_matrix" spawnarg (that name is purely an example).

- A "model scale" tool affects a "scale_matrix" spawnarg (again, the name is an example).

- When either of the above spawnargs are changed, DR automatically multiplies these matrices and sets the "rotate" spawnarg to the result.

My games | Public Service Announcement: TDM is not set in the Thief universe. The city in which it takes place is not the City from Thief. The player character is not called Garrett. Any person who contradicts these facts will be subjected to disapproving stares.
Link to comment
Share on other sites

Yesterday I found a usefull application for the matrix scaling. :) I felt that the quilt and ink model was to small, and so I applied a factor of two to it, which makes it look right IMO. Since it is only decorative, it doesn't matter if it can not be collided with properly. :)

Gerhard

Link to comment
Share on other sites

Yesterday I found a useful application for the matrix scaling. :) I felt that the quilt and ink model was to small, and so I applied a factor of two to it, which makes it look right IMO. Since it is only decorative, it doesn't matter if it can not be collided with properly. :)

Pray tell. Does it convert the model file or is it a calculator for use in DR?

Link to comment
Share on other sites

Not sure what you mean by that. :) I simply changed the rotation key in DR.

 

It's pretty easy for simple values:

you set the key rotation to some value

1 0 0 0 1 0 0 0 1

 

1 0 0

0 1 0

0 0 1

 

 

The ones are the diagonal of the matrix and represent x, y, z, so if you want to scale an item, just set this values to a factor. If you want to have it double the size set it to 2, if you want it half the size, set it to 0.5. You get the idea. Of course you can scale only on one axis so if you want to scale only along the Z axis, leave the others at 1 and only change this one value.

The only drawback is that the collisionmodel is not scaled. So you can use this only on objects where the player doesn't collide with, or where it doesn't matter, like with the ink glass in my case.

You can use it on any object (at least models), even if they have collision models, it's just that the collision will not work as expected. It will still take place at the original size. I tried it with a wooden plank, and trippled it in length, but when I walked into the plank I could walk through 2/3 of it, before the collision stopped me. Visually you can still use it though. So for rafters, roofs, etc. you can still apply it.

 

Not sure about patches. If you want to use it with brushes, you probably have to convert them to func_static, apply the rotation, and then convert them back to brushes. Haven't tried though, so it might not work.

Gerhard

Link to comment
Share on other sites

Firstly, you said you found a 'useful application'. I assumed you meant a program but now I see you meant literally just an application of the principle. You see, the other day I found an application (a program) that converts models from one format to another and can perform certain optional changes such as scaling. I tried it but it failed on the two tests I tried so I didn't pursue it. So that was the first thing that came to my mind when you said 'application'. :)

 

The other thing I was saying about a calculator is because with some (all?) models, eg, the wrought iron gate, if you rescale then rotate to an angle you need in the game then the scaling goes wrong in all but 180 degree turns. For example, I set the gate to triple thickness and double height with rotation 1 0 0 0 3 0 0 0 2 but when I then turn it to say 90 degrees it is something like three times too wide. It's probably transferring the depth value to the width I guess. The rotation value now shows 0 3 0 -1 0 0 0 0 2 which I don't understand. Alternatively, if I rotate it first to say 22 degrees and then try to rescale it I am faced with 0.927184 0.374607 0 -0.374607 0.927184 0 0 0 1 and I haven't a clue how to rescale it. I was hoping a set calculation could work it out.

 

Objects like the larger plank are easily fixed with an nodrawsolid brush of the collision size you want. Not so easy to make them smaller. Is there a way to remove the effective collision of any model in DR? I wanted to remove the collision from the wishing well and replace with some unrendered collision brushes. The reason is, many a fan mission has included access or escape via a well but this model will not permit the player to enter it even though it looks big enough - I didn't try from below though. The alternative is to build a well from brushes/patches but it's a shame to have a nice model like that which cannot be used for this purpose.

Link to comment
Share on other sites

Given you have the existing model rotation matrix

a b c
d e f
g h i

and you want to scale it by x, y and z, you just multiply the matrices:

a b c	 x 0 0	 a·x b·y c·z 
d e f  ·  0 y 0  =  d·x e·y f·z
g h i	 0 0 z	 g·x h·y i·z

Basically, you scale the first column by x, the second by y and the third by z.

Link to comment
Share on other sites

Not sure I've understood this. I create a gate, rotate it 45 degrees so its rotation values are

  0.707107 0.707107 0
-0.707107 0.707107 0
 0		0		1

 

I want to make it 8 times thicker which is the Y value so multiply each of the middle column to get...

  0.707107 5.656856 0
-0.707107 5.656856 0
 0		0		1

 

But don't seem to have done it right as the result is clearly wrong.

 

(sorry did the above off line in Courier New and it lined up correctly but somehow the code tags move it out of line)

Link to comment
Share on other sites

I take the values frmo your above example:

0.927184 0.374607 0
-0.374607 0.927184
0 0 0 1

 

Now suppose you want to scale it 8x on the X axis, 4x on the Y axis and 2x on the Z axis:

(0.927184*8) (0.374607*4) (0*2)
(-0.374607*8) (0.927184*4) (0*2)
(0*8) (0*4) (1*2)

 

Yields:

7.417472 1.49868 0
-2.996856 3.708736 0
0 0 2

 

To add to the confusion, you can also mirror the axis, by changin the sign on the given axis. :)

 

One thing you have to take care of is, that you probably can not rotate the model anymore after this. You have to always use the original matrix, that you started with, for the actual rotiation, and then multiply the scaling factor back in. You can simply create a new key as a backup, and copy the original values there for this.

Gerhard

Link to comment
Share on other sites

I don't see why a matrix-based scaling tool for models should not be possible, although Greebo would know more about the implementation details. It would be advisable to have some sort of caveat though to ensure that mappers realised the issues relating to collision models (maybe a popup dialog the first time the model-rotation tool was activated, or something).

Link to comment
Share on other sites

I think such a tool is possible, although it might be quite some work. I'm not entirely convinced that this tool is for everyday use (return on investment) and additionally it seems to break the rotation manipulator.

Link to comment
Share on other sites

Yeah, in T2 I rarely put any object in the game without considering its size. A group of bottles of only 2 or 3 types can be made into a dozen - a couple of squat fat bottle, tall thin, etc. I reckon a forest can be made from only 10 tree models using tall and thin, thick and small, huge, tiny, coupled with rotation, slight leaning and careful lighting the player would have to be consciously looking for duplication to notice. Different sizes of plates, tables, statues, pillars, foliage, there is no end to the useage to multiply one model seemingly into several.

 

But don't be shocked if the calc goes wrong. I have not been able to get it right. My original calc produced the wrong result and I've just typed in Sparhawk's numbers and though the gate scale looks about right it is no longer rotated at the same angle as a normal size test gate rotated the same amount. Maybe I'll try again tomorrow.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • Ansome

      Finally got my PC back from the shop after my SSD got corrupted a week ago and damaged my motherboard. Scary stuff, but thank goodness it happened right after two months of FM development instead of wiping all my work before I could release it. New SSD, repaired Motherboard and BIOS, and we're ready to start working on my second FM with some added version control in the cloud just to be safe!
      · 0 replies
    • Petike the Taffer  »  DeTeEff

      I've updated the articles for your FMs and your author category at the wiki. Your newer nickname (DeTeEff) now comes first, and the one in parentheses is your older nickname (Fieldmedic). Just to avoid confusing people who played your FMs years ago and remember your older nickname. I've added a wiki article for your latest FM, Who Watches the Watcher?, as part of my current updating efforts. Unless I overlooked something, you have five different FMs so far.
      · 0 replies
    • Petike the Taffer

      I've finally managed to log in to The Dark Mod Wiki. I'm back in the saddle and before the holidays start in full, I'll be adding a few new FM articles and doing other updates. Written in Stone is already done.
      · 4 replies
    • nbohr1more

      TDM 15th Anniversary Contest is now active! Please declare your participation: https://forums.thedarkmod.com/index.php?/topic/22413-the-dark-mod-15th-anniversary-contest-entry-thread/
       
      · 0 replies
    • JackFarmer

      @TheUnbeholden
      You cannot receive PMs. Could you please be so kind and check your mailbox if it is full (or maybe you switched off the function)?
      · 1 reply
×
×
  • Create New...