PDA

View Full Version : mental ray -- Geoshader, many instances, and bsp2


atap3d
01-21-2009, 05:22 PM
Hi.
I'm trying to write geoshader.
I have a very simple code.
#include <fstream>

#include <shader.h>
#include <geoshader.h>

void add_vector(miScalar x, miScalar y, miScalar z)
{
miVector v;
v.x = x; v.y = y; v.z = z;
mi_api_vector_xyz_add(&v);
}

miTag miaux_object(const char* name)
{
int i;
miVector v;

miObject *obj = mi_api_object_begin(mi_mem_strdup(name));

mi_api_object_group_begin(0.0);

add_vector(-.5,-.5,0);
add_vector(.5,-.5,0);
add_vector(.5,.5,0);
add_vector(-.5,.5,0);

add_vector(0,0,1);

for (i = 0; i < 4; i++) {
mi_api_vertex_add(i);
mi_api_vertex_normal_add(4);
}

mi_api_poly_begin_tag(1, 0);
for (i = 0; i < 4; i++)
mi_api_poly_index_add(i);
mi_api_poly_end();

mi_api_object_group_end();

return mi_api_object_end();
}

extern "C" DLLEXPORT int mrgeoshadertest_version(void) {return(1);}

extern "C" DLLEXPORT miBoolean mrgeoshadertest(
miTag *result,
miState *state,
miTag *paras)
{
char iname[100];
miTag objtag = miaux_object("hi");
miInstance *inst;

for (int i=0; i < 10; i++)
{
miMatrix matrix;

sprintf(iname, "hi%i", i);
inst = mi_api_instance_begin(mi_mem_strdup(iname));

mi_matrix_ident(matrix);
matrix[14] = (float)i;

mi_matrix_copy(inst->tf.local_to_global, matrix);
mi_matrix_invert(inst->tf.global_to_local, inst->tf.local_to_global);

mi_geoshader_add_result(result, mi_api_instance_end(0, objtag, 0));
}
return miTRUE;
}
I'm using maya 2009(mental ray 3.7.1.26, Jul 30 2008, revision 26576)
It is rendering successful. I see set of squares. But, if I change "scanline" option to off and "acceleration method" to bsp2, it is dont rendering. the object is missing. I dont see set of squares. Why? I want use bsp2 and scanline-off. How can i fix my code?

CGTalk Moderation
01-21-2009, 05:22 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.