Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/pqt/autorib/instr/InstrState.java


1   //AutoRIB
2   // Copyright © 1998 - 2002, P W Quint
3   //
4   // Contact: autorib00@aol.com
5   //
6   // This library is free software; you can redistribute it and/or
7   // modify it under the terms of the GNU General Public
8   // License as published by the Free Software Foundation; either
9   // version 2 of the License, or (at your option) any later version.
10  //
11  // This library is distributed in the hope that it will be useful,
12  // but WITHOUT ANY WARRANTY; without even the implied warranty of
13  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  // General Public License for more details.
15  //
16  // You should have received a copy of the GNU General Public
17  // License along with this library; if not, write to the Free Software
18  // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  
20  package org.pqt.autorib.instr;
21  import java.io.*;
22  import java.util.*;
23  
24  import org.pqt.autorib.tokenizer.*;
25  import org.pqt.autorib.globals.*;
26  import org.pqt.autorib.util.*;
27  
28  
29  /** A class for storing state information for an
30   * instructions file, such as map format and
31   * the current list of objects to omit from maps.
32   * State information is local to a block, and so
33   * is maintained by the InstrWReader as a stack of
34   * instances of InstrState
35   */
36  public class InstrState extends Object implements Cloneable {
37      /** the x size of the map to be generated */
38      public int mapFormatx = 1024;
39      /** the y size of the map to be generated */
40      public int mapFormaty = 1024;
41      //public float actualAspectRatio = 1;
42      /** if not -1 this specifies the map format as a proportion of the
43       * image format specified in the rib */
44      public float mapMult = - 1;
45      /** the default cone angle to use for calculating spotlight shadow maps*/
46      public double defaultConeAngle = 2 * Math.PI * 30.0 / 360.0;
47      /** the list of object names to be omitted from the map render */
48      public Vector omitNames = new Vector(5,5);
49      /** the filter to use in generating the map*/
50      public String mapFilter = "box";
51      /** filter width x */
52      public int mapFilterx = 1;
53      /** filter width y */
54      public int mapFiltery = 1;
55      /** number of samples to use in map generation */
56      public int mapSamplesx = 1;
57      /** the number of samples in the y direction
58       */
59      public int mapSamplesy = 1;
60      /** used in the Display rib call in generating the map*/
61      public String mapDisplayType = "rgb";
62      /** use this name, rather than the default map name, for the map
63       * if not blank*/
64      public String mapDisplayName = "";
65      
66      /** standard clone method
67       * @return a copy of this object
68       */
69      public Object clone() {
70          Object o = null;
71          try { o = super.clone(); }
72          catch (CloneNotSupportedException e)
73          {  }
74          InstrState is = (InstrState) o;
75          if (omitNames != null)
76              is.omitNames = (Vector) omitNames.clone();
77          return o;
78      }
79      
80      /** calculate the format leaving the result in mapFormatx, mapFormaty
81       *that is to say find the square map, whose dimensions are a power
82       *of two which is the smallest to be as large as the given
83       *dimensions. This is needed because for most Renderman renderers
84       *maps must be square, and have dimensions that are a factor of two
85       * @param x, y the dimensions of the RIB Format statement */
86      public void calcFormat(int x, int y) {
87          if (mapMult > 0) {
88              int max = x > y ? x : y;
89              float res = max * mapMult;
90              int i = 2;
91              while (i < res)
92                  i = i * 2;
93              mapFormatx = i;
94              mapFormaty = i;
95          }
96      }
97  }
98  
99  
100 
101