ObjReader Community

WIP => WIP => Topic started by: Patrice Terrier on November 25, 2019, 05:00:39 pm

Title: OR code change
Post by: Patrice Terrier on November 25, 2019, 05:00:39 pm
I am adding selection of a specific animation directly from the .mtl file.
And now we can play directly a specific audio file using drag and drop.

Could you check them?

Search // PAT: 11-25-2019  and // PAT: 11-26-2019 for the code changes

And check with the attached robots2 project that requires version #2.82
Title: Re: OR code change
Post by: Patrice Terrier on November 25, 2019, 09:59:58 pm
And for the fun, try with this material

#Light frontAmbient 0 0 0
#Light frontDiffuse 165 165 165
#Light frontSpecular 127 127 121

#Light leftAmbient 0 0 0
#Light leftDiffuse 127 127 121
#Light leftSpecular 47 79 79

#Light rightAmbient 0 0 0
#Light rightDiffuse 127 127 121
#Light rightSpecular 112 128 144

#Light topAmbient 0 0 0
#Light topDiffuse 25 25 112
#Light topSpecular 1 0 0

#multilight
#straylight 65
#wallpaper AniLights.fs
#playaudio Light-Years_V001_Looping.mp3 15 loop
#demo

newmtl mat_01
#rotate 0.05 0 0 1 359 361 0
Ka 0.01 0.01 0.01
Kd 0.40000000596046 0.40000000596046 0.40000000596046
Ks 1 1 1
Ke 0.4 0.4 0.4
map_Ka mat_01_AO.png
map_Kd mat_01_ALB.png
map_bump mat_01_NRM.png
map_Ke mat_01_EMS.png
map_Ns mat_01_roughness.png
Ns 512
illum 2

newmtl mat_02
#rotate 0.05 0 0 1 359 361 0
Ka 0.01 0.01 0.01
Kd 0.40000000596046 0.40000000596046 0.40000000596046
Ks 1 1 1
map_Ka mat_02_AO.png
map_Kd mat_02_ALB.png
map_bump mat_02_NRM.png
map_Ns mat_02_roughness.png
Ns 512
illum 2

newmtl mat_03
#rotate -0.12 0 1 0 0 0 0 1
Ka 0.01 0.01 0.01
Kd 0.39235669374466 0.39235669374466 0.39235669374466
Ks 1 1 1
map_Ka mat_03_AO.png
map_Kd mat_03_ALB.png
map_bump mat_03_NRM.png
Ns 512
illum 2

newmtl mat_04
#rotate -0.12 0 1 0 0 0 0 1
Ka 0.01 0.01 0.01
Kd 0.35159236192703 0.35159236192703 0.35159236192703
Ks 1 1 1
Ke 0.4 0.4 0.4
map_Ka mat_04_AO.png
map_Kd mat_04_ALB.png
map_bump mat_04_NRM.png
map_Ke mat_04_EMS.png
Ns 512
illum 2


Note: try also with light rotation...
Title: Re: OR code change
Post by: Patrice Terrier on November 26, 2019, 03:19:57 pm
The new official Version 2.82 has been released.
http://www.objreader.com/index.php?topic=2.msg2#msg2
Title: Re: OR code change
Post by: Michael Lobko-Lobanovsky on December 03, 2019, 04:13:14 am
Patrice,

Answering your email, yes, I merged your latest mods with my sources and your Robots2 model displays fine in my OR.

However I have five issues to note:

1. What is the #define for IDC_AUDIO in your constants.h? (you didn't send me that file)

2. As you can remember, we used to have problems with the texture files whose names began with commonly used Tr/tr because they clashed with the Tr parameter abbreviation and thus crashed OR at model load time. To protect against such crashes, the following code was agreed upon in the Mobj_importMaterials() function in mobj.h:

