/*******************************************************************************
 * This file is part of TERMINAL RECALL
 * Copyright (c) 2012-2015 Chuck Ritola
 * Part of the jTRFP.org project
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Contributors:
 *     chuck - initial API and implementation
 ******************************************************************************/
package org.jtrfp.trcl.core;

import java.awt.Color;

import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
import org.jtrfp.trcl.TextureBehavior;
import org.jtrfp.trcl.Triangle;
import org.jtrfp.trcl.TriangleList;

public class PortalTexture implements TextureDescription {
    private final int portalFramebufferNumber;
    
    public PortalTexture(int portalFrameBufferNumber){
	this.portalFramebufferNumber=portalFrameBufferNumber;
    }

    @Override
    public Color getAverageColor() {
	return Color.black;
    }

    @Override
    public void apply(TriangleList triangleList, int gpuTVIndex, int numFrames,
	    Triangle thisTriangle, Vector3D pos, TriangleVertexWindow vw) {
	throw new UnsupportedOperationException();
    }

    @Override
    public void addBehavior(TextureBehavior beh) {
	throw new UnsupportedOperationException();
	
    }

    @Override
    public void removeBehavior(TextureBehavior beh) {
	throw new UnsupportedOperationException();
	
    }

    /**
     * @return the portalFramebufferNumber
     */
    public int getPortalFramebufferNumber() {
        return portalFramebufferNumber;
    }
 
}//end PortalTexture

@@ -624,16 +624,44 @@
 t.Color;
+%0Aimport java.util.ArrayList;
 %0A%0Aimport
@@ -905,17 +905,33 @@
 ate 
-f
 in
-al int
+t                      
  por
@@ -960,124 +960,339 @@
     
-%0A    public PortalTexture(int portalFrameBufferNumber)%7B%0A%09this.portalFramebufferNumber=portalFrameBufferNumber;%0A    %7D
+private final ArrayList%3CInteger%3E  relevantVertexIndices = new ArrayList%3CInteger%3E();%0A    private TriangleVertexWindow      triangleVertexWindow;%0A    %0A    public PortalTexture()%7B%7D%0A    %0A    public PortalTexture(TriangleVertexWindow triangleVertexWindow)%7B%0A%09this();%0A%09setTriangleVertexWindow(triangleVertexWindow);%0A    %7D//end constructor
 %0A%0A  
@@ -1972,16 +1972,957 @@
 ;%0A    %7D%0A
+    %0A    public void addRelevantVertexIndex(int idx)%7B%0A%09relevantVertexIndices.add(idx);%0A    %7D%0A%0A    public void setPortalFramebufferNumber(int portalFramebufferNumber) %7B%0A        this.portalFramebufferNumber = portalFramebufferNumber;%0A        final int textureID = 65536-getPortalFramebufferNumber();%0A        final TriangleVertexWindow vw = getTriangleVertexWindow();%0A        for(int i:relevantVertexIndices)%7B%0A            vw.textureIDLo .set(i, (byte)(textureID & 0xFF));%0A    %09    vw.textureIDMid.set(i, (byte)((textureID %3E%3E 8) & 0xFF));%0A    %09    vw.textureIDHi .set(i, (byte)((textureID %3E%3E 16) & 0xFF));%0A        %7D//end for(relevantVertexIndices)%0A    %7D//end setPortalFramebufferNumber(...)%0A%0A    public TriangleVertexWindow getTriangleVertexWindow() %7B%0A        return triangleVertexWindow;%0A    %7D%0A%0A    public void setTriangleVertexWindow(TriangleVertexWindow triangleVertexWindow) %7B%0A        this.triangleVertexWindow = triangleVertexWindow;%0A    %7D%0A
  %0A%7D//end

Add selectable texture ID support to portalTexture.