Draw a spherical sphere from module

Draw a spherical sphere from module

mischa_spelt
Advisor Advisor
19 Views
2 Replies
Message 1 of 3

Draw a spherical sphere from module

mischa_spelt
Advisor
Advisor

[ FlexSim 18.0.1 ]

I tried to draw a sphere from an overridden onDraw in a module. So I created a very simple class:

class Test : public BasicFR
{
public:
  double onDraw( TreeNode* view ) override {
    double result = BasicFR::onDraw( view );

    drawtomodelscale( this->holder );
    drawsphere( 0.5, 0.5, 0.5, 1, 255, 0, 0, 0.5 );

    return result;
  }
};

When I create an instance of the class in FlexSim, everything looks fine initially, but when I resize the object the sphere stretches with the y- and z-directions:

10299-drawsphere.png

(Also note how the sphere does not seem to be centered around the specified coordinate).

To see the desired result, create a BasicFR in the model and give it the following Custom Draw trigger:

drawtomodelscale( current );
drawsphere( 0.5, 0.5, 0.5, 1, 0, 0, 255 );

Notice that when you resize the object, the sphere stays spherical and the same absolute size.

Is this a bug or am I missing something?
(Side note: I tried downloading a new flexsimcontent but the BitBucket repository seems to be missing some files, and both the Dev and the Stable versions on the CI server crash 18.0.1 on startup for me).

0 Likes
Accepted solutions (1)
20 Views
2 Replies
Replies (2)
Message 2 of 3

philboboADSK
Autodesk
Autodesk
Accepted solution

drawtomodelscale() is simply doing an fglScale() by the inverse of each component of the specified object's size.

The Y and Z axes may be different between an object's onDraw cppfunction and its customdrawtrigger variable. You can sort that out by rotating 90 degrees around the X axis.

Try rotating before calling drawtomodelscale():

fglRotate(-90, 1, 0, 0);

or

fglRotate(90, 1, 0, 0);


Phil BoBo
Sr. Manager, Software Development
Message 3 of 3

mischa_spelt
Advisor
Advisor

Thanks!

0 Likes