Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added first camera and scene implementation #43

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions SketchUpNET/Camera.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*

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.

*/

#pragma once

#include <SketchUpAPI/slapi.h>
#include <SketchUpAPI/geometry.h>
#include <SketchUpAPI/initialize.h>
#include <SketchUpAPI/unicodestring.h>
#include <SketchUpAPI/model/model.h>
#include <SketchUpAPI/model/entities.h>
#include <SketchUpAPI/model/vertex.h>
#include <SketchUpAPI/model/camera.h>
#include <SketchUpAPI/model/drawing_element.h>
#include <msclr/marshal.h>
#include "utilities.h"
#include "Vector.h"
#include "Vertex.h"


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;
};

};




}
21 changes: 21 additions & 0 deletions SketchUpNET/Camera.h
Original file line number Diff line number Diff line change
@@ -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"
97 changes: 97 additions & 0 deletions SketchUpNET/Scene.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*

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.

*/

#pragma once

#include <SketchUpAPI/slapi.h>
#include <SketchUpAPI/geometry.h>
#include <SketchUpAPI/initialize.h>
#include <SketchUpAPI/unicodestring.h>
#include <SketchUpAPI/model/model.h>
#include <SketchUpAPI/model/entities.h>
#include <SketchUpAPI/model/scene.h>
#include <SketchUpAPI/model/drawing_element.h>
#include <msclr/marshal.h>
#include "utilities.h"
#include "Camera.h"
#include "Layer.h"


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<SULayerRef> layers(layerCount);
SUSceneGetLayers(scene, layerCount, &layers[0], &layerCount);

for (size_t i = 0; i < layerCount; i++) {
Layer^ layer = Layer::FromSU(layers[i]);
layer.Name

}
}

};




};




}
21 changes: 21 additions & 0 deletions SketchUpNET/Scene.h
Original file line number Diff line number Diff line change
@@ -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"
4 changes: 4 additions & 0 deletions SketchUpNET/SketchUpNET.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Camera.cpp" />
<ClCompile Include="Color.cpp" />
<ClCompile Include="Component.cpp" />
<ClCompile Include="Curve.cpp" />
Expand All @@ -159,6 +160,7 @@
<ClCompile Include="Material.cpp" />
<ClCompile Include="Mesh.cpp" />
<ClCompile Include="MeshFace.cpp" />
<ClCompile Include="Scene.cpp" />
<ClCompile Include="SketchUpNET.cpp" />
<ClCompile Include="Surface.cpp" />
<ClCompile Include="Texture.cpp" />
Expand All @@ -168,6 +170,7 @@
<ClCompile Include="Vertex.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Camera.h" />
<ClInclude Include="Color.h" />
<ClInclude Include="Component.h" />
<ClInclude Include="Curve.h" />
Expand All @@ -180,6 +183,7 @@
<ClInclude Include="Mesh.h" />
<ClInclude Include="MeshFace.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="Scene.h" />
<ClInclude Include="Surface.h" />
<ClInclude Include="Texture.h" />
<ClInclude Include="Transform.h" />
Expand Down
12 changes: 12 additions & 0 deletions SketchUpNET/SketchUpNET.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@
<ClCompile Include="Texture.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Scene.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Camera.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Vertex.h">
Expand Down Expand Up @@ -125,6 +131,12 @@
<ClInclude Include="Texture.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Camera.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Scene.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="SketchUpNET.rc">
Expand Down