This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > VRML > August 2005 > changing viewpoint position with 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 changing viewpoint position with java
AnRil

2005-08-22, 7:31 pm

I need to change a viewpoint using Java class, I really lost any ideas on
how about to do this, I've tried even to use PositionInterpolator, it
didn't worked out. Below partial sources for the vrml and java file. Thanx
in advance for any response.

VRML:

DEF VP Viewpoint
{
position 18 53 30
orientation 1 0 0 0
jump TRUE
description "glowny"
}

DEF SC Script
{
url ["Mif.class"]
field SFNode vp USE VP
}


Java:

public class Mif extends Script
{
public void initialize()
{
Browser browser = this.getBrowser();
SFNode vp=(SFNode)getField("vp");
SFVec3f vppos=(SFVec3f)((Node)vp.getValue()).getExposedField("position");
....
try
{
...
/*
xmin,xmax,ymin,ymax calculated before, all are float
*/
float xpos=(float)((xmin+xmax)/2);
float ypos=(float)((ymin+ymax)/2);
float xdiff=(float)Math.abs((float)xmin-xmax);
float ydiff=(float)Math.abs((float)ymin-ymax);
float diff=Math.max(xdiff,ydiff);
float zpos=(float)(diff*Math.sqrt(2.0));
vppos.setValue(xpos,ypos,zpos);
}
}

public void processEvent(Event e)
{
}// processEvent()

public void shutdown()
{
}// shutdown()
}
--
AnRil :: POLAND :: GDAÑSK :: WRZESZCZ
gg:1021464 skype:anril_jaq
FORÇA BARÇA & TORONTO RAPTORS :]
Opera RULES :D :D :D :D :D (8.01 k. 7642)
Mangiucugna

2005-08-23, 7:34 am

Your error is that you take the node and his value, but the viewpoint
node doesn't have any value. You have to take the node, take the refer
to the exposedfield and change. But i might have a better solution...
create one eventIn SFVec3f position_in and one eventOut SFVec3F
position_out
Now route the value viewpoint.position_changed to position_in and
route position_out to viewpoint.set_position
Now you take the positon in calculate and out the result
viewpoint.position is an exposedField.

Stefano

Sponsored Links


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