summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/VideoTexture.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-12 22:33:32 -0800
committerFuwn <[email protected]>2026-02-12 22:33:32 -0800
commitc7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch)
treedf9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/scape/VideoTexture.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/scape/VideoTexture.java')
-rw-r--r--NET/worlds/scape/VideoTexture.java232
1 files changed, 232 insertions, 0 deletions
diff --git a/NET/worlds/scape/VideoTexture.java b/NET/worlds/scape/VideoTexture.java
new file mode 100644
index 0000000..cfa07f9
--- /dev/null
+++ b/NET/worlds/scape/VideoTexture.java
@@ -0,0 +1,232 @@
+package NET.worlds.scape;
+
+import NET.worlds.core.IniFile;
+import NET.worlds.network.URL;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+public class VideoTexture extends Attribute {
+ DirectShow _ds = null;
+ TextureSurface _surface;
+ Texture[] _textures;
+ Material _material = null;
+ String _textureURL = "http://dev.worlds.net/rr-worlds/video/eminem.asf";
+ String _defTextureURL = IniFile.override().getIniString("defaultAd", "adworlds.cmp");
+ int _xSurface = 128;
+ int _ySurface = 128;
+ boolean _autoPlay = true;
+ int _rows = 1;
+ private static Object classCookie = new Object();
+
+ public VideoTexture(int attrID) {
+ super(attrID);
+ }
+
+ public VideoTexture() {
+ }
+
+ @Override
+ protected void noteAddingTo(SuperRoot owner) {
+ Rect s = (Rect)((Sharer)owner).getOwner();
+ s._videoAttribute = this;
+ this.assignMaterial(s);
+ }
+
+ private void assignMaterial(Rect s) {
+ int xTex = this._xSurface / 128;
+ if (xTex < 1) {
+ xTex = 1;
+ }
+
+ int yTex = this._ySurface / 128;
+ if (yTex < 1) {
+ yTex = 1;
+ }
+
+ this._surface = null;
+ this._ds = null;
+ this._rows = yTex;
+ this._material = new Material(URL.make(this._defTextureURL), xTex, yTex);
+ s.setMaterial(this._material);
+ this._textures = this._material.getTextures();
+ this._surface = new TextureSurface(this._textures, yTex, this._xSurface, this._ySurface);
+ this._ds = new DirectShow(this._surface.getHwnd());
+ this._ds.nOpen(this._textureURL);
+ if (this._autoPlay) {
+ this._ds.nPlay(1);
+ }
+ }
+
+ private void setTexture() {
+ Sharer sh = (Sharer)this.getOwner();
+ if (sh != null) {
+ Rect s = (Rect)sh.getOwner();
+ this.assignMaterial(s);
+ }
+ }
+
+ @Override
+ public void detach() {
+ Rect s = (Rect)((Sharer)this.getOwner()).getOwner();
+ s._videoAttribute = null;
+ if (this._ds != null) {
+ this._ds.nStop();
+ this._ds = null;
+ }
+
+ super.detach();
+ }
+
+ @Override
+ public void finalize() {
+ this.releaseAuxilaryData();
+ super.finalize();
+ }
+
+ public DirectShow getDirectShow() {
+ return this._ds;
+ }
+
+ public void videoFrame(FrameEvent f) {
+ this.draw();
+ }
+
+ @Override
+ public final void noteChange() {
+ }
+
+ public synchronized void draw() {
+ if (this._surface != null && this._ds != null) {
+ this._surface.setTextures(this._material.getTextures(), this._rows);
+ this._surface.draw(this._ds);
+ }
+ }
+
+ @Override
+ public void generateNetData(DataOutputStream s) throws IOException {
+ s.writeUTF(this._textureURL);
+ s.writeInt(this._xSurface);
+ s.writeInt(this._ySurface);
+ }
+
+ @Override
+ public void setFromNetData(DataInputStream ds, int len) throws IOException {
+ this._textureURL = ds.readUTF();
+ this._xSurface = ds.readInt();
+ this._ySurface = ds.readInt();
+ this.noteChange();
+ this.setTexture();
+ }
+
+ @Override
+ public Object properties(int index, int offset, int mode, Object value) throws NoSuchPropertyException {
+ Object ret = null;
+ switch (index - offset) {
+ case 0:
+ if (mode == 0) {
+ ret = StringPropertyEditor.make(new Property(this, index, "Texture URL"));
+ } else if (mode == 1) {
+ ret = this._textureURL;
+ } else if (mode == 2) {
+ this._textureURL = (String)value;
+ this.setTexture();
+ }
+ break;
+ case 1:
+ if (mode == 0) {
+ ret = IntegerPropertyEditor.make(new Property(this, index, "Texture Width"), 0, 1024);
+ } else if (mode == 1) {
+ ret = new Integer(this._xSurface);
+ } else if (mode == 2) {
+ this._xSurface = (Integer)value;
+ this.setTexture();
+ }
+ break;
+ case 2:
+ if (mode == 0) {
+ ret = IntegerPropertyEditor.make(new Property(this, index, "Texture Height"), 0, 1024);
+ } else if (mode == 1) {
+ ret = new Integer(this._ySurface);
+ } else if (mode == 2) {
+ this._ySurface = (Integer)value;
+ this.setTexture();
+ }
+ break;
+ case 3:
+ if (mode == 0) {
+ ret = BooleanPropertyEditor.make(new Property(this, index, "Auto-play?"), "No", "Yes");
+ } else if (mode == 1) {
+ ret = new Boolean(this._autoPlay);
+ } else if (mode == 2) {
+ this._autoPlay = (Boolean)value;
+ this.setTexture();
+ }
+ break;
+ default:
+ ret = super.properties(index, offset + 4, mode, value);
+ }
+
+ if (mode == 2) {
+ this.noteChange();
+ }
+
+ return ret;
+ }
+
+ @Override
+ public void saveState(Saver s) throws IOException {
+ s.saveVersion(1, classCookie);
+ super.saveState(s);
+ s.saveString(this._textureURL);
+ s.saveInt(this._xSurface);
+ s.saveInt(this._ySurface);
+ s.saveBoolean(this._autoPlay);
+ }
+
+ @Override
+ public void restoreState(Restorer r) throws IOException, TooNewException {
+ switch (r.restoreVersion(classCookie)) {
+ case 0:
+ super.restoreState(r);
+ this._textureURL = r.restoreString();
+ this._xSurface = r.restoreInt();
+ this._ySurface = r.restoreInt();
+ this.noteChange();
+ break;
+ case 1:
+ super.restoreState(r);
+ this._textureURL = r.restoreString();
+ this._xSurface = r.restoreInt();
+ this._ySurface = r.restoreInt();
+ this._autoPlay = r.restoreBoolean();
+ this.noteChange();
+ break;
+ default:
+ throw new TooNewException();
+ }
+
+ this.setTexture();
+ }
+
+ @Override
+ public void releaseAuxilaryData() {
+ if (this._ds != null) {
+ this._ds.nStop();
+ this._ds = null;
+ }
+
+ if (this._surface != null) {
+ this._surface.finalize();
+ this._surface = null;
+ }
+
+ if (this._material != null) {
+ this._material.detach();
+ this._material.finalize();
+ this._material = null;
+ }
+
+ this._textures = null;
+ }
+}