Posts

Showing posts from February, 2019

Spherical Coordinates

Image
A spherical coordinate system is a coordinate system where the position of a point in 3D space is specified by three numbers: a radial distance r an azimuthal angle  θ ( theta ) a polar angle  φ ( phi ) Spherical coordinates comes in handy to implement an Arcball Camera . Imagine to have a virtual ball behind your screen, by clicking with your mouse you pinch the ball and by dragging the mouse you make the ball spin around its center. We can map the mouse x coordinates to be the θ angle and the mouse y coordinates to be the φ angle. We also assume that our virtual ball is a unit sphere so the radial distance is always 1. The problem is that we can specify the position of our camera only using cartesian coordinates so how do we convert spherical coordinates to cartesian coordinates? Polar Coordinates Polar coordinates are like spherical coordinates but in 2D.  We can specify the position of a point using two numbers: a radial distance r an

Android OpenGL ES 2.0 OBJ Loader with Lambert Shading

Image
For this experiment I've developed my own OBJ parser in Java which support parsing of vertex positions, normals, texture coordinates and indices to remove duplicated vertices before uploading them to the vertex buffer object. To test normals I've also implemented a simple lambert lighting system using OpenGL ES 2.0 GLSL shader language.