• About us
  • Contact Us
  • Terms and Conditions
  • Forum
  • Materials
  • Shaders
  • Tools
  • Video
  • Learn
  • Gallery
My Mental Ray
Go Back   MyMentalray Forum > mental ray Standalone > Shader Writing
Reload this Page Geoshader, many instances, and bsp2
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next

Old 01-21-2009, 05:22 AM   #1
atap3d
Hobbyist
 
atap3d's Avatar
 
Join Date: May 2007
Location: Moscow, RU
Posts: 4
Default Geoshader, many instances, and bsp2

Hi.
I'm trying to write geoshader.
I have a very simple code.
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?
atap3d is offline   Reply With Quote
atap3d
View Public Profile
Send a private message to atap3d
Find More Posts by atap3d
 

« Previous Thread | Next Thread »

Thread Tools
Show Printable Version Show Printable Version
Email this Page Email this Page
Display Modes
Linear Mode Switch to Linear Mode
Hybrid Mode Switch to Hybrid Mode
Threaded Mode Threaded Mode

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

vB 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 03:00 AM.

Contact Us - Welcome to MyMentalRay Forum - Archive - Top
Copyright © 2008 My Mental Ray Community. All Rights Reserved.
No part of this website may be reproduced unless for personal use without prior written permission from The My Mental Ray Community.