How to create single multi-group obj for Unity, from instanced primitives? Urgent for art competition.

   5374   8   1
User Avatar
Member
55 posts
Joined: July 2011
Offline
Hi I'm copying spheres to points on a plane and would like to create a separate group for each instanced sphere so I can then export one multi-group obj to Unity. Can anyone advise please? Working on ArtStation competition and only 3 days to go.

https://www.artstation.com/contests/ancient-civilizations/challenges/13/submissions/14223 [artstation.com]

Thank you,

Mark
Edited by Drakon - March 9, 2017 07:10:33
User Avatar
Member
2529 posts
Joined: June 2008
Offline
If you take a look at the OBJ file format [en.wikipedia.org] you will discover that there is no internal grouping supported. So all you can really do is assign a material. Then an importer can attempt to make groups based on materials. Perhaps that is how the Unity importer works?

Here is one approach. I have randomly assigned four different materials to spheres. Try writing out a .OBJ file and see if Unity can detect this.
Edited by Enivob - March 9, 2017 09:23:59

Attachments:
Untitled-1.jpg (352.6 KB)
ap_rnd_colors_for_OBJ_group.hiplc (116.7 KB)

Using Houdini Indie 20.0
Ubuntu 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
83 posts
Joined: Feb. 2016
Offline
Use the assemble SOP after the copy sop ( assuming that is what you are using for the copies )to generate polygonal islands.

Then pipe that into a for each sop and use blast to delete un selected ( you can choose the group/s generated by the assemble sop )

attachment ( the color node is just for visual feedback )
Edited by nisachar - March 9, 2017 10:36:31
User Avatar
Staff
2540 posts
Joined: July 2005
Offline
One way is to use the copy_to_points SOP's ability to pack on copy to create your assemblies per copy (I don't know if you want to have different geometry per copy).

Then use the Assemble SOP to construct the groups per assembly/packed primitive.

Finally use an Unpack SOP set to transfer the groups. This will unravel the packed primitives to get back where you started and each piece belongs to it's own group.

See the attached Houdini scene file for a working example.
There's at least one school like the old school!
User Avatar
Member
55 posts
Joined: July 2011
Offline
nisachar
Use the assemble SOP after the copy sop ( assuming that is what you are using for the copies )to generate polygonal islands.

Then pipe that into a for each sop and use blast to delete un selected ( you can choose the group/s generated by the assemble sop )

attachment ( the color node is just for visual feedback )

Hi thank you, will try, but can't see the attachment unfortunately.
User Avatar
Member
55 posts
Joined: July 2011
Offline
jeff
One way is to use the copy_to_points SOP's ability to pack on copy to create your assemblies per copy (I don't know if you want to have different geometry per copy).

Then use the Assemble SOP to construct the groups per assembly/packed primitive.

Finally use an Unpack SOP set to transfer the groups. This will unravel the packed primitives to get back where you started and each piece belongs to it's own group.

See the attached Houdini scene file for a working example.


Thanks Jeff,
Will give the above a shot now.

Yes the workflow needs different geometry per group, all encapsulated in one obj. Unity will use this to attach a collider to each child instance within the parent object. In the attached image the individual elements have colliders on them so I'm able to paint attributes.

I can then use this for physics. Unfortunately Unity doesn't have an option for separating single object into multiple objects based on their material ID, but does offer the option to create separate materials for each object within a group on import.

Not sure about the code side of .obj but I've had success exporting multiple objects/groups as single OBJ from Unity via a custom script that can be viewed and accessed in Houdini. Script was done by a c# coder on the project.

I've basically created an object/attribute painter/copier app in Unity but would like to be able to seed thousands of initial objects in Houdini for large areas.

Using this for ArtStation challenge and about to start putting together the final image whith the thousands of objects.
https://www.artstation.com/contests/ancient-civilizations/challenges/13/submissions/14223 [artstation.com]

In the attached image the individual elements have colliders on them so I'm able to paint attributes.

p.s
A more intuitive idea would be to have a check box in the group node allowing to be ‘copy stampable’ so if I attach a group node under a sphere which is then copied onto a plain for example, that group becomes instanced along with the spheres. Would a nice feature to have this multi-obj group functionality available in one export node/option in the future.
Edited by Drakon - March 9, 2017 12:11:20
User Avatar
Member
83 posts
Joined: Feb. 2016
Offline
Drakon
Hi thank you, will try, but can't see the attachment unfortunately.

Wierd. Even Jeff's attachment doesn't show up. I tried uploading twice.

Edit.. shows up in this one…

this one uses both Jeff's method as well as mine. Doesn't show up as separate pieces in FBX in Modo but somehow export fine as Alembics.
Edited by nisachar - March 9, 2017 10:51:27

Attachments:
Polygon Islands.hiplc (111.4 KB)

User Avatar
Member
55 posts
Joined: July 2011
Offline
jeff
One way is to use the copy_to_points SOP's ability to pack on copy to create your assemblies per copy (I don't know if you want to have different geometry per copy).

Then use the Assemble SOP to construct the groups per assembly/packed primitive.

Finally use an Unpack SOP set to transfer the groups. This will unravel the packed primitives to get back where you started and each piece belongs to it's own group.

See the attached Houdini scene file for a working example.


Most Excellent! The Unpack route works and the groups are recognized by Unity. Thank you very much.

Just one small issue with pivots - the pivot of each individual sphere is taking it's centre from the grids's centre and not the individual sphere's centre. I can see that in ‘Assemble’ node the pivot location is set to Centroid, still Unity doesn't see this. I've tested this by wiring a transform node, scoping one of the spheres and still the pivot is set to grid center.

Apologies, I still don't know enough expressions to figure this out myself.

Thank you.
Edited by Drakon - March 9, 2017 13:11:42

Attachments:
houdiniPivotsmall.png (537.9 KB)

User Avatar
Member
55 posts
Joined: July 2011
Offline
Any help much appreciated, sorry just running out of time on this one.

Appending an Edit sop does the trick but this info is not exported with the Save > Geometry option, so the Pivot is always centred at world centre and not at each copied object centre.

Tried $GCX… on a transform node but that doesn't work with my set up for some reason.

Thank you
  • Quick Links