| 104 | | |
| 105 | | #if 0 |
| 106 | | bool computePixelCoords(osgProducer::Viewer* viewer,float x,float y,unsigned int cameraNum,float& pixel_x,float& pixel_y) |
| 107 | | { |
| 108 | | Producer::KeyboardMouse* km = viewer->getKeyboardMouse(); |
| 109 | | if (!km) return false; |
| 110 | | |
| 111 | | if (cameraNum>=viewer->getNumberOfCameras()) return false; |
| 112 | | |
| 113 | | Producer::Camera* camera=viewer->getCamera(cameraNum); |
| 114 | | Producer::RenderSurface* rs = camera->getRenderSurface(); |
| 115 | | |
| 116 | | Producer::InputArea* inputArea = km->getInputArea(); |
| 117 | | if( inputArea != NULL ) |
| 118 | | { |
| 119 | | // first locate which InputRectange is appropriate for specified RenderSurface. |
| 120 | | unsigned int i; |
| 121 | | for(i=0;i<inputArea->getNumRenderSurfaces();++i) |
| 122 | | { |
| 123 | | if (inputArea->getRenderSurface(i)==rs) break; |
| 124 | | } |
| 125 | | |
| 126 | | // the RenderSurface isn't in the InputArea list.. therefore cannot make mouse coords to it. |
| 127 | | if (i==inputArea->getNumRenderSurfaces()) return false; |
| 128 | | |
| 129 | | // we have a valid InputRectangle |
| 130 | | Producer::RenderSurface::InputRectangle ir = inputArea->getRenderSurface(i)->getInputRectangle(); |
| 131 | | |
| 132 | | float rx = (x-ir.left())/ir.width(); |
| 133 | | float ry = (y-ir.bottom())/ir.height(); |
| 134 | | |
| 135 | | int wx, wy; |
| 136 | | unsigned int w, h; |
| 137 | | rs->getWindowRectangle( wx, wy, w, h ); |
| 138 | | |
| 139 | | pixel_x = ((float)w)* rx; |
| 140 | | pixel_y = ((float)h)* ry; |
| 141 | | } |
| 142 | | else |
| 143 | | { |
| 144 | | float rx = (x+1.0f)*0.5f; |
| 145 | | float ry = (y+1.0f)*0.5f; |
| 146 | | |
| 147 | | int wx, wy; |
| 148 | | unsigned int w, h; |
| 149 | | rs->getWindowRectangle( wx, wy, w, h ); |
| 150 | | |
| 151 | | pixel_x = ((float)w)* rx; |
| 152 | | pixel_y = ((float)h)* ry; |
| 153 | | } |
| 154 | | return true; |
| 155 | | } |
| 156 | | #endif |