void convertHairSet(ISPCHairSet* hair, RTCScene scene_out)
{
  unsigned int geomID = rtcNewHairGeometry (scene_out, RTC_GEOMETRY_STATIC, hair->numHairs, hair->numVertices, hair->v2 ? 2 : 1);
  rtcSetBuffer(scene_out,geomID,RTC_VERTEX_BUFFER,hair->v,0,sizeof(Vertex));
  if (hair->v2) rtcSetBuffer(scene_out,geomID,RTC_VERTEX_BUFFER1,hair->v2,0,sizeof(Vertex));
  rtcSetBuffer(scene_out,geomID,RTC_INDEX_BUFFER,hair->hairs,0,sizeof(ISPCHair));
  rtcSetOcclusionFilterFunction(scene_out,geomID,(RTCFilterFunc)&filterDispatch);
}
unsigned int convertHairSet(ISPCHairSet* hair, RTCScene scene_out)
{
  unsigned int geomID = rtcNewHairGeometry (scene_out, RTC_GEOMETRY_STATIC, hair->numHairs, hair->numVertices, hair->v2 ? 2 : 1);
  rtcSetBuffer(scene_out,geomID,RTC_VERTEX_BUFFER,hair->v,0,sizeof(Vertex));
  if (hair->v2) rtcSetBuffer(scene_out,geomID,RTC_VERTEX_BUFFER1,hair->v2,0,sizeof(Vertex));
  rtcSetBuffer(scene_out,geomID,RTC_INDEX_BUFFER,hair->hairs,0,sizeof(ISPCHair));
  return geomID;
}
Beispiel #3
0
  /* adds a hair to the scene */
  unsigned int addHair(RTCScene scene_i)
  {
    unsigned int geomID = rtcNewHairGeometry (scene_i, RTC_GEOMETRY_STATIC, 1, 4, 1);

    float4* pos = (float4*) rtcMapBuffer(scene_i,geomID,RTC_VERTEX_BUFFER);
    pos[0] = float4(0.0f,0.0f,0.0f,0.1f);
    pos[1] = float4(0.0f,1.0f,0.0f,0.1f);
    pos[2] = float4(0.0f,2.0f,0.0f,0.1f);
    pos[3] = float4(0.0f,3.0f,0.0f,0.1f);
    rtcUnmapBuffer(scene_i,geomID,RTC_VERTEX_BUFFER);

    int* index = (int*) rtcMapBuffer(scene_i,geomID,RTC_INDEX_BUFFER);
    index[0] = 0;
    rtcUnmapBuffer(scene_i,geomID,RTC_INDEX_BUFFER);
    
    return geomID;
  }
