Thanks Marcel!

I do indeed visualize my wheels and chassis no problem in Unreal engine, 
however my visual mesh in Unreal is not the same as the collision meshes in 
Chrono. I would like to draw the scene as Chrono sees it,
to ensure it aligns 1:1 with what Unreal sees. 

Hoping there is a way (ideally without modifying Chrono engine code) to 
visualize the contact points, tire, wheel etc. 

I notice inside ChWheel::AddVisualizationAssets() we have some logic to 
setup triangle meshes:

void ChWheel::AddVisualizationAssets(VisualizationType vis) 
{
    if (vis == VisualizationType::MESH && !m_vis_mesh_file.empty()) {
        ChQuaternion<> rot = (m_side == VehicleSide::LEFT) ? Q_from_AngZ(0) 
: Q_from_AngZ(CH_C_PI);
        auto trimesh = 
geometry::ChTriangleMeshConnected::CreateFromWavefrontFile(vehicle::GetDataFile(m_vis_mesh_file),
                                                                            
      true, true);
        m_trimesh_shape = chrono_types::make_shared<ChTriangleMeshShape>();
        m_trimesh_shape->SetMesh(trimesh);
        m_trimesh_shape->SetName(filesystem::path(m_vis_mesh_file).stem());
        m_trimesh_shape->SetMutable(false);
        m_spindle->AddVisualShape(m_trimesh_shape, ChFrame<>(ChVector<>(0, 
m_offset, 0), ChMatrix33<>(rot)));
        return;
    }
}

Is there an easy general way to draw arbitrary chrono shapes such as 
ChTriangleMeshConnected or ChCylinderShape? Or do I need to roll my own 
function to iterate over each chrono shape's verts and then render them on 
my Unreal side? 

Thanks!

On Tuesday, August 1, 2023 at 12:18:45 AM UTC-7 [email protected] wrote:

> Hello JC,
>
> On 01-Aug-23 5:10, 'JC Denton' via ProjectChrono wrote:
> > I'm using my own engine, and I have a callback system setup to draw 
> > like so:
> >
> > m_system->GetCollisionSystem()->Visualize(ChCollisionSystem::VIS_Shapes 
> > | ChCollisionSystem::VIS_Aabb);
> >
> > This works fine for my chassis.
> I learned something new, you are registering a callback to draw a 
> visualization of the collision shapes and using those callbacks to 
> render something in your engine. That's nice. As far as I'm aware, a 
> similar hook does not exist for rendering visualizations in general...
> > But for my wheels and tires it doesn't.
> >
> > My wheel set's its visual mesh file via:
> >
> >   m_vis_mesh_file = "Meshes/Collision/LeftWheel.obj";
> >
> > and my tire's visualize mesh via:
> >
> > void 
> > RangeRoverSport_TMeasyTire::AddVisualizationAssets(VisualizationType vis)
> > {
> >     if (vis == VisualizationType::MESH)
> >     {
> >         m_trimesh_shape = AddVisualizationMesh(m_meshFile_left, 
> > m_meshFile_right);
> >     }
> >     else
> > {
> >         ChTMeasyTire::AddVisualizationAssets(vis);
> >     }
> > }
> >
> > but perhaps this is only meant for visualizing with irrlicht and 
> > doesn't support drawing out to my own engine?
>
> I'm pretty sure that assumption is correct. Irrlicht and Vulkan Scene 
> Graph (VSG) both basically iterate over the whole system and will grab 
> those assets and render them. The good news is, you can do something 
> similar yourself. I have done something similar to render terrain and 
> vehicles for my own simulator.
>
> Greetings, Marcel
>
>
>

-- 
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/4904cf25-506b-4840-a5e6-abacddc1f1ean%40googlegroups.com.

Reply via email to