Commit 039a6b75 authored by schurade's avatar schurade

[ADD] module that paints directly in the 3D scene

parent 1512f5e4
......@@ -10,6 +10,7 @@ ADD_SUBDIRECTORY( hud )
ADD_SUBDIRECTORY( isosurfaceRaytracer )
ADD_SUBDIRECTORY( lic )
ADD_SUBDIRECTORY( marchingCubes )
ADD_SUBDIRECTORY( paintTexture )
ADD_SUBDIRECTORY( superquadricGlyphs )
ADD_SUBDIRECTORY( template )
ADD_SUBDIRECTORY( triangleMeshRenderer )
......
FILE( GLOB_RECURSE MODULES_SRC "*.cpp" "*.h" )
# Grab module name and setup target directories
GET_FILENAME_COMPONENT( MODULE_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME )
SET( MODULE_TARGET_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/modules/${MODULE_NAME} )
SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${MODULE_TARGET_DIR} )
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${MODULE_TARGET_DIR} )
SET( MODULE_DIRNAME ${MODULE_NAME} )
SET( MODULE_NAME "OWmodule_${MODULE_NAME}" ) # prefix all module names with "OWmodule_" to separate them from other libs
# Build module lib
ADD_LIBRARY( ${MODULE_NAME} SHARED ${MODULES_SRC} )
TARGET_LINK_LIBRARIES( ${MODULE_NAME} OWkernel )
# Copy local shaders to module target directory
IF( OW_COPY_SHADERS AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/shaders ) # copy shaders only if the user wants it
ADD_CUSTOM_TARGET( ${MODULE_NAME}_CopyShaders
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/shaders ${MODULE_TARGET_DIR}/shaders/
COMMENT "Copy shaders of ${MODULE_NAME}"
)
ADD_DEPENDENCIES( ${MODULE_NAME} ${MODULE_NAME}_CopyShaders )
ENDIF()
# Build unit tests
IF( OW_COMPILE_TESTS )
# This ensures that the test is copied to the module directory
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${MODULE_TARGET_DIR} )
CXXTEST_ADD_TESTS_FROM_LIST( "${MODULES_SRC}"
"OWkernel;${MODULE_NAME}"
)
# Copy fixtures if they exist
IF( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test/fixtures )
ADD_CUSTOM_TARGET( ${MODULE_NAME}_CopyFixtures
# as the "test" target runs in CMakes temporary build dir, the fixtures need to be placed there too.
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/test/fixtures ${CMAKE_BINARY_DIR}/modules/${MODULE_DIRNAME}/fixtures/
COMMENT "Copy fixtures of ${MODULE_NAME}"
)
ADD_DEPENDENCIES( ${MODULE_NAME} ${MODULE_NAME}_CopyFixtures )
ENDIF( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test/fixtures )
ENDIF( OW_COMPILE_TESTS )
This diff is collapsed.
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV-Leipzig and CNCF-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WMPAINTTEXTURE_H
#define WMPAINTTEXTURE_H
#include <queue>
#include <string>
#include <vector>
#include <osg/Geode>
#include "../../kernel/WModule.h"
#include "../../kernel/WModuleInputData.h"
#include "../../kernel/WModuleOutputData.h"
#include "../../dataHandler/WDataSetScalar.h"
#include "../../dataHandler/WValueSet.h"
/**
* Someone should add some documentation here.
* Probably the best person would be the module's
* creator, i.e. "schurade".
*
* This is only an empty template for a new module. For
* an example module containing many interesting concepts
* and extensive documentation have a look at "src/modules/template"
*
* \ingroup modules
*/
class WMPaintTexture: public WModule
{
public:
/**
*
*/
WMPaintTexture();
/**
*
*/
virtual ~WMPaintTexture();
/**
* Gives back the name of this module.
* \return the module's name.
*/
virtual const std::string getName() const;
/**
* Gives back a description of this module.
* \return description to module.
*/
virtual const std::string getDescription() const;
/**
* Due to the prototype design pattern used to build modules, this method returns a new instance of this method. NOTE: it
* should never be initialized or modified in some other way. A simple new instance is required.
*
* \return the prototype used to create every module in OpenWalnut.
*/
virtual boost::shared_ptr< WModule > factory() const;
/**
* Get the icon for this module in XPM format.
*/
virtual const char** getXPMIcon() const;
protected:
/**
* Entry point after loading the module. Runs in separate thread.
*/
virtual void moduleMain();
/**
* Initialize the connectors this module is using.
*/
virtual void connectors();
/**
* Initialize the properties for this module.
*/
virtual void properties();
/**
* Callback for m_active.
*/
virtual void activate();
private:
/**
* Write property values to output dataset.
*/
void setOutputProps();
/**
* this function listens to the pick handler, if the paint flag is true it will write into the out texture
*/
boost::shared_ptr< WDataSetScalar > doPaint();
/**
* this function listens to the pick handler, if the paint flag is true it will add the paint position to the
* paint queue
*
* \param pickInfo the pickInfo object fromt he current pick
*/
void queuePaint( WPickInfo pickInfo );
/**
* creates a new dataset scalar from the output field
* TODO (schurade): this is too slow and needs to be replaced by a direct texture generation from the field
*
* \return the new dataset
*/
boost::shared_ptr< WDataSetScalar > createNewOutTexture();
/**
* Interpolation?
*/
WPropBool m_painting;
/**
* A list of pencil sizes and shapes
*/
boost::shared_ptr< WItemSelection > m_pencilSelectionsList;
/**
* Selection property for pencil size and shape
*/
WPropSelection m_pencilSelection;
/**
* specifies the value we paint into the output texture
*/
WPropInt m_paintIndex;
// the following 5 members are taken from WMData
/**
* Interpolation?
*/
WPropBool m_interpolation;
/**
* A list of color map selection types
*/
boost::shared_ptr< WItemSelection > m_colorMapSelectionsList;
/**
* Selection property for color map
*/
WPropSelection m_colorMapSelection;
/**
* Opacity value for this data.
*/
WPropInt m_opacity;
/**
* true when a new paint coordinate is added to the queue
*/
WPropBool m_queueAdded;
/**
* field that stores the new values
*/
std::vector< unsigned char > m_values;
/**
* new paint coordinates get added here
*/
std::queue< wmath::WPosition >m_paintQueue;
/**
* An input connector that accepts order 1 datasets.
*/
boost::shared_ptr< WModuleInputData< WDataSetSingle > > m_input;
/**
* An output connector for the output scalar dsataset.
*/
boost::shared_ptr< WModuleOutputData< WDataSetScalar > > m_output;
/**
* This is a pointer to the dataset the module is currently working on.
*/
boost::shared_ptr< WDataSetSingle > m_dataSet;
/**
* Point to the out dataset once it is invalid. Used to deregister from the datahandler
*/
boost::shared_ptr< WDataSetScalar > m_outDataOld;
/**
* This is a pointer to the current output.
*/
boost::shared_ptr< WDataSetScalar > m_outData;
/**
* A condition used to notify about changes in several properties.
*/
boost::shared_ptr< WCondition > m_propCondition;
};
#endif // WMPAINTTEXTURE_H
/* XPM */
static const char * paintTexture_xpm[] = {
"32 32 248 2",
" c None",
". c #683908",
"+ c #673907",
"@ c #8C5214",
"# c #6E3E08",
"$ c #673A06",
"% c #9F580C",
"& c #6E3D07",
"* c #673806",
"= c #9D570B",
"- c #8F4E09",
"; c #6A3C07",
"> c #294D84",
", c #264B84",
"' c #214B87",
") c #2A4E83",
"! c #2F4A76",
"~ c #234A84",
"{ c #26518C",
"] c #3C669E",
"^ c #7A9DC5",
"/ c #5B8ABF",
"( c #6F9AC6",
"_ c #4F81B8",
": c #4174AE",
"< c #2E5D98",
"[ c #234E8B",
"} c #204A87",
"| c #6C9ACC",
"1 c #B0C4DA",
"2 c #6090C4",
"3 c #7BA1CA",
"4 c #5386BD",
"5 c #4C81BA",
"6 c #467CB6",
"7 c #9AB6D4",
"8 c #6A96C5",
"9 c #683907",
"0 c #284C83",
"a c #547499",
"b c #576B82",
"c c #5C6979",
"d c #5B6775",
"e c #5B6878",
"f c #53677D",
"g c #46688C",
"h c #214C88",
"i c #734008",
"j c #87613D",
"k c #9B9C9C",
"l c #F2F2F2",
"m c #F9F9F9",
"n c #FDFDFD",
"o c #FCFCFC",
"p c #F5F5F5",
"q c #ABABAC",
"r c #4F5967",
"s c #683A06",
"t c #6E3D08",
"u c #BC6A13",
"v c #716A64",
"w c #FFFFFF",
"x c #FEFEFE",
"y c #FBFBFB",
"z c #FAFAFA",
"A c #8D8D8D",
"B c #6A3B07",
"C c #BB670E",
"D c #92683C",
"E c #BCBCBB",
"F c #EEEEEE",
"G c #DFDFDF",
"H c #D9D9D9",
"I c #D4D4D4",
"J c #DDDDDD",
"K c #CECECE",
"L c #606060",
"M c #693A07",
"N c #B4630D",
"O c #D57510",
"P c #755F47",
"Q c #D3D3D3",
"R c #FBFCFC",
"S c #EBEDEF",
"T c #D7DADD",
"U c #D4D5D7",
"V c #D2D2D2",
"W c #DBDBDB",
"X c #616161",
"Y c #693907",
"Z c #AC5E0D",
"` c #DB7810",
" . c #A0590B",
".. c #665A4E",
"+. c #C3D1DE",
"@. c #C3D6EA",
"#. c #DEE9F4",
"$. c #A5C2E0",
"%. c #6B97C7",
"&. c #5F8BBA",
"*. c #5882AF",
"=. c #6083AA",
"-. c #C4CED9",
";. c #5E5E5E",
">. c #827A6E",
",. c #73522E",
"'. c #A3590B",
"). c #E07B11",
"!. c #A75C0C",
"~. c #675E56",
"{. c #BED0E3",
"]. c #B6CDE7",
"^. c #CFDEEF",
"/. c #A2C0DF",
"(. c #537EAD",
"_. c #4772A0",
":. c #A7BACE",
"<. c #636669",
"[. c #888A85",
"}. c #8E8E86",
"|. c #A9875F",
"1. c #AC600D",
"2. c #673A07",
"3. c #656564",
"4. c #BFD1E5",
"5. c #ADC7E3",
"6. c #C0D4EA",
"7. c #9BBBDD",
"8. c #9AAFC7",
"9. c #71777E",
"0. c #8B8D87",
"a. c #D2D2D1",
"b. c #E6E6E6",
"c. c #9C9B95",
"d. c #7E664A",
"e. c #673906",
"f. c #636363",
"g. c #C0D3E7",
"h. c #A2BFDF",
"i. c #B0CAE4",
"j. c #96B7DB",
"k. c #8CA5C0",
"l. c #808993",
"m. c #8A8D88",
"n. c #CACBCA",
"o. c #E5E5E5",
"p. c #E3E3E3",
"q. c #A0A19D",
"r. c #D6E0EC",
"s. c #D1DEEB",
"t. c #DCE4EC",
"u. c #D5DEE6",
"v. c #C7D0DA",
"w. c #BCC7D2",
"x. c #ACB9C8",
"y. c #98AABC",
"z. c #A3B3C6",
"A. c #8E98A5",
"B. c #8A8C86",
"C. c #B5B5B3",
"D. c #E2E2E2",
"E. c #ACADAB",
"F. c #898B86",
"G. c #5F5F5F",
"H. c #F3F3F3",
"I. c #F4F4F4",
"J. c #F0F0F0",
"K. c #E9E9E9",
"L. c #D8D8D8",
"M. c #B4B4B4",
"N. c #5D5D5D",
"O. c #A1A3A0",
"P. c #A5A6A4",
"Q. c #8A8C87",
"R. c #5B5B5B",
"S. c #F7F7F7",
"T. c #EDEDED",
"U. c #C5C5C5",
"V. c #C2C2C2",
"W. c #CCCCCC",
"X. c #C4C4C4",
"Y. c #626262",
"Z. c #989995",
"`. c #F6F6F6",
" + c #9FA09D",
".+ c #5C5C5C",
"++ c #F1F1F1",
"@+ c #D5D5D5",
"#+ c #AFAFAF",
"$+ c #AEAEAE",
"%+ c #C0C0C0",
"&+ c #D0D0D0",
"*+ c #80827D",
"=+ c #E4E5E4",
"-+ c #E8E8E8",
";+ c #8A8B87",
">+ c #646464",
",+ c #B7B7B7",
"'+ c #B6B6B6",
")+ c #B5B5B5",
"!+ c #B3B3B3",
"~+ c #C6C6C6",
"{+ c #DCDCDC",
"]+ c #474747",
"^+ c #757575",
"/+ c #525252",
"(+ c #757675",
"_+ c #8B8C88",
":+ c #6C6C6C",
"<+ c #F8F8F8",
"[+ c #BFBFBF",
"}+ c #BDBDBD",
"|+ c #BBBBBB",
"1+ c #313131",
"2+ c #9B9B9B",
"3+ c #4E4E4E",
"4+ c #80807D",
"5+ c #747474",
"6+ c #EBEBEB",
"7+ c #CACACA",
"8+ c #C8C8C8",
"9+ c #C3C3C3",
"0+ c #BEBEBE",
"a+ c #B8B8B8",
"b+ c #6A6A6A",
"c+ c #171717",
"d+ c #4D4D4D",
"e+ c #515151",
"f+ c #454545",
"g+ c #000000",
"h+ c #1B1B1B",
"i+ c #2B2B2B",
"j+ c #303030",
"k+ c #3A3A3A",
"l+ c #3C3C3C",
"m+ c #ECECEC",
"n+ c #EAEAEA",
"o+ c #E7E7E7",
"p+ c #5A5A5A",
"q+ c #030303",
"r+ c #121212",
"s+ c #1E1E1E",
"t+ c #252525",
"u+ c #222222",
"v+ c #727272",
"w+ c #E1E1E1",
"x+ c #D7D7D7",
"y+ c #CDCDCD",
" . ",
" + @ # ",
" $ % & ",
" * = - ; ",
" > , ' ) ! ~ ",
" { ] ^ / ( _ : < [ ",
" } | 1 2 3 4 5 6 } ",
" } | 7 2 8 4 5 6 } ",
" 9 0 a b c d e f g h ",
" + i j k l m n o p q r ",
" s t u v o w x y z n x A ",
" + B C D E y o F G H I J K L ",
" + M N O P Q z R S T U I V W X ",
" s Y Z ` ...+.@.#.$.%.&.*.=.-.;. ",
" >.,.'.).!.B ~.{.].^./.%.&.(._.:.<. ",
" [.}.|.1.t 2.3.4.5.6.7.%.&.(._.8.9. ",
" 0.a.b.c.d.e. f.g.h.i.j.%.&.(._.k.l. ",
" m.n.o.p.q.[. X r.s.t.u.v.w.x.y.z.A. ",
" B.C.z D.E.F. G.H.I.J.K.G H I K L.M.N. ",
" O.m p.P.Q. R.S.l T.J U.V.W.K I X.Y. ",
" Z.`.b. +F. .+m ++@+#+$+$+$+%+&+&+Y. ",
" *+=+-+Z.;+ >+m o.,+'+)+M.M.!+~+{+G. ",
" ]+^+/+(+_+Q. :+<+K X.V.%+[+}+|+|+o..+ ",
" 1+.+2+Y.3+4+ 5+6+7+8+U.9+%+0+|+a+H b+ ",
" c+3+/+d+e+f+ G.L >+>+>+f.f.f.f.f.f.>+G.>+ ",
" g+h+i+j+k+l+1+ ^+++++++++J.F m+n+-+o+o.D.p+ ",
" g+g+q+r+s+t+u+ v+D.w+G J W H x+@+I V &+y+p+ ",
" .+p+p+p+p+p+p+p+p+p+p+p+p+G. ",
" ",
" ",
" ",
" "};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment