Build coin3d+soWin with visual studio 2015

in #utopian-io6 years ago (edited)

What Will I Learn?

  • Learn the basic knowledge of open inventor.
  • Learn Compilation process of Coin3d + soWin.
  • Solutions to several problems in the compilation process of learning Coin3d + Sowin.

Requirements

  • The basic knowledge of openGL.
  • Basic C++ knowledge
  • Compilation Knowledge for Visual studio
  • Knowledge of coin3d in windows.

Difficulty

  • Intermediate

Tutorial Contents

issue raised

What is open inventor?

Open Inventor is a library of objects and methods used to create interactive 3D graphics applications. Although it is written in C++, Inventor also includes C bindings. Open Inventor is a set of building blocks that enables you to write programs that take advantage of powerful graphics hardware features with minimal programming effort. Based on OpenGL, the toolkit provides a library of objects that you can use, modify, and extend to meet new needs. Inventor objects include database primitives, including shape, property, group, and engine objects; interactive manipulators, such as the handle box and trackball; and components, such as the material editor, directional light editor, and examiner viewer.

what is coin3d?

Freecad is built on the powerful geometrical core Opencascade, and adopts the three-dimensional scene model which is provided by Coin 3D and Open inventor compatible.
Recently I want to do something on the basis of FREECAD, but I need to understand the structure of coin3d. I'm having some trouble compiling this open source library. So I purposely wrote a tutorial that might help.

Coin3D is a high-level, retained-mode toolkit for effective 3D graphics development. It is API compatible with Open Inventor 2.1.
Coin3D is Free Software, published under the BSD 3-clause license.

build coin3d

Download coin3d + sowin source code Package

The link address of coin3d source code Package is:https://bitbucket.org/Coin3D/coin/downloads/。Because we need to compile libraries that can use under Windows, so we also need to download Sowin. Unzip the downloaded file to the directory you want to place.

Open coind3d with VS2015

Find the Coin3d build directory and see a few (MSVC6,MSVC7,MSVC8,MSVC9,MSVC10) directories, msvc10 corresponding to Visual Studio 2010 's compiled folder. Copy the Msvc10 folder, renamed to Msvc14, for compilation in Visual Studio 2015.

Open Coin4.sln using Visual Studio 2015.

Setting up a compilation environment

First, Coin3d needs boost's library, so you need to prepare the Boost's library file and add the boost's. h file path in the c++->additional Include directories. Add the boost's. lib file path to the linker->additional Library directories.


Second, the coin3d in the Coin3dsrcprojectorssbspheresheetprojector.cpp this file has a place to modify. if not modified, The code running in Windows will cause panic.

Assign the two parameters of this line to an initialized value.

  float planardist = 0.;
  float meetdist = 0.;

The result of the modification is shown in the following figure:

Finally, you can compile coin4 this project. However, there is a compile error of redefinition, which is due to inconsistent type definitions in different systems because the coin3d is not limited to using the platform.


The solution is:search HAVE_INTTYPES_H,HAVE_STDINT_H,HAVE_SYS_TYPES_H,HAVE_STDDEF_H,HAVE_INT8_T in this project. Modify these #undef to #define.
For example: Search Have_inttypes_h, found three places to change.

The code here:

/* #undef HAVE_INT8_T */

Modify to:

#define HAVE_INT8_T 1

Similarly, the other three have made the same changes:

    /* #undef HAVE_STDINT_H */    #define HAVE_STDINT_H 1
     /* #undef HAVE_SYS_TYPES_H */    #define HAVE_SYS_TYPES_H 1
     /* #undef HAVE_STDDEF_H */    #define HAVE_STDDEF_H 1
     /* #undef HAVE_INT8_T */    #define HAVE_INT8_T 1

Finally, compile coin3d project again. Display compilation succeeded.

Copy the compiled files to the specified directory

By compiling the coin4_install project in solution, you can copy the compiled. h and. lib files and. dll files to the specified directory. First open Coin3dbuildmiscinstall-sdk.bat this file.

The following code will be:

 set type=%1
set mode=%2
set msvc=%3
set libname=%4

Modified to:

set type=%1
set mode=%2
set msvc=%3
set libname=%4
set COINDIR=D:\build\coin3dLib

The following code will be:

