Menu

Transform matrix doesnt work with GLModels

Help
Anonymous
2011-10-05
2013-01-14
  • Anonymous

    Anonymous - 2011-10-05

    Looks like applyMatrix and setMatix doesnt affect GLModels.

    translate,rotate, scale stuff works. but if i want apply transformations from matrix. this dont work.
    is this bug? or my mistake?

     
  • Andres Colubri

    Andres Colubri - 2011-10-05

    enclose the calls that you want to affect the GLModel object beween beginGL()/endGL(): 

    GLGraphics renderer = (GLGraphics)g;
    renderer.beginGL();

    translate(…);
    model.render();

    renderer.endGL();

     
  • Anonymous

    Anonymous - 2011-10-05

    I mean only matrix dont work

    for example in following code transformations works only for box object, not for wings.

      renderer.beginGL(); 
      background(0);
      PMatrix3D orientation = new PMatrix3D();
      orientation.translate(width/2,height/2,0);
      orientation.rotateX(PI/2);
      applyMatrix(orientation);
      renderer.model(wings); // dont work for this
      box(100); // work for this, translated and rotated
      
      renderer.endGL();
    
     
  • Andres Colubri

    Andres Colubri - 2011-10-05

    Ok, you are right, thanks for the feedback. The applyMatrix() method is not implemented in the GLGraphics renderer. Could you open a bug report in the tracker about this?

    Now my priority is to wok on Processing 2.0, I will come back to this issue in a later time for a maintenance release of GLGraphics.

     
  • Anonymous

    Anonymous - 2011-10-05

    thanx for the tip. i fixed it in sources. now it works very well.

    code below, just for info

        public void applyMatrix(PMatrix3D source) {
            applyMatrix(source.m00, source.m01, source.m02, source.m03, source.m10,
                    source.m11, source.m12, source.m13, source.m20, source.m21,
                    source.m22, source.m23, source.m30, source.m31, source.m32,
                    source.m33);
        }
        public void applyMatrix(float n00, float n01, float n02, float n03,
                float n10, float n11, float n12, float n13, float n20, float n21,
                float n22, float n23, float n30, float n31, float n32, float n33) {
            gltemp[0] = n00;
            gltemp[1] = n10;
            gltemp[2] = n20;
            gltemp[3] = n30;
            gltemp[4] = n01;
            gltemp[5] = n11;
            gltemp[6] = n21;
            gltemp[7] = n31;
            gltemp[8] = n02;
            gltemp[9] = n12;
            gltemp[10] = n22;
            gltemp[11] = n32;
            gltemp[12] = n03;
            gltemp[13] = n13;
            gltemp[14] = n23;
            gltemp[15] = n33;
            if (glMode) {
                gl.glMultMatrixf(gltemp, 0);
            } else {
                super.applyMatrix(n00,n01,n02,n03,n10,n11,n12,n13,n20,n21,n22,n23,n30,n31,n32,n33);
            }
        }
    
     
  • Andres Colubri

    Andres Colubri - 2011-10-05

    Excellent! I will include your code into the trunk. Thanks so much!

     
  • solipsy

    solipsy - 2013-01-14

    Hi Andres,

    I tried to apply the Matrix to a model in the GLGraphicsOffscreen in new version of GLGraphics, but it doesn't work.
    It should probably work with a low-level GL call like the other guy posted in his code?

    Cheers, and thanks.

     

Log in to post a comment.