Author Topic: Early WIP on v2.55  (Read 2852 times)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 777
Early WIP on v2.55
« on: October 24, 2018, 03:59:37 am »
Patrice,

I know it's usually annoying to wait and overtake, so here's an early beginning of our sync process. I'll be adding more features marked with TODO in the code, menus, and text below in the next few days:

Mods dated "MLL 10-18-2018:"

0.  Fixed clearing old geometry data on model reload
1.  Fixed mipmapping on texture reload
2.  Fixed material initialization for models with missing MAT files
3.  Fixed model and mesh rotation stop/resume/reset angles
4.  Fixed deletion of shader programs
5.  Fixed and refactored frenglish func names to common style
6.  Refactored PROPM structure into PROPM and RHANDL structures
7.  Refactored main and sub menus to allow new functionalities
8.  Isolated shaders and render procs into separate project files
9.  Removed lots of obsolete Mobj_xxx code
10. Added:
   - scene grid
   - TODO: inertial mouse
   - TODO: axis aligned bounding boxes
   - TODO: viewport tooltip to report material names under cursor
   - TODO: model Z rotation on Alt+LMB drag
   - flat shaders to support glShadeModel(GL_SMOOTH | GL_FLAT) (except normal map shader for now)
   - shader for discrete texture and geo inspection in design mode


I'm slow because I'm fixing everything that I find buggy or unhandy until it works and looks flawlessly by my standards. It involves a hellofalot of time and experimentation.

But many fixes and features are already working and ready for your criticism. ;) Some provisions are already included in the code for the coming features too.

Please copy the files from the zip below into their respective project folders (same project paths considering the zip as the solution root) and let them overwrite the old files. Don't forget to add the two new files (renderers.h and shaders.h) to the project.

Do not attempt a usual merger as there are far too many differences. Just copy, recompile, and enjoy. And criticize if needed. :)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 951
    • zapsolution
Re: Early WIP on v2.55
« Reply #1 on: October 24, 2018, 10:16:28 am »
The new features are great, some of them could be duplicated onto the control panel to ease the model inspection (i can do it if you want).

Thank you!
« Last Edit: October 24, 2018, 10:19:49 am by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 777
Re: Early WIP on v2.55
« Reply #2 on: October 24, 2018, 10:18:54 am »
Thanks for the appreciation! I tried hard. :)

OK, I'm ready for work. Please post any comments or fixes you might have in this thread. :)

Let me finish the eye candies first and then we'll talk on how to refactor the GUI, OK?


(IronMan's occlusion looks terrific!!! My congratulations! :D)
« Last Edit: October 24, 2018, 10:23:36 am by Michael Lobko-Lobanovsky »
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 951
    • zapsolution
Re: Early WIP on v2.55
« Reply #3 on: October 24, 2018, 10:23:54 am »
Quote
Let me finish the eye candies first and then we'll talk on how to refactor the GUI, OK?

OK
Patrice
(Always working with the latest Windows version available...)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 951
    • zapsolution
Re: Early WIP on v2.55
« Reply #4 on: October 24, 2018, 02:30:46 pm »
I am trying to deal with the case or name changes, to see what is really new in the code

Generally i prefer to put all my properties in lowercase to avoid remembering where to put the upper cases  :-[
I was accustomed for years to use non-case sensitive programming languages ;)

Quote
and looks flawlessly by my standards
Fortunatly i shall have to do this check only once, since starting from now i shall use your preferences ;)
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 777
Re: Early WIP on v2.55
« Reply #5 on: October 24, 2018, 04:31:37 pm »
I'm used to camel case in the C sources, and my gradual change from Mobj_FooBar to fooBar also helps me to intuitively keep track of what code I've already worked on vs. that not yet touched by me.

Another reason to use camel case in mobj.h is to keep track of which functions are fundamental (Mobj_xxx) vs. those that are auxiliary helper routines (camelCase). Also, I'm not very fond of underlining names and labels because it makes them far longer to type than they really should be.

Then, why I'm moving certain functions out of mobj.h is because they are not specific to the OBJ format but rather belong to the OR's own framework regardless of what particular format it's going to display now or in the future.

And finally, I just like the code being kept in separate relatively small and functionally complete files. I'll be also moving all texture handling routines out of mobj.h into a separate dedicated textures.h file. (it may require adding a few function prototype headers at the top of mobj.h though)

Generally i prefer to put all my properties in lowercase to avoid remembering where to put the upper cases  :-[
I was accustomed for years to use non-case sensitive programming languages ;)

While we're at it, did you know that OR is case sensitive regarding material names? It refuses to apply the material if its name case in the MAT files differs from that in the OBJ file. This is one thing I'd like to ask you to fix in the sources now if you don't mind... :)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 951
    • zapsolution
Re: Early WIP on v2.55
« Reply #6 on: October 24, 2018, 04:59:46 pm »
Please, check the case of gP.modelpath into the gl_LoadModel procedure, it should be gl.modelPath with the new PROP member name.

Why did you use (+Alt) in this
            wcscopy(szCaption, L"  Mouse buttons:\n- Left(+Alt), rotate.\n- Right, pan.\n- Wheel, zoom.");


Also change the version number to 2.55, see my Main.cpp sync in the attached zip file.
Patrice
(Always working with the latest Windows version available...)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 951
    • zapsolution
Re: Early WIP on v2.55
« Reply #7 on: October 24, 2018, 05:05:14 pm »
OR also doesn't accept to use a fully qualified path, perhaps we should be more permissive (as long as the target file exist) ?

Quote
did you know that OR is case sensitive regarding material names

This is because of this in Mobj_importGeometrySecondPass

        case 'u': // usemtl
            fgets(buffer, sizeof(buffer), pFile);
            sscanf(buffer, "%s %s", buffer, buffer);
            //name = buffer;
            iter = m_materialCache.find(buffer);
            activeMaterial = (iter == m_materialCache.end()) ? 0 : iter->second;
            break;

I am not comfortable with the use of iterator myself, and the problem is that find in the class map is always case sensitive.  :-\

 
« Last Edit: October 24, 2018, 07:22:23 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 777
Re: Early WIP on v2.55
« Reply #8 on: October 24, 2018, 10:59:00 pm »
This isn't the only weird thing about C++ std::vectors. You're using them unsparingly, but have you ever checked how actually spacious the vectors are to reach their .end or .size? You'll be surprised but the actual .size of texture vectors we iterate through many times in search of duplicates varies somewhere between 17500 and 45000 elements on my PC! There is no way to limit the size of memory C++ allocates for its std::vectors nor is there any way to deallocate it when no longer needed.

No wonder texture creation takes probably up to half the overall time the model loads...

Anyway, we need case-insensitive materials and other labels used throughout MAT and OBJ files. Do whatever you see fit but please fix that preternatural glitch.

Fully qualified paths would also be welcome, and even more so because they are allowed by the Wavefront OBJ format.

Tip of the Day #2: did you know that OR allows more than one word long material names? IIRC one of your latest models contains and actually displays the material(s) whose name is xxxx_yyyy zzzz. (I'm sure that was a typo but it somehow worked in both MAT and OBJ nonetheless :o)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 777
Re: Early WIP on v2.55
« Reply #9 on: October 24, 2018, 11:23:01 pm »
Probably the names should be lowercased before they go into the material cache?
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 951
    • zapsolution
Re: Early WIP on v2.55
« Reply #10 on: October 24, 2018, 11:29:07 pm »
Please see above, post #6, about: gl_LoadModel
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 777
Re: Early WIP on v2.55
« Reply #11 on: October 24, 2018, 11:48:47 pm »
Please, check the case of gP.modelpath into the gl_LoadModel procedure, it should be gl.modelPath with the new PROP member name.

OK thanks!

Quote
Why did you use (+Alt) in this
            wcscopy(szCaption, L"  Mouse buttons:\n- Left(+Alt), rotate.\n- Right, pan.\n- Wheel, zoom.");

Alt+LMB will allow the model to be rotated with the mouse not only around X and Y axes like it does now, but also around Z. This label, together with the two new textures in the \Release\Reader subfolder and two new functions commented out in renderers.h, is a provision for this new functionality I'm working on right now.

Pressing Alt will show the target ellipse on the screen as in the snapshot below, whereby you'll be able to rotate the model:
-- by dragging anywhere inside the ellipse with LMB down exactly as you do now
-- strictly around X only when the left mouse button is pressed in the yellow boxes and then dragged
-- strictly around Y only when the left mouse button is pressed in the cyan boxes and then dragged
-- strictly around Z only when LMB'ed and dragged anywhere outside the ellipse.

The ellipse will disappear again when you release the Alt button.

Quote
Also change the version number to 2.55, see my Main.cpp sync in the attached zip file.

Will do, thanks again! :)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 777
Re: Early WIP on v2.55
« Reply #12 on: October 25, 2018, 06:19:27 am »
Regarding (+Alt), I just thought we can also use it for many other purposes in the future, so it will probably be not so wise to spring up the ellipse every time the Alt button is pressed...

Alternatively we can use the letter Z as sort of a hotkey to initiate Z-axis rotation and show the ellipse in response, inviting the user to start this operation. Z is rare to use as a hotkey because there are few words to start with it, but in this case it will be kind of meaningful and appropriate.

What's your opinion?

Please, check the case of gP.modelpath into the gl_LoadModel procedure, it should be gl.modelPath with the new PROP member name.

Why, everything's all right with the gP.modelPath case in both Main.cpp (yours and mine) and mobj.h, and the project compiles fine for me... ???
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 777
Re: Early WIP on v2.55
« Reply #13 on: October 25, 2018, 09:10:00 am »
Patrice my friend,

I need your help.

I need a popup window like in the mock-up below, coded in a separate file, with the following features:
  • It should popup in response to pressing the Ctrl button.
  • It should stay visible for as long as Ctrl is kept pressed and should disappear when the button is released.
  • It should behave like a popup toolwindow not blocking the main window but staying above it at all times even when the mouse is focused on the main window to rotate/pan the model.
  • I should be able to change the captions and blablas programmatically as needed.
  • I should be able to enable/disable the controls (or even hide them) programmatically as needed.
Can you code it for me, please?

TIA :)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 951
    • zapsolution
Re: Early WIP on v2.55
« Reply #14 on: October 25, 2018, 10:03:25 am »
OK, i have fixed the case sensitive mtl name problem.

I shall work on the new dialog now.

Added:
The new dialog is ready to be customized. ;)
« Last Edit: October 25, 2018, 08:55:32 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)