Jump to content
  • Advertisement
Sign in to follow this  
TheMan22

Beginner having troubles

This topic is 3794 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys string axis = "x"; MPoint point; if (point.axis == 0) { } Simplified version of some maya api code,but you get the idea :) axis is the flag for the command and can be x,y or z.In this case it is set to x for demonstational purposes. This is the problem point.axis I can't do it like that,and i want if x is chosen to compare only x value of the point with some else.So how to do it? thank you

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by TheMan22
Hi guys

string axis = "x";
MPoint point;
if (point.axis == 0)
{
}

Simplified version of some maya api code,but you get the idea :)

axis is the flag for the command and can be x,y or z.In this case it is set to x for demonstational purposes.

This is the problem point.axis

I can't do it like that,and i want if x is chosen to compare only x value of the point with some else.So how to do it?

thank you
What's wrong with if (point.axis.x == 0)? What is "MPoint::axis"?
What does the local variable, "axis" have to do with anything?

Share this post


Link to post
Share on other sites
MPoint does not have axis method.

axis is a variable and can get values x,y,or z.

MPoint has methods MPoint::x,MPoint::y and MPoint::z

So axis tells which one of those should be used,you understand now?

Share this post


Link to post
Share on other sites
Quote:
Original post by TheMan22
MPoint does not have axis method.

axis is a variable and can get values x,y,or z.

MPoint has methods MPoint::x,MPoint::y and MPoint::z

So axis tells which one of those should be used,you understand now?
Ah, I see. Then you'll want something like:

if(axis == "x" && point.x == 0)
{
// Whatever
}
else if(axis == "y" && point.y == 0)
{
// Whatever
}
else if(axis == "z" && point.z == 0)
{
// Whatever
}


Assuming C++, that is. Also note that string comparisons are case sensitive.

Share this post


Link to post
Share on other sites
no other way to do this ?

I must use if statements?

In mel for example you do this :

polyCube -name "some" // means create a 3d cube called some

And you can do something like this :

string $name = " -name ";
eval("polyCube" + $name + "\"some\"");


Share this post


Link to post
Share on other sites
Quote:
Original post by TheMan22
no other way to do this ?

I must use if statements?
The other solutions are to use a switch, a map, or both together. But the logic you have to program is the same; you have to manually map each possible input, with the proper code to execute.

Quote:
In mel for example you do this :

polyCube -name "some" // means create a 3d cube called some

And you can do something like this :

string $name = " -name ";
eval("polyCube" + $name + "\"some\"");
That's because mel is apparently a scripting language. Scripting languages allow you to call variables by name. Compiled languages don't even store the names of variables in memory.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!