Just a quick one. Probably the most common calculation I do in my code all over the place is this:
Real unitScale = 5;
sceneNode->setScale(Vector3::UNIT_SCALE * unitScale);
It would be nice if there was an overridden method to make this simpler, even if only to save typing
setScale(Real unitScale);
setScale to unit scale
-
- Gnome
- Posts: 367
- Joined: Wed Jan 03, 2007 12:44 pm
- Location: Brisbane, Australia
- x 13
setScale to unit scale
Craftwork Games - hand crafted entertainment.
http://www.craftworkgames.com/
http://www.craftworkgames.com/
-
- Bugbear
- Posts: 833
- Joined: Thu Apr 15, 2010 7:42 am
- Location: Poznan, Poland
- x 33
Re: setScale to unit scale
I'd say it should be forced to vectors automagically (explicit constructor?)
Sos Sosowski
http://www.sos.gd
http://www.sos.gd
-
- Gnome
- Posts: 367
- Joined: Wed Jan 03, 2007 12:44 pm
- Location: Brisbane, Australia
- x 13
Re: setScale to unit scale
Sorry, I'm not sure what you mean by explicit constructor? Do you mean changing the Vector3 class so that numbers are automatically converted to Vector3? In other words, this:so0os wrote:I'd say it should be forced to vectors automatically (explicit constructor?)
Code: Select all
Vector3 v = 5;
Code: Select all
Vector3 v(5,5,5);
Code: Select all
Vector3 scale = 5; // makes sense
Vector3 position = 5; // doesn't make sense
Vector3 normal = 5; // doesn't make sense
Vector3 direction = 5; // doesn't make sense
Craftwork Games - hand crafted entertainment.
http://www.craftworkgames.com/
http://www.craftworkgames.com/
-
- Bugbear
- Posts: 833
- Joined: Thu Apr 15, 2010 7:42 am
- Location: Poznan, Poland
- x 33
Re: setScale to unit scale
Apparently, this works.zarfius wrote:Code: Select all
Vector3 v = 5;
Sos Sosowski
http://www.sos.gd
http://www.sos.gd
-
- Gnome
- Posts: 367
- Joined: Wed Jan 03, 2007 12:44 pm
- Location: Brisbane, Australia
- x 13
Re: setScale to unit scale
Fair enough, I stand corrected. I mostly use C# with Mogre these days so I didn't have time to test it.so0os wrote:Apparently, this works.zarfius wrote:Code: Select all
Vector3 v = 5;
While we are on the topic I just remembered a way to do it in C# using a relatively new feature called extension methods. Basically, they allow you to add functionality to existing classes without the need to recompile any dependencies. For example, you can add an extension to a SceneNode like this:
Code: Select all
public static void SetScale(this SceneNode sceneNode, float unitScale)
{
sceneNode.SetScale(Vector3.UNIT_SCALE * unitScale);
}
Code: Select all
sceneNode.SetScale(5.0f);
The only downside is that extension methods only work in later versions of the .NET framework and currently my Mogre.dll is compiled against .NET framework 2.0 for reason's I won't go into. Anyway, at least there is a possible solution for everyone
Craftwork Games - hand crafted entertainment.
http://www.craftworkgames.com/
http://www.craftworkgames.com/