........
        case 't': // Tr
            switch (szBuffer[1]) {
            case 'r': // Tr
                if (szBuffer[2] == 32 || szBuffer[2] == 9) { // MLL 10-10-2019: Tr should always be followed by a space or tab
                    if (pMaterial->alpha == 1.0f) { // 12-06-2015 ML: only if alpha is still default
                        fscanf(pFile, "%f", &pMaterial->alpha);
                        if (pMaterial->alpha > 0.0f) {
                            pMaterial->alpha = 1.0f - pMaterial->alpha; // 12-06-2015 ML: follow OBJ specs
                        }
                        if (pMaterial->alpha == 0.0f) { pMaterial->alpha = 1.0f; } // 02-05-2016
                    } else {
                        fgets(szBuffer, sizeof(szBuffer), pFile); // 12-06-2015 ML: ignore
                    }
                }
                break;
........


Please fix your sources.

3. The new Play audio checkbox appears with an approx. 5 second delay after the model is loaded and the sound begins to play.

4. Ticking/unticking the Play audio checkbox does not toggle the sound for me.

5. The Play audio checkbox does not get hidden on clicking the File->Close all and clear scene menu.

Can you fix those issues, please?
Title: Re: OR code change
Post by: Patrice Terrier on December 03, 2019, 01:35:42 pm
Quote
1. What is the #define for IDC_AUDIO in your constants.h?
#define IDC_AUDIO               123 // PAT: 11-05-2019
#define IDC_ANIMATION           124 // PAT: 06-08-2018
#define IDC_DEMO_MODE           125 // PAT: 12-30-2017
#define IDC_BRIGHT_CONTROL      126 // ML 01-02-2018: scene brightness
//#define IDC_BTN_TOAST           127 // PAT: Test purpose only
#define IDC_GRAPHIC_CARD        128 // PAT: 02-17-2018


Quote
2. As you can remember, we used to have problems with the texture files whose names began with commonly used Tr/tr because they clashed with the Tr parameter abbreviation and thus crashed OR at model load time.

I added your change, but the code is already protected by the change done at line 1123 into mobj.h

Quote
3. The new Play audio checkbox appears with an approx. 5 second delay after the model is loaded and the sound begins to play.
This is because WM_PAINT is a low priority message, to solve this add a windowredraw at the end of gl_LoadModel, like this
    SetWindowPos(gP.hSplitter, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); // PAT: 02-20-2019

    WindowRedraw(gP.hMain); // PA: 12-03-2019, force immediate redraw, to work around the low priority of the WM_PAINT message
}


