Hi Marcel,

I do not have a caching system yet, that would be a smart move! 
Currently the Unreal side is drawing these debug meshes once per game 
thread tick (when debugging is enabled), so its not like its once per 
chrono step. 
This debug drawing is purely for debug purpose and wouldn't be visible to 
the end user. Still though, its a good idea, might as well not waste time 
looping
over all the verts if the mesh hasn't actually moved. 


Thanks!
-JC
On Thursday, August 3, 2023 at 1:10:40 AM UTC-7 [email protected] wrote:

> Great to hear, JC!
>
> Transformation of coordinate systems is something we all have to live with 
> when converting from 3D modeling tools and physics engines to game engines.
>
> One question I have, when you transfer "low level mesh data" from Chrono 
> to Unreal, do you also have a method of caching that so you can send it to 
> the GPU once (and not every frame)?
>
> In any case, it's nice to hear your project is coming along nicely, good 
> luck with it!
>
> Greetings, Marcel
>
>
> On 03-Aug-23 7:06, 'JC Denton' via ProjectChrono wrote:
>
> Thanks Marcel!
>
> I do indeed have my physics thread separate from my render thread. I have 
> a queued callback system to send render debug info from 
> my chrono dll to the unreal side in a thread safe manner. 
>
> I rolled my own debug helper class to manually loop through the vertices 
> from ChCylinder and ChTriangleMeshes and 
> push those into vert structures that Unreal can read. Seems to be 
> rendering the meshes in unreal okay, just gotta work out some transform 
> conversions now
> and expand it to other chrono shape types.
>
> I just pulled the vert data directly from the m_trimesh_shape which exists 
> inside ChWheel already.
> So now I have my Unreal visual meshes driven from the Chrono physics 
> output + the chrono collision debug shapes rendering overlayed on top for 
> comparison which is exactly
> what I was looking for. 
>
> Thanks!
>
> -JC
>
> On Wednesday, August 2, 2023 at 12:11:41 AM UTC-7 [email protected] 
> wrote:
>
>> 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/e09f2aa7-f738-41c9-a197-8e2b74126e4dn%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/projectchrono/e09f2aa7-f738-41c9-a197-8e2b74126e4dn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
>

-- 
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/c111099c-e987-49bc-8274-84c63f0559f6n%40googlegroups.com.

Reply via email to