Everything related to SDK.
By ArmanZak
#388312
Code: Select all
#include <iostream>
#include "maxwell.h"
#include "mx_defines.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[])
{
	float vertices[12] = { -0.50f, 0.0f, 0.50f,	0.50f, 0.0f, 0.50f, 0.50f, 0.0f, -0.50f, -0.50f, 0.0f, -0.50f };

	float normals[12] = { 0.0f, 0.00998311397f, 0.0f, 0.0f, 0.00998311397f, 0.0f, 0.0f, 0.00998311397f, 0.0f, 0.0f, 0.00998311397f, 0.0f };

	dword trianglesV[6] = { 0, 3, 6, 0, 6, 9 };
	dword trianglesN[6] = { 0, 3, 6, 0, 6, 9 };
	
	Cmaxwell previewScene(mx_error_callback);

	previewScene.setAxisConversion("YXZ");
	previewScene.setSinglePrecisionOfGeometry();
	
	Cmaxwell::Cobject previewObject = previewScene.createMesh("mesh", 4, 4, 2, 1);
	
        /* method one start */
        for (int i = 0; i < 12; i+=3)
	{
		int index = i / 3;
		std::cout << index << std::endl;
		previewObject.setVertex(index, 0, Cpoint(vertices[i], vertices[i + 1], vertices[i + 2]));
		previewObject.setNormal(index, 0, Cpoint(normals[i], normals[i + 1], normals[i + 2]));
	}
	previewObject.setTriangle(0, 0, 1, 2, 0, 1, 2);
	previewObject.setTriangle(1, 0, 2, 3, 0, 2, 3);
         /* method one end*/

         /* two start */
	//previewObject.setVerticesBuffer(vertices, 3 * sizeof(float));
	//previewObject.setNormalsBuffer(normals, 3 * sizeof(float));
	//previewObject.setTrianglesBuffer(trianglesV, 3 * sizeof(dword));
	//previewObject.setTrianglesNormalsBuffer(trianglesN, 3 * sizeof(dword));
         /* two end */	

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

	previewScene.freeGeometry();
	previewScene.freeScene();
	
	return 0;
}

I complie on Visual Studio 2013 v120,
use libs from maxwell 3.2.0 beta sdk libs for vc2013.
When I export simple plane with 4 vertices and 2 triangles, all works fine.
But when I use method two
In x64 I get crash one
Code: Select all
previewScene.writeMXS("E:/test.mxs");
,
in win32 I don't have crash or any error message, but when I open exported .mxs maxwell studio crashed.

What wrong I do in method two?
User avatar
By Brany
#388313
dword trianglesV[6] = { 0, 3, 6, 0, 6, 9 };
dword trianglesN[6] = { 0, 3, 6, 0, 6, 9 };
These indices are wrong. You have to index by vertex/normal, not by component:
Code: Select all
 dword trianglesV[6] = { 0, 1, 2, 0, 2, 3 };
dword trianglesN[6] = { 0, 1, 2, 0, 2, 3 };

Hey Patrik, thanks for the suggestion. 🙌🏼 Creams […]

Hi ki_cz, this is my attempt with another engine,[…]

Great Thx for the workaround and replies! Cheers.

Pricing

In the end, I have upgraded to 5.1. Even with the […]