home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Late Night VRML 2.0 with Java CD-ROM
/
code.zip
/
Ch12
/
geometry
/
MovieTexture.java
< prev
next >
Wrap
Text File
|
1997-01-04
|
4KB
|
206 lines
// VRML Generator
// Copyright Justin Couch 1996
//
// Chapter 13: Late Night VRML 2.0 and Java
//
// Shape class
package geometry;
import java.io.PrintStream;
import vrml.external.*;
import vrml.external.field.*;
import vrml.external.exception.*;
import geometry.Texture;
public class MovieTexture extends Texture
{
EventInMFString _set_url;
EventInSFBool _set_loop;
EventInSFFloat _set_speed;
EventInSFTime _set_starttime;
EventInSFTime _set_stoptime;
String[] url;
boolean loop = false;
float speed = 1;
double startTime = 0;
double stopTime = 0;
// Null constructor since you cannot create just a straight texture
public MovieTexture()
{
Browser b = Browser.getBrowser();
if(b == null)
return;
node = b.createVrmlFromString("MovieTexture {}")[0];
_set_url = (EventInMFString)node.getEventIn("url");
_set_loop = (EventInSFBool)node.getEventIn("loop");
_set_speed = (EventInSFFloat)node.getEventIn("speed");
_set_starttime = (EventInSFTime)node.getEventIn("startTime");
_set_stoptime = (EventInSFTime)node.getEventIn("stopTime");
have_browser = true;
}
public MovieTexture(Browser b)
{
if(b == null)
return;
node = b.createVrmlFromString("MovieTexture {}")[0];
_set_url = (EventInMFString)node.getEventIn("url");
_set_loop = (EventInSFBool)node.getEventIn("loop");
_set_speed = (EventInSFFloat)node.getEventIn("speed");
_set_starttime = (EventInSFTime)node.getEventIn("startTime");
_set_stoptime = (EventInSFTime)node.getEventIn("stopTime");
have_browser = true;
}
public MovieTexture(boolean rptS, boolean rptT)
{
String tmp = "MovieTexture { ";
repeatS = rptS;
repeatT = rptT;
if(!repeatS)
tmp += "repeatS FALSE ";
if(!repeatT)
tmp += "repeatT FALSE ";
tmp += "}";
Browser b = Browser.getBrowser();
if(b == null)
return;
node = b.createVrmlFromString(tmp)[0];
_set_url = (EventInMFString)node.getEventIn("url");
_set_loop = (EventInSFBool)node.getEventIn("loop");
_set_speed = (EventInSFFloat)node.getEventIn("speed");
_set_starttime = (EventInSFTime)node.getEventIn("startTime");
_set_stoptime = (EventInSFTime)node.getEventIn("stopTime");
have_browser = true;
}
public MovieTexture(Browser b, boolean rptS, boolean rptT)
{
String tmp = "MovieTexture { ";
repeatS = rptS;
repeatT = rptT;
if(!repeatS)
tmp += "repeatS FALSE ";
if(!repeatT)
tmp += "repeatT FALSE ";
tmp += "}";
if(b == null)
return;
node = b.createVrmlFromString(tmp)[0];
_set_url = (EventInMFString)node.getEventIn("url");
_set_loop = (EventInSFBool)node.getEventIn("loop");
_set_speed = (EventInSFFloat)node.getEventIn("speed");
_set_starttime = (EventInSFTime)node.getEventIn("startTime");
_set_stoptime = (EventInSFTime)node.getEventIn("stopTime");
have_browser = true;
}
public void writeToFile(PrintStream fp, int indent)
{
int i;
StringBuffer buffer = new StringBuffer();
for(i = 0; i < indent; i++)
buffer.append(" ");
fp.print(buffer.toString() + "texture ");
if(name != null)
fp.print("DEF " + name + " ");
fp.println("MovieTexture {");
if(!repeatS)
fp.println(buffer.toString() + " repeatS FALSE");
if(!repeatT)
fp.println(buffer.toString() + " repeatT FALSE");
if(url.length > 0)
{
fp.println(buffer.toString() + " url [");
for(i = 0; i < url.length; i++)
{
fp.println(buffer.toString() + " \"" +
url[i] + "\"");
}
fp.println(buffer.toString() + " ]");
}
if(loop)
fp.println(buffer.toString() + " loop TRUE");
if(speed != 1)
fp.println(buffer.toString() + " speed " + speed);
if(startTime != 0)
fp.println(buffer.toString() + " startTime " + startTime);
if(stopTime != 0)
fp.println(buffer.toString() + " stopTime " + stopTime);
}
public void set_URL(String[] new_url)
{
url = new_url;
if(have_browser)
_set_url.setValue(url);
}
public void set_loop(boolean val)
{
loop = val;
if(have_browser)
_set_loop.setValue(val);
}
public void set_speed(float val)
{
speed = val;
if(have_browser)
_set_speed.setValue(val);
}
public void set_startTime(double val)
{
startTime = val;
if(have_browser)
_set_starttime.setValue(val);
}
public void set_stopTime(double val)
{
stopTime = val;
if(have_browser)
_set_stoptime.setValue(val);
}
}