Jump to content

Convert to separate editable meshes + retain original pivots?


eoinobroin

Recommended Posts

Hey!

 

I'm looking to essentially convert a GrowFX object to an editable mesh but not combine all paths (many instanced meshes) into one mesh, instead have them all be converted into separate meshes and retain their pivot ( the start of the path). For example, if I had a patch of grass, I would want each individual blade as it's own editable mesh with the pivot coming from the start of the blade. Is there an easy way to achieve this? Apologies if it's a simple task, still learning Max coming from Maya!

 

Thanks!

Link to comment
Share on other sites

You can use the explode button in the editable mesh tab. just set the spinner to a higher number to get the whlole sub object. ( I think I did 150) 

 

For the pivots I am not sure what to do, you can center them per object in the heirarchy tab (heirarchy- affect pivot only - center to object). But this won't put them at the begining of the path. 

  • Like 1
Link to comment
Share on other sites

Thanks for the reply!

 

Explode did indeed separate them, but the pivot information was lost unfortunately. Basically for a simple case like grass, the input instanced geometry cards all have the correct pivot, and GrowFX deforms the mesh along the path which starts at the pivot point of the mesh. Since GrowFX currently doesn't support vertex colors along the path of an instanced mesh, I've been trying to use an external script to add the colors after converting to an editable mesh, but I guess that is more complex than I initially thought, if GrowFX can't export with pivot information! Thanks for the help!

Link to comment
Share on other sites

There is another way - use MaxScript.
 
For example, select your growfx node and run this script:
 

gfx = $;
FOR i = 1 TO gfx.getNumSequences() DO
(
    FOR j = 1 TO (gfx.getNumLines i) DO
    (
        gfx_ = copy gfx;
        gfx_.GenerateOneMesh i j;
        convertToMesh gfx_;
    )
)

But for some reason, this script throws an error, and I don't know why.

Although, if use this script, then everything works fine:
 

gfx = $;
gfx_ = copy gfx;
gfx_.GenerateOneMesh 1 1;
convertToMesh gfx_;

gfx_ = copy gfx;
gfx_.GenerateOneMesh 1 2;
convertToMesh gfx_;

gfx_ = copy gfx;
gfx_.GenerateOneMesh 1 3;
convertToMesh gfx_;

gfx_ = copy gfx;
gfx_.GenerateOneMesh 1 4;
convertToMesh gfx_;

gfx_ = copy gfx;
gfx_.GenerateOneMesh 1 5;
convertToMesh gfx_;

gfx_ = copy gfx;
gfx_.GenerateOneMesh 1 6;
convertToMesh gfx_;
...

Cheers

Link to comment
Share on other sites

Thanks for the reply Eduard! 

 

Unfortunately both scripts are throwing errors (even when matching the number of meshes in the second script) "sequence index out of range"- I'm probably not setting it up right! 

 

I found a temporary solution to just apply the vertex color gradients to the instanced geometry meshes BEFORE processing in GrowFX, but for assets larger than grass, this may prove to be an issue. 

 

I saw in this post: https://exlevel.com/forum/index.php?/topic/285-about-instanced-geometry-vertex-color/that you had planned on implementing the "Coloring along path" function to instanced geometry- are those plans still in place? GrowFX is truly an amazing piece of software, just some small things holding it back from being really efficient with custom geometry (scanned atlas cards).

Link to comment
Share on other sites

Does the second script line  "gfx_.GenerateOneMesh 1 x;" relate to the path number or element number? Being able to access and bake the original pivots for all leaves/stems/branches makes it possible to quickly create really deep and realistic realtime wind in UE4. Right now the solution is to create the GrowFX object, convert to a mesh and then manually detach ALL elements, reset their pivots, and then link certain element selection sets to the paths that they are tied to in order to have proper hierarchical wind.

 

It becomes extremely difficult and tedious to do it manually this way, but since GrowFX essentially has most of that information to begin with (pivot info per element, elements attached to each parent path, hierarchy), it seems like it would be possible to retain that information with a few tweaks! I'd love to setup this script, but I'm not sure how to get it to work without getting errors!

 

Here is a quick video of a simple test I made running in UE4 (

). This simple object took hours and hours to detach and manually reset pivots/assign to paths when in theory, the information could be accessed in GrowFX. If you have any ideas to find a more efficient solution, I'd love to discuss it!

 

