Everything related to SDK.
By ArmanZak
#387395
Hi all. I wrote little testing application for testing maxwell geometry modifier extension.
Application use only Qt4.8.7 and maxwell sdk (3.0.1 x64 in vs2012). It has only one pushbutton
Code: Select all
void MainWindow::on_pushButton_clicked(bool clicked)
{
    Q_UNUSED(clicked);
	//
    QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
    QString MAXWELL3_ROOT = env.value("MAXWELL3_ROOT", "not founded");
	std::cout<<MAXWELL3_ROOT.toUtf8().constData()<<std::endl;
    QString MAXWELL3_LICENSE_SERVER = env.value("MAXWELL3_LICENSE_SERVER", "not founded");
	std::cout<<MAXWELL3_LICENSE_SERVER.toUtf8().constData()<<std::endl;
    QString MAXWELL3_MATERIALS_DATABASE = env.value("MAXWELL3_MATERIALS_DATABASE", "not founded");
	std::cout<<MAXWELL3_MATERIALS_DATABASE.toUtf8().constData()<<std::endl;

	CextensionManager::instance()->setExtensionsDirectory(QString("%1\\extensions").arg(MAXWELL3_ROOT).toUtf8().constData());
	CextensionManager::instance()->loadAllExtensions();
	std::cout<<CextensionManager::instance()->getMaterialModifierExtensionsCount();

    Cmaxwell *previewScene = new Cmaxwell(error_callback);

    previewScene->readMXS(QString("%1/test.mxs").arg("D:/").toUtf8().constData());

	Cmaxwell::Cobject::Citerator it;
	Cmaxwell::Cobject object = it.first( previewScene );
	while ( !object.isNull() )
	{	
		char *pName;
		object.getName(&pName);
		std::cout<<pName<<std::endl;

		byte isMesh = 0;
		object.isMesh(isMesh);
		if(isMesh == 1)
		{
			MXparamList *pl = new MXparamList("SubdivisionModifier");
			object.applyGeometryModifierExtension( pl );
			pl->clear();
			pl->free();
			delete pl;
		}
		object = it.next();
	}	   

    previewScene->writeMXS("D:/test.mxs");

    previewScene->freeGeometry();
    previewScene->eraseUnusedMaterials();
    previewScene->freeScene();

    delete previewScene;
}
1. In
Code: Select all
CextensionManager::instance()->loadAllExtensions();
line i get this for all extensions
Error in Loadlibrary.
Error loading library: C:\Program Files\Next Limit\Maxwell 3\extensions\subdivisionmodifier.win64.mxx
The specified module could not be found.
but all extension exists.
2. in
Code: Select all
delete pl;
application crash, with soemthing like this
....
HEAP[Project1.exe]: Heap block at 0000000000489F10 modified at 0000000000489F21 past requested size of 1
Project1.exe has triggered a breakpoint.
HEAP[Project1.exe]: Invalid address specified to RtlFreeHeap( 0000000000390000, 0000000000489F20 )
...
.

What I doing wrong. please help.
By JDHill
#387396
An extension (.mxx) depends on mxcommon_64.dll (or mxcommon_32.dll) found in the Maxwell directory -- you need to use LoadLibrary to load it, before attempting to call loadAllExtensions. Try getting this to work, and then see about issues with deleting things (probably it has to do with targeting the v110 toolset instead of v90, which is what mxcommon and the extensions will have been built with -- you can always check these things using depends and/or reshacker).
By ArmanZak
#387405
Thanks. LoadLibrary helped.
in second question i use v110 toolset, but now it does not matter

One question
Code: Select all
CgeometryModifierExtension *geoModExt = CextensionManager::instance()->createDefaultGeometryModifierExtension("SubdivisionModifier");
MXparamList *plSubD = geoModExt->getExtensionData();
object.applyGeometryModifierExtension( plSubD );
in this code i must delete geoModExt? or it will deleted when i call Cmaxwell::freegeometry() and Cmaxwell::freeScene() methods?

Thanks, again.
By JDHill
#387411
ArmanZak wrote:in second question i use v110 toolset, but now it does not matter
It may seem so now, but eventually it should be a problem, because you have two different CRTs in the process. You may get away with it if the application stays very small & simple, and never deletes/frees anything, but otherwise, you'll encounter crashes at some point, which do not seem to make much sense.
ArmanZak wrote:One question
Code: Select all
CgeometryModifierExtension *geoModExt = CextensionManager::instance()->createDefaultGeometryModifierExtension("SubdivisionModifier");
MXparamList *plSubD = geoModExt->getExtensionData();
object.applyGeometryModifierExtension( plSubD );
in this code i must delete geoModExt? or it will deleted when i call Cmaxwell::freegeometry() and Cmaxwell::freeScene() methods?

Thanks, again.
You should delete it.
By ArmanZak
#387421
Thanks for detailed information.
With reshacker I check mxcommon and it used v90 toolset.
Now I change my toolset to v90. In first look all good.
Can you advice any way(or tool) to test all depended with this issue(more then one CRT in one process)?

Thanks. again.
By JDHill
#387434
ArmanZak wrote:Can you advice any way(or tool) to test all depended with this issue(more then one CRT in one process)?
Reshacker and depends can show whether the final binary (your .exe or .dll) has dependencies on multiple CRTs; if it does, that would generally indicate that you are linking to 3rd-party libraries that use a different CRT. In certain specific circumstances, this can be okay, provided you can prove that the library in question always allocates/deallocates the memory it uses (probably because it uses a C interface), and that non-POD objects (e.g. classes, std::string, etc) do not pass across dll boundaries, since they may end up having different memory layouts in different CRT versions. Technically, this can even happen when using the same CRT, where it would depend on various compiler options (packing, etc -- see a good discussion of this here).

Another way to confirm which CRTs are being used is to watch the Output window in Visual Studio, as you debug the application; you will see if/when different runtimes are loaded, as the process is started, and as different dlls are loaded into memory.
round corners

Hi there, just a question, is the rhino rounded ed[…]

OMG! Now I understand the problem of darkening of […]

Hi! I have looked for the answer to this but so fa[…]

Settings do not stick

Quick update - if you save the viewport again (in […]