sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Importer in the same wind order

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 2 Posters 180 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • G Offline
      giuseppe500
      last edited by

      hello.
      I'm trying to finish a sketchup importer for opengl in c++ .
      My problem is that the shaders that represent the materials of sketchup are five:
      1)front color back color
      2)front color back texture
      3)texture front, back color
      4)double color
      5)double texture.

      in these shaders i use the gl_frontfacing (that return true if the face is front and false if the face is back )for draw the different materials.
      For example ,in case 2: in the pixel shader:

      if(gl_frontFacing)
      {
      gl_color = frontColor
      }
      else
      {
      gl_color = texture color
      }

      ecc...

      I see that the gl_frontFacing return true if the vertexes are in counterclockwise order or the opposite, i'm not remember good, The problem is that in my importer i have some faces that are counterclockwise and others that are clockwise , then i get a wrong model.
      I think that the problem is the indexes order of the vertexes , how i can get all the faces in an unique wind order?
      thanks.

      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        If you get the face.vertices they won't always return in the direction expected; however,
        face.outer_loop.vertices should always return them counterclockwise around the face normal; with all other face.loops [i.e. holes] return their vertices clockwise ❓

        TIG

        1 Reply Last reply Reply Quote 0
        • G Offline
          giuseppe500
          last edited by

          thanks TIG.
          Now i must find a method for import all faces in correct wing order:
          1)i see that there is a m_pMesh->GetPolygonPointIndex(m_nCurrPoly+1, m_nCurrPoint+1, &m_idx);
          is sufficent have the correct indexes of the vertexes for import all in the correct windorder ?
          2) or i must separate the importation of vertexes like the sketchup example SkpToXml of the sdk?
          The sample project do that:
          extract the loops

          hr = pFace->get_Loops(&pLoops);
          long nLoops;
          hr = pLoops->get_Count(&nLoops);

          //If this is a simple face (no loops)
          if (nLoops==1){/////////////////////////////////////////////////////////////////is a simple face
          //import vertex in counterclockwise order

          CComPtr<ISkpLoop> pLoop;
          hr = pFace->get_OuterLoop(&pLoop);
          CComPtr<ISkpVertices> pVerts;
          hr = pLoop->get_Vertices(&pVerts);
          }
          else ///////////////////////////////////////////////////////////////////is a complex face tessellate it with:

          pFace->CreateMeshWithUVHelper(3, pUVHelper, &pMesh);
          and imports vertex in clockwise order?????
          //there i must place the m_pMesh->GetPolygonPointIndex??? and import in specific order????
          ecc....

          is sufficent????

          Thanks a lot.

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post
          Buy SketchPlus
          Buy SUbD
          Buy WrapR
          Buy eBook
          Buy Modelur
          Buy Vertex Tools
          Buy SketchCuisine
          Buy FormFonts

          Advertisement