Funtion

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
M4UNOT
Posts: 39
Joined: Sat Jun 26, 2010 3:06 pm
Location: Germany

Funtion

Post by M4UNOT »

How do i make a function of setScale(); that works?

Exemple:

Code: Select all


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

Lonesome Ducky
Competition winner
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Post by Lonesome Ducky »

Not to be rude, but do you know programming at all?
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post 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
Image
Image
M4UNOT
Posts: 39
Joined: Sat Jun 26, 2010 3:06 pm
Location: Germany

code

Post 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
Lonesome Ducky
Competition winner
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Post 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.
Frank Dodd
Posts: 208
Joined: Sun Apr 02, 2006 9:20 pm

Post 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++.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post 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
slavik262
Posts: 753
Joined: Sun Nov 22, 2009 9:25 pm
Location: Wisconsin, USA

Post 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?
M4UNOT
Posts: 39
Joined: Sat Jun 26, 2010 3:06 pm
Location: Germany

macros

Post 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...
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post 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
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
slavik262
Posts: 753
Joined: Sun Nov 22, 2009 9:25 pm
Location: Wisconsin, USA

Post 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.
M4UNOT
Posts: 39
Joined: Sat Jun 26, 2010 3:06 pm
Location: Germany

..

Post 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
Last edited by M4UNOT on Mon Jun 28, 2010 8:13 pm, edited 1 time in total.
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Re: ..

Post 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:
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
ACE247
Posts: 704
Joined: Tue Mar 16, 2010 12:31 am

Post by ACE247 »

What a laugh. :lol: :lol: :lol:
Post Reply