News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

gluLookAt

Started by Farabi, August 28, 2005, 01:35:12 AM

Previous topic - Next topic

Farabi

How to use gluLookAt? Here is my last rotation code.


invoke glPushMatrix
invoke glTranslatef, CFLT(0.0), CFLT(0.0), CFLT(-5.0)


invoke glTranslatef, pos3_x, pos3_y, pos3_z
invoke glRotatef, RotX, CFLT(1.0), CFLT(0.0), CFLT(0.0)
invoke glRotatef, RotY, CFLT(0.0), CFLT(1.0), CFLT(0.0)
invoke glRotatef, RotZ, CFLT(0.0), CFLT(0.0), CFLT(1.0)


Should I remove this all code and replace is with a single code gluLookAt?
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

hitchhikr

No.

gluLookAt is used to define a viewpoint, like a camera. You can use it to move inside a scene, tho.

Farabi

Hai. I invoke gluLookAt but MASM32 show an error. It says it is too complex.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

hitchhikr


Farabi


; invoke gluLookAt,dword ptr[x_eye],dword ptr[x_eye+4],dword ptr[y_eye],dword ptr[y_eye+4],dword ptr[z_eye],dword ptr[z_eye+4],dword ptr[x_cntr],dword ptr[x_cntr+4],dword ptr[y_cntr],dword ptr[y_cntr+4],dword ptr[z_cntr],dword ptr[z_cntr+4],dword ptr[x_up],dword ptr[x_up+4],dword ptr[y_up],dword ptr[y_up+4],dword ptr[z_up],dword ptr[z_up+4]



I try to replace it with this


Push dword ptr[z_up+4]
Push dword ptr[z_up]
Push dword ptr[y_up+4]
Push dword ptr[y_up]
Push dword ptr[x_up+4]
Push dword ptr[x_up]
Push dword ptr[z_cntr+4]
Push dword ptr[z_cntr]
Push dword ptr[y_cntr+4]
Push dword ptr[y_cntr]
Push dword ptr[x_cntr+4]
Push dword ptr[x_cntr]
Push dword ptr[z_eye+4]
Push dword ptr[z_eye]
Push dword ptr[y_eye+4]
Push dword ptr[y_eye]
Push dword ptr[x_eye+4]
Push dword ptr[x_eye]
call gluLookAt


But the object is not appear. THis is the data I input.


x_eye dq 0.0
y_eye dq 0.0
z_eye dq -5.0

x_cntr dq 0.0
y_cntr dq 0.0
z_cntr dq 0.0

x_up dq 30.0
y_up dq 30.0
z_up dq 30.0
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

hitchhikr

Normally it should work provided that you don't modify the matrix afterwards.

Be sure that you save/restore the modelview matrix before/after using it (glPushMatrix/glPopMatrix) or that you reset it before (glLoadIdentity).

ninjarider

farabi,
  im not sure if ur code for gllookat works yet or not but i noticed something in ur variables.
i notice u have all of your x_up, y_up, z_up set to 30, which means the camera wouldn't be moving in the direction u want it to move. try using x_up = 0, and z_up = 0 and y_up = 1.

Farabi

Quote from: ninjarider on September 02, 2005, 12:32:11 PM
farabi,
  im not sure if ur code for gllookat works yet or not but i noticed something in ur variables.
i notice u have all of your x_up, y_up, z_up set to 30, which means the camera wouldn't be moving in the direction u want it to move. try using x_up = 0, and z_up = 0 and y_up = 1.

Hai. Yes it is working with your variable. Creating the camera is confusing and frank camera code is not easy to implement.
I found this on my research.


void orientMe(float ang) {

lx = sin(ang);
lz = -cos(ang);
glLoadIdentity();
gluLookAt(x, y, z,
      x + lx,y + ly,z + lz,
  0.0f,1.0f,0.0f);
}

void moveMeFlat(int direction) {
x = x + direction*(lx)*0.1;
z = z + direction*(lz)*0.1;
glLoadIdentity();
gluLookAt(x, y, z,
      x + lx,y + ly,z + lz,
  0.0f,1.0f,0.0f);
}



That is code for C++. It seems will work but translate it to MASM is not easy thing. Maybe you have any clue?
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

ninjarider

well i couldn't help u with the fpu functions. still havn't learned them. but maybe a better understanding of the gllookat function might help.
gllootat (x1, y1, z1, x2, y2, z2, x3, y3, z3)

x1 is the x loacation of the camera
y1 is the y
z1 is the z

x2 is the x coordinat the camera is looking at.
y2 is the y coord
z2 is the z coord

what u specify in the x2, y2, and z2 is what should be in the exact center or your window,

kinda hard to explain the x3, y3, z3. best i can think of is the camera tilt
if u were to have:
{x3, y3, z3} = {0,1,0} then the camera would be upright. any camera movement would move up
{x3, y3, z3} = {1,0,0} then the camera would be on its side. and camera movement would be to the right
{x3, y3, z3} = {0,-1,0} then the camera would be upside down. any camera movement would move down
{x3, y3, z3} = {-1,0,0} then the camera would be on its side again, but any camera movement would move the the left.

hopefully this will clean up any misunderstanding u have.

Farabi

Quote
x3, y3, z3} = {-1,0,0} then the camera would be on its side again, but any camera movement would move the the left.

To left if I add the x1?
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

MichaelW

Farabi,

I don't know anything about the gluLookAt function, but wouldn't it be easier to alter the prototype and just pass QWORDs in the invoke statement, like so:

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    include \masm32\include\masm32rt.inc

    gluLookAt PROTO \
     :QWORD,:QWORD,:QWORD,:QWORD,:QWORD,:QWORD,:QWORD,:QWORD,:QWORD

    includelib \masm32\lib\glu32.lib
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    .data
      eyex    DQ 0
      eyey    DQ 0
      eyez    DQ 0
      centerx DQ 0
      centery DQ 0
      centerz DQ 0
      upx     DQ 0
      upy     DQ 0
      upz     DQ 0
    .code
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
start:
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    invoke gluLookAt, eyex,
                      eyey,
                      eyez,
                      centerx,
                      centery,
                      centerz,
                      upx,
                      upy,
                      upz

    mov   eax, input(13,10,"Press enter to exit...")
    exit
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end start


00401000                    start:
00401000 FF3544304000           push    dword ptr [403044h]
00401006 FF3540304000           push    dword ptr [403040h]
0040100C FF353C304000           push    dword ptr [40303Ch]
00401012 FF3538304000           push    dword ptr [403038h]
00401018 FF3534304000           push    dword ptr [403034h]
0040101E FF3530304000           push    dword ptr [403030h]
00401024 FF352C304000           push    dword ptr [40302Ch]
0040102A FF3528304000           push    dword ptr [403028h]
00401030 FF3524304000           push    dword ptr [403024h]
00401036 FF3520304000           push    dword ptr [403020h]
0040103C FF351C304000           push    dword ptr [40301Ch]
00401042 FF3518304000           push    dword ptr [403018h]
00401048 FF3514304000           push    dword ptr [403014h]
0040104E FF3510304000           push    dword ptr [403010h]
00401054 FF350C304000           push    dword ptr [40300Ch]
0040105A FF3508304000           push    dword ptr [403008h]
00401060 FF3504304000           push    dword ptr [403004h]
00401066 FF3500304000           push    dword ptr [403000h]
0040106C E811010000             call    fn_00401182


eschew obfuscation

Farabi

MichaelW:
Thanks, I will try it, I hope the prototype will not give an error because there are a new prototype with a new name.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

ninjarider

i dont understand y the gllookat would be such a hard function for u to use. it took a while to get it to work right but if u go to the glnormal thread i have and run my program. u would first have to step back some.

arrow keys do left right forward backwards
mouse looks left right up down
a,z move up and down
<, > roll left and right

the coding is a little hard in assembly i can give u the psuedo for it if u want.

hitchhikr

I provided all necessary includes for the prototypes within the archive file.

Also, i'm a little bit busy with something right now but i'll be back very soon.

Farabi

Quote from: ninjarider on September 19, 2005, 06:53:56 PM
i dont understand y the gllookat would be such a hard function for u to use. it took a while to get it to work right but if u go to the glnormal thread i have and run my program. u would first have to step back some.

arrow keys do left right forward backwards
mouse looks left right up down
a,z move up and down
<, > roll left and right

the coding is a little hard in assembly i can give u the psuedo for it if u want.

Yes it is very difficult and I dont have time to try it. I dont see your attachment but I see the picture.
So If I want to rotate the camera and move I only need to change vertex 3 like this

Quote
{x3, y3, z3} = {0,1,0} then the camera would be upright. any camera movement would move up
{x3, y3, z3} = {1,0,0} then the camera would be on its side. and camera movement would be to the right
{x3, y3, z3} = {0,-1,0} then the camera would be upside down. any camera movement would move down
{x3, y3, z3} = {-1,0,0} then the camera would be on its side again, but any camera movement would move the the left.

and change the position right? I still dont get it. But if you like to share your code to do movement dan rotate camera, I will appreciate it.

Im too dumb for this.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"