if "%msvc%"=="msvc6" goto argthreegiven
if "%msvc%"=="msvc7" goto argthreegiven
if "%msvc%"=="msvc8" goto argthreegiven
if "%msvc%"=="msvc9" goto argthreegiven
if "%msvc%"=="msvc10" goto argthreegiven
goto argproblem
:argthreegiven

Modified to:

if "%msvc%"=="msvc6" goto argthreegiven
if "%msvc%"=="msvc7" goto argthreegiven
if "%msvc%"=="msvc8" goto argthreegiven
if "%msvc%"=="msvc9" goto argthreegiven
if "%msvc%"=="msvc10" goto argthreegiven
if "%msvc%"=="msvc14" goto argthreegiven
goto argproblem
:argthreegiven

Compiles the project this time and show compiles completes with obtains the Coin3d the library file. At this point, the Coin3d library file is compiled.

Build soWin

Sowin compilation, the same need to create a Msvc14 folder

Configuring the compilation Environment

After open with Visual Studio 2015, you need to configure the compilation environment first, and you need to add coin3d library files. Add a boost's. h file path in the c++->additional Include directories. Add the boost's. lib file path to the linker->additional Library directories.


Solve a problem in Sowin

the problem is: It compiles and work fine on VS2010, it also compiles fine on 2015, but when I run the test project with Examiner viewer and cone, the window hangs (only outlines of buttons on the window decoration shown and window is not responding)

the solution is: I've found a solution for the problem running Coin 3D under VC 2013. The problem was in SoWin::mainLoop(void), the function GetQueueStatus(QS_ALLINPUT) always returned 0, so none of the messages were translated, so the window was not painted and not responded to user interaction. Replacing it by GetQueueStatus(0x5FF) fixed the problem. (VS 2013 targets Win8.1, where QS_ALLINPUT includes a couple of new flags, which seems to caused the problem).

Modify this code in the SoWin.cpp:

if (GetQueueStatus(QS_ALLINPUT) != 0) { // if messagequeue != empty
      if (GetMessage(& msg, NULL, 0, 0)) { // if msg != WM_QUIT
        TranslateMessage(& msg);
        DispatchMessage(& msg);
      }

to:

if (GetQueueStatus(0x5FF) != 0) { // if messagequeue != empty
      if (GetMessage(& msg, NULL, 0, 0)) { // if msg != WM_QUIT
        TranslateMessage(& msg);
        DispatchMessage(& msg);
      }

As with compiling coin3d, you also need to solve the problem of int8_t duplicate definitions, similar to the solution above. Now compile the Sowin project and it should show that the compilation was successful.

Modify the path of the containing file

Copile this project this time maybe exist two errors, originally due to the included header file relative path problem.

This is the time to modify the directory of two header files

#include <Inventor/Win/editors/SoWinColorEditor.h>     #include <Inventor/Win/SoWinColorEditor.h>

#include <Inventor/Win/editors/SoWinColorEditor.h>      #include <Inventor/Win/SoWinColorEditor.h>

Build soWin_install

Compile Sowin_install project can copy Sowin's engineering library files to the specified directory. Modiy sowin-1.5.0buildmiscinstall-sdk.bat file configuration with the above method.

At this point, Coin3d+sowin is finished compiling!

Thank you for your attention.
@hushuilan



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Keep up the good work.Thanks for sharing.

This comment has received a 0.15 % upvote from @speedvoter thanks to: @tute.

Thank you for the contribution It has been approved.


Need help? Write a ticket on https://support.utopian.io.
Chat with us on Discord.

[utopian-moderator]

Hey @hushuilan! Thank you for the great work you've done!

We're already looking forward to your next contribution!

Fully Decentralized Rewards

We hope you will take the time to share your expertise and knowledge by rating contributions made by others on Utopian.io to help us reward the best contributions together.

Utopian Witness!

Vote for Utopian Witness! We are made of developers, system administrators, entrepreneurs, artists, content creators, thinkers. We embrace every nationality, mindset and belief.

Want to chat? Join us on Discord https://discord.me/utopian-io

Loading...

Coin Marketplace

STEEM 0.27
TRX 0.13
JST 0.032
BTC 62983.95
ETH 2962.52
USDT 1.00
SBD 3.58