Question about a script node using JAVA 
Author Message
 Question about a script node using JAVA


There is a little test combination (which is a part of a larger scene,
which is meant to communicate with a dtabase over JDBC), which I am
trying to run. This works on cosmo player, but does not work on any
other browser I have tried, Cortona included.

The script is a part of a PROTO, and on passing the mouse on the one of
the spheres its docnumber should appear near the sphere.

Two possibilities I have in mind:
1. Only Cosmoplayer supports a script node inside a proto (not very
2. Something wrong in the Java code which cosmoplayer "tolerates" (more
3. Some conflict in the wrl file.

I attach the code of both WRL and java class (using jikes as compiler),
and hope you will be able to help me.



 field SFVec3f trans 0 0 0
 field SFFloat rad 0.25
 field MFFloat textlen 0.75
 exposedField MFString docnam ""
 field SFFloat fontsize 0.2
 field SFFloat fontspace 0.01
 field SFInt32 docnumber 0
      translation IS trans
     appearance DEF transp Appearance {
        material Material { transparency 0.5}
     geometry Sphere { radius IS rad}

  DEF touch TouchSensor{},

  #Document is a script written in
  #the Java language, that communicates with the database
  DEF Document Script{
     url "test_no_jdbc.class"
     field SFInt32 thenumber IS docnumber
     field SFVec3f thelocation IS trans
     eventIn SFBool showName
     eventOut MFString thename
     eventOut MFFloat thelength

     # Based on a mouse click and other circumstances
     # the active document is either added to the user profile
     # or some further textual information is supplied
     eventIn SFBool retrieve

     axisOfRotation 0.0 0.0 0.0
        Shape {#shape2
    appearance DEF Red Appearance {
       material Material {
   emissiveColor 1.0 0.0 0.0
   diffuseColor 1 0 0
   #shininess 1
   #ambientIntensity 1
    geometry DEF docnametext Text {
       string IS docnam
       length IS textlen
       fontStyle DEF docFontStyle FontStyle{
   size IS fontsize
   spacing IS fontspace
   family "SANS"
   style "BOLD"
        } #shape2
     ]# Billboard children
      ]# Proto transform children
      #      ROUTE touch.isActive TO Document.retrieve
      ROUTE touch.isOver TO Document.showName
      ROUTE Document.thename TO docnametext.set_string
      ROUTE Document.thelength TO docnametext.set_length



   skyColor 0.6 0.8 1


Doc{ textlen 0.5 }
Doc{ textlen 0.5 docnumber 1 trans 1 0 0}
Doc{ textlen 0.5 docnumber 214 trans 0 1 0}

------------------------------------------------end of WRL file

import vrml.*;
import vrml.Browser;
import vrml.field.*;
import vrml.node.*;
//import java.sql.*;
//import java.util.Properties;

public class test_no_jdbc extends Script {

    private  SFInt32 thenumber ;
    private SFVec3f thelocation;
    private SFBool showName;
    private MFString thename;
    private MFFloat thelength;
    //    private String db_id[]={""};

    public void initialize() {

    public void processEvent(Event e) {
 if(e.getName().equals("showName") == true){
     // "getValue" only initialize an instance of SFbool
     ConstSFBool v = (ConstSFBool)e.getValue();
     String name_value[]={makeString(thenumber.getValue())};
     float text_length[]={textLength(name_value[0])};
     String zero[]={"zero"};
     } else {

    public String makeString(int docNum){
 String s=new String(""  + docNum);
 //Integer Docnumber= new Integer(docNum);
 return s ;

    public float textLength(String s){
 //return s.length*lengthPerChar
 return (float)0.0;


-------------------------------------------end of java

Michael Preminger

Forsker / Research Scientist
Avdeling for journalistikk,
bibliotek- og informasjonsfag /
Faculty of Journalism, Library and
Information Science
H?gskolen i Oslo / Oslo College

http://www.*-*-*.com/ ~michaelp

Pilestredet 52, N-0167 Oslo
Voice: +47-22452778
Fax:   +47-22452605

Sat, 03 Nov 2001 03:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Help Needed : Using native methods in Java Script Nodes in Netscape 4.0/Cosmo 2.0

2. Question about Java class in Script node

3. Mixing Java EAI stuff with Java in Script nodes

4. Script node: JavaScript vs. Java

5. Java Script Node and security

6. HELP java script node and outside communication

7. Security problem in a VRML JAVA Script node?

8. VRML, JAVA (script node) and Windows NT

9. Java networking inside a script node

10. NEED HELP, Java script node and applet

11. VRML Java Script Node strangeness

12. Problem with script node written in JAVA


Powered by phpBB® Forum Software