From 5e6f062b1bdd659eec5af7ce904404c454a5fe2e Mon Sep 17 00:00:00 2001 From: gouarin Date: Sun, 28 Jan 2018 07:05:11 +0100 Subject: [PATCH] add default cpp classes which are not generated --- xthreejs/xthreejs/base/xenums.hpp | 210 +++++++++++++++++++++++ xthreejs/xthreejs/base/xrender.hpp | 219 ++++++++++++++++++++++++ xthreejs/xthreejs/base/xthree.hpp | 74 ++++++++ xthreejs/xthreejs/base/xthree_types.hpp | 15 ++ xthreejs/xthreejs/core/xrenderer.hpp | 102 +++++++++++ 5 files changed, 620 insertions(+) create mode 100644 xthreejs/xthreejs/base/xenums.hpp create mode 100644 xthreejs/xthreejs/base/xrender.hpp create mode 100644 xthreejs/xthreejs/base/xthree.hpp create mode 100644 xthreejs/xthreejs/base/xthree_types.hpp create mode 100644 xthreejs/xthreejs/core/xrenderer.hpp diff --git a/xthreejs/xthreejs/base/xenums.hpp b/xthreejs/xthreejs/base/xenums.hpp new file mode 100644 index 00000000..e42d4d7c --- /dev/null +++ b/xthreejs/xthreejs/base/xenums.hpp @@ -0,0 +1,210 @@ +#pragma once + +// +// This file auto-generated with generate-enums.js +// Date: Thu Jan 25 2018 04:46:33 GMT+0100 (CET) +// + +#include "xwidgets/xeither.hpp" + +namespace xthree{ + namespace xenums{ + + auto Equations = XEITHER( + "AddEquation", + "SubtractEquation", + "ReverseSubtractEquation", + "MinEquation", + "MaxEquation", + ); + + auto BlendFactors = XEITHER( + "ZeroFactor", + "OneFactor", + "SrcColorFactor", + "OneMinusSrcColorFactor", + "SrcAlphaFactor", + "OneMinusSrcAlphaFactor", + "DstAlphaFactor", + "OneMinusDstAlphaFactor", + "DstColorFactor", + "OneMinusDstColorFactor", + "SrcAlphaSaturateFactor", + ); + + auto Side = XEITHER( + "FrontSide", + "BackSide", + "DoubleSide", + ); + + auto Shading = XEITHER( + "FlatShading", + "SmoothShading", + ); + + auto Colors = XEITHER( + "NoColors", + "FaceColors", + "VertexColors", + ); + + auto BlendingMode = XEITHER( + "NoBlending", + "NormalBlending", + "AdditiveBlending", + "SubtractiveBlending", + "MultiplyBlending", + "CustomBlending", + ); + + auto DepthMode = XEITHER( + "NeverDepth", + "AlwaysDepth", + "LessDepth", + "LessEqualDepth", + "EqualDepth", + "GreaterEqualDepth", + "GreaterDepth", + "NotEqualDepth", + ); + + auto Operations = XEITHER( + "MultiplyOperation", + "MixOperation", + "AddOperation", + ); + + auto MappingModes = XEITHER( + "UVMapping", + "CubeReflectionMapping", + "CubeRefractionMapping", + "EquirectangularReflectionMapping", + "EquirectangularRefractionMapping", + "SphericalReflectionMapping", + "CubeUVReflectionMapping", + "CubeUVRefractionMapping", + ); + + auto WrappingModes = XEITHER( + "RepeatWrapping", + "ClampToEdgeWrapping", + "MirroredRepeatWrapping", + ); + + auto Filters = XEITHER( + "NearestFilter", + "NearestMipMapNearestFilter", + "NearestMipMapLinearFilter", + "LinearFilter", + "LinearMipMapNearestFilter", + "LinearMipMapLinearFilter", + ); + + auto DataTypes = XEITHER( + "UnsignedByteType", + "ByteType", + "ShortType", + "UnsignedShortType", + "IntType", + "UnsignedIntType", + "FloatType", + "HalfFloatType", + ); + + auto PixelTypes = XEITHER( + "UnsignedShort4444Type", + "UnsignedShort5551Type", + "UnsignedShort565Type", + "UnsignedInt248Type", + ); + + auto PixelFormats = XEITHER( + "AlphaFormat", + "RGBFormat", + "RGBAFormat", + "LuminanceFormat", + "LuminanceAlphaFormat", + "DepthFormat", + "DepthStencilFormat", + ); + + auto DepthFormats = XEITHER( + "DepthFormat", + "DepthStencilFormat", + ); + + auto CompressedTextureFormats = XEITHER( + "RGB_S3TC_DXT1_Format", + "RGBA_S3TC_DXT1_Format", + "RGBA_S3TC_DXT3_Format", + "RGBA_S3TC_DXT5_Format", + "RGB_PVRTC_4BPPV1_Format", + "RGB_PVRTC_2BPPV1_Format", + "RGBA_PVRTC_4BPPV1_Format", + "RGBA_PVRTC_2BPPV1_Format", + "RGB_ETC1_Format", + ); + + auto TextureEncodings = XEITHER( + "LinearEncoding", + "sRGBEncoding", + "RGBEEncoding", + "LogLuvEncoding", + "RGBM7Encoding", + "RGBM16Encoding", + "RGBDEncoding", + "GammaEncoding", + ); + + auto CullFaceModes = XEITHER( + "CullFaceNone", + "CullFaceBack", + "CullFaceFront", + "CullFaceFrontBack", + ); + + auto FrontFaceDirection = XEITHER( + "FrontFaceDirectionCW", + "FrontFaceDirectionCCW", + ); + + auto ShadowTypes = XEITHER( + "BasicShadowMap", + "PCFShadowMap", + "PCFSoftShadowMap", + ); + + auto ToneMappings = XEITHER( + "NoToneMapping", + "LinearToneMapping", + "ReinhardToneMapping", + "Uncharted2ToneMapping", + "CineonToneMapping", + ); + + auto LoopModes = XEITHER( + "LoopOnce", + "LoopRepeat", + "LoopPingPong", + ); + + auto InterpolationModes = XEITHER( + "InterpolateDiscrete", + "InterpolateLinear", + "InterpolateSmooth", + ); + + auto EndingModes = XEITHER( + "ZeroCurvatureEnding", + "ZeroSlopeEnding", + "WrapAroundEnding", + ); + + auto DrawModes = XEITHER( + "TrianglesDrawMode", + "TriangleStripDrawMode", + "TriangleFanDrawMode", + ); + } +} \ No newline at end of file diff --git a/xthreejs/xthreejs/base/xrender.hpp b/xthreejs/xthreejs/base/xrender.hpp new file mode 100644 index 00000000..c0a29839 --- /dev/null +++ b/xthreejs/xthreejs/base/xrender.hpp @@ -0,0 +1,219 @@ +#ifndef XTHREE_RENDER_HPP +#define XTHREE_RENDER_HPP + +#include + +#include "xwidgets/xmaterialize.hpp" +#include "xwidgets/xobject.hpp" +#include "xwidgets/xcolor.hpp" +#include "xwidgets/xholder.hpp" + +#include "xenums.hpp" +#include "../math/xplane_autogen.hpp" +#include "../renderers/webgl/xwebgl_shadow_map_autogen.hpp" + +namespace xthree +{ + + // + // xRenderWidget declaration + // + + template + class xRenderWidget : public xw::xwidget + { + public: + + using base_type = xw::xwidget; + using derived_type = D; + + xeus::xjson get_state() const; + void apply_patch(const xeus::xjson& patch); + + XPROPERTY(int, derived_type, _width, 200); + XPROPERTY(int, derived_type, _height, 200); + XPROPERTY(bool, derived_type, _antialias, false); + + XPROPERTY(bool, derived_type, autoClear, true); + XPROPERTY(bool, derived_type, autoClearColor, true); + XPROPERTY(bool, derived_type, autoClearDepth, true); + XPROPERTY(bool, derived_type, autoClearStencil, true); + XPROPERTY(std::vector, derived_type, clippingPlanes); + XPROPERTY(double, derived_type, gammaFactor, 2.0); + XPROPERTY(bool, derived_type, gammaInput, false); + XPROPERTY(bool, derived_type, gammaOutput, false); + XPROPERTY(bool, derived_type, localClippingEnabled, false); + XPROPERTY(int, derived_type, maxMorphTargets, 8); + XPROPERTY(int, derived_type, maxMorphNormals, 4); + XPROPERTY(bool, derived_type, physicallyCorrectLights, false); + XPROPERTY(webgl_shadow_map, derived_type, shadowMap, webgl_shadow_map()); + XPROPERTY(bool, derived_type, sortObject, true); + XPROPERTY(std::string, derived_type, toneMapping, "LinearToneMapping", xenums::ToneMappings); + XPROPERTY(double, derived_type, toneMappingExposure, 1.0); + XPROPERTY(double, derived_type, toneMappingWhitePoint, 1.0); + + XPROPERTY(xw::html_color, derived_type, clearColor, "#000000"); + XPROPERTY(double, derived_type, clearOpacity, 1.0); + + protected: + + xRenderWidget(); + + using base_type::base_type; + + private: + + void set_defaults(); + }; + + // + // xRenderWidget implementation + // + + template + inline void xRenderWidget::apply_patch(const xeus::xjson& patch) + { + base_type::apply_patch(patch); + + XOBJECT_SET_PROPERTY_FROM_PATCH(_width, patch); + XOBJECT_SET_PROPERTY_FROM_PATCH(_height, patch); + XOBJECT_SET_PROPERTY_FROM_PATCH(_antialias, patch); + XOBJECT_SET_PROPERTY_FROM_PATCH(autoClear, patch); + XOBJECT_SET_PROPERTY_FROM_PATCH(autoClearColor, patch); + XOBJECT_SET_PROPERTY_FROM_PATCH(autoClearDepth, patch); + XOBJECT_SET_PROPERTY_FROM_PATCH(autoClearStencil, patch); + XOBJECT_SET_PROPERTY_FROM_PATCH(clippingPlanes, patch); + XOBJECT_SET_PROPERTY_FROM_PATCH(gammaFactor, patch); + XOBJECT_SET_PROPERTY_FROM_PATCH(gammaInput, patch); + XOBJECT_SET_PROPERTY_FROM_PATCH(gammaOutput, patch); + XOBJECT_SET_PROPERTY_FROM_PATCH(localClippingEnabled, patch); + XOBJECT_SET_PROPERTY_FROM_PATCH(maxMorphTargets, patch); + XOBJECT_SET_PROPERTY_FROM_PATCH(maxMorphNormals, patch); + XOBJECT_SET_PROPERTY_FROM_PATCH(physicallyCorrectLights, patch); + XOBJECT_SET_PROPERTY_FROM_PATCH(shadowMap, patch); + XOBJECT_SET_PROPERTY_FROM_PATCH(sortObject, patch); + XOBJECT_SET_PROPERTY_FROM_PATCH(toneMapping, patch); + XOBJECT_SET_PROPERTY_FROM_PATCH(toneMappingExposure, patch); + XOBJECT_SET_PROPERTY_FROM_PATCH(toneMappingWhitePoint, patch); + XOBJECT_SET_PROPERTY_FROM_PATCH(clearColor, patch); + XOBJECT_SET_PROPERTY_FROM_PATCH(clearOpacity, patch); + } + + template + inline xeus::xjson xRenderWidget::get_state() const + { + xeus::xjson state = base_type::get_state(); + + XOBJECT_SET_PATCH_FROM_PROPERTY(_width, state); + XOBJECT_SET_PATCH_FROM_PROPERTY(_height, state); + XOBJECT_SET_PATCH_FROM_PROPERTY(_antialias, state); + XOBJECT_SET_PATCH_FROM_PROPERTY(autoClear, state); + XOBJECT_SET_PATCH_FROM_PROPERTY(autoClearColor, state); + XOBJECT_SET_PATCH_FROM_PROPERTY(autoClearDepth, state); + XOBJECT_SET_PATCH_FROM_PROPERTY(autoClearStencil, state); + XOBJECT_SET_PATCH_FROM_PROPERTY(clippingPlanes, state); + XOBJECT_SET_PATCH_FROM_PROPERTY(gammaFactor, state); + XOBJECT_SET_PATCH_FROM_PROPERTY(gammaInput, state); + XOBJECT_SET_PATCH_FROM_PROPERTY(gammaOutput, state); + XOBJECT_SET_PATCH_FROM_PROPERTY(localClippingEnabled, state); + XOBJECT_SET_PATCH_FROM_PROPERTY(maxMorphTargets, state); + XOBJECT_SET_PATCH_FROM_PROPERTY(maxMorphNormals, state); + XOBJECT_SET_PATCH_FROM_PROPERTY(physicallyCorrectLights, state); + XOBJECT_SET_PATCH_FROM_PROPERTY(shadowMap, state); + XOBJECT_SET_PATCH_FROM_PROPERTY(sortObject, state); + XOBJECT_SET_PATCH_FROM_PROPERTY(toneMapping, state); + XOBJECT_SET_PATCH_FROM_PROPERTY(toneMappingExposure, state); + XOBJECT_SET_PATCH_FROM_PROPERTY(toneMappingWhitePoint, state); + XOBJECT_SET_PATCH_FROM_PROPERTY(clearColor, state); + XOBJECT_SET_PATCH_FROM_PROPERTY(clearOpacity, state); + return state; + } + + template + inline xRenderWidget::xRenderWidget() + : base_type() + { + set_defaults(); + } + + template + inline void xRenderWidget::set_defaults() + { + this->_model_module() = "jupyter-threejs"; + this->_model_module_version() = "1.0.0-beta.3"; + this->_view_module() = "jupyter-threejs"; + this->_view_module_version() = "1.0.0-beta.3"; + + } + + // + // xPreview declaration + // + + template + class xPreview : public xRenderWidget + { + public: + + using base_type = xRenderWidget; + using derived_type = D; + + using child_type = xw::xholder; + + xeus::xjson get_state() const; + void apply_patch(const xeus::xjson& patch); + + XPROPERTY(bool, derived_type, _flat, false); + XPROPERTY(bool, derived_type, _wire, false); + XPROPERTY(child_type, derived_type, child); + + xPreview(const child_type&); + + private: + + void set_defaults(); + }; + + using preview = xw::xmaterialize; + using preview_generator = xw::xgenerator; + + // + // xPreview implementation + // + + template + inline void xPreview::apply_patch(const xeus::xjson& patch) + { + base_type::apply_patch(patch); + + XOBJECT_SET_PROPERTY_FROM_PATCH(_flat, patch); + XOBJECT_SET_PROPERTY_FROM_PATCH(_wire, patch); + XOBJECT_SET_PROPERTY_FROM_PATCH(child, patch); + } + + template + inline xeus::xjson xPreview::get_state() const + { + xeus::xjson state = base_type::get_state(); + XOBJECT_SET_PATCH_FROM_PROPERTY(_flat, state); + XOBJECT_SET_PATCH_FROM_PROPERTY(_wire, state); + XOBJECT_SET_PATCH_FROM_PROPERTY(child, state); + return state; + } + + template + inline xPreview::xPreview(const child_type& child_) + : base_type() + { + this->child() = child_; + set_defaults(); + } + + template + inline void xPreview::set_defaults() + { + this->_model_name() = "PreviewModel"; + this->_view_name() = "PreviewView"; + } +} +#endif \ No newline at end of file diff --git a/xthreejs/xthreejs/base/xthree.hpp b/xthreejs/xthreejs/base/xthree.hpp new file mode 100644 index 00000000..344db329 --- /dev/null +++ b/xthreejs/xthreejs/base/xthree.hpp @@ -0,0 +1,74 @@ +#ifndef XTHREE_THREE_HPP +#define XTHREE_THREE_HPP + +#include + +#include "xwidgets/xmaterialize.hpp" +#include "xwidgets/xobject.hpp" + +namespace xthree +{ + + // + // xthree_widget declaration + // + + template + class xthree_widget : public xw::xobject + { + public: + + using base_type = xw::xobject; + using derived_type = D; + + xeus::xjson get_state() const; + void apply_patch(const xeus::xjson& patch); + + protected: + + xthree_widget(); + + using base_type::base_type; + + private: + + bool _previewable = true; + void set_defaults(); + }; + + using three_widget = xw::xmaterialize; + using three_widget_generator = xw::xgenerator; + + // + // xthree_widget implementation + // + + template + inline void xthree_widget::apply_patch(const xeus::xjson& patch) + { + base_type::apply_patch(patch); + } + + template + inline xeus::xjson xthree_widget::get_state() const + { + return base_type::get_state(); + } + + template + inline xthree_widget::xthree_widget() + : base_type() + { + set_defaults(); + } + + template + inline void xthree_widget::set_defaults() + { + this->_model_module() = "jupyter-threejs"; + this->_model_module_version() = "1.0.0-beta.3"; + this->_view_module() = ""; + this->_view_module_version() = ""; + } +} +#endif \ No newline at end of file diff --git a/xthreejs/xthreejs/base/xthree_types.hpp b/xthreejs/xthreejs/base/xthree_types.hpp new file mode 100644 index 00000000..fac29776 --- /dev/null +++ b/xthreejs/xthreejs/base/xthree_types.hpp @@ -0,0 +1,15 @@ +#ifndef XTHREE_THREE_TYPES_HPP +#define XTHREE_THREE_TYPES_HPP + +#include + +namespace xthree{ + using vector2 = std::array; + using vector3 = std::array; + using vector4 = std::array; + + using matrix3 = std::array; + using matrix4 = std::array; +} + +#endif diff --git a/xthreejs/xthreejs/core/xrenderer.hpp b/xthreejs/xthreejs/core/xrenderer.hpp new file mode 100644 index 00000000..d8497c48 --- /dev/null +++ b/xthreejs/xthreejs/core/xrenderer.hpp @@ -0,0 +1,102 @@ +#ifndef XTHREE_RENDERER_HPP +#define XTHREE_RENDERER_HPP + +#include "xtl/xoptional.hpp" +#include "xwidgets/xeither.hpp" +#include "xwidgets/xwidget.hpp" + +#include "../base/xenums.hpp" +#include "../base/xthree_types.hpp" +#include "../base/xthree.hpp" +#include "../base/xrender.hpp" +#include "../scenes/xscene_autogen.hpp" +#include "../cameras/xcamera_autogen.hpp" +#include "../controls/xcontrols_autogen.hpp" + +namespace xthree +{ + // + // renderer declaration + // + + template + class xrenderer : public xRenderWidget + { + public: + + using base_type = xRenderWidget; + using derived_type = D; + + xeus::xjson get_state() const; + void apply_patch(const xeus::xjson& patch); + + XPROPERTY(int, derived_type, width, 200); + XPROPERTY(int, derived_type, height, 200); + XPROPERTY(xw::xholder, derived_type, scene); + XPROPERTY(xw::xholder, derived_type, camera); + XPROPERTY(std::vector>, derived_type, controls); + //XPROPERTY(effect, derived_type, effect = Instance(Effect, allow_none=True).tag(sync=True, **widget_serialization) + XPROPERTY(xw::html_color, derived_type, background, "black"); + XPROPERTY(double, derived_type, background_opacity, 1.); + + protected: + + xrenderer(); + + private: + + void set_defaults(); + }; + + using renderer = xw::xmaterialize; + + using renderer_generator = xw::xgenerator; + + // + // renderer implementation + // + + template + inline void xrenderer::apply_patch(const xeus::xjson& patch) + { + base_type::apply_patch(patch); + + XOBJECT_SET_PROPERTY_FROM_PATCH(width, patch); + XOBJECT_SET_PROPERTY_FROM_PATCH(height, patch); + XOBJECT_SET_PROPERTY_FROM_PATCH(scene, patch); + XOBJECT_SET_PROPERTY_FROM_PATCH(camera, patch); + XOBJECT_SET_PROPERTY_FROM_PATCH(controls, patch); + XOBJECT_SET_PROPERTY_FROM_PATCH(background, patch); + XOBJECT_SET_PROPERTY_FROM_PATCH(background_opacity, patch); + } + + template + inline xeus::xjson xrenderer::get_state() const + { + xeus::xjson state = base_type::get_state(); + + XOBJECT_SET_PATCH_FROM_PROPERTY(width, state); + XOBJECT_SET_PATCH_FROM_PROPERTY(height, state); + XOBJECT_SET_PATCH_FROM_PROPERTY(scene, state); + XOBJECT_SET_PATCH_FROM_PROPERTY(camera, state); + XOBJECT_SET_PATCH_FROM_PROPERTY(controls, state); + XOBJECT_SET_PATCH_FROM_PROPERTY(background, state); + XOBJECT_SET_PATCH_FROM_PROPERTY(background_opacity, state); + return state; + } + + template + inline xrenderer::xrenderer() + : base_type() + { + set_defaults(); + } + + template + inline void xrenderer::set_defaults() + { + this->_model_name() = "RendererModel"; + this->_view_name() = "RendererView"; + } +} +#endif \ No newline at end of file