Jump to content

  • Log In with Google      Sign In   
  • Create Account

NumberXaero

Member Since 29 Apr 2002
Offline Last Active Today, 06:49 PM

Posts I've Made

In Topic: How to find the center of a modelview matrix?

02 April 2016 - 07:27 PM

Imagine a stack of matrices, in this case the "model_view" matrix stack activated with a call to glMatrixMode()

<Top>
[matrix1]
[matrix0]
<bottom>
-----------

glPushMatrix() copies the matrix on the top, and then makes it the new top

<Top>
[matrix1copy]
[matrix1]
[matrix0]
<bottom>
-----------

this essentially saves matrix1 (any transforms youve done) and creates a copy, which you might then follow with a call that modifies the top matrix further, such as

glTranslate*() -> builds a translation matrix and multiplies it into the top of the current stack (the matrix 1 copy) further transforming matrix 1
glScale() -> same thing, but a scale matrix is multipled into top
glRotate()  -> same thing, but a rotation matrix it multipled into top
glLoadIdentity() -> clear top to identity
glMultMatrix() -> you provide the matrix already built

<Top>
[matrix1copy] *= Trans|Scale|Rot Matrix
[matrix1]
[matrix0]
<bottom>
-----------

now you draw, its use the top, then when you are done drawing, you call PopMatrix(), which removes the top and goes back to the original

<Top>
[matrix1]
[matrix0]
<bottom>
-----------

simple example, want to draw an object at 10 down +x, at 20 down +x, and 5 up +y

<Top>
[matrix0.identity]
<bottom>
-----------

PushMatrix()

<Top>
[matrix0.identity] <- glPushMatrix()
[matrix0.identity]
<bottom>
-----------

<Top>
[matrix0.(10, 0, 0)] <- PushMatrix(), *= glTranslate(10, 0, 0), now draws at 10 down x
[matrix0.identity]
<bottom>
-----------

<Top>
[matrix0.(20, 0, 0)] <- PushMatrix(), *= glTranslate(10, 0, 0), now draws at 20 down x
[matrix0.(10, 0, 0)]
[matrix0.identity] <- drawing now draws at origin
<bottom>
-----------

PopMatrix(), PopMatrix()

<Top>
[matrix0.identity] <- drawing now draws at origin
<bottom>
-----------

<Top>
[matrix0.(0, 5, 0)] <- PushMatrix(), *= glTranslate(0, 5, 0), now draws at 5 up y
[matrix0.identity]
<bottom>
-----------

thats the general idea anyway, think of pushmatrix as transform save point, a fork in the road you might want to come back to before applying more transforms.
Its the model view matrix because you generally put the view matrix (inverse of the cameras matrix) at the bottom (first) which brings an objects model matrix (world matrix)
into the cameras "view space". These are all old opengl calls, but the idea can still be important to understand.


In Topic: Recommendations for a Text Editor

27 January 2016 - 10:03 PM

Not sure if its what you need, https://code.visualstudio.com/

I use it for quick shader editing, it has highlighting and extensions, not sure about heavy plugins


In Topic: Resolving Creative Differences

17 January 2016 - 07:55 PM

https://www.youtube.com/watch?v=aD3xfT0c99g


In Topic: Question regarding game mechanics and dynamic allocation

17 October 2015 - 09:02 PM

You could also make the observation that your weapon likely has an ammo capacity, which you could pre-allocate at start up or creation time, and simply fire one out of the list placing it in a "used" or "fired" list of some sort and get a new one next time from the unused/loaded list. Once a used bullet dies, hitting an object or traveling too far, recycle it back into the unused list.

If you need infinite ammo, your weapon probably has a rate of fire, and the bullets probably have a max travel distance limit, you could again use this info to allocate the max bullets you might ever need, and just keep firing and recycling.

What you can do is sorta dependent on what youre making, but it could be as simple as pre allocating an array of bullets, and maintaining a fired/loaded link list of bullets where each bullet has a pointer to the next, where next is either fired or loaded depending on which list the bullet is in.


In Topic: Passing massive arrays of data as uniform texture

01 October 2015 - 03:12 PM

I suppose you could just not use texture filtering, use point sampling (nearest), dont mipmap, and make sure your texture coordinates (table lookup indices?) fall exactly on texel centers.


PARTNERS