|
| 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)
|
|