Home Technical Talk
The BRAWL² Tournament Challenge has been announced!

It starts May 12, and ends Sept 12. Let's see what you got!

https://polycount.com/discussion/237047/the-brawl²-tournament

MaxScript (Beginners) Questions

polycounter lvl 14
Offline / Send Message
PeteHawk polycounter lvl 14
Hey folks.
Currently working on a project for uni, trying to create a more user friendly fire generator in 3DsMax.
Using Partical systems as the basis of the tool and just simplifying it.

FireGen_img.png

Replies

  • PeteHawk
    Offline / Send Message
    PeteHawk polycounter lvl 14
    So I may need a little help here and there. Would appreciate it if anyone could point me in the right direction.
    Here's what I'm stuck with:


    1st:
    I need it so that my spinners are disabled when the Partical System is not selected in the scene
    if myPartical != undefined then
    (
    particalSpeed.enabled = false
    )
    else
    (
    particalSpeed.enabled = true
    )

    2nd
    I want to add a play timeline button to my rollout. But I cannot find the maxScript of the action.
    timeline.play
    ??
  • Mark Dygert
    RE 1st:
    I'm not exactly sure how to acomplish this without doing some trial and error scripting which I don't have time for right now but I think I can help with you're 2nd question.

    RE 2nd:
    "max time play" to start the animation playback.
    "stopAnimation()" to stop the playback.

    You might also want to add an option to your fire generator to create a looping system since particles in max don't actually loop on their own. You do this by creating 4 identical sprayers set to go off at regular intervals and fade out as others are fading in. Here is a thread that talks about it as well as links to another script that automates the process a bit:
    http://www.polycount.com/forum/showthread.php?p=1197140#post1197140
  • havardsc
    To update the ui you can add a selection callback:
    1. (
    2. tp = teapot name:"Special teapot"
    3. fn selectionCallback e handles =
    4. (
    5. if handles.count == 1 and selection[1] == tp then
    6. print tp.name
    7. )
    8. ::callbackItem = nodeEventCallback selectionChanged:selectionCallback
    9. )
    This one checks if there is only one object selected and if the selected object is the teapot created before. The reason I use selection[1] instead of GetHandleByAnim is to prevent the if-statement to pass when you deselect the object. Be sure to clean it up if you use it.
    More details here: http://docs.autodesk.com/3DSMAX/14/ENU/MAXScript%20Help%202012/files/GUID-7C91D285-5683-4606-9F7C-B8D3A7CA508-2062.htm

    Instead of max time play you can use playanimation() which gives you some more optional arguments.
  • PeteHawk
    Offline / Send Message
    PeteHawk polycounter lvl 14
    Cheers guys, still having a little trouble with the callback but everything else is working just fine. Much appreciated.
    I'm working on adding a texture to my particle. It's a pre-set that I've made which should be applied by a simple button press.


    Untitled-1.png

    Error:
    -- Error occurred in texture(); filename: F: \MaxScript\; position: 888; line: 32
    -- Frame:
    -- called in addTexture.pressed(); filename: F: \MaxScript\; position: 2716; line: 63
    -- Frame:
    >> MAXScript Rollout Handler Exception:
    -- Unknown property: "color1" in undefined <<

    I also need to find a way of applying textures to the viewport (2 on diagram)
  • monster
    Offline / Send Message
    monster polycounter
    1. You should probably use a more descriptive function name. Generic names like "texture" are easy to type, but when you look at your code some time from now, or share it with others, a more descriptive name will be appriciated. So instead of Texture() we'll use ApplyNoiseTexture().

    2. The problem is that you are referencing the Noise map by name, but the name of the map has changed. When you apply a Noise texture through the interface, the name is #Diffuse_Color__Map__1____Noise. However, when you apply it through maxscript the name is #Diffuse_Color__Noise____Noise. Working with names is unreliable. Instead you should store the Noise texture in a variable on creation, then reference the variable's properties.

    1. fn ApplyNoiseTexture =
    2. (
    3. newNoiseMap = Noise()
    4. newNoiseMap.color1 = color 255 146 30
    5. newNoiseMap.color2 = color 255 42 0
    6. newNoiseMap.type = 1
    7. meditMaterials[1].diffuseMap = newNoiseMap
    8. )
  • PeteHawk
    Offline / Send Message
    PeteHawk polycounter lvl 14
    Great stuff monster, makes perfect sense and thanks for the tip. I still need to comment my script at some point.
    Any ideas for showing material in viewport? maybe
    1. showTextureMap newNoiseMap true
  • PeteHawk
    Offline / Send Message
    PeteHawk polycounter lvl 14
    Ok, finally got the callback working, so that you can only change the values if its selected, thanks havardsc and cheers mark for the timeline playback.
    One final question would be, how to link my two colour pickers to the noise texture.

    1. myColorPicker cp2 "" width:72 height:40 title:"Colour 2"
    2. myColorPicker cp1 "" width:72 height:40 title:"Colour 1"
    1. newNoiseMap.color1 = color 255 144 0
    2. newNoiseMap.color2 = color 255 30 0
  • monster
    Offline / Send Message
    monster polycounter
    One way control is pretty easy. (Color Picker controls the Noise Map)
    1. on cp1 changed val do
    2. (
    3. meditMaterials[1].diffuseMap.color1 = val
    4. )
    5.  
    6. on cp2 changed val do
    7. (
    8. meditMaterials[1].diffuseMap.color2 = val
    9. )

    Two way control would be a little trickier since the ColorPicker control doesn't support animation controllers. Basically, you would create hidden spinners, have those modifier the color picker and vice versa. But also assign the controllers of the RGB channels of the Noise map color to the spinners.

    For this script to work reset the scene, and apply a noise map to medit[1]'s diffuse channel.
    1. rollout ColorLinkTest "Color Link"
    2. (
    3. colorPicker cp1 "" width:72 height:40
    4. spinner spnR "" range:[0,1,0] visible:false
    5. spinner spnG "" range:[0,1,0] visible:false
    6. spinner spnB "" range:[0,1,0] visible:false
    7. fn updateColor =
    8. (
    9. cp1.color = (color (spnR.value*255.0) (spnG.value*255.0) (spnB.value*255.0))
    10. )
    11. on ColorLinkTest open do
    12. (
    13. AnimController = Point3_XYZ()
    14. meditMaterials[1].diffuseMap.color2.controller = AnimController
    15. spnR.controller = meditMaterials[1].diffuseMap.color2.controller.x.controller
    16. spnG.controller = meditMaterials[1].diffuseMap.color2.controller.y.controller
    17. spnB.controller = meditMaterials[1].diffuseMap.color2.controller.z.controller
    18. updateColor()
    19. )
    20. on cp1 changed val do
    21. (
    22. spnR.value = val.r/255.0
    23. spnG.value = val.g/255.0
    24. spnB.value = val.b/255.0
    25. )
    26. on spnR changed val do
    27. (
    28. updateColor()
    29. )
    30. on spnG changed val do
    31. (
    32. updateColor()
    33. )
    34. on spnB changed val do
    35. (
    36. updateColor()
    37. )
    38. )
    39. createDialog ColorLinkTest
Sign In or Register to comment.