question

Mischa Spelt avatar image
0 Likes"
Mischa Spelt asked Mischa Spelt commented

Draw a spherical sphere from module

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:

(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).

FlexSim 18.0.1
module sdkopengldrawsphere
drawsphere.png (1.7 MiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

·
Phil BoBo avatar image
1 Like"
Phil BoBo answered Mischa Spelt commented

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);
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Mischa Spelt avatar image Mischa Spelt commented ·

Thanks!

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.