Thanks a lot for your time!

 

 

 

EDIT: I have also experimented with a different script that allows rigging by hierarchy- so if I made for example 3 different stems with leaves attached as children, added each stem in GrowFX as instanced meshes, and then clicked "use Hierarchy" which would bring in the linked leaves to GrowFX- then make a bush with a count of say 50 instances, if it was possible to convert each stem as a separate object with the same pivot as in GrowFX (bringing the leaves hierarchy with it), then rigging for ue4 would be a 1 click process! Because the hierarchy / link / pivot information is lost when converting to a mesh in GrowFX, it's currently not possible to do that without going through every single path manually and detaching all leaves which isn't a feasible option for many assets.

 

 

 

Thanks!

Link to comment
Share on other sites

To summarize and hopefully make things clearer- to get really convincing + deep realtime wind in UE4 (without expensive bone rigging), you'd need to implement a way to:


 


Retain original pivots of ALL paths (converted to separate editable meshes)


 


Keep hierarchy intact (the ability to retain the parent and child relationship of the meshes over multiple levels (essentially the same as if you took all leaves that belonged to a particular branch of a tree and used the link tool to associate them to their branch- and do this for all branches of a tree) Right now this impossible to do even manually for anything remotely complex). The same idea would apply to linking all branches of a tree to the trunk. 


 


 


 


Paint vertex color gradient down paths of instanced meshes (This is lower priority but still very useful and important for creating bend/random weighting along with the pivot rotation)


 


I do realize that this functionality may be very difficult to pull off, but if there is any way to retain the information, it'd be extremely useful!


 


Thanks!


Link to comment
Share on other sites

Hi eoinobroin again,

 

Yet I have one question:

If you have a long branch that must be bent by the wind, how should behave the leaves that are tied to it? The pivot of the branch will not change, it only bend, as a result, all leaves that are tied to this branch will remain at the same places.

 

To better understand what you want, please send me your model, which is presented on your video.

 

Thanks!

Link to comment
Share on other sites

Hey Eduard! 

 

Thanks so much for taking the time to look into this- I think it could be extremely powerful for realtime applications, and a very valuable and efficient way to get foliage rigged fast. 

 

The way pivot based realtime wind works is a combination of rotation through each pivot (trunk/branches/leaves all separately rotating) and vertex weighted bending. This animation is done in Unreal Engine- so is possible to do a lot of customization in real time (stormy directional winds/ huge amount of variation over one instanced asset through simple randomized values per instanced asset- here is an extremely basic test made in engine using a single instanced grass clump, hopefully you can see the potential it would have for trees/bushes/plants:

) You can see when tweaking the shader that each blade moves on its own axis, and it's easily possible to tweak the direction/strength/randomness + any other custom variables right in engine. 

 

Simple typical game wind just runs a noise mask over the entire mesh to make it move, but the result looks very poor and cheap/not realistic.

 

Having access to the pivot information baked to a texture (where each pixel represents a pivot location) means that it is possible to get much more natural and realistic movement while keeping good performance. Unreal Engine 4 for example provides a pivot painter script that allows that pivot texture to be created quickly from a model that is set up correctly (proper linked hierarchy/all elements on their own pivot). This then gives the power to create really powerful dynamic wind shaders.

 

So, knowing this- the assets will all still be created as normal in GrowFX, the big change is just how they are converted to a mesh at the end. All that would be required is each element separate, and each branch/leaf/trunk hierarchy preserved, and then the script from Epic Games (Unreal Engine) will be able to create the pivot texture in one click! 

 

I can create a video outlining the workflow if that would help understand? The model presented in the video was a quick simple asset created in GrowFX (instanced meshes for the leaves) and then converted to a single editable mesh. I then manually detached all leaves from the stems, manually moved the pivots for each leaf back to their original relative positions, manually moved all stem pivots to their origin and then linked the leaves to the stems using the max link tool to create a hierarchy. I then was able to run the script from Epic Games to create the pivot texture for use in UE4. So you can see that if the information was available from GrowFX when converting, it would have been possible to rig in a matter of seconds! 

 

 

