Coder Social home page Coder Social logo

Comments (10)

rserban avatar rserban commented on June 26, 2024

Of course, with that function commented out you will not get any visualization.
What version of OCC do you use? Note that Chrono can only work with version 7.4.0. And in that version, both functions Poly_Triangulation::Nodes() and Poly_Triangulation::Normals() are defined.

from chrono.

AramNasser avatar AramNasser commented on June 26, 2024

Thank you for your prompt reply

Yes, I use opencascade-7.7.0. I will try to recompile and link to the OCC 7.4.0 and hope the problem will be solved.

Thanks again and have a nice day

from chrono.

AramNasser avatar AramNasser commented on June 26, 2024

Hi again,

I have redone the installation with OCC 7.4.0 but am still unable to visualize the loaded step files, nor ChBodyEasySphere or ChBodyEasyBox when their add function is called from a GUI button's event function. I can visualize them only when called in the Main function before
vis->AttachSystem(&sys);
vis->SetWindowSize(800, 600);
vis->SetWindowTitle("ChCascade");
vis->Initialize();

....and the other settings

Please note that when I do "sys->Clear();" from the button's event function the objects disappear, meaning the reference to the sys is working well. Do I miss anything to show the added objects?

What do you advise in this case?

from chrono.

rserban avatar rserban commented on June 26, 2024

When you add a physics item (such as a body) to the system after the associated visual system was initialized, you must explicitly inform the visual system of the new assets (the item's visual model). You do this by explicitly invoking the function ChVisualSystem::BindItem(). Note that all visual models defined at the time you initialize the visual system are automatically bound (so no need for any explicit call in that case).

from chrono.

AramNasser avatar AramNasser commented on June 26, 2024

Great, thanks

However, now the added elements just float. How can I add the physical attributes to them?
For example, the same objects fall down when I call them from the Main

from chrono.

rserban avatar rserban commented on June 26, 2024

This is likely some bug in your code. Not sure what you mean by "adding the physical attributes". Are you sure you do not set them as "fixed"?

from chrono.

AramNasser avatar AramNasser commented on June 26, 2024

Thanks for your prompt reply

Yes, I am sure they are not fixed. They fall when they are called from the main function....
About "adding the physical attributes", I meant to make them fall as a physical object not stay afloat.

Should you need any further details, please do not hesitate to ask. Thank you in advance.

from chrono.

AramNasser avatar AramNasser commented on June 26, 2024

Hi again @rserban

Please, let me clarify the issue:

I am calling the function "AddFallingItems(sys)" that exists in the demo: "demo_MBS_collisionNSC.cpp" from a button. Now the items are visible and everything is OK (after installing the right OCC 7.4.0 and binding the elements.)

However, when I call the function from the main, the items fall as they do in the demo but when I call it from the button, they do not fall unless they touch the falling items loaded from the main. When the items loaded from the main are no longer falling, i.e. they touch the bottom of the container "AddContainer", the newly added items stay at their positions and do not fall (this also applies to the items loaded using the LoadStepModel(....))

I tried to update the ChSystemNSC sys (sys.Update()) but it seems it has no effect!

Have I missed anything?

Thank you in advance

from chrono.

rserban avatar rserban commented on June 26, 2024

There must be a mistake somewhere in your code. A very simple modification of demo_MBS_collisionNSC where the falling objects are created at some later point in the simulation, using something like:

    bool create = true;
    while (vis->Run()) {
        if (create && sys.GetChTime() > 3) {
            AddFallingItems(sys, vis);
            create = false;
        }

        vis->BeginScene();
        vis->Render();
        vis->EndScene();

        sys.DoStepDynamics(step_size);

        rt.Spin(step_size);
    }

postponing the generation of falling objects and with an appropriately modified AddFallingItems() to pass the visualization system so that the newly created bodies can be bound to the vis system, works exactly as expected.

from chrono.

AramNasser avatar AramNasser commented on June 26, 2024

Thank you so much indeed for your time and effort

You are right, the problem was in my code as I sat "sys.SetUseSleeping(true);" to test something and forgot to reset it back to false, or delete it!

In case someone faced the final issue I mention here, just turn this feature off!
/// Turn on this feature to let the system put to sleep the bodies whose
/// motion has almost come to a rest. This feature will allow faster simulation
/// of large scenarios for real-time purposes, but it will affect the precision!
/// This functionality can be turned off selectively for specific ChBodies.
void SetUseSleeping(bool ms) { use_sleeping = ms; }

Thanks again and have a great day :)

from chrono.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.