Is vab va x vb

package cgp.render; import cgp.basics.Shape3D; import cgp.basics.Face3D; import cgp.basics.Vertex3D; import cgp.basics.LightParams; import cgp.math.Point2f; import cgp.math.Point4f; import java.util.Enumeration; / ** * A renderer that * - performs BFC, * - clips the remaining areas on the frustum * - displays textures. * * This version takes into account that there is no longer any difference between * Flat and CurvedFace or -Vertex. * * Now a BFCuller is used. * * @author Olaf Mueller * @version V1.0 07/22/2002 * / public class TextureMapper implements Renderer {public static final float EPS = -0.001f; public WCClipper clipper; public BFCuller bfculler; public view view; public lighting lights = null; public CGCanvas cgc = null; int [] colors; // Triangle for shading // DC coordinates Point4f [] dc = {new Point4f (), new Point4f (), new Point4f ()}; // texture coordinates Point2f [] tc = {new Point2f (), new Point2f (), new Point2f ()}; // Vertices with all information Vertex3D [] triangle = {new Vertex3D (null, 0, null, new Point2f ()), new Vertex3D (null, 0, null, new Point2f ()), new Vertex3D (null, 0, null , new Point2f ())}; public TextureMapper () {clipper = new WCClipper (); bfculler = new BFCuller (); colors = new int [256]; for (int i = 0; i <256; i ++) {colors [i] = 255 << 24; colors [i] | = i << 16; colors [i] | = i << 8; colors [i] | = i; }} / ** * Central method; triggers the rendering of the scene. The transferred view * provides all information that the renderer needs to display the scene *. * The transfer of the view enables the use of the same * renderer instance in several views. * / public void renderScene (View view) {Scene scene = view.scene; lights = scene.lights; Camera cam = view.cam; Shape3D shape; // current body Face3D face; // current area view.cgc.clearBuffer (); // prepare new frame view.cgc.clearZBuffer (); // prepare new frame enumeration e = scene.getVisibleShapes (cam); // list of visible bodies while (e.hasMoreElements ()) {// run through list shape = (Shape3D) e.nextElement (); // get the next body if (shape == cam) continue; for (int j = 0; j 2)) {// area partially visible? Vertex3D tmptri; kc = node.length; float tmpw; // according to Hecker's instructions. However, there seem to be // a few problems ... // Transfer all information for the first vertex // Project geometry coordinates view.WC2DC.multiply (node ​​[0] .wc, triangle [0] .wc); tmpw = 1f / triangle [0] .wc.w; // remember homogeneous coordinate triangle [0] .wc.homogenize (); // divide by homogeneous coordinate triangle [0] .wc.w = tmpw; // save homogeneous coordinates // project texture coordinates triangle [0] .tc.u = node [0] .tc.u * tmpw; triangle [0] .tc.v = node [0] .tc.v * tmpw; // save normals triangle [0] .wc_normal = knoten [0] .wc_normal; // set area triangle [0] .face = f; // From here: second vertex view.WC2DC.multiply (node ​​[1] .wc, triangle [2] .wc); tmpw = 1f / triangle [2] .wc.w; // remember homogeneous coordinate triangle [2] .wc.homogenize (); // divide by homogeneous coordinate triangle [2] .wc.w = tmpw; // save homogeneous coordinates // project texture coordinates triangle [2] .tc.u = node [1] .tc.u * tmpw; triangle [2] .tc.v = node [1] .tc.v * tmpw; // save normal triangle [2] .wc_normal = node [1] .wc_normal; // set area triangle [2] .face = f; for (int k = 2; k = vB.wc.y) {vC = vc; } else {vC = vB; if (vc.wc.y> = vA.wc.y) {vB = vc; } else {vB = vA; vA = vc; }} // Sorting completed // Now the test for negative z-coordinates follows if (((vA.wc.z <0) || (vB.wc.z <0)) || (vC.wc.z < 0)) {System.out.println ("shade: Negative z-coordinate in the triangle:"); System.out.println ("vA =" + vA + "; vB =" + vB + "; vC =" + vC); } // Now comes the calculation of the gradients // We have 5 parameters in this implementation: // x, z, w, u and v. // These are already available in the form // x / w, z / w, 1 / w, u / w and v / w. Gradients gradAC = new Gradients (5); Gradients gradAB = new Gradients (5); Gradients gradBC = new Gradients (5); if (vA.wc.y! = vC.wc.y) {// Edge AC not horizontal -> calculate slopes onedy = 1f / (vC.wc.y - vA.wc.y); sxAC = (vC.wc.x - vA.wc.x) * onedy; szAC = (vC.wc.z - vA.wc.z) * onedy; swAC = (vC.wc.w - vA.wc.w) * onedy; suAC = (vC.tc.u - vA.tc.u) * onedy; svAC = (vC.tc.v - vA.tc.v) * onedy; } else {// slopes are not required - except for the compiler ;-) sxAC = 0f; szAC = 0f; swAC = 0f; suAC = 0f; svAC = 0f; } // Y = Scanline starts at the top point (A) y = ceil (vA.wc.y); yPreStep = y - vA.wc.y; float xAC = vA.wc.x + yPreStep * sxAC; float zAC = vA.wc.z + yPreStep * szAC; float wAC = vA.wc.w + yPreStep * swAC; float uAC = vA.tc.u + yPreStep * suAC; float vAC = vA.tc.v + yPreStep * svAC; yEnd = ceil (vB.wc.y); if (vA.wc.y == vB.wc.y) {// Edge AB horizontal} else {onedy = 1f / (vB.wc.y - vA.wc.y); sxAB = (vB.wc.x - vA.wc.x) * onedy; // Calculate gradients szAB = (vB.wc.z - vA.wc.z) * onedy; swAB = (vB.wc.w - vA.wc.w) * onedy; suAB = (vB.tc.u - vA.tc.u) * onedy; svAB = (vB.tc.v - vA.tc.v) * onedy; // runs from A to B ... float xAB = vA.wc.x + yPreStep * sxAB; // in x / w dimension float zAB = vA.wc.z + yPreStep * szAB; // in z / w dimension float wAB = vA.wc.w + yPreStep * swAB; // in 1 / w dimension float uAB = vA.tc.u + yPreStep * suAB; // in u / w dimension float vAB = vA.tc.v + yPreStep * svAB; // in v / w dimension for (; y