-- 作者:cleverwz
-- 发布时间:3/15/2009 7:46:00 PM
-- vrml 与java连接运行不起来,帮忙看看
vrml 代码 Viewpoint { position 0 0 15 orientation 0 0 1 0 fieldOfView 0.8 } Background { skyColor [ 0 0 0.2, 0.1 0.1 0.8, 0.7 0.8 0.9 ] skyAngle [1 1.57 ] groundColor [ 0 0 0, 0.5 0.4 0.3, 0.3 0.3 0.3 ] groundAngle [1 1.57] } DEF ball1 Transform { translation -3 0 0 children [ DEF touch1 TouchSensor{ } Shape { appearance Appearance { material DEF SphereColor Material { diffuseColor 1 0 0 } } geometry Sphere { } } ] } DEF ball2 Transform { translation 3 0 0 children [ DEF touch2 TouchSensor{ } Shape { appearance Appearance { material DEF SphereColor2 Material { diffuseColor 0 1 0 } } geometry Sphere { } } ] } DEF print Script { url "print.class" eventIn SFBool clicked eventIn SFBool clicked2 field SFString sceneEnt "Sphere" } ROUTE touch1.isActive TO print.clicked ROUTE touch2.isActive TO print.clicked2 java代码: import vrml.*; import vrml.field.*; import vrml.node.*; public class print extends Script { public void processEvent(Event e) { ConstSFBool v=(ConstSFBool)e.getValue(); if(v.getValue()) { System.out.println("you clicked aball"); if(e.getName().equals("clicked")==true) { System.out.println("red"); } else { System.out.println("green"); } } } } 在dos 中编译print.java 时出现错误,无法访问 Script 错误的类文件 .\script.class 类文件包含错误的类: vrml.node.script ...... public class print extends(这里出现提示) Script 不知道是哪出问题了,也把vrml的包放进去了,弄了很长时间,帮忙指导一下。谢谢 我是用vrmlpad编号vrml代码后,它里面有调试,进入运行的,(或直接按f8直接运行),是ParallelGraphics公司的VRML浏览器Cortona ,仅出现vrml模型,还有B用S Contact VRML,打开后也不行
|