Scripting to populate scene with objects?

Hi, not sure where to look for this information but the background is that I have a lot of small 3D utilities I have developed in C#. They creates things like particle systems, heightmapped data using simple boxes (many boxes), clusters of spheres etc. I use them to produce abstract 3D art and love the Iray renderer in DAZ Studio. Problem is I have to export my data to .obj files and then import the objects into DAZ Studio. If I have a cluster of several thousands of spheres, the obj file grows to Gigabytes in size and takes a very looooong time to import.

I think that there must already exist a way to tell DAZ Studio to populate the scene with primitive objects other than going the extra mile using .obj files. But I do not know where to look. Basically it is very simple data. A cluster of spheres for example is nothing but a list of sphere data (x,y,z for position, a radius and a number for the count of lattitudes/longitudes). 

I hope someone can point me in the right direction. Do I have to script things inside DAZ Studio (i.e. convert my C# code to whatever script language is used in DAZ Studio) or is there a way via some SDK or something to write some importer-plugin to be able to read my data from file and use it to populate the scene with spere objects? 

Best regards

Sefan

Comments

  • staspstasp Posts: 13

    To give you an idea of what I want to be able to populate in the scene :)

    ParticleSystem2D_circle-20_20 copy_1024.jpg
    1024 x 706 - 381K
  • Matt_CastleMatt_Castle Posts: 2,299
    edited January 2021

    I think this is already largely covered by UltraScatter Pro.

    https://www.daz3d.com/ultrascatterpro

    EDIT: On re-reading, I might have misunderstood slightly. In any case, UltraScatter does demonstrate the possibility of what you're doing, so *yes*, the scripting tools do exist. Unfortunately, I'm not an expert on that side of things.

    However, another option is that .DUF and .DSF files are, while often zipped, comprehensible code, so it would actually be possible to study their format and create a C# utility that could write directly to this format, which may well be faster than trying to have DazScript read a file and assemble it itself.

    Post edited by Matt_Castle on
  • RobotHeadArtRobotHeadArt Posts: 904
    edited January 2021

    If you are a programmer, you can write a script to read a text file that contains the points and then in DAZ Studio, create instances of the objects.  You're going to run into several challenges though.

    1. In DAZ Studio, you have to create instances of geometry, not points. So you need to have something with polygons, not just a center point, radius, and size.
    2. Instances use the same material, so you wouldn't be able to vary the colors/textures/etc of each instance.
    3. DAZ's support of instances is pretty primitive. It can't support instances of instances and the viewport gets super laggy with lots of instances being displayed. You can work around it slightly by showing just the bounding boxes.

    If you're programming and want to do lots of instances with complex shading, I would suggest you look at SideFx's Houdini.  It's pretty much Visual Studio for 3d art.  You can write code and use the node system to develop very sophisticated scattering/instancing as well as being able to write code for shading each instance (example, every third sphere is blue, every fourth sphere is red, every sphere with 1 meter of this square is a shade of yellow).  Houdini is also designed for handling millions of instances and will not lag like DAZ Studio.  For some ideas of abstract designs you can code, check out the youtube channels of Entagma and Junichiro Horikawa.  There is a free version of Houdini you can try out that has limits on render size and renders are watermarked.  They have an indie license that removes those restrictions.

    I attached a screenshot showing an example of Houdini's instancing power. This is 5000 spheres as instances with random colors applied.  If you tried to do this in DAZ Studio, you would find it not possible as the instances would need to have the same color.  You can also see it only uses 600KB of memory for the 5000 spheres, but in DAZ Studio it would need to represent geometry which would occupy more memory.

    Spheres.jpg
    1513 x 626 - 199K
    Post edited by RobotHeadArt on
  • staspstasp Posts: 13

    Thank you for your information. It was helpful :)

    The thing is... what I find funny and interesting is creating the data structures my self. Programming the stuff is at least as fun as rendering/creating the image. If I used Houdini, it would not be the same amount of fun. I would still be producing cool images but no "programming from scratch" involved. And to render large size images, I would have to pay for Houdini.

    Guess I have to stick with generating .obj files (where I still can group different speres with different material groups), DAZ Studio handles the imported data as one object with diferrent material zones, so it is pretty easy to handle materials. The only problem is the size of the .obj file and it seems to me like it is an extra step that would not be needed :)

     

  • staspstasp Posts: 13

    Matt_Castle said:

    I think this is already largely covered by UltraScatter Pro.

    https://www.daz3d.com/ultrascatterpro

    EDIT: On re-reading, I might have misunderstood slightly. In any case, UltraScatter does demonstrate the possibility of what you're doing, so *yes*, the scripting tools do exist. Unfortunately, I'm not an expert on that side of things.

    However, another option is that .DUF and .DSF files are, while often zipped, comprehensible code, so it would actually be possible to study their format and create a C# utility that could write directly to this format, which may well be faster than trying to have DazScript read a file and assemble it itself.

    Yes I know, I already have ultrascatterpro :) But since I want to program stuff my self, I was looking for a way to leave out the step where I export my data to .obj and then import the .obj in DAZ Studio. I wanted to push the data directly in to the current scene.

  • staspstasp Posts: 13

    Another example. Spraying spheres onto a bigger sphere. Imported to DAZ Studio and rendered :)

    randomSphereForm_allan copy_1024.jpg
    1024 x 706 - 379K
  • ArtiniArtini Posts: 8,528

    Very nice, please post more renders.

     

  • WendyLuvsCatzWendyLuvsCatz Posts: 37,712

    stasp said:

    Thank you for your information. It was helpful :)

    The thing is... what I find funny and interesting is creating the data structures my self. Programming the stuff is at least as fun as rendering/creating the image. If I used Houdini, it would not be the same amount of fun. I would still be producing cool images but no "programming from scratch" involved. And to render large size images, I would have to pay for Houdini.

    Guess I have to stick with generating .obj files (where I still can group different speres with different material groups), DAZ Studio handles the imported data as one object with diferrent material zones, so it is pretty easy to handle materials. The only problem is the size of the .obj file and it seems to me like it is an extra step that would not be needed :)

     

    if you can get it into DAZ studio as separate objects (FBX sometimes works or via the Hexagon bridge) Totte (Code66) has the instancify script 

    https://www.daz3d.com/instancify

  • HavosHavos Posts: 5,294

    You could always create a DAZ Studio plug-in for your program. I have not done this before myself, but several people have, you can download the SDK for free. I am pretty sure the language you will need is C++, so your existing program should port over easily. 

    Ultrascenery accelerator is a plugin and it creates literally hundreds of thousands of instances in a very short period of time, so it is clear that plug-ins have access to the instance creation apis.

  • richardandtracyrichardandtracy Posts: 4,981
    edited January 2021

    It is possible to program all this in DAZ Studio, and I do know instancing is possible though I've not yet needed to try. So, can I suggest that you go ahead & try it.

    I usually do my programming in C++, and there is not a huge difference in concept between C++ and the ScriptingAPI, both are OOP based languages with inheritence & polymorphism. The hardest thing I have had to get around is that the variables are untyped, so it is possible to assign objects to things you thought were integers. Things became a bit easier when I started thinking of all variable as pointers instead, which then made it comprehensible how you could assign an object to something that had been a bool up until the assignment.

    One thing I will say is that, in comparison to most 'proper' programming languages, the documentation is awful, and a lot of trial & error is needed even to find out member functions of objects. It's less catastrophic than the documentation for DAZ Studio, but is nowhere near the quality you'd expect for a serious programming environment. The DS3 API documention is much better, but unfortunately the DS3 API was only a small subset of the DS4 API, but it will allow you to get up & running with basic scripts fairly fast, if not doing everything that's possible.

    There are quite a few DS4 API script examples which cover a few holes in the documentation, so don't miss them.

    Best of luck.

    Richard.

     

    Post edited by richardandtracy on
  • staspstasp Posts: 13

    richardandtracy said:

    It is possible to program all this in DAZ Studio, and I do know instancing is possible though I've not yet needed to try. So, can I suggest that you go ahead & try it.

    I usually do my programming in C++, and there is not a huge difference in concept between C++ and the ScriptingAPI, both are OOP based languages with inheritence & polymorphism. The hardest thing I have had to get around is that the variables are untyped, so it is possible to assign objects to things you thought were integers. Things became a bit easier when I started thinking of all variable as pointers instead, which then made it comprehensible how you could assign an object to something that had been a bool up until the assignment.

    One thing I will say is that, in comparison to most 'proper' programming languages, the documentation is awful, and a lot of trial & error is needed even to find out member functions of objects. It's less catastrophic than the documentation for DAZ Studio, but is nowhere near the quality you'd expect for a serious programming environment. The DS3 API documention is much better, but unfortunately the DS3 API was only a small subset of the DS4 API, but it will allow you to get up & running with basic scripts fairly fast, if not doing everything that's possible.

    There are quite a few DS4 API script examples which cover a few holes in the documentation, so don't miss them.

    Best of luck.

    Richard.

     

    Thanks for your reply. Since I have limited amount of time, I think I have decided to continue to export to obj files and then import them. I want it to be simple to use, trial and error is not what I am looking for right now ;) 

Sign In or Register to comment.