Author Topic: ObjectReader  (Read 4699 times)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 462
    • zapsolution
ObjectReader
« on: January 15, 2016, 10:44:28 am »

This is the 64-bit version of ObjectReader, compiled with the latest Visual Studio Community 2015 edition, and Windows 10.

In its current state, this is the result of a close cooperation between:
Patrice Terrier and Michael Lobko-Lobanovsky,
In order to join the fun, send us a PM, and we will gladly share our code with you, if you want to contribute.

The ZIP file is provided with one single 3D model, you can download more from the links posted in "The 3D model collection". All material files have been tailored to use the unique features built-in ObjReader64, to achieve visual quality that comes close to real objects.

Make sure to use the latest OpenGL drivers, and to switch to the high performance nVIDIA graphic card mode, because the quality is so much better than with the default Intel graphic card.

You can select a 3D model from the menu "File", "Open..." option, or by using drag and drop of an *.obj file from the Explorer onto the ObjReader64 OpenGL section.


To install ObjReader64:

    1. Download the attached ZIP file
    2. Unlock the ZIP file to avoid any Windows UAC problem.
    3. Create a new folder, and unzip all files into it, preserving the directory tree structure.
    4. Once done, select ObjReader64.exe to run the program.
    5. The "Models" folder is the place to put all the models you download, keeping each of them into a distinct subfolder.

Note: The default model provided with the ObjReader64.zip is located into the "Models\IronMan" subfolder.

For those still running a 32-bit version of Windows, there is a 32-bit version available on request.


HISTORY
01-14-2016 Version 1.00: forum opening.
03-20-2016 Version 1.01: bounding sphere detection (Efficient Frustum Culling)
05-03-2016 Version 1.02: to illuminate both sides of polygons in case of dark faces.
07-14-2017 Version 1.03: added simplified command line support (ProccessCommandline).
01-24-2018 Version 2.00: new features list
02-24-2018 Version 2.50: new features list

...
« Last Edit: February 24, 2018, 08:42:55 am by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 462
    • zapsolution
Documentation
« Reply #1 on: January 27, 2016, 02:01:32 pm »
ObjReader, displays 3D models using the wavefront OBJ format exclusively.


THE INTERFACE
Because ObjReader is a GDImage/WinLIFT application it uses a specific skinned interface.




COMMAND LIST
They are available from the menu "File" or from the menu "View".
Note: "View" is also the contextual menu that pops up when you press the right mouse button on the OpenGL viewport.

Open...
Display the Windows file selector to choose a model from a specific folder.
ObjReader uses a default "Models\" subfolder, that is the prefered place to put all your models, like the "Models\IronMan\" that stores the Mark17.obj file and all its related materials. Each model with all related materials must be stored into an individual subfolder.

Rather than using the "Open" command, you can also use directly the Windows explorer to select a specific .obj file, and use drag and drop onto the ObjReader's OpenGL section to display the model.

Note: Because some 3D models could be very large, ObjReader displays a spinner animation, and you have to wait for full completion before you can do anything with it.

About
A dialog box shows you the version number, the copyright, and informations about the active 3D model.

Exit
Shut down the program, same as the close button on the top right corner.

Fullscreen
Switch to fullscreen mode, with just the OpenGL viewport visible. To return to the window mode, either press the space bar or the escape key.
Note: The contextual popup menu is also avaible in fullscreen mode, and you can select the "Fullscreen" command again to return to the window mode.

Reset
Restore the initial state of the camera, same than when you first display the model.

Use fixed pipeline
This command allows you to switch between the two 3D mode supported by ObjReader.
The GLSL Programmable Pipeline (PPL), and the Fixed Function Pipeline (FFP).
Most of the time you will not see much difference between PPL and FFP, however in case of bump materials we always switch to the Programmable Pipeline, while we keep using the Fixed Function Pipeline for simple material files.

Textured
This one is set automatically at the time you load a new model, and it is checked when the model uses textures.
However this command allows you to switch between textured or untextured mode to inspect the basic model.

Wireframe
This is very handy to better figure the polygon details used by a specific model, and it uses wire raher than solid to render the surfaces.

Point cloud
Same than wireframe, except that point are used rather than wire. The point size vary slightly with the zooming factor, because we have to accomodate to always show you something.

Ambient reflection
In order to see this effect, you must switch first to untextured mode, then this command uses the wallpaper to create GLSL spherical/specular reflection. To better see the effect, try with different wallpapers, you can select them from the listbox shown on the right.

Mipmap textures
When turned on (default), this command enables GPU computation of intermediate textures to better render the model when zooming in or out.

Multiple light sources
Three different light sources are used simultaneously to enhance the global illumination of the model.
(see also, the #ambient meta command)

Alpha to coverage
When using low polygon models with alpha transparency, this command help to produce better rendering of the transparent part of a texture. This is also very useful when dense foliage, grass, or hair must be rendered. It uses the alpha channel of the texture as a coverage mask for anti-aliasing.

Cull back faces
When this command is enabled, it doesn't render the hidden polygons.

Swap Y,Z axes
To change the orientation of a misaligned model.

Swap polygon winding order
The default OpenGL orientation is to use GL_CCW, but some models are using GL_CW causing elimination of back facing polygons, in that case GL_CW must be specified to change the default OpenGL setting, especially when using the menu "Cull back faces" command.
(see also, the #GL_CW meta command)

Smooth zooming
This is mostly to be used with high polygon models, to produce smooth zooming transition while performing video screen capture.

Illuminate both sides
To illuminate both sides of polygons with models using inverted normals (black faces).

Save to image
Save the current OpenGL viewport into a .png file (works also in full screen mode).

Print image
Send the current OpenGL viewport to the default printer.


Material files
Each of the .mtl, material file, must be tailored to use the exclusive features provided by the software.

This is done by using meta commands prefixed by the hashtag symbol: #.

In version 1.00 (command menu "About" to check the version) they are:

#wallpaper
To use a specific image stored into the resource\ subfolder, as wallpaper background (same than in the listbox).
Syntax: #wallpaper abstract02.png

#GL_CW
The default OpenGL orientation is to use GL_CCW, but some models are using GL_CW causing elimination of back facing polygons, in that case GL_CW must be specified to change the default OpenGL setting, especially when using the menu "Cull back faces" command.
Syntax: #GL_CW

#ambient
This is the same than using the menu command "Multiple light sources", in that case a total of 3 light sources are used from multiple angles to enhance the global illumination.
Syntax: #ambient

#threshold
This is the same than using the rotary button to adjust the alpha threshold with transparent materials. It is a decimal value ranging from 0.0 to 0.99. The default value is 0.10, the higher the value the larger the threshold to full transparency.
Syntax: #threshold 0.10

#bothsides
Enable the GL_LIGHT_MODEL_TWO_SIDE parameter, to illuminate both sides of polygons. By default, only the front of polygons is illuminated.
Syntax: #bothsides

Note: the meta commands are not case sensitive.


Specific material features
In order to produce nice rendering, ObjReader is able to use reflection files, they are spherical .png textures stored in each model's subfolder.

These spherical textures are meant to be used in conjunction with the refl and illum reserved mtl keywords, like this:

illum 3
refl texture.png

This one could be used altogether with, or without, alpha transparency, and the d 0.75 (percentage parameter), to produce raytracing reflection using the texture file specified as the refl parameter.

illum 4
refl fake_texture_name.png

In that case, while the refl instruction is still needed, the texture parameter name is not meaningful, because illum 4 instructs ObjReader to use the active wallpaper background to produce spherical reflection.
Most of the time, the best looking result is achieved by using it altogether with the specular value Ns 512, and a Ks 0.75 0.75 0.75 parameter.

« Last Edit: May 03, 2016, 10:15:59 am by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 462
    • zapsolution
Version 1.03
« Reply #2 on: July 14, 2017, 04:36:56 pm »
The first post of this thread has been updated with version 1.03 (see HISTORY for further details).

...
« Last Edit: July 15, 2017, 06:51:35 am by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 462
    • zapsolution
New features of version 2.00
« Reply #3 on: January 12, 2018, 12:28:22 pm »
New meta commands:

#alphatocoverage
This is a global or per material  meta.

#straylight percentage.
This is a global meta.
To reduce the light intensity, the percentage value is any number in the range 0 to 100, 100 being the current value and the default.

#multilight
Same than #ambient, but more explicit.

Ke
To specify the material emissive color.

New menu "Lighting"



Front_All
Front_Ambient
Front_Diffuse
Front_Specular

Left_All
Left_Ambient
Left_Diffuse
Left_Specular

Right_All
Right_Ambient
Right_Diffuse
Right_Specular

Each light meta, can use one of those color constants :



Y rotation mode (demo mode)
This starts the 360 self rotation of the model along the Y axe.
Press either the "+" or "-" key to speedup or slowdown the rotation.
By default the rotation starts in CCW mode, press the "-" to run it in CW mode.

Using a specific wallpaper
Rather than using a generic wallpaper into the mtl file,
it is possible to use a texture laying into the model folder,  using the "@" prefix in front of the texture name, like this:
#wallpaper @texture.png

Adding global lighting colors into mtl file

You can use either three R G B color values in the range 0-255, or a predefined GDIPLUS constant (see the above color table).

#Light frontAll 1 2 3
#Light frontAmbient aliceblue
#Light frontDiffuse antiquewhite
#Light frontSpecular 255 255 240

#Light frontAll 255 255 0
#Light frontAmbient aliceblue
#Light frontDiffuse antiquewhite
#Light frontSpecular 0 0 0

#Light leftAll aquamarine
#Light leftAmbient aquamarine
#Light leftDiffuse azure
#Light leftSpecular aquamarine

#Light rightAll bisque
#Light rightAmbient aqua
#Light rightDiffuse darkcyan
#Light rightSpecular darkgreen

#Billboard
Arguments to the #billboard metastatement may come in any order. Meaning of each:
  • cylinder/sphere -- cylindrical or spherical billboard, respectively. sphere is the default and may be omitted.
  • nodepth -- billboard is drawn in glDisable(GL_DEPTH_TEST) mode so that it is seen through the model as it rotates at any angle.
  • flip -- pertains to cylinder billboard mode only; when specified, it forces an asymmetrical cylindrical billboard to keep its "head" "up" when flipped upside down by model rotation. sphere billboards are always "flippable" and ignore this parameter.
...
« Last Edit: February 22, 2018, 09:12:39 am by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 462
    • zapsolution
Version 2.00 video presentation
« Reply #4 on: January 13, 2018, 05:46:10 pm »
Here is a link to a video presentation of some of the things that could be done with version 2.00.

onyx.mp4
« Last Edit: January 14, 2018, 08:32:17 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 462
    • zapsolution
Re: ObjectReader
« Reply #5 on: January 24, 2018, 12:34:49 pm »
Version 2.00 has been attached to the first post of this thread.

Note: This is a complete VS 2017 C++ 64-bit project targeted to the latest Windows 10 version 1709.
The pre-compiled binary code is within the x64\release subfolder.
« Last Edit: January 24, 2018, 12:39:56 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 462
    • zapsolution
New features of version 2.50
« Reply #6 on: February 22, 2018, 01:50:32 pm »
Version 2.50

SPEED, SPEED, SPEED:
This version has switched from VBA to VBO mode, meaning almost everything is now handled by the GPU at the maximum speed of the graphic card to allow for smooth manipulation of high polygon models with millions of vertices.

However the CPU/GPU loads and system responsiveness are still dependent on: (in the order of importance)
-- polygon count
-- default/maximized/full screen window size
-- visible distance to model
-- "Illuminate both sides" setting
-- FFP or PPL (menu "Use fixed pipeline" checked or unchecked, respectively)
-- number of material textures (and consequently, number of texture lookups in the shaders)
-- backface culling
-- etc.

Graphics card auto detection:
The matching icon is shown on the right side of caption bar (currently only nVidia or ATi).

New composited control panel:
Its primary purpose is to greatly simplify and enhance the light settings through the "Lighting" menu.

To show the control panel, either select the "Light settings panel" from the menu or press the F1 key that works as an On/Off toggle switch.

Use the mouse wheel to scroll the panel content up or down when mouse focus is on the panel, and press the right mouse button if you want to jump up to the panel top.



Light settings
Use the [<<] or [>>] buttons to select colors from a specific color palette (currently 8 palettes all in all). The default is the same color set as in version 2.00 (see post #3).

FPS
Use this switch to display the FPS rate (a.k.a. frames per second) normally shown as two digits in the top left corner of OpenGL view port.

TURBO ("running man" button)
Use this switch to double the FPS rate (increases the GPU percentage but makes animation smoother).

CPU / GPU
Monitor the percentage use for the respective processor.

PALETTE
Drag and drop a desired color onto a specific light option. The matching On/Off switch must be enabled to see the effect.
The "Lighting" menu option "Save lighting to mtl file" stores the settings directly into the material file (.mtl extension).
You can always switch back to default using the "Lighting" menu option "Reset scene lighting".
« Last Edit: February 23, 2018, 07:58:40 pm by Michael Lobko-Lobanovsky »
Patrice
(Always working with the latest Windows version available...)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 462
    • zapsolution
Re: ObjectReader
« Reply #7 on: February 23, 2018, 07:28:07 pm »
The full new version 2.50 project has been attached to the first post of this thread.

The binary ObjReader64.exe has been compiled with VS2010 to produce a smaller EXE file (310 Kb).
But the project itself is compatible with the free VS2017 Community version.

Enjoy!
« Last Edit: February 24, 2018, 08:43:46 am by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)