Note that there are some explanatory texts on larger screens.

plurals
  1. POSharpGL - Point Cloud (drawn with GL_TRIANGLES from Kinect depth data) is not rotating on local axis coordinates
    text
    copied!<p>We are trying to translate the depth data that Kinect provides for us to a point cloud with the use of SharpGL (C# wrapper for OpenGL). Our goal is to create a 3D-model from the data that Kinect manages to give us. So far we have accomplished:</p> <ul> <li>Capture depth data (understand what it is that Kinect gives)</li> <li>Obtain x,y coordinates for each depth data given, thus generating our x,y,z points</li> <li>render said points using GL_Points (we can also render it using GL_Triangles, where one<br> triangle representes a SINGLE point)</li> <li>Capture keyboard events in order to Zoom-in and Zoom-out of the view of the point-cloud </li> </ul> <p>What we use:</p> <ul> <li>Visual Studio 2010</li> <li>Programming in C#</li> <li>Microsoft Kinect SDK 1.6</li> <li>SharpGL (C# wrapper for OpenGL)</li> </ul> <p>Problem:</p> <p>We manage to render our (x,y,z) points onto the opengGLControl, we can zoom-in and zoom-out and appreciate the points drawn. As a 3d-model interaction requires, we have moved on to try and rotate (over y axis) our point cloud. Here is where our troubles begin.</p> <p>Our point cloud DOES rotate, just not on the local coordinates that we want. When it begins to rotate it seems to do so along the world y axis, but not the object´s local y axis. Seeing as how SharpGL doesn´t allow to set a "center rotation point" (because there is a world coordinate system and a local coordinate system for each object) we have tried to follow different tutorials that explain a combination of gl.Translate(...) and gl.Rotate(...).</p> <ol> <li>gl.Translate(..) // Move to center point that you want as "center rotation point" for // your object</li> <li>gl.Rotate(..) // Rotate along wanted axis with specified angle of rotation</li> <li>gl.Translate(..) // Move back to original points where you want your object drawn</li> </ol> <p>We have tried doing this with a single triangle in order to make sure that we understand what needs to be done:</p> <hr> <pre><code> private float zoom = -7.0f; private float xAxis = -3.5f; //this is done so that image can be rendered in // the center of our view ************************************* OpenGL gl = openGLControl.OpenGL; gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); gl.LoadIdentity(); float xAxisReturn = this.xAxis - 3.55f; //Needed for the second gl.Translate() float yAxisReturn = 1.5f + 2.25f; float zoomReturn = this.zoom - 0.67f; gl.Translate(3.55f, -2.25f, 0.67f); //Center Point calculated personally for // the SINGLE triangle drawn gl.Rotate(this.triangleRotation, 0.0f, 1.0f, 0.0f); gl.Translate(xAxisReturn, yAxisReturn, zoomReturn); //means that the object will //be drawn at (-3.5f, 1.5f, -7f) gl.Begin(OpenGL.GL_TRIANGLES); gl.Color(0f, 1f, 0f); gl.Vertex(3.55f, -2.18f, 0f); gl.Vertex(3.45f, -2.28f, 1f); gl.Vertex(3.65f, -2.28f, 1f); gl.End(); </code></pre> <hr> <p>Result? Same as if we would not have done those two gl.Translate(...) and would have directly done:</p> <pre><code> gl.Translate(-3.5f, 1.5f, -7f); gl.Rotate(this.triangleRotation, 0.0f, 1.0f, 0.0f); </code></pre> <p>In conclusion, we want to be able to rotate our point cloud over it's own local axis, but we just seem to not be able to set it's "center rotation point". Thing is, since the code is valid (no errors occur) we don't know why it´s not doing as it is supposed to do.</p> <p>We'd preferably have it rendered with GL_POINTS instead of GL_TRIANGLES because of how it looks. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload