c# - How alter the camera in opengl so I can see my entire surface plot on screen? -


i using sharpgl in wpf application , have surface plot. problem when try move lookat camera away lot of plot disappears.... i'm new opengl, how can adjust camera can see plot multiple sides?

namespace sharpglwpfapplication1 {     /// <summary>     /// interaction logic mainwindow.xaml     /// </summary>     public partial class mainwindow : window     {       ///this set of 29 121 arrays cant put data here on stackoverflow         double[][] surface = new double[29][]              {new double[] { 0.157502594025719, 0.160975938019107, 0.168564003076642, 0.171284471913381, 0.174722441310675, 0.182467533566265, 0.190681891360462, 0.197452867532186, ..... }};            /// <summary>initializes new instance of <see cref="mainwindow"/> class.</summary>         public mainwindow()         {             initializecomponent();         }          /// <summary>         /// handles opengldraw event of openglcontrol1 control.         /// </summary>         /// <param name="sender">the source of event.</param>         /// <param name="args">the <see cref="sharpgl.scenegraph.opengleventargs"/> instance containing event data.</param>         private void openglcontrol_opengldraw(object sender, opengleventargs args)         {             //  opengl object.             opengl gl = openglcontrol.opengl;              //  clear color , depth buffer.             gl.clear(opengl.gl_color_buffer_bit | opengl.gl_depth_buffer_bit);              //  load identity matrix.             gl.loadidentity();              //  rotate around y axis.             gl.rotate(rotation, 0.0f, 1.0f, 0.0f);              //  nudge rotation.             rotation += 3.0f;              float r = 0.3f;             float g = 0.2f;             float b = 0.1f;              gl.translate(-10f, 0f, 0f);             gl.begin(opengl.gl_triangles);             (int x = 1; x < surface.getupperbound(0); ++x)             {                  (int y = 1; y < surface[0].getupperbound(0) + 1; ++y)                 {                     gl.color(r, g, b);                     double = surface[x - 1][y - 1];                     double b = surface[x][y - 1];                     double c = surface[x][y];                     double d = surface[x - 1][y];                     // 4 points on surface (they form quad)                      gl.vertex(x - 1, a, y - 1);                     gl.vertex(x, b, y - 1);                     gl.vertex(x, c, y);                     // draw triangle abc                      gl.vertex(x - 1, a, y - 1);                     gl.vertex(x, c, y);                     gl.vertex(x - 1, d, y);                     // draw triangle acd                     r += y;                     b += .0003f;                     g += .0001f;                 }                 //r += .03f;                 //b += .03f;                 //g += .03f;             }              gl.end();             }          /// <summary>         /// handles openglinitialized event of openglcontrol1 control.         /// </summary>         /// <param name="sender">the source of event.</param>         /// <param name="args">the <see cref="sharpgl.scenegraph.opengleventargs"/> instance containing event data.</param>         private void openglcontrol_openglinitialized(object sender, opengleventargs args)         {             //  todo: initialise opengl here.              //  opengl object.             opengl gl = openglcontrol.opengl;              //  set clear color.             gl.clearcolor(0, 0, 0, 0);         }          /// <summary>         /// handles resized event of openglcontrol1 control.         /// </summary>         /// <param name="sender">the source of event.</param>         /// <param name="args">the <see cref="sharpgl.scenegraph.opengleventargs"/> instance containing event data.</param>         private void openglcontrol_resized(object sender, opengleventargs args)         {             //  todo: set projection matrix here.              //  opengl object.             opengl gl = openglcontrol.opengl;              //  set projection matrix.             gl.matrixmode(opengl.gl_projection);              //  load identity.             gl.loadidentity();              //  create perspective transformation.             gl.perspective(60.0f, (double)width / (double)height, 0.01, 100.0);              //  use 'look at' helper function position , aim camera.             gl.lookat(-105, 105, -105, 50, 0, 0, 0, 1, 0);              //  set modelview matrix.             gl.matrixmode(opengl.gl_modelview);         }          /// <summary>         /// current rotation.         /// </summary>         private float rotation = 0.0f;     } } 

not sure using sharpgl, in perspective state want far clipping plane @ 100 , you're setting camera @ -105, 105, -105, further away 100. might fix problem setting far clipping plane further away?


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -