ATTENTION

This FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices.


flexsim.com

Go Back   FlexSim Community Forum > FlexSim Software > User Development
FAQ Downloads Calendar Search Mark Forums Read

User Development User developed add-ons to Flexsim

View Poll Results: Do you find this functionality useful?
I would use better graphing options frequently 5 55.56%
I would use better graphing options some of the time 4 44.44%
I don't use the current graphing options 0 0%
Voters: 9. You may not vote on this poll

Reply
 
Thread Tools Display Modes
  #1  
Old 06-06-2008
Alex Christensen Alex Christensen is offline
Flexsim Technical Support
 
Join Date: Nov 2007
Location: Provo, UT
Posts: 96
Downloads: 41
Uploads: 8
Thanks: 29
Thanked 141 Times in 56 Posts
Rep Power: 290
Alex Christensen is a splendid one to beholdAlex Christensen is a splendid one to beholdAlex Christensen is a splendid one to beholdAlex Christensen is a splendid one to beholdAlex Christensen is a splendid one to beholdAlex Christensen is a splendid one to beholdAlex Christensen is a splendid one to behold
Default data display

With the new Flexscript OpenGL commands, we now have more ability to better display data. We could always use all the OpenGL commands in C++ and some draw commands in Flexscript, but now we have a little more control of drawing. These could be used to make new ways to display data in a model, instead of just using the recorder object.

I've attached three models that draw 3D graphs. There's a cartesian 3d graph of a function of x, y, and time, a polar function of theta, phi, and time, and an actual practical application that draws a 3D bar graph of a global table.

Most of the code is in the OnDraw triggers of the visual tools. This code can be adapted to make some cool data displays.
Attached Files
File Type: zip 3d graphs.zip (141.4 KB, 481 views)

Last edited by Brandon Peterson; 06-06-2008 at 11:47 AM.
Reply With Quote
The Following 7 Users Say Thank You to Alex Christensen For This Useful Post:
AlanZhang (06-07-2008), Brandon Peterson (06-09-2008), Cliff King (06-06-2008), Pablo Concha (06-09-2008), RalfGruber (06-14-2008), syseo (06-06-2008), tobias.biemueller (06-09-2008)
  #2  
Old 06-07-2008
AlanZhang's Avatar
AlanZhang AlanZhang is offline
Flexsim Super Moderator
 
Join Date: Aug 2007
Location: CA
Posts: 289
Downloads: 64
Uploads: 0
Thanks: 88
Thanked 91 Times in 47 Posts
Rep Power: 217
AlanZhang is a jewel in the roughAlanZhang is a jewel in the roughAlanZhang is a jewel in the rough
Default

Thanks, Alex. This is really great! The cartesian model (and polar model) shows a great way of visualizing functions with parameter t.

The different of Flexscript and C++ is so dramatic here. If I change it to Flexscript, Flexsim almost hang on. I guess here is the case that a DLL could be used.

Here is one interesting but simpler pattern (an ideal water wave) by using the following code:
Code:
        double t=10*sqrt(time()/100);
        double z00=5+cos(y0+t);
        double z01=5+cos(y1+t);
        double z10=z00;
        double z11=z01;
For the polar model, add two lines before draw rectangle to make it more interesting:
Code:
        double t=10*sqrt(time());
        glColor3d(sin(t+x00),cos(t+y00),(sin(t+z00)+cos(t+z00))/sqrt(2.0));
To view the effects, it is better to comment out the glEnable(GL_LIGHTING) line.

Some questions: What glDisable(2884); and glNormal3D do?
__________________
Best,
Alan

Last edited by AlanZhang; 06-07-2008 at 01:39 AM.
Reply With Quote
The Following User Says Thank You to AlanZhang For This Useful Post:
Cliff King (06-09-2008)
  #3  
Old 06-09-2008
Alex Christensen Alex Christensen is offline
Flexsim Technical Support
 
Join Date: Nov 2007
Location: Provo, UT
Posts: 96
Downloads: 41
Uploads: 8
Thanks: 29
Thanked 141 Times in 56 Posts
Rep Power: 290
Alex Christensen is a splendid one to beholdAlex Christensen is a splendid one to beholdAlex Christensen is a splendid one to beholdAlex Christensen is a splendid one to beholdAlex Christensen is a splendid one to beholdAlex Christensen is a splendid one to beholdAlex Christensen is a splendid one to behold
Default

First of all, here's an updated bar graph code. Copy it into any OnDraw trigger (especially a visual tool), and it will fully display any global table with a nice picklist option.
Code:
treenode current = ownerobject(c);
treenode view = parnode(1);


/**draw global table bar graph                                                             \n*/
/**table name: */
string tablename=/**/"processtimes"/**/;
/**\nbar width:*/
double barwidth=/**/2/**/;
/**\nbar height:*/
double barheight=/**/2/**/;


int tablenum=getrank(ownerobject(reftable(tablename)));

for(int row=1;row<=gettablerows(tablenum);row++){
    for(int col=1;col<=gettablecols(tablenum);col++){
        double value=gettablenum(tablenum,row,col);
        drawcube((col-1)*barwidth/get(spatialsx(current)),//x
                -(row-1)*barheight/get(spatialsy(current))+barheight*gettablerows(tablenum),//y
                0.000001,                                 //z
                barwidth/get(spatialsx(current)),         //sx
                barheight/get(spatialsy(current)),        //sy
                value/10,                                 //sz
                0,                                        //rx
                0,                                        //ry
                0,                                        //rz
                0,                                        //red
                min(value*11,255),                        //green
                0,                                        //blue
                0,0,0);                                   //no texture
            
    }
}
glNormal3d sets the normal vector of a polygon (facing straight out of the polygon), which is used in determining the lighting. If this vector is facing a light, the polygon is bright. If this vector is facing perpendicular to a light, the polygon is dark. I calculated the normal vector using a cross product of two vectors along the edges of the polygon. I'm not sure why, but it is calculating it wrong on the first row (when y0=0), so it's shading the first row wrong. Maybe there's a way to do it correctly automatically with an OpenGl command.

GL_CULL_FACE is supposed to be #defined to 2884, but just manually entering its integer value does the same thing as glDisable(GL_CULL_FACE); Back-face culling is an optimization that makes it not draw polygons that are facing away from the camera. It makes it look bad in the Cartesian graph, so I disabled it.

Last edited by Alex Christensen; 06-10-2008 at 01:03 PM. Reason: spelling error (with-->width)
Reply With Quote
The Following User Says Thank You to Alex Christensen For This Useful Post:
AlanZhang (06-09-2008)
  #4  
Old 10-06-2011
dalin cai dalin cai is offline
Flexsim User
 
Join Date: Aug 2010
Location: Wollongong, NSW, Australia
Posts: 9
Downloads: 19
Uploads: 0
Thanks: 11
Thanked 3 Times in 2 Posts
Rep Power: 0
dalin cai is on a distinguished road
Default

Hi Alex, I need to turn off back face culling, however, either glDisable(GL_CULL_FACE) or glDisable(2884) doesn't work on my machine using Flexsim 5.02.

The glDisable(2884) works.

Last edited by dalin cai; 10-06-2011 at 08:35 PM.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 09:29 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.