vector3df to char

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.
Post Reply
wEEp
Posts: 70
Joined: Thu Nov 27, 2008 7:55 am

vector3df to char

Post by wEEp »

Hello,

Is it possible to cast vector3df to a char? When i make an explicit cast i get this error:

Code: Select all

cannot convert from 'const irr::core::vector3df' to 'char'
How can i cast this to a char?:(
Sylence
Posts: 725
Joined: Sat Mar 03, 2007 9:01 pm
Location: Germany
Contact:

Post by Sylence »

Code: Select all


stringc str( vec.X );
str += "x";
str += vec.Y;
str += "x";
str += "vec.z;

Software documentation is like sex. If it's good you want more. If it's bad it's better than nothing.
wEEp
Posts: 70
Joined: Thu Nov 27, 2008 7:55 am

Post by wEEp »

Sylence wrote:

Code: Select all


stringc str( vec.X );
str += "x";
str += vec.Y;
str += "x";
str += "vec.z;

Thanks, it works =)

last question: Can you tell me now how to make from this again a vectore3df?:D
Sylence
Posts: 725
Joined: Sat Mar 03, 2007 9:01 pm
Location: Germany
Contact:

Post by Sylence »

Code: Select all


s32 sep1 = str.findFirst('x');
s32 sep2 = str.findNext('x', sep1+1);

vec.X = atof( str.subString(0, sep1).c_str() );
vec.Y = atof( str.subString(sep1+1, sep2-sep1-1).c_str() );
vec.Z = atof( str.subString(sep2+1, str.size()-sep2-1).c_str() ); 

Software documentation is like sex. If it's good you want more. If it's bad it's better than nothing.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Code: Select all

char buf [256];

// vector to string
sprintf ("x=%f y=%f z=%f", v.X, v.Y, v.Z);

// string to vector
sscanf ("x=%f y=%f z=%f", &v.X, &v.Y, &v.Z);
Nox
Posts: 304
Joined: Wed Jan 14, 2009 6:23 pm

Post by Nox »

Or use the irrlicht Attributesystem :)
Post Reply