WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 04-25-2014, 08:53 AM
shivanangel shivanangel is offline
Member
 
Join Date: Feb 2006
Location: New Jersey
Posts: 180
Help with VizExtension.command?

I'm working to port a new version of our volume rendered over to C++ as a Vizard extension, but I'm running into some issues using the VizExtension.command method.

I followed your documentation, and I can construct a simple cube when I call my extensions .addNode() method.

However, when I try to use the .command method Vizard crashes on me every time.

Specifically, I'm just trying to send back bogus data from the C++ extension to Python using the data.set() method.

MyExtension Header
Code:
#pragma once

#include <viz\Extension>
#include <viz\python>
#include "MyNode.h"


class MyExtension : public viz::Extension
{
public:
	MyExtension(void);
	virtual const char* getName() const;
	virtual viz::Referenced* createNode(viz::Data &data);
	virtual void command( viz::Data& data);

protected:
	virtual ~MyExtension(void);

protected:
	osg::ref_ptr<viz::ExtensionOSGNode> node_;

};
MyExtension .ccp
Code:
#include "MyExtension.h"

MyExtension::MyExtension(void)
{
}

MyExtension::~MyExtension(void)
{
}

const char* MyExtension::getName() const
{
	return "My Extension";
}

viz::Referenced* MyExtension::createNode(viz::Data &data)
{
	node_ = new DummyNode;
	return node_.get();
}

void MyExtension::command( viz::Data& data )
{
	int command = data.getInt( "command" );

	switch(command)
	{
		case 1:	//Passing in the camera's normal
			float tempX = data.getFloat("x");
			data.set(  PYTHON_RETURN_OBJECT, PYTHON_STRING("This is a test.") );
			break;
	}
}

extern "C" __declspec(dllexport) viz::Extension* CreateVizardExtension(viz::Data &data)
{
	return new MyExtension();
}
Reply With Quote
  #2  
Old 04-25-2014, 09:58 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
It sounds like you are compiling the plugin with an incompatible version of Visual Studio. If you are not compiling with Visual Studio 2008, then you most likely will encounter issues like this due to mismatched C++ runtime versions.
Reply With Quote
  #3  
Old 04-25-2014, 10:04 AM
shivanangel shivanangel is offline
Member
 
Join Date: Feb 2006
Location: New Jersey
Posts: 180
Ugh... I was afraid of that. Everything was working so well with Visual Studio 2012 until this little hick-up.

Thank you,
~George
Reply With Quote
  #4  
Old 04-29-2014, 07:58 AM
shivanangel shivanangel is offline
Member
 
Join Date: Feb 2006
Location: New Jersey
Posts: 180
Just confirming for anyone else who searches for this answer, the problem was indeed the Compiler using later C++ runtimes.
I installed and compiled the .dle using Visual Studio 2008 and the problems and crashes disappeared.
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 09:32 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Copyright 2002-2018 WorldViz LLC