Halaman

Tampilkan postingan dengan label OpenGL. Tampilkan semua postingan
Tampilkan postingan dengan label OpenGL. Tampilkan semua postingan

Selasa, 27 Maret 2012

3d: Rotations, Axes, Local Space, Parent Space, World Space

The biggest factor i need to overcome with 3d programming was the math-side of 3d programming, there are many terms, such as vector, matrix, gimbals, local space, world space, projections, quaternions, euclidean, eulers etc.. We need to understand those terms so that i could position my objects correctly

If you are like me, you will be thrilled to read this page : opengl transforms, great article, made me understand the concept of local space and the world space

If you work with 3dsmax, blender, autocad, lightwave, etc you will likely works with axes, you use this axes to translate, rotate, scale your models, even per-element base(vertices, faces, polygons, edges).

There is a concept which helps me a lot to program transformation, and that is the local axes, the forward, up, and left axes which is locally for our object. If you put your matrix data using OpenGL conventions (column major) and you save your transformation to your object, then the elements :

  • local-x (default 1,0,0) would be (m0, m1, m2) 
  • local-y (default 0,1,0) would be (m4, m5, m6)
  • local-z (default 0,0,1) would be (m8, m9, m10)
  • and your object translation would be (m12, m13, m14)

But remember this matrix represents your modelview (that is your model matrix * view matrix)
okayh, now, what is this model matrix, and view matrix?

Kamis, 05 Mei 2011

Alpha channel di SDL dan OpenGL

Ini suatu trick yang penting namun sering dilupakan, misalkan kamu pengen menduplikasi SDL_Surface dan preserve alpha channel nya sebab hendak digunakan fungsi alpha blending OpenGL, sebelum di SDL_BlitSurface sebaiknya matikan dulu alpha blending dari source nya dengan cara sebagai berikut :

SDL_SetAlpha(src, 0, src->format->alpha);

ini dilakukan supaya blitting dilakukan penuh (pixel information attached)

semoga membantu! :)