1 /*
2 * Copyright (C) 2012 Alberto Irurueta Carro (alberto@irurueta.com)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package com.irurueta.geometry.io;
17
18 import com.irurueta.geometry.Point3D;
19
20 /**
21 * This class defines the structure that contains data for a single vertex in
22 * an OBJ file.
23 */
24 public class VertexOBJ {
25
26 /**
27 * Contains coordinates of 3D point.
28 */
29 private Point3D vertex;
30
31 /**
32 * Index of vertex in OBJ file.
33 */
34 private int vertexIndex;
35
36 /**
37 * Index of normal corresponding to this vertex in OBJ file.
38 */
39 private int normalIndex;
40
41 /**
42 * Index of texture assigned to this vertex in OBJ file.
43 */
44 private int textureIndex;
45
46
47 /**
48 * Constructor.
49 */
50 public VertexOBJ() {
51 vertex = null;
52 vertexIndex = normalIndex = textureIndex = -1;
53 }
54
55 /**
56 * Returns coordinates of 3D point.
57 *
58 * @return coordinates of 3D point.
59 */
60 public Point3D getVertex() {
61 return vertex;
62 }
63
64 /**
65 * Sets coordinates of 3D point.
66 *
67 * @param vertex coordinates of 3D point.
68 */
69 public void setVertex(final Point3D vertex) {
70 this.vertex = vertex;
71 }
72
73 /**
74 * Indicates whether 3D point has been provided or not.
75 *
76 * @return true if 3D point is available, false otherwise.
77 */
78 public boolean isVertexAvailable() {
79 return vertex != null;
80 }
81
82 /**
83 * Returns index of vertex in OBJ file.
84 *
85 * @return index of vertex in OBJ file.
86 */
87 public int getVertexIndex() {
88 return vertexIndex;
89 }
90
91 /**
92 * Sets index of vertex in OBJ file.
93 *
94 * @param vertexIndex index of vertex in OBJ file.
95 */
96 public void setVertexIndex(final int vertexIndex) {
97 this.vertexIndex = vertexIndex;
98 }
99
100 /**
101 * Indicates whether vertex index has been provided or not.
102 *
103 * @return true if vertex index is available, false otherwise.
104 */
105 public boolean isVertexIndexAvailable() {
106 return vertexIndex >= 0;
107 }
108
109 /**
110 * Returns index of normal corresponding to this vertex in OBJ file.
111 *
112 * @return index of normal corresponding to this vertex in OBJ file.
113 */
114 public int getNormalIndex() {
115 return normalIndex;
116 }
117
118 /**
119 * Sets index of normal corresponding to this vertex in OBJ file.
120 *
121 * @param normalIndex index of normal corresponding to this vertex in OBJ
122 * file.
123 */
124 public void setNormalIndex(final int normalIndex) {
125 this.normalIndex = normalIndex;
126 }
127
128 /**
129 * Indicates whether normal index has been provided or not.
130 *
131 * @return true if normal index is available, false otherwise.
132 */
133 public boolean isNormalIndexAvailable() {
134 return normalIndex >= 0;
135 }
136
137 /**
138 * Returns index of texture assigned to this vertex in OBJ file.
139 *
140 * @return index of texture assigned to this vertex in OBJ file.
141 */
142 public int getTextureIndex() {
143 return textureIndex;
144 }
145
146 /**
147 * Sets index of texture assigned to this vertex in OBJ file.
148 *
149 * @param textureIndex index of texture assigned to this vertex in OBJ file.
150 */
151 public void setTextureIndex(final int textureIndex) {
152 this.textureIndex = textureIndex;
153 }
154
155 /**
156 * Indicates if texture assigned to this vertex is available or not
157 *
158 * @return true if available, false otherwise.
159 */
160 public boolean isTextureIndexAvailable() {
161 return textureIndex >= 0;
162 }
163 }