From cd8425ee7a2f18a2abad53659093f3b214905eca Mon Sep 17 00:00:00 2001 From: moethu Date: Wed, 1 Jul 2020 12:08:17 +0200 Subject: [PATCH 1/2] added first camera and scene implementation --- SketchUpNET/Camera.cpp | 87 ++++++++++++++++++++++ SketchUpNET/Camera.h | 21 ++++++ SketchUpNET/Scene.cpp | 96 +++++++++++++++++++++++++ SketchUpNET/Scene.h | 21 ++++++ SketchUpNET/SketchUpNET.vcxproj | 4 ++ SketchUpNET/SketchUpNET.vcxproj.filters | 12 ++++ 6 files changed, 241 insertions(+) create mode 100644 SketchUpNET/Camera.cpp create mode 100644 SketchUpNET/Camera.h create mode 100644 SketchUpNET/Scene.cpp create mode 100644 SketchUpNET/Scene.h diff --git a/SketchUpNET/Camera.cpp b/SketchUpNET/Camera.cpp new file mode 100644 index 0000000..48f2383 --- /dev/null +++ b/SketchUpNET/Camera.cpp @@ -0,0 +1,87 @@ +/* + +SketchUpNET - a C++ Wrapper for the Trimble(R) SketchUp(R) C API +Copyright(C) 2015, Autor: Maximilian Thumfart + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "utilities.h" +#include "Vector.h" +#include "Vertex.h" + +#pragma once + +using namespace System; +using namespace System::Collections; +using namespace System::Collections::Generic; + +namespace SketchUpNET +{ + public ref class Camera + { + public: + + Vector^ Up; + Vertex^ Position; + Vertex^ Target; + bool Perspective; + double FOV; + + Camera(Vertex ^ position, Vertex ^ target, Vector^ up, bool perspective, double fov) + { + this->Up = up; + this->Position = position; + this->Target = target; + this->FOV = fov; + this->Perspective = perspective; + }; + + Camera() {}; + internal: + static Camera^ FromSU(SUCameraRef cam) + { + SUPoint3D pos = SU_INVALID; + SUPoint3D target = SU_INVALID; + SUVector3D up = SU_INVALID; + SUCameraGetOrientation(cam, &pos, &target, &up); + + + double fov = 0; + SUCameraGetPerspectiveFrustumFOV(cam, &fov); + bool persp = true; + SUCameraGetPerspective(cam, &persp); + + Camera^ c = gcnew Camera(Vertex::FromSU(pos), Vertex::FromSU(target), Vector::FromSU(up), persp, fov); + return c; + }; + + }; + + + + +} \ No newline at end of file diff --git a/SketchUpNET/Camera.h b/SketchUpNET/Camera.h new file mode 100644 index 0000000..a55ad4c --- /dev/null +++ b/SketchUpNET/Camera.h @@ -0,0 +1,21 @@ +/* + +SketchUpNET - a C++ Wrapper for the Trimble(R) SketchUp(R) C API +Copyright(C) 2015, Autor: Maximilian Thumfart + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ +#include "Camera.cpp" \ No newline at end of file diff --git a/SketchUpNET/Scene.cpp b/SketchUpNET/Scene.cpp new file mode 100644 index 0000000..4953a50 --- /dev/null +++ b/SketchUpNET/Scene.cpp @@ -0,0 +1,96 @@ +/* + +SketchUpNET - a C++ Wrapper for the Trimble(R) SketchUp(R) C API +Copyright(C) 2015, Autor: Maximilian Thumfart + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "utilities.h" +#include "Camera.h" +#include "Layer.h" + +#pragma once + +using namespace System; +using namespace System::Collections; +using namespace System::Collections::Generic; + +namespace SketchUpNET +{ + public ref class Scene + { + public: + + Vertex ^ Start; + Vertex^ End; + System::String^ Layer; + + Scene(Vertex ^ start, Vertex ^ end, System::String^ layer) + { + this->Start = start; + this->End = end; + this->Layer = layer; + }; + + Scene() {}; + internal: + static Scene^ FromSU(SUSceneRef scene) + { + SUStringRef name = SU_INVALID; + SUStringCreate(&name); + SUSceneGetName(scene, &name); + String^ n = SketchUpNET::Utilities::GetString(name); + + SUCameraRef cam = SU_INVALID; + SUSceneGetCamera(scene, &cam); + + + //Get All Layers + size_t layerCount = 0; + SUSceneGetNumLayers(scene, &layerCount); + + if (layerCount > 0) { + std::vector layers(layerCount); + SUSceneGetLayers(scene, layerCount, &layers[0], &layerCount); + + for (size_t i = 0; i < layerCount; i++) { + Layer^ layer = Layer::FromSU(layers[i]); + layer.Name + + } + } + + }; + + + + + }; + + + + +} \ No newline at end of file diff --git a/SketchUpNET/Scene.h b/SketchUpNET/Scene.h new file mode 100644 index 0000000..dafea89 --- /dev/null +++ b/SketchUpNET/Scene.h @@ -0,0 +1,21 @@ +/* + +SketchUpNET - a C++ Wrapper for the Trimble(R) SketchUp(R) C API +Copyright(C) 2015, Autor: Maximilian Thumfart + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ +#include "Scene.cpp" \ No newline at end of file diff --git a/SketchUpNET/SketchUpNET.vcxproj b/SketchUpNET/SketchUpNET.vcxproj index 310be7e..c6d83ce 100644 --- a/SketchUpNET/SketchUpNET.vcxproj +++ b/SketchUpNET/SketchUpNET.vcxproj @@ -148,6 +148,7 @@ + @@ -159,6 +160,7 @@ + @@ -168,6 +170,7 @@ + @@ -180,6 +183,7 @@ + diff --git a/SketchUpNET/SketchUpNET.vcxproj.filters b/SketchUpNET/SketchUpNET.vcxproj.filters index 9bb8fe9..cb3044a 100644 --- a/SketchUpNET/SketchUpNET.vcxproj.filters +++ b/SketchUpNET/SketchUpNET.vcxproj.filters @@ -69,6 +69,12 @@ Source Files + + Source Files + + + Source Files + @@ -125,6 +131,12 @@ Header Files + + Header Files + + + Header Files + From 7e35de4524f4a3c88938dc7962120e96e56f28aa Mon Sep 17 00:00:00 2001 From: moethu Date: Tue, 18 Jan 2022 08:47:06 +0100 Subject: [PATCH 2/2] fixing pragma once statements --- SketchUpNET/Camera.cpp | 3 ++- SketchUpNET/Scene.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/SketchUpNET/Camera.cpp b/SketchUpNET/Camera.cpp index 48f2383..d357221 100644 --- a/SketchUpNET/Camera.cpp +++ b/SketchUpNET/Camera.cpp @@ -19,6 +19,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SO */ +#pragma once + #include #include #include @@ -33,7 +35,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SO #include "Vector.h" #include "Vertex.h" -#pragma once using namespace System; using namespace System::Collections; diff --git a/SketchUpNET/Scene.cpp b/SketchUpNET/Scene.cpp index 4953a50..17adc39 100644 --- a/SketchUpNET/Scene.cpp +++ b/SketchUpNET/Scene.cpp @@ -19,6 +19,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SO */ +#pragma once + #include #include #include @@ -32,7 +34,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SO #include "Camera.h" #include "Layer.h" -#pragma once using namespace System; using namespace System::Collections;