Quick question: Newbie and modelview-matrix..

Consider this pseudo-code (partly from python, you’ll get the idea, I think):


A44 = matrix([\
     [  0.96126169,   0.,           0.27563736,          0],\
     [  0.07597595,   0.96126169,  -0.26495963,          0],\
     [ -0.26495963,   0.27563736,   0.92402405,          0],\
     [  0,            0,            0,                   1])

glMultMatrixf(Anew)
// Drawing some stuff works ok
model = glGetDoublev(GL_MODELVIEW_MATRIX)
print "model = 
", model

// This prints the following out to screen:
//model = 
//[[ 1.  0.  0.  0.]
// [ 0.  1.  0.  0.]
// [ 0.  0.  1.  0.]
// [ 0.  0.  0.  1.]]
// But why is it still identity matrix, like it's unaffected by multiplication???

And then I have another problem:


A44 = matrix([\
     [  0.96126169,   0.,           0.27563736,          0],\
     [  0.07597595,   0.96126169,  -0.26495963,          0],\
     [ -0.26495963,   0.27563736,   0.92402405,          0],\
     [  0,            0,            0,                   1])
glLoadMatrixd(Anew)
// Trying to draw some new things - don't work - nothing happens!

// And once again, when I try to print out current modelview matrix, I get 4x4 identity - why???

In the last case, I suspect that the A44 matrix I’ve given isn’t precise enough and then I suspect that the matrix isn’t orthogonal - hence nothing is drawn. Is that guess correct (that I need more digits to A44) ???

You set values on A44, but pass Anew to the OpenGL functions.
Also, are you sure GL_MODELVIEW is the current matrix mode (set with glMatrixMode())?

[QUOTE=carsten neumann;1237025]You set values on A44, but pass Anew to the OpenGL functions.
Also, are you sure GL_MODELVIEW is the current matrix mode (set with glMatrixMode())?[/QUOTE]

Oh, damn… I’m sorry, I was too fast because actually A44 = Anew. Besides that, I just inserted " glMatrixMode(GL_MODELVIEW) " just before [LEFT]glLoadMatrixd(Anew) and still nothing happens…

My guess is that it will fail for sure, if I for instance define A44 with only 1 digit after the comma (because then the matrix is not orthogonal and I guess then it’ll not show anything?) ? Is this assumption correct? Maybe I should post some python code for you, however my impression is that most people here use C++… I hoped what I had already posted would suffice, however it’s good to know that you also feel this should work (so I know I’m not alone)… Maybe I made a stupid mistake somewhere. I hope more people will tell their opion… Thanks a lot for your suggesion, though I don’t think my problem is yet solved.

[/LEFT]

model = glGetDoublev(GL_MODELVIEW_MATRIX)

Firstly, what are you using doubles instead of floats?
Secondly, glGetFloatv and freinds take two arguments not one. The first is the enumerant, the second is a pointer.


procedure TMatrix44.GetModelViewMatrix(var result: TMatrix44);
begin
   glGetFloatv(GL_MODELVIEW_MATRIX, @result.M.glmatrixf[0]);
end;

Thanks a lot for a good answer. I gave up and thought nobody could help - still, my problem is unsolved.
About why using doubles vs. floats: Not 100% sure, but here it says that double is better than float:

http://3dengine.org/Avoid_glGetFloat_in_Python

I’m using python, so my syntax should be ok, at least that’s what I think. So in python, I guess there’s only one argument and then a matrix that is returned/popped back from the stack…

hmm. Maybe it’s my own mistake. Explaining a bit better, what I do (very simplified, removed a lot for simplicity):


glutDisplayFunc(display)


def display():
    global lightZeroPosition
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
    glLoadIdentity()
    gluLookAt(0,0,10,0,0,0,0,1,0)
    glCallList(1) # <<=========== display list, look into here...


    # light stuff    
    glutSwapBuffers()
    return

Display list number 1:


def setupDispList():
    # setup display list
    glNewList(1,GL_COMPILE)
    glPushMatrix()
    drawSomething() # <<<===== look into this function...
    cyl = gluNewQuadric()
    gluCylinder(cyl, 0.3, 0.3, 0.5, 12, 12)
    glPopMatrix()
    glEndList()


def drawSomething():
    glPushMatrix()
    
    # here I do my glLoadmatrixf (doesn't work) and/or glMultMatrixf(works)
    A44 = matrix([\
         [  0.96126169,   0.,           0.27563736,          0],\
         [  0.07597595,   0.96126169,  -0.26495963,          0],\
         [ -0.26495963,   0.27563736,   0.92402405,          0],\
         [  0,            0,            0,                   1])

    if 1:
        glLoadMatrixf(A44) # doesn't work
    else:
        glMultMatrixf(Anew) # does work


    gluCylinder(arrcyl, 0.3, 0.0, 1.0, 6, 6) # not draw with loadmatrixf, only with multmatrixf
    glutPostRedisplay()

    glPopMatrix()

I think I would’ve been better off, it I had shown this from the beginning (thanks, laziness)…