Everything related to SDK.
#389111
Hi.
I use Maxwell SDK 3.2.0, Visual Studio 2013,using v120 toolset
In simple console application, i trying create simple scene with only one particle object,
try to get her points. But every time in getProxyDisplayPoints line app crash.
Code bellow
Code: Select all
#include <iostream>
#include "stdafx.h"

#include "maxwell.h"
#include "mx_defines.h"
#include "mx_extensionmanager.h"
#include "mx_geometryextension.h"
#include "mx_paramlist.h"

byte mx_error_callback(byte isError, const char *pMethod, const char *string, const void *data)
{
	if (isError)
	{
		printf( "Error in Method  = %s \n error = %s  \n value = %d\n", pMethod, string, data );
	}
	return (0);
}

int _tmain(int argc, _TCHAR* argv[])
{
	Cmaxwell previewScene(mx_error_callback);

	previewScene.setAxisConversion("YXZ");
	previewScene.setSinglePrecisionOfGeometry();

	CextensionManager::instance()->setExtensionsDirectory("E:/ext");
	CextensionManager::instance()->loadAllExtensions();
	CextensionManager::instance()->InitializeAllExtensions();	
	
	CgeometryProceduralExtension *gExtension = CextensionManager::instance()->createDefaultGeometryProceduralExtension("MaxwellParticles");
	if (gExtension != NULL)
	{
		MXparamList *pl = gExtension->getExtensionData();
		
		pl->setString("FileName", "E:/Particle_Test_01.bin");

		Cmaxwell::Cobject previewObject = previewScene.createGeometryProceduralObject("particles", pl);
		//
		gExtension->initializeForRendering(&previewScene, previewObject) << std::endl;
		//
		float *points;
		dword nPoints = 0;
		gExtension->getProxyDisplayPoints(10, 1000, nPoints, points);
		std::cout << "Num of points" << nPoints << std::endl;

	
		pl->clear();
		pl->free();
		
		delete points;
		
		gExtension->cleanup(&previewScene);
		delete gExtension;
	}

	previewScene.writeMXS("E:/test.mxs");

	previewScene.freeGeometry();
	previewScene.freeScene();
	
	return 0;
}
E:/ext is a path where maxwell extenstion located(copied from maxwell 3.2 directory)
E:/Particle_Test_01.bin is a simple particles object downloaded from http://support.nextlimit.com/display/mx ... +Particles.
mxcommon library located in same directory where placed executable file, and it loaded properly.
Other extentions types work successfull.
Application crashed in
Code: Select all
gExtension->getProxyDisplayPoints(10, 1000, nPoints, points);
line, for MaxwellVolumetric, too.
#389119
The initializeForRendering method is intended to be called by the engine itself just prior to rendering; in order to use the getProxyDisplay methods, you should call initializePreview and freePreview. You should not free the data returned by getProxyDisplayPoints, because it should be both allocated & freed (in initialize/freePreview) by the extension itself. So, try something more like this:
Code: Select all
static byte error_callback(byte type, const char* pMethod, const char* pError, const void*)
{
    switch (type)
    {
    case Cmaxwell::CALLBACK_WARNING:
        printf("SDK WARNING: %s @ %s", pError, pMethod);
        break;
    case Cmaxwell::CALLBACK_ERROR:
        printf("SDK ERROR: %s @ %s", pError, pMethod);
        break;
    }
    return 0;
}

static void testParticlesPreview()
{
    // Assuming extensions to be loaded already.

    Cmaxwell previewScene(error_callback);
    CgeometryProceduralExtension *gExtension = CextensionManager::instance()->createDefaultGeometryProceduralExtension("MaxwellParticles");
    if (gExtension)
    {
        MXparamList *pl = gExtension->getExtensionData();
        if (pl)
        {
            pl->setString("FileName", "Particle_Test_01.bin");
            Cmaxwell::Cobject previewObject = previewScene.createGeometryProceduralObject("particles", pl);
            if (!previewObject.isNull() && gExtension->initializePreview(&previewScene, previewObject))
            {
                float* points = 0;
                dword nPoints = 0;
                if (gExtension->getProxyDisplayPoints(10, 1000, nPoints, points))
                {
                    for (dword i = 0; i < nPoints; ++i)
                        printf("pt: %f,%f,%f\n", points[i*3+0], points[i*3+1], points[i*3+2]);
                }
                gExtension->freePreview();
            }
        }
        delete gExtension;
    }
}
#389121
Don't delete that, the extension owns it. Don't call cleanup either; that is intended to be called by the render engine (like initializeForRendering). Generally, the only methods you will need to call on an extension are getExtensionData, initializePreview, freePreview, and the getProxyDisplay methods.
#389123
I do not think there is any guarantee that you will get a valid bounding box by calling that. It would ultimately depend on the extension in question, and whether it calculates & caches its bounding box when initializePreview is called, or only when initializeForRendering is called. If it returns a zero-size box after calling initializePreview, either the box is of zero size, or you will need to calculate it yourself by iterating the lines, points, or faces, from one of the getProxyDisplay methods (which are all optional for the extension).

...and 3 Days later, 82.528 Views !!! ...NL, every[…]

Hello dear customers, We have just released a new[…]

grass generator extension

Just downloaded MWR5 for Rhino 6 and want to use g[…]

Hello everyone, I have a new bug with the latest M[…]