Quote
4. Ticking/unticking the Play audio checkbox does not toggle the sound for me.
I am unable to reproduce this behavior, it works perfectly well by me :(
Make sure that i goes to BASS_ChannelPause.


Quote
5. The Play audio checkbox does not get hidden on clicking the File->Close all and clear scene menu.
    case MENU_FILE_CLOSE: // MLL 12-20-2018:
        if (gP.bObjectLoaded) { // PAT: 02-27-2019
            gl_CloseAll();
            BassCloseChannel();
            HWND hCtrl = GetDlgItem(gP.hMain, IDC_AUDIO);        // PAT: 12-03-2019
            if (IsWindow(hCtrl)) { ShowWindow(hCtrl, SW_HIDE); } // PAT: 12-03-2019
//TOR            ResetTorControls();
//TOR            MoveTorWindows(FALSE);
        }
        break;


and add this in gl_CloseAll

void gl_CloseAll() { // MLL 12-20-2018: unload model and reset viewport
    RECT vr = { 0 };

    if (gP.bObjectLoaded) {
        ClearMemory(&gP.wModelPath, sizeof(gP.wModelPath));

        if (IsWindowVisible(gP.hOverlay))
            ShowWindow(gP.hOverlay, SW_HIDE);

        HWND hCheckList = GetDlgItem(gP.hMain, IDC_CHECKLIST);
        if (IsWindow(hCheckList)) {
            ListView_DeleteAllItems(hCheckList);
            ZI_UpdateWindow(hCheckList, 0);
        }
        SetWindowText(GetDlgItem(gP.hMain, IDC_VERTICES), $NULL);
        SetWindowText(GetDlgItem(gP.hMain, IDC_TRIANGLES), $NULL);
        SetWindowText(GetDlgItem(gP.hMain, IDC_INDICES), $NULL);
        SetWindowText(GetDlgItem(gP.hMain, IDC_MESHES), $NULL);
        SetWindowText(GetDlgItem(gP.hMain, IDC_MATERIALS), $NULL);
        SetWindowText(GetDlgItem(gP.hMain, IDC_OBJ_SIZE), $NULL);
        SetWindowText(GetDlgItem(gP.hMain, IDC_LOAD_TIME), $NULL);
        SetWindowText(gP.hMain, MAIN_CAPTION);

        if (Mobj_getNumberOfVertices())
            Mobj_destroy();

        gP.frontAmbient = gP.frontDiffuse = gP.frontSpecular = 0;
        gP.leftAmbient = gP.leftDiffuse = gP.leftSpecular = 0;
        gP.rightAmbient = gP.rightDiffuse = gP.rightSpecular = 0;
        gP.topAmbient = gP.topDiffuse = gP.topSpecular = 0;
        gP.nSplitXoffset = 0;

        if (gP.bGiration) { // PAT: 12-03-2019
            gP.bGiration = FALSE;
            SendMessage(GetDlgItem(gP.hMain, IDC_DEMO_MODE), BM_SETCHECK, MF_UNCHECKED, 0); // hack: reuse MF_ flags as BST_ flags
            CheckMenuItem(gR.hAniMenu, MENU_ANI_MODEL, MF_UNCHECKED);
        }

#ifdef MLL_DEV
        HideHelp();
#endif

        GetViewRect(gP.hMain, &vr);
        MoveWindow(gP.hGL, 0, 0, gP.glWidth, gP.glHeight, TRUE);
        MoveWindow(gP.hSplitter, vr.right, vr.top, SPLITTER_WIDTH, gP.glHeight, TRUE);

        ResetCamera();
        gl_DestroyObjTextures();

        backToStaticBkgnd(); // MLL 06-10-2019:

        gl_InitRenderProps(); // ... and redraw the viewport
    }
}
Title: Re: OR code change
Post by: Michael Lobko-Lobanovsky on December 03, 2019, 04:28:06 pm
Okay Patrice,

1./4. Setting a correct #define for IDC_AUDIO (rather than an arbitrary number higher than 59902) fixed the both issues.

2. I'm still in favor of my solution because it does the same but works faster; it checks the space/tab character only if the line begins with a T or t while your solution checks every line in the file for the presence of a rather long string char sequence #playaudio, which is objectively slower. If you've put in my code, you can safely delete yours from line 1123 to 1127. There is no point in checking a global #meta in a local material section.

3. The forced redraw really did the trick.

5. Now both audio and demo check boxes behave as expected at all times.

Thank you!
Title: Re: OR code change
Post by: Patrice Terrier on December 04, 2019, 07:36:49 pm
Mike

I find that:
AnimateWindow(gP.hInfoTip, 200, AW_BLEND); // emulate genuine tooltip default behavior
is a nuisance when OR is running itself in animated mode.

I would rather use
ShowWindow(gP.hInfoTip, SW_SHOWNOACTIVATE);
to keep the OR animation smooth rather than being interrupted by the tooltip display effect.
Title: Re: OR code change
Post by: Michael Lobko-Lobanovsky on December 04, 2019, 08:23:15 pm
You're probably right.

Let's do it that way: if both the background and model are static, we use AnimateWindow(). But if at least one or the other is dynamic, then we use ShowWindow().

An alternative approach would be to create the tooltip window in a separate thread, in which case its animation won't block the rendering process. The same concerns the toast window whose animation also stalls rotation. (if only GDImage controls support multithreading)
Title: Re: OR code change
Post by: Patrice Terrier on December 05, 2019, 10:55:34 am
Please, fix this:

void ToggleFullScreen() {
    static DWORD savedExStyle, savedStyle, screenWidth, screenHeight;
    static long OverLayVisible, AnimationVisible, AudioVisible; // PAT: 12-05-2019
    static RECT rcSaved;
    static HRGN oldRgn = 0, newRgn = 0;
    long K = 0, nLeft = 0, nTop = 0;
    WINDOWPLACEMENT wp = { 0 };

    gP.bIsFullScreen = !gP.bIsFullScreen;

    if (GetWindowPlacement(gP.hMain, &wp)) { // 04-20-2015
        if (wp.showCmd == SW_SHOWMAXIMIZED) {
            //ShowWindow(gP.hMain, SW_RESTORE);
            skRestore(gP.hMain);
        }
    }

    if (gP.bIsFullScreen) { // Moving to full screen mode.
        long wasFPS = gP.bUseFPS; if (gP.bUseFPS) { gP.bUseFPS = FALSE; }

        GetWindowRgn(gP.hMain, oldRgn);

        GetWindowRect(gP.hMain, &rcSaved);

        AnimationVisible = IsWindowVisible(GetDlgItem(gP.hMain, IDC_ANIMATION));
        AudioVisible = IsWindowVisible(GetDlgItem(gP.hMain, IDC_AUDIO)); // PAT: 12-05-2019

        if (IsWindowVisible(gP.hHelp)) { HideHelp(); } // PAT: 12-28-2018

        for (K = IDC_FIRST; K <= IDC_LAST; K++) {
            ShowWindow(GetDlgItem(gP.hMain, K), SW_HIDE);
        }
        ShowWindow(gP.hSplitter, SW_HIDE); // PAT: 16-12-2018
        OverLayVisible = IsWindowVisible(gP.hOverlay);

        MONITORINFO tmi = { 0 };
        RECT rw = { 0 };
        HMONITOR hMonitor = MonitorFromWindow(gP.hMain, MONITOR_DEFAULTTONEAREST);
        tmi.cbSize = sizeof(tmi);
        GetWindowRect(gP.hMain, &rw);
        GetMonitorInfo(hMonitor, &tmi);
        screenWidth = abs(tmi.rcMonitor.right - tmi.rcMonitor.left);
        screenHeight = abs(tmi.rcMonitor.bottom - tmi.rcMonitor.top);
        nLeft = skGetSystemMetrics(SK_CXFRAMELEFT);
        nTop = skGetSystemMetrics(SK_CYCAPTION) + skGetSystemMetrics(SK_CYMENU);
        //rw.left = tmi.rcMonitor.left - nLeft + 1; // Pat: 01-05-2016
        rw.left = tmi.rcMonitor.left - nLeft; // Pat: 03-23-2016
        rw.top = tmi.rcMonitor.top - nTop; // Pat: 01-05-2016
        long RightPanelSize = ClientW - ClientWGL;

        // PAT: 02-06-2018 without minus Overlay, no way to let it work correctly
        // Windows do not like when an application take full control of the whole view port...
        rw.right = screenWidth + nLeft + skGetSystemMetrics(SK_CXFRAMERIGHT) + RightPanelSize; //- OverLayVisible; // PAT: 02-12-2018
        rw.bottom = screenHeight + nTop + skGetSystemMetrics(SK_CYFRAMEBOTTOM);
        MoveWindow(gP.hMain, rw.left, rw.top, rw.right, rw.bottom, FALSE);

        // PAT: 02-12-2018
        SetWindowLongPtr(gP.hGL, GWL_STYLE, WS_POPUP | WS_VISIBLE);                                          // PAT: 02-12-2018
        MoveWindow(gP.hGL, 0, 0, screenWidth, screenHeight + 1, FALSE);                                      // PAT: 02-12-2018
        SetWindowPos(gP.hOverlay, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);                        // PAT: 02-12-2018
        if (IsWindow(go.hTip)) { SetWindowPos(go.hTip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); } // PAT: 02-12-2018

        //newRgn = CreateRectRgn(nLeft - 1, nTop, nLeft + screenWidth - OverLayVisible, nTop + screenHeight); // Pat: 01-05-2016
        newRgn = CreateRectRgn(nLeft, nTop, nLeft + screenWidth, nTop + screenHeight); // PAT: 02-06-2018
        if (newRgn) { SetWindowRgn(gP.hMain, newRgn, TRUE); }

        gP.bUseFPS = wasFPS;
        CheckMenuItem(gP.hSubMenu, MENU_VIEW_FULLSCREEN, MF_CHECKED); // MLL 10-28-2018:

        popupToastWindow(L"Full Screen", L"Press ESC or SPACEBAR to exit the full screen mode."); // MLL 11-15-2018:

    } else { // Moving back to windowed mode.
        HideToast(); // MLL 11-15-2018:

        // PAT: 02-12-2018
        SetWindowLongPtr(gP.hGL, GWL_STYLE, WS_CHILD | WS_VISIBLE);                     // PAT: 02-12-2018
        SetWindowPos(gP.hOverlay, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); // PAT: 02-12-2018

        for (K = IDC_FIRST; K <= IDC_LAST; K++) {
            if ((K == IDC_ANIMATION) && (!AnimationVisible)) { continue; }
            if ((K == IDC_AUDIO) && (!AudioVisible)) { continue; } // PAT: 12-05-2019
            ShowWindow(GetDlgItem(gP.hMain, K), SW_SHOW);
        }
        ShowWindow(gP.hSplitter, SW_SHOW); // PAT: 16-12-2018
        if (OverLayVisible) { ShowWindow(gP.hOverlay, SW_SHOW); }

        screenWidth = rcSaved.right - rcSaved.left;
        screenHeight = rcSaved.bottom - rcSaved.top;
        SetWindowRgn(gP.hMain, oldRgn, FALSE);
        SetWindowPos(gP.hMain, HWND_NOTOPMOST, rcSaved.left, rcSaved.top, screenWidth, screenHeight, SWP_SHOWWINDOW);
        if (oldRgn) { SetWindowRgn(gP.hMain, oldRgn, TRUE); }
        if (newRgn) { DeleteObject(newRgn); }
        PostMessage(gP.hMain, WM_SIZE, 0, MAKLNG(screenWidth, screenHeight));
        CheckMenuItem(gP.hSubMenu, MENU_VIEW_FULLSCREEN, MF_UNCHECKED); // MLL 10-28-2018:
    }
    SetFocus(gP.hGL); // MLL 10-28-2018: Z rotation support
}
Title: Re: OR code change
Post by: Michael Lobko-Lobanovsky on December 05, 2019, 12:53:05 pm
Done as requested, Patrice!

And you, in your turn, please add the following fixes to Infotip.h:

void showTip(IN POINT & pos) {
    SIZE txtsize;
    HDC hDC, hDCompat;
    HWND hWnd;
    HGDIOBJ hObj;
    POINT p;
    int x, y, txtx, txty, dx, dy;

    p.x = pos.x; p.y = pos.y + 18;

    hDCompat = CreateCompatibleDC(hDC = GetDC(hWnd = GetDesktopWindow()));
    ReleaseDC(hWnd, hDC);
    hObj = SelectObject(hDCompat, GetStockObject(DEFAULT_GUI_FONT));
    GetTextExtentPoint32(hDCompat, infoTipText, lstrlen(infoTipText), &txtsize);
    SelectObject(hDCompat, hObj); // restore original font
    DeleteDC(hDCompat);
    x = GetSystemMetrics(SM_CXVIRTUALSCREEN);
    y = GetSystemMetrics(SM_CYVIRTUALSCREEN);
    dx = txtsize.cx + 8; dy = txtsize.cy + 7;
    txtx = p.x + dx; txty = p.y + dy;
    if (txtx > x)
        p.x -= (txtx - x);
    if (txty > y)
        p.y -= (dy + 20);
    SetWindowPos(gP.hInfoTip, HWND_TOP, p.x, p.y, dx, dy, SWP_NOACTIVATE);
    if (gP.bGiration || gP.bRotation || gP.bAniBkgnd)
        ShowWindow(gP.hInfoTip, SW_SHOWNOACTIVATE);
    else
        AnimateWindow(gP.hInfoTip, 200, AW_BLEND); // emulate genuine tooltip default behavior
}

void hideTip() {
    if (gP.bGiration || gP.bRotation || gP.bAniBkgnd)
        ShowWindow(gP.hInfoTip, SW_HIDE);
    else
        AnimateWindow(gP.hInfoTip, 100, AW_BLEND | AW_HIDE); // emulate genuine tooltip default behavior
    infoTipText = TipFormat(L"Background");
    //infoTipMeshID = -1;
}


to implement your earlier suggestion to unblock animation while showing/hiding the info tip.
Title: Re: OR code change
Post by: Patrice Terrier on December 05, 2019, 01:37:23 pm
Looks like we have done twice almost the same change(s).

See in the attachment the new IsAnimated() function (in ToastWindow.h),
used both in HideToast/ShowToast and HideTip/ShowTip.

Added:
I need to make more room on the right pannel to add a new gauge control  ???

...
Title: Re: OR code change
Post by: Michael Lobko-Lobanovsky on December 05, 2019, 05:24:56 pm
Re: render blockers
Well, they say "great minds think alike". ;) I added your function in place of my duplicate ORs.

