Announcement

Collapse
No announcement yet.

Assign per face shaders

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Hi,
    I tried to implement this type but struggle a bit to understand the different types. Below my piece of code that doesn't even compile. Would you have any hint/correct for me ?
    Code:
                DefMapChannelsParam param_uvs("map_channels",1);
                MapChannel oneMapChannel=param_uvs.getMapChannels();
                
                VectorRefList VL;
                IntList IL;
                IL.setCount(nbFaces);
                VL.setCount(nbFaces);
                for (int i=0;i<nbFaces;i++)
                {
                    VL[i]=Vector(myU[i],0.0f, myV[i]);
                    IL[i]=i;
                }
                oneMapChannel.setVerts(VL);
                oneMapChannel.setFaces(IL);
                
                baseGeomPlugin->setParameter(param_vs);
    Thanks for your hints !

    Comment


    • #17
      Something like that:
      Code:
                  DefMapChannelsParam param_uvs("map_channels",1);
                  MapChannelList &mapChannelsList=param_uvs.getMapChannels();
                  
                  DefMapChannelsParam::MapChannel &chan=(*(mapChannelsList.newElement()));
              
                  chan.idx=0;
                  chan.verts.setCount(nbFaces);
                  chan.faces.setCount(nbFaces*3);    
      
                  for (int i=0;i<nbFaces;i++) {
                      chan.verts[i]=Vector(myU[i],0.0f, myV[i]);
                      chan.faces[i*3+0]=i;
                      chan.faces[i*3+1]=i;
                      chan.faces[i*3+2]=i;
                  }
                  
                  baseGeomPlugin->setParameter(param_uvs);
      Best regards,
      Vlado
      I only act like I know everything, Rogers.

      Comment


      • #18
        Thanks. Will give it a try !

        Comment


        • #19
          Apart from adding a & into baseGeomPlugin->setParameter(&param_uvs), it now compiles fine.
          However the rendering crashes. If I remove this setParameter, then no crash anymore.
          What could be wrong ? I again checked that the amount of uvs is indeed the same as the amount of vertices, which is the case.
          Even by simply doing this:
          Code:
                      DefMapChannelsParam param_uvs("map_channels",1);
                      baseGeomPlugin->setParameter(&param_uvs);
          then it is crashing
          Last edited by lcrivell; 16-12-2015, 08:45 AM.

          Comment


          • #20
            The problem is that you are creating the parameter on the stack; if you only need one instance of the parameter, you can make it a member of your class, otherwise, create it on the heap using operator new() - you'll have to remember to delete it after the rendering though.

            Best regards,
            Vlado
            I only act like I know everything, Rogers.

            Comment


            • #21
              You are my hero, thanks !!

              Comment

              Working...
              X