Project

General

Profile

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

library / src / main / java / org / distorted / library / DistortedSurface.java @ 226144d0

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;
21

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

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

    
30
///////////////////////////////////////////////////////////////////////////////////////////////////
31

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

    
36
    mWidth        = width ;
37
    mHeight       = height;
38
    mColorCreated = create;
39
    mColorH[0]    = 0;
40
    }
41

    
42
///////////////////////////////////////////////////////////////////////////////////////////////////
43
// debugging only
44

    
45
  String printDetails()
46
    {
47
    return getClass().getSimpleName()+" "+mWidth+"x"+mHeight;
48
    }
49

    
50
///////////////////////////////////////////////////////////////////////////////////////////////////
51
// PUBLIC API
52
///////////////////////////////////////////////////////////////////////////////////////////////////
53
/**
54
 * Return the width of this Surface.
55
 *
56
 * @return width of the Object, in pixels.
57
 */
58
  public int getWidth()
59
    {
60
    return mWidth;
61
    }
62

    
63
///////////////////////////////////////////////////////////////////////////////////////////////////
64
/**
65
 * Return the height of this Surface.
66
 *
67
 * @return height of the Object, in pixels.
68
 */
69
  public int getHeight()
70
    {
71
    return mHeight;
72
    }
73

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