hi francesco !

bravo bravissimo !! thanks a lot for your tip about normalizing the coordinates … without you it could have token me years to find … yes now it’s working !!

i did exactly what you suggested :

warpedPoint.x = warpedPoint.x / warpedPoint.w;

warpedPoint.y = warpedPoint.y / warpedPoint.w;

warpedPoint.z = warpedPoint.z / warpedPoint.w;

and put

mousePoint.w = 1.0;

!!!

also i’ve changed some minor details in ofxGLWarper … i’ll try to tell the author and maybe they make sense, maybe are no sense . For example : changed the draw() function by begin() and added a end() also to make more clear (in my opinion) how it works, more like a ofFbo or ofShader …

and i’ve added 2 functions :

one to get the Warped space coordinates from a Screen spac coordinates .

and another one to get the Screen space coordinates from a Warped spac coordinates .

i leave it here in case someone needs it …

thanks everyone ;)!

e*

```
.h
//void draw();
void begin(); //changed name from draw to begin
void end(); //added to make it easier to use, similar to ofFbo (begin,end)
ofVec4f fromScreenToWarpCoord(float x,float y,float z);
ofVec4f fromWarpToScreenCoord(float x,float y,float z);
```

```
.cpp
//--------------------------------------------------------------
//--------------------------------------------------------------
void ofxGLWarper::begin(){
if (active) {
processMatrices();
}
glPushMatrix();
glMultMatrixf(myMatrix);
}
//--------------------------------------------------------------
void ofxGLWarper::end(){
glPopMatrix();
}
ofVec4f ofxGLWarper::fromScreenToWarpCoord(float x, float y, float z)
{
ofVec4f mousePoint;
ofVec4f warpedPoint;
// this is the point on the image which i want to know the coordinates inside the warped system ...
mousePoint.x = x;
mousePoint.y = y;
mousePoint.z = 0.0;
mousePoint.w = 1.0;
// i create a ofMatrix4x4 with the ofxGLWarper myMatrixData in column order
ofMatrix4x4 myOFmatrix = ofMatrix4x4(myMatrix[0], myMatrix[4],myMatrix[8],myMatrix[12],
myMatrix[1], myMatrix[5],myMatrix[9], myMatrix[13],
myMatrix[2], myMatrix[6],myMatrix[10],myMatrix[14],
myMatrix[3],myMatrix[7],myMatrix[11],myMatrix[15]);
// do not invert the matrix
ofMatrix4x4 invertedMyMatrix = myOFmatrix.getInverse();
//ofMatrix4x4 invertedMyMatrix = myOFmatrix;
// multiply
warpedPoint = invertedMyMatrix * mousePoint ;
warpedPoint.x = warpedPoint.x / warpedPoint.w;
warpedPoint.y = warpedPoint.y / warpedPoint.w;
warpedPoint.z = warpedPoint.z / warpedPoint.w;
return warpedPoint;
}
//--------------------------------------------------------------
ofVec4f ofxGLWarper::fromWarpToScreenCoord(float x, float y, float z)
{
ofVec4f mousePoint;
ofVec4f warpedPoint;
// this is the point on the image which i want to know the coordinates inside the warped system ...
mousePoint.x = x;
mousePoint.y = y;
mousePoint.z = 0.0;
mousePoint.w = 1.0;
// i create a ofMatrix4x4 with the ofxGLWarper myMatrixData in column order
ofMatrix4x4 myOFmatrix = ofMatrix4x4(myMatrix[0], myMatrix[4],myMatrix[8],myMatrix[12],
myMatrix[1], myMatrix[5],myMatrix[9], myMatrix[13],
myMatrix[2], myMatrix[6],myMatrix[10],myMatrix[14],
myMatrix[3],myMatrix[7],myMatrix[11],myMatrix[15]);
// invert the matrix
//ofMatrix4x4 invertedMyMatrix = myOFmatrix.getInverse();
ofMatrix4x4 invertedMyMatrix = myOFmatrix;
// multiply
warpedPoint = invertedMyMatrix * mousePoint ;
warpedPoint.x = warpedPoint.x / warpedPoint.w;
warpedPoint.y = warpedPoint.y / warpedPoint.w;
warpedPoint.z = warpedPoint.z / warpedPoint.w;
return warpedPoint;
}
```