Regarding your specific question- since the pivots are baked in a hierarchy, the engine knows the relative position of the leaves to the branch- so if the branch bends, the leaves will follow and hold their correct position on the branch, even though the whole mesh has been collapsed to a single editable poly before exporting from Max.

Link to comment
Share on other sites

  • 2 weeks later...

Hey Eduard! 

 

I've done a lot of testing over the last week and have figured out a solution that may be easier for you to to implement.

 

The pivot based wind is great (and will certainly be used in the future), but for lower LODs (where entire leaf clusters need to be on a piece of low poly geometry), it seems that vertex colors offer the most benefits, while having a really strong integration with GrowFX.

 

Here is my current work in progress setup in UE4: 

 

This wind shader is entirely driven by vertex colors using a single model exported straight from GrowFX(no pivots or any detaching) You can see the vertex colors affect the model at different intensities (still some bugs to iron out with the leaf gusts in the more intense section).

 

Basically GrowFX offers a near perfect implementation right now- the only thing that is missing for this wind solution to work fully is the "Paint vertex color gradient down paths of instanced meshes" option. This gradient along path option is currently greyed out for instanced meshes as discussed above, but being able to mix the inherited values, random values per element, and gradient for instanced meshes would allow for the most possible control with very little work ( I didn't realise how good the vertex color integration was with GrowFX until a few days ago)

 

 

Here is an image of the mesh with the colors applied, to explain:

 eoin-o-broin-screenshot-2016-12-05-00-15

 

Blue strength = branch bend strength

 

Green strength = random bend offset

 

Red strength = leaf bend strength

 

As you can see, the red has very little influence on the leaves as they are instanced meshes, and the trunk/branches are GrowFX cylinders.

 

Ideally, I'd want the leaves to have a strong red strength at their tips (using a gradient like so): eoin-o-broin-screenshot-2016-12-01-21-27

 

 

I hope this feature can be implemented for instanced meshes like it is for GrowFX objects, as it will be a perfect solution for getting really nice wind weights very quickly!

 

Thanks!

  • Like 1
Link to comment
Share on other sites

  • 4 years later...
On 11/22/2016 at 7:44 PM, Eduard said:
Yet I have one question:

 

If you have a long branch that must be bent by the wind, how should behave the leaves that are tied to it? The pivot of the branch will not change, it only bend, as a result, all leaves that are tied to this branch will remain at the same places.

 

this is happening inside UE!

all what UE needs is the pivot position of each path and the index of the parent , also xVector ,which are created with the UE Pivot Painter script .

the script only creates 2 maps, which you have to input in unreal.

Those values are stored static , means not animated, like a pose for character animating

 

about your script , i  also get errors, but if you disable cache and activate autoupdate also put a editmesh modifier on top of growfx , you will get no errors anymore.

but the pivots are the same like using the explode mesh to objects , which is far the more performant method

 

the UEscript can re - set the pivots , but they are set not in an identical ideal way, building a hierachy is perhaps possible with a script and intersection testing (checking atm)

 

it would be nice if we had a Utility /script tool to extract those information to those 2 maps (export from growfx) , like the PivotPainter 2 script does..

(i attached the script from epic games for you)

 

I`m shure, when Ue 5 comes out, Ue will come much bigger and used in the market... would be nice to have compatiblity.

Doing this manually is just pain

 

 

 

PivotPainter2.ms

Link to comment
Share on other sites

  • 2 weeks later...

i found a solution to get the pivots and some suboptimal Pivot orientation , which i`m able to export to unreal !!

now testing and fixxing things...

 

i need access to the visibility of a path..

is there any script access function for this?

some of my cylinder meshbuilders have parent thickness, if i disable them i have another result... visibility access would fix this

(using the old growfx )

 

 

additional in grow fx2 is there any posibility to get acccess to those nodes?

$.getNumPaths()

$.getMeshBuilder 1 1

and all these good things are gone :((

 

thanks

yours schellicon

Link to comment
Share on other sites

On 5/30/2021 at 5:12 PM, schellicon said:

additional in grow fx2 is there any posibility to get acccess to those nodes?

$.getNumPaths()

$.getMeshBuilder 1 1

and all these good things are gone :((

 

We'll try to restore these MaxScript functions, but maybe it will change and will work as with nodes.
It's just that the system has been completely changed, and now instead of different components we've nodes of different types with continuous numbering.

 

Thanks!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...