Beruflich Dokumente
Kultur Dokumente
Tablet PC
A Thesis
Presented to
the Faculty of the College of Computer Studies
De La Salle University Manila
In Partial Fulfillment
of the Requirements for the Degree of
Bachelor of Science in Computer Science
by
This research project tackles 3D modeling for Android tablet PCs with a fo-
cus on parametric curves and surfaces, and as well as implement a proper user
interface for curve and surface manipulation. This research extends the features
implemented in Gesture based 3D mesh modeling(Carlos, Jr., Sanchez, & To-
lentino, 2012) to parametric curves - specifically Bezier, B-Spline, NURBS and
Subdivision Curves - and as well as to parametric surfaces - specifically Bezier,
B-Spline, NURBS and Subdivision Surfaces. The tools that will be used for this
research are OpenGL ES 2.0 (Khronos Group, 2015) and Android Studio. The
software and prototypes will be tested on 8” to 10” sized Android tablets.
1 Research Description 1
2.2.2 OpenGL ES . . . . . . . . . . . . . . . . . . . . . . . . . . 12
ii
3 Theoretical Framework 15
3.1 Curves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.2 Surfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.4.1 Polygon . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
iii
A OpenGL ES 2.0 Draw Requirements 35
References 39
iv
List of Figures
3.1 A line segment that starts with P0 , ends with P1 , and interpolated
by P(t) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
v
List of Tables
vi
Chapter 1
Research Description
This chapter gives an overview of the topic. A short introduction, the scope and
objectives, and the methodology is found in this chapter.
Along with the computer and computer graphics, the mobile phone also has its
share of evolution. In its earlier stages, the only popular function of mobile phones
are for calling and sending text messages. Today, in the smartphone era, the phone
is not only expected as a medium for communication, but for learning, earning as
well as for gaming and recreation made possible using mobile applications.
1
accordingly. While the model is limited to what the user can make-up from a
sphere, this application offers more advanced tools such as extrusion/intrusion,
subdivision, split, and etc. on top of the basic 3D transformation. Lastly, Qubism
(Quinn, 2016) offers 3D modeling by combining together and modifying cubes.
This application offers basic 3D modeling transformation to a single or a set of
cubes as well as transformation of a selected cube to a predefined shape.
• Bezier Curves
• Curve Extrusion
• Subdivision Surfaces
Carlos et al. (2012), a BSCS undergraduate research project, has already im-
plented a 3D modeling application that provides basic functionalities for creation/-
modification/deletion of vertices. This thesis is an extension of their research to
parametric curves and surfaces. While the applications mentioned previously
provides a functionality for pre-defined curved meshes, the product application of
this research project will primarily be focused on parametric curves and surface
modeling.
2
1.2.2 Specific Objectives
Parametric curves and surfaces to be reviewed are limited to the following specifics:
Curves Surfaces
• Bezier Curve • Bezier Surface
• B-Splines / NURBS Curve • B-Splines / NURBS Surface
• Subdivision Curve • Subdivision Surface
While the topic of this thesis is focused on curves and surfaces, 3D modeling for
mobile applications (consisting of mobile phone and tablet applications) in general
is considered for surveying. This is for comparing and obtaining a baseline on the
functionalities and user interface implemented on these mobile applications.
Only OpenGL ES 2.0 (Khronos Group, 2015) and its dependencies as well
as Android Studio will be studied. These said dependencies consists of function-
s/methods of previous OpenGL versions that are also implemented in OpenGL
ES 2.0 (Khronos Group, 2015); and are considered only because of poor docu-
mentation on OpenGL ES 2.0 (Khronos Group, 2015). Also, OpenGL aspects are
limited to the basic functionalities for manipulating vertices, edges and basic col-
oring/shading. These said aspects include the following dependencies: OpenGL
matrices, essential/basic pipeline programming (needed only for OpenGL ES 2.0),
renderers, camera and perspectives.
Functionalities of the system consists of, but not limited to, the curves and
surfaces reviewed. Along with this, implementation of a data structure or a pack-
age that could abstract the requirements and practices of these said tools from
the requirements of the system is also considered. Additional implementations
3
include: winged-edge data structure (Baumgart, 1972), basic 3D modeling trans-
formations, saving, loading and exporting of data, and a workable user interface
for 3D modeling.
This research also gives as much importance to the usability of the imple-
mented application. Therefore, a survey on the usability and first use ease of the
prototypes and final product will be conducted to determine its standing on the
mentioned matters. The survey will consist of various users testing the application
through completing a single or a series of simple modeling tasks. Modeling task
will vary from modeling a simple cube to modeling certain objects/animals. Test
users will vary from students, hobbyist and a seasoned 3D modeler.
This research project adds some curves and surface functionalities to its predeces-
sor, Carlos et al. (2012)’s Gesture Based 3D Mesh Modeling.
There are very few 3D modeling applications available for mobile devices and
even fewer 3D modeling applications that support curves and surfaces. The prod-
uct application of this research project, upon extension, could lead to even more
detailed and complex 3D modeling for mobile devices compared to the gamified
or recreational 3D modeling applications that are currently being offered.
The final software could also be potentially deployed to Google’s Playstore for
various users to benefit from; as well as made available on Github for possible
further extension from interested parties.
The steps and activities that have been and will be performed to accomplish the
objectives are the following:
4
• Consultation and Finalization of Functionalities
This step is the very first and the core and foundation of the research. The
step is basically understanding the technicalities of the thesis as well as drawing
inspiration for the final product.
Carlos et al. (2012)’s Gesture Based 3D Mesh Modeling has been used as the
starting point for references and sub-topics to be reviewed. These references/sub-
topcs consisted of the following: sketch-based 3D modeling, the vertex-vertex
data structure, winged-edged data structure, and their system - Point: A Gesture
Based 3D Modeling tool.
Other subjects that will be reviewed are NURBS, Subdivision Curve, B-Spline
Surface and NURBS Surface.
The initial prototype was made to familiarize with OpenGL and the Android
platform. Due to the technical difficulty of OpenGL ES 2.0 (Khronos Group,
5
2015), this step took longer than the others. The length of the time on which
to learn OpenGL was the reason for a system design that abstracts or wraps, as
much as possible, all the OpenGL calls to a set of classes for easier reference.
The initial prototype is also the deliverable for the THSST-1 Software Proto-
type. This step applies the knowledge gained from the previous step, Review of
Related Works.
The initial system design covers the class structure, data structure to use for
3D data (Winged-Edged Data Structure (Baumgart, 1972)) and implementation
of Bezier Curves and Subdivision Surfaces; however, with limitations in basic 3D
modeling transformations, proper gestures and a proper user interface.
The previous steps, Review of Related Works and Initial System Design and Pro-
totyping, are steps to grasp an idea or inspiration to this thesis’ final application
deliverable. The target implemented 3D curves and surfaces (see Section 1.3) are
finalized in this step from a consultation with the adviser.
• User Interface
• User Actions (how could the user model, what can the user control or do)
• Application Assets
• Gestures supported
These aspects revolve on the usability and user appeal of the software and will
be finalized in THSST-2 along with the System Design Implementation step.
The Agile software development life cycle will be used for this thesis. This is the
cause of why some aspects of the target application enumerated in the previous
step, Consultation and Finalization of Functionalities, have intentionally not been
finalized.
6
This step is allotted for the whole of THSST-2. Several prototypes will be
submitted to the adviser and various testers, and modified accordingly based on
the said testers’ recommendations.
The actions that will be performed, each prototype and its specifications as
well as challenges/bugs and changes in the prototype will be recorded for docu-
mentation purposes. The source code will be uploaded to Github to keep track of
the time allotted for each prototype.
The final prototype of this step will be the deliverable for THSST-2
Alpha testing is done later in THSST-2 and the whole of THSST-3 by the proponent
of the thesis as well as the adviser and testers to catch any undetected bugs and
for quality assurance. The software in this step should be in at least a “nearly
fully-usable” state. Tests for this step is focused on the functionalities and a few
final modifications on user interface.
The Beta testing, also done in THSST-3, is done by potential users of the
mobile application such as students, recreational 3D modelers and other interested
parties. The application, in this step, should be in release state that could readily
be uploaded to Google’s Playstore. This step is aimed to get user feedback and
the first use ease of the mobile application.
Table 1.1 shows a Gantt chart of the activities. Each bullet represents approxi-
mately one week worth of activity.
7
Table 1.1: Timetable of Activities for 2016
Activities (2016) Jan Feb Mar Apr May Oct Nov Dec Jan Feb Mar Apr
Review of Related Works •• •• • ••••
Initial System Design and •••• ••
Prototyping
8
Consultation and Finaliza- • • • • • • •
tion of Functionalities
Software Development and • •••• •••• •••• •••• • • • •
Documentation
Alpha and Beta Testing •• •••• •••• • •
Documentation • •••• •• • • • •• • •• •• •
Chapter 2
This chapter discusses the features, capabilities, and limitations of existing re-
search, algorithms, or software that are related/similar to the thesis.
Sketch-based 3D Modeling
“Sketching is a natural way to communicate ideas quickly: with only a few pencil
strokes, complex shapes can be evoked in viewers” - this is how Olsen, Samavati,
Sousa, and Jorge (2009) started their paper. It was followed by a statement
pointing out that the creation of 3D models is often slowed down by complex
3D modeling systems because of its high learning curve. The goal, then, of the
Sketch-Based Interface for Modeling (SBIM) research is to combine both the ex-
presomsive power and control of WIMP-based systems and the expeditious and
natural interaction of sketching. Although this kind of interface has gained re-
search interest, it has not yet been able to replace industry systems because it
lacks the functionalities that a full-featured WIMP-based 3D modeling software
would have.
9
Figure 2.1: A brochure for Gesture Based 3D Modeling (Carlos et al., 2012)
10
• Save Geometry • Delete Geometry
• Load Geometry
Their system functions are focused, but without limitation, on basic modeling
transformations (translation, scaling and rotation). Carlos et al. (2012), however,
did not include textures, lighting and shaders in their scope.
For development, Carlos et al. (2012) have used the Android SDK tools as well
as OpenGL ES 1.0. Their mobile application was tested on two Samsung GT-1000
Android tables and an Asus Eeepad Transformaer Android tablet although there
was no mention on the OS version of Android it was tested on. It has also been
tested and expected to be used by those who have little or no background in 3D
modeling.
Figure 2.2: Screenshots of 3D Creationist, Subdiv Former and Qubism from left
to right.
11
There already exists several 3D modeling mobile applications on Google’s Play-
store. A few notable applications, as earlier mentioned, are 3D Creationist (3D
Creationist, 2016), Subdiv Former (ASCON, 2016) and Qubism (Quinn, 2016).
These applications are notable for this research project because of their similarity
to Point Modeler 2.0 in functionality and in user interface. Table 2.1 shows the
similarity of the 3 applications, Point (Carlos et al., 2012) and Point Modeler 2.0.
• 3D Creationist (3D Creationist, 2016)’s grid plane that the camera’s Look
At is set to. This grid is set as the platform of the model as well as not to
confuse the camera orientation.
2.2.2 OpenGL ES
OpenGL ES (Khronos Group, 2015) is a subset from the larger OpenGL 2.0 API
discussed above and is optimized for resource constrained display devices such as
smartphones, tablets and gaming consoles. As of October 2012, more than 90%
of Android devices were already running OpenGL ES 2.0 (Mehta, 2013) while
well known companies such as Apple, Inc., NVIDIA Corporation, Intel, Pana-
sonic, Sony Computer Entertainment, Google, Inc., AMD, Samsung Electronics,
and many more (Khronos Group, 2015) have made use of OpenGL ES for their
products at no cost in license fees.
12
Table 2.1: Operations available on the sample 3D modeling applications
Mobile Applications
Operations/Features 3D Creationist SubDiv Former Qubism Point Point Modeler 2.0
Basic Transformations (Translate, Rotate, Scale) • • • • •
Extrude/Intrude •
Split • •
Add Initial Meshes • • •
13
Colors/Shading • • •
Subdivision • •
Camera Manipulation • • • • •
Edit Tools (Create/Delete/Undo/Redo) • • • • •
Multiple Selection • • • • •
Selection Tools (Duplicate/Copy/Paste) • • •
Save/Load • • • •
Export •
Table 2.2: Programmable Graphic-Rendering API vs. Fixed-Function Graphic-
Rendering API
Property Fixed-Function Pipeline Programmable Pipeline
Other names Fixed-Function Graphic- Programmable Graphic-
Rendering API Rendering API
OpenGL ES re- 1.0 2.0
lease
Rendering func- Hard-coded and unmodifi- Programmable and flexible
tions and algo- able device-provided algo- rendering functions
rithm rithms
Access to under- Does not provide develop- Provides developers full ac-
lying hardware ers with access to underlying cess to underlying hardware
hardware through shaders
Graphics card Uses special purpose graph- Uses general purpose graph-
ics card ics card
Complexity Graphics hardware could be Slower than the fixed-
optimized for faster render- function pipeline; however,
ing offers more enhanced graph-
ics rendering
14
Chapter 3
Theoretical Framework
This chapter discusses the topics that are to be reviewed upon as mentioned in
Section 1.2.2. The topics discussed are as shown in (Farin, 1996).
3.1 Curves
Figure 3.1: A line segment that starts with P0 , ends with P1 , and interpolated by
P(t)
Let P0 be a point starting a line segment; P1 , a point ending the line segment;
and P(t), a point along the line segment such that 0 ≤ t ≤ 1 (Refer to Figure 3.1
for an illustration of this line segment).
t−0 P(t) − P0
= (3.1)
1−t P1 − P(t)
15
We manipulate Equation 3.1 to isolate P(t) on the left hand side to yield:
The resulting formula in Equation 3.2 is called the Linear Interpolation Equa-
tion. This states that given P0 , P1 and a value for t, we could compute for P(t) -
a point interpolating the given end points P0 and P1 .
Step 1 Interpolate the line segments connecting the control points: P0 and P1 ,
P1 and P2 . . . Pn and Pn+1
Step 2 Interpolate the line segments connecting the new points yielded from the
previous level of subdivision.
Step 3 Repeat Step 2 n − 2 times
Step 4 Repeat from Step 1 for the different values of t as seen in Figure 3.2
Figure 3.2: The 3rd level of subdivision for different values for t
The result of the interpolations made from the line segments are denoted as
Pab where a denotes the level of subdivision and b denotes the subscript of the
starting point of the line segment being interpolated. The point yielded from the
last level of subdivision Pn0 is the value of Pn (t)
16
Example: Cubic Bezier Curves
To further explain Bezier Curves, we will use Cubic Bezier Curves of degree 3 and
4 control points P0 , P1 , P2 and P3 .
Figure 3.3: The 3 levels of subdivision of a Cubic Bezier Curve where t = 0.5
1st Level of Subdivision Given the control points and a value for t, we first
interpolate the line segments connecting the control points. This yields
new points P10 from the line segment connecting P0 and P1 , P11 from the
line segment connecting P1 and P2 , and finally P12 from the line segment
connecting P2 and P3 .
Applying the Linear Interpolation Equation in Equation 3.2, we get the
following:
17
3rd Level of Subdivision Finally, we interpolate the line segment connecting
P20 and P21 to get P30 .
Applying the Linear Interpolation Equation in Equation 3.2, we get the
following:
Because this is the last level of subdivision for Cubic Bezier Curves, P(t)
gets the value of P30 .
Substituting the values from Equations 3.3 to 3.9, we get the following final
equation of P(t) relative to P0 , P1 , P2 and P3 .
The algorithm above is called the de Casteljau Algorithm. The previously de-
scribed repeated interpolation step is generalized in this algorithm for an arbitrary
degree n as follows:
Set:
r=1,. . . ,n
Pri = (1 − t)Pr−1
i (t) + tPr−1
i+1 (t) (3.11)
i = 0 , . . . , n-r
and
P0i (t) = Pi
Pn0 (t) = Pn (t)
Generalizing the equation in (3.10), the point on the Bezier Curve Pn (t) is ex-
pressed as:
18
n
X
n
P (t) = Pn0 = Pj Bjn (t) (3.12)
j=0
n j
Bjn (t) = t (1 − t)n−j (3.13)
j
Figure 3.4: A cubic B-spline curve with 7 control points (D0 to D6 ), 4 Bezier curve
segments, and 11 knots (u0 to u10 ) (Farin, 1996)
The knots in the B-spline curve could change the parametric segments longer
or shorter. Knot vectors which have equal distances between each knots are called
uniform; conversely, non equal distances between each knots are otherwise called
19
non-uniform. The example in Figure 3.4 is an example of a non-uniform B-spline
curve.
Given:
• A degree m
• n control points (D0 , D1 , ..., Dn−1 )
• The knot vector (u0 , u1 , ..., un+m )
1 if ui ≤ u < ui+1
Ni,0 (u) =
0 otherwise
u − ui ui+j+1 − u
Ni,j (u) = Ni,j−1 + Ni+1,j−1 (3.16)
ui+j − ui ui+j+1 − ui+1
and j = 1, 2, ..., m
Pn−1
m i=0 wi Di Ni,m (u)
C (u) = P n−1 (3.17)
i=0 wi Ni,m (u)
20
3.2 Surfaces
Catmull and Clark (1978)’s algorithm for the subdivision surface requires the
computation of the following:
21
• Face Points. For every face of the mesh, a new face point is created. A face
point is defined as the average of all the vertices making up the face.
Referring to the sample patch in Figure 3.6, face point Q11 is defined as
follows:
P11 + P12 + P21 + P22
Q11 = (3.18)
4
• Edge Points. For every edge of the mesh, a new edge point is created. An
edge point is defined as the average of the midpoint of the old edge with the
average of the two new face points neighboring the edge.
Referring to the sample patch in Figure 3.6, edge point Q12 is defined as
follows:
• Vertex Points. For every vertex of the mesh, a new vertex point is created.
a vertex point is defined as follows:
Q 2R S(n − 3)
+ + (3.20)
n n n
where
Q = the average of the new face points of all faces adjacent to the old vertex
point.
R = the average of the midpoints of all edges incident on the old vertex
point.
S = the old vertex point
n = the total number of faces touching the old vertex point
Referring to the sample patch in Figure 3.6, vertex point Q22 is defined as
follows:
Q R P22
Q22 = + + (3.21)
4 2 4
where
Q11 + Q13 + Q31 + Q33
Q=
4
and
P22 +P12 P22 +P21 P22 +P32 P22 +P23
2
+ 2
+ 2
+ 2
R=
4
22
These new points will then be connected by the following rules:
• The new face points connect to the new edge points of the old edges defining
the old face.
• The new vertex points connect to the new edge points of the old edges
incident on the old vertex point.
• The edge
• Predecessor and successor edge when traversing the left face clockwise
• Predecessor and successor edge when traversing the right face clockwise
23
Table 3.1: The edge table entries for edge a in Figure 3.7
Edge Vertices Faces Left Traverse Right Traverse
Name Start End Left Right Pred Succ Pred Succ
a X Y 1 2 b d e c
3.4.1 Polygon
24
3.4.2 3D Modeling Transformations and Representations
x
y
P=
z
(3.22)
1
Translation
0
x 1 0 0 Tx x x + Tx
y 0 0 1 0 Ty
∗ y = y + Ty
0 = (3.24)
z 0 0 1 Tz z z + Tz
1 0 0 0 1 1 1
25
Scaling
Scaling transforms an object’s size. The scaling factors (Sx , Sy and Sz ) specifies
the rate of the scale where the values 0 < S < 1 means scaling down and values s <
1 means scaling up. This transformation could be expressed as P0 = S(Sx , Sy , Sx )∗
P
0
x Sx 0 0 0 x x ∗ Sx
y 0 0 Sy 0
∗ y = y ∗ Sy
0
0 = (3.25)
z 0 0 Sz 0 z z ∗ Sz
1 0 0 0 1 1 1
Rotation
26
Chapter 4
This chapter discusses about the target application of this thesis. The objectives
and scope, system architecture and functionalities of the application is discussed
in this chapter.
27
• To be able to save, load and export previous works/models
This system will use the winged-edge data structure (Baumgart, 1972) as de-
scribed in Section 3.3. This data structure is limited in storing data for vertices,
edges and faces only. The system is to display these data as a wireframe model.
Lighting and shading are not covered by the thesis and this system.
The creation, transformation and deletion of vertices, edges and faces is the
focus and main goal of this thesis’ predecessor - Gesture Based 3D Mesh Modeling
(Carlos et al., 2012). These functionalities are reimplemented in this system only
as a formality and should not be confused as one of Point Modeler 2.0 ’s main
functions. Thereof, there will be minimal discussion on these functionalities in
this thesis. The gestures and implementations previously used by Carlos et al. to
achieve these functions may also differ.
The specific curves, surfaces and subdivisions that this system will implement
were discussed in Section 1.3. Supported operations related to this functionality
are creation, deletion, transformation and setting the resolution of the curves,
surfaces or subdivisions. Section 4.5 discusses these operations in detail.
Saving and loading of the models are exclusive to this mobile application only.
Exporting of a model to obj format is also supported; however, the system will not
support any import functionalities of obj’s exported from external 3D modeling
applications such as Blender. Import functionality was excluded because of the
possibility of extra data / complications in the obj file from features that are not
supported by Point Modeler 2.0 . Saved models, however, could be loaded from
one device to another given that both devices are running the same build of Point
Modeler 2.0 .
The design discussed in this section conforms to the design of the prototype for
THSST-1. These designs are limited to the modules of Point Modeler 2.0 that
are related to OpenGL, drawing the geometries (basic polygons, curves, surfaces
and subdivisions), and a structure to accommodate the requirements of OpenGL
ES 2.0 (Khronos Group, 2015) along with the different complexities/algorithms
28
of the geometries.
3. File Module is responsible for all the file handling process of the applica-
tion. These includes the process for the following system functions: save,
load and export.
4. Data Structure Module is responsible for the data structure of the model.
This is further discussed on Section 4.4.1
29
Figure 4.2: A simple class diagram depicting some interactions of the
datastructure package of Point Modeler 2.0
The system uses the winged edge data structure to represent the 3D model (Refer
to Section 3.3 for a discussion on this data structure). The class diagram in Figure
4.2 shows Point Modeler 2.0 ’s design for this data structure.
A WingedEdge class is responsible for the collection of all the Edges in the
model. It is initialized with an empty list of edges and is successively added edges
using the addEdge() method. This class is also responsible for extracting all the
MainVertices and Faces of the model through the attributes of the Edges as
they are added.
Point Modeler 2.0 implements a class structure to abstract all necessary OpenGL
calls into a few method calls. The diagram in Figure 4.3 shows these classes and
their main interactions with other classes.
30
Figure 4.3: A simple class diagram depicting some interactions of the drawables
package of Point Modeler 2.0
Before the discussion on the class diagram in Figure 4.3, it is first recommended
to know the basic requirements of OpenGL ES 2.0 to draw basic lines and vertices
found in Appendix A.
The reason for creating a class structure as that of the drawable package is to
abstract all necessary OpenGL calls into only a few method calls. This was
constructed mainly so that there will be no confusion between the geometries
being implemented (such as basic polygons, curves, surfaces and subdivisions)
and the requirements of OpenGL ES 2.0 (refer to Appendix A) to draw these
geometries.
1. The geometry could return a FloatBuffer of all its vertices including those
that are from interpolation.
2. The geometry could return a FloatBuffer of all its vertices excluding those
that are from interpolation.
3. The geometry specifies, in a ShortBuffer, which vertices in 1.) are inter-
connected
31
An abstract class Drawable was made to make sure that the enumerated rules
above are followed by the geometries. All geometries extend from the Drawable
class and are drawn by OpenGL using their inherited draw() function.
The class Drawer was made to encapsulate all the requirements and necessary
steps of OpenGL ES 2.0 to draw; this includes the shader codes and its compila-
tion, OpenGL ES program creation, and attributes binding. There is one instance
of Drawer for every Drawable. Whenever a Drawable needs to be drawn (such
that the Drawable’s draw() method was invoked), its Drawer gets all the nec-
essary Buffers from the Drawable and binds these Buffers to the OpenGL ES
program to be processed by the graphics card.
Main functions are those that are directly related to the topic of this thesis. This
is inclusive of all operations on curves, surfaces and subdivisions only.
Curves
Surfaces
32
• Addition of pre-defined Bezier and NURBS surfaces/patches to the model.
Subdivision Surfaces
• Subdivision iterations
Miscellaneous functions are those that are not explicitly related to the topic of
this thesis, however, are necessary for a proper or usable 3D modeling mobile
application.
Creation Tools
These tools allow the creation of vertices, edges, faces or predefined meshes.
Picking/Selection Tools
The user has the option to select the following:
• Vertices
33
• Faces
• Curves
• Surfaces
• Subdivisions
Multiple selection are supported by the system for vertices and faces only.
Camera/Viewing Tools
The system will support the following camera/viewing operations:
Saving/Loading Tools
This functionality allows the user to save and load a model. Additionally, the
user is also allowed to duplicate a saved model. Limitations on this functionality
could be found in Section 4.3.
Software The system is designed specifically for Android Tablet PCs. Develop-
ment tools used are Android Studio - the official IDE for Android Development -
and OpenGL ES 2.0 (note that OpenGL ES 2.0 already comes bundled with An-
droid Studio and is readily available for use with the IDE). Miscellaneous software
used in designing or modifying the application assets are Adobe Photoshop CS6
and Adobe Illustrator CS6. Github will also be used in the development phase
for a timestamp of when and how long the functionalities were being developed
through the commits made.
Hardware The hardware required to run the application is one that can support
OpenGL ES 2.0. The PC used for development is an Asus Transformer Book
T300LA. The tablet to be used for testing the application is a 10.5” Samsung
Galaxy Tab S.
34
Appendix A
The requirements identified in this section are exclusive for OpenGL ES 2.0 and
will differ from its previous version, OpenGL ES 1.0.
Point Modeller 2.0 only defines two shaders (or ”shader stage” as it is formally
referred to, and from now on will be referred to as such): the Vertex Shader and
the Fragment Shader. The code for these stages, which are in OpenGL Shading
Language (GLSL), specify the data, its datatype, and what to do with or opera-
tions on the data. Since Point Modeller 2.0 only defines 2 of these stages, only
these will be further discussed.
• A 4x4 matrix (mat4), uMVPMatrix, that will have the same values for each
vertex (uniform)
35
• A vector consisting of 4 values (vec4), aColor, that will have different values
per vertex (attribute)
The next and last stage that Point Modeler 2.0 defines is the Fragment Shader.
This stage handles the processing for the individual fragments of a model. Listing
A.2 shows an example of a Fragment Shader code.
Listing A.2: The Fragment Shader Code of Point Modeller 2.0
1 precision mediump f l o a t ;
2 varying vec4 vColor ; /∗ Gets t h e i n t e r p o l a t e d v a l u e o f
3 v C o l o r from t h e V e r t e x Shader Code ∗/
4
5 void main ( ) {
6 gl FragColor = vColor ; /∗ S e t s t h e f r a g m e n t
7 c o l o r ∗/
8 }
36
In openGL ES 2.0 for Java, these shader codes are most commonly specified
in a String variable. Point Modeler 2.0 defines these shaders as a String vari-
able, vertexShaderCode and fragmentShaderCode, of the Drawer class as seen
in Figure 4.3. These variables are then compiled as can be seen in Listing A.3 for
later use.
Listing A.3: A code snippet for shader code compilation in Java
1 // Create an empty s h a d e r code s p e c i f y i n g t h e t y p e o f
2 // s h a d e r as parameter
3 int v e r t e x S h a d e r = GLES20 . g l C r e a t e S h a d e r (
4 GLES20 .GL VERTEX SHADER ) ;
5 int fragmentShader = GLES20 . g l C r e a t e S h a d e r (
6 GLES20 .GL FRAGMENT SHADER) ;
7
8 // Attach t h e s h a d e r code s t o r e d i n v e r t e x S h a d e r C o d e and
9 // fragmentShaderCode t o t h e r e s p e c t i v e c r e a t e d s h a d e r s
10 GLES20 . g l S h a d e r S o u r c e ( v e r t e x S h a d e r , vertexShaderCode ) ;
11 GLES20 . g l S h a d e r S o u r c e ( fragmentShader , fragmentShaderCode ) ;
12
13 // Compile t h e s h a d e r s
14 GLES20 . glCompileShader ( v e r t e x S h a d e r ) ;
15 GLES20 . glCompileShader ( fragmentShader ) ;
OpenGL ES Program
The shader codes are processed by the system through an OpenGL ES program.
Similar to shader compilation previously discussed, OpenGL ES 2.0 also already
provides a functionality to be able to create an OpenGL ES program, attach the
specified shader codes to the said program, and link (or create an executable of)
the program to the system. These functionalities/process is described in Listing
A.4.
Listing A.4: A code snippet for OpenGL ES Program creation in Java
1 // Create empty OpenGL ES Program
2 mProgram = GLES20 . glCreateProgram ( ) ;
3
4 // Add t h e v e r t e x s h a d e r t o program
5 GLES20 . g l A t t a c h S h a d e r ( mProgram , v e r t e x S h a d e r ) ;
6
7 // Add t h e f r a g m e n t s h a d e r t o program
37
8 GLES20 . g l A t t a c h S h a d e r ( mProgram , fragmentShader ) ;
9
10 // C r e a t e s OpenGL ES program e x e c u t a b l e s
11 GLES20 . glLinkProgram ( mProgram ) ;
Attribute Buffers
After specifying and compiling the shader codes, creation of the OpenGL ES
program and attaching the shader codes to the program, all that is left for OpenGL
ES to be able to draw is to give values to the attributes specified in the shader
code. This is done in Java by binding the shader code attributes to a Buffer.
Listing A.5 shows a code snippet of binding the vPosition attribute of the Verted
Shader code to a Buffer named vertexBuffer.
Listing A.5: A code snippet for binding shader code attributes to Buffers in Java
1 // Get h a n d l e t o v e r t e x s h a d e r ’ s v P o s i t i o n member
2 mPositionHandle = GLES20 . g l G e t A t t r i b L o c a t i o n (
3 mProgram , // The program b e i n g used
4 ” vPosition ” ) ; // The name o f t h e a t t r i b u t e
5
6 GLES20 . g l V e r t e x A t t r i b P o i n t e r (
7 mPositionHandle ,
8 3, // S i z e (3 c o o r d i n a t e v a l u e s per v e r t e x )
9 GLES20 . GL FLOAT, // Datatype
10 false , // I s v a l u e s n o r m a l i z e d ?
11 3 ∗ 4, // S t r i d e (3 c o o r d i n a t e v a l u e s ∗ 4 b y t e s
12 // per v e r t e x )
13 vertexBuffer // B u f f e r
14 ) ;
38
References
39