android - Wrap OpenGL Matrix translation -


let's have opengl 4x4 matrix use transformation, inside call use "translate" many times then, @ end, want "wrap" translation around specific size, so, in 2d terms, let's translate x 210, want wrap translation "50 width" box, resulting in translation of 10 (210 % 50).

since need convert coordinates screen pixels init matrix in way:

private float[] mscreenmatrix = {         2f / width, 0f, 0f, 0f,         0f, -2f / height, 0f, 0f,         0f, 0f, 0f, 0f,         -1f, 1f, 0f, 1f }; 

so, if width "50" , call matrix.translatem(210,0,0) how can "wrap" matrix final translation on x 10?

you can't (without doing work) because wrap introduces modulo arithmetic (or toroidal topology) doesn't match way opengl's ndc space (which translate volume can see in window) laid out. when primitive reaches out of ndc space gets clipped remains within ndc space.

so in order toroidal topology have duplicate primitives clipped ndc , reintroduce them appear opposite end of ndc. ways either explicit submission of geometry or using geometry shader create such geometry in-situ.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -