Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk 3ds® Max® / SDK / Drawing a copy of a node
  RSS 2.0 ATOM  

Drawing a copy of a node
Rate this thread
 
16607
 
Permlink of this thread  
avatar
  • Total Posts: 10
  • Joined: 15 May 2008 09:51 PM

I’ve got a helper object that is meant to let people specify a position for a shape in the scene - for use with other stuff after exporting to another environment. In order to help the authors line up the position correctly relative to other stuff in the scene that pertains to it, I want to draw a copy of the original object as part of my helper object’s geometry.

Does anybody have recommendations as to how to do this? Currently I’m keeping a reference back to the original node and calling its DrawAndHit method from within the helperobj’s DrawAndHit. This works ok but it’s resulted some instability and I’m not convinced it’s the best idea. It’s all complicated by the fact that I’d like to be able to support this drawing with entire groups of objects.



Replies: 0
avatar
  • StephenT
  • Posted: 18 September 2008 12:28 PM

Have you tried directly calling the Display method?  Why are you going with the Draw and Hit style?



If it aint broke, hit it with a hammer and then we’ll see…

Replies: 0
avatar

StephenT 18 September 2008 03:28 PM

Have you tried directly calling the Display method?  Why are you going with the Draw and Hit style?

I was using the draw and hit because I need the user to be able to select the shape copy as part of my object’s gizmo. I did try just using the Display method at one point - and I still had problems. It seemed like under certain rare circumstances, I’d get a mis-cast pointer to the original node and the subsequent calls to the INode method would just try to call methods on random spots in memory - giving me an pretty untraceable error.



Replies: 0
avatar
  • StephenT
  • Posted: 30 September 2008 01:29 PM

I’ve taken a quick look through the SDK documentation, but I can’t find any reference a routine called DrawAndHit - but I doubt that the routine itself is the cause of your issues.

If you have a reference (a Max-style reference, not C++) to your target object, then it is almost impossible to mis-cast it.  You get a pointer to an object, hold your pointer locally on your class, and it simply stays there.  I have a couple of suggestions that you may want to look at:

Make sure your setting your reference.  Call ReplaceReference to create a real Max-style reference.  Then, if the target node is deleted, you’ll get notified.  You should never really call SetReference directly.

Implement your NotifyRefChanged to handle the target deleted flag (I forget what its actually called) to make sure when the node gets deleted, you don’t lose track of it. [edit - I mean, keep trying to use the dangling pointer!!]

Make sure you reference the node, not the object.  This means you’ll keep track of the scene representation, calling display on the node will automatically include modifiers etc.  If you reference the object directly, you’ll just display the object, not the result of the geometry pipeline that the node draws.  Also, if you collapse to editable mesh for instance, the object will be deleted, but you probably still want to keep displaying the result.

If you really are worried about miscasting your pointer, then check the SuperClassID etc.  This is a good way to verify your plugin has the correct style of pointer.  An easier way to do this is to get the DEBUG version of Max too - I know its available for download on ADN.  Then you can see, in the watch window, exactly what type of class you are pointing at.

Anywho, if any of that makes sense, it might help you out somewhat.  If not, then perhaps some step-by-step workflow would help us out in making better suggestions :-)



If it aint broke, hit it with a hammer and then we’ll see…

Replies: 0
avatar

StephenT 30 September 2008 04:29 PM

I’ve taken a quick look through the SDK documentation, but I can’t find any reference a routine called DrawAndHit - but I doubt that the routine itself is the cause of your issues.

If you have a reference (a Max-style reference, not C++) to your target object, then it is almost impossible to mis-cast it.  You get a pointer to an object, hold your pointer locally on your class, and it simply stays there.  I have a couple of suggestions that you may want to look at:

Make sure your setting your reference.  Call ReplaceReference to create a real Max-style reference.  Then, if the target node is deleted, you’ll get notified.  You should never really call SetReference directly.

Implement your NotifyRefChanged to handle the target deleted flag (I forget what its actually called) to make sure when the node gets deleted, you don’t lose track of it. [edit - I mean, keep trying to use the dangling pointer!!]

Make sure you reference the node, not the object.  This means you’ll keep track of the scene representation, calling display on the node will automatically include modifiers etc.  If you reference the object directly, you’ll just display the object, not the result of the geometry pipeline that the node draws.  Also, if you collapse to editable mesh for instance, the object will be deleted, but you probably still want to keep displaying the result.

If you really are worried about miscasting your pointer, then check the SuperClassID etc.  This is a good way to verify your plugin has the correct style of pointer.  An easier way to do this is to get the DEBUG version of Max too - I know its available for download on ADN.  Then you can see, in the watch window, exactly what type of class you are pointing at.

Anywho, if any of that makes sense, it might help you out somewhat.  If not, then perhaps some step-by-step workflow would help us out in making better suggestions :-)

Thanks for taking the time to respond. I did recently switch from trying to track pointers (what a nightmare) to using the reference system - which has helped. In this particular case, the node in question is the parent node of my gizmo’s node - so I’m accessing it using the “GetParent()” method of the gizmo’s node (then checking to make sure I got a Node back before trying to draw it). Do you see any problems doing it that way?



Replies: 0
avatar
  • StephenT
  • Posted: 02 October 2008 12:52 PM

No, that seems pretty decent to me.

Although - the only thing about using the parent is that it is possible for the artist to change it, even accidentally.  If you create a full reference, you never need to worry about these sorts of issues.

Good luck - let us know how it goes



If it aint broke, hit it with a hammer and then we’ll see…

Replies: 0
avatar

I a new user to 3d max ver. 2011, the problem i was facing that i can’t draw line or inser object, there is a view point is in black surface divided in 4 parts, views are highlited but cant draw over it.



Attachment Attachment
Replies: 0
avatar
  • Istan
  • Posted: 07 March 2011 02:47 AM

rajive_sehgal 26 February 2011 08:15 AM

I a new user to 3d max ver. 2011, the problem i was facing that i can’t draw line or inser object, there is a view point is in black surface divided in 4 parts, views are highlited but cant draw over it.

And you created these viewports with the SDK?



Replies: 0