Itoo Software Forum

Author Topic: Getting element transforms  (Read 4561 times)

Shawn Olson

  • Jr. Member
  • **
  • Posts: 92
  • Wall Worm
    • Wall Worm
Getting element transforms
« on: June 14, 2014, 02:57:57 PM »
I need to get the transformations for each element of a RailClone. Below is my pseudo-code start:

Code: [Select]
function wallworm_railclone_map rc = (

for currentNode in rc.sobjnode do (

local transforms = for t in rc.TRANFORMATIONS_FOR_currentNode_PARTS collect t

/*
NOW DO WHATEVER
*/

)

)

In the code above, how would I collect an array of transforms that are for the node specified as currentNode ?
Shawn Olson
Product Management Team @ Autodesk for 3ds Max
Developer of Wall Worm Tools

Shawn Olson

  • Jr. Member
  • **
  • Posts: 92
  • Wall Worm
    • Wall Worm
Re: Getting element transforms
« Reply #1 on: June 14, 2014, 03:45:12 PM »
What I'm trying to do is export prop locations/orientations. I went through all the public properties and couldn't seem to find a solution.

I also tried using the Railclone Tools Instantiate utility as a manual work-around. But it won't work as I need because of a couple important issues:

1) The pivots are always offset with the instanced nodes that are generated (and I need the instances to have pivots unmodified from the original state in relation to the mesh).

2) Some segment elements are collapsed together (with a pivot aligned to the RC node itself).

For my purposes, I really just want to calculate the transforms of the segments on the fly, but I wanted to mention the Instantiate tool issues as well.
Shawn Olson
Product Management Team @ Autodesk for 3ds Max
Developer of Wall Worm Tools

iToo

  • Administrator
  • Hero Member
  • *****
  • Posts: 4123
    • iToo Software
Re: Getting element transforms
« Reply #2 on: June 15, 2014, 09:09:15 AM »
There is an important limitation in the workflow you want to achieve: not all elements of RailClone are instances, only those that are identical to the segment (not bended, sliced or deformed in any way). For this reason, RailClone Tools generates a collection of instances, and a separated mesh with the geometry that cannot be instantiated.

Besides that, RailClone includes an API to generate the geometry/instances without using RailClone Tools. It's used by some render engines as Thea Render or Corona, but it's written for for C++, not for Maxscript.
Carlos Quintero
iToo Software

Shawn Olson

  • Jr. Member
  • **
  • Posts: 92
  • Wall Worm
    • Wall Worm
Re: Getting element transforms
« Reply #3 on: June 15, 2014, 04:24:00 PM »
I suspected just such an answer.

That being said, I'd like to add a new option in RC for "Keep All Segments as Instances" specifically for this scenario, along with the ability to derive the transforms of the instances. While this is a specific scenario that forces a limit on some of the features of RC, it would help me add native prop export using Rail Clone (instead of just exporting a single large-high poly asset, the scene can reuse assets as is expected in the game engine), in my game exporter tools. I've already added this support for Forest Pro, and I would really love to have it with Railclone as well.

As it stands, emulating this requires me to use standard Max spline distribution--which is far more tedious than using Railclone and doesn't remain parametric.
Shawn Olson
Product Management Team @ Autodesk for 3ds Max
Developer of Wall Worm Tools

iToo

  • Administrator
  • Hero Member
  • *****
  • Posts: 4123
    • iToo Software
Re: Getting element transforms
« Reply #4 on: June 15, 2014, 05:16:34 PM »
If that helps, there is a combination of settings that disables most of deformations (and therefore increasing the number of instances):

- For Segments: Bend Off, Slice Off and Deform->Adaptative or Stepped.
- For Generators: Corner->Bevel Mode None

Or alternatively use proxies for Segments, that always as instanced. Anyway, i add your suggestion to the wishlist. I think it would be done easily.
Carlos Quintero
iToo Software

Shawn Olson

  • Jr. Member
  • **
  • Posts: 92
  • Wall Worm
    • Wall Worm
Re: Getting element transforms
« Reply #5 on: June 16, 2014, 03:15:46 AM »
If that helps, there is a combination of settings that disables most of deformations (and therefore increasing the number of instances):

- For Segments: Bend Off, Slice Off and Deform->Adaptative or Stepped.
- For Generators: Corner->Bevel Mode None

Or alternatively use proxies for Segments, that always as instanced. Anyway, i add your suggestion to the wishlist. I think it would be done easily.

Thanks!
Shawn Olson
Product Management Team @ Autodesk for 3ds Max
Developer of Wall Worm Tools

Shawn Olson

  • Jr. Member
  • **
  • Posts: 92
  • Wall Worm
    • Wall Worm
Re: Getting element transforms
« Reply #6 on: October 26, 2022, 03:23:33 AM »
It's been several years since I asked this question, but I was returning to the problem now that I see that there is an Instantiate option in Segment Deform tab. Is there a method and/or existing example where I can query a RailClone object to get these bits of relational data:

  • Nodes used in each instance
  • Transform of each instance inside the RailClone

Also, is there a complete MAXScript Reference for RC? I was using Show & ShowInterfaces to inspect, but since there are so many params, it would be nice to get the full docs. I didn't see any RC MXS reference. Thanks in advance.
Shawn Olson
Product Management Team @ Autodesk for 3ds Max
Developer of Wall Worm Tools

iToo

  • Administrator
  • Hero Member
  • *****
  • Posts: 4123
    • iToo Software
Re: Getting element transforms
« Reply #7 on: October 26, 2022, 09:55:39 AM »
The support for Maxscript is very limited. To fetch all RC data, including instances, transforms, etc. is better to use the C++ API. This is the method used by third-parties (as render engines) to support our plugins.

You can find them at Github: https://github.com/itoosoft. Documentation is included in the header file.
Carlos Quintero
iToo Software

Shawn Olson

  • Jr. Member
  • **
  • Posts: 92
  • Wall Worm
    • Wall Worm
Re: Getting element transforms
« Reply #8 on: October 26, 2022, 02:39:15 PM »
Thanks for the update. It would be far more convenient for my purpose if I could get to this data via MAXScript. I'd put this in as a vote from me :)

I looked at the header and it kind of looks like I'll be able to write a C++ function using this, but I'm not 100% sure. I do not need the meshes at all in most cases--just the transform and a reference to what INODE created that instance--as I'm exporting that instance as an entity into a game and generally not using the mesh at all.

I saw that in TRCInstanceV400 you provide the INode *node; But I see the comment is  // Source INode for non-geometric segments . I would need the node regardless of type. Does this return the Inode in all cases or just non-geometric instances?

If that returns an Inode in all cases, it probably works for my needs. In my case I would then just be building a function to publish to MAXScript that my exporter can use to insert the data into functions already written to expect MXS.

I'd love a way to query this data via MXS:

Code: [Select]
instanceCount = RC.GetInstanceCount()
for i = 1 to instanceCount do (
local instance = RC.GetInstance i
local node = instance.node
if isvalideNode node then (--in case the instance comes from a scene node and not another data source
local transform = instance.transform
/*
Use the data
*/
)
)
Shawn Olson
Product Management Team @ Autodesk for 3ds Max
Developer of Wall Worm Tools

iToo

  • Administrator
  • Hero Member
  • *****
  • Posts: 4123
    • iToo Software
Re: Getting element transforms
« Reply #9 on: October 27, 2022, 10:26:59 AM »
No, it's not possible to get a INode in all cases. TRCInstanceV400::node works only for non-geometric objects (lights and so).
There are two reasons for this limitation:

a) Geometry can be embedded in the RailClone object, without any reference to INodes. This happens for example when you delete the source node from scene. In this case, RC keeps a copy of the geometry internally.
b) Some segments generate a different mesh from the source node. Geometry can be deformed, sliced, etc.

As you can see, this work very different from Forest, where all items are instances of the source INodes.

Another option would be to convert RC to standalone objects, using RailClone Tools. It creates the required INodes for each segment, keeping the instances where possible.

Can i ask what what game engine do you use ? We're evaluating to provide exporting tools for Unity, Unreal, etc. in next versions.

Carlos Quintero
iToo Software

Shawn Olson

  • Jr. Member
  • **
  • Posts: 92
  • Wall Worm
    • Wall Worm
Re: Getting element transforms
« Reply #10 on: October 29, 2022, 01:24:40 PM »
No, it's not possible to get a INode in all cases. TRCInstanceV400::node works only for non-geometric objects (lights and so).

OK. It would be great if there was added a method to get the inodes for those that happen to have inodes.

Another option would be to convert RC to standalone objects, using RailClone Tools. It creates the required INodes for each segment, keeping the instances where possible.

This isn't ideal because it breaks proceduralism and iteration. It's a reason that I developed a tool called PropLine almost a decade ago because I needed to keep the system procedural and export instances. Even though I can use PropLine for my purposes, I prefer to use RC because of its robust control and speed. PropLine is MAXScript-driven and creates meshes... causing it to be much less performant than RC.

Can i ask what what game engine do you use ? We're evaluating to provide exporting tools for Unity, Unreal, etc. in next versions.

This is for the Source Engine. I've built and maintained a Max > Source Engine pipeline called Wall Worm for over a decade. I wanted to update the level exporter to support RC in the same fashion that I support Forest and PropLine for placing game entities. I know that RC would have to be used in the narrow context of Instanced segments, but for my needs, that is what I'd be doing.

(Not directly related but informational: We used both Forest and RailClone in the development of the Xen, Gonarch and Interloper chapters of Black Mesa.)
Shawn Olson
Product Management Team @ Autodesk for 3ds Max
Developer of Wall Worm Tools

iToo

  • Administrator
  • Hero Member
  • *****
  • Posts: 4123
    • iToo Software
Re: Getting element transforms
« Reply #11 on: November 02, 2022, 11:37:21 AM »
OK. It would be great if there was added a method to get the inodes for those that happen to have inodes.

Well, even if Segment has an INode, RailClone may generate different meshes, depending if result is bended, sliced, etc.
Getting the INode for exporting would be correct only if the resulting mesh is exactly an instance of the source (for example if 'Force Instance' is used).

Quote
This is for the Source Engine. I've built and maintained a Max > Source Engine pipeline called Wall Worm for over a decade. I wanted to update the level exporter to support RC in the same fashion that I support Forest and PropLine for placing game entities. I know that RC would have to be used in the narrow context of Instanced segments, but for my needs, that is what I'd be doing.

I see. But what is the problem exactly to generate and export the meshes, together their transformations ? RC already does the hard job, generating instanced meshes where possible.

Quote
(Not directly related but informational: We used both Forest and RailClone in the development of the Xen, Gonarch and Interloper chapters of Black Mesa.)

Nice to know. I have one more reason to play it !  ;)

Carlos Quintero
iToo Software