Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
4d9a8165
Commit
4d9a8165
authored
Dec 12, 2011
by
Sebastian Eichelbaum
Browse files
[PATCH] - some major patches from default
parent
bc8c21b2
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
156 additions
and
15 deletions
+156
-15
src/CMakeLists.txt
src/CMakeLists.txt
+7
-2
src/core/common/WColor.h
src/core/common/WColor.h
+37
-4
src/core/graphicsEngine/WGEViewer.cpp
src/core/graphicsEngine/WGEViewer.cpp
+3
-0
src/core/graphicsEngine/WGEViewer.h
src/core/graphicsEngine/WGEViewer.h
+3
-7
src/core/graphicsEngine/shaders/shaders/WGEShadingTools.glsl
src/core/graphicsEngine/shaders/shaders/WGEShadingTools.glsl
+103
-0
src/modules/template/WMTemplate.cpp
src/modules/template/WMTemplate.cpp
+3
-2
No files found.
src/CMakeLists.txt
View file @
4d9a8165
...
...
@@ -142,7 +142,8 @@ SET( CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -DDEBUG -O2" CACHE STRING "" FORCE )
# Eigen3 specifics
# NOTE: this is included in ext. But we need to set several definitions to make this work on 32 Bit machines due to alignment problems
ADD_DEFINITIONS
(
-DEIGEN_DONT_VECTORIZE -DEIGEN_DONT_ALIGN -DEIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT
)
SET
(
EIGEN3_DEFINES -DEIGEN_DONT_VECTORIZE -DEIGEN_DONT_ALIGN -DEIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT
)
ADD_DEFINITIONS
(
${
EIGEN3_DEFINES
}
)
# ---------------------------------------------------------------------------------------------------------------------------------------------------
#
...
...
@@ -239,6 +240,10 @@ IF( CMAKE_GENERATOR MATCHES "Visual Studio" )
ENDIF
()
ENDIF
()
FIND_PACKAGE
(
OpenSceneGraph
${
MIN_OSG_VERSION
}
REQUIRED osgDB osgUtil osgGA osgViewer osgSim osgWidget osgText
)
IF
(
OPENSCENEGRAPH_FOUND
)
INCLUDE_DIRECTORIES
(
${
OPENSCENEGRAPH_INCLUDE_DIRS
}
)
ENDIF
()
# -----------------------------------------------------------------------------------------------------------------------------------------------
# Eigen3, at least 3.0.0
...
...
@@ -357,7 +362,7 @@ ADD_CUSTOM_TARGET( doc
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# SETUP_STYLECHECKER adds targets for each lib which then add theirself to this target
ADD_CUSTOM_TARGET
(
stylecheck
DEPENDS numCores
)
ADD_CUSTOM_TARGET
(
stylecheck
)
# ---------------------------------------------------------------------------------------------------------------------------------------------------
#
...
...
src/core/common/WColor.h
View file @
4d9a8165
...
...
@@ -25,8 +25,6 @@
#ifndef WCOLOR_H
#define WCOLOR_H
#include <iostream>
#include <osg/Vec4>
#include <osg/io_utils> // for the operator<< and operator>> for Vec4
...
...
@@ -65,12 +63,47 @@ WColor OWCOMMON_EXPORT inverseColor( const WColor& other );
namespace
defaultColor
{
// \cond Suppress_Doxygen
static
const
WColor
GREEN
(
0.
0
,
1
.0
,
0.0
,
1.0
);
//!< Default for
green
static
const
WColor
DARKRED
(
0.
5
,
0
.0
,
0.0
,
1.0
);
//!< Default for
dark red
static
const
WColor
RED
(
1.0
,
0.0
,
0.0
,
1.0
);
//!< Default for red
static
const
WColor
LIGHTRED
(
1.0
,
0.5
,
0.5
,
1.0
);
//!< Default for lighter red
static
const
WColor
DARKGREEN
(
0.0
,
0.5
,
0.0
,
1.0
);
//!< Default for a dark green
static
const
WColor
GREEN
(
0.0
,
1.0
,
0.0
,
1.0
);
//!< Default for green
static
const
WColor
LIGHTGREEN
(
0.5
,
1.0
,
0.5
,
1.0
);
//!< Default for lighter green
static
const
WColor
DARKBLUE
(
0.0
,
0.0
,
0.5
,
1.0
);
//!< Default for blue
static
const
WColor
BLUE
(
0.0
,
0.0
,
1.0
,
1.0
);
//!< Default for blue
static
const
WColor
LIGHTBLUE
(
0.5
,
0.5
,
1.0
,
1.0
);
//!< Default for blue
static
const
WColor
DARKYELLOW
(
0.5
,
0.5
,
0.0
,
1.0
);
//!< Default for yellow
static
const
WColor
YELLOW
(
1.0
,
1.0
,
0.0
,
1.0
);
//!< Default for yellow
static
const
WColor
LIGHTYELLOW
(
1.0
,
1.0
,
0.5
,
1.0
);
//!< Default for yellow
static
const
WColor
ORANGE
(
1.0
,
0.5
,
0.0
,
1.0
);
//!< Default for orange
static
const
WColor
VIOLET
(
0.5
,
0.0
,
0.5
,
1.0
);
//!< Default for violet (darker pink)
static
const
WColor
PINK
(
1.0
,
0.0
,
1.0
,
1.0
);
//!< Default for pink
static
const
WColor
TEAL
(
0.0
,
0.5
,
0.5
,
1.0
);
//!< Default for darker cyan (teal)
static
const
WColor
CYAN
(
0.0
,
1.0
,
1.0
,
1.0
);
//!< Default for cyan
static
const
WColor
BLACK
(
0.0
,
0.0
,
0.0
,
1.0
);
//!< Default for black
static
const
WColor
WHITE
(
1.0
,
1.0
,
1.0
,
1.0
);
//!< Default for black
static
const
WColor
GRAY25
(
0.25
,
0.25
,
0.25
,
1.0
);
//!< Default for gray
static
const
WColor
GRAY50
(
0.5
,
0.5
,
0.5
,
1.0
);
//!< Default for gray
static
const
WColor
GRAY75
(
0.75
,
0.75
,
0.75
,
1.0
);
//!< Default for gray
static
const
WColor
WHITE
(
1.0
,
1.0
,
1.0
,
1.0
);
//!< Default for white
// \endcond
/**
* The size of the default palette
*/
static
const
size_t
DefaultPaletteSize
=
22
;
/**
* This array is a simple palette definition containing the above colors. This palette is probably not very usable for all your special
* needs. DO NOT add thousand other palettes here. Define them for yourself, in your module.
*/
extern
const
WColor
DefaultPalette
[
22
];
}
#endif // WCOLOR_H
src/core/graphicsEngine/WGEViewer.cpp
View file @
4d9a8165
...
...
@@ -43,11 +43,14 @@
#include "exceptions/WGEInitFailed.h"
#include "WGE2DManipulator.h"
#include "WGEGroupNode.h"
#include "WGENoOpManipulator.h"
#include "WGEZoomTrackballManipulator.h"
#include "WPickHandler.h"
#include "../common/WConditionOneShot.h"
#include "../common/WThreadedRunner.h"
#include "WGEViewer.h"
WGEViewer
::
WGEViewer
(
std
::
string
name
,
osg
::
ref_ptr
<
osg
::
Referenced
>
wdata
,
int
x
,
int
y
,
...
...
src/core/graphicsEngine/WGEViewer.h
View file @
4d9a8165
...
...
@@ -32,11 +32,8 @@
#include <osg/Node>
#include <osg/Version>
#include <osgGA/DriveManipulator>
#include <osgGA/FlightManipulator>
#include <osgGA/TerrainManipulator>
#include <osgGA/UFOManipulator>
#include <osgViewer/View>
#include <osgViewer/Viewer>
// OSG interface changed in 2.9.7, to make it compile also with those versions we do this:
// OSG_MIN_VERSION_REQUIRED(2, 9, 8) macro is not available in e.g. OSG 2.8.1, hence we use the old way
...
...
@@ -53,13 +50,12 @@
#include "../common/WColor.h"
#include "../common/WFlag.h"
#include "../common/WThreadedRunner.h"
#include "WExportWGE.h"
#include "WGECamera.h"
#include "WGEGraphicsWindow.h"
#include "
WGEGroupNode
.h"
class
WGEGroupNode
;
#include "WGEScreenCapture.h"
#include "
WPickHandler
.h"
class
WPickHandler
;
#include "animation/WGEAnimationManipulator.h"
/**
...
...
src/core/graphicsEngine/shaders/shaders/WGEShadingTools.glsl
View file @
4d9a8165
...
...
@@ -206,6 +206,109 @@ float blinnPhongIlluminationIntensity( in vec3 normal )
return
blinnPhongIlluminationIntensity
(
wge_DefaultLightIntensity
,
normal
);
}
/**
* Function to calculate lighting intensity for a matte (non-specular) Phong illumination.
*
* \param ambient materials ambient color
* \param diffuse materials diffuse color
* \param lightColor the light color
* \param ambientLight the ambient light color
* \param normalDir the normal
* \param viewDir viewing direction
* \param lightDir light direction
*
* \return the color.
*/
vec4
mattePhongIllumination
(
vec3
ambient
,
vec3
diffuse
,
vec3
lightColor
,
vec3
ambientLight
,
vec3
normalDir
,
vec3
viewDir
,
vec3
lightDir
)
{
vec3
H
=
normalize
(
lightDir
+
viewDir
);
// compute ambient term
vec3
ambientV
=
ambient
*
ambientLight
;
// compute diffuse term
float
diffuseLight
=
max
(
dot
(
lightDir
,
normalDir
),
0
.
0
);
vec3
diffuseV
=
diffuse
*
diffuseLight
;
return
vec4
(
ambientV
+
diffuseV
*
lightColor
,
1
.
0
);
}
/**
* Function to calculate lighting intensity for a matte (non-specular) Phong illumination.
* It is basically the same as blinnPhongIllumination function above. But it is faster if you just need
* the intensity.
*
* \param ambient materials ambient intensity
* \param diffuse materials diffuse intensity
* \param specular materials specular intensity
* \param shininess material shininess
* \param lightIntensity the light intensity
* \param ambientIntensity the ambient light intensity
* \param normalDir the normal
* \param viewDir viewing direction
* \param lightDir light direction
*
* \return the light intensity.
*/
float
mattePhongIlluminationIntensity
(
float
ambient
,
float
diffuse
,
float
lightIntensity
,
float
ambientIntensity
,
vec3
normalDir
,
vec3
viewDir
,
vec3
lightDir
)
{
vec3
H
=
normalize
(
lightDir
+
viewDir
);
// compute ambient term
float
ambientV
=
ambient
*
ambientIntensity
;
// compute diffuse term
float
diffuseLight
=
max
(
dot
(
lightDir
,
normalDir
),
0
.
0
);
float
diffuseV
=
diffuse
*
diffuseLight
;
return
ambientV
+
diffuseV
*
lightIntensity
;
}
/**
* Function to calculate lighting intensity for a matte (non-specular) Phong illumination.
* Any specular or shininess given with the parameters will be ignored.
* It is basically the same as blinnPhongIllumination function above. But it is faster if you just need
* the intensity.
*
* \param parameter the wge_LightIntensityParameter defining material and light
* \param normal the normal. Needs to be normalized.
*
* \return lighting intensity.
*/
float
mattePhongIlluminationIntensity
(
in
wge_LightIntensityParameter
parameter
,
in
vec3
normal
)
{
return
mattePhongIlluminationIntensity
(
parameter
.
materialAmbient
,
parameter
.
materialDiffuse
,
parameter
.
lightDiffuse
,
parameter
.
lightAmbient
,
normal
,
parameter
.
viewDirection
,
parameter
.
lightPosition
);
}
/**
* Function to calculate lighting intensity for a matte (non-specular) Phong illumination.
* It is basically the same as blinnPhongIllumination function above. But it is faster if you just need
* the intensity. This uses the wge_DefaultLightIntensity without the specular and shininess.
*
* \param normal the normal. Must be normalized beforehand
*
* \return the light intensity
*/
float
mattePhongIlluminationIntensity
(
in
vec3
normal
)
{
wge_LightIntensityParameter
noSpecular
=
wge_DefaultLightIntensity
;
noSpecular
.
materialShinines
=
0
.
0
;
noSpecular
.
materialSpecular
=
0
.
0
;
return
mattePhongIlluminationIntensity
(
noSpecular
,
normal
);
}
/**
* This illumination technique is from "Jens Krüger and Rüdiger Westermann - EFFICIENT STIPPLE RENDERING". It is a non-linear illumination model
* which only handles ambient and diffuse components. The parameter alpha determines how much the diffuse light should depend on the orientation
...
...
src/modules/template/WMTemplate.cpp
View file @
4d9a8165
...
...
@@ -386,7 +386,8 @@ void WMTemplate::moduleMain()
// One note about "setResetable": It might happen, that a condition fires and your thread does not currently waits on it. This would mean,
// that your thread misses the event. The resettable flag for those condition sets can help here. Whenever a condition, managed by the
// condition set, fires, the moduleState variable remembers it. So, the next call to m_moduleState.wait() will immediately return and reset
// the "memory" of the moduleState. For more details, see: http://berkeley.informatik.uni-leipzig.de/trac/ow-public/wiki/HowtoWaitCorrectly
// the "memory" of the moduleState. For more details, see:
// http://www.openwalnut.org/projects/openwalnut/wiki/MultithreadingHowto#How-to-wait-correctly
// Signal ready state. Now your module can be connected by the container, which owns the module.
ready
();
...
...
@@ -709,7 +710,7 @@ void WMTemplate::TranslateCallback::operator()( osg::Node* node, osg::NodeVisito
}
bool
WMTemplate
::
StringLength
::
accept
(
boost
::
shared_ptr
<
WPropertyVariable
<
WPVBaseTypes
::
PV_STRING
>
>
/* property */
,
WPVBaseTypes
::
PV_STRING
value
)
const
WPVBaseTypes
::
PV_STRING
&
value
)
{
// This method gets called every time the m_aString property is going to be changed. It can decide whether the new value is valid or not. If
// the method returns true, the new value is set. If it returns false, the value is rejected.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment