Jump to content

How I can create a 3dObject componet inside a plugin


photo

Recommended Posts

I create a plugin where I want to include a new 3d object. For my 3dObject I inherited from ObjectExternBase

class My3dObject: public Unigine::ObjectExternBase
{
public:
	template <class> friend class Unigine::Ptr;
	static void release_ptr(My3dObject *p);
	{ 
		delete p; 
	}

	static Unigine::Ptr<My3dObject> create();
	{
		Unigine::Ptr<My3dObject> ptr = Unigine::Ptr<My3dObject>(new My3dObject());
		return ptr;
	}

	virtual int getClassID() override;
	virtual int getNumSurfaces() override;
	virtual const char *getSurfaceName(int surface) override;
	virtual const ::Unigine::BoundBox &getBoundBox(int surface) override;
	virtual const ::Unigine::BoundSphere &getBoundSphere(int surface) override;
	virtual const ::Unigine::BoundBox& getBoundBox() override;
	virtual const ::Unigine::BoundSphere& getBoundSphere() override;
  
  ...
  
int MyPlugin::init()
{  

	int id = Unigine::Interpreter::addGroup("MyGroup");

	Unigine::ExternClass<My3dObject> *My3dObj = Unigine::MakeExternClass<My3dObject>();
	Unigine::Interpreter::addExternClass("My3dObject", My3dObj, id);

    this->my3dObj = My3dObject::create();
    this->my3dObj.get()->release();
    Unigine::Editor::get()->addNode(this->my3dObj.get()->getNode(), true);
  
  ...

After load the plugin in the "word tree" appear the node "ObjectExtern", but if I select this raise an exception

        Unhandled exception at 0x00007FF88046E91E (ucrtbase.dll) in Editor_x64d.exe: Fatal program exit requested.

Exist some sample that show how I can add My3dObject to the editor from a plugin.

1935139535_2019-08-2313-25-42UNIGINE2.9Alpha.thumb.png.4a6a2108fcb613be430a6a3bc81630b0.png

/Roberto

 

 

Edited by roberto.voxelfarm
Link to comment
×
×
  • Create New...