Exploding a CAD assembly and picking up individual parts in VR

Hello! I’d like to create a custom Engineering environment and I am wondering what the best way is to approach this. Here is what I would like to do:

  • View a CAD assembly in VR.
  • Smoothly animate the assembly exploding in midair and un-exploding (Ideally in steps - meaning certain parts come apart first, then other parts, etc.)
  • Grab individual parts in VR, when they are either exploded floating in the air or un-exploded.
  • Activate gravity on the individual parts when you release them after grabbing them, so they can fall on the floor or on a table.
  • Have the individual parts snap back to their original exploded position (by means of a button press or some other trigger).

I know for a fact that all of this is entirely possible, but I am not sure how to approach it. I realize this will take some custom work. Could someone please give me some pointers? Ideally I would like to keep this in Blueprint rather than C++.

For software outside of UE4, I primarily use Fusion 360 for CAD, and Blender for gamedev related modeling/animation. I am also open to using Maya if it works better for this application.

I would greatly appreciate any help getting started on this!

My two cents:

  • Perfectly doable, but you need to consider how many parts you have in your assembly, siunce the mantra is “the more parts you have the more draw calls you have”, so FPS could take a hit because of that
  • If you have the possibility to save the exploded view and use it as a CAD model, I would suggest to use that in order to store the world transform for each part in UE4, so that you can use those values ( into an excel sheet or array ) and do an interpolation between the unexploded view and the exploded view. Since each assembly is its own beast, this method might not work properly, so an alternative would be to use a timeline with a float value ( 0 to 100/200mm ), that would drive the original part position to the “exploded” position, then use the float value for the next component, multiply that by 2, and explode that sequentially, so that each part will be exploded from the other part by 100-200mm…but this is very time consuming.
  • Doable in different ways: Modify the Interactive cube from the VR Template by replacing the cube with your part, repeat for each single CAD part; assign a tag to every CAD part ( select all the cad part in the scene, go to tag and add one ), and have the interactivity setup in your Motion Controller BP to enable the grabbing when the motion controller is overlapping a part with that tag.
  • You can either set Simulate physics on each part, or you can do that one by one in a BP by adding a Physic constraint actor
  • The best way to unexplode the parts would be to have your CAD file separated into sub-assy, so that, by using a UMG menu, you can choose to unexplode just that sub-assy, rather then the entire assembly.

BR,

Nicolas

I’m not too worried about FPS, UE4 should be able to handle many parts if paired with decent hardware.

I have gotten an assembly to smoothly explode and un-explode but this was done by using morph targets that I created in Blender and the assembly was exported to FBX as one model. This means there’s no possibility of grabbing an individual part in VR (only the whole thing) so it’s not feasible.

I think for it to work properly, there needs to be some way to store the individual position of each part in both the exploded and un-exploded state and animate between the two positions. I am not sure what the best way is to approach this. I don’t know of any way to export offset positions from any CAD software, and if it’s possible to do this in Blender or Maya then I’m not sure where to start.

It would sure be nice if there was a tool within Unreal Studio that allows you to create an “exploded view” in steps similar to any CAD software. Basically you’d select the first set of parts that should explode and move them, select the next set of parts and move them, and so on until everything is exploded and then those positions would be stored. Then it could animate the explode going through step 1, 2, etc. All this really comes down to is several sets of offsets for all of the parts, right? I wonder if it’s possible to make something like this?

The grabbing and gravity won’t be too hard I think. I have done that before with individual models. I think the tricky part is getting everything to explode and un-explode properly and also grab and manipulate individual parts.

Honestly, you should be worried about FPS.
CAD assemblies often have thousands of parts, so if you’re not in VR that is not a big issue, but in VR the amount of draw calls is one of the biggest issue, so if exceed with the amount of parts in the scene, you’ll begin to have a performance hit.

Informations from the CAD files are usually stored into the .cfg file, so I guess that the best way would be to get all the data from there, store it into UE4 into an array, then use it automatically.

Regarding the “auto explode view”, you can build it right now, possibly using the method mentioned in my previous post, additionally storing all the selected parts into an array, then use only those and explode them by a certain amount between each other.

I think that you need to take into account if you really want to be every single part to be interactive, so if you really want that small washer to be interactive, or to be a part of the model itself, since that would ne something not 100% necessary.

Some of the asked functionality will make its way in future versions of the product viewer template that ship with studio. Do you have examples in mind of other softwares that work well with regards to exploding parts that we should look at?

That’s great to hear! Yes, here are some examples of exploded view functionality:

Solidworks: Creating Exploded Views (Assemblies) - 2018 - SOLIDWORKS Help
Fusion 360: Fusion 360 Help
Creo: Creo Parametric Help Center

I think the most user friendly example is Solidworks. For every explode “step” you can select a group of parts that should move to an exploded position. Then for the next step, you move another set of parts (that can also include the first set of parts you moved). Once you’re done, Solidworks smoothly animates everything coming apart and going back together. It works very well. I’d assume it basically stores several sets of offsets and moves the parts accordingly.

Explode in Fusion 360 and Creo also works pretty well. Fusion 360 uses an animation workspace/timeline for everything coming apart so you can fine tune things. Creo is a different beast but it’s very powerful.

If you’d like, I’d be willing to help test and improve aspects of the product viewer template that ships with studio, especially in regard to exploding assemblies. I have a lot I could throw at it!

2 Likes

If FPS is ever an issue, all that really comes down to is proper LOD for all of the models. UE4’s built in tools certainly help with that.

Do you mean there is a .cfg file generated from CAD software such as Solidworks or Fusion 360?

The auto explode view idea is pretty cool. I don’t think it could be used practically since it would work in unexpected ways (parts need to move in different directions and come apart correctly) but it might be a quick and dirty way to get an initial idea of all of the parts in an assembly. A proper exploded view needs to be hand placed in steps, like Solidworks for example.

I do want every single part to be interactive. I have personally seen everything I described accomplished in Unity engine, and I know UE4 can handle it as well.

@pf_breton I see in the product viewer template there’s a blueprint titled “Explode_BP”. What is the correct way to use this blueprint?

EDIT: I was able to get the Explode_BP working by following your instructions in this post. Awesome! :slight_smile: Now while I can explode and rebuild, this does break the interactability of the parts. Would I run into any roadblocks trying to re-implement the interactability? What’s the best way to do so?

I do already have one suggestion for improving the Explode_BP with interactivity in mind. The timeline to move the parts to explode/rebuild lerps between the exploded and un-exploded transforms. It should instead get the current transform for each part and lerp between the current transform and the desired exploded/un-exploded transform because if the parts are interactable, they could be positioned wherever by the player.

hey @Matt2468rv, this is what P-F was alluding to above, when he mentioned that the Product Viewer would get some improvements in this area. In the upcoming 4.21 release, you should see that the behavior is pretty much as you describe. The parts are still interactable, and just lerp between their current position and the positions you set for them in the explode blueprint.

although we haven’t fully designed it yet :). We want to consider hierarchy at some point and that bp isn’t entirely what we need;)

[USER=“1823580”]Robb Surridge[/USER] Awesome! That’s the exact functionality I need. On top of that I want to be able to enable gravity and collision after you grab a part and release it, so that parts can be set down on a table or thrown aside. Then when exploding/rebuilding, the parts would disable gravity and lerp back to their original exploded/unexploded position. This seems like the most realistic and natural way to manipulate CAD assemblies in VR. I also eventually want to get Leap Motion working with it for an even more natural experience.

@pf_breton What do you have in mind as far as considering hierarchy? The functionality previously described will still be possible, right?

what is with the possibilities Marc Bouchard showing in this video? Is this available somewhere and the Engine as well?

https://academy.unrealengine.com/Learning-Extra/Viewer%20Template

What Marc shows in that video is already in the 4.20 version of the Product Viewer template. He’s reworked and improved it in 4.21 to make it simpler to set up.

ETA? :slight_smile: .

4.21 :slight_smile:
No official date yet, but look for it probably in early November.

Hey so I wanted to bump this tread because this seems to be a fairly requested thing to do. I sat down this weekend to figure it out for a few reasons, and it actually worked pretty good, but I wanted to get some feedback on a few hacks I had to do to get it to work.

So basically I made an independent BP with all of the logic calculates and handles all of the positions. Now, I had to custom tailor a few things based on the data I was working with and I imagine most people with need to do the same, but this is the general idea:

  1. Put the BP in the level at the center of where you want the parts to explode away from (usually the center, or in my case a little below center of the parts.
  2. In the BP, store the location of the BP itself, and make an array of all of the datasmith parts you want to explode. I just got the parent datasmith actor and got all attached static meshes.
  3. Store each position of each mesh at rest.
  4. Derive the actual center of those meshes and store those as well ***
  5. From the center points, trace back to the BP and reverse the direction of the vector and store those vectors
  6. Derive the distance from the BP to the center of the parts and set a distance multiplier to adjust how far each part moves
  7. Make a timeline that moves each part away from the center of the BP a certain distance away based on the direction and distance we calculated earlier.
  8. When the timeline completes, save each position of each mesh again as the exploded position.

Past that, you can setup whatever grab functionality you want, and just determine whether you want the part to fly back to its exploded or resting position. I didn’t need the gravity thing people wanted to do, but you could very easily set that up.

So about the hacks. Step 4… I really didn’t have a good way to calculate the physical center of each part. I tried to get the origin of the bounding box, but the values for that node seemed to be in local space maybe? which didn’t make sense, nor could I switch it to make it work anyway, so no go there. The hack I ended up doing was to get the world position of the actor and its forward vector, then get the box extent of the static mesh and calculate backwards to find the center point…ish…

Its hacky because that’s not going to work for everything, and it was really a fluke it worked for the data set I was working with. Is there anyway to get the world Center position of an actor? Not the 0,0,0 but the center point of its bounding box in world space. Or a proper way to calculate it with the bounds nodes. It seemed like all of the info I needed was there, just couldn’t figure out how to put it all together.

Bonus question! In one assembly I exploded, there was 1 mesh that, no matter what, would always move in the opposite Y direction than expected. I ended up having to do an override on that part to switch the direction. I don’t even have a guess as that what caused that.

tl;dr : Whats the proper way to get the world center position of a static mesh actor’s bounding box?