Adding Models into optixRayCasting sample project

Hi,

I am new to OptiX. I am playing around with the optixRayCasting project in Optix6.0 SDK. I want to add more models into the scene using loadMesh() api. My code looks like the following:

void OptiXRaycastingContext::newMeshLoader(const std::string& filename, optix::Matrix4x4 xform_matrix)
{
	OptiXMesh mesh;
	mesh.context = m_context;
	mesh.material = m_material;
	mesh.use_tri_api = true;
	mesh.ignore_mats = true;
	mesh.closest_hit = m_closest_hit;
	mesh.any_hit = m_any_hit;
	loadMesh(filename, mesh);
	// Start from here. optix mesh might need tthe closes hit and anyhit program supplied.
	mesh.geom_instance->setMaterial(0, m_material);
	optix::GeometryGroup geometry_group = m_context->createGeometryGroup();
	geometry_group->setAcceleration(m_context->createAcceleration("Trbvh"));
	geometry_group->addChild(mesh.geom_instance);

	optix::Transform xform = m_context->createTransform();
	xform->setMatrix(0, xform_matrix.getData(), 0);
	xform->setChild(geometry_group);
	m_top_object->addChild(xform);
}

Made the following change in the optixMesh.cpp file

optix::Material createOptiXMaterial(
    optix::Context         context,
    optix::Program         closest_hit,
    optix::Program         any_hit,
    const MaterialParams&  mat_params,
    bool                   use_textures
    )
{
  ...            
  mat->setAnyHitProgram( 0, any_hit ) ;  // replaced 1u with 0   
  ...
  return mat;
}

I have already initialized the anyhit and closest_hit program in the constructor of this class.

OptiXRaycastingContext::OptiXRaycastingContext()
{
	m_context = optix::Context::create();
	m_context->setRayTypeCount(1);
	m_context->setEntryPointCount(1);
	m_context->setStackSize(4096);
	m_context->setPrintEnabled(true);
	// Set small stack for a simple kernel without much shading.
	 // Limit to single GPU for this sample, to simplify CUDA interop.
	const std::vector<int> enabled_devices = m_context->getEnabledDevices();
	m_context->setDevices(enabled_devices.begin(), enabled_devices.begin() + 1);
	m_optix_device_ordinal = enabled_devices[0];
	{
		m_cuda_device_ordinal = -1;
		m_context->getDeviceAttribute(m_optix_device_ordinal, RT_DEVICE_ATTRIBUTE_CUDA_DEVICE_ORDINAL, sizeof(int), &m_cuda_device_ordinal);
	}
	const char *ptx = sutil::getPtxString(SAMPLE_NAME, CUDA_SOURCE);
	
	m_top_object = m_context->createGroup();	// level 4/4
	m_top_object->setAcceleration(m_context->createAcceleration("Trbvh"));

	m_geometry = m_context->createGeometry(); // level 0/4
	m_material = m_context->createMaterial(); // level 0/4
	optix::GeometryInstance geom_instance = m_context->createGeometryInstance(m_geometry, &m_material, &m_material + 1);	// level 1/4
	optix::GeometryGroup geom_group = m_context->createGeometryGroup(&geom_instance, &geom_instance + 1);				// level 2/4
	geom_group->setAcceleration(m_context->createAcceleration("Trbvh"));

	optix::Transform xform = m_context->createTransform();		// level 3/4
	xform->setMatrix(0, optix::Matrix4x4::identity().getData(), 0);
	xform->setChild(geom_group);
	m_top_object->addChild(xform);
	m_context["top_object"]->set(m_top_object);
	//Ray gen
	optix::Program ray_gen = m_context->createProgramFromPTXString(ptx, "ray_gen");
	m_context->setRayGenerationProgram(0, ray_gen);

	// Exception prog
	optix::Program exception_program = m_context->createProgramFromPTXString(ptx, "exception");
	m_context->setExceptionProgram(0, exception_program);

	// Closest hit
	m_closest_hit = m_context->createProgramFromPTXString(ptx, "closest_hit");
	m_material->setClosestHitProgram(0, m_closest_hit);

	// ANy hit
	m_any_hit = m_context->createProgramFromPTXString(ptx, "any_hit");
	m_material->setAnyHitProgram(0, m_any_hit);
}

I have added private variables in optixRayCasting.h

optix::Material m_material;
optix::Program m_closest_hit;
optix::Program m_any_hit;

When I invoke the optix code, I end up getting the following errors:

Invalid context (Details: Function "_rtContextLaunch1D" caught exception: Validation error: Geometry does not have a primitive count)

I want to know if there is anything that I am missing when initializing the meshes in the scene, Or is there any other method that needs to be followed to add obj models in the scene. Any insights are helpful.

Also, I want to attach the closest_hit and any_hit program to the new meshes.

TIA.