我的订单|我的收藏|我的商城|帮助中心|返回首页
虚拟现实新闻>VR>VR软件>Cult3d

cult3d和java综合运用 - Cult3D

文章来源:网络收集 作者:Frank 发布时间:2010年04月28日 点击数: 字号:

Cult3D and Java Methods
A java method is a function exposed by a Java object.

 

The Cult3DStart class exposes several methods:

 

doActionsStep
executeBlock
loadScript
loadScriptRes
executeMapped01 ... executeMapped32
Also it has other methods which are not visible to Cult player.

 

How Cult player knows which methods to call ?

 

There is a rule in implementing Java for Cult. In order methods to appear in Designer they must be public (in Java that means to be visible outside the object they belong), to return no value and to have one String parameter. Methods which does not respect this are not visible to the Cult player.

 

This is important, although this is a tutorial for non-Java programmers, because that means that a string parameter may be specified when you call a Java method in cult.

 

For example if you want to execute the block named "init" you can trigger the JAS_ExecuteBlock method and specify the name "init" as its string parameter.

 

Unfortunately things are so simple if you trigger the event from the HTML page only.

 

There is a player method - triggerAction(event_name, string_param) - which can be used to trigger an event in cult together with the string parameter.

 

If you trigger an event in Designer and that event is connected to a Java method you cannot specify the string param. Designer set the string param by itself and you cannot change this.

 

If the event is a MouseClick event and you click an object Designer will set the name of the object as the string parameter.

In the example above Designer will call the executeBlock method specifying "Cube" as the string parameter.

 

If the event is a KeyDown, KeyUp event the Designer put the key being pressed (released) as the string parameter.

 

If the event is a manual one, like JAS contains, then no string param is specified.

 

This is not good. We need a mechanism to specify the string parameter to inform JAS what block we want to execute.

 

For this reason I've included 32 methods excuteMapped01 ... 32 and a mapping mechanism which maps named blocks to executeMapped01...32 methods.

 

The command :

 


mapExecute("init", 1);
tells JAS that when Designer calls the executeMapped01 method JAS should execute the block named "init". When you use the mapExecute command you must specify a block name and an index between 1 and 32. The mapExecute command may be used whenever you want, mapping and re-mapping blocks as you need.

 

Suppose we have the following script:

 


javaActionsScript(1, 0, 0) {
printOut("project name");
printOut("your name, date");
mapExecute("init", 5);
}

 

actionsList ("init"){
printOut("initializing ...");
mapExecute("test", 5);
}
actionsList ("test"){
printOut("in test ...");
mapExecute("init", 5);
}
After the script is interpreted

共2页 您在第1页 首页 上一页 1 2 下一页 尾页 跳转到页 本页共有3184个字符
  • 暂无资料
  • 暂无资料
  • 暂无资料
  • 暂无资料
  • 暂无资料