Import a OBJ file in OptiXSphere Sample.

Dear Developer:
From the OptiXSphere project, I get the Context,Material and GeometryGroup in the OptiXsphere’s createInstance Funtion. In OptiX3.7.0, I applyed the cow.obj to the OptixSphere project. The sucessful way is follows:

// Load OBJ scene
OptixMesh loader( context_hw, geometrygroup_hw, material1_hw );
loader.loadBegin_Geometry( s );
loader.loadFinish_Materials();

In OptiX4.1.1, the OptiXMesh does’t have the function of loader. I try to import the obj file in OptiX 4.1.1’s OptiXMesh. As follows:

OptiXMesh mesh;
mesh.context = context1;
mesh.material = material1;
loadMesh(“E:\cow.obj”, mesh);

aabb.set(mesh.bbox_min, mesh.bbox_max);
mesh.geom_instance = geo;
geometry_group->addChild(mesh.geom_instance);
geometry_group->setAcceleration(context1->createAcceleration(“Trbvh”));
context1[“top_object”]->set(geometry_group);
context1[“top_shadower”]->set(geometry_group);

Above this way doesn’t get the cow’s effect. I wish you can give a useful suggestion. Thanks!

First, I would not recommend to use any OptiX 4 version for new applications, use at least OptiX 5.1.0.

Then there are multiple working applications inside the OptiX 5.1.x SDK which demonstrate how to load an OBJ file with the OptiXMesh class and some also exchange the materials. Just search for “OptiXMesh” in the OptiX 5.1.x SDK sources and single step through the code with a debugger to see what steps are done exactly to setup an OptiX scene graph

The problem of mixing and matching OptiX SDK example sources is that each SDK example might use a different material implementation (different device code dependencies) and you normally cannot simply merge arbitrary code pieces without adjustments to that device code but must make sure the shader programs are compatible.

You gives me very important advice! I conbine Context、Material with GeometryGroup as the loadmesh function’s parameters. So the question is solved. Thanks very much.