Re: gl_CloseAll()
There were times when audio used to not stop in response to clicking the Close all and clear screen menu; so my function (in Main.cpp) now begins with

void gl_CloseAll() { // MLL 12-20-2018: unload model and reset viewport
    RECT vr = { 0 };

    if (gP.bObjectLoaded) {
        BassCloseChannel();
        ClearMemory(&gP.wModelPath, sizeof(gP.wModelPath));
........


Is your OR audio responsive to this menu? If not, please add that line to your function.

Re: right panel size
Can you also make it autohide (automatically slide away to the right completely out of view leaving only the splitter visible) when the cursor is not close to the right border of main window? If you could, then we would have a much broader view of completely unobscured OpenGL view of the scene... ::)
Title: Re: OR code change
Post by: Patrice Terrier on December 05, 2019, 06:35:38 pm
When starting in demo mode with a background animation, it takes several seconds before the mouse click get responsive, any thought on how to fix this?

(Cursor stay in hour glass mode for a while)

That is what causes the slowdown at startup, and the reason why i had to force a WindowRedraw at the end of gl_LoadModel (check it with ROBOTS2).

Added:
Here is a screen shot of the new GUI
with the new audio volume level gauge.

More:
I may have found a solution to work around the slowdown...
Title: Re: OR code change
Post by: Patrice Terrier on December 05, 2019, 08:38:55 pm
Here is the sync version, sorry for the extra work.  :-\

volume.png is to copy into the reader skin folder.
Title: Re: OR code change
Post by: Michael Lobko-Lobanovsky on December 05, 2019, 09:02:35 pm
Patrice,

Thank you for the mods but I will only give you my feedback tomorrow.

I can only tell you now that I wouldn't mind if you could replace the alpha threshold knob and illumination slider too with buttons like that of audio. The panel would then look more uniform and less crowded with dissimilar controls...
Title: Re: OR code change
Post by: Michael Lobko-Lobanovsky on December 06, 2019, 06:02:19 am
Infotip.h:
BOOL IsAnimated() { // MLL -> PAT: 12-05-2019
    if (gP.bGiration || gP.bRotation || gP.bAniBkgnd)
        return TRUE;
    return FALSE;
}

;D ;D ;D ;D

All your mods have merged OK and are working as expected. Thank you!

I still think the mouse control label should be completely removed from the right-side panel. Anyway, it doesn't fully describe what mouse does and how. Mouse control is different in different modes of operation. Removing the label will add extra space and will allow us to make all the controls rotary similar to the volume control.
Title: Re: OR code change
Post by: Patrice Terrier on December 06, 2019, 12:03:33 pm
Your thought?
Title: Re: OR code change
Post by: Michael Lobko-Lobanovsky on December 06, 2019, 12:45:14 pm
Very nice! :)
Title: Re: OR code change
Post by: Patrice Terrier on December 06, 2019, 01:53:52 pm
Here is the new GUI...

No specific comments, you will have to use WinMerge to see the many changes that have been done.  ???
Title: Re: OR code change
Post by: Michael Lobko-Lobanovsky on December 06, 2019, 04:14:56 pm
Everything seems to work as expected, thank you!

Two things to discuss:

1. A threshold looks confusing but apparently there's no glyph in Trebuchet. We can however call it Alpha value which fits in the existing checkbox label perfectly. Not very exact but passable under the circumstances.

Alternatively, can the checkbox label be implemented as a bitmap (possibly as a bitmap substrate under an empty label or a gap in the label), rather than text, to display instead of A?

2. Now that we have enough room for the checkboxes, we can make them inactive, rather than invisible, if they are not applicable to the current model. This will avoid ugly gaps in the checkbox list.

It will only require a few changes from IsWindowVisible to IsWindowEnabled throughout the sources.

What is your opinion?
Title: Re: OR code change
Post by: Patrice Terrier on December 06, 2019, 04:32:18 pm
Currently there is no ugly gaps, because the checkbox list has been setup to display first those that are always visible.
For the labels i could replace them with disabled image buttons, but so far i would prefer to use the label "Alpha value" rather than "A threshold".

Quote
2. Now that we have enough room for the checkboxes, we can make them inactive, rather than invisible.
I have to think of it...
Title: Re: OR code change
Post by: Michael Lobko-Lobanovsky on December 06, 2019, 04:47:58 pm
There is a gap if the model uses the Animation checkbox but doesn't use Play audio.
Title: Re: OR code change
Post by: Patrice Terrier on December 06, 2019, 06:47:38 pm
Here is the new sync version, keeping all controls always visible, using enable/disable rather than show/hide.

