mjbWorld program - Running A BeanShell Script

Note: the following only applies if you are using the version of mjbWorld which includes Bean Shell. For more information about Bean Shell see http://www.beanshell.org/

To run a script

This particular script loads a green box, to see it click on front view:

To write your own script

You can use any text editor such as notepad to enter your own script file. The advantage of using a Bean Shell script is that it is written in Java, so once a script is developed, if it is useful it could potentially be compiled to a bean and turned into a part of the program.

The example script looks like this:


import mjbModel.*;
import mjbWorld.*;

transformGroupBean tg = new transformGroupBean();
shape3dBean shape = new shape3dBean();
boxBean box = new boxBean();
appearanceBean appearance = new appearanceBean();
materialBean material = new materialBean();

material.setDiffuseColor(new sfcolor(0.5f,0.9f,0.1f));

scene.add(TG);
tg.add(shape);
shape.add(box);
shape.add(appearance);
appearance.add(material);


The beans available are listed in Programmers guide here

typical methods available in these beans are:

add(node_bean nb)

add a bean to the scene under this bean.

setParameter(parameter)

getParameter()

i.e. uses the standard beans conventions for setting and getting parameters. For example to set the diffuseColor property use setDiffuseColor(sfcolor) as in the above example.


metadata block
see also:

 

Correspondence about this page

Book Shop - Further reading.

Where I can, I have put links to Amazon for books that are relevant to the subject, click on the appropriate country flag to get more details of the book or to buy it from them.

 

cover Developing Games in Java

Commercial Software Shop

Where I can, I have put links to Amazon for commercial software, not directly related to this site, but related to the subject being discussed, click on the appropriate country flag to get more details of the software or to buy it from them.

cover cover Blitz is based on BASIC programming language. Blitz Basic is 2D only, Blitz3D adds 3D commands.

This site may have errors. Don't use for critical systems.

Copyright (c) 1998-2017 Martin John Baker - All rights reserved - privacy policy.