Hello World

   Print

First Script

We like to write our first script and start with only one function in the render section.
In the method InitEffect() Write the function WriteText("Hello World"); in a new line.

 
Note: Do not forget the semicolon at the end of the line.
Than compile the script using the Short Cut "F5" for example, using the Button Compile in the Toolbar or go to Script > Compile.

 

@scriptname="";

@author="";

@version="";

@description="";

 

void InitEffect()

{

 WriteText("Hello World");

}

 

void RenderEffect()

{

 

}

 

void MatrixSizeChanged()

{

 InitEffect();

}

 

If everything is correct you should see a "Hello World" output at the Script Output section.

WriteText is a function of the MADRIX Script Language which write text into the script output during execution.
This function takes one parameter, the text to write.
Programmer which are familiar with C or C++ know this function under a different name TRACE.
It is up to you to use WriteText("some text") or TRACE("some text").
The function WriteText is very useful for debugging or during the development of a new script.

 

InitEffect() vs. RenderEffect()

Now we insert this line into the RenderEffect() method instead of the InsertEffect() method to get the following code.

 

@scriptname="";

@author="";

@version="";

@description="";

 

void InitEffect()

{

 

}

 

void RenderEffect()

{

 WriteText("Hello World");        

}

 

void MatrixSizeChanged()

{

 InitEffect();

}

 

If we now compile the script we get a lot of "Hello World" outputs in the Script Output section.
Why this?
The InitEffect method is processed only one time at the beginning of the effect. Therefore we get only one time output.
This method is used to initialize the effect. More detailed sampled will follow in later chapters.
The RenderEffect method is processed multiple times per second because within this the visual content of the effect will be generated.

 

MatrixSizeChanged()

There is one more method in the template if we create a new script.
Each time the matrix size changes for the effect this method is called by the system.
The matrix size will change if the patch size of your MADRIX setup is changed for example or if the mapping of your effect is changed.
By default the InitEffect() method is called within the MatrixSizeChanged() method.
Using the first script with WriteText at the InitEffect section would create a script output each time the matrix size has changed.

 

Congratulations! You have created your first MADRIX Script

MADRIX 5 Tutorials Version 1.0
[Ctrl & +/-] = Zoom In/Out | [Ctrl & 0] = 100%
Print