Java communicates with VRML using EAI mode
来源:互联网 发布:linux下搭建vm center 编辑:程序博客网 时间:2024/06/01 22:57
Last week several students came to ask me how to use java to control VRML?This question remembered me something:the same question was asked 2 years ago by one friend of mine,and I even forgot to tell him how.That's really too bad.He is now in Copenhagen,Denmark. I e-mailed him to ask this,he just totally forgot it. Well,things in the world are usually out of the control of your own hand,perhaps at that time I thought I had told him how.But now,I decide to write down the answer,though an old tech,it is useful for the beginners to understand something.
This article assumes you are familiar with Java,VRML and HTML(know about is OK).
To run the example below rightly you should eatablish its running envrionment.This is not our main point to discuss in this article,I'll just give u a clue and the environment information.The running environment is necessary to learn the java EAI mode communicating with VRML.
1.the "vrml97.jar" should be copied to the dir "jre/lib/etc".
2.one VRML plugin is necessary, you may choose"Cortona","Blaxxun" or "BS" as u like.
3.the classpath should be like "C:/jdk1.3.1_06/jre/lib/rt.jar;C:/jdk1.3.1_06/jre/lib/i18n.jar;C:/jdk1.3.1_06/lib/dt.jar;C:/jdk1.3.1_06/lib/tools.jar;C:/Program Files/Common Files/ParallelGraphics/Cortona/classes.zip;C:/Program Files/Common Files/ParallelGraphics/Cortona/corteai.zip
",here one thing I should mention is the jdk version,the 1.3 series is recommended.
4.your Microsoft VM should be reset to "Java Console Enabled (yes)
Java compiler (no)
Java Logging (yes) "
The following is the example,it includes three files:the create.wrl,the index.htm and the createbox.class,which was complied from the createbox.java.We use the java applet embedded in the html to control the wrl object embedded in the html.That's the main idea of EAI.
the index.htm(I use the cortona plugin):
<head><title>Create Sphere</title></head>
<body>
<object name="cortona" id="cortona"
codebase="http://www.parallelgraphics.com/bin/cortvrml.cab#Version=4,0,0,76"
classid="CLSID:86A88967-7A20-11d2-8EDA-00600818EDB1" width="52%" height="58%"
type="x-world/x-vrml" standby="Loading...">
<param name="src" value="create.wrl">
<param name="BackColor" value="#FFFFFF">
<param name="VRML_DASHBOARD" value="FALSE">
<param name="WaitForAllResources" value="TRUE">
<param name="VRML_SPLASHSCREEN" value="FALSE">
<embed name="cortona" id="cortona"
pluginspage="http://www.parallelgraphics.com/products/cortona/download/"
type="x-world/x-vrml" width="52%" height="58%" src="create.wrl"
vrml_background_color="#FFFFFF" vrml_dashboard="FALSE" waitforallresources="TRUE"
vrml_splashscreen="FALSE">
</embed>
</object>
<applet code="createbox.class" mayscript height="30" width="80"></applet>
</body>
</html>
the create.wrl:(a very simple one)
DEF NewNode Group {}
Shape {
appearance Appearance {
material DEF BoxMaterial Material {
diffuseColor 1 0 0
}
}
geometry Box { size 2 2 1 }
}
the createbox.java:
import vrml.eai.field.*;
import vrml.eai.Node;
import vrml.eai.BrowserFactory;
import vrml.eai.Browser;
public class createbox extends Applet ...{
public void init() ...{
super.init();
}
public void start() ...{
Browser browser = null;
Node rootnode = null;
EventInMFNode children = null;
// Get the VRML Browser - try 10 times
for (int count = 0; count < 10; count++) ...{
browser = BrowserFactory.getBrowser(this);
if (browser != null) break;
try ...{ Thread.sleep(200); } catch (InterruptedException e) ...{}
}
// Get the set_children eventIn of the DEF'd Group node
try ...{
rootnode = browser.getNode("NewNode");
children = (EventInMFNode) rootnode.getEventIn("set_children");
} catch (vrml.eai.InvalidNodeException ignored) ...{}
// Create a new blue Sphere Shape node
String newvrml =
"#VRML V2.0 utf8 Shape { appearance Appearance { material " +
"Material { diffuseColor 0 0 1 } } geometry Sphere { radius 1 } }";
// Create and add the new node to the scene graph
children.setValue( browser.createVrmlFromString( newvrml ) );
}
}
This example was tested to run well in my computer.
Nasky
- Java communicates with VRML using EAI mode
- Late Night Vrml 2.0 With Java
- the scmxx communicates with the simens finally
- Siebel EAI: Create a account with EJB3.x using AccountAttachment Business Service
- Using Vim's paste mode with the system paste command
- VRML与JAVA
- java控制vrml
- Using OpenCV Java with Eclipse
- Using OpenCV Java with Eclipse
- Using reCaptcha with java/jsp
- vrml
- EAI
- EAI
- Augmenting EAI with Web Services @ JDJ
- Using Struts With Java Data Objects
- Using the SOAP Protocol with Java
- Intro-Using Java with Oracle db(notes)
- using-couchdb-with-java-and-domain
- 让TcppWebbrowser响应键盘事件,如回车等
- Javascript脚本常用代码
- (Access Report开发系列一)在报表中添加Section
- VB.NET连接数据库的几种方法
- C++对象布局及多态实现之带虚函数的类
- Java communicates with VRML using EAI mode
- ACE开发游戏服务器笔记 (来自于 http://blog.donews.com/xtion/archive/2005/09/29/571881.aspx )
- Programming Video for Windows
- SQL语句复制表(两种有表结构、无表结构)
- VI编辑器的用法
- javascript读取xml
- 关于HashTable的操作
- struts源代码学习(初始化)
- pku1002题解