2005


3ds Max References
References are like record of the relationships that exist between objects and elements of the scene. For example a Boolean-object is dependent upon its two operand objects, so anytime one of them changes the Boolean-object gets notified so it can calculate the new result, a lookat constraint is dependent upon the look-at object that is pointing to (target camera could be an example of this), or consider a simple sphere where the radius is animated, anytime this parameter is changed notifies the sphere object in order to make it bigger or smaller. References are not usually very well known by scripters, however Max architecture is heavily based on them, so I thought that some useful examples could help scripters to understand their utility. I've been playing with references enough to say that they can give you access to all the information you need from an element of your scene, areas that you couldn't access through getPropNames or subAnims.

How do I use references?
refs.dependents <MAXWrapper_object> [immediateOnly:<boolean>]
would give us an array of elements that depend of the object specified. Note that those elements could be objects, controllers, parameter blocks, etc... all of them are references to the object specified. If immediateOnly parameter is true, only the immediate dependents of the specified object would be returned.

refs.dependsOn <MAXWrapper_object>
would return an array of elements that the specified object directly depends on. For example if we ask a sphere what are its dependencies, it returns the transform controller, the sphere parameter block, and the layer where the sphere is located.

refs.dependencyLoopTest <MAXWrapper_object> <maxwrapper_object>
basically allows us to test the dependency loop between two references in the scene. For example if object A had a look-at constraint that points to Object B, and we try to create a look-at constraint for this object B, we couldn't use the object A as a target because it would create an infinite loop: I'm looking what you are looking, but ey! you were looking what I was looking , but ... wasn't I looking what you were looking ? ...

Example 1: Accessing to all controllers of an object
References become very handy in cases where you would have go through all properties/subanim/controllers/submaterials etc. Imagine you want to grab all the controllers of an object in your scene. The typical approach to this problem would be to get the subanims and go through them looking for controllers. But what happens if some controllers have subcontrollers or a controller depends of a different controller.

MAXSCRIPT:
  1.  
  2. fn getControllers ref =
  3. (
  4.     local ctrlList = #()
  5.     local refList = refs.dependsOn ref
  6.  
  7.     for r in refList do   
  8.     (
  9.         if (isProperty r #keyable == true) then
  10.             append ctrlList r
  11.  
  12.         join ctrlList (getControllers r)
  13.     )
  14.  
  15.     return ctrlList
  16. )
  17.  
  18. -- we create our sphere object
  19. myObject = Geosphere radius:10
  20. myObjectControllers = getControllers myObject
  21. for c in myObjectControllers do
  22.     format "% - %\n" c (exprForMaxObject c)
  23.  

Example 2: Accessing all bitmaps textures of a material
With a simple modification we could grab all the bitmap textures from a material, no matter how deep they are inside submaterials, mix maps, composite maps, etc ...

MAXSCRIPT:
  1.  
  2. fn getBitmapTextures ref =
  3. (
  4.     local bitmapList = #()
  5.     local refList = refs.dependsOn ref
  6.  
  7.     for r in refList do   
  8.     (
  9.         if (classof r == bitmaptexture) then
  10.             append bitmapList r
  11.  
  12.         join bitmapList (getBitmapTextures r)
  13.     )
  14.  
  15.     return bitmapList
  16. )
  17.  
  18. -- we create a standard material with a opacity map and a mix
  19. -- map in the diffuse channel that contains two textures
  20. mixTex= mixTexture map1:(bitmapTexture()) map2:(bitmapTexture())
  21. myMat = standard diffusemap:mixTex opacityMap:(bitmapTexture())
  22. myObject.mat = myMat
  23.  
  24. myObjectBitmatTextures = getBitmapTextures myObject.mat
  25. for t in myObjectBitmatTextures do
  26.     format "% - %\n" t (exprForMaxObject t)
  27.  

Example 3: Scene References
Here is a trick if you want to get almost all references that are in your scene:

MAXSCRIPT:
  1.  
  2. -- first we ask for the dependencies of the root node:
  3. rootRefs = refs.dependents rootNode
  4. -- returns:
  5. --   #(ReferenceTarget:Scene)
  6.  
  7. -- secondly we ask what objects depends on the scene reference:
  8. refs.dependson rootRefs[1]
  9. -- returns:
  10. --   #(ReferenceTarget:Material_Editor,ReferenceTarget:MtlBaseLib,
  11. --    ReferenceTarget:Default_Sound,$<root>,RenderEnvironment:(null),
  12. --    ReferenceTarget:NamedSelSetList,ReferenceTarget:Animatable,
  13. --    ReferenceTarget:Animatable,RenderEffects:(null),shadowMap:shadowMap,
  14. --    ReferenceTarget:LayerManager)
  15.  

