Scaling a mounted ShapeBaseImage
by Konrad Kiss · 07/02/2009 (3:40 pm) · 39 comments
To be able to set your weapon's scale without having to re-export it, do the following:
First, in shapeBase.h find (in the ShapeBaseImageData struct)
/// Maximum number of sounds this image can play at a time. /// Any value <= 0 indicates that it can play an infinite number of sounds. S32 maxConcurrentSounds;
and after that insert:
// >>> // custom mounted image scaling Point3F scale; // <<<
Next, in shapeImage.cpp, add to the ShapeBaseImageData constructor:
// >>> scale = Point3F(1,1,1); // <<<
Still in the same file, find ShapeBaseImageData::initPersistFields() and add at the end of the method:
// >>>
addField("scale", TypePoint3F, Offset(scale, ShapeBaseImageData));
// <<<In the ShapeBaseImageData::packData method, add at the end:
// >>> mathWrite( *stream, scale ); // <<<
In the ShapeBaseImageData::unpackData method, add at the end:
// >>> mathRead( *stream, &scale ); // <<<
In shapeBase.cpp's ShapeBase::prepBatchRender find the following:
MatrixF mat;
getRenderImageTransform(mountedImageIndex, &mat, state->isShadowPass());
GFX->setWorldMatrix( mat );
image.shapeInstance->animate();
image.shapeInstance->render( rdata );and replace with this:
MatrixF mat;
getRenderImageTransform(mountedImageIndex, &mat, state->isShadowPass());
GFX->setWorldMatrix( mat );
image.shapeInstance->animate();
// >>>
MatrixF s(true);
s.scale( image.dataBlock->scale );
GFX->multWorld( s );
// <<<
image.shapeInstance->render( rdata );Finally, some scripting: in your weapon's (or any other mounted image's) ShapeBaseImageData datablock, add a scale property (defaults to Point3F(1,1,1) if not set, which means no further scaling) and set it's value to the desired scale.
You're done, now you can scale any of your mounted objects. Tested only in Torque3D.
Update (07/30/2009): Updated the resource to make it networked.
Update (09/25/2009): Updated code to reflect changes to a getRenderImageTransform call from Beta 5.
Update (01/30/2010): For T3D 1.0.1, check out this post by Eikon Games.
@konradkiss
KonradKiss @ GitHub
konradkiss.com
About the author
http://about.me/konrad.kiss
#2
With my very limited art talent, things like this save the day for me. About Gideon - I think Gideon is actually closer to being the right size than Kork - but I might be wrong there.
Anyway, speaking of core assets - this will definitely help with the funny-huge crossbow. :)
07/02/2009 (4:11 pm)
You're very welcome, Michael. With my very limited art talent, things like this save the day for me. About Gideon - I think Gideon is actually closer to being the right size than Kork - but I might be wrong there.
Anyway, speaking of core assets - this will definitely help with the funny-huge crossbow. :)
#3
07/02/2009 (4:15 pm)
Sweet thanks again Konrad!
#4
07/02/2009 (6:06 pm)
I have to agree with Konrad that Gideon seems closer to right size. Given accepted scales, Kork is something around 7 feet tall, IIRC.
#5
Yeah, your're probably right about Gideon's size being more close to "right" -- I've been eyeballing all of my assets to more accurately fit that apparent scale anyway. This just makes it easier :D
07/02/2009 (11:08 pm)
@Konrad:Yeah, your're probably right about Gideon's size being more close to "right" -- I've been eyeballing all of my assets to more accurately fit that apparent scale anyway. This just makes it easier :D
#6
I have been struggling with incorrect sized weapons on a project, my art skills are beginner at best and just when I was about to give up ... you pull this gem out. :)
Thanks man. Awesome job.
07/03/2009 (2:42 am)
Konrad ... Konrad ... Konrad ... dude you are incredible and probably a mind reader.I have been struggling with incorrect sized weapons on a project, my art skills are beginner at best and just when I was about to give up ... you pull this gem out. :)
Thanks man. Awesome job.
#7
@Jason: To tell the truth, I think I've heard that info from such prestigious artists as Apparatus and Maxim Lyulyukin. I wouldn't normally have a clue, but it's nice to hear that I'm not imagining things. :)
@Michael: Nice. This is such a small change, and very useful imho, maybe you could use your special blue nametag force and get this into Torque3D? :)
@Quinton: Anytime. I'm glad this thing helps you out! ;)
07/03/2009 (5:18 am)
@OmegaDog: You're welcome, OD. Hope it will prove useful to you.@Jason: To tell the truth, I think I've heard that info from such prestigious artists as Apparatus and Maxim Lyulyukin. I wouldn't normally have a clue, but it's nice to hear that I'm not imagining things. :)
@Michael: Nice. This is such a small change, and very useful imho, maybe you could use your special blue nametag force and get this into Torque3D? :)
@Quinton: Anytime. I'm glad this thing helps you out! ;)
#8
07/04/2009 (6:39 am)
I vote merge this into the T3D Core!
#9
@aldavidson: Yeah I agree - bring this forward into T3D
As for Kork, he is an Orc. 7 Feet tall doesn't seem out of reason. :)
07/04/2009 (9:24 am)
@Konrad: Thanks, this is really helpful!@aldavidson: Yeah I agree - bring this forward into T3D
As for Kork, he is an Orc. 7 Feet tall doesn't seem out of reason. :)
#10
But on the side topic of player scale:

