Hi

I am trying to import a triangle mesh shell structure into Chrono, but when 
using the BSTShellFromObjFile I get no visual in Irrlicht. I have attached 
my project file and obj file. Is there any specific requirements for the 
obj mesh I haven't met? I just wanted to test with a course triangle mesh, 
but maybe I need a finer mesh?
Thanks for any answers!

Halvor

-- 
You received this message because you are subscribed to the Google Groups 
"ProjectChrono" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/projectchrono/6fc14a25-651a-47c3-a262-356c663d6337n%40googlegroups.com.

Attachment: circle.obj
Description: Binary data

// =============================================================================
// PROJECT CHRONO
//==============================================================================

#include "chrono/physics/ChSystemNSC.h"
#include "chrono/physics/ChBodyEasy.h"
#include "chrono/physics/ChBody.h"
#include "chrono/physics/ChInertiaUtils.h"
#include "chrono/physics/ChLoadContainer.h"
#include "chrono/physics/ChLoadsBody.h"

#include "chrono/geometry/ChTriangleMeshConnected.h"
#include "chrono/assets/ChVisualShapeTriangleMesh.h"
#include "chrono/assets/ChTexture.h"
#include "chrono/assets/ChVisualShapeFEA.h"

#include "chrono/fea/ChMesh.h"
#include "chrono/fea/ChNodeFEAxyz.h"
#include "chrono/fea/ChElementShellANCF_3423.h"
#include "chrono/fea/ChMaterialShellKirchhoff.h"
#include "chrono/fea/ChMeshFileLoader.h"


#include "chrono_irrlicht/ChVisualSystemIrrlicht.h"

#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <map>

using namespace chrono;
using namespace chrono::fea;
using namespace chrono::geometry;
using namespace chrono::irrlicht;

int main(int argc, char* argv[]) {
    
    // Create a Chrono::Engine physical system + collision system
    ChSystemNSC sys;

    SetChronoDataPath(CHRONO_DATA_DIR);

    ChCollisionModel::SetDefaultSuggestedEnvelope(0.0025);
	ChCollisionModel::SetDefaultSuggestedMargin(0.0025);

    sys.SetCollisionSystemType(ChCollisionSystem::Type::BULLET);

    
    //create surface material
    auto surfacemat = chrono_types::make_shared<ChMaterialSurfaceNSC>();
    
    auto floorBody = chrono_types::make_shared<ChBodyEasyBox>(10, 0, 10,  // x, y, z dimensions
                                                     3000,       // density
                                                     true,       // create visualization asset
                                                     true,       // collision geometry
                                                     surfacemat // surface material
                                                     );
    floorBody->SetPos(ChVector<>(0, -3, 0)); 
    floorBody->SetBodyFixed(true);
    floorBody->GetVisualShape(0)->SetTexture(GetChronoDataFile("textures/blue.png"));
    sys.Add(floorBody);

    auto mesh = chrono_types::make_shared<ChMesh>();

    // Create a material
    auto elasticity = chrono_types::make_shared<ChElasticityKirchhoffIsothropic>(500, 0.33);
    auto material = chrono_types::make_shared<ChMaterialShellKirchhoff>(elasticity);

    std::cout << "Loading .obj file..." << std::endl;

    ChMeshFileLoader::BSTShellFromObjFile(mesh, "/Users/weizhiwang/workspace/circle_2.obj", material, 100);

    std::cout << "Number of nodes: " << mesh->GetNnodes() << std::endl;
    std::cout << "Number of elements: " << mesh->GetNelements() << std::endl;

    std::cout << "Creating visual shape for the mesh..." << std::endl;

    // Create a visual shape for the mesh
    auto visa = chrono_types::make_shared<ChVisualShapeFEA>(mesh);
    visa->SetWireframe(true); // Set this to false if you don't want to see the wireframe

    std::cout << "Adding visual shape to the mesh..." << std::endl;

    // Add the visual shape to the mesh
    mesh->AddVisualShapeFEA(visa);

    std::cout << "Adding mesh to the system..." << std::endl;

    // Add the mesh to the system
    sys.Add(mesh);

    std::cout << "Mesh added to the system" << std::endl;

     // Create the Irrlicht visualization system
    auto vis = chrono_types::make_shared<ChVisualSystemIrrlicht>();
    vis->AttachSystem(&sys);
    vis->SetWindowSize(800, 600);
    vis->SetWindowTitle("GEO Mesh Simulation");
    vis->Initialize();
    vis->AddLogo();
    vis->AddSkyBox();
    vis->AddCamera(ChVector<>(0, 0.5, -1));
    vis->AddTypicalLights();

    // Simulation loop
    while (vis->Run()) {
        vis->BeginScene(true, true, ChColor(0.55f, 0.63f, 0.75f));
        vis->Render();
        vis->EndScene();
        sys.DoStepDynamics(0.001);
    }

    return 0;
}

Reply via email to