As you can see, it returns an array of very useful references, that we could recurse to grab almost everything in the scene.

Example 4: Show me all!
Last week I noticed that there was an activeX installed in the 3dsMax root directory, it is called addFlow4.ocx so I investigated a bit more and voila! we have an Flowcharting activeX installed by default! very interesting to create flowcharts like the schematic editor. I was thinking that combining references with a powerful way to see them will make us understand much better the way 3ds max works under the hood, so I wondered what if I create the flowchart of the references in the scene, or for the selected object, or for the current renderer... This a script that uses both, references and the flow activeX and it displays the all references that are going on in the current scene.

I hope this helps, and people consider using more often references in their scripts.

Download: [ ReferenceViewer.ms ReferenceViewer.zip ]

blurLogo.jpgWe are looking for a talented coder/scripter here at Blur. If you think you know everything about Maxscript, you love making artist's life easier, and even better, you have some experience writing plugins for 3dsmax, let us know! we have a position right here waiting for you.
I warn you ... you would end working with me though! ;) but I promise that it will be in very cool and challenging projects and indeed with some of the most talented and dedicated people in this field.
Drop me an email if you are interested, or send your resume’ and an example of your code to Blur Studio, tom@blur.com

Diego Garcia Huerta
Tools Programmer
www.blur.com


(Diego 04 October 2005) We found Eric! but we are always looking for talented people so if you are interested send the resume anyway!

I had never been in E3 Exhibition before, this year was the first time and I have to say that I'm very impressed, It reminded me like Siggraph's old golden days. I don't play videogames a lot but I always like to take a look at the last gadget in the market, and this year was indeed the perfect year because the anouncement of the new consoles PS3, XBOX2, Nintendo Revolution, 2006 sounds very promising!

During E3 I had the oportunity to take a look at what Blur did for the exhibition, "Hellgate London", "Aeonflux", "Company of heroes", "Shadow", etc ... I mainly worked on pipeline tools so people could previsualize their job before sending it to renderfarm, and a bunch of tools that improved the workflow considerably.

Here there are some pictures of the event:

E3 2005, crowed as always!


Hellgate London - Blur

Batman Begin's Videogame, I worked for it in Eurocom last year

PacMan 25th Aniversary - GameBoy Mini

NAMCO Girls - E3's 2005 best attraction ;)

Silhouette.jpgIt's been a while because I've been extremely busy last couple of months moving and at work but ... there it is!
Fernando, this is the script you requested in the wishlist section, I hope it does what you need. As always any improvement or any bug, please people let me know and I'll fix it. Thanks for your suggestions.

The script turns on/off the silhouette appareance of the objects, making their wireframe color black (customizable) and the viewport shade to object mode. It can be assigned to a shorcut key to easy access. The option menu is displayed when the user presses the shift key at the same time that runs the script, so the silhouette color can be customized as well as to affect only the selected objects instead of the whole scene (default behaviour). When the silhouette mode is off the objects recover their original wireframe color.

Download: [ Silhouette.zip Silhouette.zip ]

WishListImage.jpgIt always happens, "If I < put your favourite 3D application > had this option ... ", "I wish I could have a script for ... ", how many times have asked yourself the same question in the last month ...

Now you can post your idea in the WishList section (adding a comment to the post) and tell me what would you like to have as script or plugin for Max or Maya and I´ll try to code it if I have enough time for it. You can comment any bug you found in any script I´ve done, or anything that you would include or remove from them...wish-list link

Next Page »