Page 1 of 3

Funtion

Posted: Sun Jun 27, 2010 6:04 pm
by M4UNOT
How do i make a function of setScale(); that works?

Exemple:

Code: Select all


void Scale(int one)
{
setScale(one);
}


Posted: Sun Jun 27, 2010 6:54 pm
by Lonesome Ducky
Not to be rude, but do you know programming at all?

Posted: Sun Jun 27, 2010 7:11 pm
by Acki

Posted: Sun Jun 27, 2010 7:41 pm
by B@z
also, check the api.
or if u use visual studio it writes out what parameter it wants.

Code: Select all

void ISceneNode::setScale(const irr::core::vector3df &scale);
so you need a vector3df parameter
vector3df(1,1,1); // X, Y, Z scale

also, check the tutorials

code

Posted: Sun Jun 27, 2010 8:10 pm
by M4UNOT
Friends..

i'm trying to change " setScale " name to just " Scale "

with functions

like this:

Code: Select all


#include <irrlicht.h>

using namespace irr;

using namespace core;

using namespace scene;

using namespace video;

using namespace io;

using namespace gui;

void Scale(irr::f32 one, irr::f32 two, irr::f32 three) 
{ 

setScale(core::vector3df(one,two,three));

} 


And i get : 'setScale': identifier not found

i'm using : Microsoft Visual C++ 2008 Express Edition

Posted: Sun Jun 27, 2010 8:54 pm
by Lonesome Ducky
setScale is a member function. You can't use it without an object.

Code: Select all

node->setScale()
You could of course, change the definition of the function in the irrlicht code itself. But why do you need to change the name?
And on a side note, names like one, two, and three for a function aren't very good. Consider x,y,z; names that make sense so you don't forget down the road.

Posted: Sun Jun 27, 2010 11:10 pm
by Frank Dodd
Why do you want this 'Scale' function rather than just call setScale for that object? I have created a similar function myself but it was necessary to allow it to be used by a language that was not object oriented.

If you just want to uniformly scale your object you could use the following command: -

Code: Select all

void Scale( ISceneNode* node, f32 fScale )
{
    node->setScale (vector3df( fScale, fScale, fScale ));
}
This is making a C style function though and not C++.

Posted: Mon Jun 28, 2010 1:44 pm
by vitek
If you want your code to be totally awesome, you could use macros...

Code: Select all

#define Scale(x,y,z) setScale(x,y,z)
Travis

Posted: Mon Jun 28, 2010 2:05 pm
by slavik262
You could use macros, but the more important question of why you can't just use setScale() still remains. What's the point in renaming it?

macros

Posted: Mon Jun 28, 2010 6:19 pm
by M4UNOT
I don't whant to use macros.. but functions.. becouse

i'm making my own static library of irrlicht engine library so i can work fast in

my own way...

Posted: Mon Jun 28, 2010 6:42 pm
by sudi
you don't even know what a member function is and then u want to create a lib to work your own way???

well whatever

Posted: Mon Jun 28, 2010 6:53 pm
by slavik262
M4UNOT, it seems like you could use some basic C++ lessons before you start using Irrlicht. http://www.cplusplus.com/doc/tutorial/ and http://www.learncpp.com are both good in my experinece.

..

Posted: Mon Jun 28, 2010 7:49 pm
by M4UNOT
slavik262

I don't need some basic C++ lessons

and i know how to create a lib ... Sudi see my videos:

http://www.youtube.com/user/m4unot


I just need help .. to make a function in c++ called: " Scale " that can scale

my object's instead of " setScale "


but i think maybe none of you ..know how to do it...


sorry for being a little bit rude guys but..i got tired of reading..negative

post.. and asking me to read som c++ tutorial that i already know

Re: ..

Posted: Mon Jun 28, 2010 8:13 pm
by Acki
M4UNOT wrote:but i think maybe none of you ..know how to do this function..
wow, how challenging !!! :lol:
well, I guess you're right, nobody here knows how to do such a simple function... :roll:
also a solution was already posted above...
so, hello stupidity !!! :?

and just as a sidenote: keep in mind that any function put on another function slows down the code a bit, so you should always avoid unneccessary function dublications, especially for a realtime rendering engine... ;)
M4UNOT wrote:asking me to read som c++ tutorial that i already know
but it seems that you don't already know this...
well, you should read ybout stuff you don't know about, like this one here... :lol:

Posted: Mon Jun 28, 2010 8:26 pm
by ACE247
What a laugh. :lol: :lol: :lol: