Author Topic: Flying around  (Read 465 times)

caballero

  • Member
  • ****
  • Posts: 743
    • Abre Ojos Ensamblador
Flying around
« on: August 05, 2017, 05:43:54 AM »
Hello. This is the first approach to flying around moving the mouse, left and right buttons pretenders to be for moving forward and backward, but don't work well yet :redface: Let's working on it.
En un lugar de la Mancha de cuyo nombre no quiero acordarme

HSE

  • Member
  • ****
  • Posts: 519
  • <AMD>< 7-32>
Re: Flying around
« Reply #1 on: August 05, 2017, 06:35:27 AM »
 :icon_eek: Very dark I think. 

caballero

  • Member
  • ****
  • Posts: 743
    • Abre Ojos Ensamblador
Re: Flying around
« Reply #2 on: August 05, 2017, 04:25:21 PM »
Yes, it's a simple example: two parallel planes of points and a camera. The objective is to move the camera.
En un lugar de la Mancha de cuyo nombre no quiero acordarme

HSE

  • Member
  • ****
  • Posts: 519
  • <AMD>< 7-32>
Re: Flying around
« Reply #3 on: August 06, 2017, 02:53:36 AM »
 :t We will expect final result. 

caballero

  • Member
  • ****
  • Posts: 743
    • Abre Ojos Ensamblador
Re: Flying around
« Reply #4 on: August 07, 2017, 02:15:27 AM »
Ahí estamos, Horacio :biggrin:

It's not full working well, but now you can move the camera forward with the left button of the mouse and backwards with the left one, and you can freely watching around moving de mouse. Something like if you fly between the two planes in one direction watching to anywhere.

Hopefully now it would be easy to make any demo moving also the camera.

Regards.
En un lugar de la Mancha de cuyo nombre no quiero acordarme

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 4639
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Flying around
« Reply #5 on: August 07, 2017, 02:07:49 PM »
Seems to work OK but it would be good if you could see the mouse cursor.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

caballero

  • Member
  • ****
  • Posts: 743
    • Abre Ojos Ensamblador
Re: Flying around
« Reply #6 on: August 07, 2017, 06:09:53 PM »
Thank you for testing, Hutch, the mouse is supposed to be hidden in a demo or in a game.
En un lugar de la Mancha de cuyo nombre no quiero acordarme

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 4639
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Flying around
« Reply #7 on: August 07, 2017, 06:57:15 PM »
Only hide it in the client area, it was hard to find the top right close button as you could not see the mouse cursor.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

caballero

  • Member
  • ****
  • Posts: 743
    • Abre Ojos Ensamblador
Re: Flying around
« Reply #8 on: August 07, 2017, 07:10:37 PM »
ESC key is always ready to exit my demos  :biggrin:

I didn't know that there's a method to hide the cursor only in the client area, if you know it, please, tell me or I'll have to look for it  :biggrin:

Maybe the evident way? Hiding it when it is over the client area and restoring it when is outside. Isn't there any other method? Nevertheless, the cursor is confined in the client area because we don't want to elapsed times when you can't controlled the demo.
En un lugar de la Mancha de cuyo nombre no quiero acordarme

jj2007

  • Member
  • *****
  • Posts: 7309
  • Assembler is fun ;-)
    • MasmBasic
Re: Flying around
« Reply #9 on: August 07, 2017, 08:21:35 PM »
I didn't know that there's a method to hide the cursor only in the client area, if you know it, please, tell me or I'll have to look for it  :biggrin:

WM_NCHITTEST and WM_SETCURSOR are your friends. Maybe GetClientRect, too.

caballero

  • Member
  • ****
  • Posts: 743
    • Abre Ojos Ensamblador
Re: Flying around
« Reply #10 on: August 07, 2017, 08:49:57 PM »
Maybe when we create the main class/window we can define no cursor, would be possible? I have to check it.

Nah, not possible, wndclass.hCursor = NULL; assumes the default one.
Using a transparent cursor would a tricky way to do it

Thank you
En un lugar de la Mancha de cuyo nombre no quiero acordarme

TWell

  • Member
  • ****
  • Posts: 749
Re: Flying around
« Reply #11 on: August 07, 2017, 09:56:51 PM »
Another way
Code: [Select]
BOOL bHideCursor;
...
case WM_MOUSEMOVE:
if (!bHideCursor) {
bHideCursor = 1;
ShowCursor(FALSE);
}
return 0;
case WM_NCMOUSEMOVE:
{
if (bHideCursor) {
bHideCursor = 0;
ShowCursor(TRUE);
}
return 0;
}

jj2007

  • Member
  • *****
  • Posts: 7309
  • Assembler is fun ;-)
    • MasmBasic
Re: Flying around
« Reply #12 on: August 07, 2017, 10:25:23 PM »
@Tim: Your solution works, see attachment (pure Masm32) :t

One of the messiest aspects of window handling :(
Code: [Select]
  SWITCH uMsg
  CASE WM_SETCURSOR
invoke GetCursorPos, addr pos
mov edx, pos.y
shl edx, 16
or edx, pos.x
invoke SendMessage, hWnd, WM_NCHITTEST, 0, edx ; OPT_Susy Console
.if eax==HTCLIENT
.if cState
invoke SetCursor, rv(LoadCursor, wcx.hInstance, IDC_NO)
and cState, 0  ; global var
.if !eax
print LastError$()
.endif
print "client", 13, 10
.endif
.else
.if !cState
invoke SetCursor, rv(LoadCursor, wcx.hInstance, IDC_UPARROW)
inc cState
.if !eax
print LastError$()
.endif
print "other", 13, 10
.endif
.endif
or eax, -1
ret

Doesn't work as it should :(

caballero

  • Member
  • ****
  • Posts: 743
    • Abre Ojos Ensamblador
Re: Flying around
« Reply #13 on: August 08, 2017, 03:16:12 AM »
TWell rocks! :t  Attached the sample with source code.
« Last Edit: August 08, 2017, 05:28:24 PM by caballero »
En un lugar de la Mancha de cuyo nombre no quiero acordarme