I hope i didn't forget anything  :o

Title: Re: OR code change
Post by: Michael Lobko-Lobanovsky on December 06, 2019, 08:04:20 pm
Amazing! :D

It seems to work OK, thank you my friend! :D
Title: Re: Straylight Control
Post by: Michael Lobko-Lobanovsky on December 07, 2019, 08:04:21 am
Patrice,

You made straylight slider horizontal but you forgot to adjust its control accordingly. (its max is currently at -100 at its extreme left)

Please make the following fixes. My files differ from yours because my OR is somewhat more advanced than yours, so your line numbering may be slightly different.

Main.cpp, WndProc(), near line 3167:
    case WM_HSCROLL: // ML 02-01-2018: scene brightness
        hCtrl = (HWND)lParam;
        if (hCtrl == GetDlgItem(hWnd, IDC_BRIGHT_CONTROL)) {
            gP.rIllumFactor = SendMessage(hCtrl, TBM_GETPOS, 0, 0) / 100.0f;
            SCALEILLUM(0); SCALEILLUM(1); SCALEILLUM(2); SCALEILLUM(3);
            swprintf_s(zTxt, strSize(zTxt), L"brightness %2.0f", gP.rIllumFactor * 100 + 0.001f);
            skSetToolTipText(hCtrl, TipFormat(zTxt));

            gP.bRedraw = TRUE; // Redraw the OpenGL scene
        }
        break;


Main.cpp, wWinMain(), near line 4025:
                    SendMessage(hCtrl, TBM_SETRANGE, TRUE, MAKELONG(0, 100)); // Both WinLIFT and GDImage support negative ranges, for example -50, 50; then 0 being the medium value
                    SendMessage(hCtrl, TBM_SETPOS, TRUE, 100);


Mobj.h, Mobj_importMaterials(), near line 962:
    Mobj_strayLight(100, TRUE);            // PAT: 01-10-2018

