Hi, I’m pretty new to Optix but I’ve spent the last week reading through the guides and SDK examples and I think I have a decent understanding of it.
However I’m trying to modify the mesh viewer example to load and render two separate meshes, but it only ever seems to render the last mesh that I load.
So essentially I’ve modified the code so that the load mesh function takes a transform as a parameter, the mesh is loaded and set as the child of the transform:
void loadMesh( const std::string& filename, Transform& trans )
{
OptiXMesh mesh;
mesh.context = context;
loadMesh( filename, mesh );
aabb.set( mesh.bbox_min, mesh.bbox_max );
GeometryGroup geometry_group = context->createGeometryGroup();
geometry_group->addChild( mesh.geom_instance );
geometry_group->setAcceleration( context->createAcceleration( "Trbvh" ) );
trans->setChild( geometry_group );
}
In main I then create two separate transforms, call load_mesh twice with the different transforms and add them to a group object which I set as the “top_object” on the context:
createContext();
Group top_group = context->createGroup();
top_group->setAcceleration( context->createAcceleration( "Trbvh" ) );
Transform trans = context->createTransform();
trans->setMatrix( false, Matrix4x4::translate( make_float3( 10.0f, 5.0f, 10.0f ) ).getData(), 0 );
loadMesh( mesh_file, trans );
top_group->addChild( trans );
Transform trans2 = context->createTransform();
trans2->setMatrix( false, Matrix4x4::translate( make_float3( -10.0f, -5.0f, -10.0f ) ).getData(), 0 );
loadMesh( mesh_file2, trans2 );
top_group->addChild( trans2 );
context[ "top_object" ]->set( top_group );
context[ "top_shadower" ]->set( top_group );
Is there something I’m just not getting ? Any help would be greatly appreciated, thanks.