Jump to content
  • Advertisement

Dzogchener

Member
  • Content Count

    47
  • Joined

  • Last visited

Everything posted by Dzogchener

  1. Dzogchener

    Wpf, Scrolling Graph and Performance

    Thank you very much for this example. It is major food for thought, thank you. D
  2. Hi- I posted the following message to the .Net forum, but I am also interested in how this could be done differently, possibly agnostic to wpf per se. From a graphics programming perspective how could this be achieved and not cost the earth in cpu: Thanks for any advice: Hi, I am looking for some design/graphics advice. I have built a little graph in Wpf, which is a descendant of Canvas. The graphs core design is that it scrolls from right to left, exactly like the CPU performance graph does in the Windows task manager. I achieved this by running through the data points, drawing from left to right. Each time graph is updated I essentially move one data point in, and draw a little from the left of the previous. What this essentially means is that when I have enough data points to fill the actual graph visually, I run from the left position to the right position, pulling out the data points as I go. I have to do this for every update. So if the graph is visually 600 pixels wide, and the refresh rate is every 1 second, that involves drawing each line from left to right, every single time. I am wondering if there is a smarter approach to this type of problem. I knocked up the logic for this as it stands today, so I expect I am doing this completely wrong. This approach seems to be burning CPU time like nobodies business. Any advice? Thanks, D
  3. Dzogchener

    Wpf, Scrolling Graph and Performance

    Thanks ernow. I am in th emean time doing some research on clipping in wpf....
  4. Hi, I am looking for some design/graphics advice. I have built a little graph in Wpf, which is a descendant of Canvas. The graphs core design is that it scrolls from right to left, exactly like the CPU performance graph does in the Windows task manager. I achieved this by running through the data points, drawing from left to right. Each time graph is updated I essentially move one data point in, and draw a little from the left of the previous. What this essentially means is that when I have enough data points to fill the actual graph visually, I run from the left position to the right position, pulling out the data points as I go. I have to do this for every update. So if the graph is visually 600 pixels wide, and the refresh rate is every 1 second, that involves drawing each line from left to right, every single time. I am wondering if there is a smarter approach to this type of problem. I knocked up the logic for this as it stands today, so I expect I am doing this completely wrong. This approach seems to be burning CPU time like nobodies business. Any advice? Thanks, D
  5. Dzogchener

    Wpf, Scrolling Graph and Performance

    Hi ernow- Thats a very interesting idea - I would need to do it from right to left rather than the inverse, but I think it would be possible. I havent played with clipping, so will take a look at that approach. you wouldnt happen to know of any examples of this technique online would you? Thanks alot! D.
  6. Dzogchener

    Wpf, Scrolling Graph and Performance

    Hi- That does make total sense to me - many years ago I did Masm+watcom c graphics programming in mode-x (320x240) on the PC. We used to write offline to a 64k buffer and bitblit onto the vgascreen when the crt beam was on its way back to the top (cant remember the term for that). So I was thinking about that approach, perhaps drawing to an offline buffer and then somehow just pasting in the OnRender - I guess its hard for you to know what this is given you dont know wpf. One wrinkle is the window has some transparency, which might not be a major issue. Possibly more of an issue is that I have a rendered grid, and then the lines are drawn onto it. Today on each call to render, I draw the grid, then draw each data series onto the canvas. If I were to look into double-buffering in the theme of above, I think I would need to have one bitmap for the grid, one for the data series, and then xor them onto the same canvas, or something. Thanks for the feedback/food for thought. D
  7. Dzogchener

    Mapping Mouse Click to 3D object

    Hi Mathias, Thanks for your reply yesterday it gave me a lot to think about. In your last reply you mention at the end of performing an inverse calculation to get the initial position. What I cant work out now is given I am using open gl, how I get the world, view and projection matrix so I can do this calculation? I did some more research and found this post: http://www.gamedev.net/community/forums/topic.asp?topic_id=65558. This looks like it essentially goes the other way, producing a value that is in 3D space - maybe if I could then calculate if an object sits within or around that point I could detect which item was selected? Incidentally as I read that post I realise GetDoublev(GL_MODELVIEW_MATRIX) returns the model matrix, which answers my qandry above. Would I be correct in assuming using my own calculations here (eventually) would be more performant than using open gl picking? Samoth mentions calling unproject twice and then doing a collision detection - would anyone have an example of this approach? Many thanks, D
  8. Hi, I would really like some pointers/advice on how I can detect which 3D object a mouse click sits within. I have build a 10x10 grid, looking at it face on. I want to click one of the squares so I can do somethign with it, but I am not sure how I map a mouse click to 3D coordinates and then work out if the click resides within an object. I am using open gl, so my transforms etc are happening through it, so all I have is a square around the origin that is translated when I draw it. I guess I can use the translation calucation to map a position on my x and y plane... Any advice on this would be most appreciated, D
  9. Dzogchener

    Mapping Mouse Click to 3D object

    Hi Mathias, Thanks for your help - much appreciated. Some of my confusion comes from the fact I havent needed to use any matrices yet, beyond the calls to GL. I have a routne that draws a square around the origin using glVertex(..) andI use glTransform and glRotate at particular points. Now that I need to do more math (and I know so far I have got off very lightly), I am not sure if I need to be creating my own matrix objects - I have managed not to use these so far. I will take a look at your links - the first one looks pretty useful in explaining things, albeit for direct x. I appreciate the help, thanks, D
  10. Dzogchener

    Mapping Mouse Click to 3D object

    Hi Mathias, I think you posted just after I did...thanks for the code I will look through it. I found this link just after posting : http://www.opengl.org/resources/faq/technical/selection.htm. This all looks scarily complicated :-( D
  11. Dzogchener

    Mapping Mouse Click to 3D object

    Thanks for the advice.... I found the following link: http://www.glprogramming.com/red/chapter13.html, and wondered why it doesnt mention Unproject and instead mentions selection and picking? Is the red book out of date? Thanks, D
  12. Dzogchener

    Beginner: Help getting started in 3D

    Hi Gauge, My question was a dumb one yesterday and I managed to solve it doing exaclty as you suggest. This now allows me ot build a grid up, and have both the complete grid and the individual squares rotate independently which is what I was after. Again I really appreciate the help. D.
  13. Hi, I have been trying to get started with open gl and I have failed to get little further than the starting line. I understand 2D geometry well, but I am failing to make progress with 3D as my maths is not brilliant. I started trying to build a grid of squares, which I have managed to do, but there are some fundamentals I am not getting. My specific issue is that I dont know how to choose my units or my camera in a 3D world so that I can see all of the grid perfectly up to the edges of the screen, with a blank border around the edges. If anybody has some advice or links to something that will get me started in this area I would be really grateful. I appreciate my question my be silly, but I am a beginner and while I have a few 3D books they are pretty hardcore and I dont meet the entry level with the math. However I am sure that with a few useful links/tips I can get going. Thank you, D.
  14. Hi, My question probably has a simple answer so please forgive my stupidity... I have 3 squares drawn to the screen, one in the center and one either side. The squares are made out of quads, and I build them during initialisation only. In my draw routine I loop through each object and perform: 1. LoadIdentity 2. Translate (x, y, z) 3. Rotate(angle, xv, yv, zv) 4. Draw quad So I want to create an animation that sees each quad rotate along its y axis such that it looks as if it is rotating on a pole - so it doesnt move around the screen but remains static in the x position, and simply rotates. What I get instead is that the 3 squares all rotate around as if they are connected and there is a pole going through the middle of the center square. I dont know how to change this so each square/quad rotates in-place. Any advice? Thanks, D
  15. Dzogchener

    Beginner: Help getting started in 3D

    Hi Gauge, Would each square have exactly the same vertices? That is, the only thing that changes is the translation before drawing? Apologies if this is a stupid quesiton. D
  16. Dzogchener

    Beginner: Help getting started in 3D

    Actually I think I have done something wrong... I have created my squares out of quads, and calculated them doing the following: 1. Working out the xplane size and yplane size 2. Workout the number of cols and rows of squares I want to create 3. Map each square onto vertexes around the origin. 4. Set the viewport/camera and translate the z so I see the squares/grid. What this means is if I have an xplane size of say 10 and I want 5 squares, the left square starts at (-5, -5, 0) and extends across x to (-3,-5,0). The next square begins at (-3,-5,-0) and extends to (-1, -5, 0). I never change these vertex values when rendering, I only use the gl.Rotate and Translate to move. I think this is my problem. I am wondering whether each square should be the same, that is (-1, 1, 0) to (1,1,0) with respect to the its dimension on the x axis, and then use rotate and translate to move it. A little lost... Thanks for any help, D.
  17. Dzogchener

    Beginner: Help getting started in 3D

    Managed to get this working after reading the Red book online. Thanks. D.
  18. Hi, I have drawn a square of a particulare colour and I want to use the Alpha to change its brightness (someone advised me to use this to emulate a flashing light). I have enabled blending and switched off DEPTH_TEST. I then do the following right before drawing a quad: gl.Color( colour.R, colour.G, colour.B, colour.Alpha ); gl.BlendFunc(OpenGL.ALPHA, OpenGL.ONE); I have played around with this but the colour remains the same. My intention is, when I have a backdrop, for the square to pulse in and out, but its made of a solid colour. Thanks for any help, D
  19. Dzogchener

    Beginner: Help getting started in 3D

    On the advice from Porsche_Man I have ordered 3D Math Primer. In the mean time I would like to make a bit more progress. I have been reading OpenGL Game Development, but there have been a few things that havent been explained that have left me perplexed. For exampIe I am hoping to port my game to the iPhone eventually, but I have been informed opengl es doesnt support orthographic projection, yet the game development book uses that extensively in all of its examples. Heres what I would just like to do: Create a 10 x 7 grid of squares and have them rendered to most of the screen area. Heres some problems I have: 1. I have a canvas/window that has a height and width - which projection/perspective should I use? 2. What units do I need to be using? If my width is 100 and I dont want a gap between squares, I would work out that the distance is 10 per square. Do you use this approach when building something like a grid here? I have actually managed to build a grid and show it but I had to play with the numbers. I decided some arbitrary numnber to use for the width and height (10.0f) and then divided my area up and plotted using a zero Z value. So I do the following: 1. Set the perspective: Perspective(45.0f, (float)Width / Height, 0.1f, 100.0f) 2. Translate along x,y and z. I set x and y to zero and z to -20f. 3. I then split the view up and draw quads. The grid does appear, but I admit its not exactly clear why, or rather the values arent clear. I just picked 10 out of the air for the width and height. Heres the code in the paint routine (using SharpGL and C#): private void openGLCtrl1_OpenGLDraw(object sender, PaintEventArgs e) { OpenGL gl = openGLCtrl1.OpenGL; gl.Clear(OpenGL.COLOR_BUFFER_BIT | OpenGL.DEPTH_BUFFER_BIT); gl.MatrixMode(OpenGL.MATRIX_MODE); GL.Perspective(45.0f, (float)Width / Height, 0.1f, 100.0f); gl.LoadIdentity(); gl.Translate(translateX, translateY, translateZ); double cols = 10; double rows = 7f; double xplaneSize = 10f; double yplaneSize = 10f; double widthDim = xplaneSize / cols; double heightDim = yplaneSize / rows; for (int c = 0; c < cols; c++) { gl.Begin(OpenGL.QUADS); for (int r = 0; r < rows; r++) { double left = -(xplaneSize / 2) + (c * widthDim); double top = (yplaneSize / 2) - (r * heightDim); gl.Color(0.15f, 0.15f, 0.15f); gl.Vertex(left, top, 0.0); gl.Vertex(left + widthDim - 0.05, top, 0.0); gl.Color(1f, 1f, 1f); gl.Vertex(left + widthDim - 0.05, top - heightDim + 0.05, 0.0); gl.Vertex(left, top - heightDim + 0.05, 0.0); } gl.End(); } } Thanks for any tips on this, D.
  20. Dzogchener

    Help making a start

    Hi, I have been trying to get started with open gl and I have failed to get little further than the starting line. I understand 2D geometry well, but I am failing to make progress with 3D as my maths is not brilliant. I started trying to build a grid of squares, which I have managed to do, but there are some fundamentals I am not getting. My specific issue is that I dont know how to choose my units or my camera in a 3D world so that I can see all of the grid perfectly up to the edges of the screen, with a blank border around the edges. If anybody has some advice or links to something that will get me started in this area I would be really grateful. I appreciate my question my be silly, but I am a beginner and while I have a few 3D books they are pretty hardcore and I dont meet the entry level with the math. However I am sure that with a few useful links/tips I can get going. Thank you, D.
  21. Dzogchener

    Help making a start

    Hi, Thanks for the advice, I ordered the book today. D
  22. Hi, I am trying to get to grips with open gl, because I want to build something but use 2D essentially. I admit I am not exactly sure how to set things up to work with open gl such that 2D works/looks ok. Right now I want to build a table of quads, as if each quad is a cell of a normal grid/table. Here is some code in Csharp: private void openGLCtrl1_OpenGLDraw(object sender, PaintEventArgs e) { SharpGL.OpenGL gl = this.openGLCtrl1.OpenGL; gl.Clear(OpenGL.COLOR_BUFFER_BIT | OpenGL.DEPTH_BUFFER_BIT); gl.LoadIdentity(); gl.Translate(translateX, translateY, translateZ); gl.Begin(OpenGL.QUADS); float cols = 13.0f; float rows = 10.0f; float xplaneSize = 10.0f; float yplaneSize = 10.0f; float widthDim = (float)xplaneSize / cols; float heightDim = (float)yplaneSize / rows; for (int c = 0; c < cols; c++) { for (int r = 0; r < rows; r++) { float left = -(xplaneSize / 2) + ((float)c * widthDim); float top = (yplaneSize / 2) - ((float)r * heightDim); gl.Vertex(left, top, 0.0f); gl.Vertex(left + widthDim - 0.05, top, 0.0f); gl.Vertex(left + widthDim-0.05, top - heightDim - 0.05, 0.0f); gl.Vertex(left, top - heightDim - 0.05, 0.0f); } } gl.End(); } So with this code I attempt to draw a table in the middle of the screen. I'd actually like to have the table flush against the borders of the screen, but I am lost as to how to calculate the units/measurements so I can do this (any advice?). So the translateX, translateY members are set to zero, and the transferZ is set to minus 10; When this code runs I get a grid thats not flush with the borders, but worse still is the fact that the table is missing the last column for rows 8, 9 and 10. I think my math above is just not right, and I admit I made them up arbitrarily. I just chose a plane size of 10 for x and y, but I admit I dont know how you work out the measurements. Any advice on how to improve the grid building would be really appreciated. Thanks, D
  23. Dzogchener

    Newbie Help with open GL and 2D

    So I moved the gl.Begin/gl.End into the loop and the grid draws properly. When I change the number of columns x rows I get to a point when the grid stops drawing as a proper table, implying there must be some limit to the number of quads/vertex's you can invoke within gl.Begin/gl.End? Thanks, D
  24. Hi, Just found this: http://cs-sdl.sourceforge.net/index.php/Main_Page. Thank you for showing me the light :) Looks like I have to go back to the drawing board... D
  25. Hi, I am new to graphics/game programming and I am just after some clarification on something that seems simple/fundamental. I am not using DirectX or OpenGL because I thought that because its 2D I dont need to use those technologies - is this a naive decision? I have a number of sprites that I am drawing to my main view. I want some of them to pulse - so fade in and fade out. I am not sure if I need to create n number of sprites - from brightest to darkest. If I do this so I have a strip per sprite that is bright to dark, I can then iterate over them in my render loop. Another way seems to be to create the fade on the fly (I am not sure how I do this yet, but thik I need to do alpha blending?). What would people advise? A second question relates to actually drawing the view. Currently I have a buffer the size of the main screen (which is a Picturebox in C#). On every render, I fill the background to black and then draw the sprites. I wondered if this is the correct approach or if there is a more efficient way of doing this? My concern is if the screen area is large, say 1024x768, the performance will degrade using this approach. Thanks for any help, D
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!