Mobj.h, Mobj_importMaterials(), near line 1056:
                } else if(strcmp(szBuffer, "#straylight") == 0) {           // SCENE ILLUMINATION BRIGHTNESS
                    fgets(szBuffer, sizeof(szBuffer), pFile);
                    if (sscanf(szBuffer, "%d", &nStraylight) == 1) {
                        Mobj_strayLight(nStraylight, TRUE);
                    }


Mobj.h, Mobj_importGeometryFirstPass(), near line 1573:
        Mobj_strayLight(100, TRUE); // MLL 10-18-2018: init lighting for models w/ missing or undefined MTL files


Hopefully, that's all there is to it... ???
Title: Re: OR code change
Post by: Michael Lobko-Lobanovsky on December 07, 2019, 08:24:35 am
Also, I made tooltips on the new checkboxes a little more informative and consistent with each other. Please fix yours in wWinMain() accordingly:

........
                    //skSetAnchorCtrl(GetDlgItem(gP.hMain, IDC_GAUGE_CHECKBOX), ANCHOR_RIGHT);

                    hCtrl = GetDlgItem(gP.hMain, IDC_GAUGE_CONTROL);  // MLL: 12-06-2019
                    skSetAnchorCtrl(hCtrl, ANCHOR_RIGHT); skCreateToolTip(hCtrl, L"  Threshold level  ");

                    hCtrl = GetDlgItem(gP.hMain, IDC_GAUGE_CHECKBOX);  // PAT: 12-06-2019
                    skSetAnchorCtrl(hCtrl, ANCHOR_RIGHT); skCreateToolTip(hCtrl, L"  Threshold On/Off  ");

                    hCtrl = GetDlgItem(gP.hMain, IDC_GAUGE_VOLUME);  // PAT: 12-05-2019
                    skSetAnchorCtrl(hCtrl, ANCHOR_RIGHT); skCreateToolTip(hCtrl, L"  Audio volume level  ");

                    hCtrl = GetDlgItem(gP.hMain, IDC_AUDIO);  // PAT: 11-05-2019
                    skSetAnchorCtrl(hCtrl, ANCHOR_RIGHT); skCreateToolTip(hCtrl, L"  Audio On/Off  ");

                    hCtrl = GetDlgItem(gP.hMain, IDC_ANIMATION);
                    skSetAnchorCtrl(hCtrl, ANCHOR_RIGHT); skCreateToolTip(hCtrl, L"  Mesh animation On/Off  ");

                    hCtrl = GetDlgItem(gP.hMain, IDC_DEMO_MODE);
                    skSetAnchorCtrl(hCtrl, ANCHOR_RIGHT); skCreateToolTip(hCtrl, L"  Y rotation On/Off  ");

                    hCtrl = GetDlgItem(gP.hMain, IDC_BRIGHT_CONTROL);
                    skSetAnchorCtrl(hCtrl, ANCHOR_RIGHT); skCreateToolTip(hCtrl, L"  Straylight intensity  ");

                    ///////////////////////////////////////
........
Title: Re: OR code change
Post by: Patrice Terrier on December 07, 2019, 12:21:12 pm
Changes have been done, thank you!

and here is a new one to avoid moving unexpectedly the slider button while using the threshold gauge.


                    y = 422;
                    hCtrl = addLabel(gP.hMain, LAB_STRAYLIGHT, L"Straylight", ClientW - 129, y, 120, 13, WS_CHILD | WS_VISIBLE | SS_LEFT);
                    // ML 01-02-2018: scene brightness
                    y += 15;
                    dwStyle = WS_CHILD | WS_VISIBLE | TBS_HORZ | TBS_RIGHT;
                    hCtrl = CreateWindowExW(0, L"msctls_trackbar32", $NULL, dwStyle, ClientW - 127, y, 120, 16, gP.hMain, (HMENU)IDC_BRIGHT_CONTROL, gP.hInstance, NULL);
                    SendMessage(hCtrl, TBM_SETRANGE, TRUE, MAKELONG(0, 100)); // Both WinLIFT and GDImage support negative ranges, for example -50, 50; then 0 being the medium value
                    SendMessage(hCtrl, TBM_SETPOS, TRUE, 100);

                    y += 31;
                    hCtrl = CreateWindowEx(0, L"BUTTON", L"Alpha value", WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
                                           ClientW - 127, y, 88, 16, gP.hMain, (HMENU) IDC_GAUGE_CHECKBOX, gP.hInstance, NULL);
Title: Re: OR code change
Post by: Michael Lobko-Lobanovsky on December 07, 2019, 02:16:49 pm
Fixed, thank you!
Title: Re: OR code change
Post by: Patrice Terrier on December 07, 2019, 03:00:21 pm
Now that we have more room, would you like to have a FPS check box there?
Title: Re: OR code change
Post by: Michael Lobko-Lobanovsky on December 07, 2019, 05:09:36 pm
Yes, both FPS and Turbo!!! :-*

BTW my FPS counter now shows in green if CPU load is <= 60%, in yellow if 60% < CPU <= 80%, and in red if > 80%. :P
Title: Re: OR code change
Post by: Patrice Terrier on December 07, 2019, 07:09:19 pm
Here is the sync for FPS and TURBO.

Warning, there is a new void SetTurboMode() in overlay.h, to avoid code duplication.

New version number #2.83

PS: There is a problem with the straylight computation now that the slider orientation has been changed

Added:
Here is the fix

void Mobj_resetLighting() { // PAT: 01-09-2018
    long nStrayLight = Mobj_strayLight(0, FALSE); // PAT: 01-10-2018
    SendMessage(GetDlgItem(gP.hMain, IDC_BRIGHT_CONTROL), TBM_SETPOS, TRUE, nStrayLight); // this also sets gP.rIllumFactor = 1.0f
    // zizi SendMessage(gP.hMain, WM_VSCROLL, MAKELONG(SB_THUMBPOSITION, nStrayLight), (LPARAM)GetDlgItem(gP.hMain, IDC_BRIGHT_CONTROL));
    SendMessage(gP.hMain, WM_HSCROLL, MAKELONG(SB_THUMBPOSITION, nStrayLight), (LPARAM)GetDlgItem(gP.hMain, IDC_BRIGHT_CONTROL));
    gP.nLightFlags = 1; // bin 0001
    gP.bIsLight0_On = TRUE;
    gP.bIsLight1_On = gP.bIsLight2_On = gP.bIsLight3_On = gP.bMultiLight = FALSE;
    CheckMenuItem(gP.hSubMenu, MENU_BRIGHT_LIGHT, MF_UNCHECKED);
    //gP.light0ColorAll = gP.light1ColorAll = gP.light2ColorAll = gP.light3ColorAll = true; // MLL: unused
    SetSwitch(ID_ONOFF0, gP.bIsLight0_On);
    SetSwitch(ID_ONOFF1, gP.bIsLight1_On);
    SetSwitch(ID_ONOFF2, gP.bIsLight2_On);
    SetSwitch(ID_ONOFF3, gP.bIsLight3_On);
    Mobj_lightInit();
    Mobj_assignColor();
}
Title: Re: OR code change
Post by: Michael Lobko-Lobanovsky on December 07, 2019, 08:52:18 pm
Thank you Patrice!

Oh yes, of course it should've been WM_HSCROLL. It was the only fix I overlooked to send you, sorry! :-[


P.S. Both FPS and Turbo are working perfectly. Just make the Turbo mode checkbox 98 pxs wide rather than 88 because otherwise the trailing e letter gets truncated.
Title: Re: OR code change
Post by: Patrice Terrier on December 09, 2019, 09:21:09 am
Mike

I plan to release the new official version, does there is anything else to fix first?
Title: Re: OR code change
Post by: Michael Lobko-Lobanovsky on December 09, 2019, 09:43:23 am
Does the current code have sufficient new features for a new version release, do you think?
Title: Re: OR code change
Post by: Patrice Terrier on December 09, 2019, 10:10:20 am
Not that much, except for the GUI that is now very different.

The help file needs also to be updated  :(
fortunatly i wrote a tutorial to reminds me what to do there:
http://www.objreader.com/index.php?topic=205.msg4396#msg4396

Added:
Please check the attached file for the new features:
- Animate background
- Audio support
- Demo mode
Title: Re: OR code change
Post by: Michael Lobko-Lobanovsky on December 09, 2019, 12:50:34 pm
The Demo mode section has been merged with the topmost Rotate model section because they are essentially about one and the same effect.

The text in the other sections has also been updated to reflect the titles and behavior of new checkboxes at the bottom of right side panel.
Title: Re: OR code change
Post by: Patrice Terrier on December 09, 2019, 01:42:41 pm
Ok, thank you!

Here are 2 new TruePNG files to update the help folder ;)

Now i shall build the new official release version...
Title: Re: OR code change
Post by: Michael Lobko-Lobanovsky on December 09, 2019, 03:50:54 pm
Patrice,

The animation image file should be named 007Animation.png (with a capital A) for the Contents entries to be consistent with each other!
Title: Re: OR code change
Post by: Patrice Terrier on December 09, 2019, 04:27:17 pm
Mike,

I just checked the one from the binary official release, and it has already a capital A, thank you!
Title: Re: OR code change
Post by: Patrice Terrier on December 30, 2019, 10:13:06 am
Saving a screenshot while a shader animation i running is a real pain, especially when the common Windows file selector dialog pops up, do you have any suggestion to fix this?
Title: Re: OR code change
Post by: Michael Lobko-Lobanovsky on December 30, 2019, 11:38:22 am
It seems to me it happens only at the maximum screen size when practically 100% of GPU are consumed by rendering and Windows Explorer is beginning to generally lag.

Save your screen shots in a windowed mode or uncheck Turbo and possibly Demo prior to saving the snapshot to disk.