please leave your comment

Thursday, May 20, 2010

R&D Schooling fish in 3dsmax

After a few days doing some test, finally i found the way to create auto turning animation for the fish. This is still very simple solution using bend modifier driven by script controller, but in my opinion its really effective way for massive object. Because after i satisfy with the result i can collapse the animation and convert to keyframe to reduce the computation. Its not finished yet, i will update in some part to improve the quality.

Thursday, May 6, 2010

Random Sequence without Repetition (Maxscript)

In practical use of scripting sometimes we really often using Random function to generate random numbers. But in some cases usually we also need to get random number in sequence without any repetition. for example how you get 5 sequence number without any same number in your result? By using "random 1 5" you will always have a chance to get the same number. Then how is the solution for this task...? After playing around little bit finally i found this solution:

-- CREATE FUNCTION
fn RandomSequence Num=
(   
    theSequence = for i=1 to Num collect i    -- Create Initial Sequence
    theResult =#() -- Create empty array for the result
   
    -- Loop
    range = theSequence.count+1
    for j=1 to theSequence.count do
    (   
        range -=1
        rand = random 1 range -- Create  random  start with higher range value until empty
        append theResult theSequence[rand]    -- Insert to the Result
        index = finditem theSequence theSequence[rand]    -- Check the index of result in thesequence
        deleteitem theSequence index     -- Then delete item in theSequence with indexed number
    )    -- End Loop
    theResult  -- Output the result
)

RandomSequence 10 -- Call the function


----------------Result---------------------
#(7, 8, 10, 5, 2, 4, 3, 6, 1, 9)


Every time you execute this function it will always generate new random number in sequence without any repetition. You can try use this number to manipulating object properties, transform, etc.

Wednesday, May 5, 2010

Welcome to maxscript

Yeah..!!! Welcome to maxscript. That's right, Since i am using 3dsMax in my current company, i have to start learning maxscript to make my life easier when facing some problem.Although sometimes its take time to develop new things with script, but i realize that bigger things sometime comes with small thing that you get from the experience in the past. So there is nothing wrong with doing some trial and error every time you have problem that need a good solution. Scripting is not the main solution for every problem, sometimes its faster to do manually rather than developing new script when dealing with the deadline. But its also a good way to use script for everyday use(like repetitive task) or for future solution increasing your speed in productivity. For example:  In a simple case we can easily align box to another object like sphere. But how if you have to align 100 box to another 100 sphere? would you do this by hand? By using the script we can ask your computer to do the job which much more efficient in a just a few line of code.
Initially i am not a technical guy (Trust me, i really weak in math), But i really love to do some R&D to know how things work. every time i did, i've got new knowledge when dealing with problems. Sometimes it will push me to find some reference or source, or even i must try to remember some lesson that i've got in high school. Ok, i thinks that's enough for introduction...
For now on, i will share some of my knowledge here about maxscript in my spare time. :)