Jump to content

instance is Class - C++/Unigine-script analog


photo

Recommended Posts

Some languages have is operator (Pascal, Java, ets.), so programmer can write:

 

Object object;

Node node;

 

if (object is Object)
{
 // it's true
}

if (node is Object)
{
 // it isn't true
}

 

Has C++ / Unigine script analog of this?

Link to comment

Please check documentation about:

 

typeof()

is_int()

is_float()

...

is_base_class()

is_user_class()

is_extern_class()

 

class Foo { };
class Bar : Foo { };
Bar b = new Bar();
Socket s = new Socket();
if(is_base_class("Foo",:mellow:) printf("b is Foo\n");
if(is_base_class("Bar",B)) printf("b is Bar\n");
if(is_base_class("Stream",s)) printf("s is Stream\n");
if(is_base_class("Socket",s)) printf("s is Socket\n");

Link to comment
  • 4 weeks later...

Maybe silly question again, but I have bodies with JointHinge and JointPrismatic joints, I need do different manipulations with they, so I need know, what type of joint I get, I have next code:

Body body = Object(node).getBodyRigid();
Joint joint = body.getJoint(0);

log.message("typeof(joint) = " + typeof(joint) + "\n");
log.message("JointHinge(joint) = " + is_base_class("JointHinge", joint) + "\n");
log.message("JointPrismatic(joint) = " + is_base_class("JointPrismatic", joint) + "\n");

 

 

trace:

17:58:37 typeof(joint) = Joint

17:58:37 JointHinge(joint) = 0

17:58:37 JointPrismatic(joint) = 0

 

How can I do this? Thanks.

Link to comment
×
×
  • Create New...