Jump to content

[SOLVED] Extending Class Problem


photo

Recommended Posts

Posted

Another quick question. I just don't get why the code below doesn't work:

 

class ExtendNode : Node

{

    ObjectMeshSkinned mesh;

    ExtendNode (string nNodeName, vec3 nPos)

    {
        // brabra
    }

}

 

 

int init()

{

   ExtendNode nNode;= new ExtendNode("something", vec3(0));

   nNode.setPosition(vec3(1));

}

 

Basically, it always gives me error upon calling setPosition() function on the extended node class...

Can someone help shine some light on this?

 

Thx. :-)

Posted

Hi, you can't extend external class "Node" on a unigine scripts.

But you can write a user class that allow to code user interface to the Node class.

#include <core/unigine.h>

class ExtendNode {
		
	private:
		
		Node node;
		
	public:
		
		ExtendNode(string name,Vec3 pos) {
			// create your node
			node = node_append(engine.world.loadNode("data/test/test.node"));
			node.setName(name);
		}
		
		// interface
		void setPosition(Vec3 pos) {
			node.setPosition(pos);
		}
		
		vec3 getPosition() {
			return node.getPosition();
		}
		
		/*
		 * your other methods
		 */
};

ExtendNode node;

/*
 */
int init() {
	node = new ExtendNode("something",Vec3_zero);
	node.setPosition(Vec3_one);
	
	return 1;
}
×
×
  • Create New...