Beispiel #4
0
RTCScene convertScene(ISPCScene* scene_in)
{
  //scene_in->numHairSets = 0;
  //scene_in->numMeshes = 0;

  /* create scene */
  RTCScene scene_out = rtcNewScene(RTC_SCENE_STATIC | RTC_SCENE_INCOHERENT, RTC_INTERSECT1);

  /* add all hair sets to the scene */
  for (int i=0; i<scene_in->numHairSets; i++)
  {
    ISPCHairSet* hair = scene_in->hairs[i];
    unsigned int geomID = rtcNewHairGeometry (scene_out, RTC_GEOMETRY_STATIC, hair->numHairs, hair->numVertices, hair->v2 ? 2 : 1);
    rtcSetBuffer(scene_out,geomID,RTC_VERTEX_BUFFER,hair->v,0,sizeof(Vertex));
    if (hair->v2) rtcSetBuffer(scene_out,geomID,RTC_VERTEX_BUFFER1,hair->v2,0,sizeof(Vertex));
    rtcSetBuffer(scene_out,geomID,RTC_INDEX_BUFFER,hair->hairs,0,sizeof(ISPCHair));
    rtcSetOcclusionFilterFunction(scene_out,geomID,(RTCFilterFunc)&filterDispatch);
  }

  /* add all triangle meshes to the scene */
  for (int i=0; i<scene_in->numMeshes; i++)
  {
    ISPCMesh* mesh = scene_in->meshes[i];
    unsigned int geomID = rtcNewTriangleMesh (scene_out, RTC_GEOMETRY_STATIC, mesh->numTriangles, mesh->numVertices, mesh->positions2 ? 2 : 1);
    rtcSetBuffer(scene_out,geomID,RTC_VERTEX_BUFFER,mesh->positions,0,sizeof(Vertex));
    if (mesh->positions2) rtcSetBuffer(scene_out,geomID,RTC_VERTEX_BUFFER1,mesh->positions2,0,sizeof(Vertex));
    rtcSetBuffer(scene_out,geomID,RTC_INDEX_BUFFER,mesh->triangles,0,sizeof(ISPCTriangle));
    rtcSetOcclusionFilterFunction(scene_out,geomID,(RTCFilterFunc)&filterDispatch);
  }

  /* commit changes to scene */
#if !defined(PARALLEL_COMMIT)
  rtcCommit (scene_out);
#else
  launch[ getNumHWThreads() ] parallelCommit(scene_out); 
#endif

  return scene_out;
}
extern "C" unsigned ispcNewBezierCurves (RTCScene scene, RTCGeometryFlags flags, size_t numCurves, size_t numVertices, size_t numTimeSteps) {
    return rtcNewHairGeometry(scene,flags,numCurves,numVertices,numTimeSteps);
}
Beispiel #6
0
RTCScene convertScene(ISPCScene* scene_in)
{
  //scene_in->numHairSets = 0;
  //scene_in->numMeshes = 0;

  /* create scene */
  RTCScene scene_out = rtcNewScene(RTC_SCENE_STATIC | RTC_SCENE_INCOHERENT, RTC_INTERSECT1);

  /* add all hair sets to the scene */
  for (int i=0; i<scene_in->numHairSets; i++)
  {
    ISPCHairSet* hair = scene_in->hairs[i];
    unsigned int geomID = rtcNewHairGeometry (scene_out, RTC_GEOMETRY_STATIC, hair->numHairs, hair->numVertices, hair->v2 ? 2 : 1);
    rtcSetBuffer(scene_out,geomID,RTC_VERTEX_BUFFER,hair->v,0,sizeof(Vertex));
    if (hair->v2) rtcSetBuffer(scene_out,geomID,RTC_VERTEX_BUFFER1,hair->v2,0,sizeof(Vertex));
    rtcSetBuffer(scene_out,geomID,RTC_INDEX_BUFFER,hair->hairs,0,sizeof(ISPCHair));
    rtcSetOcclusionFilterFunction(scene_out,geomID,(RTCFilterFunc)&filterDispatch);
  }

  /* add all triangle meshes to the scene */
  for (int i=0; i<scene_in->numMeshes; i++)
  {
    ISPCMesh* mesh = scene_in->meshes[i];
   
    if (mesh->numQuads)
     {
     g_subdiv_mode = true;

      size_t numPrimitives = mesh->numQuads;
      size_t numEdges      = mesh->numQuads*4;
      mesh->edge_level             = new float[numEdges];
      int *index_buffer = new int[numEdges];
      
      for (size_t i=0; i<numEdges; i++) 
	mesh->edge_level[i] = FIXED_EDGE_TESSELLATION_VALUE;
      
      /* create a triangle mesh */
      unsigned int geomID = rtcNewSubdivisionMesh (scene_out, RTC_GEOMETRY_STATIC, numPrimitives, numEdges, mesh->numVertices, 0, 0, 0);
      mesh->geomID = geomID;

      unsigned int* faces = (unsigned int*) rtcMapBuffer(scene_out, geomID, RTC_FACE_BUFFER);
      for (size_t i=0; i<mesh->numQuads    ; i++) faces[i] = 4;
      
      rtcUnmapBuffer(scene_out,geomID,RTC_FACE_BUFFER);

      for (size_t i=0; i<mesh->numQuads; i++)
      	 {
	   index_buffer[4*i+0] = mesh->quads[i].v0;
	   index_buffer[4*i+1] = mesh->quads[i].v1;
	   index_buffer[4*i+2] = mesh->quads[i].v2;
	   index_buffer[4*i+3] = mesh->quads[i].v3;	   
	 }

      rtcSetBuffer(scene_out, geomID, RTC_VERTEX_BUFFER, mesh->positions , 0, sizeof(Vec3fa  ));
      rtcSetBuffer(scene_out, geomID, RTC_INDEX_BUFFER,  index_buffer    , 0, sizeof(unsigned int));
      rtcSetBuffer(scene_out, geomID, RTC_LEVEL_BUFFER,  mesh->edge_level, 0, sizeof(float));
      
#if ENABLE_DISPLACEMENTS == 1
      rtcSetDisplacementFunction(scene_out,geomID,(RTCDisplacementFunc)&displacementFunction,NULL);
#endif
     } 
    else if (mesh->numTriangles)
    {
     unsigned int geomID = rtcNewTriangleMesh (scene_out, RTC_GEOMETRY_STATIC, mesh->numTriangles, mesh->numVertices, mesh->positions2 ? 2 : 1);
     rtcSetBuffer(scene_out,geomID,RTC_VERTEX_BUFFER,mesh->positions,0,sizeof(Vertex));
     if (mesh->positions2) rtcSetBuffer(scene_out,geomID,RTC_VERTEX_BUFFER1,mesh->positions2,0,sizeof(Vertex));
     rtcSetBuffer(scene_out,geomID,RTC_INDEX_BUFFER,mesh->triangles,0,sizeof(ISPCTriangle));
     rtcSetOcclusionFilterFunction(scene_out,geomID,(RTCFilterFunc)&filterDispatch);
    }
  
  }


  /* commit changes to scene */
  rtcCommit (scene_out);

  return scene_out;
}