Exemple #1
0
void 
Renderer::CommitVolume()
{
	volume.commit();

	OSPModel model = ospNewModel();
	ospAddVolume(model, volume.getOSPVolume());
	ospCommit(model);
	ospSetObject(getRenderer(), "model", model);
	ospCommit(getRenderer());
}
Exemple #2
0
void VolumeViewer::importObjectsFromFile(const std::string &filename)
{
  if (!ownModelPerObject)
  // Create an OSPRay model and its associated model state.
  modelStates.push_back(ModelState(ospNewModel()));

  // Load OSPRay objects from a file.
  OSPObject *objects = ObjectFile::importObjects(filename.c_str());

  // Iterate over the objects contained in the object list.
  for (size_t i=0 ; objects[i] ; i++) {
    if (ownModelPerObject)
      modelStates.push_back(ModelState(ospNewModel()));

    OSPDataType type;
    ospGetType(objects[i], NULL, &type);

    if (type == OSP_GEOMETRY) {

      // Commit the geometry.
      ospCommit(objects[i]);

      // Add the loaded geometry to the model.
      ospAddGeometry(modelStates.back().model, (OSPGeometry) objects[i]);

    } else if (type == OSP_VOLUME) {

      // For now we set the same transfer function on all volumes.
      ospSetObject(objects[i], "transferFunction", transferFunction);
      ospCommit(objects[i]);

      // Add the loaded volume(s) to the model.
      ospAddVolume(modelStates.back().model, (OSPVolume) objects[i]);

      // Add to volumes vector for the current model.
      modelStates.back().volumes.push_back((OSPVolume) objects[i]);
    }

    if (ownModelPerObject)
      ospCommit(modelStates.back().model);
  }

  if (!ownModelPerObject)
  // Commit the model.
  ospCommit(modelStates.back().model);
}