Hello JC,
Responses in-line below.
On 02-Aug-23 5:27, 'JC Denton' via ProjectChrono wrote:
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.
Understood, and this of course is a generic "issue". Collision meshes
are always simplified meshes to keep a decent performance and the visual
mesh (regardless of Unreal, Irrlicht or VSG rendering it) will be
different. I typically use a mental model where I distinguish three worlds:
1. The visual one, that is normally rendered.
2. The collision world, that has all kinds of collidable (simple) shapes
bumping into each other (car bodies bumping into terrain or other cars).
3. The tire world, that typically uses its own type of collision system
(although that depends a bit on the type of tire, I mostly use
semi-empirical ones for my use case.
Hoping there is a way (ideally without modifying Chrono engine code)
to visualize the contact points, tire, wheel etc.
I've gone through a similar process and with the help of this community
and a few small patches I have mostly managed to get to the data I want
to visualize without having to change the engine. I did end up doing a
lot of the drawing "myself". There is a lot of information available at
the end of every physics "step" so the biggest deal then becomes how to
pass all that data to (in your case) Unreal. Part of that design is also
about potentially decoupling the physics thread from your rendering (at
least in my case I quickly concluded that with physics running at 1000
fps my graphics card was never going to keep up).
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?
I don't think there is. For "primitive" shapes I ended up implementing
them myself based on the provided parameters and I mostly use those to
visualize how the vehicle physics respond. For "mesh" shapes I ended up
completely ignoring what is defined in Chrono and loading my own 3D
model, using a bit of glue code to make the right parts of that model
show up in the places calculated by Chrono (position and orientation).
You could also take the defined OBJ meshes and load those in Unreal I
guess. OBJ is nice because it's a simple format to generate and parse.
That said, I ended up wanting to have the whole vehicle in a single
graphics file, so I ended up with a GLTF file containing all the parts
(body, wheels, etc.).
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/cac908d6-c8f8-7ac2-03b1-a3d679dfb144%40gmail.com.