merge
commit
3a3374a886
|
@ -99,25 +99,26 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="src\CaptionButton.cpp" />
|
<ClCompile Include="src\CaptionButton.cpp" />
|
||||||
<ClCompile Include="src\Editor\EditorWidget.cpp" />
|
<ClCompile Include="src\Editor\EditorWidget.cpp" />
|
||||||
<ClCompile Include="src\Editor\GraphicElement.cpp" />
|
|
||||||
<ClCompile Include="src\IconWidget.cpp" />
|
<ClCompile Include="src\IconWidget.cpp" />
|
||||||
<ClCompile Include="src\main.cpp" />
|
<ClCompile Include="src\main.cpp" />
|
||||||
<ClCompile Include="src\MainWindow.cpp" />
|
<ClCompile Include="src\MainWindow.cpp" />
|
||||||
<ClCompile Include="src\NavigationBarWidget.cpp" />
|
<ClCompile Include="src\NavigationBarWidget.cpp" />
|
||||||
<ClCompile Include="src\Renderer\BvhTree.cpp" />
|
<ClCompile Include="src\Renderer\Painting\BvhTree.cpp" />
|
||||||
<ClCompile Include="src\Renderer\Camera.cpp" />
|
<ClCompile Include="src\Renderer\Camera.cpp" />
|
||||||
<ClCompile Include="src\Renderer\CubicBezier.cpp" />
|
<ClCompile Include="src\Renderer\Painting\CubicBezier.cpp" />
|
||||||
<ClCompile Include="src\Renderer\CubicMonotonization.cpp" />
|
<ClCompile Include="src\Renderer\Painting\CubicMonotonization.cpp" />
|
||||||
<ClCompile Include="src\Renderer\Light.cpp" />
|
<ClCompile Include="src\Renderer\Light.cpp" />
|
||||||
<ClCompile Include="src\Renderer\Line.cpp" />
|
<ClCompile Include="src\Renderer\Painting\Element.cpp" />
|
||||||
|
<ClCompile Include="src\Renderer\Painting\Line.cpp" />
|
||||||
<ClCompile Include="src\Renderer\Mesh.cpp" />
|
<ClCompile Include="src\Renderer\Mesh.cpp" />
|
||||||
<ClCompile Include="src\Renderer\Model.cpp" />
|
<ClCompile Include="src\Renderer\Model.cpp" />
|
||||||
<ClCompile Include="src\Renderer\PaintingHelper.cpp" />
|
<ClCompile Include="src\Renderer\Painting\Painting.cpp" />
|
||||||
|
<ClCompile Include="src\Renderer\Painting\PaintingHelper.cpp" />
|
||||||
<ClCompile Include="src\Renderer\PaintingMesh.cpp" />
|
<ClCompile Include="src\Renderer\PaintingMesh.cpp" />
|
||||||
<ClCompile Include="src\Renderer\RendererGLWidget.cpp" />
|
<ClCompile Include="src\Renderer\RendererGLWidget.cpp" />
|
||||||
<ClCompile Include="src\Renderer\RendererWidget.cpp" />
|
<ClCompile Include="src\Renderer\RendererWidget.cpp" />
|
||||||
<ClCompile Include="src\Renderer\ShortCutTree.cpp" />
|
<ClCompile Include="src\Renderer\Painting\ShortCutTree.cpp" />
|
||||||
<ClCompile Include="src\Renderer\StraightLine.cpp" />
|
<ClCompile Include="src\Renderer\Painting\StraightLine.cpp" />
|
||||||
<ClCompile Include="src\SvgParser.cpp" />
|
<ClCompile Include="src\SvgParser.cpp" />
|
||||||
<ClCompile Include="src\TitleWidget.cpp" />
|
<ClCompile Include="src\TitleWidget.cpp" />
|
||||||
<QtRcc Include="MainWindow.qrc" />
|
<QtRcc Include="MainWindow.qrc" />
|
||||||
|
@ -146,11 +147,11 @@
|
||||||
<None Include="Shaders\shader.vert" />
|
<None Include="Shaders\shader.vert" />
|
||||||
<None Include="Shaders\shadow_mapping.comp" />
|
<None Include="Shaders\shadow_mapping.comp" />
|
||||||
<None Include="Shaders\ssgi.comp" />
|
<None Include="Shaders\ssgi.comp" />
|
||||||
<None Include="src\Editor\data.json" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<QtMoc Include="src\MainWindow.h" />
|
<QtMoc Include="src\MainWindow.h" />
|
||||||
<ClInclude Include="src\Editor\GraphicElement.h" />
|
<ClInclude Include="src\Renderer\Painting\Element.h" />
|
||||||
|
<ClInclude Include="src\Renderer\Painting\Painting.h" />
|
||||||
<ClInclude Include="src\SvgParser.h" />
|
<ClInclude Include="src\SvgParser.h" />
|
||||||
<QtMoc Include="src\TitleWidget.h" />
|
<QtMoc Include="src\TitleWidget.h" />
|
||||||
<QtMoc Include="src\IconWidget.h" />
|
<QtMoc Include="src\IconWidget.h" />
|
||||||
|
@ -158,19 +159,19 @@
|
||||||
<QtMoc Include="src\NavigationBarWidget.h" />
|
<QtMoc Include="src\NavigationBarWidget.h" />
|
||||||
<QtMoc Include="src\Renderer\RendererWidget.h" />
|
<QtMoc Include="src\Renderer\RendererWidget.h" />
|
||||||
<QtMoc Include="src\Editor\EditorWidget.h" />
|
<QtMoc Include="src\Editor\EditorWidget.h" />
|
||||||
<ClInclude Include="src\Renderer\BvhTree.h" />
|
<ClInclude Include="src\Renderer\Painting\BvhTree.h" />
|
||||||
<ClInclude Include="src\Renderer\Camera.h" />
|
<ClInclude Include="src\Renderer\Camera.h" />
|
||||||
<ClInclude Include="src\Renderer\CubicBezier.h" />
|
<ClInclude Include="src\Renderer\Painting\CubicBezier.h" />
|
||||||
<ClInclude Include="src\Renderer\CubicMonotonization.h" />
|
<ClInclude Include="src\Renderer\Painting\CubicMonotonization.h" />
|
||||||
<ClInclude Include="src\Renderer\Drawable.h" />
|
<ClInclude Include="src\Renderer\Drawable.h" />
|
||||||
<ClInclude Include="src\Renderer\Light.h" />
|
<ClInclude Include="src\Renderer\Light.h" />
|
||||||
<ClInclude Include="src\Renderer\Line.h" />
|
<ClInclude Include="src\Renderer\Painting\Line.h" />
|
||||||
<ClInclude Include="src\Renderer\Mesh.h" />
|
<ClInclude Include="src\Renderer\Mesh.h" />
|
||||||
<ClInclude Include="src\Renderer\Model.h" />
|
<ClInclude Include="src\Renderer\Model.h" />
|
||||||
<ClInclude Include="src\Renderer\PaintingHelper.h" />
|
<ClInclude Include="src\Renderer\Painting\PaintingHelper.h" />
|
||||||
<ClInclude Include="src\Renderer\PaintingMesh.h" />
|
<ClInclude Include="src\Renderer\PaintingMesh.h" />
|
||||||
<ClInclude Include="src\Renderer\ShortCutTree.h" />
|
<ClInclude Include="src\Renderer\Painting\ShortCutTree.h" />
|
||||||
<ClInclude Include="src\Renderer\StraightLine.h" />
|
<ClInclude Include="src\Renderer\Painting\StraightLine.h" />
|
||||||
<QtMoc Include="src\Renderer\RendererGLWidget.h" />
|
<QtMoc Include="src\Renderer\RendererGLWidget.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -35,6 +35,12 @@
|
||||||
<Filter Include="Resource Files\Shaders">
|
<Filter Include="Resource Files\Shaders">
|
||||||
<UniqueIdentifier>{60515177-3da7-420f-8f5b-27c16bb2b77b}</UniqueIdentifier>
|
<UniqueIdentifier>{60515177-3da7-420f-8f5b-27c16bb2b77b}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter Include="Source Files\Renderer\Painting">
|
||||||
|
<UniqueIdentifier>{653d1291-0de8-4e0a-855d-7cfc755f7632}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Header Files\Renderer\Painting">
|
||||||
|
<UniqueIdentifier>{22909273-2b23-49fa-84ab-444cefb09656}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<QtUic Include="MainWindow.ui">
|
<QtUic Include="MainWindow.ui">
|
||||||
|
@ -51,45 +57,24 @@
|
||||||
<ClCompile Include="src\Editor\EditorWidget.cpp">
|
<ClCompile Include="src\Editor\EditorWidget.cpp">
|
||||||
<Filter>Source Files\Editor</Filter>
|
<Filter>Source Files\Editor</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\Renderer\BvhTree.cpp">
|
|
||||||
<Filter>Source Files\Renderer</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\Renderer\Camera.cpp">
|
<ClCompile Include="src\Renderer\Camera.cpp">
|
||||||
<Filter>Source Files\Renderer</Filter>
|
<Filter>Source Files\Renderer</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\Renderer\CubicBezier.cpp">
|
|
||||||
<Filter>Source Files\Renderer</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\Renderer\CubicMonotonization.cpp">
|
|
||||||
<Filter>Source Files\Renderer</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\Renderer\Light.cpp">
|
<ClCompile Include="src\Renderer\Light.cpp">
|
||||||
<Filter>Source Files\Renderer</Filter>
|
<Filter>Source Files\Renderer</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\Renderer\Line.cpp">
|
|
||||||
<Filter>Source Files\Renderer</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\Renderer\Mesh.cpp">
|
<ClCompile Include="src\Renderer\Mesh.cpp">
|
||||||
<Filter>Source Files\Renderer</Filter>
|
<Filter>Source Files\Renderer</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\Renderer\Model.cpp">
|
<ClCompile Include="src\Renderer\Model.cpp">
|
||||||
<Filter>Source Files\Renderer</Filter>
|
<Filter>Source Files\Renderer</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\Renderer\PaintingHelper.cpp">
|
|
||||||
<Filter>Source Files\Renderer</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\Renderer\PaintingMesh.cpp">
|
<ClCompile Include="src\Renderer\PaintingMesh.cpp">
|
||||||
<Filter>Source Files\Renderer</Filter>
|
<Filter>Source Files\Renderer</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\Renderer\RendererGLWidget.cpp">
|
<ClCompile Include="src\Renderer\RendererGLWidget.cpp">
|
||||||
<Filter>Source Files\Renderer</Filter>
|
<Filter>Source Files\Renderer</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\Renderer\ShortCutTree.cpp">
|
|
||||||
<Filter>Source Files\Renderer</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\Renderer\StraightLine.cpp">
|
|
||||||
<Filter>Source Files\Renderer</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\main.cpp">
|
<ClCompile Include="src\main.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -114,6 +99,33 @@
|
||||||
<ClCompile Include="src\TitleWidget.cpp">
|
<ClCompile Include="src\TitleWidget.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\Renderer\Painting\BvhTree.cpp">
|
||||||
|
<Filter>Source Files\Renderer\Painting</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\Renderer\Painting\CubicBezier.cpp">
|
||||||
|
<Filter>Source Files\Renderer\Painting</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\Renderer\Painting\CubicMonotonization.cpp">
|
||||||
|
<Filter>Source Files\Renderer\Painting</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\Renderer\Painting\PaintingHelper.cpp">
|
||||||
|
<Filter>Source Files\Renderer\Painting</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\Renderer\Painting\ShortCutTree.cpp">
|
||||||
|
<Filter>Source Files\Renderer\Painting</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\Renderer\Painting\StraightLine.cpp">
|
||||||
|
<Filter>Source Files\Renderer\Painting</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\Renderer\Painting\Painting.cpp">
|
||||||
|
<Filter>Source Files\Renderer\Painting</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\Renderer\Painting\Line.cpp">
|
||||||
|
<Filter>Source Files\Renderer\Painting</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\Renderer\Painting\Element.cpp">
|
||||||
|
<Filter>Source Files\Renderer\Painting</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<QtMoc Include="src\Renderer\RendererGLWidget.h">
|
<QtMoc Include="src\Renderer\RendererGLWidget.h">
|
||||||
|
@ -206,48 +218,54 @@
|
||||||
</QtUic>
|
</QtUic>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="src\Renderer\BvhTree.h">
|
|
||||||
<Filter>Header Files\Renderer</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="src\Renderer\Camera.h">
|
<ClInclude Include="src\Renderer\Camera.h">
|
||||||
<Filter>Header Files\Renderer</Filter>
|
<Filter>Header Files\Renderer</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="src\Renderer\CubicBezier.h">
|
|
||||||
<Filter>Header Files\Renderer</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="src\Renderer\CubicMonotonization.h">
|
|
||||||
<Filter>Header Files\Renderer</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="src\Renderer\Drawable.h">
|
<ClInclude Include="src\Renderer\Drawable.h">
|
||||||
<Filter>Header Files\Renderer</Filter>
|
<Filter>Header Files\Renderer</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="src\Renderer\Light.h">
|
<ClInclude Include="src\Renderer\Light.h">
|
||||||
<Filter>Header Files\Renderer</Filter>
|
<Filter>Header Files\Renderer</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="src\Renderer\Line.h">
|
|
||||||
<Filter>Header Files\Renderer</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="src\Renderer\Mesh.h">
|
<ClInclude Include="src\Renderer\Mesh.h">
|
||||||
<Filter>Header Files\Renderer</Filter>
|
<Filter>Header Files\Renderer</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="src\Renderer\Model.h">
|
<ClInclude Include="src\Renderer\Model.h">
|
||||||
<Filter>Header Files\Renderer</Filter>
|
<Filter>Header Files\Renderer</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="src\Renderer\PaintingHelper.h">
|
|
||||||
<Filter>Header Files\Renderer</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="src\Renderer\PaintingMesh.h">
|
<ClInclude Include="src\Renderer\PaintingMesh.h">
|
||||||
<Filter>Header Files\Renderer</Filter>
|
<Filter>Header Files\Renderer</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="src\Renderer\ShortCutTree.h">
|
|
||||||
<Filter>Header Files\Renderer</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="src\Renderer\StraightLine.h">
|
|
||||||
<Filter>Header Files\Renderer</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="src\SvgParser.h">
|
<ClInclude Include="src\SvgParser.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\Renderer\Painting\BvhTree.h">
|
||||||
|
<Filter>Header Files\Renderer\Painting</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\Renderer\Painting\CubicBezier.h">
|
||||||
|
<Filter>Header Files\Renderer\Painting</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\Renderer\Painting\CubicMonotonization.h">
|
||||||
|
<Filter>Header Files\Renderer\Painting</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\Renderer\Painting\Line.h">
|
||||||
|
<Filter>Header Files\Renderer\Painting</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\Renderer\Painting\PaintingHelper.h">
|
||||||
|
<Filter>Header Files\Renderer\Painting</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\Renderer\Painting\ShortCutTree.h">
|
||||||
|
<Filter>Header Files\Renderer\Painting</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\Renderer\Painting\StraightLine.h">
|
||||||
|
<Filter>Header Files\Renderer\Painting</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\Renderer\Painting\Painting.h">
|
||||||
|
<Filter>Header Files\Renderer\Painting</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\Renderer\Painting\Element.h">
|
||||||
|
<Filter>Header Files\Renderer\Painting</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<QtRcc Include="MainWindow.qrc">
|
<QtRcc Include="MainWindow.qrc">
|
||||||
|
|
|
@ -94,7 +94,7 @@ QTabWidget::pane {
|
||||||
<string>纹理编辑</string>
|
<string>纹理编辑</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="RendererWidget" name="rendererWidget">
|
<widget class="Renderer::RendererWidget" name="rendererWidget">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>场景渲染</string>
|
<string>场景渲染</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
@ -109,7 +109,7 @@ QTabWidget::pane {
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>RendererWidget</class>
|
<class>Renderer::RendererWidget</class>
|
||||||
<extends>QWidget</extends>
|
<extends>QWidget</extends>
|
||||||
<header>Renderer/RendererWidget.h</header>
|
<header>Renderer/RendererWidget.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
<enum>QLayout::SetDefaultConstraint</enum>
|
<enum>QLayout::SetDefaultConstraint</enum>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="RendererGLWidget" name="openGLWidget">
|
<widget class="Renderer::RendererGLWidget" name="openGLWidget">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
|
@ -94,7 +94,7 @@
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>RendererGLWidget</class>
|
<class>Renderer::RendererGLWidget</class>
|
||||||
<extends>QOpenGLWidget</extends>
|
<extends>QOpenGLWidget</extends>
|
||||||
<header>RendererGLWidget.h</header>
|
<header>RendererGLWidget.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
|
|
@ -251,6 +251,42 @@ int cubic_bezier_int_test(vec2 uv, vec2 p0, vec2 p1, vec2 p2, vec2 p3)
|
||||||
return n_ints;
|
return n_ints;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool cubic_bezier_sign_test(vec2 uv, vec2 p0, vec2 p1, vec2 p2, vec2 p3)
|
||||||
|
{
|
||||||
|
float cu = (-p0.y + 3. * p1.y - 3. * p2.y + p3.y);
|
||||||
|
float qu = (3. * p0.y - 6. * p1.y + 3. * p2.y);
|
||||||
|
float li = (-3. * p0.y + 3. * p1.y);
|
||||||
|
float co = p0.y - uv.y;
|
||||||
|
|
||||||
|
vec3 roots = vec3(1e38);
|
||||||
|
int n_roots = solve_cubic(vec3(co/cu,li/cu,qu/cu),roots);
|
||||||
|
|
||||||
|
int n_ints = 0;
|
||||||
|
|
||||||
|
for(int i=0;i<3;i++){
|
||||||
|
if(i < n_roots){
|
||||||
|
//if(roots[i] >= 0. && roots[i] <= 1.){
|
||||||
|
float x_pos = -p0.x + 3. * p1.x - 3. * p2.x + p3.x;
|
||||||
|
x_pos = x_pos * roots[i] + 3. * p0.x - 6. * p1.x + 3. * p2.x;
|
||||||
|
x_pos = x_pos * roots[i] + -3. * p0.x + 3. * p1.x;
|
||||||
|
x_pos = x_pos * roots[i] + p0.x;
|
||||||
|
|
||||||
|
if(x_pos < uv.x){
|
||||||
|
n_ints++;
|
||||||
|
}
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return n_ints%2==0;
|
||||||
|
// if(n_ints==0 || n_ints==2 || n_ints==4){
|
||||||
|
// return 1;
|
||||||
|
// }
|
||||||
|
// else{
|
||||||
|
// return 0;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
const float eps = .000005;
|
const float eps = .000005;
|
||||||
const int halley_iterations = 8;
|
const int halley_iterations = 8;
|
||||||
//lagrange positive real root upper bound
|
//lagrange positive real root upper bound
|
||||||
|
@ -743,7 +779,7 @@ bool drawElement(uint elementIndex, vec2 localUV, out vec3 color, out vec2 metal
|
||||||
// for(int i = 0; i<200;i++)
|
// for(int i = 0; i<200;i++)
|
||||||
if (elementData[styleIndex] == 0.) //Ãæ
|
if (elementData[styleIndex] == 0.) //Ãæ
|
||||||
{
|
{
|
||||||
uint contourIndex = leftChild - 0x80000000;
|
uint contourIndex = linesOffset + leftChild - 0x80000000;
|
||||||
|
|
||||||
uint num_its = 0;
|
uint num_its = 0;
|
||||||
|
|
||||||
|
@ -802,29 +838,40 @@ bool drawElement(uint elementIndex, vec2 localUV, out vec3 color, out vec2 metal
|
||||||
else if (elementData[styleIndex] == 1) //Ïß
|
else if (elementData[styleIndex] == 1) //Ïß
|
||||||
{
|
{
|
||||||
float strokeWidth = elementData[styleIndex+1];
|
float strokeWidth = elementData[styleIndex+1];
|
||||||
uint lineIndex = leftChild - 0x80000000;
|
uint contourIndex = linesOffset + leftChild - 0x80000000;
|
||||||
uint p0Index = elementIndexs[linesOffset + 4 * lineIndex];
|
float d = 1e38;
|
||||||
uint p1Index = elementIndexs[linesOffset + 4 * lineIndex + 1];
|
uint signTmp=0;
|
||||||
uint p2Index = elementIndexs[linesOffset + 4 * lineIndex + 2];
|
uint lineCountTmp=0;
|
||||||
uint p3Index = elementIndexs[linesOffset + 4 * lineIndex + 3];
|
uint lastPIndex = -1;
|
||||||
|
uint lineCount = elementIndexs[contourIndex];
|
||||||
|
|
||||||
vec2 p0 = vec2(elementData[pointsOffset + 2 * p0Index],
|
for ( uint contourIterator = contourIndex + 1;contourIterator < contourIndex + 1 + lineCount; contourIterator++)
|
||||||
elementData[pointsOffset + 2 * p0Index + 1]);
|
{
|
||||||
vec2 p1 = vec2(elementData[pointsOffset + 2 * p1Index],
|
uint lineIndex = elementIndexs[contourIterator];
|
||||||
elementData[pointsOffset + 2 * p1Index + 1]);
|
bool reverse = false;
|
||||||
vec2 p2 = vec2(elementData[pointsOffset + 2 * p2Index],
|
if(lineIndex>=0x80000000)
|
||||||
elementData[pointsOffset + 2 * p2Index + 1]);
|
{
|
||||||
vec2 p3 = vec2(elementData[pointsOffset + 2 * p3Index],
|
reverse = true;
|
||||||
elementData[pointsOffset + 2 * p3Index + 1]);
|
lineIndex -= 0x80000000;
|
||||||
|
}
|
||||||
|
uint pLocation = linesOffset + 4 * lineIndex;
|
||||||
|
uvec4 pxIndex = uvec4(pointsOffset)+2*uvec4(elementIndexs[pLocation], elementIndexs[pLocation+1], elementIndexs[pLocation+2], elementIndexs[pLocation+3]);
|
||||||
|
uvec4 pyIndex = uvec4(1)+pxIndex;
|
||||||
|
|
||||||
|
mat4x2 p = mat4x2(elementData[pxIndex[0]], elementData[pyIndex[0]],
|
||||||
|
elementData[pxIndex[1]], elementData[pyIndex[1]],
|
||||||
|
elementData[pxIndex[2]],elementData[pyIndex[2]],
|
||||||
|
elementData[pxIndex[3]], elementData[pyIndex[3]]);
|
||||||
|
|
||||||
|
if(lastPIndex!=pxIndex[0])
|
||||||
|
{
|
||||||
float lineType = elementData[styleIndex+4];
|
float lineType = elementData[styleIndex+4];
|
||||||
/*if(cubic_bezier_dis(localUV, p0, p1, p2, p3, true)<=0.001)
|
if(d<=0.001)
|
||||||
{
|
{
|
||||||
hitElement = true;
|
hitElement = true;
|
||||||
elementColor = vec4(1);
|
elementColor = vec4(0,0,0,1);
|
||||||
}
|
}
|
||||||
else */if(cubic_bezier_dis(localUV, p0, p1, p2, p3, elementData[styleIndex+2]==0)<=strokeWidth
|
else if(d<=strokeWidth && signTmp==lineCountTmp)
|
||||||
&&(lineType==2 ||cubic_bezier_int_test(localUV, p0, p1, p2, p3)==lineType))
|
|
||||||
{
|
{
|
||||||
hitElement = true;
|
hitElement = true;
|
||||||
elementColor = vec4(1);
|
elementColor = vec4(1);
|
||||||
|
@ -834,6 +881,74 @@ bool drawElement(uint elementIndex, vec2 localUV, out vec3 color, out vec2 metal
|
||||||
metallicRoughness = vec2(elementData[styleIndex+10],elementData[styleIndex+11]);
|
metallicRoughness = vec2(elementData[styleIndex+10],elementData[styleIndex+11]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
d = 1e38;
|
||||||
|
signTmp=0;
|
||||||
|
lineCountTmp = 0;
|
||||||
|
}
|
||||||
|
lastPIndex = pxIndex[3];
|
||||||
|
lineCountTmp++;
|
||||||
|
float lineType = elementData[styleIndex+4];
|
||||||
|
d = min(d, cubic_bezier_dis(localUV, p[0], p[1], p[2], p[3], elementData[styleIndex+2]==0));
|
||||||
|
if(lineType==2 || cubic_bezier_sign_test(localUV, p[0], p[1], p[2], p[3])==(reverse? lineType==0: lineType==1))
|
||||||
|
++signTmp;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
float lineType = elementData[styleIndex+4];
|
||||||
|
if(d<=0.001)
|
||||||
|
{
|
||||||
|
hitElement = true;
|
||||||
|
elementColor = vec4(0,0,0,1);
|
||||||
|
}
|
||||||
|
else if(d<=strokeWidth && signTmp==lineCountTmp)
|
||||||
|
{
|
||||||
|
hitElement = true;
|
||||||
|
elementColor = vec4(1);
|
||||||
|
if(elementData[styleIndex+3]==0)
|
||||||
|
{
|
||||||
|
elementColor = vec4(elementData[styleIndex+7],elementData[styleIndex+8],elementData[styleIndex+9],1);
|
||||||
|
metallicRoughness = vec2(elementData[styleIndex+10],elementData[styleIndex+11]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// float strokeWidth = elementData[styleIndex+1];
|
||||||
|
// uint lineIndex = leftChild - 0x80000000;
|
||||||
|
// uint p0Index = elementIndexs[linesOffset + 4 * lineIndex];
|
||||||
|
// uint p1Index = elementIndexs[linesOffset + 4 * lineIndex + 1];
|
||||||
|
// uint p2Index = elementIndexs[linesOffset + 4 * lineIndex + 2];
|
||||||
|
// uint p3Index = elementIndexs[linesOffset + 4 * lineIndex + 3];
|
||||||
|
|
||||||
|
// vec2 p0 = vec2(elementData[pointsOffset + 2 * p0Index],
|
||||||
|
// elementData[pointsOffset + 2 * p0Index + 1]);
|
||||||
|
// vec2 p1 = vec2(elementData[pointsOffset + 2 * p1Index],
|
||||||
|
// elementData[pointsOffset + 2 * p1Index + 1]);
|
||||||
|
// vec2 p2 = vec2(elementData[pointsOffset + 2 * p2Index],
|
||||||
|
// elementData[pointsOffset + 2 * p2Index + 1]);
|
||||||
|
// vec2 p3 = vec2(elementData[pointsOffset + 2 * p3Index],
|
||||||
|
// elementData[pointsOffset + 2 * p3Index + 1]);
|
||||||
|
|
||||||
|
// // if(p0.y==p3.y)
|
||||||
|
// // {
|
||||||
|
// // p2.y-=0.0000001;
|
||||||
|
// // p3.y-=0.0000001;
|
||||||
|
// // }
|
||||||
|
// float lineType = elementData[styleIndex+4];
|
||||||
|
// if(cubic_bezier_dis(localUV, p0, p1, p2, p3, true)<=0.001)
|
||||||
|
// {
|
||||||
|
// hitElement = true;
|
||||||
|
// elementColor = vec4(0,0,0,1);
|
||||||
|
// }
|
||||||
|
// else if(cubic_bezier_dis(localUV, p0, p1, p2, p3, elementData[styleIndex+2]==0)<=strokeWidth
|
||||||
|
// &&(lineType==2 || cubic_bezier_sign_test(localUV, p0, p1, p2, p3)==(lineType==1)))
|
||||||
|
// {
|
||||||
|
// hitElement = true;
|
||||||
|
// elementColor = vec4(1);
|
||||||
|
// if(elementData[styleIndex+3]==0)
|
||||||
|
// {
|
||||||
|
// elementColor = vec4(elementData[styleIndex+7],elementData[styleIndex+8],elementData[styleIndex+9],1);
|
||||||
|
// metallicRoughness = vec2(elementData[styleIndex+10],elementData[styleIndex+11]);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
elementBvhIndex = elementBvhLength;
|
elementBvhIndex = elementBvhLength;
|
||||||
|
|
|
@ -110,7 +110,7 @@ CentralWidget::CentralWidget(QWidget* parent) : QMainWindow(parent)
|
||||||
QObject::connect(navigationBarWidget->buttonGroup, &QButtonGroup::idClicked,
|
QObject::connect(navigationBarWidget->buttonGroup, &QButtonGroup::idClicked,
|
||||||
ui.tabWidget, &QTabWidget::setCurrentIndex);
|
ui.tabWidget, &QTabWidget::setCurrentIndex);
|
||||||
QObject::connect(ui.tabWidget, &QTabWidget::currentChanged,
|
QObject::connect(ui.tabWidget, &QTabWidget::currentChanged,
|
||||||
ui.rendererWidget, &RendererWidget::currentTabChanged);
|
ui.rendererWidget, &Renderer::RendererWidget::currentTabChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
CentralWidget::~CentralWidget()
|
CentralWidget::~CentralWidget()
|
||||||
|
|
|
@ -1,88 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <QOpenGLTexture>
|
|
||||||
#include <QOpenGLContext>
|
|
||||||
#include <QTextCodec>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <QVector4D>
|
|
||||||
#include <iostream>
|
|
||||||
#include <memory>
|
|
||||||
#include <vector>
|
|
||||||
#include <cmath>
|
|
||||||
|
|
||||||
using std::shared_ptr;
|
|
||||||
|
|
||||||
struct BvhTreeData {
|
|
||||||
QVector4D bound;
|
|
||||||
GLuint leftSon, rightSon;
|
|
||||||
void show() {
|
|
||||||
printf("Bvh: (%lf, %lf) (%lf, %lf): %d %d\n",
|
|
||||||
bound.x(), bound.y(), bound.z(), bound.w(),
|
|
||||||
leftSon, rightSon);
|
|
||||||
}
|
|
||||||
BvhTreeData(QVector4D bound, GLuint leftSon, GLuint rightSon)
|
|
||||||
: bound(bound), leftSon(leftSon), rightSon(rightSon) {}
|
|
||||||
BvhTreeData()
|
|
||||||
: leftSon(0), rightSon(0) {}
|
|
||||||
~BvhTreeData() {}
|
|
||||||
};
|
|
||||||
// BvhTree 节点
|
|
||||||
struct BvhNode {
|
|
||||||
GLuint lab;
|
|
||||||
bool isLeaf;
|
|
||||||
QVector4D bound;
|
|
||||||
shared_ptr<BvhNode> child[2];
|
|
||||||
static bool x_compare(BvhTreeData a, BvhTreeData b) {
|
|
||||||
return a.bound.x() < b.bound.x();
|
|
||||||
}
|
|
||||||
static bool y_compare(BvhTreeData a, BvhTreeData b) {
|
|
||||||
return a.bound.y() < b.bound.y();
|
|
||||||
}
|
|
||||||
GLuint getLeftSon(int k) {
|
|
||||||
if (isLeaf) {
|
|
||||||
return 0x80000000+child[0]->lab;
|
|
||||||
}
|
|
||||||
return child[0]->lab;
|
|
||||||
}
|
|
||||||
GLuint getRightSon(int k) {
|
|
||||||
if (isLeaf) {
|
|
||||||
return child[1]->lab;
|
|
||||||
}
|
|
||||||
return child[1]->lab;
|
|
||||||
}
|
|
||||||
BvhNode() {
|
|
||||||
child[0] = child[1] = NULL;
|
|
||||||
isLeaf = false;
|
|
||||||
lab = 0;
|
|
||||||
}
|
|
||||||
int maximumBound() {
|
|
||||||
return (std::fabs(bound.x() - bound.w()) < std::fabs(bound.y() - bound.z()));
|
|
||||||
}
|
|
||||||
~BvhNode() {}
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef std::shared_ptr<BvhNode> BvhPtr;
|
|
||||||
|
|
||||||
class BvhTree
|
|
||||||
{
|
|
||||||
|
|
||||||
private:
|
|
||||||
GLuint tot;
|
|
||||||
BvhPtr root;
|
|
||||||
static QVector4D calcBound(BvhTreeData initBound[], int l, int r);
|
|
||||||
static QVector4D Union(QVector4D a, QVector4D b);
|
|
||||||
BvhPtr subBvhTree(BvhTreeData initBound[], int l, int r);
|
|
||||||
void traverseBvhTree(BvhPtr now, std::vector<GLuint>& children, std::vector<QVector4D>& bounds);
|
|
||||||
public:
|
|
||||||
BvhTree() {
|
|
||||||
tot = 0;
|
|
||||||
root = NULL;
|
|
||||||
}
|
|
||||||
// 根据底层包围盒生成bvh树
|
|
||||||
void buildBvhTree(BvhTreeData initBound[], int len);
|
|
||||||
// 获得 Bvh (rootBvh部分)的 children 数组,包围盒数组 vector 传输
|
|
||||||
void getBvhArray(std::vector<GLuint>& children, std::vector<QVector4D>& bounds);
|
|
||||||
// 获得 BvhTree 中节点总数
|
|
||||||
GLuint getBvhNodeNum();
|
|
||||||
};
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "Camera.h"
|
#include "Camera.h"
|
||||||
|
using namespace Renderer;
|
||||||
|
|
||||||
|
|
||||||
// constructor with vectors
|
// constructor with vectors
|
||||||
|
|
|
@ -5,27 +5,29 @@
|
||||||
#include <QtMath>
|
#include <QtMath>
|
||||||
#include <QOpenGLFunctions_4_5_Compatibility>
|
#include <QOpenGLFunctions_4_5_Compatibility>
|
||||||
|
|
||||||
// Default camera values
|
namespace Renderer
|
||||||
const float YAW = -90.0f;
|
{
|
||||||
const float PITCH = 0.0f;
|
|
||||||
const float SPEED = 200.f;
|
|
||||||
const float SENSITIVITY = 0.1f;
|
|
||||||
const float ZOOM = 45.0f;
|
|
||||||
|
|
||||||
// Defines several possible options for camera movement. Used as abstraction to stay away from window-system specific input methods
|
// Defines several possible options for camera movement. Used as abstraction to stay away from window-system specific input methods
|
||||||
enum Camera_Movement {
|
enum Camera_Movement {
|
||||||
FORWARD,
|
FORWARD,
|
||||||
BACKWARD,
|
BACKWARD,
|
||||||
LEFT,
|
LEFT,
|
||||||
RIGHT,
|
RIGHT,
|
||||||
UP,
|
UP,
|
||||||
DOWN
|
DOWN
|
||||||
};
|
};
|
||||||
|
|
||||||
class Camera
|
class Camera
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
// Default camera values
|
||||||
|
static constexpr float YAW = -90.0f;
|
||||||
|
static constexpr float PITCH = 0.0f;
|
||||||
|
static constexpr float SPEED = 200.f;
|
||||||
|
static constexpr float SENSITIVITY = 0.1f;
|
||||||
|
static constexpr float ZOOM = 45.0f;
|
||||||
// camera Attributes
|
// camera Attributes
|
||||||
QVector3D Position;
|
QVector3D Position;
|
||||||
QVector3D Front;
|
QVector3D Front;
|
||||||
|
@ -63,8 +65,9 @@ public:
|
||||||
// processes input received from a mouse scroll-wheel event. Only requires input on the vertical wheel-axis
|
// processes input received from a mouse scroll-wheel event. Only requires input on the vertical wheel-axis
|
||||||
void ProcessMouseScroll(float yoffset);
|
void ProcessMouseScroll(float yoffset);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// calculates the front vector from the Camera's (updated) Euler Angles
|
// calculates the front vector from the Camera's (updated) Euler Angles
|
||||||
void updateCameraVectors();
|
void updateCameraVectors();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
|
@ -1,20 +0,0 @@
|
||||||
#pragma once
|
|
||||||
#include "Line.h"
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
class CubicBezier : public Line
|
|
||||||
{
|
|
||||||
using Line::Line;
|
|
||||||
private:
|
|
||||||
static Point getPointByT(Point a, Point b, double t);
|
|
||||||
static Point calculateControlPoint(Point a, Point b);
|
|
||||||
static void findPointsOfDivison(vector<double> &p, vector<double>& res);
|
|
||||||
void splitBezierCubic(double t, vector<LinePtr>& res);
|
|
||||||
public:
|
|
||||||
virtual double findTByValue(double value, bool isY);
|
|
||||||
virtual void monotonization(vector <LinePtr>& res);
|
|
||||||
virtual double getLineValueByT(double t, bool isY);
|
|
||||||
virtual int judgeBoundIntersection(double xy, double l, double r, bool isY);
|
|
||||||
void transformToCubic();
|
|
||||||
};
|
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
#include <utility>
|
|
||||||
#include <vector>
|
|
||||||
#include <algorithm>
|
|
||||||
#pragma once
|
|
||||||
using std::pair;
|
|
||||||
using std::vector;
|
|
||||||
using std::min;
|
|
||||||
using std::max;
|
|
||||||
using std::sort;
|
|
||||||
class CubicMonotonization
|
|
||||||
{
|
|
||||||
typedef pair<double, double> point;
|
|
||||||
typedef vector<point> Line;
|
|
||||||
private:
|
|
||||||
static const double eps;
|
|
||||||
point getPointByT(point a, point b, double t) const;
|
|
||||||
void findPointsOfDivison(vector<double> p, vector<double> &res);
|
|
||||||
double getBezierPoint(vector<double> &p, double t) const;
|
|
||||||
void splitBezierCubic(Line& p, point mid, double t, vector <Line> &res);
|
|
||||||
public:
|
|
||||||
// p 为端点、控制点、控制点、端点, res 为所有导数为0的点
|
|
||||||
void getPointsOfDivision(Line p, vector <Line> &res);
|
|
||||||
};
|
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
class Drawable
|
namespace Renderer
|
||||||
{
|
{
|
||||||
public:
|
class Drawable
|
||||||
|
{
|
||||||
|
public:
|
||||||
virtual void draw() = 0;
|
virtual void draw() = 0;
|
||||||
virtual void drawShadow() = 0;
|
virtual void drawShadow() = 0;
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "Light.h"
|
#include "Light.h"
|
||||||
#include <qDebug>
|
#include <qDebug>
|
||||||
|
using namespace Renderer;
|
||||||
Light::Light(Camera* camera)
|
Light::Light(Camera* camera)
|
||||||
: camera(camera)
|
: camera(camera)
|
||||||
//, shadowCascadeLevels{ camera->FarPlane / 25.0f, camera->FarPlane / 12.0f, camera->FarPlane / 6.0f, camera->FarPlane / 3.0f }
|
//, shadowCascadeLevels{ camera->FarPlane / 25.0f, camera->FarPlane / 12.0f, camera->FarPlane / 6.0f, camera->FarPlane / 3.0f }
|
||||||
|
|
|
@ -9,9 +9,11 @@
|
||||||
#include "Camera.h"
|
#include "Camera.h"
|
||||||
#include "Model.h"
|
#include "Model.h"
|
||||||
|
|
||||||
class Light
|
namespace Renderer
|
||||||
{
|
{
|
||||||
public:
|
class Light
|
||||||
|
{
|
||||||
|
public:
|
||||||
QVector3D lightDirection = QVector3D(0.2, 4, 1).normalized();
|
QVector3D lightDirection = QVector3D(0.2, 4, 1).normalized();
|
||||||
std::vector<float> shadowCascadeLevels;
|
std::vector<float> shadowCascadeLevels;
|
||||||
float blendRatio = 0.3;
|
float blendRatio = 0.3;
|
||||||
|
@ -22,8 +24,9 @@ public:
|
||||||
std::vector<QVector4D> getFrustumCornersWorldSpace(const QMatrix4x4& proj, const QMatrix4x4& view);
|
std::vector<QVector4D> getFrustumCornersWorldSpace(const QMatrix4x4& proj, const QMatrix4x4& view);
|
||||||
QMatrix4x4 getLightSpaceMatrix(const float nearPlane, const float farPlane);
|
QMatrix4x4 getLightSpaceMatrix(const float nearPlane, const float farPlane);
|
||||||
std::vector<QMatrix4x4> getLightSpaceMatrices();
|
std::vector<QMatrix4x4> getLightSpaceMatrices();
|
||||||
private:
|
private:
|
||||||
Camera* camera;
|
Camera* camera;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,65 +0,0 @@
|
||||||
#pragma once
|
|
||||||
#include <vector>
|
|
||||||
#include <utility>
|
|
||||||
#include <vector>
|
|
||||||
#include <QVector4D>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <memory>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
using std::vector;
|
|
||||||
using std::pair;
|
|
||||||
using std::min;
|
|
||||||
using std::max;
|
|
||||||
using std::sort;
|
|
||||||
using std::shared_ptr;
|
|
||||||
using std::make_shared;
|
|
||||||
using std::swap;
|
|
||||||
|
|
||||||
const double eps = 1e-5;
|
|
||||||
|
|
||||||
struct Point {
|
|
||||||
double x, y;
|
|
||||||
Point operator + (const Point a) { return { x + a.x, y + a.y }; }
|
|
||||||
Point operator - (const Point a) { return { x - a.x, y - a.y }; }
|
|
||||||
Point operator * (const double a) { return { x * a, y * a }; }
|
|
||||||
double operator * (const Point a) { return x * a.y - y * a.x; }
|
|
||||||
bool operator== (const Point& a) const {
|
|
||||||
return fabs(x - a.x) <= eps && fabs(y - a.y) <= eps;
|
|
||||||
}
|
|
||||||
bool operator< (const Point& a) const {
|
|
||||||
return fabs(x - a.x) <= eps ? y < a.y : x < a.x;
|
|
||||||
}
|
|
||||||
void show() {
|
|
||||||
std::cout << '(' << x << ',' << y << ')' << ' ';
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class Line
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
vector<double> vX, vY;
|
|
||||||
int siz;
|
|
||||||
public:
|
|
||||||
typedef shared_ptr<Line> LinePtr;
|
|
||||||
Line() :siz(0) {}
|
|
||||||
Line(vector<Point> Vp);
|
|
||||||
int size();
|
|
||||||
void clear();
|
|
||||||
Point getBegin();
|
|
||||||
Point getEnd();
|
|
||||||
int direction(bool isY);
|
|
||||||
virtual double getLineValueByT(double t, bool isY) = 0;
|
|
||||||
virtual void monotonization(vector <LinePtr>& res) = 0;
|
|
||||||
virtual int judgeBoundIntersection(double xy, double l, double r, bool isY) = 0;
|
|
||||||
virtual bool judgeIntersection(QVector4D bound);
|
|
||||||
bool isLineContained(QVector4D bound);
|
|
||||||
Point operator[](int index) const;
|
|
||||||
Point getPointByIndex(int index) const;
|
|
||||||
vector<Point> toPointVector() const;
|
|
||||||
void setPointByIndex(int index, Point now);
|
|
||||||
void push_back(Point now);
|
|
||||||
virtual ~Line() {}
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef shared_ptr<Line> LinePtr;
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "Mesh.h"
|
#include "Mesh.h"
|
||||||
|
using namespace Renderer;
|
||||||
Mesh::Mesh(QOpenGLFunctions_4_5_Compatibility* glFunc, QOpenGLShaderProgram* shaderProgram, QOpenGLShaderProgram* shadowProgram, aiMatrix4x4 model)
|
Mesh::Mesh(QOpenGLFunctions_4_5_Compatibility* glFunc, QOpenGLShaderProgram* shaderProgram, QOpenGLShaderProgram* shadowProgram, aiMatrix4x4 model)
|
||||||
: glFunc(glFunc)
|
: glFunc(glFunc)
|
||||||
, shaderProgram(shaderProgram)
|
, shaderProgram(shaderProgram)
|
||||||
|
|
|
@ -13,18 +13,19 @@
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
#include "Drawable.h"
|
#include "Drawable.h"
|
||||||
|
namespace Renderer
|
||||||
struct Vertex
|
|
||||||
{
|
{
|
||||||
|
struct Vertex
|
||||||
|
{
|
||||||
QVector3D Position;
|
QVector3D Position;
|
||||||
QVector3D Normal;
|
QVector3D Normal;
|
||||||
QVector2D TexCoords;
|
QVector2D TexCoords;
|
||||||
QVector3D Tangent;
|
QVector3D Tangent;
|
||||||
QVector3D Bitangent;
|
QVector3D Bitangent;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Texture
|
struct Texture
|
||||||
{
|
{
|
||||||
QOpenGLTexture texture;
|
QOpenGLTexture texture;
|
||||||
QString type;
|
QString type;
|
||||||
QString path;
|
QString path;
|
||||||
|
@ -34,11 +35,11 @@ struct Texture
|
||||||
texture.setWrapMode(QOpenGLTexture::DirectionT, QOpenGLTexture::Repeat);
|
texture.setWrapMode(QOpenGLTexture::DirectionT, QOpenGLTexture::Repeat);
|
||||||
texture.setMinMagFilters(QOpenGLTexture::LinearMipMapLinear, QOpenGLTexture::Linear);
|
texture.setMinMagFilters(QOpenGLTexture::LinearMipMapLinear, QOpenGLTexture::Linear);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class Mesh : public Drawable
|
class Mesh : public Drawable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/* 网格数据 */
|
/* 网格数据 */
|
||||||
QVector<Vertex> vertices; //顶点数据
|
QVector<Vertex> vertices; //顶点数据
|
||||||
QVector<unsigned int> indices; //索引数组
|
QVector<unsigned int> indices; //索引数组
|
||||||
|
@ -53,9 +54,10 @@ public:
|
||||||
void drawShadow() override;
|
void drawShadow() override;
|
||||||
void setupMesh();
|
void setupMesh();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/* 渲染数据 */
|
/* 渲染数据 */
|
||||||
QOpenGLVertexArrayObject VAO;
|
QOpenGLVertexArrayObject VAO;
|
||||||
QOpenGLBuffer VBO, EBO;
|
QOpenGLBuffer VBO, EBO;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
}
|
|
@ -6,10 +6,11 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "PaintingMesh.h"
|
#include "PaintingMesh.h"
|
||||||
#include <QtMath>
|
#include <QtMath>
|
||||||
#include "BvhTree.h"
|
#include "Painting/BvhTree.h"
|
||||||
#include "ShortCutTree.h"
|
#include "Painting/ShortCutTree.h"
|
||||||
#include "../SvgParser.h"
|
#include "../SvgParser.h"
|
||||||
|
using namespace Renderer;
|
||||||
|
using std::vector;
|
||||||
Model::Model(QString path, QOpenGLContext* context, QOpenGLShaderProgram* shaderProgram)
|
Model::Model(QString path, QOpenGLContext* context, QOpenGLShaderProgram* shaderProgram)
|
||||||
: context(context)
|
: context(context)
|
||||||
, glFunc(context->versionFunctions<QOpenGLFunctions_4_5_Compatibility>())
|
, glFunc(context->versionFunctions<QOpenGLFunctions_4_5_Compatibility>())
|
||||||
|
@ -205,172 +206,178 @@ Drawable* Model::processMesh(aiMesh* mesh, const aiScene* scene, aiMatrix4x4 mod
|
||||||
// {{-0.5,0.3}, {-0.420466,0.379534}, {-0.736743,0.6}, {-0.624264,0.6}},
|
// {{-0.5,0.3}, {-0.420466,0.379534}, {-0.736743,0.6}, {-0.624264,0.6}},
|
||||||
// {{-0.624264,0.6}, {-0.511785,0.6}, {-0.579534,0.979534}, {-0.5,0.9}}
|
// {{-0.624264,0.6}, {-0.511785,0.6}, {-0.579534,0.979534}, {-0.5,0.9}}
|
||||||
//};
|
//};
|
||||||
vector<vector<Point>> lineSet = SvgParser("M377,459.61a11.26,11.26,0,0,1,11.27-11.27H696.12a11.27,11.27,0,0,0,11-8.62A359.84,359.84,0,0,0,708,280.56a11.26,11.26,0,0,0-11-8.73H388.27A11.26,11.26,0,0,1,377,260.57h0a11.26,11.26,0,0,1,11.27-11.26H683.71A11.32,11.32,0,0,0,694.28,234C649.8,113.69,542.57,23.85,412.3,4.12a11.22,11.22,0,0,0-12.76,11.17v158.9a11.26,11.26,0,0,0,11.26,11.27H583.12a11.32,11.32,0,0,0,9.26-17.75c-31.67-46.59-78.51-75.2-109.11-90.07a11.25,11.25,0,0,0-16.13,10.17V115.2a11.24,11.24,0,0,0,6.22,10.07l7.51,3.76a11.28,11.28,0,0,1,5,15.12h0a11.27,11.27,0,0,1-15.11,5l-20-10a11.27,11.27,0,0,1-6.22-10.07V54a11.27,11.27,0,0,1,14.62-10.75c5.11,1.59,125.66,40.35,172.24,149A11.27,11.27,0,0,1,621.11,208H388.27A11.26,11.26,0,0,1,377,196.73V11.36A11.32,11.32,0,0,0,365.89.08C363.34,0,360.79,0,358.22,0s-5.11,0-7.66.08a11.32,11.32,0,0,0-11.11,11.28V196.74A11.26,11.26,0,0,1,328.18,208H95.35A11.27,11.27,0,0,1,85,192.3c46.57-108.67,167.12-147.42,172.23-149A11.26,11.26,0,0,1,271.86,54v75.11a11.25,11.25,0,0,1-6.23,10.07l-20,10a11.27,11.27,0,0,1-15.11-5h0a11.26,11.26,0,0,1,5-15.11l7.52-3.76a11.27,11.27,0,0,0,6.22-10.07V87.82a11.25,11.25,0,0,0-16.14-10.16c-30.6,14.87-77.45,43.48-109.1,90.07a11.3,11.3,0,0,0,9.25,17.74H305.66a11.26,11.26,0,0,0,11.27-11.26V15.31A11.22,11.22,0,0,0,304.17,4.14C173.88,23.86,66.66,113.71,22.17,234a11.32,11.32,0,0,0,10.56,15.29H328.18a11.26,11.26,0,0,1,11.27,11.26v0a11.26,11.26,0,0,1-11.27,11.26H19.52a11.26,11.26,0,0,0-11,8.72,359.84,359.84,0,0,0,.83,159.16,11.26,11.26,0,0,0,11,8.61H328.18a11.26,11.26,0,0,1,11.27,11.27h0a11.26,11.26,0,0,1-11.27,11.26h-294a11.32,11.32,0,0,0-10.53,15.4C69,604.65,175.3,692.78,304.16,712.3a11.21,11.21,0,0,0,12.76-11.16V542.22A11.26,11.26,0,0,0,305.66,531h-166c-9.53,0-14.89,11.22-8.69,18.47,34.09,39.77,74.45,65.66,101.77,80.18a11.25,11.25,0,0,0,16.53-10V591a11.26,11.26,0,0,1,11.26-11.26h0A11.26,11.26,0,0,1,271.85,591v63.85A11.27,11.27,0,0,1,256.8,665.5c-4.45-1.59-109.58-40-171-139.9a11.27,11.27,0,0,1,9.59-17.17H328.18a11.26,11.26,0,0,1,11.27,11.26V705.08a11.32,11.32,0,0,0,11.11,11.28q3.82.07,7.66.08c2.57,0,5.12,0,7.67-.08A11.32,11.32,0,0,0,377,705.08V519.69a11.25,11.25,0,0,1,11.27-11.26H621.1a11.26,11.26,0,0,1,9.59,17.16c-61.46,99.87-166.59,138.3-171,139.9a11.27,11.27,0,0,1-15-10.61V591a11.26,11.26,0,0,1,11.26-11.26h0A11.26,11.26,0,0,1,467.14,591v28.6a11.25,11.25,0,0,0,16.53,10c27.33-14.53,67.68-40.42,101.77-80.19,6.2-7.23.85-18.46-8.69-18.46h-166a11.26,11.26,0,0,0-11.26,11.26V701.12a11.21,11.21,0,0,0,12.76,11.17c128.86-19.51,235.14-107.66,280.48-226a11.33,11.33,0,0,0-10.53-15.41h-294A11.25,11.25,0,0,1,377,459.61ZM35.27,399.53V316.9a11.26,11.26,0,0,1,11.27-11.26H669.92a11.25,11.25,0,0,1,11.26,11.26v82.63a11.25,11.25,0,0,1-11.26,11.26H46.54a11.27,11.27,0,0,1-11.27-11.26Z", 716.45, 716.44).parse();
|
/*vector<vector<Point>> lineSet = SvgParser("M377,459.61a11.26,11.26,0,0,1,11.27-11.27H696.12a11.27,11.27,0,0,0,11-8.62A359.84,359.84,0,0,0,708,280.56a11.26,11.26,0,0,0-11-8.73H388.27A11.26,11.26,0,0,1,377,260.57h0a11.26,11.26,0,0,1,11.27-11.26H683.71A11.32,11.32,0,0,0,694.28,234C649.8,113.69,542.57,23.85,412.3,4.12a11.22,11.22,0,0,0-12.76,11.17v158.9a11.26,11.26,0,0,0,11.26,11.27H583.12a11.32,11.32,0,0,0,9.26-17.75c-31.67-46.59-78.51-75.2-109.11-90.07a11.25,11.25,0,0,0-16.13,10.17V115.2a11.24,11.24,0,0,0,6.22,10.07l7.51,3.76a11.28,11.28,0,0,1,5,15.12h0a11.27,11.27,0,0,1-15.11,5l-20-10a11.27,11.27,0,0,1-6.22-10.07V54a11.27,11.27,0,0,1,14.62-10.75c5.11,1.59,125.66,40.35,172.24,149A11.27,11.27,0,0,1,621.11,208H388.27A11.26,11.26,0,0,1,377,196.73V11.36A11.32,11.32,0,0,0,365.89.08C363.34,0,360.79,0,358.22,0s-5.11,0-7.66.08a11.32,11.32,0,0,0-11.11,11.28V196.74A11.26,11.26,0,0,1,328.18,208H95.35A11.27,11.27,0,0,1,85,192.3c46.57-108.67,167.12-147.42,172.23-149A11.26,11.26,0,0,1,271.86,54v75.11a11.25,11.25,0,0,1-6.23,10.07l-20,10a11.27,11.27,0,0,1-15.11-5h0a11.26,11.26,0,0,1,5-15.11l7.52-3.76a11.27,11.27,0,0,0,6.22-10.07V87.82a11.25,11.25,0,0,0-16.14-10.16c-30.6,14.87-77.45,43.48-109.1,90.07a11.3,11.3,0,0,0,9.25,17.74H305.66a11.26,11.26,0,0,0,11.27-11.26V15.31A11.22,11.22,0,0,0,304.17,4.14C173.88,23.86,66.66,113.71,22.17,234a11.32,11.32,0,0,0,10.56,15.29H328.18a11.26,11.26,0,0,1,11.27,11.26v0a11.26,11.26,0,0,1-11.27,11.26H19.52a11.26,11.26,0,0,0-11,8.72,359.84,359.84,0,0,0,.83,159.16,11.26,11.26,0,0,0,11,8.61H328.18a11.26,11.26,0,0,1,11.27,11.27h0a11.26,11.26,0,0,1-11.27,11.26h-294a11.32,11.32,0,0,0-10.53,15.4C69,604.65,175.3,692.78,304.16,712.3a11.21,11.21,0,0,0,12.76-11.16V542.22A11.26,11.26,0,0,0,305.66,531h-166c-9.53,0-14.89,11.22-8.69,18.47,34.09,39.77,74.45,65.66,101.77,80.18a11.25,11.25,0,0,0,16.53-10V591a11.26,11.26,0,0,1,11.26-11.26h0A11.26,11.26,0,0,1,271.85,591v63.85A11.27,11.27,0,0,1,256.8,665.5c-4.45-1.59-109.58-40-171-139.9a11.27,11.27,0,0,1,9.59-17.17H328.18a11.26,11.26,0,0,1,11.27,11.26V705.08a11.32,11.32,0,0,0,11.11,11.28q3.82.07,7.66.08c2.57,0,5.12,0,7.67-.08A11.32,11.32,0,0,0,377,705.08V519.69a11.25,11.25,0,0,1,11.27-11.26H621.1a11.26,11.26,0,0,1,9.59,17.16c-61.46,99.87-166.59,138.3-171,139.9a11.27,11.27,0,0,1-15-10.61V591a11.26,11.26,0,0,1,11.26-11.26h0A11.26,11.26,0,0,1,467.14,591v28.6a11.25,11.25,0,0,0,16.53,10c27.33-14.53,67.68-40.42,101.77-80.19,6.2-7.23.85-18.46-8.69-18.46h-166a11.26,11.26,0,0,0-11.26,11.26V701.12a11.21,11.21,0,0,0,12.76,11.17c128.86-19.51,235.14-107.66,280.48-226a11.33,11.33,0,0,0-10.53-15.41h-294A11.25,11.25,0,0,1,377,459.61ZM35.27,399.53V316.9a11.26,11.26,0,0,1,11.27-11.26H669.92a11.25,11.25,0,0,1,11.26,11.26v82.63a11.25,11.25,0,0,1-11.26,11.26H46.54a11.27,11.27,0,0,1-11.27-11.26Z", 716.45, 716.44).parse();
|
||||||
qDebug() << lineSet.size();
|
qDebug() << lineSet.size();
|
||||||
for (vector<Point>& line : lineSet)
|
for (vector<Point>& line : lineSet)
|
||||||
{
|
{
|
||||||
for (Point& p : line)
|
for (Point& p : line)
|
||||||
p.show();
|
p.show();
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//vector<vector<Point>> lineSet = { {Point{-1,-1}, Point{1,-1}},{Point{1,-1}, Point{1,1}}, {Point{1,1}, Point{-1,1}},{Point{-1,1}, Point{-1,-1}} };
|
|
||||||
//vector<vector<Point>> lineSet = { {Point{-1,-1}, Point{1,-1}},{Point{1,-1}, Point{1,1}}, {Point{1,1}, Point{-1,1}},{Point{-1,1}, Point{-1,-1}} };
|
|
||||||
ShortCutTree shortCutTree(20);
|
|
||||||
shortCutTree.buildShortCutTree(lineSet);
|
|
||||||
vector<float> pointVector;
|
|
||||||
vector<GLuint> lineVector;
|
|
||||||
vector<BvhTreeData> bvhTreeData = shortCutTree.getPointLineAndBvhTree(pointVector, lineVector);
|
|
||||||
qDebug() << "----------------------------------------------";
|
|
||||||
qDebug() << "element0CellNum: " << bvhTreeData.size();
|
|
||||||
//qDebug() << pointVector;
|
|
||||||
//qDebug() << lineVector;
|
|
||||||
/*for (BvhTreeData data : bvhTreeData)
|
|
||||||
{
|
|
||||||
data.show();
|
|
||||||
}*/
|
}*/
|
||||||
BvhTree element0Bvh;
|
|
||||||
element0Bvh.buildBvhTree(bvhTreeData.data(), bvhTreeData.size());
|
|
||||||
std::vector<GLuint> element0Children;
|
|
||||||
std::vector<QVector4D> element0Bounds;
|
|
||||||
element0Bvh.getBvhArray(element0Children, element0Bounds);
|
|
||||||
//qDebug() << element0Children;
|
|
||||||
//qDebug() << element0Bounds;
|
|
||||||
|
|
||||||
//std::vector<GLuint> bvhChildren = {
|
|
||||||
// //root
|
|
||||||
// 1,2,
|
|
||||||
// 3,4, 5,6,
|
|
||||||
// encodeChild(0),0, encodeChild(0),GLuint(30. / 360 * 65536 + 1 * 65536) /*右儿子用来表示旋转角度和zIndex*/, encodeChild(0),0, encodeChild(0),0
|
|
||||||
//};
|
|
||||||
//std::vector<QVector4D> bvhBounds = {
|
|
||||||
// //root
|
|
||||||
// QVector4D(-1,-1,1,1),
|
|
||||||
// QVector4D(-0.9,-0.9,-0.1,0.9), QVector4D(0.1, -0.9,0.9,0.9),
|
|
||||||
// QVector4D(-0.8,-0.8,-0.2,-0.1), QVector4D(-0.7,0.2,-0.2,0.7), QVector4D(0.2,-0.8,0.8,-0.1), QVector4D(0.2,0.1,0.8,0.8),
|
|
||||||
//};
|
|
||||||
std::vector<GLuint> bvhChildren;
|
|
||||||
std::vector<QVector4D> bvhBounds;
|
|
||||||
rootBvhTree.getBvhArray(bvhChildren, bvhBounds);
|
|
||||||
|
|
||||||
//qDebug() << bvhChildren;
|
|
||||||
bvhChildren.insert(bvhChildren.end(), element0Children.begin(), element0Children.end());
|
|
||||||
bvhBounds.insert(bvhBounds.end(), element0Bounds.begin(), element0Bounds.end());
|
|
||||||
|
|
||||||
std::vector<GLuint> elementOffset = {
|
|
||||||
//element0
|
|
||||||
rootBvhTree.getBvhNodeNum(), //elementBvhRoot
|
|
||||||
(GLuint)element0Bounds.size(), //elementBvhLength
|
|
||||||
0, //pointsOffset
|
|
||||||
0, //linesOffset
|
|
||||||
};
|
|
||||||
std::vector<GLuint> elementIndex = lineVector;
|
|
||||||
std::vector<GLfloat> elementData = {
|
|
||||||
//fillStyle
|
|
||||||
//fill
|
|
||||||
0,
|
|
||||||
//fillType
|
|
||||||
0, //单色
|
|
||||||
//fillColorMetallicRoughness
|
|
||||||
240/255.,220/255.,160/255., 0.996,0.18,
|
|
||||||
};
|
|
||||||
elementData.insert(elementData.begin(), pointVector.begin(), pointVector.end());
|
|
||||||
//qDebug() << elementIndex;
|
|
||||||
//qDebug() << elementData;
|
|
||||||
|
|
||||||
|
|
||||||
//std::vector<GLuint> bvhChildren0 = {
|
//ShortCutTree shortCutTree(20);
|
||||||
// //root
|
//shortCutTree.buildShortCutTree(lineSet);
|
||||||
// 1,2,
|
//vector<GLfloat> pointVector;
|
||||||
// 3,4, 5,6,
|
//vector<GLuint> lineVector;
|
||||||
// encodeChild(0),0, encodeChild(0),GLuint(30. / 360 * 65536 + 1 * 65536) /*右儿子用来表示旋转角度和zIndex*/, encodeChild(1),0, encodeChild(0),0,
|
//vector<BvhTreeData> bvhTreeData = shortCutTree.getPointLineAndBvhTree(pointVector, lineVector);
|
||||||
// //elememt0
|
//for (auto& data : bvhTreeData)
|
||||||
// 1,2,
|
// data.rightSon = 0;
|
||||||
// encodeChild(20)/*contour索引,由于contour不定长,这里需要给到contour在elementIndex中位置*/,14/*style索引,在elementData中位置*/, encodeChild(24), 14,
|
//qDebug() << "----------------------------------------------";
|
||||||
// //elememt1
|
//qDebug() << "element0CellNum: " << bvhTreeData.size();
|
||||||
// encodeChild(0)/*line索引,element中第几条*/, 27
|
////qDebug() << pointVector;
|
||||||
|
////qDebug() << lineVector;
|
||||||
|
///*for (BvhTreeData data : bvhTreeData)
|
||||||
|
//{
|
||||||
|
// data.show();
|
||||||
|
//}*/
|
||||||
|
//BvhTree element0Bvh;
|
||||||
|
//element0Bvh.buildBvhTree(bvhTreeData.data(), bvhTreeData.size());
|
||||||
|
//std::vector<GLuint> element0Children;
|
||||||
|
//std::vector<QVector4D> element0Bounds;
|
||||||
|
//element0Bvh.getBvhArray(element0Children, element0Bounds);
|
||||||
|
////qDebug() << element0Children;
|
||||||
|
////qDebug() << element0Bounds;
|
||||||
|
|
||||||
//};
|
////std::vector<GLuint> bvhChildren = {
|
||||||
//std::vector<QVector4D> bvhBounds0 = {
|
//// //root
|
||||||
// //root
|
//// 1,2,
|
||||||
// QVector4D(-1,-1,1,1),
|
//// 3,4, 5,6,
|
||||||
// QVector4D(-0.9,-0.9,-0.1,0.9), QVector4D(0.1, -0.9,0.9,0.9),
|
//// encodeChild(0),0, encodeChild(0),GLuint(30. / 360 * 65536 + 1 * 65536) /*右儿子用来表示旋转角度和zIndex*/, encodeChild(0),0, encodeChild(0),0
|
||||||
// QVector4D(-0.8,-0.8,-0.2,-0.1), QVector4D(-0.7,0.2,-0.2,0.7), QVector4D(0.2,-0.8,0.8,-0.1), QVector4D(0.2,0.1,0.8,0.8),
|
////};
|
||||||
// //elememt0
|
////std::vector<QVector4D> bvhBounds = {
|
||||||
// QVector4D(-1,-1,1,1),
|
//// //root
|
||||||
// QVector4D(-1,-1,-0.2,1), QVector4D(-0.2,-1,1,1),
|
//// QVector4D(-1,-1,1,1),
|
||||||
// //elememt1
|
//// QVector4D(-0.9,-0.9,-0.1,0.9), QVector4D(0.1, -0.9,0.9,0.9),
|
||||||
// QVector4D(-1,-1,1,1)
|
//// QVector4D(-0.8,-0.8,-0.2,-0.1), QVector4D(-0.7,0.2,-0.2,0.7), QVector4D(0.2,-0.8,0.8,-0.1), QVector4D(0.2,0.1,0.8,0.8),
|
||||||
//};
|
////};
|
||||||
//std::vector<GLuint> elementOffset0 = {
|
//std::vector<GLuint> bvhChildren;
|
||||||
// //element0
|
//std::vector<QVector4D> bvhBounds;
|
||||||
// 7, //elementBvhRoot
|
//rootBvhTree.getBvhArray(bvhChildren, bvhBounds);
|
||||||
// 3, //elementBvhLength
|
//
|
||||||
// 0, //pointsOffset
|
////qDebug() << bvhChildren;
|
||||||
// 0, //linesOffset
|
//bvhChildren.insert(bvhChildren.end(), element0Children.begin(), element0Children.end());
|
||||||
// //element1
|
//bvhBounds.insert(bvhBounds.end(), element0Bounds.begin(), element0Bounds.end());
|
||||||
// 10, //elementBvhRoot
|
|
||||||
// 1, //elementBvhLength
|
|
||||||
// 21, //pointsOffset
|
|
||||||
// 28, //linesOffset
|
|
||||||
//};
|
|
||||||
|
|
||||||
//std::vector<GLuint> elementIndex0 = {
|
|
||||||
// //element0
|
|
||||||
// //lines, 全部当作三阶贝塞尔, 每条线四个点索引
|
|
||||||
// 0,1,1,2,
|
|
||||||
// 0,0,3,3,
|
|
||||||
// 3,4,4,5,
|
|
||||||
// 2,2,5,5,
|
|
||||||
// 5,5,6,6,
|
|
||||||
// //contours, 第一个元素为线数,后面为轮廓线索引
|
|
||||||
// 3, 1,2,4,
|
|
||||||
// 3, 0,2,3,
|
|
||||||
// //element1
|
|
||||||
// //lines
|
|
||||||
// 0,1,1,2
|
|
||||||
//};
|
|
||||||
|
|
||||||
//std::vector<GLfloat> elementData0 = {
|
//std::vector<GLuint> elementIndex = lineVector;
|
||||||
// //element0
|
//std::vector<GLfloat> elementData = {
|
||||||
// //points
|
|
||||||
// -0.2,1, -0.2,-0.2, 1,-0.2, -1,1, -1,-1, 1,-1, 1,1,
|
|
||||||
// //fillStyle
|
// //fillStyle
|
||||||
// //fill
|
// //fill
|
||||||
// 0,
|
// 0,
|
||||||
// //fillType
|
// //fillType
|
||||||
// 0, //µ¥É«
|
// 0, //µ¥É«
|
||||||
// //fillColorMetallicRoughness
|
// //fillColorMetallicRoughness
|
||||||
// 1,1,0, 0,0.8,
|
// 240/255.,220/255.,160/255., 0.996,0.18,
|
||||||
|
|
||||||
// //element1
|
|
||||||
// //points
|
|
||||||
// 0,0.8, 1,0, 0,-0.8,
|
|
||||||
// //strokeStyle
|
|
||||||
// //stroke
|
|
||||||
// 1,
|
|
||||||
// //strokeWidth
|
|
||||||
// 0.02,
|
|
||||||
// //strokeEndType
|
|
||||||
// 0, //圆角
|
|
||||||
// //strokeFillType
|
|
||||||
// 0, //单色
|
|
||||||
// //线类型
|
|
||||||
// 1, //左侧
|
|
||||||
// //线外描边宽度
|
|
||||||
// 0,
|
|
||||||
// //线外描边方式
|
|
||||||
// 0, //单色
|
|
||||||
// //strokeFillColorMetallicRoughness
|
|
||||||
// 1,0,1, 0,0.8
|
|
||||||
//};
|
//};
|
||||||
|
//std::vector<GLuint> elementOffset = {
|
||||||
|
// //element0
|
||||||
|
// rootBvhTree.getBvhNodeNum(), //elementBvhRoot
|
||||||
|
// (GLuint)element0Bounds.size(), //elementBvhLength
|
||||||
|
// (GLuint)elementData.size(), //pointsOffset
|
||||||
|
// 0, //linesOffset
|
||||||
|
//};
|
||||||
|
//elementData.insert(elementData.end(), pointVector.begin(), pointVector.end());
|
||||||
|
////qDebug() << elementIndex;
|
||||||
|
////qDebug() << elementData;
|
||||||
|
|
||||||
|
|
||||||
|
std::vector<GLuint> bvhChildren0 = {
|
||||||
|
//root
|
||||||
|
1,2,
|
||||||
|
3,4, 5,6,
|
||||||
|
encodeChild(0),0, encodeChild(0),GLuint(30. / 360 * 65536 + 1 * 65536) /*右儿子用来表示旋转角度和zIndex*/, encodeChild(1),0, encodeChild(0),0,
|
||||||
|
//elememt0
|
||||||
|
1,2,
|
||||||
|
encodeChild(20)/*contour索引,由于contour不定长,这里需要给到contour在elementIndex中位置*/,14/*style索引,在elementData中位置*/, encodeChild(24), 14,
|
||||||
|
//elememt1
|
||||||
|
encodeChild(12)/*contour索引*/, 35
|
||||||
|
|
||||||
|
};
|
||||||
|
std::vector<QVector4D> bvhBounds0 = {
|
||||||
|
//root
|
||||||
|
QVector4D(-1,-1,1,1),
|
||||||
|
QVector4D(-0.9,-0.9,-0.1,0.9), QVector4D(0.1, -0.9,0.9,0.9),
|
||||||
|
QVector4D(-0.8,-0.8,-0.2,-0.1), QVector4D(-0.7,0.2,-0.2,0.7), QVector4D(0.2,-0.8,0.8,-0.1), QVector4D(0.2,0.1,0.8,0.8),
|
||||||
|
//elememt0
|
||||||
|
QVector4D(-1,-1,1,1),
|
||||||
|
QVector4D(-1,-1,-0.2,1), QVector4D(-0.2,-1,1,1),
|
||||||
|
//elememt1
|
||||||
|
QVector4D(-1,-1,1,1)
|
||||||
|
};
|
||||||
|
std::vector<GLuint> elementOffset0 = {
|
||||||
|
//element0
|
||||||
|
7, //elementBvhRoot
|
||||||
|
3, //elementBvhLength
|
||||||
|
0, //pointsOffset
|
||||||
|
0, //linesOffset
|
||||||
|
//element1
|
||||||
|
10, //elementBvhRoot
|
||||||
|
1, //elementBvhLength
|
||||||
|
21, //pointsOffset
|
||||||
|
28, //linesOffset
|
||||||
|
};
|
||||||
|
|
||||||
|
std::vector<GLuint> elementIndex0 = {
|
||||||
|
//element0
|
||||||
|
//lines, 全部当作三阶贝塞尔, 每条线四个点索引
|
||||||
|
0,1,1,2,
|
||||||
|
0,0,3,3,
|
||||||
|
3,4,4,5,
|
||||||
|
2,2,5,5,
|
||||||
|
5,5,6,6,
|
||||||
|
//contours, 第一个元素为线数,后面为轮廓线索引
|
||||||
|
3, 1,2,4,
|
||||||
|
3, 0,2,3,
|
||||||
|
//element1
|
||||||
|
//lines
|
||||||
|
0,0,1,1,
|
||||||
|
1,2,3,4,
|
||||||
|
5,5,6,6,
|
||||||
|
//contours
|
||||||
|
3, 0+ 0x80000000 ,1,2
|
||||||
|
};
|
||||||
|
|
||||||
|
std::vector<GLfloat> elementData0 = {
|
||||||
|
//element0
|
||||||
|
//points
|
||||||
|
-0.2,1, -0.2,-0.2, 1,-0.2, -1,1, -1,-1, 1,-1, 1,1,
|
||||||
|
//fillStyle
|
||||||
|
//fill
|
||||||
|
0,
|
||||||
|
//fillType
|
||||||
|
0, //单色
|
||||||
|
//fillColorMetallicRoughness
|
||||||
|
1,1,0, 0,0.8,
|
||||||
|
|
||||||
|
//element1
|
||||||
|
//points
|
||||||
|
-0.5,-0.5, -0.5,0.5, 0.2,0.5, 0.5,0.2, 0.5,-0.5, -0.8,-0.5, -0.8,0.5,
|
||||||
|
//strokeStyle
|
||||||
|
//stroke
|
||||||
|
1,
|
||||||
|
//strokeWidth
|
||||||
|
0.02,
|
||||||
|
//strokeEndType
|
||||||
|
0, //圆角
|
||||||
|
//strokeFillType
|
||||||
|
0, //单色
|
||||||
|
//线类型
|
||||||
|
1, //左侧
|
||||||
|
//线外描边宽度
|
||||||
|
0,
|
||||||
|
//线外描边方式
|
||||||
|
0, //单色
|
||||||
|
//strokeFillColorMetallicRoughness
|
||||||
|
1,0,1, 0,0.8
|
||||||
|
};
|
||||||
|
|
||||||
//m_mesh->paintingIndex = paintingHelper->addPainting(bounds.size(), std::vector<GLuint>(children.begin()+2, children.end()), bounds,
|
//m_mesh->paintingIndex = paintingHelper->addPainting(bounds.size(), std::vector<GLuint>(children.begin()+2, children.end()), bounds,
|
||||||
// elementOffset, elementIndex, elementData);
|
// elementOffset, elementIndex, elementData);
|
||||||
m_mesh->paintingIndex = paintingHelper->addPainting(rootBvhTree.getBvhNodeNum(), bvhChildren, bvhBounds,
|
//m_mesh->paintingIndex = paintingHelper->addPainting(rootBvhTree.getBvhNodeNum(), bvhChildren, bvhBounds,
|
||||||
elementOffset, elementIndex, elementData);
|
// elementOffset, elementIndex, elementData);
|
||||||
|
m_mesh->paintingIndex = paintingHelper->addPainting(7, bvhChildren0, bvhBounds0,
|
||||||
|
elementOffset0, elementIndex0, elementData0);
|
||||||
m_mesh->setupMesh();
|
m_mesh->setupMesh();
|
||||||
return m_mesh;
|
return m_mesh;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,14 @@
|
||||||
|
|
||||||
#include "Mesh.h"
|
#include "Mesh.h"
|
||||||
#include "Drawable.h"
|
#include "Drawable.h"
|
||||||
#include "PaintingHelper.h"
|
#include "Painting/PaintingHelper.h"
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
class Model
|
namespace Renderer
|
||||||
{
|
{
|
||||||
public:
|
class Model
|
||||||
|
{
|
||||||
|
public:
|
||||||
std::vector<QVector3D> AABB;
|
std::vector<QVector3D> AABB;
|
||||||
|
|
||||||
void draw();
|
void draw();
|
||||||
|
@ -15,7 +17,7 @@ public:
|
||||||
void destroy();
|
void destroy();
|
||||||
static Model* createModel(QString path, QOpenGLContext* context, QOpenGLShaderProgram* shaderProgram);
|
static Model* createModel(QString path, QOpenGLContext* context, QOpenGLShaderProgram* shaderProgram);
|
||||||
Model(QString path, QOpenGLContext* context, QOpenGLShaderProgram* shaderProgram, QOpenGLShaderProgram* paintingProgram, QOpenGLShaderProgram* shadowProgram, PaintingHelper* paintingHelper);
|
Model(QString path, QOpenGLContext* context, QOpenGLShaderProgram* shaderProgram, QOpenGLShaderProgram* paintingProgram, QOpenGLShaderProgram* shadowProgram, PaintingHelper* paintingHelper);
|
||||||
private:
|
private:
|
||||||
Model(QString path, QOpenGLContext* context, QOpenGLShaderProgram* shaderProgram);
|
Model(QString path, QOpenGLContext* context, QOpenGLShaderProgram* shaderProgram);
|
||||||
|
|
||||||
~Model();
|
~Model();
|
||||||
|
@ -47,4 +49,5 @@ private:
|
||||||
//¼ÓÔزÄÖÊÎÆÀí
|
//¼ÓÔزÄÖÊÎÆÀí
|
||||||
QVector<Texture*> loadMaterialTextures(aiMaterial* mat, aiTextureType type, QString typeName);
|
QVector<Texture*> loadMaterialTextures(aiMaterial* mat, aiTextureType type, QString typeName);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
#include "BvhTree.h"
|
#include "BvhTree.h"
|
||||||
|
using namespace Renderer;
|
||||||
GLuint BvhTree::getBvhNodeNum() {
|
GLuint BvhTree::getBvhNodeNum() {
|
||||||
return tot;
|
return tot;
|
||||||
}
|
}
|
|
@ -0,0 +1,89 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QOpenGLTexture>
|
||||||
|
#include <QOpenGLContext>
|
||||||
|
#include <QTextCodec>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <QVector4D>
|
||||||
|
#include <iostream>
|
||||||
|
#include <memory>
|
||||||
|
#include <vector>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
namespace Renderer
|
||||||
|
{
|
||||||
|
struct BvhTreeData {
|
||||||
|
QVector4D bound;
|
||||||
|
GLuint leftSon, rightSon;
|
||||||
|
void show() {
|
||||||
|
printf("Bvh: (%lf, %lf) (%lf, %lf): %d %d\n",
|
||||||
|
bound.x(), bound.y(), bound.z(), bound.w(),
|
||||||
|
leftSon, rightSon);
|
||||||
|
}
|
||||||
|
BvhTreeData(QVector4D bound, GLuint leftSon, GLuint rightSon)
|
||||||
|
: bound(bound), leftSon(leftSon), rightSon(rightSon) {}
|
||||||
|
BvhTreeData()
|
||||||
|
: leftSon(0), rightSon(0) {}
|
||||||
|
~BvhTreeData() {}
|
||||||
|
};
|
||||||
|
// BvhTree 节点
|
||||||
|
struct BvhNode {
|
||||||
|
GLuint lab;
|
||||||
|
bool isLeaf;
|
||||||
|
QVector4D bound;
|
||||||
|
std::shared_ptr<BvhNode> child[2];
|
||||||
|
static bool x_compare(BvhTreeData a, BvhTreeData b) {
|
||||||
|
return a.bound.x() < b.bound.x();
|
||||||
|
}
|
||||||
|
static bool y_compare(BvhTreeData a, BvhTreeData b) {
|
||||||
|
return a.bound.y() < b.bound.y();
|
||||||
|
}
|
||||||
|
GLuint getLeftSon(int k) {
|
||||||
|
if (isLeaf) {
|
||||||
|
return 0x80000000 + child[0]->lab;
|
||||||
|
}
|
||||||
|
return child[0]->lab;
|
||||||
|
}
|
||||||
|
GLuint getRightSon(int k) {
|
||||||
|
if (isLeaf) {
|
||||||
|
return child[1]->lab;
|
||||||
|
}
|
||||||
|
return child[1]->lab;
|
||||||
|
}
|
||||||
|
BvhNode() {
|
||||||
|
child[0] = child[1] = NULL;
|
||||||
|
isLeaf = false;
|
||||||
|
lab = 0;
|
||||||
|
}
|
||||||
|
int maximumBound() {
|
||||||
|
return (std::fabs(bound.x() - bound.w()) < std::fabs(bound.y() - bound.z()));
|
||||||
|
}
|
||||||
|
~BvhNode() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::shared_ptr<BvhNode> BvhPtr;
|
||||||
|
|
||||||
|
class BvhTree
|
||||||
|
{
|
||||||
|
|
||||||
|
private:
|
||||||
|
GLuint tot;
|
||||||
|
BvhPtr root;
|
||||||
|
static QVector4D calcBound(BvhTreeData initBound[], int l, int r);
|
||||||
|
static QVector4D Union(QVector4D a, QVector4D b);
|
||||||
|
BvhPtr subBvhTree(BvhTreeData initBound[], int l, int r);
|
||||||
|
void traverseBvhTree(BvhPtr now, std::vector<GLuint>& children, std::vector<QVector4D>& bounds);
|
||||||
|
public:
|
||||||
|
BvhTree() {
|
||||||
|
tot = 0;
|
||||||
|
root = NULL;
|
||||||
|
}
|
||||||
|
// 根据底层包围盒生成bvh树
|
||||||
|
void buildBvhTree(BvhTreeData initBound[], int len);
|
||||||
|
// 获得 Bvh (rootBvh部分)的 children 数组,包围盒数组 vector 传输
|
||||||
|
void getBvhArray(std::vector<GLuint>& children, std::vector<QVector4D>& bounds);
|
||||||
|
// 获得 BvhTree 中节点总数
|
||||||
|
GLuint getBvhNodeNum();
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
#include "CubicBezier.h"
|
#include "CubicBezier.h"
|
||||||
|
using namespace Renderer;
|
||||||
|
using std::vector;
|
||||||
double CubicBezier::getLineValueByT(double t, bool isY) {
|
double CubicBezier::getLineValueByT(double t, bool isY) {
|
||||||
vector<double> p;
|
vector<double> p;
|
||||||
if (isY) p = vY;
|
if (isY) p = vY;
|
|
@ -0,0 +1,21 @@
|
||||||
|
#pragma once
|
||||||
|
#include "Line.h"
|
||||||
|
#include <memory>
|
||||||
|
namespace Renderer
|
||||||
|
{
|
||||||
|
class CubicBezier : public Line
|
||||||
|
{
|
||||||
|
using Line::Line;
|
||||||
|
private:
|
||||||
|
static Point getPointByT(Point a, Point b, double t);
|
||||||
|
static Point calculateControlPoint(Point a, Point b);
|
||||||
|
static void findPointsOfDivison(std::vector<double>& p, std::vector<double>& res);
|
||||||
|
void splitBezierCubic(double t, std::vector<LinePtr>& res);
|
||||||
|
public:
|
||||||
|
virtual double findTByValue(double value, bool isY);
|
||||||
|
virtual void monotonization(std::vector <LinePtr>& res);
|
||||||
|
virtual double getLineValueByT(double t, bool isY);
|
||||||
|
virtual int judgeBoundIntersection(double xy, double l, double r, bool isY);
|
||||||
|
void transformToCubic();
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,5 +1,9 @@
|
||||||
#include "CubicMonotonization.h"
|
#include "CubicMonotonization.h"
|
||||||
|
using namespace Renderer;
|
||||||
|
using std::vector;
|
||||||
|
using std::min;
|
||||||
|
using std::max;
|
||||||
|
using std::sort;
|
||||||
const double CubicMonotonization::eps = 1e-6;
|
const double CubicMonotonization::eps = 1e-6;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
#pragma once
|
||||||
|
#include <utility>
|
||||||
|
#include <vector>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
namespace Renderer
|
||||||
|
{
|
||||||
|
class CubicMonotonization
|
||||||
|
{
|
||||||
|
typedef std::pair<double, double> point;
|
||||||
|
typedef std::vector<point> Line;
|
||||||
|
private:
|
||||||
|
static const double eps;
|
||||||
|
point getPointByT(point a, point b, double t) const;
|
||||||
|
void findPointsOfDivison(std::vector<double> p, std::vector<double>& res);
|
||||||
|
double getBezierPoint(std::vector<double>& p, double t) const;
|
||||||
|
void splitBezierCubic(Line& p, point mid, double t, std::vector <Line>& res);
|
||||||
|
public:
|
||||||
|
// p 为端点、控制点、控制点、端点, res 为所有导数为0的点
|
||||||
|
void getPointsOfDivision(Line p, std::vector <Line>& res);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
#include "Element.h"
|
|
@ -0,0 +1,18 @@
|
||||||
|
#pragma once
|
||||||
|
#include <vector>
|
||||||
|
#include <QOpenGLFunctions_4_5_Compatibility>
|
||||||
|
#include "Line.h"
|
||||||
|
|
||||||
|
namespace Renderer
|
||||||
|
{
|
||||||
|
class Element
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
std::vector<GLuint> bvhChildren;
|
||||||
|
std::vector<QVector4D> bvhBound;
|
||||||
|
std::vector<GLuint> elementIndex;
|
||||||
|
std::vector<GLfloat> points;
|
||||||
|
|
||||||
|
Element(std::vector<std::vector<Point>> lines);
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,5 +1,13 @@
|
||||||
#include "Line.h"
|
#include "Line.h"
|
||||||
|
using namespace Renderer;
|
||||||
|
using std::vector;
|
||||||
|
using std::pair;
|
||||||
|
using std::min;
|
||||||
|
using std::max;
|
||||||
|
using std::sort;
|
||||||
|
using std::shared_ptr;
|
||||||
|
using std::make_shared;
|
||||||
|
using std::swap;
|
||||||
Line::Line(vector<Point> Vp) {
|
Line::Line(vector<Point> Vp) {
|
||||||
siz = Vp.size();
|
siz = Vp.size();
|
||||||
for (Point now : Vp) {
|
for (Point now : Vp) {
|
|
@ -0,0 +1,57 @@
|
||||||
|
#pragma once
|
||||||
|
#include <vector>
|
||||||
|
#include <utility>
|
||||||
|
#include <vector>
|
||||||
|
#include <QVector4D>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <memory>
|
||||||
|
#include <iostream>
|
||||||
|
namespace Renderer
|
||||||
|
{
|
||||||
|
|
||||||
|
const double eps = 1e-5;
|
||||||
|
|
||||||
|
struct Point {
|
||||||
|
double x, y;
|
||||||
|
Point operator + (const Point a) { return { x + a.x, y + a.y }; }
|
||||||
|
Point operator - (const Point a) { return { x - a.x, y - a.y }; }
|
||||||
|
Point operator * (const double a) { return { x * a, y * a }; }
|
||||||
|
double operator * (const Point a) { return x * a.y - y * a.x; }
|
||||||
|
bool operator== (const Point& a) const {
|
||||||
|
return fabs(x - a.x) <= eps && fabs(y - a.y) <= eps;
|
||||||
|
}
|
||||||
|
bool operator< (const Point& a) const {
|
||||||
|
return fabs(x - a.x) <= eps ? y < a.y : x < a.x;
|
||||||
|
}
|
||||||
|
void show() {
|
||||||
|
std::cout << '(' << x << ',' << y << ')' << ' ';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class Line
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
std::vector<double> vX, vY;
|
||||||
|
int siz;
|
||||||
|
public:
|
||||||
|
typedef std::shared_ptr<Line> LinePtr;
|
||||||
|
Line() :siz(0) {}
|
||||||
|
Line(std::vector<Point> Vp);
|
||||||
|
int size();
|
||||||
|
void clear();
|
||||||
|
Point getBegin();
|
||||||
|
Point getEnd();
|
||||||
|
int direction(bool isY);
|
||||||
|
virtual double getLineValueByT(double t, bool isY) = 0;
|
||||||
|
virtual void monotonization(std::vector <LinePtr>& res) = 0;
|
||||||
|
virtual int judgeBoundIntersection(double xy, double l, double r, bool isY) = 0;
|
||||||
|
virtual bool judgeIntersection(QVector4D bound);
|
||||||
|
bool isLineContained(QVector4D bound);
|
||||||
|
Point operator[](int index) const;
|
||||||
|
Point getPointByIndex(int index) const;
|
||||||
|
std::vector<Point> toPointVector() const;
|
||||||
|
void setPointByIndex(int index, Point now);
|
||||||
|
void push_back(Point now);
|
||||||
|
virtual ~Line() {}
|
||||||
|
};
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
#include "Painting.h"
|
||||||
|
#include "../../SvgParser.h"
|
||||||
|
#include "ShortCutTree.h"
|
||||||
|
|
||||||
|
using namespace Renderer;
|
||||||
|
Painting::Painting()
|
||||||
|
{
|
||||||
|
Contour contour = SvgParser("M377,459.61a11.26,11.26,0,0,1,11.27-11.27H696.12a11.27,11.27,0,0,0,11-8.62A359.84,359.84,0,0,0,708,280.56a11.26,11.26,0,0,0-11-8.73H388.27A11.26,11.26,0,0,1,377,260.57h0a11.26,11.26,0,0,1,11.27-11.26H683.71A11.32,11.32,0,0,0,694.28,234C649.8,113.69,542.57,23.85,412.3,4.12a11.22,11.22,0,0,0-12.76,11.17v158.9a11.26,11.26,0,0,0,11.26,11.27H583.12a11.32,11.32,0,0,0,9.26-17.75c-31.67-46.59-78.51-75.2-109.11-90.07a11.25,11.25,0,0,0-16.13,10.17V115.2a11.24,11.24,0,0,0,6.22,10.07l7.51,3.76a11.28,11.28,0,0,1,5,15.12h0a11.27,11.27,0,0,1-15.11,5l-20-10a11.27,11.27,0,0,1-6.22-10.07V54a11.27,11.27,0,0,1,14.62-10.75c5.11,1.59,125.66,40.35,172.24,149A11.27,11.27,0,0,1,621.11,208H388.27A11.26,11.26,0,0,1,377,196.73V11.36A11.32,11.32,0,0,0,365.89.08C363.34,0,360.79,0,358.22,0s-5.11,0-7.66.08a11.32,11.32,0,0,0-11.11,11.28V196.74A11.26,11.26,0,0,1,328.18,208H95.35A11.27,11.27,0,0,1,85,192.3c46.57-108.67,167.12-147.42,172.23-149A11.26,11.26,0,0,1,271.86,54v75.11a11.25,11.25,0,0,1-6.23,10.07l-20,10a11.27,11.27,0,0,1-15.11-5h0a11.26,11.26,0,0,1,5-15.11l7.52-3.76a11.27,11.27,0,0,0,6.22-10.07V87.82a11.25,11.25,0,0,0-16.14-10.16c-30.6,14.87-77.45,43.48-109.1,90.07a11.3,11.3,0,0,0,9.25,17.74H305.66a11.26,11.26,0,0,0,11.27-11.26V15.31A11.22,11.22,0,0,0,304.17,4.14C173.88,23.86,66.66,113.71,22.17,234a11.32,11.32,0,0,0,10.56,15.29H328.18a11.26,11.26,0,0,1,11.27,11.26v0a11.26,11.26,0,0,1-11.27,11.26H19.52a11.26,11.26,0,0,0-11,8.72,359.84,359.84,0,0,0,.83,159.16,11.26,11.26,0,0,0,11,8.61H328.18a11.26,11.26,0,0,1,11.27,11.27h0a11.26,11.26,0,0,1-11.27,11.26h-294a11.32,11.32,0,0,0-10.53,15.4C69,604.65,175.3,692.78,304.16,712.3a11.21,11.21,0,0,0,12.76-11.16V542.22A11.26,11.26,0,0,0,305.66,531h-166c-9.53,0-14.89,11.22-8.69,18.47,34.09,39.77,74.45,65.66,101.77,80.18a11.25,11.25,0,0,0,16.53-10V591a11.26,11.26,0,0,1,11.26-11.26h0A11.26,11.26,0,0,1,271.85,591v63.85A11.27,11.27,0,0,1,256.8,665.5c-4.45-1.59-109.58-40-171-139.9a11.27,11.27,0,0,1,9.59-17.17H328.18a11.26,11.26,0,0,1,11.27,11.26V705.08a11.32,11.32,0,0,0,11.11,11.28q3.82.07,7.66.08c2.57,0,5.12,0,7.67-.08A11.32,11.32,0,0,0,377,705.08V519.69a11.25,11.25,0,0,1,11.27-11.26H621.1a11.26,11.26,0,0,1,9.59,17.16c-61.46,99.87-166.59,138.3-171,139.9a11.27,11.27,0,0,1-15-10.61V591a11.26,11.26,0,0,1,11.26-11.26h0A11.26,11.26,0,0,1,467.14,591v28.6a11.25,11.25,0,0,0,16.53,10c27.33-14.53,67.68-40.42,101.77-80.19,6.2-7.23.85-18.46-8.69-18.46h-166a11.26,11.26,0,0,0-11.26,11.26V701.12a11.21,11.21,0,0,0,12.76,11.17c128.86-19.51,235.14-107.66,280.48-226a11.33,11.33,0,0,0-10.53-15.41h-294A11.25,11.25,0,0,1,377,459.61ZM35.27,399.53V316.9a11.26,11.26,0,0,1,11.27-11.26H669.92a11.25,11.25,0,0,1,11.26,11.26v82.63a11.25,11.25,0,0,1-11.26,11.26H46.54a11.27,11.27,0,0,1-11.27-11.26Z", 716.45, 716.44).parse();
|
||||||
|
std::shared_ptr<Contour> contourPtr = std::make_shared<Contour>(contour);
|
||||||
|
contourPool.insert({ contourPtr, {nullptr, nullptr} });
|
||||||
|
|
||||||
|
|
||||||
|
std::vector<GLfloat> style = {
|
||||||
|
//fillStyle
|
||||||
|
//fill
|
||||||
|
0,
|
||||||
|
//fillType
|
||||||
|
0, //µ¥É«
|
||||||
|
//fillColorMetallicRoughness
|
||||||
|
240 / 255.,220 / 255.,160 / 255., 0.996,0.18,
|
||||||
|
};
|
||||||
|
|
||||||
|
Element element{ contourPtr, style, QVector4D(-0.8,-0.8,-0.2,-0.1), 0, 0 };
|
||||||
|
elements.push_back(element);
|
||||||
|
if (style[0] == 0 && contourPool[contourPtr].first == nullptr)
|
||||||
|
{
|
||||||
|
ShortCutTree shortCutTree(20);
|
||||||
|
shortCutTree.buildShortCutTree(*contourPtr);
|
||||||
|
ElementBuffer elementBuffer;
|
||||||
|
elementBuffer.bvhLeaves = shortCutTree.getPointLineAndBvhTree(elementBuffer.pointBuffer, elementBuffer.lineBuffer);
|
||||||
|
contourPool[contourPtr].first = std::make_shared<ElementBuffer>(elementBuffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GLuint encodeZIndexRotation(GLuint zIndex, float rotation)
|
||||||
|
{
|
||||||
|
return GLuint(rotation / 360 * 0x10000 + zIndex * 0x10000);
|
||||||
|
}
|
||||||
|
|
||||||
|
//void Painting::addElement(Contour contour, std::vector<GLfloat> style, QVector4D bound, float rotation, int zIndex)
|
||||||
|
//{
|
||||||
|
// BvhTreeData(bound, 0, encodeZIndexRotation(zIndex, rotation));
|
||||||
|
//
|
||||||
|
// std::shared_ptr<Element> element = nullptr;
|
||||||
|
// auto iterator = elementMap.find(lines);
|
||||||
|
// if (iterator != elementMap.end())
|
||||||
|
// element = iterator->second;
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// element = std::make_shared<Element>(lines);
|
||||||
|
// elementMap.insert({ lines, element });
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
|
||||||
|
void Painting::generateBuffers()
|
||||||
|
{
|
||||||
|
//std::unordered_map < std::shared_ptr<Contour>, int>
|
||||||
|
for (auto& iter : contourPool)
|
||||||
|
{
|
||||||
|
elementData.insert(elementData.end(), iter.second.first->pointBuffer.begin(), iter.second.first->pointBuffer.end());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
#pragma once
|
||||||
|
#include <vector>
|
||||||
|
#include <QOpenGLFunctions_4_5_Compatibility>
|
||||||
|
#include "Line.h"
|
||||||
|
#include "BvhTree.h"
|
||||||
|
//#include "Element.h"
|
||||||
|
|
||||||
|
namespace Renderer
|
||||||
|
{
|
||||||
|
using Contour = std::vector<std::vector<Point>>;
|
||||||
|
|
||||||
|
struct Element
|
||||||
|
{
|
||||||
|
std::shared_ptr<Contour> contour;
|
||||||
|
std::vector<GLfloat> style;
|
||||||
|
QVector4D bound;
|
||||||
|
float rotation;
|
||||||
|
int zIndex;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ElementBuffer
|
||||||
|
{
|
||||||
|
std::vector<GLfloat> pointBuffer;
|
||||||
|
std::vector<GLuint> lineBuffer;
|
||||||
|
std::vector<BvhTreeData> bvhLeaves;
|
||||||
|
};
|
||||||
|
|
||||||
|
class Painting
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
std::vector<GLuint> bvhChildren;
|
||||||
|
std::vector<QVector4D> bvhBound;
|
||||||
|
std::vector<GLuint> elementOffset;
|
||||||
|
std::vector<GLuint> elementIndex;
|
||||||
|
std::vector<GLfloat> elementData;
|
||||||
|
int paintingId = 0;
|
||||||
|
|
||||||
|
Painting();
|
||||||
|
//void addElement(Contour contour, std::vector<GLfloat> style, QVector4D bound, float rotation, int zIndex);
|
||||||
|
void generateBuffers();
|
||||||
|
private:
|
||||||
|
std::vector<BvhTreeData> bvhLeaves;
|
||||||
|
std::unordered_map< std::shared_ptr<Contour>, std::pair<std::shared_ptr<ElementBuffer>, std::shared_ptr<ElementBuffer>>> contourPool;
|
||||||
|
//std::vector<std::shared_ptr<Contour>> contourPool;
|
||||||
|
std::vector<Element> elements;
|
||||||
|
//std::unordered_map<std::vector<std::vector<Point>>, std::shared_ptr<Element>> elementMap;
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "PaintingHelper.h"
|
#include "PaintingHelper.h"
|
||||||
|
using namespace Renderer;
|
||||||
|
|
||||||
PaintingHelper::PaintingHelper(QOpenGLFunctions_4_5_Compatibility* glFunc) :glFunc(glFunc)
|
PaintingHelper::PaintingHelper(QOpenGLFunctions_4_5_Compatibility* glFunc) :glFunc(glFunc)
|
||||||
{
|
{
|
||||||
|
@ -24,34 +24,34 @@ void PaintingHelper::allocateBuffers()
|
||||||
{
|
{
|
||||||
glFunc->glGenBuffers(1, &paintingOffsetsSSBO);
|
glFunc->glGenBuffers(1, &paintingOffsetsSSBO);
|
||||||
glFunc->glBindBuffer(GL_SHADER_STORAGE_BUFFER, paintingOffsetsSSBO);
|
glFunc->glBindBuffer(GL_SHADER_STORAGE_BUFFER, paintingOffsetsSSBO);
|
||||||
glFunc->glBufferData(GL_SHADER_STORAGE_BUFFER, paintingOffsets.size() * sizeof(GLuint), paintingOffsets.data(), GL_DYNAMIC_DRAW);
|
glFunc->glBufferData(GL_SHADER_STORAGE_BUFFER, paintingOffsets.size() * sizeof(GLuint), paintingOffsets.data(), GL_STATIC_READ);
|
||||||
glFunc->glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
|
glFunc->glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
|
||||||
|
|
||||||
glFunc->glGenBuffers(1, &bvhSSBO);
|
glFunc->glGenBuffers(1, &bvhSSBO);
|
||||||
glFunc->glBindBuffer(GL_SHADER_STORAGE_BUFFER, bvhSSBO);
|
glFunc->glBindBuffer(GL_SHADER_STORAGE_BUFFER, bvhSSBO);
|
||||||
glFunc->glBufferData(GL_SHADER_STORAGE_BUFFER, bvhChildren.size() * sizeof(GLuint), bvhChildren.data(), GL_DYNAMIC_DRAW);
|
glFunc->glBufferData(GL_SHADER_STORAGE_BUFFER, bvhChildren.size() * sizeof(GLuint), bvhChildren.data(), GL_STATIC_READ);
|
||||||
glFunc->glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
|
glFunc->glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
|
||||||
|
|
||||||
glFunc->glGenBuffers(1, &bvhBoundSSBO);
|
glFunc->glGenBuffers(1, &bvhBoundSSBO);
|
||||||
glFunc->glBindBuffer(GL_SHADER_STORAGE_BUFFER, bvhBoundSSBO);
|
glFunc->glBindBuffer(GL_SHADER_STORAGE_BUFFER, bvhBoundSSBO);
|
||||||
glFunc->glBufferData(GL_SHADER_STORAGE_BUFFER, bvhBound.size() * sizeof(QVector4D), bvhBound.data(), GL_DYNAMIC_DRAW);
|
glFunc->glBufferData(GL_SHADER_STORAGE_BUFFER, bvhBound.size() * sizeof(QVector4D), bvhBound.data(), GL_STATIC_READ);
|
||||||
glFunc->glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
|
glFunc->glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
|
||||||
|
|
||||||
|
|
||||||
glFunc->glGenBuffers(1, &elementOffsetSSBO);
|
glFunc->glGenBuffers(1, &elementOffsetSSBO);
|
||||||
glFunc->glBindBuffer(GL_SHADER_STORAGE_BUFFER, elementOffsetSSBO);
|
glFunc->glBindBuffer(GL_SHADER_STORAGE_BUFFER, elementOffsetSSBO);
|
||||||
glFunc->glBufferData(GL_SHADER_STORAGE_BUFFER, elementOffset.size() * sizeof(GLuint), elementOffset.data(), GL_DYNAMIC_DRAW);
|
glFunc->glBufferData(GL_SHADER_STORAGE_BUFFER, elementOffset.size() * sizeof(GLuint), elementOffset.data(), GL_STATIC_READ);
|
||||||
glFunc->glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
|
glFunc->glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
|
||||||
|
|
||||||
|
|
||||||
glFunc->glGenBuffers(1, &elementIndexSSBO);
|
glFunc->glGenBuffers(1, &elementIndexSSBO);
|
||||||
glFunc->glBindBuffer(GL_SHADER_STORAGE_BUFFER, elementIndexSSBO);
|
glFunc->glBindBuffer(GL_SHADER_STORAGE_BUFFER, elementIndexSSBO);
|
||||||
glFunc->glBufferData(GL_SHADER_STORAGE_BUFFER, elementIndex.size() * sizeof(GLuint), elementIndex.data(), GL_DYNAMIC_DRAW);
|
glFunc->glBufferData(GL_SHADER_STORAGE_BUFFER, elementIndex.size() * sizeof(GLuint), elementIndex.data(), GL_STATIC_READ);
|
||||||
glFunc->glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
|
glFunc->glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
|
||||||
|
|
||||||
glFunc->glGenBuffers(1, &elementDataSSBO);
|
glFunc->glGenBuffers(1, &elementDataSSBO);
|
||||||
glFunc->glBindBuffer(GL_SHADER_STORAGE_BUFFER, elementDataSSBO);
|
glFunc->glBindBuffer(GL_SHADER_STORAGE_BUFFER, elementDataSSBO);
|
||||||
glFunc->glBufferData(GL_SHADER_STORAGE_BUFFER, elementData.size() * sizeof(GLfloat), elementData.data(), GL_DYNAMIC_DRAW);
|
glFunc->glBufferData(GL_SHADER_STORAGE_BUFFER, elementData.size() * sizeof(GLfloat), elementData.data(), GL_STATIC_READ);
|
||||||
glFunc->glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
|
glFunc->glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QVector4D>
|
||||||
|
#include <QOpenGLFunctions_4_5_Compatibility>
|
||||||
|
#include "BvhTree.h"
|
||||||
|
namespace Renderer
|
||||||
|
{
|
||||||
|
class PaintingHelper
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
QOpenGLFunctions_4_5_Compatibility* glFunc;
|
||||||
|
GLuint paintingOffsetsSSBO, bvhSSBO, bvhBoundSSBO, elementOffsetSSBO, elementIndexSSBO, elementDataSSBO;
|
||||||
|
std::vector<GLuint> paintingOffsets;
|
||||||
|
std::vector<GLuint> bvhChildren;
|
||||||
|
std::vector<QVector4D> bvhBound;
|
||||||
|
std::vector<GLuint> elementOffset;
|
||||||
|
std::vector<GLuint> elementIndex;
|
||||||
|
std::vector<GLfloat> elementData;
|
||||||
|
int paintingCount = 0;
|
||||||
|
|
||||||
|
public:
|
||||||
|
PaintingHelper(QOpenGLFunctions_4_5_Compatibility* glFunc);
|
||||||
|
int addPainting(GLuint paintingBvhLength, std::vector<GLuint> bvhChildren, std::vector<QVector4D> bvhBound,
|
||||||
|
std::vector<GLuint> elementOffset, std::vector<GLuint> elementIndex, std::vector<GLfloat> elementData);
|
||||||
|
void allocateBuffers();
|
||||||
|
void bindPaintingBuffers();
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
|
@ -1,6 +1,12 @@
|
||||||
#include "ShortCutTree.h"
|
#include "ShortCutTree.h"
|
||||||
#include <qDebug>
|
#include <qDebug>
|
||||||
|
using namespace Renderer;
|
||||||
|
using std::queue;
|
||||||
|
using std::map;
|
||||||
|
using std::for_each;
|
||||||
|
using std::set;
|
||||||
|
using std::pair;
|
||||||
|
using std::vector;
|
||||||
void ShortCutTree::init() {
|
void ShortCutTree::init() {
|
||||||
restOfTreeNodes.clear();
|
restOfTreeNodes.clear();
|
||||||
allLine.clear();
|
allLine.clear();
|
||||||
|
@ -57,9 +63,9 @@ bool ShortCutTree::isLineEqual(PointIndexVector& a, PointIndexVector& b) const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShortCutTree::monotonization(vector<PointVector>& inLines, vector<LinePtr>& outLines) {
|
void ShortCutTree::monotonization(vector<PointVector>& inLines, vector<std::shared_ptr<Line>>& outLines) {
|
||||||
for (PointVector&l: inLines) {
|
for (PointVector&l: inLines) {
|
||||||
LinePtr nowLine;
|
std::shared_ptr<Line> nowLine;
|
||||||
switch(l.size()) {
|
switch(l.size()) {
|
||||||
case 2: nowLine.reset(new StraightLine(l)); break;
|
case 2: nowLine.reset(new StraightLine(l)); break;
|
||||||
case 3: case 4: nowLine.reset(new CubicBezier(l)); break;
|
case 3: case 4: nowLine.reset(new CubicBezier(l)); break;
|
||||||
|
@ -288,7 +294,7 @@ vector<BvhTreeData> ShortCutTree::getPointLineAndBvhTree(vector<float>& resPoint
|
||||||
for (auto& nowTreeNode : restOfTreeNodes) {
|
for (auto& nowTreeNode : restOfTreeNodes) {
|
||||||
BvhTreeData oneData;
|
BvhTreeData oneData;
|
||||||
oneData.leftSon = resLines.size();
|
oneData.leftSon = resLines.size();
|
||||||
oneData.rightSon = resPoints.size();
|
//oneData.rightSon = rightSon;
|
||||||
oneData.bound = nowTreeNode.bound;
|
oneData.bound = nowTreeNode.bound;
|
||||||
std::cout << nowTreeNode.lineSet.size() << ' ';
|
std::cout << nowTreeNode.lineSet.size() << ' ';
|
||||||
resLines.push_back(nowTreeNode.lineSet.size());
|
resLines.push_back(nowTreeNode.lineSet.size());
|
|
@ -0,0 +1,62 @@
|
||||||
|
#pragma once
|
||||||
|
#include "CubicBezier.h"
|
||||||
|
#include "StraightLine.h"
|
||||||
|
#include "BvhTree.h"
|
||||||
|
#include <queue>
|
||||||
|
#include <set>
|
||||||
|
namespace Renderer
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
struct ShortCutNode {
|
||||||
|
typedef std::vector<Point> vectorPoint;
|
||||||
|
int windingIncrement, eastGroup;
|
||||||
|
bool divided;
|
||||||
|
/* type 代表进入广度优先搜索队列的节点种类:
|
||||||
|
0:不需要拆开的节点
|
||||||
|
1:需要拆分*/
|
||||||
|
QVector4D bound;
|
||||||
|
std::vector<int> lineSet;
|
||||||
|
ShortCutNode() {
|
||||||
|
divided = true;
|
||||||
|
windingIncrement = 0;
|
||||||
|
eastGroup = 0;
|
||||||
|
lineSet.clear();
|
||||||
|
bound = { 0, 0, 0, 0 };
|
||||||
|
}
|
||||||
|
~ShortCutNode() {}
|
||||||
|
};
|
||||||
|
class ShortCutTree
|
||||||
|
{
|
||||||
|
typedef std::vector<Point> PointVector;
|
||||||
|
typedef std::vector<int> PointIndexVector;
|
||||||
|
private:
|
||||||
|
std::vector<ShortCutNode> restOfTreeNodes;
|
||||||
|
std::vector<std::shared_ptr<Line>> allLine;
|
||||||
|
int RequiredLineMin, numPoint, numLine;
|
||||||
|
std::map<Point, int> pointMap;
|
||||||
|
std::vector<int> lineIndexs;
|
||||||
|
|
||||||
|
int getPointIndex(Point nowPoint);
|
||||||
|
void generateShortCutsegmentement(ShortCutNode& nowTreeNode);
|
||||||
|
bool handleShortCutNode(ShortCutNode& fa, ShortCutNode& nowTreeNode, double yValue, std::vector<ShortCutNode>& v, int& sumIncrement);
|
||||||
|
void spliteToShortCutTree();
|
||||||
|
static void monotonization(std::vector<PointVector>& inL, std::vector<std::shared_ptr<Line>>& outL);
|
||||||
|
bool isLineEqual(PointIndexVector& a, PointIndexVector& b) const;
|
||||||
|
void simplifyLineVector();
|
||||||
|
// 需要测试,随机获得合理的边界
|
||||||
|
static bool IsBorderValueResonable(double value, std::set <double>& valueSet);
|
||||||
|
static double findBorderValueNotOnLine(double value, std::set <double>& valueSet);
|
||||||
|
public:
|
||||||
|
void init();
|
||||||
|
//lineMin最小线数目,即划分终止条件
|
||||||
|
ShortCutTree(int lineMin = 3)
|
||||||
|
:RequiredLineMin(lineMin), numPoint(0), numLine(0) {}
|
||||||
|
// 传入一个vector<vector<Point> > 作为所有输入的线
|
||||||
|
void buildShortCutTree(std::vector<PointVector>& lineSet);
|
||||||
|
// 获得点集合和线集合 返回输入BvhTree的数据集合
|
||||||
|
std::vector<BvhTreeData> getPointLineAndBvhTree(std::vector<float>& pointSet, std::vector<GLuint>& lineSet);
|
||||||
|
~ShortCutTree() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
#include "StraightLine.h"
|
#include "StraightLine.h"
|
||||||
|
using namespace Renderer;
|
||||||
|
using std::swap;
|
||||||
double StraightLine::getLineValueByT(double t, bool isY) {
|
double StraightLine::getLineValueByT(double t, bool isY) {
|
||||||
double valueBegin, valueEnd;
|
double valueBegin, valueEnd;
|
||||||
if (isY) {
|
if (isY) {
|
|
@ -0,0 +1,12 @@
|
||||||
|
#include "Line.h"
|
||||||
|
namespace Renderer
|
||||||
|
{
|
||||||
|
class StraightLine : public Line
|
||||||
|
{
|
||||||
|
using Line::Line;
|
||||||
|
virtual double getLineValueByT(double t, bool isY);
|
||||||
|
virtual void monotonization(std::vector <LinePtr>& res) {};
|
||||||
|
virtual double findTByValue(double value, bool isY);
|
||||||
|
virtual int judgeBoundIntersection(double xy, double l, double r, bool isY);
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,29 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QVector4D>
|
|
||||||
#include <QOpenGLFunctions_4_5_Compatibility>
|
|
||||||
#include "BvhTree.h"
|
|
||||||
|
|
||||||
class PaintingHelper
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
QOpenGLFunctions_4_5_Compatibility* glFunc;
|
|
||||||
GLuint paintingOffsetsSSBO, bvhSSBO, bvhBoundSSBO, elementOffsetSSBO, elementIndexSSBO, elementDataSSBO;
|
|
||||||
std::vector<GLuint> paintingOffsets;
|
|
||||||
std::vector<GLuint> bvhChildren;
|
|
||||||
std::vector<QVector4D> bvhBound;
|
|
||||||
std::vector<GLuint> elementOffset;
|
|
||||||
std::vector<GLuint> elementIndex;
|
|
||||||
std::vector<GLfloat> elementData;
|
|
||||||
int paintingCount = 0;
|
|
||||||
|
|
||||||
public:
|
|
||||||
PaintingHelper(QOpenGLFunctions_4_5_Compatibility* glFunc);
|
|
||||||
int addPainting(GLuint paintingBvhLength, std::vector<GLuint> bvhChildren, std::vector<QVector4D> bvhBound,
|
|
||||||
std::vector<GLuint> elementOffset, std::vector<GLuint> elementIndex, std::vector<GLfloat> elementData);
|
|
||||||
void allocateBuffers();
|
|
||||||
void bindPaintingBuffers();
|
|
||||||
};
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "PaintingMesh.h"
|
#include "PaintingMesh.h"
|
||||||
|
using namespace Renderer;
|
||||||
PaintingMesh::PaintingMesh(QOpenGLFunctions_4_5_Compatibility* glFunc, QOpenGLShaderProgram* shaderProgram, QOpenGLShaderProgram* shadowProgram, aiMatrix4x4 model)
|
PaintingMesh::PaintingMesh(QOpenGLFunctions_4_5_Compatibility* glFunc, QOpenGLShaderProgram* shaderProgram, QOpenGLShaderProgram* shadowProgram, aiMatrix4x4 model)
|
||||||
: glFunc(glFunc)
|
: glFunc(glFunc)
|
||||||
, shaderProgram(shaderProgram)
|
, shaderProgram(shaderProgram)
|
||||||
|
|
|
@ -15,18 +15,20 @@
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
#include "Drawable.h"
|
#include "Drawable.h"
|
||||||
|
|
||||||
struct PaintingVertex
|
namespace Renderer
|
||||||
{
|
{
|
||||||
|
struct PaintingVertex
|
||||||
|
{
|
||||||
QVector3D Position;
|
QVector3D Position;
|
||||||
QVector3D Normal;
|
QVector3D Normal;
|
||||||
QVector2D TexCoords;
|
QVector2D TexCoords;
|
||||||
QVector3D Tangent;
|
QVector3D Tangent;
|
||||||
QVector3D Bitangent;
|
QVector3D Bitangent;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PaintingMesh : public Drawable
|
class PaintingMesh : public Drawable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/* 网格数据 */
|
/* 网格数据 */
|
||||||
QVector<PaintingVertex> vertices; //顶点数据
|
QVector<PaintingVertex> vertices; //顶点数据
|
||||||
QVector<unsigned int> indices; //索引数组
|
QVector<unsigned int> indices; //索引数组
|
||||||
|
@ -40,9 +42,10 @@ public:
|
||||||
void drawShadow() override;
|
void drawShadow() override;
|
||||||
void setupMesh();
|
void setupMesh();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/* 渲染数据 */
|
/* 渲染数据 */
|
||||||
QOpenGLVertexArrayObject VAO;
|
QOpenGLVertexArrayObject VAO;
|
||||||
QOpenGLBuffer VBO, EBO;
|
QOpenGLBuffer VBO, EBO;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
}
|
|
@ -6,7 +6,7 @@
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
#include <random>
|
#include <random>
|
||||||
|
using namespace Renderer;
|
||||||
//QVector3D lightPositions[] = { 2000 * QVector3D(0.2, 4, 1).normalized(), QVector3D(100,100,100) ,QVector3D(-100,100,100) ,QVector3D(100,100,-100) };
|
//QVector3D lightPositions[] = { 2000 * QVector3D(0.2, 4, 1).normalized(), QVector3D(100,100,100) ,QVector3D(-100,100,100) ,QVector3D(100,100,-100) };
|
||||||
QVector3D lightColors[] = { 20 * QVector3D(0.7529,0.7450,0.6784).normalized(), QVector3D(0,0,0) ,QVector3D(0,0,0) ,QVector3D(0,0,0) };
|
QVector3D lightColors[] = { 20 * QVector3D(0.7529,0.7450,0.6784).normalized(), QVector3D(0,0,0) ,QVector3D(0,0,0) ,QVector3D(0,0,0) };
|
||||||
static float sunPitch = 105, sunYaw = 80;
|
static float sunPitch = 105, sunYaw = 80;
|
||||||
|
|
|
@ -10,21 +10,22 @@
|
||||||
#include "Camera.h"
|
#include "Camera.h"
|
||||||
#include "Light.h"
|
#include "Light.h"
|
||||||
#include "Model.h"
|
#include "Model.h"
|
||||||
#include "PaintingHelper.h"
|
#include "Painting/PaintingHelper.h"
|
||||||
|
namespace Renderer
|
||||||
class RendererGLWidget : public QOpenGLWidget, protected QOpenGLFunctions_4_5_Compatibility
|
|
||||||
{
|
{
|
||||||
|
class RendererGLWidget : public QOpenGLWidget, protected QOpenGLFunctions_4_5_Compatibility
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
RendererGLWidget(QWidget* parent = nullptr);
|
RendererGLWidget(QWidget* parent = nullptr);
|
||||||
~RendererGLWidget();
|
~RendererGLWidget();
|
||||||
|
|
||||||
void startTimer();
|
void startTimer();
|
||||||
void stopTimer();
|
void stopTimer();
|
||||||
public slots:
|
public slots:
|
||||||
void setMainLightPitch(float pitch);
|
void setMainLightPitch(float pitch);
|
||||||
void setMainLightYaw(float yaw);
|
void setMainLightYaw(float yaw);
|
||||||
protected:
|
protected:
|
||||||
void initializeGL() override;
|
void initializeGL() override;
|
||||||
void paintGL() override;
|
void paintGL() override;
|
||||||
void resizeGL(int width, int height) override;
|
void resizeGL(int width, int height) override;
|
||||||
|
@ -35,7 +36,7 @@ protected:
|
||||||
void focusInEvent(QFocusEvent* event) override;
|
void focusInEvent(QFocusEvent* event) override;
|
||||||
void focusOutEvent(QFocusEvent* event) override;
|
void focusOutEvent(QFocusEvent* event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int timerId = -1;
|
int timerId = -1;
|
||||||
int frameWidth, frameHeight;
|
int frameWidth, frameHeight;
|
||||||
int depthWidth, depthHeight;
|
int depthWidth, depthHeight;
|
||||||
|
@ -64,5 +65,5 @@ private:
|
||||||
QOpenGLVertexArrayObject quadVAO;
|
QOpenGLVertexArrayObject quadVAO;
|
||||||
Model* model;
|
Model* model;
|
||||||
PaintingHelper* paintingHelper;
|
PaintingHelper* paintingHelper;
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "RendererWidget.h"
|
#include "RendererWidget.h"
|
||||||
#include "RendererGLWidget.h"
|
#include "RendererGLWidget.h"
|
||||||
|
using namespace Renderer;
|
||||||
RendererWidget::RendererWidget(QWidget *parent)
|
RendererWidget::RendererWidget(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,17 +2,19 @@
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include "ui_RendererWidget.h"
|
#include "ui_RendererWidget.h"
|
||||||
|
namespace Renderer
|
||||||
class RendererWidget : public QWidget
|
|
||||||
{
|
{
|
||||||
|
class RendererWidget : public QWidget
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
RendererWidget(QWidget *parent = nullptr);
|
RendererWidget(QWidget* parent = nullptr);
|
||||||
~RendererWidget();
|
~RendererWidget();
|
||||||
public slots:
|
public slots:
|
||||||
void currentTabChanged(int index);
|
void currentTabChanged(int index);
|
||||||
private:
|
private:
|
||||||
Ui::RendererWidgetClass ui;
|
Ui::RendererWidgetClass ui;
|
||||||
};
|
};
|
||||||
|
}
|
|
@ -1,63 +0,0 @@
|
||||||
#pragma once
|
|
||||||
#include "CubicBezier.h"
|
|
||||||
#include "StraightLine.h"
|
|
||||||
#include "BvhTree.h"
|
|
||||||
#include <queue>
|
|
||||||
#include <set>
|
|
||||||
|
|
||||||
using std::queue;
|
|
||||||
using std::map;
|
|
||||||
using std::for_each;
|
|
||||||
using std::set;
|
|
||||||
|
|
||||||
struct ShortCutNode {
|
|
||||||
typedef vector<Point> vectorPoint;
|
|
||||||
int windingIncrement, eastGroup;
|
|
||||||
bool divided;
|
|
||||||
/* type 代表进入广度优先搜索队列的节点种类:
|
|
||||||
0:不需要拆开的节点
|
|
||||||
1:需要拆分*/
|
|
||||||
QVector4D bound;
|
|
||||||
vector<int> lineSet;
|
|
||||||
ShortCutNode() {
|
|
||||||
divided = true;
|
|
||||||
windingIncrement = 0;
|
|
||||||
eastGroup = 0;
|
|
||||||
lineSet.clear();
|
|
||||||
bound = { 0, 0, 0, 0 };
|
|
||||||
}
|
|
||||||
~ShortCutNode() {}
|
|
||||||
};
|
|
||||||
class ShortCutTree
|
|
||||||
{
|
|
||||||
typedef vector<Point> PointVector;
|
|
||||||
typedef vector<int> PointIndexVector;
|
|
||||||
private:
|
|
||||||
vector<ShortCutNode> restOfTreeNodes;
|
|
||||||
vector<LinePtr> allLine;
|
|
||||||
int RequiredLineMin, numPoint, numLine;
|
|
||||||
map<Point, int> pointMap;
|
|
||||||
vector<int> lineIndexs;
|
|
||||||
|
|
||||||
int getPointIndex(Point nowPoint);
|
|
||||||
void generateShortCutsegmentement(ShortCutNode& nowTreeNode);
|
|
||||||
bool handleShortCutNode(ShortCutNode& fa, ShortCutNode& nowTreeNode, double yValue, vector<ShortCutNode>& v, int& sumIncrement);
|
|
||||||
void spliteToShortCutTree();
|
|
||||||
static void monotonization(vector<PointVector>& inL, vector<LinePtr> &outL);
|
|
||||||
bool isLineEqual(PointIndexVector& a, PointIndexVector& b) const;
|
|
||||||
void simplifyLineVector();
|
|
||||||
// 需要测试,随机获得合理的边界
|
|
||||||
static bool IsBorderValueResonable(double value, set <double>& valueSet);
|
|
||||||
static double findBorderValueNotOnLine(double value, set <double>& valueSet);
|
|
||||||
public:
|
|
||||||
void init();
|
|
||||||
//lineMin最小线数目,即划分终止条件
|
|
||||||
ShortCutTree(int lineMin = 3)
|
|
||||||
:RequiredLineMin(lineMin), numPoint(0), numLine(0) {}
|
|
||||||
// 传入一个vector<vector<Point> > 作为所有输入的线
|
|
||||||
void buildShortCutTree(vector<PointVector>& lineSet);
|
|
||||||
// 获得点集合和线集合 返回输入BvhTree的数据集合
|
|
||||||
vector<BvhTreeData> getPointLineAndBvhTree(vector<float> &pointSet, vector<GLuint> &lineSet);
|
|
||||||
~ShortCutTree() {}
|
|
||||||
};
|
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
#include "Line.h"
|
|
||||||
|
|
||||||
class StraightLine : public Line
|
|
||||||
{
|
|
||||||
using Line::Line;
|
|
||||||
virtual double getLineValueByT(double t, bool isY);
|
|
||||||
virtual void monotonization(vector <LinePtr>& res) {};
|
|
||||||
virtual double findTByValue(double value, bool isY);
|
|
||||||
virtual int judgeBoundIntersection(double xy, double l, double r, bool isY);
|
|
||||||
};
|
|
|
@ -484,7 +484,7 @@ namespace SVGParser
|
||||||
}
|
}
|
||||||
|
|
||||||
}; // namespace SVGParser
|
}; // namespace SVGParser
|
||||||
|
using Renderer::Point;
|
||||||
SvgParser::SvgParser(const std::string path, double width, double height) : path(path), width(width), height(height)
|
SvgParser::SvgParser(const std::string path, double width, double height) : path(path), width(width), height(height)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Renderer/Line.h"
|
#include "Renderer/Painting/Line.h"
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <string>
|
#include <string>
|
||||||
using namespace std;
|
|
||||||
namespace SVGParser
|
namespace SVGParser
|
||||||
{
|
{
|
||||||
enum SVGCommandType
|
enum SVGCommandType
|
||||||
{
|
{
|
||||||
SVG_INVALID = -1,
|
SVG_INVALID = -1,
|
||||||
// SVG_MOVE_TO_REL, SVG_LINE_TO_REL, SVG_QUADRATIC_CURVE_TO_REL, SVG_CUBIC_CURVE_TO_REL,
|
// SVG_MOVE_TO_REL, SVG_LINE_TO_REL, SVG_QUADRATIC_CURVE_TO_REL, SVG_CUBIC_CURVE_TO_REL,
|
||||||
// SVG_MOVE_TO_ABS, SVG_LINE_TO_ABS, SVG_QUADRATIC_CURVE_TO_ABS, SVG_CUBIC_CURVE_TO_ABS,
|
// SVG_MOVE_TO_ABS, SVG_LINE_TO_ABS, SVG_QUADRATIC_CURVE_TO_ABS, SVG_CUBIC_CURVE_TO_ABS,
|
||||||
|
@ -31,11 +31,11 @@ enum SVGCommandType
|
||||||
SVG_ARC_TO_ABS,
|
SVG_ARC_TO_ABS,
|
||||||
|
|
||||||
SVG_CLOSE_PATH
|
SVG_CLOSE_PATH
|
||||||
};
|
};
|
||||||
|
|
||||||
bool isAbsolute(SVGCommandType);
|
bool isAbsolute(SVGCommandType);
|
||||||
class SVGCommand
|
class SVGCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SVGCommand(double, double, bool = false);
|
SVGCommand(double, double, bool = false);
|
||||||
static const int length;
|
static const int length;
|
||||||
|
@ -44,85 +44,85 @@ class SVGCommand
|
||||||
virtual const std::string toString() const = 0;
|
virtual const std::string toString() const = 0;
|
||||||
virtual SVGCommandType getType() = 0;
|
virtual SVGCommandType getType() = 0;
|
||||||
virtual std::string toString2() = 0;
|
virtual std::string toString2() = 0;
|
||||||
};
|
};
|
||||||
class SVGMoveTo : public SVGCommand
|
class SVGMoveTo : public SVGCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static const int length = 2;
|
static const int length = 2;
|
||||||
SVGMoveTo(double, double, bool = false);
|
SVGMoveTo(double, double, bool = false);
|
||||||
virtual const std::string toString() const;
|
virtual const std::string toString() const;
|
||||||
virtual SVGCommandType getType();
|
virtual SVGCommandType getType();
|
||||||
virtual std::string toString2();
|
virtual std::string toString2();
|
||||||
};
|
};
|
||||||
|
|
||||||
class SVGLineTo : public SVGCommand
|
class SVGLineTo : public SVGCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static const int length = 2;
|
static const int length = 2;
|
||||||
SVGLineTo(double, double, bool = false);
|
SVGLineTo(double, double, bool = false);
|
||||||
virtual const std::string toString() const;
|
virtual const std::string toString() const;
|
||||||
virtual SVGCommandType getType();
|
virtual SVGCommandType getType();
|
||||||
virtual std::string toString2();
|
virtual std::string toString2();
|
||||||
};
|
};
|
||||||
class SVGHLineTo : public SVGCommand
|
class SVGHLineTo : public SVGCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static const int length = 1;
|
static const int length = 1;
|
||||||
SVGHLineTo(double, bool = false);
|
SVGHLineTo(double, bool = false);
|
||||||
virtual const std::string toString() const;
|
virtual const std::string toString() const;
|
||||||
virtual SVGCommandType getType();
|
virtual SVGCommandType getType();
|
||||||
virtual std::string toString2();
|
virtual std::string toString2();
|
||||||
};
|
};
|
||||||
class SVGVLineTo : public SVGCommand
|
class SVGVLineTo : public SVGCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static const int length = 1;
|
static const int length = 1;
|
||||||
SVGVLineTo(double, bool = false);
|
SVGVLineTo(double, bool = false);
|
||||||
virtual const std::string toString() const;
|
virtual const std::string toString() const;
|
||||||
virtual SVGCommandType getType();
|
virtual SVGCommandType getType();
|
||||||
virtual std::string toString2();
|
virtual std::string toString2();
|
||||||
};
|
};
|
||||||
|
|
||||||
class SVGQuadraticCurveTo : public SVGCommand
|
class SVGQuadraticCurveTo : public SVGCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SVGQuadraticCurveTo(double, double, double, double, bool = false);
|
SVGQuadraticCurveTo(double, double, double, double, bool = false);
|
||||||
double x0, y0;
|
double x0, y0;
|
||||||
virtual const std::string toString() const;
|
virtual const std::string toString() const;
|
||||||
virtual SVGCommandType getType();
|
virtual SVGCommandType getType();
|
||||||
virtual std::string toString2();
|
virtual std::string toString2();
|
||||||
};
|
};
|
||||||
|
|
||||||
class SVGCubicCurveTo : public SVGCommand
|
class SVGCubicCurveTo : public SVGCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
double x0, y0, x1, y1;
|
double x0, y0, x1, y1;
|
||||||
SVGCubicCurveTo(double, double, double, double, double, double, bool = false);
|
SVGCubicCurveTo(double, double, double, double, double, double, bool = false);
|
||||||
virtual const std::string toString() const;
|
virtual const std::string toString() const;
|
||||||
virtual SVGCommandType getType();
|
virtual SVGCommandType getType();
|
||||||
virtual std::string toString2();
|
virtual std::string toString2();
|
||||||
};
|
};
|
||||||
class SVGSmoothQuadraticCurveTo : public SVGCommand
|
class SVGSmoothQuadraticCurveTo : public SVGCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SVGSmoothQuadraticCurveTo(double, double, bool = false);
|
SVGSmoothQuadraticCurveTo(double, double, bool = false);
|
||||||
virtual const std::string toString() const;
|
virtual const std::string toString() const;
|
||||||
virtual SVGCommandType getType();
|
virtual SVGCommandType getType();
|
||||||
virtual std::string toString2();
|
virtual std::string toString2();
|
||||||
};
|
};
|
||||||
|
|
||||||
class SVGSmoothCubicCurveTo : public SVGCommand
|
class SVGSmoothCubicCurveTo : public SVGCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
double x1, y1;
|
double x1, y1;
|
||||||
SVGSmoothCubicCurveTo(double, double, double, double, bool = false);
|
SVGSmoothCubicCurveTo(double, double, double, double, bool = false);
|
||||||
virtual const std::string toString() const;
|
virtual const std::string toString() const;
|
||||||
virtual SVGCommandType getType();
|
virtual SVGCommandType getType();
|
||||||
virtual std::string toString2();
|
virtual std::string toString2();
|
||||||
};
|
};
|
||||||
|
|
||||||
class SVGArcTo : public SVGCommand
|
class SVGArcTo : public SVGCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
double rx, ry, rot;
|
double rx, ry, rot;
|
||||||
bool large, sweep;
|
bool large, sweep;
|
||||||
|
@ -130,44 +130,44 @@ class SVGArcTo : public SVGCommand
|
||||||
virtual const std::string toString() const;
|
virtual const std::string toString() const;
|
||||||
virtual SVGCommandType getType();
|
virtual SVGCommandType getType();
|
||||||
virtual std::string toString2();
|
virtual std::string toString2();
|
||||||
};
|
};
|
||||||
|
|
||||||
class SVGClosePath : public SVGCommand
|
class SVGClosePath : public SVGCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SVGClosePath(bool = false);
|
SVGClosePath(bool = false);
|
||||||
virtual const std::string toString() const;
|
virtual const std::string toString() const;
|
||||||
virtual SVGCommandType getType();
|
virtual SVGCommandType getType();
|
||||||
virtual std::string toString2();
|
virtual std::string toString2();
|
||||||
};
|
};
|
||||||
typedef vector<std::shared_ptr<SVGCommand>> SVGPath;
|
typedef std::vector<std::shared_ptr<SVGCommand>> SVGPath;
|
||||||
SVGPath parsePath(std::istream &);
|
SVGPath parsePath(std::istream&);
|
||||||
|
|
||||||
std::ostream &operator<<(std::ostream &, const SVGParser::SVGPath &);
|
std::ostream& operator<<(std::ostream&, const SVGParser::SVGPath&);
|
||||||
std::ostream &operator<<(std::ostream &, const SVGParser::SVGCommand *);
|
std::ostream& operator<<(std::ostream&, const SVGParser::SVGCommand*);
|
||||||
}; // namespace SVGParser
|
}; // namespace SVGParser
|
||||||
class SvgParser
|
class SvgParser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SvgParser(const std::string path, const double width, const double height);
|
SvgParser(const std::string path, const double width, const double height);
|
||||||
vector<vector<Point>> parse();
|
std::vector<std::vector<Renderer::Point>> parse();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static constexpr const double eps = 1e-6;
|
static constexpr const double eps = 1e-6;
|
||||||
static constexpr const double PI = 3.14159265358979323846;
|
static constexpr const double PI = 3.14159265358979323846;
|
||||||
const std::string path;
|
const std::string path;
|
||||||
const double width;
|
const double width;
|
||||||
const double height;
|
const double height;
|
||||||
|
|
||||||
Point convertPoint(double x, double y);
|
Renderer::Point convertPoint(double x, double y);
|
||||||
Point clampPoint(Point p);
|
Renderer::Point clampPoint(Renderer::Point p);
|
||||||
Point convertAbsPoint(double x, double y);
|
Renderer::Point convertAbsPoint(double x, double y);
|
||||||
Point convertRelPoint(Point pointBegin, double x, double y);
|
Renderer::Point convertRelPoint(Renderer::Point pointBegin, double x, double y);
|
||||||
void ellipticalArcConverter(Point beginPoint, double radiusX, double radiusY, double phi, bool flagA,
|
void ellipticalArcConverter(Renderer::Point beginPoint, double radiusX, double radiusY, double phi, bool flagA,
|
||||||
bool flagS, Point endPoint,vector<vector<Point>>& lines);
|
bool flagS, Renderer::Point endPoint, std::vector<std::vector<Renderer::Point>>& lines);
|
||||||
vector<double> centerConverter(Point beginPoint, double radiusX, double radiusY, double phi, bool flagA, bool flagS,
|
std::vector<double> centerConverter(Renderer::Point beginPoint, double radiusX, double radiusY, double phi, bool flagA, bool flagS,
|
||||||
Point endPoint);
|
Renderer::Point endPoint);
|
||||||
double angleConverter(Point u, Point v);
|
double angleConverter(Renderer::Point u, Renderer::Point v);
|
||||||
Point eConverter(Point c, Point r, double cosPhi, double sinPhi, double t);
|
Renderer::Point eConverter(Renderer::Point c, Renderer::Point r, double cosPhi, double sinPhi, double t);
|
||||||
Point e2Converter(Point c, Point r, double cosPhi, double sinPhi, double t);
|
Renderer::Point e2Converter(Renderer::Point c, Renderer::Point r, double cosPhi, double sinPhi, double t);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue