eugene.litvinov Posted February 16, 2011 Share Posted February 16, 2011 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
frustum Posted February 16, 2011 Share Posted February 16, 2011 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
eugene.litvinov Posted February 16, 2011 Author Share Posted February 16, 2011 Thanks, is_base_class do for me :mellow: Link to comment
eugene.litvinov Posted March 11, 2011 Author Share Posted March 11, 2011 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
frustum Posted March 12, 2011 Share Posted March 12, 2011 Correct syntax for automatic class casting is: Joint joint = joint_cast(body.getJoint(0)); Link to comment
Recommended Posts