Interestingly enough it looks like Gideon could fit in the Spacesuit.
07/05/2009 (2:52 pm)
This absolutely has my vote for inclusion in Torque 3D! Have you seen how huge the gravitygun in the T3D PhysX Demo is?Quote:This is such a small change, and very useful imho, maybe you could use your special blue nametag force and get this into Torque3D?I could slip this in, but... volunteering to work on the FPS kit, or the status of that blue button doesn't really give me much say in additions...
But on the side topic of player scale:

Interestingly enough it looks like Gideon could fit in the Spacesuit.
#11
... and that is how the steam-space genre was born.
Don't get yourself into an uneasy situation about the inclusion, I was just joking. :) This is easy to add, so doesn't really matter much.
07/05/2009 (3:18 pm)
Quote:
Interestingly enough it looks like Gideon could fit in the Spacesuit.
... and that is how the steam-space genre was born.
Don't get yourself into an uneasy situation about the inclusion, I was just joking. :) This is easy to add, so doesn't really matter much.
#12
07/06/2009 (8:32 pm)
Thanks Konrad, I have been wanting to do this!
#13
07/14/2009 (1:36 pm)
Amazingly handy - thanks Konrad!
#14
07/30/2009 (3:24 am)
I updated the resource to make it networked.
#15
in B5 the line has changed to getRenderImageTransform(mountedImageIndex, &mat, state->isShadowPass());
but other than that was easy to install and works like a dream - TYVM
09/25/2009 (8:20 am)
i would just like to point out 1 minute point in B5 the line has changed to getRenderImageTransform(mountedImageIndex, &mat, state->isShadowPass());
but other than that was easy to install and works like a dream - TYVM
#16
09/25/2009 (8:30 am)
Thanks LC, I've updated the resource to reflect that!
#17
09/25/2009 (11:01 am)
you need to add it to the find area also - but fast response gratz :P
#18
09/25/2009 (11:05 am)
You're right! Thanks for checking back on that! It should be cool now.
#19
sure this would come up but the code changed a little for the last insert for the 1.0 release.
The last insert now happens in ShapeBase::renderMountedImage(). Still works charmy.
EDIT -- //
Whoops! Looks like the change needed to happen in Player::renderMountedImage().
09/30/2009 (6:09 pm)
Hey Konrad, sure this would come up but the code changed a little for the last insert for the 1.0 release.
The last insert now happens in ShapeBase::renderMountedImage(). Still works charmy.
EDIT -- //
Whoops! Looks like the change needed to happen in Player::renderMountedImage().
#20
09/30/2009 (6:13 pm)
Thanks for the heads up, Martin! Glad it still works! :) 
Associate Michael Hall
Distracted...
Consistency in art size seems to be a hard baseline to maintain, even with my slow plodding pace. Heck, the various players & weapons that come stock in Torque all seem to have a different scale size intended for use -- have you noticed that Gideon is so small compared to other Torque player shapes (about the size of a hobbit) that the FPS kit rifle looks to be about the scale of a puntgun?
I'm definitely going to be dropping this one in for me to use. Thanks Konrad!