1 |
c5369f1b
|
leszek
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
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 |
af4cc5db
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
23 |
|
|
|
24 |
226144d0
|
leszek
|
abstract class DistortedSurface extends DistortedObject
|
25 |
|
|
{
|
26 |
c7da4e65
|
leszek
|
int mColorCreated;
|
27 |
af4cc5db
|
Leszek Koltunski
|
int[] mColorH = new int[1];
|
28 |
6e7c8721
|
Leszek Koltunski
|
int mWidth, mHeight;
|
29 |
af4cc5db
|
Leszek Koltunski
|
|
30 |
af27df87
|
leszek
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
31 |
|
|
|
32 |
09ab7524
|
Leszek Koltunski
|
DistortedSurface(int width, int height, int create, int type)
|
33 |
af4cc5db
|
Leszek Koltunski
|
{
|
34 |
226144d0
|
leszek
|
super(create,type);
|
35 |
|
|
|
36 |
6e7c8721
|
Leszek Koltunski
|
mWidth = width ;
|
37 |
|
|
mHeight = height;
|
38 |
c7da4e65
|
leszek
|
mColorCreated = create;
|
39 |
|
|
mColorH[0] = 0;
|
40 |
af4cc5db
|
Leszek Koltunski
|
}
|
41 |
|
|
|
42 |
f28fffc2
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
43 |
226144d0
|
leszek
|
// debugging only
|
44 |
f28fffc2
|
Leszek Koltunski
|
|
45 |
226144d0
|
leszek
|
String printDetails()
|
46 |
f28fffc2
|
Leszek Koltunski
|
{
|
47 |
226144d0
|
leszek
|
return getClass().getSimpleName()+" "+mWidth+"x"+mHeight;
|
48 |
f28fffc2
|
Leszek Koltunski
|
}
|
49 |
|
|
|
50 |
af4cc5db
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
51 |
|
|
// PUBLIC API
|
52 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
53 |
c5369f1b
|
leszek
|
/**
|
54 |
3a70bd6d
|
leszek
|
* Return the width of this Surface.
|
55 |
af4cc5db
|
Leszek Koltunski
|
*
|
56 |
3a70bd6d
|
leszek
|
* @return width of the Object, in pixels.
|
57 |
c5369f1b
|
leszek
|
*/
|
58 |
af4cc5db
|
Leszek Koltunski
|
public int getWidth()
|
59 |
|
|
{
|
60 |
6e7c8721
|
Leszek Koltunski
|
return mWidth;
|
61 |
af4cc5db
|
Leszek Koltunski
|
}
|
62 |
|
|
|
63 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
64 |
c5369f1b
|
leszek
|
/**
|
65 |
3a70bd6d
|
leszek
|
* Return the height of this Surface.
|
66 |
af4cc5db
|
Leszek Koltunski
|
*
|
67 |
3a70bd6d
|
leszek
|
* @return height of the Object, in pixels.
|
68 |
c5369f1b
|
leszek
|
*/
|
69 |
af4cc5db
|
Leszek Koltunski
|
public int getHeight()
|
70 |
|
|
{
|
71 |
6e7c8721
|
Leszek Koltunski
|
return mHeight;
|
72 |
af4cc5db
|
Leszek Koltunski
|
}
|
73 |
|
|
|
74 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
75 |
c5369f1b
|
leszek
|
/**
|
76 |
8d52a49c
|
Leszek Koltunski
|
* Return the depth of this Surface.
|
77 |
af4cc5db
|
Leszek Koltunski
|
* <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 |
c5369f1b
|
leszek
|
*/
|
84 |
af4cc5db
|
Leszek Koltunski
|
public int getDepth(MeshObject mesh)
|
85 |
|
|
{
|
86 |
6e7c8721
|
Leszek Koltunski
|
return mesh==null ? 0 : (int)(mWidth*mesh.zFactor);
|
87 |
af4cc5db
|
Leszek Koltunski
|
}
|
88 |
226144d0
|
leszek
|
}
|