Exemplo n.º 1
0
optix::GeometryInstance PolygonMesh::makeGeometry( optix::Context &m_context, optix::Material material ) {
	if (!initialised) {
		throw runtime_error("mesh programs not initialised");
	}

	optix::GeometryGroup model_group = m_context->createGeometryGroup();
	ObjLoader objloader0(model.filepath.c_str(), m_context, model_group, material);
	objloader0.setBboxProgram(bounding_box);
	objloader0.setIntersectProgram(intersection);
	objloader0.load(model.transform);


	model.tr = m_context->createTransform();
	model.tr->setChild(model_group);
	setPosition(model.tr, model.position, model_rot);


	optix::GeometryInstance gi = model_group->getChild(0);
	setMaterial(gi, material, "diffuse_color", model.colour);
	return gi;
}
Exemplo n.º 2
0
void Object::optixInit(optix::Context context) {

	try {
		
		// Make geometry group
		Optix.geometryGroup = context->createGeometryGroup();
		Optix.geometryGroup->setAcceleration(context->createAcceleration(OPTIX_GEOMETRY_BUILDER, OPTIX_GEOMETRY_TRAVERSER)); // TODO: Look into different traversers/builders

		// Add geometries
		for (uint i = 0; i < geometries.size(); i++) {
			geometries[i]->optixInit(context);
			Optix.geometryGroup->addChild(((TriangleMesh*)geometries[i])->Optix.geometryInstance);
		}

		// Make transform
		Optix.transform = context->createTransform();
		Optix.transform->setChild(Optix.geometryGroup);
		Optix.transform->setMatrix(true, matrix.e, NULL);

	} catch (optix::Exception e) {
		printException(e);
	}

}
Exemplo n.º 3
0
optix::Transform Transform::getOptixTransform( optix::Context& context )
{
    optix::Transform t = context->createTransform();
    t->setMatrix(false, this->arr, NULL);
    return t;
}