This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > VRML > May 2005 > VRML and Java





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author VRML and Java
AnRil

2005-05-16, 7:20 am

i've got problem with using java. i'm a student and we're told to use
microsoft's compiler and vm.
files are compiled using jvc (visual j++ compiler) and view files with IE.
i've got MS VM installed,
but also Sun JRE 1.50 and my IE even doesn't show initialisation
information in the file I
appended.
thanx for any idea.


WRL FILE:

#VRML V2.0 utf8

Transform
{
translation-5.5 0 0
children
[
DEFtouchR TouchSensor {}
Shape
{
appearance Appearance
{
material DEF matR Material
{
diffuseColor 1 0 0
}
}
geometry Box
{
size 1 5 0.1
}
}
]
}

Transform
{
translation-4 0 0
children
[
DEFtouchG TouchSensor {}
Shape
{
appearance Appearance
{
material DEF matG Material
{
diffuseColor 0 1 0
}
}
geometry Box
{
size 1 5 0.1
}
}
]
}

Transform
{
translation-2.5 0 0
children
[
DEFtouchB TouchSensor {}
Shape
{
appearance Appearance
{
material DEF matB Material
{
diffuseColor 0 0 1
}
}
geometry Box
{
size 1 5 0.1
}
}
]
}

DEF kulka Transform
{
translation0 0 0
children
[
DEFtouchS TouchSensor {}
Shape
{
appearance Appearance
{
material DEF matS Material
{
diffuseColor 0.8 0.8 0.8
}
}
geometry Sphere
{
radius 1
}
}
]
}

Transform
{
translation5 0 0
children
[
DEFtouchV TouchSensor {}
Shape
{
appearance Appearance
{
material DEF matV Material
{
diffuseColor 1 1 1
}
}
geometry Box
{
size 1 5 0.1
}
}
]
}

DEFskrypt Script
{
eventInSFVec3fposR
eventInSFVec3fposG
eventInSFVec3fposB
eventInSFVec3fposV
field SFNode matR USE matR
field SFNode matG USE matG
field SFNode matB USE matB
field SFNode matS USE matS
field SFNode kulka USE kulka
field SFNode move USE touchV
url"example.class"
}

ROUTE touchR.hitPoint_changed TO skrypt.posR
ROUTE touchG.hitPoint_changed TO skrypt.posG
ROUTE touchB.hitPoint_changed TO skrypt.posB
ROUTE touchV.hitPoint_changed TO skrypt.posV



Java file

import vrml.*;
import vrml.field.*;
import vrml.node.*;

public class example extends Script
{
private SFNode matR,matG,matB,matS,kulka,move;
private SFFloat transparencyR,transparencyG,transparencyB;
private SFColor diffuseColor;
private SFVec3f translation;
private ConstField position,pos2;
private float r=1,g=1,b=1,x,y,z;


public void initialize()
{
matR= (SFNode)getField("matR");
matG= (SFNode)getField("matG");
matB= (SFNode)getField("matB");
matS= (SFNode)getField("matS");
kulka = (SFNode)getField("kulka");
move = (SFNode)getField("move");
System.out.println("Initialize complete");
}

public void processEvent(Event e)
{
transparencyR=(SFFloat)((Node)matR.getValue()).getExposedField("transparency");
transparencyG=(SFFloat)((Node)matG.getValue()).getExposedField("transparency");
transparencyB=(SFFloat)((Node)matB.getValue()).getExposedField("transparency");
translation =
(SFVec3f)((Node)kulka.getValue()).getExposedField("translation");
diffuseColor=(SFColor)((Node)matS.getValue()).getExposedField("diffuseColor");

if(e.getName().equals("posR"))
{
position = e.getValue();
r = (float)(2.5 + ((ConstSFVec3f)position).getY())/5;
transparencyR.setValue(new SFFloat(1-r));
diffuseColor.setValue(new SFColor(r,g,b));
System.out.println ("r = "+ r + " g = " + g + " b = " + b);
}

if(e.getName().equals("posG")) {
position = e.getValue();
g = (float)(2.5 + ((ConstSFVec3f)position).getY())/5;
transparencyG.setValue(new SFFloat(1-g));
diffuseColor.setValue(new SFColor(r,g,b));
System.out.println ("r = "+ r + " g = " + g + " b = " + b);
}

if(e.getName().equals("posB")) {
position = e.getValue();
b = (float)(2.5 + ((ConstSFVec3f)position).getY())/5;
transparencyB.setValue(new SFFloat(1-b));
diffuseColor.setValue(new SFColor(r,g,b));
System.out.println ("r = "+ r + " g = " + g + " b = " + b);
}

if(e.getName().equals("posV"))
{
pos2 = e.getValue();
x = ((ConstSFVec3f)pos2).getY();
translation.setValue(new SFVec3f(0, x, 0));
System.out.println ("x = "+ x + " y = " + y + " z = " + z);

}
}
}

--
AnRil :: POLAND :: GDAÑSK :: WRZESZCZ
gg:1021464 skype:anril_jaq
FORÇA BARÇA & TORONTO RAPTORS :]
Opera RULES :D :D :D :D :D (8.0 k. 7561)
Russ

2005-05-17, 7:50 am

Off the top of my head without actually
compiling and trying your code,
Have you added -depreciate to the
command line? That is pretty much
a necessity if you are going to use
Sun 1.1 or greater instead of M.S.
to compile.

tc
Russ

AnRil

2005-05-17, 7:50 am

Dnia Tue, 17 May 2005 09:45:15 +0200, Russ <Pyth7@comcast.net> napisa³:

> Off the top of my head without actually
> compiling and trying your code,
> Have you added -depreciate to the
> command line? That is pretty much
> a necessity if you are going to use
> Sun 1.1 or greater instead of M.S.
> to compile.
>
> tc
> Russ
>


i _DON'T_ compile it with sun's java sdk

--
AnRil :: POLAND :: GDAÑSK :: WRZESZCZ
gg:1021464 skype:anril_jaq
FORÇA BARÇA & TORONTO RAPTORS :]
Opera RULES :D :D :D :D :D (8.0 k. 7561)
Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews