Project

General

Profile

Download (3.83 KB) Statistics
| Branch: | Revision:

library / src / main / java / org / distorted / library / main / DistortedSurface.java @ c41d046c

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2016 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Distorted.                                                               //
5
//                                                                                               //
6
// Distorted is free software: you can redistribute it and/or modify                             //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Distorted 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                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

    
20
package org.distorted.library.main;
21

    
22
///////////////////////////////////////////////////////////////////////////////////////////////////
23

    
24
abstract class DistortedSurface extends DistortedObject
25
{
26
  int mColorCreated;
27
  int mNumColors;
28
  int[] mColorH;
29
  int mWidth, mHeight;
30

    
31
///////////////////////////////////////////////////////////////////////////////////////////////////
32

    
33
  DistortedSurface(int width, int height, int create, int numcolors, int type)
34
    {
35
    super(create,type);
36

    
37
    mNumColors    = numcolors;
38
    mWidth        = width ;
39
    mHeight       = height;
40
    mColorCreated = create;
41

    
42
    if( mNumColors>0 )
43
      {
44
      mColorH = new int[mNumColors];
45
      for( int i=0; i<mNumColors; i++ )  mColorH[i] = 0;
46
      }
47
    }
48

    
49
///////////////////////////////////////////////////////////////////////////////////////////////////
50
// debugging only
51

    
52
  String printDetails()
53
    {
54
    return getClass().getSimpleName()+" "+mWidth+"x"+mHeight;
55
    }
56

    
57
///////////////////////////////////////////////////////////////////////////////////////////////////
58
// PUBLIC API
59
///////////////////////////////////////////////////////////////////////////////////////////////////
60
/**
61
 * Return the width of this Surface.
62
 *
63
 * @return width of the Object, in pixels.
64
 */
65
  public int getWidth()
66
    {
67
    return mWidth;
68
    }
69

    
70
///////////////////////////////////////////////////////////////////////////////////////////////////
71
/**
72
 * Return the height of this Surface.
73
 *
74
 * @return height of the Object, in pixels.
75
 */
76
  public int getHeight()
77
    {
78
    return mHeight;
79
    }
80

    
81
///////////////////////////////////////////////////////////////////////////////////////////////////
82
/**
83
 * Return the depth of this Surface.
84
 * <p>
85
 * Admittedly quite a strange method. Why do we need to pass a Mesh to it? Because one cannot determine
86
 * 'depth' of a Surface (bitmap really!) when rendered based only on the texture itself, that depends
87
 * on the Mesh it is rendered with.
88
 *
89
 * @return depth of the Object, in pixels.
90
 */
91
  public int getDepth(MeshObject mesh)
92
    {
93
    return mesh==null ? 0 : (int)(mWidth*mesh.zFactor);
94
    }
95
}
(11-11/21)