vpCurrentMatrix(3)

πŸ“¦ version 1.0c7, in fedora 43, fedora 44

πŸ’– vpCurrentMatrix(3) β€” choosing ur main character transformation matrix πŸ’–

okay bestie, welcome to vpCurrentMatrix(3) from the Library Functions Manual section of the VolPack world. this is the function that picks which transformation matrix is currently getting all the attention. sit down, hydrate, let's go ✨


🌸 NAME 🌸

vpCurrentMatrix β€” choose the current transformation matrix. that's it, that's the whole job, and she does it flawlessly πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <volpack.h>

vpResult
vpCurrentMatrix(vpc, option)
    vpContext *vpc;
    int option;

πŸ¦‹ ARGUMENTS πŸ¦‹

  • vpc β€” the VolPack context, and you get it from vpCreateContext. she's the whole vibe, the source of truth, ur ride or die 🫢
  • option β€” a code that says which one of the VolPack transformation matrices you want: VP_MODEL, VP_VIEW or VP_PROJECT. pick one, bestie, no takebacks (jk there are takebacks, just call the function again).

✨ DESCRIPTION ✨

so vpCurrentMatrix is literally the function you call to choose the current transformation matrix. the option parameter must be one of these three, no exceptions, don't try to be quirky:

  • VP_MODEL β€” modeling transformation 🌈
  • VP_VIEW β€” viewing transformation πŸ‘€
  • VP_PROJECT β€” projection transformation πŸ“½οΈ

after you call this, every subsequent call to the matrix transformation functions β€” that's vpIdentityMatrix, vpTranslate, vpRotate, vpScale, vpMultMatrix and vpSetMatrix β€” gets applied to the new current transformation matrix. not me rewiring the whole matrix pipeline with one call, iconic behavior fr fr πŸ’€


πŸ’œ the modeling transformation (VP_MODEL) πŸ’œ

typically this one is used to specify a transformation from object coordinates to world coordinates. in object coordinates, the volume data lives inside a unit cube centered at the origin, with corners at (-0.5, -0.5, -0.5) and (0.5, 0.5, 0.5). cozy little cube, love that for her 🧊

the default modeling transformation is the identity, so at the start the volume is just chilling inside the unit cube in world coordinates. and by default, the current matrix is VP_MODEL β€” she's the default main character, no cap πŸ‘‘

oh and heads up: the modeling transformation also gets applied to light direction vectors (peep vpSetLight(3) for that lore). ✨


πŸ‘€ the viewing transformation (VP_VIEW) πŸ‘€

this one transforms world coordinates into eye coordinates. in eye coordinates, the viewer is looking down the Z axis in the negative direction. the default value of this matrix is also the identity, so by default the viewer is looking down the Z axis in world coordinates too. symmetry, we love to see it πŸ¦‹

typically you use this matrix to specify the location and direction of the viewer β€” where you're standing and where you're looking, basically.

and lowkey the fun part: it's also possible to combine the modeling and viewing matrices (like in the OpenGL viewing model). if you do that, you can store the composite transformation in either the model or the view matrix, and set the other matrix to the identity. dealer's choice, bestie πŸ’…


πŸ“½οΈ the projection transformation (VP_PROJECT) πŸ“½οΈ

this one specifies the transformation from eye coordinates to clip coordinates. in the clip coordinate system, the entire viewing frustum lies inside a cube defined by the planes X=1, X=-1, Y=1, Y=-1, Z=1 and Z=-1. six planes, one cube, everything fits inside, periodt.

this transformation also specifies the type of projection used to produce a 2D image. the 2D image is computed by projecting along the Z axis in the clip coordinate system, and then scaling in the X and Y dimensions to the final image size.

and if you need help computing projection transformations? the routines vpWindow and vpWindowPHIGS are genuinely useful for that. they ate πŸ”₯


⭐ STATE VARIABLES ⭐

you can retrieve the current transformation matrix code with the following state variable codes (see vpGeti(3)): VP_CURRENT_MATRIX. yes bestie, you can always ask her what she's up to πŸ’–


πŸ’€ ERRORS πŸ’€

the normal return value is VP_OK. the following error return value is possible:

  • VPERROR_BAD_OPTION β€” the option argument is invalid. like, you passed something that isn't one of the three. she's not mad, she's just disappointed 😭

🌈 SEE ALSO 🌈

VolPack(3), vpCreateContext(3), vpGetMatrix(3)


ngl if you pass a bad option, VPERROR_BAD_OPTION is coming for you and it will find you. vibe check ur option before you call, bestie 🫢

that's the whole page, and she's a baddie. this one came straight from VolPack, and the page is vpCurrentMatrix(3) β€” go forth and transform ur coordinates, you absolute legend πŸ‘‘βœ¨πŸ’–

πŸ“¦ where this page comes from