Forum > OpenGL
Graduated colour depending on offset from original position
ranny:
Hi,
I have been working on a program that calculates stresses and deflection of a structure under various loading conditions. Currently I can draw the model and I can draw, at the moment, the deflected state. I know what the maximum deflection is for any part of the structure and what I would like is to have the deflection image display the shape with graduated colour, say, from blue to red, based on amount of deflection.
On the attached image the original framework is shown and the deflected shape is in red. So what I would like is for any node that is deflected the elements between will be coloured based on how much it is deflected from its original position.
wp:
If you do this drawing in OpenGL you can specify a color after every vertex of the line segments, and OpenGL will interpolate colors between them:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- glBegin(GL_LINES); glColor3f(1, 0, 0); glVertex3f(-1, -1, 0); glColor3f(0, 0, 1); glVertex3f(0, 1, 1); glEnd;
If you draw with standard LCL graphics canvas commands, you will have to write your own Line() method. If you draw with BGRABitmap you probably find a corresponding line-drawing method in the codebase.
ranny:
Hi wp,
I was aware of being able to do this and I guess I have a bit of coding to do to get it to work in the three directions for each node. I was just wondering if there was a quicker solution.
I will give it a try and see how I get on.
Thanks as always.
wp:
Which graphics library do you use for drawing?
ranny:
Hmm... I'm not very good at identifying these things, I just installed the lazOpenGlContext package and use the basic OpenGl commands. Lazarus is version 3.2 with FPC 3.2.2 if that makes a difference....
Navigation
[0] Message Index
[#] Next page