├── README.md ├── build ├── BMesh │ ├── BMesh.vcxproj │ └── BMesh.vcxproj.filters ├── BaseLib │ ├── BaseLib.vcxproj │ └── BaseLib.vcxproj.filters ├── Boolean │ ├── Boolean.vcxproj │ └── Boolean.vcxproj.filters ├── Sculpt │ ├── Sculpt.vcxproj │ ├── Sculpt.vcxproj.filters │ └── Sculpt.vcxproj.user ├── VBvh │ ├── VBvh.vcxproj │ └── VBvh.vcxproj.filters ├── VKernel │ ├── VKernel.vcxproj │ ├── VKernel.vcxproj.filters │ └── VKernel.vcxproj.user ├── VbsQt │ ├── VbsQt.vcxproj │ ├── VbsQt.vcxproj.filters │ └── VbsQt.vcxproj.user ├── render │ ├── render.vcxproj │ ├── render.vcxproj.filters │ └── render.vcxproj.user ├── vsculpt │ ├── vsculpt.vcxproj │ ├── vsculpt.vcxproj.filters │ └── vsculpt.vcxproj.user ├── vsculpt_qt5.sln └── vsculpt_qt5.v12.suo ├── inc ├── BMesh │ ├── BMCompilerTypeCheck.h │ ├── BMCustomData.h │ ├── BMUtilDefine.h │ ├── BMesh.h │ ├── BMeshClass.h │ ├── BMeshCore.h │ ├── BMeshInline.h │ ├── BMeshIterators.h │ ├── BMeshPolygon.h │ ├── BMeshQueries.h │ ├── BMeshStructure.h │ ├── BMeshUtility.h │ └── Tools │ │ ├── BMBisectOp.h │ │ ├── BMeshBisectPlane.h │ │ ├── BMeshDecimate.h │ │ ├── BMeshDiffCurvature.h │ │ ├── BMeshDuplicate.h │ │ ├── BMeshOp.h │ │ ├── BMeshRemesh.h │ │ ├── BMeshSymmetrize.h │ │ └── BMeshTriangulate.h ├── BaseLib │ ├── BasePrecompiled.h │ ├── Box.h │ ├── BoxEdge.h │ ├── BoxPlane.h │ ├── BoxVertex.h │ ├── CalcPolygonOffset.h │ ├── ClipPolygon.h │ ├── DlnEdge.h │ ├── DlnPoint.h │ ├── DlnTriangle.h │ ├── GluTesselator.h │ ├── GluTesselatorBoundary.h │ ├── KArray.h │ ├── KGrid1D.h │ ├── KLinkList.h │ ├── KModelMatrix.h │ ├── KPair.h │ ├── KSphereOctree.h │ ├── K_HashTable.h │ ├── LinearEquation.h │ ├── MathBase.h │ ├── MathGeom.h │ ├── MathUtil.h │ ├── PlanarContour.h │ ├── Plane.h │ ├── Point2Df.h │ ├── Point3Dd.h │ ├── Point3DdList.h │ ├── PointnD.h │ ├── Quadrangle.h │ ├── Ray2Dd.h │ ├── Segment2Df.h │ ├── SkeletonGenerator.h │ ├── SseVector3f.h │ ├── StackWalker.h │ ├── Timer.h │ ├── TriTriIsct.h │ ├── TriangleIndexByZ.h │ ├── UtilMacro.h │ ├── VB2DTessellator.h │ ├── VBGrid2D.h │ ├── VBOffsetor.h │ ├── VBQuaternion.h │ ├── VQuadric.h │ ├── VertexGrid2D.h │ ├── aabb2d.h │ ├── contour2d.h │ ├── defined.h │ ├── eigen3.h │ ├── geometry.h │ ├── geometry.inl │ ├── intersectpoint.h │ ├── line2Dd.h │ ├── line3D.h │ ├── matrix3x3d.h │ ├── matrix4x4d.h │ ├── misc │ │ └── TriangleTriangleIntersection.h │ ├── point2D.h │ ├── ppl │ │ ├── agents_extras.h │ │ ├── barrier.h │ │ ├── bounded_queue.h │ │ ├── concrt_extras.h │ │ ├── concurrent_unordered_map.h │ │ ├── concurrent_unordered_set.h │ │ ├── connect.h │ │ ├── internal_concurrent_hash.h │ │ ├── internal_split_ordered_list.h │ │ ├── ppl_extras.h │ │ ├── ppltasks.h │ │ └── semaphore.h │ ├── segment2Dd.h │ ├── segment3Dd.h │ ├── triangle3Dd.h │ └── util.h ├── Boolean │ ├── accel │ │ └── aabvh.h │ ├── bm │ │ ├── bm_isct.h │ │ ├── bm_isct_bool_include.h │ │ ├── bm_isct_boolean.h │ │ ├── bm_isct_isct_problem.h │ │ ├── bm_isct_outer_hull_exact.h │ │ └── bm_isct_tri_problem.h │ ├── isct │ │ ├── absext4.h │ │ ├── empty3d.cpp │ │ ├── empty3d.h │ │ ├── ext4.h │ │ ├── fixext4.h │ │ ├── fixint.h │ │ ├── gmpext4.h │ │ ├── quantization.cpp │ │ ├── quantization.h │ │ ├── triangle.c │ │ ├── triangle.h │ │ └── unsafeRayTriIsct.h │ ├── math │ │ ├── bbox.h │ │ ├── ray.h │ │ └── vec.h │ └── util │ │ ├── iterPool.h │ │ ├── log.cpp │ │ ├── memPool.h │ │ ├── prelude.h │ │ ├── shortVec.h │ │ ├── timer.cpp │ │ └── unionFind.h ├── Sculpt │ ├── AnchoredStroke.h │ ├── AverageBrushDataOp.h │ ├── BMSplitCollapseOp.h │ ├── BezierCurve.h │ ├── NormalUpdateOp.h │ ├── SUtil.h │ ├── SculptCommand.h │ ├── StrokeData.h │ ├── VSculptConfig.h │ ├── VSculptLogger.cpp │ ├── VSculptLogger.h │ ├── brush │ │ ├── ClayBrushOp.h │ │ ├── ClayStripBrushOp.h │ │ ├── CreaseBrushOp.h │ │ ├── DrawBrushOp.h │ │ ├── FillBrushOp.h │ │ ├── FlattenBrushOp.h │ │ ├── GrabBrushOp.h │ │ ├── InflateBrushOp.h │ │ ├── NudgetBrushOp.h │ │ ├── PinchBrushOp.h │ │ ├── RotateBrushOp.h │ │ ├── SculptStroke.h │ │ ├── SmoothBrushOp.h │ │ ├── SnakeHookBrushOp.h │ │ └── ThumbBrushOp.h │ ├── commonDefine.h │ └── transform.h ├── VBvh │ ├── BMBvhIsect.h │ ├── BMeshBvh.h │ ├── BMeshBvhBuilder.h │ ├── BMeshBvhNodeSplitter.h │ ├── VBvhBinBuilder.h │ ├── VBvhDefine.h │ ├── VBvhIterator.h │ ├── VBvhMortonBuilder.h │ ├── VBvhNode.h │ ├── VBvhOverlap.h │ ├── VBvhUtil.h │ ├── VMorton.h │ ├── VObjectPartition.h │ ├── VPrimInfor.h │ ├── VPrimRef.h │ ├── WorkStack.h │ ├── common │ │ ├── default.h │ │ ├── math │ │ │ ├── bbox.h │ │ │ ├── mymath.h │ │ │ ├── vec2.h │ │ │ ├── vec3.h │ │ │ ├── vec3ba.h │ │ │ ├── vec3fa.h │ │ │ ├── vec3ia.h │ │ │ └── vec4.h │ │ ├── simd │ │ │ ├── simd.h │ │ │ ├── sse.h │ │ │ ├── sse_special.h │ │ │ ├── sseb.h │ │ │ ├── ssef.h │ │ │ └── ssei.h │ │ └── sys │ │ │ ├── constants.h │ │ │ ├── intrinsics.h │ │ │ ├── platform.h │ │ │ └── sysinfo.h │ └── hash │ │ ├── GridUtil.h │ │ └── SpacialHash.h ├── VKernel │ ├── BMeshRemeshOp.h │ ├── GteWireframeEffect.h │ ├── VCamera.h │ ├── VCameraLens.h │ ├── VContext.h │ ├── VEffectManager.h │ ├── VFloorNode.h │ ├── VKernelCommon.h │ ├── VLighting.h │ ├── VManipulatorNode.h │ ├── VMeshObject.h │ ├── VMeshObjectRender.h │ ├── VNode.h │ ├── VNodeRender.h │ ├── VObject.h │ ├── VPVWUpdater.h │ ├── VScene.h │ ├── VSceneRenderer.h │ ├── VSmoothOp.h │ ├── VTextureLoader.h │ ├── VTrackBall.h │ ├── VTransform.h │ ├── VView3DEditBox.h │ └── VView3DRegion.h ├── VbsQt │ └── VbsDef.h ├── render │ ├── GTEngineDEF.h │ ├── GTEnginePCH.h │ ├── GTGraphics.h │ ├── Graphics │ │ ├── GL4 │ │ │ ├── GteGL4BlendState.h │ │ │ ├── GteGL4Buffer.h │ │ │ ├── GteGL4ConstantBuffer.h │ │ │ ├── GteGL4DepthStencilState.h │ │ │ ├── GteGL4DrawTarget.h │ │ │ ├── GteGL4DrawingState.h │ │ │ ├── GteGL4Engine.h │ │ │ ├── GteGL4GraphicsObject.h │ │ │ ├── GteGL4IndexBuffer.h │ │ │ ├── GteGL4InputLayout.h │ │ │ ├── GteGL4InputLayoutManager.h │ │ │ ├── GteGL4RasterizerState.h │ │ │ ├── GteGL4Resource.h │ │ │ ├── GteGL4SamplerState.h │ │ │ ├── GteGL4Texture.h │ │ │ ├── GteGL4Texture2.h │ │ │ ├── GteGL4Texture3.h │ │ │ ├── GteGL4TextureArray.h │ │ │ ├── GteGL4TextureCube.h │ │ │ ├── GteGL4TextureDS.h │ │ │ ├── GteGL4TextureRT.h │ │ │ ├── GteGL4TextureSingle.h │ │ │ ├── GteGL4VertexBuffer.h │ │ │ ├── GteGLFunction.h │ │ │ ├── GteGLSLComputeProgram.h │ │ │ ├── GteGLSLProgramFactory.h │ │ │ ├── GteGLSLReflection.h │ │ │ ├── GteGLSLVisualProgram.h │ │ │ ├── GteOpenGL.h │ │ │ └── GteOpenGLHelper.h │ │ ├── GteAmbientLightEffect.h │ │ ├── GteBlendState.h │ │ ├── GteBuffer.h │ │ ├── GteComputeProgram.h │ │ ├── GteComputeShader.h │ │ ├── GteConstantBuffer.h │ │ ├── GteConstantColorEffect.h │ │ ├── GteDataFormat.h │ │ ├── GteDepthStencilState.h │ │ ├── GteDirectionalLightEffect.h │ │ ├── GteDirectionalLightTextureEffect.h │ │ ├── GteDrawTarget.h │ │ ├── GteDrawingState.h │ │ ├── GteFont.h │ │ ├── GteFontArialW400H18.h │ │ ├── GteGEDrawTarget.h │ │ ├── GteGEInputLayoutManager.h │ │ ├── GteGEObject.h │ │ ├── GteGeometryShader.h │ │ ├── GteGraphicsEngine.h │ │ ├── GteGraphicsObject.h │ │ ├── GteIndexBuffer.h │ │ ├── GteIndexFormat.h │ │ ├── GteIndirectArgumentsBuffer.h │ │ ├── GteKeyframeController.h │ │ ├── GteLightCameraGeometry.h │ │ ├── GteLighting.h │ │ ├── GteLightingEffect.h │ │ ├── GteMaterial.h │ │ ├── GteMemberLayout.h │ │ ├── GteMeshFactory.h │ │ ├── GteOverlayEffect.h │ │ ├── GtePixelShader.h │ │ ├── GtePointLightEffect.h │ │ ├── GtePointLightTextureEffect.h │ │ ├── GteProgramDefines.h │ │ ├── GteProgramFactory.h │ │ ├── GteRasterizerState.h │ │ ├── GteRawBuffer.h │ │ ├── GteResource.h │ │ ├── GteSamplerState.h │ │ ├── GteShader.h │ │ ├── GteSpotLightEffect.h │ │ ├── GteStructuredBuffer.h │ │ ├── GteTextEffect.h │ │ ├── GteTexture.h │ │ ├── GteTexture1.h │ │ ├── GteTexture1Array.h │ │ ├── GteTexture2.h │ │ ├── GteTexture2Array.h │ │ ├── GteTexture2ColorEffect.h │ │ ├── GteTexture2Effect.h │ │ ├── GteTexture3.h │ │ ├── GteTexture3Effect.h │ │ ├── GteTextureArray.h │ │ ├── GteTextureBuffer.h │ │ ├── GteTextureCube.h │ │ ├── GteTextureCubeArray.h │ │ ├── GteTextureDS.h │ │ ├── GteTextureRT.h │ │ ├── GteTextureSingle.h │ │ ├── GteTypedBuffer.h │ │ ├── GteVertexBuffer.h │ │ ├── GteVertexColorEffect.h │ │ ├── GteVertexFormat.h │ │ ├── GteVertexShader.h │ │ ├── GteVisualEffect.h │ │ ├── GteVisualProgram.h │ │ └── gteCommon.h │ ├── LowLevel │ │ ├── GteArray2.h │ │ ├── GteAtomicMinMax.h │ │ ├── GteComputeModel.h │ │ ├── GteMemory.h │ │ ├── GteMinHeap.h │ │ ├── GteRangeIteration.h │ │ ├── GteThreadSafeMap.h │ │ ├── GteThreadSafeQueue.h │ │ ├── GteTimer.h │ │ └── GteWrapper.h │ └── Mathematics │ │ └── GteBitHacks.h └── vsculpt │ ├── K3DQMLAdapter.h │ ├── Operator │ ├── VCommonConfigOp.h │ ├── VDropMeshOp.h │ ├── VManipulatorOp.h │ ├── VMeshBooleanOp.h │ ├── VMeshDecimateOp.h │ ├── VMeshRemeshOp.h │ ├── VMeshSelfIsectOp.h │ ├── VMeshSmoothOp.h │ ├── VOpTemplate.h │ ├── VOperator.h │ ├── VSculptBrushOp.h │ ├── VSculptConfigOp.h │ ├── VView3DEditBoxOp.h │ └── VViewEditOp.h │ ├── QtQuickAppViewer.h │ ├── VCommon.h │ ├── VEventHandler.h │ ├── VOperatorQmlAdaptor.h │ └── VView3DRegionQuickItem.h ├── qml ├── box_view.ply └── cube.png ├── resource ├── K3DStudio-2.qrc ├── K3DStudio-3.qrc ├── K3DStudio-4.qrc ├── K3DStudio-5.qrc ├── TestForm.ui.qml ├── TestForm.ui.qml.autosave ├── qml.qrc ├── vsculptres.pro ├── vsculptres.pro.user └── vsculptres.pro.user.ec4a7c4 └── src ├── BMesh ├── BMCustomData.cpp ├── BMeshCore.cpp ├── BMeshIterators.cpp ├── BMeshPolygon.cpp ├── BMeshQueries.cpp ├── BMeshStructure.cpp ├── BMeshUtility.cpp └── Tools │ ├── BMBisectOp.cpp │ ├── BMeshBisectPlane.cpp │ ├── BMeshDecimate.cpp │ ├── BMeshDiffCurvature.cpp │ ├── BMeshRemesh.cpp │ ├── BMeshSymmetrize.cpp │ └── BMeshTriangulate.cpp ├── BaseLib ├── BasePrecompiled.cpp ├── Box.cpp ├── BoxEdge.cpp ├── BoxPlane.cpp ├── BoxVertex.cpp ├── CalcPolygonOffset.cpp ├── ClipPolygon.cpp ├── DlnEdge.cpp ├── DlnPoint.cpp ├── DlnTriangle.cpp ├── GluTesselator.cpp ├── GluTesselatorBoundary.cpp ├── KModelMatrix.cpp ├── MathGeom.cpp ├── MathUtil.cpp ├── PlanarContour.cpp ├── Plane.cpp ├── Point2Df.cpp ├── Point3Dd.cpp ├── Quadrangle.cpp ├── Ray2Dd.cpp ├── Segment2Dd.cpp ├── Segment2Df.cpp ├── SkeletonGenerator.cpp ├── StackWalker.cpp ├── Timer.cpp ├── TriTriIsct.cpp ├── VB2DTessellator.cpp ├── VBOffsetor.cpp ├── VBQuaternion.cpp ├── VQuadric.cpp ├── contour2d.cpp ├── eigen3.cpp ├── intersectpoint.cpp ├── line2Dd.cpp ├── line3D.cpp ├── matrix3x3d.cpp ├── matrix4x4d.cpp ├── misc │ └── TriangleTriangleIntersection.cpp ├── segment3Dd.cpp ├── triangle3Dd.cpp └── util.cpp ├── Boolean └── bm │ ├── bm_isct.cpp │ ├── bm_isct_bool_include.cpp │ ├── bm_isct_boolean.cpp │ ├── bm_isct_isct_problem.cpp │ ├── bm_isct_outer_hull_exact.cpp │ └── bm_isct_tri_problem.cpp ├── Sculpt ├── BMSplitCollapseOp.cpp ├── BezierCurve.cpp ├── SUtil.cpp ├── SculptCommand.cpp ├── VSculptConfig.cpp ├── brush │ └── SculptStroke.cpp └── transform.cpp ├── VBvh ├── BMBvhIsect.cpp ├── BMeshBvh.cpp ├── BMeshBvhBuilder.cpp ├── BMeshBvhNodeSplitter.cpp ├── VBvhUtil.cpp ├── VObjectPartition.cpp └── common │ ├── simd │ └── sse.cpp │ └── sys │ └── sysinfo.cpp ├── VKernel ├── BMeshRemeshOp.cpp ├── GteWireframeEffect.cpp ├── VCamera.cpp ├── VCameraLens.cpp ├── VContext.cpp ├── VEffectManager.cpp ├── VFloorNode.cpp ├── VLighting.cpp ├── VManipulatorNode.cpp ├── VMeshObject.cpp ├── VMeshObjectRender.cpp ├── VNode.cpp ├── VObject.cpp ├── VPVWUpdater.cpp ├── VScene.cpp ├── VSceneRenderer.cpp ├── VSmoothOp.cpp ├── VTextureLoader.cpp ├── VTrackBall.cpp ├── VTransform.cpp ├── VView3DEditBox.cpp └── VView3DRegion.cpp ├── VbsQt └── VbsDef.cpp ├── render ├── Graphics │ ├── GL4 │ │ ├── GteGL4BlendState.cpp │ │ ├── GteGL4Buffer.cpp │ │ ├── GteGL4ConstantBuffer.cpp │ │ ├── GteGL4DepthStencilState.cpp │ │ ├── GteGL4DrawTarget.cpp │ │ ├── GteGL4DrawingState.cpp │ │ ├── GteGL4Engine.cpp │ │ ├── GteGL4GraphicsObject.cpp │ │ ├── GteGL4IndexBuffer.cpp │ │ ├── GteGL4InputLayout.cpp │ │ ├── GteGL4InputLayoutManager.cpp │ │ ├── GteGL4RasterizerState.cpp │ │ ├── GteGL4Resource.cpp │ │ ├── GteGL4SamplerState.cpp │ │ ├── GteGL4Texture.cpp │ │ ├── GteGL4Texture2.cpp │ │ ├── GteGL4Texture3.cpp │ │ ├── GteGL4TextureArray.cpp │ │ ├── GteGL4TextureCube.cpp │ │ ├── GteGL4TextureDS.cpp │ │ ├── GteGL4TextureRT.cpp │ │ ├── GteGL4TextureSingle.cpp │ │ ├── GteGL4VertexBuffer.cpp │ │ ├── GteGLFunction.cpp │ │ ├── GteGLSLComputeProgram.cpp │ │ ├── GteGLSLProgramFactory.cpp │ │ ├── GteGLSLReflection.cpp │ │ ├── GteGLSLVisualProgram.cpp │ │ ├── GteOpenGL.cpp │ │ ├── GteOpenGLHelper.cpp │ │ └── GteWGLExtensions.cpp │ ├── GteAmbientLightEffect.cpp │ ├── GteBlendState.cpp │ ├── GteBuffer.cpp │ ├── GteComputeProgram.cpp │ ├── GteComputeShader.cpp │ ├── GteConstantBuffer.cpp │ ├── GteConstantColorEffect.cpp │ ├── GteDataFormat.cpp │ ├── GteDepthStencilState.cpp │ ├── GteDirectionalLightEffect.cpp │ ├── GteDirectionalLightTextureEffect.cpp │ ├── GteDrawTarget.cpp │ ├── GteDrawingState.cpp │ ├── GteFont.cpp │ ├── GteFontArialW400H18.cpp │ ├── GteGEDrawTarget.cpp │ ├── GteGEObject.cpp │ ├── GteGeometryShader.cpp │ ├── GteGraphicsEngine.cpp │ ├── GteGraphicsObject.cpp │ ├── GteIndexBuffer.cpp │ ├── GteIndirectArgumentsBuffer.cpp │ ├── GteKeyframeController.cpp │ ├── GteLightCameraGeometry.cpp │ ├── GteLighting.cpp │ ├── GteLightingEffect.cpp │ ├── GteMaterial.cpp │ ├── GteMeshFactory.cpp │ ├── GteOverlayEffect.cpp │ ├── GtePixelShader.cpp │ ├── GtePointLightEffect.cpp │ ├── GtePointLightTextureEffect.cpp │ ├── GteProgramDefines.cpp │ ├── GteProgramFactory.cpp │ ├── GteRasterizerState.cpp │ ├── GteRawBuffer.cpp │ ├── GteResource.cpp │ ├── GteSamplerState.cpp │ ├── GteShader.cpp │ ├── GteSpotLightEffect.cpp │ ├── GteStructuredBuffer.cpp │ ├── GteTextEffect.cpp │ ├── GteTexture.cpp │ ├── GteTexture1.cpp │ ├── GteTexture1Array.cpp │ ├── GteTexture2.cpp │ ├── GteTexture2Array.cpp │ ├── GteTexture2ColorEffect.cpp │ ├── GteTexture2Effect.cpp │ ├── GteTexture3.cpp │ ├── GteTexture3Effect.cpp │ ├── GteTextureArray.cpp │ ├── GteTextureBuffer.cpp │ ├── GteTextureCube.cpp │ ├── GteTextureCubeArray.cpp │ ├── GteTextureDS.cpp │ ├── GteTextureRT.cpp │ ├── GteTextureSingle.cpp │ ├── GteTypedBuffer.cpp │ ├── GteVertexBuffer.cpp │ ├── GteVertexColorEffect.cpp │ ├── GteVertexFormat.cpp │ ├── GteVertexShader.cpp │ ├── GteVisualEffect.cpp │ └── GteVisualProgram.cpp ├── LowLevel │ ├── GteTimer.cpp │ └── GteWrapper.cpp └── Mathematics │ └── GteBitHacks.cpp └── vsculpt ├── K3DQMLAdapter.cpp ├── Operator ├── VCommonConfigOp.cpp ├── VDropMeshOp.cpp ├── VManipulatorOp.cpp ├── VMeshBooleanOp.cpp ├── VMeshDecimateOp.cpp ├── VMeshRemeshOp.cpp ├── VMeshSelfIsectOp.cpp ├── VMeshSmoothOp.cpp ├── VOpTemplate.cpp ├── VOperator.cpp ├── VSculptBrushOp.cpp ├── VSculptConfigOp.cpp ├── VView3DEditBoxOp.cpp └── VViewEditOp.cpp ├── QtQuickAppViewer.cpp ├── VEventHandler.cpp ├── VOperatorQmlAdaptor.cpp ├── VView3DRegionQuickItem.cpp └── main.cpp /README.md: -------------------------------------------------------------------------------- 1 | 2 | # An open-source digital sculpting project 3 | 4 | ## Some cool features. 5 | 6 | ### Multiple Types of Sculpt Brushes 7 | Inflate, Nudget, Draw Pinch, Snake Hook, Clay Strip, Smooth, Crease, Clay, Grab, Flatten, Rotate, Thumb 8 | ![image](https://user-images.githubusercontent.com/2276264/161384069-783d6944-72db-43cc-8015-c88440d917b8.png) 9 | 10 | ### Dynamic Topology 11 | Automatical subdivison of mesh surfaces to support higher level of detail 12 | ![image](https://user-images.githubusercontent.com/2276264/161384161-9f46f399-7803-48f1-a81a-5a48252ae265.png) 13 | 14 | ### Adaptive Remeshing 15 | Optimize mesh topology for more vertices at high curvature regions and fewer vertices at more flat regions. 16 | ![image](https://user-images.githubusercontent.com/2276264/161384303-660d9f11-26c2-4948-bccb-3ed4599526df.png) 17 | 18 | ### Mesh Boolean Tools 19 | Calculate Union, Difference or Subtraction of two meshes 20 | ![image](https://user-images.githubusercontent.com/2276264/161384738-33079e96-5317-4bd1-b9d5-f311be2c6db2.png) 21 | 22 | ### Meshing of Sphere-based Skeleton Structure for Fash Mesh Creation. 23 | ![image](https://user-images.githubusercontent.com/2276264/161385212-279b7f05-74d0-4ecd-b94c-3bec8e98a10e.png) 24 | 25 | ## Requirements. 26 | - Qt5 27 | 28 | ## Additional resource 29 | - A few more [demo clips](https://www.youtube.com/playlist?list=PLkLcpRjubtMfBnvqnge646SncXCaHWqBJ) 30 | -------------------------------------------------------------------------------- /build/Sculpt/Sculpt.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | C:\Qt\Qt5.6.0\5.6\msvc2013 6 | PATH=$(QTDIR)\bin%3b$(PATH) 7 | 8 | 9 | C:\Qt\Qt5.6.0\5.6\msvc2013 10 | PATH=$(QTDIR)\bin%3b$(PATH) 11 | 12 | -------------------------------------------------------------------------------- /build/VKernel/VKernel.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | PATH="$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(PATH) 5 | C:\Qt\Qt5.6.0\5.6\msvc2013 6 | 7 | 8 | PATH="$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(PATH) 9 | C:\Qt\Qt5.6.0\5.6\msvc2013 10 | 11 | -------------------------------------------------------------------------------- /build/VbsQt/VbsQt.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | PATH="$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(PATH) 5 | C:\Qt\Qt5.6.0\5.6\msvc2013 6 | 7 | 8 | PATH="$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(PATH) 9 | C:\Qt\Qt5.6.0\5.6\msvc2013 10 | 11 | -------------------------------------------------------------------------------- /build/render/render.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | C:\Qt\Qt5.6.0\5.6\msvc2013 6 | PATH=$(QTDIR)\bin%3b$(PATH) 7 | 8 | 9 | C:\Qt\Qt5.6.0\5.6\msvc2013 10 | PATH=$(QTDIR)\bin%3b$(PATH) 11 | 12 | -------------------------------------------------------------------------------- /build/vsculpt/vsculpt.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | PATH="$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(PATH) 5 | C:\Qt\Qt5.6.0\5.6\msvc2013 6 | 7 | 8 | PATH="$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(PATH) 9 | C:\Qt\Qt5.6.0\5.6\msvc2013 10 | 11 | -------------------------------------------------------------------------------- /build/vsculpt_qt5.v12.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhha/digital_sculpting/804edb2757143b87f3ffe6585a7b79b804ccdc80/build/vsculpt_qt5.v12.suo -------------------------------------------------------------------------------- /inc/BMesh/BMesh.h: -------------------------------------------------------------------------------- 1 | #ifndef VMESH_VMESH_H 2 | #define VMESH_VMESH_H 3 | #include "BMeshCore.h" 4 | #include "BMeshClass.h" 5 | #include "BMeshIterators.h" 6 | #include "BMeshQueries.h" 7 | #include "BMeshPolygon.h" 8 | #include "BMeshUtility.h" 9 | #include "BMCustomData.h" 10 | #endif -------------------------------------------------------------------------------- /inc/BMesh/BMeshPolygon.h: -------------------------------------------------------------------------------- 1 | #ifndef BMESH_BM_POLYGON_H 2 | #define BMESH_BM_POLYGON_H 3 | #include "BMUtilDefine.h" 4 | #include "BaseLib/UtilMacro.h" 5 | #include "BMeshClass.h" 6 | 7 | VM_BEGIN_NAMESPACE 8 | 9 | void BM_face_as_array_vert_tri(const BMFace *f, BMVert *r_verts[3]) ATTR_NONNULL(); 10 | void BM_face_as_array_vert_quad(const BMFace *f, BMVert *r_verts[4]) ATTR_NONNULL(); 11 | 12 | void BM_face_as_array_loop_tri(const BMFace *f, BMLoop *r_loops[3]) ATTR_NONNULL(); 13 | void BM_face_as_array_loop_quad(const BMFace *f, BMLoop *r_loops[4]) ATTR_NONNULL(); 14 | bool BM_face_closest_point(BMFace *f, const Vector3f &p, Vector3f &closest); 15 | 16 | void BM_face_normal_update(BMFace *f); 17 | float BM_face_calc_normal(const BMFace *f, Vector3f &r_no) ATTR_NONNULL(); 18 | void BM_face_calc_bounds(const BMFace *f, Vector3f &lower, Vector3f &upper); 19 | float BM_face_calc_area(const BMFace *f) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); 20 | void BM_face_calc_center_mean(const BMFace *f, Vector3f ¢er) ATTR_NONNULL(); 21 | 22 | void BM_vert_calc_mean(const BMVert *v, Vector3f &r_mean); 23 | bool BM_vert_calc_normal(const BMVert *v, Vector3f &r_no); 24 | bool BM_vert_calc_normal_ex(const BMVert *v, const char hflag, Vector3f &r_no); 25 | void BM_vert_normal_update(BMVert *v) ATTR_NONNULL(); 26 | void BM_vert_normal_update_face(BMVert *v) ATTR_NONNULL(); 27 | void BM_vert_normal_update_all(BMVert *v) ATTR_NONNULL(); 28 | 29 | /*TODO. Ignore it*/ 30 | void BM_vert_default_color_set(BMVert *v); 31 | VM_END_NAMESPACE 32 | #endif -------------------------------------------------------------------------------- /inc/BMesh/BMeshUtility.h: -------------------------------------------------------------------------------- 1 | #ifndef BMESH_UTILITY_H 2 | #define BMESH_UTILITY_H 3 | #include "BMUtilDefine.h" 4 | #include "BaseLib/UtilMacro.h" 5 | #include "BMeshClass.h" 6 | #include "BaseLib/VQuadric.h" 7 | 8 | VM_BEGIN_NAMESPACE 9 | void BM_edge_collapse_optimize_co(BMEdge *e, Vector3f &co); 10 | void BM_vert_quadric_calc(BMVert *v, Qdr::Quadric &vquadric); 11 | float BM_verts_calc_rotate_beauty(const BMVert *v1, const BMVert *v2, const BMVert *v3, const BMVert *v4, const short method); 12 | VM_END_NAMESPACE 13 | #endif -------------------------------------------------------------------------------- /inc/BMesh/Tools/BMBisectOp.h: -------------------------------------------------------------------------------- 1 | #ifndef BMESH_BM_BISECT_OP_H 2 | #define BMESH_BM_BISECT_OP_H 3 | #include "BMeshOp.h" 4 | VM_BEGIN_NAMESPACE 5 | 6 | class BMBisectOp : public BMeshOp 7 | { 8 | public: 9 | BMBisectOp(); 10 | ~BMBisectOp(); 11 | virtual void execute(); 12 | private: 13 | Vector3f _plane_co; 14 | Vector3f _plane_no; 15 | }; 16 | 17 | VM_END_NAMESPACE 18 | #endif -------------------------------------------------------------------------------- /inc/BMesh/Tools/BMeshDiffCurvature.h: -------------------------------------------------------------------------------- 1 | #ifndef BMESH_DIFF_CURVATURE_H 2 | #define BMESH_DIFF_CURVATURE_H 3 | 4 | #include "BMesh/BMesh.h" 5 | #define FIXED_VORONOI_AREA 6 | 7 | VM_BEGIN_NAMESPACE 8 | 9 | class BMeshDiffCurvature 10 | { 11 | public: 12 | BMeshDiffCurvature(BMesh *bm, int ncurvature_off); 13 | ~BMeshDiffCurvature(); 14 | void compute(); 15 | private: 16 | void init(); 17 | void computeVertexArea(); 18 | void computeGaussCurvature(); 19 | void computeMeanCurvature(); 20 | void computeEdgeWeight(); 21 | void smoothMeshBegin(); 22 | void smoothMeshEnd(); 23 | void smoothCurvature(); 24 | void outputCurvature(); 25 | void checkVertexBoundary(); 26 | private: 27 | BMesh *_bmesh; 28 | int _curvature_off; 29 | std::vector _vOrgCoord; 30 | 31 | /*real-time data*/ 32 | std::vector _vBoundary; 33 | std::vector _vArea; 34 | std::vector _vGaussCurvature; 35 | std::vector _vMeanCurvature; 36 | 37 | std::vector _eWeight; 38 | std::vector _eLength; 39 | std::vector _eVec; 40 | 41 | std::vector _fInternalAngle; 42 | std::vector _fArea; 43 | }; 44 | 45 | VM_END_NAMESPACE 46 | 47 | #endif -------------------------------------------------------------------------------- /inc/BMesh/Tools/BMeshDuplicate.h: -------------------------------------------------------------------------------- 1 | #ifndef BMESH_BMESH_DUPLICATE_H 2 | #define BMESH_BMESH_DUPLICATE_H 3 | #include "BMesh/BMesh.h" 4 | 5 | VM_BEGIN_NAMESPACE 6 | 7 | VM_END_NAMESPACE 8 | #endif -------------------------------------------------------------------------------- /inc/BMesh/Tools/BMeshRemesh.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhha/digital_sculpting/804edb2757143b87f3ffe6585a7b79b804ccdc80/inc/BMesh/Tools/BMeshRemesh.h -------------------------------------------------------------------------------- /inc/BMesh/Tools/BMeshSymmetrize.h: -------------------------------------------------------------------------------- 1 | #ifndef BMESH_BMESH_SYMMETRIZE_H 2 | #define BMESH_BMESH_SYMMETRIZE_H 3 | #include "BMesh/BMesh.h" 4 | VM_BEGIN_NAMESPACE 5 | class BMeshSymmetrize 6 | { 7 | enum 8 | { 9 | ELEM_CENTER = 1 << 0 10 | }; 11 | public: 12 | BMeshSymmetrize(BMesh *bm, Vector3f plane_co, Vector3f plane_no, bool side); 13 | ~BMeshSymmetrize(); 14 | void execute(); 15 | private: 16 | void clear_flag(BMesh *mesh); 17 | void mirror_clone(); 18 | private: 19 | BMesh *_bm; 20 | Vector3f _plane_co; 21 | Vector3f _plane_no; 22 | Vector4f _plane; 23 | bool _side; 24 | }; 25 | VM_END_NAMESPACE 26 | #endif -------------------------------------------------------------------------------- /inc/BMesh/Tools/BMeshTriangulate.h: -------------------------------------------------------------------------------- 1 | #ifndef BMESH_BMESH_TRIANGULATE_H 2 | #define BMESH_BMESH_TRIANGULATE_H 3 | #include "BMesh/BMesh.h" 4 | VM_BEGIN_NAMESPACE 5 | class BMeshTriangulate 6 | { 7 | public: 8 | BMeshTriangulate(BMesh *bm, const int quad_method, const int ngon_method, const bool tag_only); 9 | ~BMeshTriangulate(); 10 | void run(); 11 | private: 12 | BMesh *_bm; 13 | const int _quad_method; 14 | const int _ngon_method; 15 | const bool _tag_only; 16 | }; 17 | VM_END_NAMESPACE 18 | #endif -------------------------------------------------------------------------------- /inc/BaseLib/BasePrecompiled.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Plane.h" 4 | #include "Point2D.h" 5 | #include "Point2Df.h" 6 | #include "Point3Dd.h" 7 | #include "Point3DdList.h" 8 | #include "PointnD.h" 9 | #include "Quadrangle.h" 10 | #include "Ray2Dd.h" 11 | #include "segment2Dd.h" 12 | #include "Segment2Df.h" 13 | #include "segment3Dd.h" 14 | //#include "SseVector3f.h" 15 | #include "Timer.h" 16 | #include "triangle3Dd.h" 17 | #include "util.h" 18 | #include "aabb2d.h" 19 | #include "Box.h" 20 | #include "BoxEdge.h" 21 | #include "BoxPlane.h" 22 | #include "BoxVertex.h" 23 | #include "contour2d.h" 24 | #include "defined.h" 25 | #include "geometry.h" 26 | #include "intersectpoint.h" 27 | #include "KArray.h" 28 | #include "KGrid1D.h" 29 | #include "KLinkList.h" 30 | #include "KSphereOctree.h" 31 | #include "line2Dd.h" 32 | -------------------------------------------------------------------------------- /inc/BaseLib/Box.h: -------------------------------------------------------------------------------- 1 | #ifndef PARALLELEPIPPED_VERTEX 2 | #define PARALLELEPIPPED_VERTEX 3 | 4 | //#include "Point3Dd.h" 5 | //class Vector3Dd; 6 | class Point3Dd; 7 | class BoxVertex; 8 | class BoxPlane; 9 | class BoxEdge; 10 | class Box { 11 | public: 12 | //Cube(); 13 | Box(BoxVertex* minv, BoxVertex* maxv); 14 | //Parallelepiped(ParallelepipedVertex* minv, ParallelepipedVertex* maxv); 15 | ~Box(); 16 | public: 17 | Point3Dd* getXVect(); 18 | Point3Dd* getYVect(); 19 | Point3Dd* getZVect(); 20 | BoxPlane** getBoxPlanes(); 21 | int getNumberOfPlanes(); 22 | BoxVertex** getVertexs(); 23 | BoxEdge** getEdges(); 24 | private: 25 | //int buildEdges(); 26 | //int buildPlane(); 27 | int calcBasicParams(); 28 | public: 29 | BoxVertex* _vertexes[8]; 30 | BoxVertex* _minVertex; 31 | BoxVertex* _maxVertex; 32 | BoxEdge* _edges[12]; 33 | BoxPlane* _planes[6]; 34 | 35 | double _dx, _dy, _dz; 36 | Point3Dd* _vx, *_vy, *_vz; 37 | }; 38 | 39 | #endif -------------------------------------------------------------------------------- /inc/BaseLib/BoxEdge.h: -------------------------------------------------------------------------------- 1 | #ifndef CUBE_EDGE 2 | #define CUBE_EDGE 3 | #include "Point3Dd.h" 4 | #include 5 | 6 | class BoxVertex; 7 | class BoxPlane; 8 | class BoxEdge { 9 | public: 10 | BoxEdge(BoxVertex* v1, BoxVertex* v2); 11 | ~BoxEdge(); 12 | public: 13 | //void setPlanes(BoxPlane* plane1, BoxPlane* plane2); 14 | int calcPlanes(); 15 | Point3Dd getCenterPoint(); 16 | BoxVertex* getVextex(const int& index); 17 | BoxVertex* getOtherVertex(const BoxVertex* vertex); 18 | double module(); 19 | BoxVertex* getCommonVertex(BoxEdge* edge); 20 | BoxVertex* getCommonVertex(BoxEdge* edge1, BoxEdge* edge2); 21 | bool isContainVertex(BoxVertex* vertex); 22 | Point3Dd getVector(); 23 | std::string getAxisText(); 24 | private: 25 | BoxVertex* _vextexes[2]; 26 | BoxPlane* _planes[2]; 27 | }; 28 | 29 | #endif -------------------------------------------------------------------------------- /inc/BaseLib/BoxPlane.h: -------------------------------------------------------------------------------- 1 | #ifndef BOX_PLANE 2 | #define BOX_PLANE 3 | 4 | #include 5 | class Point3Dd; 6 | class BoxEdge; 7 | class BoxVertex; 8 | class BoxPlane{ 9 | public: 10 | BoxPlane(BoxVertex* v1, BoxVertex* v2, BoxVertex* v3, BoxVertex* v4); 11 | ~BoxPlane(); 12 | //void addBoxEdges(BoxEdge* e); 13 | void setNormal(Point3Dd* normal); 14 | void setEdges(BoxEdge* e1, BoxEdge* e2, BoxEdge* e3, BoxEdge* e4); 15 | bool isContainEdges(BoxEdge* e); 16 | bool isContainVertex(BoxVertex* v); 17 | BoxVertex* getCommonVertex(BoxPlane* plane1, BoxPlane* plane2); 18 | BoxEdge* getCommonEdge(BoxPlane* plane); 19 | BoxEdge** getBoxEdges(); 20 | Point3Dd* getNormal(); 21 | int getIntersectedEdges(BoxPlane* plane1, BoxPlane* plane2, 22 | BoxEdge*& edge1, BoxEdge*& edge2, BoxEdge*& edge3); 23 | BoxVertex* getVertex(const int& index); 24 | private: 25 | BoxVertex* _vertexes[4]; 26 | //std::vector _edges; 27 | BoxEdge* _edges[4]; 28 | Point3Dd* _normal; 29 | }; 30 | 31 | #endif -------------------------------------------------------------------------------- /inc/BaseLib/BoxVertex.h: -------------------------------------------------------------------------------- 1 | #ifndef CUBE_VERTEX 2 | #define CUBE_VERTEX 3 | 4 | #include "Point3Dd.h" 5 | #include 6 | 7 | class BoxEdge; 8 | class BoxPlane; 9 | class BoxVertex{ 10 | public: 11 | //CubeVertex(); 12 | BoxVertex(const Point3Dd& p); 13 | BoxVertex(Point3Dd* p); 14 | ~BoxVertex(); 15 | 16 | Point3Dd* getPoint(); 17 | //void setEdges(BoxEdge* e1, BoxEdge* e2, BoxEdge* e3); 18 | void addBoxEdge(BoxEdge* e); 19 | void addBoxPlan(BoxPlane* e); 20 | 21 | std::vector getPlanes(); 22 | std::vector getEdges(); 23 | BoxEdge* getOtherEdge(BoxEdge* e1, BoxEdge* e2); 24 | void get3Edges(BoxEdge*& e1, BoxEdge*& e2, BoxEdge*& e3); 25 | private: 26 | Point3Dd* _p; 27 | std::vector _edges; 28 | std::vector _planes; 29 | 30 | }; 31 | 32 | #endif -------------------------------------------------------------------------------- /inc/BaseLib/DlnEdge.h: -------------------------------------------------------------------------------- 1 | #ifndef SUPPORTGEN_SKEEDGE_H 2 | #define SUPPORTGEN_SKEEDGE_H 3 | 4 | 5 | namespace BaseType{ 6 | 7 | class DlnPoint; 8 | class DlnTriangle; 9 | 10 | class DlnEdge 11 | { 12 | public: 13 | DlnEdge(void); 14 | DlnEdge(DlnPoint* p1, DlnPoint* p2); 15 | ~DlnEdge(void); 16 | bool isChecked(); 17 | int setChecked(const bool flag = true); 18 | DlnPoint* getPoint(int i); 19 | int addTriangle(DlnTriangle* trig); 20 | bool isNotBoundaryEdge(); 21 | double calc2DSquareLength(); 22 | double calc2DLength(); 23 | int calc2DMidPoint(double* mid); 24 | int removeTriangle(const DlnTriangle* trig); 25 | DlnTriangle* getOtherTriangle(DlnTriangle* trig); 26 | DlnTriangle* getTriangle(size_t i); 27 | bool addPoint(DlnPoint* p); 28 | bool removePoint(DlnPoint* p); 29 | void removeFromPoint(); 30 | private: 31 | bool _isChecked; 32 | DlnPoint* _vps[2]; 33 | DlnTriangle* _trigs[2]; 34 | }; 35 | 36 | } // namespace 37 | 38 | #endif -------------------------------------------------------------------------------- /inc/BaseLib/DlnTriangle.h: -------------------------------------------------------------------------------- 1 | #ifndef SUPPORTGEN_SKETRIANGLE_H 2 | #define SUPPORTGEN_SKETRIANGLE_H 3 | 4 | #include "Point2D.h" 5 | 6 | namespace BaseType{ 7 | 8 | class DlnEdge; 9 | class DlnPoint; 10 | 11 | class DlnTriangle 12 | { 13 | public: 14 | DlnTriangle(void); 15 | DlnTriangle(DlnPoint* p0, DlnPoint* p1, DlnPoint* p2); 16 | ~DlnTriangle(void); 17 | 18 | DlnEdge* getEdge(const unsigned i); 19 | bool removeEdge(DlnEdge* e); 20 | bool addEdge(DlnEdge* e); 21 | void removeFromEdge(); 22 | void removePoints(); 23 | int setEdge(const int i, DlnEdge* ed); 24 | bool isExistEdge(const int &i); 25 | Point2Dd* getCoord(int i); 26 | int calc2DcenterPoint(double* cen); 27 | int checkType(); 28 | unsigned getType(); 29 | bool isChecked(); 30 | int setChecked(bool flag = true); 31 | int filter(const double& aveWidth2); 32 | int getTipVertexCoordOfType1Trig(double* coord); 33 | DlnEdge* getSkeEdgeOfType1Trig(); 34 | DlnEdge* getUncheckedSkeEdge(); 35 | DlnEdge* getOtherSkeEdge(DlnEdge* ed); 36 | DlnPoint* getOtherPoint(DlnPoint* v0, DlnPoint* v1); 37 | void setEdges(DlnEdge* e0, DlnEdge* e1, DlnEdge* e2); 38 | void setPoints(DlnPoint* p0, DlnPoint* p1, DlnPoint* p2); 39 | void recalcType(); 40 | DlnPoint* getPoint(size_t i){ return _points[i]; } 41 | private: 42 | unsigned short _isChecked:1; 43 | unsigned short _skeTrigType:4; 44 | DlnEdge* _edges[3]; 45 | DlnPoint* _points[3]; 46 | 47 | #ifdef _DEBUG 48 | int SkeTriangle_filter_count; 49 | #endif 50 | }; 51 | 52 | } 53 | 54 | #endif -------------------------------------------------------------------------------- /inc/BaseLib/GluTesselatorBoundary.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "Point3Dd.h" 6 | 7 | namespace Tesselator 8 | { 9 | 10 | //typedef std::array Point3d; 11 | 12 | typedef Point3Dd Point3d; 13 | typedef std::vector Polygon3d; 14 | typedef std::vector PolygonList; 15 | 16 | bool boundTesselatePolygon(PolygonList const & polygons, PolygonList & boundaries, int windingRule); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /inc/BaseLib/KPair.h: -------------------------------------------------------------------------------- 1 | #ifndef BASETYPE_KPAIR_H 2 | #define BASETYPE_KPAIR_H 3 | 4 | namespace BaseType{ 5 | 6 | 7 | 8 | template 9 | class KPair3{ 10 | public: 11 | KPair3(): 12 | _value1(0), 13 | _value2(0) 14 | { 15 | 16 | } 17 | KPair3(T key, T1* val1, T2* val2): 18 | _key(key), 19 | _value1(val1), 20 | _value2(val2){ 21 | 22 | } 23 | ~KPair3(){} 24 | 25 | public: 26 | T _key; 27 | T1* _value1; 28 | T2* _value2; 29 | }; 30 | 31 | template 32 | struct KPairAscendingSort 33 | { 34 | 35 | bool operator()(KPair3 const* s_pair, KPair3 const* e_pair) const 36 | { 37 | if (s_pair->_key < e_pair->_key) 38 | { 39 | return true; 40 | } 41 | return false; 42 | } 43 | 44 | }; 45 | 46 | } // namespace 47 | #endif -------------------------------------------------------------------------------- /inc/BaseLib/MathBase.h: -------------------------------------------------------------------------------- 1 | #ifndef BASELIB_MATHBASE_H 2 | #define BASELIB_MATHBASE_H 3 | 4 | #include "BaseLib/UtilMacro.h" 5 | 6 | //#define RAD2DEG(_rad) ((_rad) * (180.0 / M_PI)) 7 | //#define DEG2RAD(_deg) ((_deg) * (M_PI / 180.0)) 8 | 9 | 10 | #define RAD2DEGF(_rad) ((_rad) * (float)(180.0 / M_PI)) 11 | #define DEG2RADF(_deg) ((_deg) * (float)(M_PI / 180.0)) 12 | 13 | namespace MathBase 14 | { 15 | MINLINE float saacos(float fac) 16 | { 17 | if (UNLIKELY(fac <= -1.0f)) return (float)M_PI; 18 | else if (UNLIKELY(fac >= 1.0f)) return 0.0f; 19 | else return acosf(fac); 20 | } 21 | 22 | MINLINE float saasin(float fac) 23 | { 24 | if (UNLIKELY(fac <= -1.0f)) return (float)-M_PI / 2.0f; 25 | else if (UNLIKELY(fac >= 1.0f)) return (float)M_PI / 2.0f; 26 | else return asinf(fac); 27 | } 28 | 29 | MINLINE float sasqrt(float fac) 30 | { 31 | if (UNLIKELY(fac <= 0.0f)) return 0.0f; 32 | else return sqrtf(fac); 33 | } 34 | 35 | MINLINE float saacosf(float fac) 36 | { 37 | if (UNLIKELY(fac <= -1.0f)) return (float)M_PI; 38 | else if (UNLIKELY(fac >= 1.0f)) return 0.0f; 39 | else return acosf(fac); 40 | } 41 | 42 | MINLINE float saasinf(float fac) 43 | { 44 | if (UNLIKELY(fac <= -1.0f)) return (float)-M_PI / 2.0f; 45 | else if (UNLIKELY(fac >= 1.0f)) return (float)M_PI / 2.0f; 46 | else return asinf(fac); 47 | } 48 | }; 49 | #endif -------------------------------------------------------------------------------- /inc/BaseLib/Plane.h: -------------------------------------------------------------------------------- 1 | #ifndef PLANE_H 2 | #define PLANE_H 3 | #include "point3Dd.h" 4 | #include 5 | 6 | class Segment3Dd; 7 | 8 | class Plane { 9 | public: 10 | Plane(const Point3Dd& p, const Point3Dd& normal); 11 | Plane(){}; 12 | public: 13 | int intersectPlane(Point3Dd& lp, Vector3Dd& ld, const Point3Dd& p, const Vector3Dd& n) const; 14 | 15 | public: 16 | Point3Dd _p; 17 | Vector3Dd _normal; 18 | }; 19 | #endif -------------------------------------------------------------------------------- /inc/BaseLib/Point2Df.h: -------------------------------------------------------------------------------- 1 | #ifndef BASE_POINT2DF_H 2 | #define BASE_POINT2DF_H 3 | #pragma once 4 | //class Point2Df 5 | //{ 6 | //public: 7 | // float _v[2]; 8 | //public: 9 | // Point2Df(void); 10 | // Point2Df(const float* coord); 11 | // Point2Df(const double* coord); 12 | // Point2Df(const double x, const double y); 13 | // ~Point2Df(void); 14 | //}; 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /inc/BaseLib/Point3DdList.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Point3Dd.h" 6 | 7 | //namespace BaseType 8 | //{ 9 | // 10 | //typedef std::vector Polygon; 11 | // 12 | //typedef std::vector PolygonList; 13 | // 14 | //} 15 | -------------------------------------------------------------------------------- /inc/BaseLib/Quadrangle.h: -------------------------------------------------------------------------------- 1 | #ifndef BASE_QUADRANGLE_H 2 | #define BASE_QUADRANGLE_H 3 | #include "Point3Dd.h" 4 | #pragma once 5 | 6 | namespace BaseType{ 7 | 8 | class Quadrangle 9 | { 10 | public: 11 | Quadrangle(void); 12 | Quadrangle(const Point3Dd& p1, const Point3Dd& p2, const Point3Dd& p3, const Point3Dd& p4); 13 | ~Quadrangle(void); 14 | private: 15 | Point3Dd _vp[4]; 16 | }; 17 | 18 | } // namespace 19 | #endif -------------------------------------------------------------------------------- /inc/BaseLib/Ray2Dd.h: -------------------------------------------------------------------------------- 1 | #ifndef RAY2D_H 2 | #define RAY2D_H 3 | #include "Point2D.h" 4 | #include "contour2d.h" 5 | #include 6 | #include "segment2Dd.h" 7 | 8 | class Segment2Dd; 9 | 10 | class Ray2Dd { 11 | public: 12 | Ray2Dd(); 13 | Ray2Dd(const Point2Dd& sp, const Point2Dd& vector); 14 | ~Ray2Dd(); 15 | 16 | public: 17 | bool checkintersectSegment(const Point2Dd& sp, const Point2Dd& ep); 18 | bool intersectSegment(Point2Dd& ip, const Point2Dd& sp, 19 | const Point2Dd& ep); 20 | bool intersectSegment(ISPoint2D& ip, Segment2Dd* segment); 21 | bool intersectLine(Point2Dd& ip, const Point2Dd& sp, 22 | const Point2Dd& ep); 23 | Point2Dd getOriginalPoint(); 24 | Point2Dd getVector(); 25 | private: 26 | Point2Dd _sp; 27 | Point2Dd _vector; 28 | }; 29 | #endif -------------------------------------------------------------------------------- /inc/BaseLib/Segment2Df.h: -------------------------------------------------------------------------------- 1 | #ifndef BASE_SEGMENT2DF_H 2 | #define BASE_SEGMENT2DF_H 3 | #pragma once 4 | #include "Point2D.h" 5 | 6 | class Segment2Df 7 | { 8 | public: 9 | Point2Df* _sp; 10 | Point2Df* _ep; 11 | public: 12 | 13 | Segment2Df(void); 14 | Segment2Df(Point2Df* sp, Point2Df* ep); 15 | ~Segment2Df(void); 16 | }; 17 | 18 | #endif -------------------------------------------------------------------------------- /inc/BaseLib/VB2DTessellator.h: -------------------------------------------------------------------------------- 1 | #ifndef BASELIB_TESSELLATOR_H 2 | #define BASELIB_TESSELLATOR_H 3 | #include "KLinkList.h" 4 | #include 5 | #include 6 | #include "Point3Dd.h" 7 | #include "Point2Df.h" 8 | #include "VBGrid2D.h" 9 | namespace BaseType{ 10 | 11 | typedef KLinkListEx Point2DfLinkList; 12 | typedef VBGrid2D WPGridLinkPoint2Df; 13 | 14 | class VB2DTessellator 15 | { 16 | private: 17 | unsigned _numberInitContour; 18 | WPGridLinkPoint2Df _grid; 19 | std::vector < Point2DfLinkList*> _contours; 20 | std::deque _indexTrigs; 21 | std::vector _pointCoord; 22 | public: 23 | VB2DTessellator(); 24 | ~VB2DTessellator(); 25 | void setOrigin(float origin[2]); 26 | void setSize(float size[2]); 27 | void addAContour(const std::vector &contour); 28 | void dumpToCad(Point2DfLinkList *contour, int color = 0); 29 | void dumpToCad(int color = 0); 30 | Point2DfLinkList* findOuterContour(); 31 | void calcAngleOfContour(Point2DfLinkList *contour); 32 | void calcAngleOfAllContours(); 33 | Point2DfLinkList* findVertexWithSmallestAngle(Point2DfLinkList *contour); 34 | void generateTriangles(); 35 | void getData(float **coords, unsigned &coordSize, unsigned **index, unsigned &indexSize); 36 | void getTrianglesIndex(unsigned **index, unsigned &nts); 37 | 38 | Point2DfLinkList* createTriangle(Point2DfLinkList *vmin); 39 | void setPolygonID(Point2DfLinkList *contour, const int id){ contour->setIDForAllLinkList(id); }; 40 | }; 41 | }// namespace 42 | #endif 43 | -------------------------------------------------------------------------------- /inc/BaseLib/eigen3.h: -------------------------------------------------------------------------------- 1 | 2 | /* Eigen-decomposition for symmetric 3x3 real matrices. 3 | Public domain, copied from the public domain Java library JAMA. */ 4 | 5 | #ifndef BASELIB_EIGEN3_H 6 | #define BASELIB_EIGEN3_H 7 | /* Symmetric matrix A => eigenvectors in columns of V, corresponding 8 | eigenvalues in d. */ 9 | namespace BaseType{ 10 | void eigen_decomposition(double A[3][3], double V[3][3], double d[3]); 11 | 12 | }// namespace 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /inc/BaseLib/intersectpoint.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERSECSION_POINT_H 2 | #define INTERSECSION_POINT_H 3 | #include "Point2D.h" 4 | 5 | class Segment2Dd; 6 | 7 | class ISPoint2D { 8 | public: 9 | ISPoint2D() { 10 | isDeleted = false; 11 | segment = nullptr; 12 | } 13 | ISPoint2D(const ISPoint2D& p) 14 | : ip (p.ip) 15 | , segment (p.segment) 16 | , isDeleted (p.isDeleted) 17 | { 18 | } 19 | ISPoint2D(Point2Dd ip_, Segment2Dd* seg) 20 | : ip (ip_) 21 | , segment (seg) 22 | , isDeleted (false) 23 | { 24 | } 25 | Point2Dd ip; 26 | Segment2Dd* segment; 27 | bool isDeleted; 28 | 29 | const bool operator<( const ISPoint2D& p ) const { 30 | return ip < p.ip; 31 | } 32 | 33 | //ISPoint2D& operator=( const ISPoint2D& p ) { 34 | // ip = p.ip; 35 | // segment = p.segment; 36 | // isDeleted = p.isDeleted; 37 | 38 | // return *this; 39 | //} 40 | 41 | ISPoint2D& operator=(const ISPoint2D& p) { 42 | ip = p.ip; 43 | segment = p.segment; 44 | isDeleted = p.isDeleted; 45 | 46 | return *this; 47 | } 48 | 49 | //const bool operator>( const ISPoint& p ) const { 50 | // return ip > p.ip; 51 | //} 52 | 53 | }; 54 | 55 | #endif -------------------------------------------------------------------------------- /inc/BaseLib/line2Dd.h: -------------------------------------------------------------------------------- 1 | #ifndef LINE2D_H 2 | #define LINE2D_H 3 | #include "Point2D.h" 4 | #include "intersectpoint.h" 5 | #include 6 | 7 | class Segment2Dd; 8 | 9 | class Line2Dd { 10 | public: 11 | Line2Dd(const Point2Dd& p, const Point2Dd& v); 12 | 13 | public: 14 | bool xLineIntersectXSegment(Point2Dd& ip, Segment2Dd* segment); 15 | 16 | bool xLineIntersectSegment( std::vector& ips, 17 | Segment2Dd* segment ); 18 | private: 19 | Point2Dd _p; 20 | Point2Dd _v; 21 | }; 22 | #endif -------------------------------------------------------------------------------- /inc/BaseLib/line3D.h: -------------------------------------------------------------------------------- 1 | #ifndef LINE3D_H 2 | #define LINE3D_H 3 | #include "point3Dd.h" 4 | #include 5 | 6 | class Segment3Dd; 7 | 8 | class Line3Dd { 9 | public: 10 | Line3Dd(const Point3Dd& p, const Point3Dd& v); 11 | 12 | public: 13 | bool intersectPlanarLine(Point3Dd& ip, const Point3Dd& p, const Vector3Dd& v); 14 | int Line3Dd::intersectPlane( Point3Dd& ip, const Point3Dd& onPoint, const Vector3Dd& normal) const; 15 | private: 16 | Point3Dd _p; 17 | Point3Dd _v; 18 | }; 19 | #endif -------------------------------------------------------------------------------- /inc/BaseLib/matrix3x3d.h: -------------------------------------------------------------------------------- 1 | #ifndef BASE_MATRIX3X3D_H 2 | #define BASE_MATRIX3X3D_H 3 | 4 | #include "Point3Dd.h" 5 | class Matrix3x3d 6 | { 7 | public: 8 | Matrix3x3d(void); 9 | Matrix3x3d(const Matrix3x3d &m); 10 | ~Matrix3x3d(void); 11 | 12 | void setIdentity(); 13 | Matrix3x3d operator*( Matrix3x3d& other) ; 14 | Matrix3x3d calRotateMatrixRevert(); 15 | Matrix3x3d calRotateMatrixRevert2(); 16 | Matrix3x3d calRotateMatrixRevert(Matrix3x3d& other); 17 | const Point3Dd operator*(const Point3Dd& p) const; 18 | const Matrix3x3d operator*(double d) const; 19 | const Matrix3x3d operator/(double d) const; 20 | void makeRotationAboutAxis(Point3Dd& axis, double angle); 21 | Vector3Dd getRow(unsigned i) const; 22 | Vector3Dd getColumn(unsigned i) const; 23 | void setColumn(unsigned i,const Vector3Dd &v); 24 | void setRow(unsigned i, const Vector3Dd &v); 25 | void unit(); 26 | Matrix3x3d inverse() const; 27 | 28 | public: 29 | double _v[3][3]; 30 | }; 31 | 32 | #endif -------------------------------------------------------------------------------- /inc/BaseLib/matrix4x4d.h: -------------------------------------------------------------------------------- 1 | #ifndef BASE_MATRIX4X4D_H 2 | #define BASE_MATRIX4X4D_H 3 | #pragma once 4 | class Matrix4x4d 5 | { 6 | public: 7 | Matrix4x4d(void); 8 | ~Matrix4x4d(void); 9 | public: 10 | double _v[4][4]; 11 | }; 12 | 13 | #endif -------------------------------------------------------------------------------- /inc/BaseLib/ppl/agents_extras.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhha/digital_sculpting/804edb2757143b87f3ffe6585a7b79b804ccdc80/inc/BaseLib/ppl/agents_extras.h -------------------------------------------------------------------------------- /inc/BaseLib/ppl/ppl_extras.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhha/digital_sculpting/804edb2757143b87f3ffe6585a7b79b804ccdc80/inc/BaseLib/ppl/ppl_extras.h -------------------------------------------------------------------------------- /inc/BaseLib/segment3Dd.h: -------------------------------------------------------------------------------- 1 | #ifndef SEGMENT_3D_H 2 | #define SEGMENT_3D_H 3 | 4 | #include "Point3Dd.h" 5 | #include "segment2Dd.h" 6 | #include "triangle3Dd.h" 7 | 8 | class Segment3Dd 9 | { 10 | public: 11 | Segment3Dd(); 12 | Segment3Dd( const Point3Dd& firstPoint, const Point3Dd& lastPoint ); 13 | Segment3Dd( const Segment3Dd& segment ); 14 | ~Segment3Dd(); 15 | public: 16 | 17 | const int intersectAxisPlane(double& ip, const double & offsetVal, 18 | const int icoord ) const/* icoord: coord index */; 19 | 20 | const int intersectAxisPlane(Point3Dd& ip, const double &offsetVal, 21 | const int icoord ) const/* icoord: coord index */; 22 | const Point3Dd getFisrtPoint() const; 23 | const Point3Dd getSecondPoint() const; 24 | bool isContainPoint(const Point3Dd& p, const bool& isOnLine = false); 25 | void getArrows(Segment3Dd& lArrow, Segment3Dd& rArrow); 26 | 27 | void get2SupplementSegments(const Segment3Dd& seg, 28 | Segment3Dd& seg1, Segment3Dd& seg2); 29 | const Vector3Dd getVector() const; 30 | private: 31 | Point3Dd _sp; 32 | Point3Dd _ep; 33 | 34 | }; 35 | 36 | typedef std::vector Segment3DdListVector; 37 | #endif -------------------------------------------------------------------------------- /inc/BaseLib/triangle3Dd.h: -------------------------------------------------------------------------------- 1 | #ifndef TRIANGLE_3D_H 2 | #define TRIANGLE_3D_H 3 | #include 4 | #include "Point2D.h" 5 | #include "Point3Dd.h" 6 | 7 | 8 | class Triangle3Dd 9 | { 10 | public: 11 | Triangle3Dd(const Point3Dd* vertexs, const Vector3Dd& normal); 12 | Triangle3Dd(const Point3Dd* vertexs); 13 | Triangle3Dd(const Point3Dd& p1, const Point3Dd& p2, const Point3Dd& p3); 14 | Triangle3Dd(const Point3Dd* p1, const Point3Dd* p2, const Point3Dd* p3, const Point3Dd* norm); 15 | Triangle3Dd(); 16 | ~Triangle3Dd(); 17 | public: 18 | void set(const Point3Dd& p1, const Point3Dd& p2, const Point3Dd& p3); 19 | int intersectAxisPlane( Point2Dd& ip1, Point2Dd& ip2, 20 | const double & zValue, const int iCoord ) const; 21 | bool isInvertedNormal(); 22 | void correctInvertedNormal(); 23 | void getVertexts(Point3Dd vertexs[3]); 24 | Point3Dd getVertext(const int i); 25 | Point3Dd* getpVertext(const int i); 26 | Vector3Dd getNormal(); 27 | Vector3Dd* getpNormal(); 28 | void getZMinMax(double& min, double& max); 29 | int calcNormal(); 30 | void offset(const double& d); 31 | void invertNormal(); 32 | public: 33 | 34 | #ifdef _DEBUG 35 | int _ired; 36 | #endif 37 | 38 | private: 39 | Point3Dd _vertexs[3]; 40 | Vector3Dd _normal; 41 | }; 42 | 43 | #endif -------------------------------------------------------------------------------- /inc/Boolean/bm/bm_isct_bool_include.h: -------------------------------------------------------------------------------- 1 | #ifndef BOOLEAN_BM_ISCT_BOOL_INCLUDE_H 2 | #define BOOLEAN_BM_ISCT_BOOL_INCLUDE_H 3 | #include "BMesh/BMesh.h" 4 | #include "VBvh/BMeshBvh.h" 5 | 6 | namespace bm_isct 7 | { 8 | BMesh *compute_union(VM::BMesh *bm0, VBvh::BMBvh *bvh0, VM::BMesh *bm1, VBvh::BMBvh *bvh1); 9 | BMesh *compute_difference(VM::BMesh *bm0, VBvh::BMBvh *bvh0, VM::BMesh *bm1, VBvh::BMBvh *bvh1); 10 | BMesh *compute_intersection(VM::BMesh *bm0, VBvh::BMBvh *bvh0, VM::BMesh *bm1, VBvh::BMBvh *bvh1); 11 | BMesh *resolve_self_isct(VM::BMesh *bm0); 12 | } 13 | #endif -------------------------------------------------------------------------------- /inc/Boolean/bm/bm_isct_tri_problem.h: -------------------------------------------------------------------------------- 1 | #ifndef BM_ISECT_TRI_PROBLEM_H 2 | #define BM_ISECT_TRI_PROBLEM_H 3 | #include "bm/bm_isct.h" 4 | 5 | #define REAL double 6 | extern "C" { 7 | #include "triangle.h" 8 | } 9 | namespace bm_isct 10 | { 11 | class IsctProblem; 12 | class TriangleProblem 13 | { 14 | public: 15 | TriangleProblem() {} 16 | ~TriangleProblem() {} 17 | 18 | void init(IsctProblem *iprob, Tptr t); 19 | private: 20 | void addEdge(IsctProblem *iprob, IVptr iv, Tptr tri_key); 21 | void addBoundaryHelper(Eptr edge, IVptr iv); 22 | public: 23 | // specify reference glue point and edge piercing this triangle. 24 | IVptr addInteriorEndpoint(IsctProblem *iprob, Eptr edge, GluePt glue); 25 | 26 | void addInteriorPoint(IsctProblem *iprob, Tptr t0, Tptr t1, GluePt glue); 27 | // specify the other triangle cutting this one, the edge cut, 28 | // and the resulting point of intersection 29 | void addBoundaryEndpoint(IsctProblem *iprob, Tptr tri_key, Eptr edge, IVptr iv); 30 | // run after we've accumulated all the elements 31 | void consolidate(IsctProblem *iprob); 32 | bool isValid() const; 33 | void subdivide(IsctProblem *iprob); 34 | private: 35 | void subdivideEdge(IsctProblem *iprob, GEptr ge, ShortVec &edges); 36 | private: 37 | friend class IsctProblem; 38 | 39 | ShortVec iverts; 40 | ShortVec iedges; 41 | // original triangle elements 42 | OVptr overts[3]; 43 | OEptr oedges[3]; 44 | 45 | ShortVec gtris; 46 | 47 | Tptr the_tri; 48 | }; 49 | } 50 | #endif -------------------------------------------------------------------------------- /inc/Boolean/isct/quantization.cpp: -------------------------------------------------------------------------------- 1 | // +------------------------------------------------------------------------- 2 | // | quantization.h 3 | // | 4 | // | Author: Gilbert Bernstein 5 | // +------------------------------------------------------------------------- 6 | // | COPYRIGHT: 7 | // | Copyright Gilbert Bernstein 2013 8 | // | See the included COPYRIGHT file for further details. 9 | // | 10 | // | This file is part of the Cork library. 11 | // | 12 | // | Cork is free software: you can redistribute it and/or modify 13 | // | it under the terms of the GNU Lesser General Public License as 14 | // | published by the Free Software Foundation, either version 3 of 15 | // | the License, or (at your option) any later version. 16 | // | 17 | // | Cork is distributed in the hope that it will be useful, 18 | // | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | // | GNU Lesser General Public License for more details. 21 | // | 22 | // | You should have received a copy 23 | // | of the GNU Lesser General Public License 24 | // | along with Cork. If not, see . 25 | // +------------------------------------------------------------------------- 26 | #include "quantization.h" 27 | 28 | namespace Quantization { 29 | 30 | double MAGNIFY = 1.0; 31 | double RESHRINK = 1.0; 32 | 33 | } // end namespace Quantization 34 | 35 | -------------------------------------------------------------------------------- /inc/Sculpt/AnchoredStroke.h: -------------------------------------------------------------------------------- 1 | #ifndef SCULPT_ANCHORED_STROKE_H 2 | #define SCULPT_ANCHORED_STROKE_H 3 | #include "sculpt/IStroke.h" 4 | class AnchoredStroke : public IStroke 5 | { 6 | public: 7 | AnchoredStroke(); 8 | ~AnchoredStroke(); 9 | void startStroke(const double& mouseX, const double& mouseY); 10 | void doStroke(const double& mouseX, const double& mouseY); 11 | void endStroke(const double& mouseX, const double& mouseY); 12 | void processStroke(); 13 | void saveData(); 14 | void restoreData(); 15 | private: 16 | size_t _oldFlag; 17 | std::vector _lastNodes; 18 | Point2Dd _pixelCenter; 19 | Point3Dd _initialHitPoint; 20 | double _oldPixelRadius; 21 | bool _firstTime; 22 | 23 | StlVertex** _lastVertArr; 24 | size_t _sizeLastVertArr; 25 | size_t _numLastVerts; 26 | }; 27 | #endif -------------------------------------------------------------------------------- /inc/Sculpt/BezierCurve.h: -------------------------------------------------------------------------------- 1 | #ifndef SCULPT_BEZIER_CURVE_H 2 | #define SCULPT_BEZIER_CURVE_H 3 | #include 4 | #include 5 | #include "BaseLib/Point3Dd.h" 6 | #include "VbsQt/VbsDef.h" 7 | 8 | class BezierCurve 9 | { 10 | public: 11 | struct CurvePoint 12 | { 13 | double x; 14 | double y; 15 | }; 16 | 17 | BezierCurve(VbsDef::CURVE type = VbsDef::CURVE_SMOOTH); 18 | ~BezierCurve(); 19 | 20 | double evaluate(const double par); 21 | void render(); 22 | void reset(VbsDef::CURVE type); 23 | void dumpCurve(); 24 | 25 | private: 26 | bool setControlPoints(int type); 27 | void makeTable(int resolution); 28 | 29 | private: 30 | int _resolution; 31 | int _totalPoint; 32 | float _step; 33 | VbsDef::CURVE _type; 34 | CurvePoint *_cpoints; 35 | CurvePoint *_table; 36 | }; 37 | #endif -------------------------------------------------------------------------------- /inc/Sculpt/SculptCommand.h: -------------------------------------------------------------------------------- 1 | #ifndef SCULPT_COMMAND_H 2 | #define SCULPT_COMMAND_H 3 | #include 4 | #include "VBvh//BMeshBvh.h" 5 | #include "VKernel/VScene.h" 6 | #include "VKernel/VMeshObject.h" 7 | #include "VSculptLogger.h" 8 | 9 | using namespace VBvh; 10 | 11 | class VSculptCommand 12 | { 13 | private: 14 | struct BMFaceLog 15 | { 16 | BMFace *f; 17 | BMVert *verts[3]; 18 | }; 19 | 20 | struct BMVLog 21 | { 22 | BMVert* v; 23 | Vector3f co; 24 | }; 25 | 26 | public: 27 | VSculptCommand(vk::VScene *scene, vk::VMeshObject *obj); 28 | ~VSculptCommand(); 29 | protected: 30 | /*method called from system. mutex must be locked here*/ 31 | bool doHook(); 32 | void undoHook(); 33 | void redoHook(); 34 | public: 35 | void log_data(const std::vector& nodes); 36 | void log_data(VSculptLogger &&logger); 37 | private: 38 | vk::VScene *_scene; 39 | vk::VMeshObject* _obj; 40 | std::shared_ptr _logger; 41 | }; 42 | #endif -------------------------------------------------------------------------------- /inc/Sculpt/StrokeData.h: -------------------------------------------------------------------------------- 1 | #ifndef SCULPT_STROKE_DATA_H 2 | #define SCULPT_STROKE_DATA_H 3 | #include 4 | #include "BezierCurve.h" 5 | #include "VKernel/VMeshObject.h" 6 | #include "Vbvh/BMeshBvh.h" 7 | #include "VKernel/VScene.h" 8 | #include "VKernel/VMeshObject.h" 9 | using namespace VBvh; 10 | 11 | enum SYMNFlag 12 | { 13 | SYMM_X = (1 << 0), 14 | SYMM_Y = (1 << 1), 15 | SYMM_Z = (1 << 2) 16 | }; 17 | struct SymmetricData 18 | { 19 | Vector3f first_hit_pos; 20 | Vector3f cur_pos; 21 | Vector3f view_dir; 22 | Vector3f grab_delta; 23 | }; 24 | 25 | class BVHRenderer; 26 | class VSculptCommand; 27 | 28 | struct StrokeData 29 | { 30 | vk::VScene *scene; 31 | vk::VMeshObject *object; 32 | BMBvh *bvh; 33 | BMesh *bm; 34 | VSculptCommand *undo_redo_logger; 35 | 36 | SymmetricData symn_data; 37 | Vector3f last_pos; 38 | Vector3f cur_pos; 39 | Vector3f first_hit_pos; 40 | Vector3f view_dir; 41 | Vector3f grab_delta; 42 | 43 | int brush_type; 44 | int flag; 45 | int sym_flag; //symm is a bit combination of XYZ - 1 is mirror X; 2 is Y; 3 is XY; 4 is Z; 5 is XZ; 6 is YZ; 7 is XYZ 46 | 47 | float world_radius; 48 | float rotate_angle; /*angle between first mouse and current mouse direction. Currently for rotate brush*/ 49 | float max_edge_len; 50 | float min_edge_len; 51 | float edge_len_unit_threshold; 52 | 53 | float scale; 54 | float pinch_factor; 55 | float brush_strength; 56 | 57 | bool ensure_min_edge_len; 58 | 59 | BezierCurve *deform_curve; 60 | }; 61 | #endif -------------------------------------------------------------------------------- /inc/Sculpt/VSculptConfig.h: -------------------------------------------------------------------------------- 1 | #ifndef SCULPT_SCULPT_CONFIG_H 2 | #define SCULPT_SCULPT_CONFIG_H 3 | #include "BezierCurve.h" 4 | #include "commonDefine.h" 5 | #include "BaseLib/UtilMacro.h" 6 | #include "VbsQt/VbsDef.h" 7 | 8 | class VSculptConfig 9 | { 10 | struct BrushConfig{ 11 | BrushConfig() : 12 | strength(0.5f), 13 | spacing(10.0f), 14 | pixel_size(50), 15 | detail_size(5.0), 16 | dynamic_topo(false), 17 | falloff(VbsDef::CURVE_SMOOTH) 18 | {} 19 | 20 | float strength; 21 | float spacing; 22 | int pixel_size; 23 | float detail_size; 24 | bool dynamic_topo; 25 | VbsDef::CURVE falloff; 26 | }; 27 | 28 | public: 29 | VSculptConfig(); 30 | ~VSculptConfig(); 31 | void setBrush(VbsDef::BRUSH); 32 | void setBrushStrength(float strength); 33 | void setBrushSpacing(float spacing); 34 | void setBrushPixelSize(int size); 35 | void setBrushDynamicTopology(bool topo); 36 | void setFalloffCurve(VbsDef::CURVE type); 37 | void setBrushDetailsize(float detail); 38 | 39 | VbsDef::BRUSH brush(); 40 | float brushStrength(); 41 | float brushSpacing(); 42 | float brushPixelSize(); 43 | float brushDynamicTopology(); 44 | float brushDetailsize(); 45 | VbsDef::CURVE brushFalloffCurve(); 46 | 47 | private: 48 | std::vector _brush_confs; 49 | VbsDef::BRUSH _brush; /*current brush*/ 50 | }; 51 | #endif -------------------------------------------------------------------------------- /inc/Sculpt/VSculptLogger.h: -------------------------------------------------------------------------------- 1 | #ifndef SCULPT_LOGGER_H 2 | #define SCULPT_LOGGER_H 3 | 4 | #include 5 | #include "VBvh//BMeshBvh.h" 6 | #include "VKernel/VScene.h" 7 | #include "VKernel/VMeshObject.h" 8 | 9 | using namespace vk; 10 | 11 | class VSculptLogger 12 | { 13 | private: 14 | struct BMFaceLog 15 | { 16 | BMFace *f; 17 | BMVert *verts[3]; 18 | }; 19 | 20 | struct BMVLog 21 | { 22 | BMVert* v; 23 | Vector3f co; 24 | }; 25 | 26 | public: 27 | VSculptLogger(VScene *scene, VMeshObject *obj); 28 | VSculptLogger(VSculptLogger &&other); 29 | ~VSculptLogger(); 30 | void log_nodes(const std::vector& nodes, bool keep_node = false); 31 | void undo(bool bvh_undo = false); 32 | void redo(bool bvh_undo = false); 33 | void undo_apply(); 34 | const std::vector& nodes(); 35 | private: 36 | void log_faces(const std::vector& nodes); 37 | void log_verts(const std::vector& nodes); 38 | private: 39 | VScene *_scene; 40 | VMeshObject* _obj; 41 | std::vector _nodes; 42 | std::vector _changed_verts; 43 | std::vector _created_faces; 44 | std::vector _deleted_faces; 45 | std::vector _created_verts; 46 | std::vector _deleted_verts; 47 | }; 48 | #endif -------------------------------------------------------------------------------- /inc/Sculpt/brush/SculptStroke.h: -------------------------------------------------------------------------------- 1 | #ifndef SCULPT_STROKE_H 2 | #define SCULPT_STROKE_H 3 | 4 | #include 5 | #include "StrokeData.h" 6 | #include "SculptCommand.h" 7 | #include "commonDefine.h" 8 | #include 9 | #include 10 | 11 | class SculptStroke 12 | { 13 | class StepLogger 14 | { 15 | typedef std::tuple FaceLog; 16 | typedef std::tuple VertLog; 17 | public: 18 | StepLogger(const std::vector &nodes); 19 | void restore(); 20 | private: 21 | std::vector _changed_nodes; 22 | std::vector _deleted_faces; 23 | std::vector _created_faces; 24 | std::vector _changed_verts; 25 | }; 26 | 27 | public: 28 | SculptStroke(StrokeData *sdata); 29 | ~SculptStroke(); 30 | void add_step(bool log_step = false); 31 | void finish_stroke(); 32 | void step_logger_begin(); 33 | void step_logger_end(); 34 | private: 35 | void calc_symm_data(size_t symm); 36 | bool is_dynamic_topology(); 37 | void update_topology(); 38 | void push_undo_redo(); 39 | void save_origin_node_data(const std::vector &nodes); 40 | void do_brush(); 41 | private: 42 | StrokeData *_data; 43 | VSculptLogger *_step_logger; 44 | }; 45 | #endif -------------------------------------------------------------------------------- /inc/Sculpt/commonDefine.h: -------------------------------------------------------------------------------- 1 | #ifndef SCULPT_COMMON_DEFINE_H 2 | #define SCULPT_COMMON_DEFINE_H 3 | 4 | #include "BaseLib/Point2D.h" 5 | #include "BaseLib/Point3Dd.h" 6 | #include "tbb/task_scheduler_init.h" 7 | #define TBB_PREVIEW_MEMORY_POOL 1 8 | #include "tbb/memory_pool.h" 9 | #include "tbb/cache_aligned_allocator.h" 10 | #include "tbb/mutex.h" 11 | #include 12 | 13 | 14 | class StlVertex; 15 | class NormalUpdateOp; 16 | class Transform; 17 | 18 | namespace sculpt 19 | { 20 | const size_t thread_number = tbb::task_scheduler_init::default_num_threads(); 21 | const size_t min_leaf_size = 100; 22 | const size_t max_leaf_size = 150; 23 | } 24 | 25 | //now we have four bit for flag 26 | //so flag's value 27 | enum EFlag 28 | { 29 | E_VISITED = 1, 30 | E_NEW_SUBDIVISION_EDGE = 2, 31 | E_GARBAGE_SUBDIVISION_EDGE = 4 32 | }; 33 | 34 | enum VFlag 35 | { 36 | V_MARK_DIRTY= 1, 37 | V_NEW_SUBDIVISION_VERTEX = 2, 38 | V_GARBAGE_SUBDIVISION_VERTEX = 4 39 | }; 40 | 41 | enum FFlag 42 | { 43 | F_MARK_DIRTY = 1 << 0, 44 | F_NEW_SUBDIVISION_TRIANGLE = 1 << 1, 45 | F_GARBAGE_SUBDIVISION_TRIANGLE = 1 << 2 /*triangle created and then deleted during subdivision: we don't need it*/ 46 | }; 47 | 48 | enum SFlag 49 | { 50 | PICK_ORIGINAL_LOCATION = (1 << 0), 51 | DYNAMIC_TOPOLOGY = (1 << 1), 52 | AVERAGE_DATA = (1 << 2) 53 | }; 54 | 55 | //typedef std::allocator PointerAllocator; 56 | typedef tbb::scalable_allocator PointerAllocator; 57 | typedef tbb::memory_pool PointerMemPool; //used inside each brush for vertex array 58 | 59 | #endif -------------------------------------------------------------------------------- /inc/Sculpt/transform.h: -------------------------------------------------------------------------------- 1 | #ifndef SCULPT_Transform_H 2 | #define SCULPT_Transform_H 3 | 4 | #include "BaseLib/Point3Dd.h" 5 | #include 6 | #include "OpenGL/include/glew.h" 7 | #include 8 | class Transform 9 | { 10 | public: 11 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW 12 | public: 13 | Transform(){}; 14 | ~Transform(){}; 15 | void reset(); 16 | Eigen::Vector2f project(const Eigen::Vector3f& point); 17 | bool unprojectScreenSpace(const int& mousex, const int& mousey, const double& depth, Point3Dd& p); 18 | bool unproject(const int& winx, const int& winy, const double& winz, Point3Dd& p); 19 | double calculateDepth(const Point3Dd& p); 20 | double worldRadius(const double& pixelRadius, const int& mouseX, const int& mouseY, const Point3Dd& location); 21 | void viewDirection(Point3Dd& viewDir); 22 | void nearFarPoints(int mouseX, int mouseY, Point3Dd& nearP, Point3Dd& farP); 23 | void nearPoint(const int& mx, const int& my, Point3Dd& nearP); 24 | void screenNormal(double& x, double& y, double& z); 25 | bool invertMatrix44(const double mat[4][4], double inverse[4][4]); 26 | void copyMatrix33Matrix44(double m1[3][3], double m2[4][4]); 27 | void mulMatrix33Vector3(const double M[3][3], const double r[3], double out[3]); 28 | void dump(std::string file); 29 | void load(std::string file); 30 | 31 | public: 32 | Eigen::Matrix4f _modelViewMat; 33 | Eigen::Matrix4f _projectMat; 34 | 35 | double _modelview[4][4]; 36 | double _projection[4][4]; 37 | double _invModelview[4][4]; 38 | double _invProjection[4][4]; 39 | int _viewport[4]; 40 | double _viewDir[3]; 41 | 42 | }; 43 | #endif -------------------------------------------------------------------------------- /inc/VBvh/BMeshBvhBuilder.h: -------------------------------------------------------------------------------- 1 | #ifndef VBVH_BMESH_BVH_BUILDER_H 2 | #define VBVH_BMESH_BVH_BUILDER_H 3 | 4 | #include "BMesh/BMesh.h" 5 | #include "VBvhMortonBuilder.h" 6 | #include "VPrimRef.h" 7 | #include "BMeshBvh.h" 8 | #include "tbb/scalable_allocator.h" 9 | 10 | using namespace VM; 11 | using namespace VBvh; 12 | 13 | VBVH_BEGIN_NAMESPACE 14 | 15 | class BMeshBvhBuilder 16 | { 17 | public: 18 | BMeshBvhBuilder(BMesh *bm); 19 | BMBvh* build(); 20 | void computeBounds(const std::vector &faces, VPrimRef *prims, size_t tot); 21 | void addCustomDataLayer(BMeshBvhContext &info); 22 | private: 23 | void computePrimInfo(VPrimRef *prims, size_t tot, VPrimInfo &infor); 24 | BMesh *_bmesh; 25 | }; 26 | 27 | VBVH_END_NAMESPACE 28 | 29 | #endif -------------------------------------------------------------------------------- /inc/VBvh/BMeshBvhNodeSplitter.h: -------------------------------------------------------------------------------- 1 | #ifndef VBVH_BMESHBVH_NODE_SPLITER_H 2 | #define VBVH_BMESHBVH_NODE_SPLITER_H 3 | #include "VBvh/VBvhDefine.h" 4 | #include "VBvh/BMeshBvh.h" 5 | #include "VBvh/VPrimRef.h" 6 | #include "VBvh/VPrimInfor.h" 7 | #include "VBvh/VBvhBinBuilder.h" 8 | 9 | VBVH_BEGIN_NAMESPACE 10 | class BMeshBvhNodeSplitter 11 | { 12 | public: 13 | BMeshBvhNodeSplitter(BMLeafNode *node, const BMeshBvhContext &bmbvhinfo); 14 | ~BMeshBvhNodeSplitter(); 15 | void run(); 16 | BaseNode *root(){ return _root; }; 17 | std::vector leafs(){ return _leafs; } 18 | private: 19 | const BMeshBvhContext &_bmbvh_info; 20 | BMLeafNode *_node; 21 | VPrimInfo _priminfo; 22 | VPrimRef *_prims; 23 | size_t _total; 24 | 25 | /*result*/ 26 | BaseNode *_root; 27 | std::vector _leafs; 28 | }; 29 | 30 | VBVH_END_NAMESPACE 31 | #endif -------------------------------------------------------------------------------- /inc/VBvh/VBvhUtil.h: -------------------------------------------------------------------------------- 1 | #ifndef VBVH_UTIL_H 2 | #define VBVH_UTIL_H 3 | #include "VBvhDefine.h" 4 | #include "BaseLib/Point3Dd.h" 5 | #include "BMeshBvh.h" 6 | #include "VBvh/VPrimRef.h" 7 | #include "VBvh/VPrimInfor.h" 8 | #include 9 | 10 | VBVH_BEGIN_NAMESPACE 11 | 12 | bool isectRayBB(const Ray* ray, const Vector3f &lower, const Vector3f &upper, float& hitParam); 13 | void facesBoundsNormalUpdate(BMFace * const *faces, size_t num, Vector3f &lower, Vector3f &upper); 14 | void BMFacesPrimInfoCompute(BMFace *const* faces, size_t num, VPrimRef *prims, VPrimInfo &info, bool threaded = true); 15 | void debugOutputNodeBB(BaseNode *node, std::vector &segments); 16 | Vector3f convert(const Vec3fa &p); 17 | 18 | VBVH_END_NAMESPACE 19 | #endif -------------------------------------------------------------------------------- /inc/VBvh/VMorton.h: -------------------------------------------------------------------------------- 1 | #ifndef VBVH_MORTON_H 2 | #define VBVH_MORTON_H 3 | #include "VBvhDefine.h" 4 | VBVH_BEGIN_NAMESPACE 5 | 6 | static const size_t LATTICE_BITS_PER_DIM = 10; 7 | static const size_t LATTICE_SIZE_PER_DIM = size_t(1) << LATTICE_BITS_PER_DIM; 8 | 9 | struct __declspec(align(8)) VMortonID32Bit 10 | { 11 | union { 12 | struct { 13 | unsigned int code; 14 | unsigned int index; 15 | //uint64 index; 16 | }; 17 | //int64 all; 18 | }; 19 | 20 | __forceinline operator unsigned() const { return code; } 21 | 22 | __forceinline unsigned int get(const unsigned int shift, const unsigned and_mask) const { 23 | return (code >> shift) & and_mask; 24 | } 25 | 26 | /*__forceinline void operator=(const MortonID32Bit& v) { 27 | all = v.all; 28 | };*/ 29 | 30 | __forceinline friend std::ostream &operator<<(std::ostream &o, const VMortonID32Bit& mc) { 31 | o << "index " << mc.index << " code = " << mc.code; 32 | return o; 33 | } 34 | 35 | __forceinline bool operator<(const VMortonID32Bit &m) const { return code < m.code; } 36 | __forceinline bool operator>(const VMortonID32Bit &m) const { return code > m.code; } 37 | }; 38 | 39 | VBVH_END_NAMESPACE 40 | #endif -------------------------------------------------------------------------------- /inc/VBvh/common/simd/simd.h: -------------------------------------------------------------------------------- 1 | #ifndef SCULPT_SIMD_H 2 | #define SCULPT_SIMD_H 3 | #include "VBvh/common/math/mymath.h" 4 | 5 | /* include SSE emulation for Xeon Phi */ 6 | #if defined (__MIC__) 7 | //# include "simd/sse_mic.h" 8 | # include "VBvh/common/simd/mic.h" 9 | #endif 10 | 11 | /* include SSE wrapper classes */ 12 | #if defined(__SSE__) 13 | # include "VBvh/common/simd/sse.h" 14 | #endif 15 | 16 | /* include AVX wrapper classes */ 17 | #if defined(__AVX__) 18 | #include "VBvh/common/simd/avx.h" 19 | #endif 20 | 21 | #if defined (__AVX__) 22 | #define AVX_ZERO_UPPER() _mm256_zeroupper() 23 | #else 24 | #define AVX_ZERO_UPPER() 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /inc/VBvh/common/simd/sse.h: -------------------------------------------------------------------------------- 1 | #ifndef SCULPT_SSE_H 2 | #define SCULPT_SSE_H 3 | #include "VBvh/common/sys/platform.h" 4 | #include "VBvh/common/sys/intrinsics.h" 5 | #include "VBvh/common/simd/sse_special.h" 6 | #include "VBvh/VBvhDefine.h" 7 | 8 | /* Workaround for Compiler bug in VS2008 */ 9 | #if (!defined(__SSE4_1__) || defined(_MSC_VER) && (_MSC_VER < 1600)) && !defined(__INTEL_COMPILER) 10 | #define _mm_blendv_ps __emu_mm_blendv_ps 11 | __forceinline __m128 _mm_blendv_ps( __m128 f, __m128 t, __m128 mask ) { 12 | return _mm_or_ps(_mm_and_ps(mask, t), _mm_andnot_ps(mask, f)); 13 | } 14 | #endif 15 | 16 | /* Workaround for Compiler bug in VS2008 */ 17 | #if defined(_MSC_VER) && (_MSC_VER < 1600) && !defined(__INTEL_COMPILER) 18 | #define _mm_extract_epi32 __emu_mm_extract_epi32 19 | __forceinline int _mm_extract_epi32( __m128i input, const int i ) { 20 | return input.m128i_i32[i]; 21 | } 22 | #endif 23 | 24 | VBVH_BEGIN_NAMESPACE 25 | 26 | extern const __m128 _mm_lookupmask_ps[16]; 27 | 28 | struct sseb; 29 | struct ssei; 30 | struct ssef; 31 | 32 | #if !defined(__MIC__) 33 | typedef ssef ssef_t; 34 | typedef ssei ssei_t; 35 | 36 | typedef ssef ssef_m; 37 | typedef ssei ssei_m; 38 | #endif 39 | 40 | VBVH_END_NAMESPACE 41 | 42 | #include "VBvh/common/simd/sseb.h" 43 | #include "VBvh/common/simd/ssei.h" 44 | #include "VBvh/common/simd/ssef.h" 45 | #endif 46 | -------------------------------------------------------------------------------- /inc/VKernel/BMeshRemeshOp.h: -------------------------------------------------------------------------------- 1 | #ifndef VKERNEL_REMESH_OP 2 | #define VKERNEL_REMESH_OP 3 | #include "VKernel/VMeshObject.h" 4 | #include "BMesh/BMesh.h" 5 | 6 | using namespace VM; 7 | class BMeshRemeshOp 8 | { 9 | static int count; 10 | enum 11 | { 12 | REMESH_V_FEATURE = 1 << 0, 13 | REMESH_V_CORNER = 1 << 1, 14 | REMESH_V_BOUNDARY = 1 << 2 15 | }; 16 | 17 | enum 18 | { 19 | REMESH_E_FEATURE = 1 << 0 20 | }; 21 | 22 | public: 23 | BMeshRemeshOp(BMesh *bm_, BMBvh *bvh_, bool feature = true); 24 | ~BMeshRemeshOp(); 25 | void run(); 26 | void setFeatureReserve(bool val){ _feature_ensure = val; }; 27 | void setIteration(size_t iter){ _iteration = iter; }; 28 | private: 29 | bool isTooShort(BMVert *v0, BMVert *v1); 30 | bool isTooLong(BMVert *v0, BMVert *v1); 31 | void begin(); 32 | void end(); 33 | void splitLongEdges(); 34 | void collapseShortEdges(); 35 | void optimizeValence(); 36 | void tangentialSmooth(); 37 | void projectOriginMesh(); 38 | void featureDetect(); 39 | private: 40 | BMesh *_bm; 41 | BMBvh *_refer_bvh; 42 | BMesh *ret_bm; 43 | float _emax, _emin, _eavg, _emaxsqr, _eminsqr; 44 | float _error; 45 | size_t _cd_v_curvature; 46 | bool _feature_ensure; 47 | size_t _iteration; 48 | }; 49 | #endif -------------------------------------------------------------------------------- /inc/VKernel/VContext.h: -------------------------------------------------------------------------------- 1 | #ifndef VSCULPT_VCONTEXT_H 2 | #define VSCULPT_VCONTEXT_H 3 | 4 | #include "VScene.h" 5 | #include 6 | #include 7 | #include 8 | 9 | VK_BEGIN_NAMESPACE 10 | struct VCommonConfig 11 | { 12 | VCommonConfig(){} 13 | }; 14 | 15 | class VContext 16 | { 17 | public: 18 | static VContext* instance(); 19 | public: 20 | ~VContext(); 21 | 22 | VScene* scene(); 23 | 24 | QQuickWindow* window(); 25 | void setWindow(QQuickWindow *win); 26 | 27 | VView3DRegion* region(); 28 | void setRegion(VView3DRegion *region); 29 | 30 | static void viewLine(VView3DRegion *region, Eigen::Vector2f win, Eigen::Vector3f &l1, Eigen::Vector3f &l2); 31 | static void viewRay(VView3DRegion *region, Eigen::Vector2f win, Eigen::Vector3f &org, Eigen::Vector3f &dir); 32 | static float screenDistanceToModelDistance(VView3DRegion *region, float pixel_dst, Eigen::Vector3f ref_pos); 33 | static Eigen::Vector3f project(VView3DRegion *region, Eigen::Vector3f &pos); 34 | static Eigen::Vector3f unproject(VView3DRegion *region, Eigen::Vector3f &win); 35 | static Vector3 viewModelDirection(VView3DRegion *region, VScene *scene); 36 | VCommonConfig* commonConfig(); 37 | Eigen::Vector2f currentGLMouse(); 38 | private: 39 | VContext(); 40 | private: 41 | static VContext _context; 42 | VScene *_scene; 43 | QQuickWindow *_window; 44 | VView3DRegion *_region; /*current region under mouse position*/ 45 | VCommonConfig _config; 46 | }; 47 | 48 | VK_END_NAMESPACE 49 | #endif -------------------------------------------------------------------------------- /inc/VKernel/VEffectManager.h: -------------------------------------------------------------------------------- 1 | #ifndef VKERNEL_VEFFECT_MANAGER_H 2 | #define VKERNEL_VEFFECT_MANAGER_H 3 | #include 4 | #include "VKernelCommon.h" 5 | 6 | VK_BEGIN_NAMESPACE 7 | class VEffectManager 8 | { 9 | public: 10 | VEffectManager(gte::ProgramFactory &factory, gte::BufferUpdater bufferUpdator); 11 | ~VEffectManager(); 12 | private: 13 | gte::ProgramFactory &_factory; 14 | gte::BufferUpdater &_bufferUpdator; 15 | }; 16 | VK_END_NAMESPACE 17 | 18 | #endif -------------------------------------------------------------------------------- /inc/VKernel/VFloorNode.h: -------------------------------------------------------------------------------- 1 | #ifndef VKERNEL_VGRID_NODE_H 2 | #define VKERNEL_VGRID_NODE_H 3 | #include "VKernel/VKernelCommon.h" 4 | #include "VKernel/VNode.h" 5 | #include "VKernel/VScene.h" 6 | VK_BEGIN_NAMESPACE 7 | class VFloorNode : public VNode 8 | { 9 | public: 10 | VFloorNode(VScene *scene); 11 | virtual ~VFloorNode(); 12 | virtual void onRender(VView3DRegion *region); 13 | private: 14 | void ensureEffect(); 15 | private: 16 | VScene *_scene; 17 | std::shared_ptr _effect; 18 | std::shared_ptr _vBuffer; 19 | std::shared_ptr _iBuffer; 20 | gte::EVector4 _gridColor, _axisXColor, _axisYColor; 21 | }; 22 | VK_END_NAMESPACE 23 | #endif -------------------------------------------------------------------------------- /inc/VKernel/VKernelCommon.h: -------------------------------------------------------------------------------- 1 | #ifndef VKERNEL_VKERNEL_COMMON_H 2 | #define VKERNEL_VKERNEL_COMMON_H 3 | 4 | #define VK_BEGIN_NAMESPACE namespace vk{ 5 | #define VK_END_NAMESPACE } 6 | 7 | #include 8 | #include 9 | VK_BEGIN_NAMESPACE 10 | 11 | typedef Eigen::Matrix Vector2; 12 | typedef Eigen::Matrix Vector3; 13 | typedef Eigen::Matrix Vector4; 14 | typedef Eigen::Matrix Matrix3x3; 15 | typedef Eigen::Matrix Matrix4x4; 16 | 17 | typedef Eigen::Quaternionf Quaternion; 18 | typedef Eigen::AngleAxisf AngleAxis; 19 | typedef Eigen::Transform Transform; 20 | 21 | VK_END_NAMESPACE 22 | #endif // !VKERNEL_VKERNEL_COMMON_H 23 | -------------------------------------------------------------------------------- /inc/VKernel/VLighting.h: -------------------------------------------------------------------------------- 1 | #ifndef VKERNEL_VLIGHTING_H 2 | #define VKERNEL_VLIGHTING_H 3 | 4 | #include "VKernelCommon.h" 5 | #include 6 | #include "VNode.h" 7 | 8 | VK_BEGIN_NAMESPACE 9 | 10 | struct VLighting : public VNode 11 | { 12 | Q_OBJECT 13 | public: 14 | VLighting(); 15 | ~VLighting(); 16 | public: 17 | Vector4 lightPosition() const; 18 | Vector4 lightDirection() const; 19 | Vector4 lightUp() const; 20 | Vector4 lightRight() const; 21 | const Vector4& ambient() const; 22 | const Vector4& diffuse() const; 23 | const Vector4& specular() const; 24 | const Vector4& cutoff() const; 25 | const Vector4& attenuation() const; 26 | public Q_SLOTS: 27 | void setLightPosition(const Vector4 &pos); 28 | void setLightDirection(const Vector4 &dir); 29 | void setLightUp(const Vector4 &up); 30 | void setLightRight(const Vector4 &right); 31 | void setAmbient(const Vector4 &val); 32 | void setDiffuse(const Vector4 &val); 33 | void setSpecular(const Vector4 &val); 34 | void setCutoff(const Vector4 &val); 35 | void setAttenuation(const Vector4 &val); 36 | Q_SIGNALS: 37 | void lightingChanged(VLighting*); 38 | private: 39 | Vector4 _lightPosition; // default: (0,0,0,1) 40 | Vector4 _lightDirection; // default: (0,0,-1,0) 41 | Vector4 _lightUp; // default: (0,1,0,0) 42 | Vector4 _lightRight; // default: (1,0,0,0) 43 | 44 | Vector4 _ambient; 45 | Vector4 _diffuse; 46 | Vector4 _specular; 47 | Vector4 _cutoff; 48 | Vector4 _attenuation; 49 | }; 50 | 51 | VK_END_NAMESPACE 52 | 53 | #endif -------------------------------------------------------------------------------- /inc/VKernel/VMeshObject.h: -------------------------------------------------------------------------------- 1 | #ifndef VKERNEL_VBMESH_NODE_H 2 | #define VKERNEL_VBMESH_NODE_H 3 | #include 4 | #include 5 | #include "VObject.h" 6 | #include "BMesh/BMesh.h" 7 | #include "VScene.h" 8 | 9 | VK_BEGIN_NAMESPACE 10 | class VView3DRegion; 11 | class VContext; 12 | class VMeshObject; 13 | 14 | 15 | 16 | class VMeshObject : public VObject 17 | { 18 | public: 19 | enum State 20 | { 21 | STATE_NONE, 22 | STATE_SCULPT, 23 | STATE_POSE_BEING_SELECT, 24 | STATE_POSE_DEFORM 25 | }; 26 | public: 27 | VMeshObject(VScene *scene, VM::BMesh *bm); 28 | virtual ~VMeshObject(); 29 | 30 | virtual void syncUpdate(); 31 | virtual void applyLocalTransform(); 32 | virtual Eigen::Vector3f center(); 33 | 34 | VM::BMesh* getBmesh(); 35 | VBvh::BMBvh* getBmeshBvh(); 36 | 37 | 38 | void setState(State s){ _state = s; }; 39 | State state(){ return _state; }; 40 | 41 | virtual bool pick(const Eigen::Vector3f& org, const Eigen::Vector3f& dir, Eigen::Vector3f& hit); 42 | virtual void onSceneRemoved(); 43 | virtual void onSceneReadded(); 44 | void setRenderMode(VbsDef::RENDER_MODE mode); 45 | 46 | private: 47 | void subcribeRenderData(); 48 | void unscribeRenderData(); 49 | private: 50 | VScene *_scene; 51 | VM::BMesh *_bmesh; 52 | VBvh::BMBvh *_bvh; 53 | State _state; 54 | }; 55 | VK_END_NAMESPACE 56 | 57 | #endif -------------------------------------------------------------------------------- /inc/VKernel/VNode.h: -------------------------------------------------------------------------------- 1 | #ifndef VKERNEL_VNODE_H 2 | #define VKERNEL_VNODE_H 3 | #include 4 | #include "VKernelCommon.h" 5 | #include 6 | #include 7 | VK_BEGIN_NAMESPACE 8 | 9 | class VView3DRegion; 10 | class VNodeVisitor 11 | { 12 | public: 13 | virtual void visit(class VNode *node) = 0; 14 | }; 15 | 16 | class VNode : public QObject 17 | { 18 | Q_OBJECT 19 | public: 20 | VNode(VNode *parent = nullptr); 21 | virtual ~VNode(); 22 | void accept(VNodeVisitor *visitor); 23 | virtual void syncUpdate(); 24 | virtual void onRender(VView3DRegion *region); 25 | public: 26 | virtual void updateWorldTransform(); 27 | Transform& worldTransform(); 28 | const Transform& worldTransform() const; 29 | Transform& localTransform(); 30 | const Transform& localTransform() const; 31 | 32 | protected: 33 | int _oflag; 34 | std::shared_ptr _worldTransform; 35 | std::shared_ptr _localTransform; 36 | }; 37 | 38 | VK_END_NAMESPACE 39 | 40 | #endif -------------------------------------------------------------------------------- /inc/VKernel/VNodeRender.h: -------------------------------------------------------------------------------- 1 | #ifndef VKERNEL_VOBJET_RENDER_H 2 | #define VKERNEL_VOBJET_RENDER_H 3 | #include "VKernel/VKernelCommon.h" 4 | 5 | VK_BEGIN_NAMESPACE 6 | class VContext; 7 | class VView3DRegion; 8 | class VNode; 9 | class VNodeRender 10 | { 11 | public: 12 | VNodeRender(){} 13 | virtual ~VNodeRender(){} 14 | virtual void onRender(VView3DRegion *region, Eigen::Vector4f(*cullingPlanes)[4]) = 0; 15 | virtual void syncUpdate(VContext *context, VNode *object) = 0; 16 | }; 17 | VK_END_NAMESPACE 18 | #endif -------------------------------------------------------------------------------- /inc/VKernel/VSceneRenderer.h: -------------------------------------------------------------------------------- 1 | #ifndef VKERNEL_VSCENE_RENDER_H 2 | #define VKERNEL_VSCENE_RENDER_H 3 | #include "VKernel/VKernelCommon.h" 4 | #include "VKernel/VContext.h" 5 | #include "VKernel/VNodeRender.h" 6 | #include 7 | 8 | VK_BEGIN_NAMESPACE 9 | 10 | class VView3DRegion; 11 | class VObject; 12 | 13 | class VSceneRender 14 | { 15 | public: 16 | typedef std::function RenderConstructor; 17 | typedef std::function RenderDestuctor; 18 | public: 19 | static VSceneRender *instance(); 20 | ~VSceneRender(); 21 | 22 | void syncUpdate(VContext *context); 23 | void render(VView3DRegion *region, Eigen::Vector4f(*cullingPlanes)[4]); 24 | 25 | void subcribe(VObject *obj, RenderConstructor constructor, RenderDestuctor destructor); 26 | void unsubcribe(VObject *obj); 27 | VNodeRender *renderer(VObject *obj); 28 | private: 29 | VSceneRender(); 30 | private: 31 | static VSceneRender *_instance; 32 | 33 | struct ObjectRenderInfo 34 | { 35 | RenderConstructor constructor; 36 | RenderDestuctor destructor; 37 | VNodeRender *renderer; 38 | bool active; 39 | }; 40 | std::map _renders; 41 | }; 42 | 43 | VK_END_NAMESPACE 44 | #endif -------------------------------------------------------------------------------- /inc/VKernel/VSmoothOp.h: -------------------------------------------------------------------------------- 1 | #ifndef VKERNEL_BM_SMOOTH_H 2 | #define VKERNEL_BM_SMOOTH_H 3 | #include "BMesh/BMesh.h" 4 | #include "VKernel/VScene.h" 5 | #include "VKernel/VMeshObject.h" 6 | 7 | using namespace VM; 8 | class VSmoothOp 9 | { 10 | enum LaplaceWeighting 11 | { 12 | UNIFORM_WEIGHT, 13 | COTAGANT_WEIGHT 14 | }; 15 | enum VFlag 16 | { 17 | V_BOUNDARY = 1 << 0 18 | }; 19 | public: 20 | VSmoothOp(VM::BMesh *bm); 21 | ~VSmoothOp(); 22 | void run(); 23 | void setIteration(size_t iter); 24 | void setLambda(float lambda); 25 | private: 26 | void mark_locked_vert(); 27 | void smooth(); 28 | void compute_weight(); 29 | float compute_edge_weight(BMEdge *e); 30 | private: 31 | BMesh *_bm; 32 | LaplaceWeighting _wtype; 33 | size_t _iteration; 34 | float _lambda; 35 | size_t _totedge; 36 | size_t _totvert; 37 | std::vector _vlocked; 38 | std::vector _eweight; 39 | std::vector _vweight; 40 | }; 41 | #endif -------------------------------------------------------------------------------- /inc/VKernel/VTextureLoader.h: -------------------------------------------------------------------------------- 1 | #ifndef VKERNEL_VTEXTURE_LOADER_H 2 | #define VKERNEL_VTEXTURE_LOADER_H 3 | #include 4 | #include "VKernelCommon.h" 5 | VK_BEGIN_NAMESPACE 6 | class VTextureLoader 7 | { 8 | public: 9 | static gte::Texture2* load(std::string const& filename); 10 | }; 11 | VK_END_NAMESPACE 12 | #endif -------------------------------------------------------------------------------- /inc/VbsQt/VbsDef.h: -------------------------------------------------------------------------------- 1 | #ifndef VSCULPT_VBS_DEF_H 2 | #define VSCULPT_VBS_DEF_H 3 | #include 4 | 5 | class VbsDef : public QObject { 6 | public: 7 | Q_OBJECT 8 | public: 9 | enum BRUSH 10 | { 11 | BRUSH_INFLATE = 0, 12 | BRUSH_SNAKE_HOOK, 13 | BRUSH_CREASE, 14 | BRUSH_FLATTEN , 15 | BRUSH_NUDGET , 16 | BRUSH_CLAY_STRIP , 17 | BRUSH_CLAY , 18 | BRUSH_FILL , 19 | BRUSH_ROTATE, 20 | BRUSH_DRAW, 21 | BRUSH_SMOOTH , 22 | BRUSH_GRAB, 23 | BRUSH_THUMB, 24 | BRUSH_PINCH, 25 | BRUSH_TOTAL 26 | }; 27 | Q_ENUMS(BRUSH); 28 | 29 | enum CURVE 30 | { 31 | CURVE_SHARP, 32 | CURVE_SMOOTH, 33 | CURVE_ROUND, 34 | CURVE_ROOT, 35 | CURVE_TOTAL 36 | }; 37 | Q_ENUMS(CURVE); 38 | 39 | enum MANIPULATOR_AXIS 40 | { 41 | MANIPULATOR_AXIS_0 = 1 << 0, 42 | MANIPULATOR_AXIS_1 = 1 << 1, 43 | MANIPULATOR_AXIS_2 = 1 << 2, 44 | MANIPULATOR_AXIS_FULL = MANIPULATOR_AXIS_0 | MANIPULATOR_AXIS_1 | MANIPULATOR_AXIS_2, 45 | MANIPULATOR_AXIS_NONE = 1 << 3 46 | }; 47 | Q_ENUMS(MANIPULATOR_AXIS); 48 | 49 | enum MANIPULATOR_MODE 50 | { 51 | MANIPULATOR_SCALE, 52 | MANIPULATOR_ROTATE, 53 | MANIPULATOR_TRANSLATE, 54 | MANIPULATOR_NONE 55 | }; 56 | Q_ENUMS(MANIPULATOR_MODE); 57 | 58 | enum RENDER_MODE 59 | { 60 | RENDER_SHADING, 61 | RENDER_WIREFRAME 62 | }; 63 | Q_ENUMS(RENDER_MODE); 64 | 65 | enum BOOLEAN_TYPE 66 | { 67 | BOOLEAN_UNION, 68 | BOOLEAN_DIFFERENCE, 69 | BOOLEAN_INTERSECTION, 70 | BOOLEAN_NONE 71 | }; 72 | Q_ENUMS(BOOLEAN_TYPE); 73 | 74 | }; 75 | #endif -------------------------------------------------------------------------------- /inc/render/GTEnginePCH.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.1 (2016/01/30) 7 | 8 | // NOTE: If you add GTE_DISABLE_PCH to the GTEngine project's C++ 9 | // preprocessor definitions, you must also disable the precompiled 10 | // header system in the project settings. Do so by modifying the 11 | // precompiled headers option from "Use (/Yu)" to "Not Using 12 | // Precompiled Headers". 13 | #include 14 | #include 15 | #ifndef GTE_DISABLE_PCH 16 | //#include 17 | #endif 18 | 19 | 20 | -------------------------------------------------------------------------------- /inc/render/Graphics/GL4/GteGL4Buffer.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP GL4Buffer : public GL4Resource 17 | { 18 | protected: 19 | // Abstract base class. 20 | GL4Buffer(Buffer const* buffer, GLenum type); 21 | virtual ~GL4Buffer(); 22 | 23 | // Must be called by constructor. 24 | virtual void Initialize(); 25 | 26 | public: 27 | // Member access. 28 | inline Buffer* GetBuffer() const; 29 | inline GLenum GetType() const; 30 | inline GLenum GetUsage() const; 31 | 32 | // TODO: TENTATIVE INTERFACE (modify as needed). Do we really need 33 | // these to be virtual? Revisit the DX11 code and investigate why the 34 | // choice was made there. 35 | virtual bool Update(); 36 | virtual bool CopyCpuToGpu(); 37 | virtual bool CopyGpuToCpu(); 38 | 39 | protected: 40 | GLenum mType; 41 | GLenum mUsage; 42 | }; 43 | 44 | inline Buffer* GL4Buffer::GetBuffer() const 45 | { 46 | return static_cast(mGTObject); 47 | } 48 | 49 | inline GLenum GL4Buffer::GetType() const 50 | { 51 | return mType; 52 | } 53 | 54 | inline GLenum GL4Buffer::GetUsage() const 55 | { 56 | return mUsage; 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /inc/render/Graphics/GL4/GteGL4ConstantBuffer.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP GL4ConstantBuffer : public GL4Buffer 17 | { 18 | public: 19 | // Construction. 20 | GL4ConstantBuffer(ConstantBuffer const* cbuffer); 21 | 22 | static GEObject* Create(void* unused, GraphicsObject const* object); 23 | 24 | // Member access. 25 | inline ConstantBuffer* GetConstantBuffer() const; 26 | 27 | // Bind the constant buffer data to the specified uniform buffer unit. 28 | void AttachToUnit(GLint uniformBufferUnit); 29 | }; 30 | 31 | inline ConstantBuffer* GL4ConstantBuffer::GetConstantBuffer() const 32 | { 33 | return static_cast(mGTObject); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /inc/render/Graphics/GL4/GteGL4DepthStencilState.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP GL4DepthStencilState : public GL4DrawingState 17 | { 18 | public: 19 | // Construction. 20 | GL4DepthStencilState(DepthStencilState const* depthStencilState); 21 | static GEObject* Create(void* unused, GraphicsObject const* object); 22 | 23 | // Member access. 24 | inline DepthStencilState* GetDepthStencilState(); 25 | 26 | // Enable the depth-stencil state. 27 | void Enable(HGLRC context); 28 | 29 | private: 30 | struct Face 31 | { 32 | GLenum onFail; 33 | GLenum onZFail; 34 | GLenum onZPass; 35 | GLenum comparison; 36 | }; 37 | 38 | GLboolean mDepthEnable; 39 | GLboolean mWriteMask; 40 | GLenum mComparison; 41 | GLboolean mStencilEnable; 42 | GLuint mStencilReadMask; 43 | GLuint mStencilWriteMask; 44 | Face mFrontFace; 45 | Face mBackFace; 46 | GLuint mReference; 47 | 48 | // Conversions from GTEngine values to GL4 values. 49 | static GLboolean const msWriteMask[]; 50 | static GLenum const msComparison[]; 51 | static GLenum const msOperation[]; 52 | }; 53 | 54 | inline DepthStencilState* GL4DepthStencilState::GetDepthStencilState() 55 | { 56 | return static_cast(mGTObject); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /inc/render/Graphics/GL4/GteGL4DrawTarget.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | namespace gte 15 | { 16 | 17 | class GTE_IMPEXP GL4DrawTarget : public GEDrawTarget 18 | { 19 | public: 20 | // Construction and destruction. 21 | virtual ~GL4DrawTarget(); 22 | GL4DrawTarget(DrawTarget const* target, 23 | std::vector& rtTextures, GL4TextureDS* dsTexture); 24 | static GEDrawTarget* Create(DrawTarget const* target, 25 | std::vector& rtTextures, GEObject* dsTexture); 26 | 27 | // Member access. 28 | inline GL4TextureRT* GetRTTexture(unsigned int i) const 29 | { 30 | return mRTTextures[i]; 31 | } 32 | 33 | inline GL4TextureDS* GetDSTexture() const 34 | { 35 | return mDSTexture; 36 | } 37 | 38 | // Used in the Renderer::Draw function. 39 | void Enable(); 40 | void Disable(); 41 | GLuint GetFrameBuffer() const { return mFrameBuffer; } 42 | private: 43 | std::vector mRTTextures; 44 | GL4TextureDS* mDSTexture; 45 | 46 | GLuint mFrameBuffer; 47 | 48 | // Temporary storage during enable/disable of targets. 49 | GLint mSaveViewportX; 50 | GLint mSaveViewportY; 51 | GLsizei mSaveViewportWidth; 52 | GLsizei mSaveViewportHeight; 53 | GLfloat mSaveViewportNear; 54 | GLfloat mSaveViewportFar; 55 | }; 56 | } 57 | -------------------------------------------------------------------------------- /inc/render/Graphics/GL4/GteGL4DrawingState.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP GL4DrawingState : public GL4GraphicsObject 17 | { 18 | protected: 19 | // Abstract base class. 20 | GL4DrawingState(DrawingState const* gtState); 21 | }; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /inc/render/Graphics/GL4/GteGL4GraphicsObject.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP GL4GraphicsObject : public GEObject 17 | { 18 | protected: 19 | // Abstract base class. 20 | GL4GraphicsObject(GraphicsObject const* gtObject); 21 | 22 | public: 23 | // Member access. 24 | inline GLuint GetGLHandle() const; 25 | 26 | // Support for debugging. 27 | virtual void SetName(std::string const& name) override; 28 | 29 | protected: 30 | GLuint mGLHandle; 31 | }; 32 | 33 | inline GLuint GL4GraphicsObject::GetGLHandle() const 34 | { 35 | return mGLHandle; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /inc/render/Graphics/GL4/GteGL4IndexBuffer.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP GL4IndexBuffer : public GL4Buffer 17 | { 18 | public: 19 | // Construction and destruction. 20 | GL4IndexBuffer(IndexBuffer const* ibuffer); 21 | static GEObject* Create(void* unused, GraphicsObject const* object); 22 | 23 | // Member access. 24 | inline IndexBuffer* GetIndexBuffer() const; 25 | 26 | // Support for drawing geometric primitives. 27 | void Enable(); 28 | void Disable(); 29 | }; 30 | 31 | inline IndexBuffer* GL4IndexBuffer::GetIndexBuffer() const 32 | { 33 | return static_cast(mGTObject); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /inc/render/Graphics/GL4/GteGL4InputLayout.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP GL4InputLayout 17 | { 18 | public: 19 | // Construction and destruction. 20 | ~GL4InputLayout(); 21 | GL4InputLayout(GLuint programHandle, GLuint vbufferHandle, 22 | VertexBuffer const* vbuffer); 23 | 24 | // Support for drawing geometric primitives. 25 | void Enable(); 26 | void Disable(); 27 | 28 | private: 29 | GLuint mProgramHandle; 30 | GLuint mVBufferHandle; 31 | GLuint mVArrayHandle; 32 | 33 | struct Attribute 34 | { 35 | VASemantic semantic; 36 | GLint numChannels; 37 | GLint channelType; 38 | GLboolean normalize; 39 | GLint location; 40 | GLintptr offset; 41 | GLsizei stride; 42 | }; 43 | 44 | int mNumAttributes; 45 | Attribute mAttributes[VA_MAX_ATTRIBUTES]; 46 | 47 | // Conversions from GTEngine values to GL4 values. 48 | static GLenum const msChannelType[]; 49 | }; 50 | 51 | } 52 | -------------------------------------------------------------------------------- /inc/render/Graphics/GL4/GteGL4RasterizerState.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP GL4RasterizerState : public GL4DrawingState 17 | { 18 | public: 19 | // Construction. 20 | GL4RasterizerState(RasterizerState const* rasterizerState); 21 | static GEObject* Create(void* unused, GraphicsObject const* object); 22 | 23 | // Member access. 24 | inline RasterizerState* GetRasterizerState(); 25 | 26 | // Enable the rasterizer state. 27 | void Enable(HGLRC context); 28 | 29 | private: 30 | GLenum mFillMode; 31 | GLenum mCullFace; 32 | GLenum mFrontFace; 33 | float mDepthScale; 34 | float mDepthBias; 35 | GLboolean mEnableScissor; 36 | 37 | // TODO: D3D11_RASTERIZER_DESC has the following. We need to determine 38 | // how to handle these in OpenGL. 39 | // DepthBiasClamp 40 | // DepthClipEnable 41 | // MultisampleEnable 42 | // AntialiasedLineEnable 43 | 44 | // Conversions from GTEngine values to GL4 values. 45 | static GLenum const msFillMode[]; 46 | static GLenum const msCullFace[]; 47 | }; 48 | 49 | inline RasterizerState* GL4RasterizerState::GetRasterizerState() 50 | { 51 | return static_cast(mGTObject); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /inc/render/Graphics/GL4/GteGL4Resource.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP GL4Resource : public GL4GraphicsObject 17 | { 18 | protected: 19 | // Abstract base class. 20 | GL4Resource(Resource const* gtResource); 21 | 22 | public: 23 | // Member access. 24 | inline Resource* GetResource() const; 25 | 26 | // TODO: TENTATIVE INTERFACE (modify as needed). Make these pure 27 | // virtual latter (if relevant). 28 | void* MapForWrite(GLenum target, const GLintptr offset, const GLsizeiptr len); 29 | void Unmap(GLenum target); 30 | virtual bool Update() { return false; } 31 | virtual bool CopyCpuToGpu() { return false; } 32 | virtual bool CopyGpuToCpu() { return false; } 33 | 34 | protected: 35 | // Support for copying between CPU and GPU. 36 | bool PreparedForCopy(GLenum access) const; 37 | }; 38 | 39 | inline Resource* GL4Resource::GetResource() const 40 | { 41 | return static_cast(mGTObject); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /inc/render/Graphics/GL4/GteGL4SamplerState.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP GL4SamplerState : public GL4DrawingState 17 | { 18 | public: 19 | // Construction and destruction. 20 | virtual ~GL4SamplerState(); 21 | GL4SamplerState(SamplerState const* samplerState); 22 | static GEObject* Create(void* unused, GraphicsObject const* object); 23 | 24 | // Member access. 25 | inline SamplerState* GetSamplerState(); 26 | 27 | private: 28 | // Conversions from GTEngine values to GL4 values. 29 | static GLint const msMode[]; 30 | }; 31 | 32 | inline SamplerState* GL4SamplerState::GetSamplerState() 33 | { 34 | return static_cast(mGTObject); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /inc/render/Graphics/GL4/GteGL4Texture2.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP GL4Texture2 : public GL4TextureSingle 17 | { 18 | public: 19 | // Construction and destruction. 20 | virtual ~GL4Texture2(); 21 | GL4Texture2(Texture2 const* texture); 22 | static GEObject* Create(void* unused, GraphicsObject const* object); 23 | 24 | // Member access. 25 | inline Texture2* GetTexture() const; 26 | 27 | // Returns true if mipmaps need to be generated. 28 | virtual bool CanAutoGenerateMipmaps() const override; 29 | 30 | protected: 31 | virtual void LoadTextureLevel(unsigned int level, void const* data) override; 32 | }; 33 | 34 | inline Texture2* GL4Texture2::GetTexture() const 35 | { 36 | return static_cast(mGTObject); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /inc/render/Graphics/GL4/GteGL4Texture3.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP GL4Texture3 : public GL4TextureSingle 17 | { 18 | public: 19 | // Construction and destruction. 20 | virtual ~GL4Texture3(); 21 | GL4Texture3(Texture3 const* texture); 22 | static GEObject* Create(void* unused, GraphicsObject const* object); 23 | 24 | // Member access. 25 | inline Texture3* GetTexture() const; 26 | 27 | // Returns true if mipmaps need to be generated. 28 | virtual bool CanAutoGenerateMipmaps() const override; 29 | 30 | protected: 31 | virtual void LoadTextureLevel(unsigned int level, void const* data) override; 32 | }; 33 | 34 | inline Texture3* GL4Texture3::GetTexture() const 35 | { 36 | return static_cast(mGTObject); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /inc/render/Graphics/GL4/GteGL4TextureCube.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP GL4TextureCube : public GL4TextureArray 17 | { 18 | public: 19 | // Construction and destruction. 20 | virtual ~GL4TextureCube(); 21 | GL4TextureCube(TextureCube const* textureArray); 22 | static GEObject* Create(void* unused, GraphicsObject const* object); 23 | 24 | // Member access. 25 | inline TextureCube* GetTexture() const; 26 | 27 | // Returns true if mipmaps need to be generated. 28 | virtual bool CanAutoGenerateMipmaps() const override; 29 | 30 | protected: 31 | virtual void LoadTextureLevel(unsigned int item, unsigned int level, void const* data) override; 32 | }; 33 | 34 | inline TextureCube* GL4TextureCube::GetTexture() const 35 | { 36 | return static_cast(mGTObject); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /inc/render/Graphics/GL4/GteGL4TextureDS.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP GL4TextureDS : public GL4Texture2 17 | { 18 | public: 19 | // Construction. 20 | GL4TextureDS(TextureDS const* texture); 21 | static GEObject* Create(void* unused, GraphicsObject const* object); 22 | 23 | // Member access. 24 | inline TextureDS* GetTexture() const 25 | { 26 | return static_cast(mGTObject); 27 | } 28 | 29 | // Returns true of mipmaps need to be generated. 30 | virtual bool CanAutoGenerateMipmaps() const override; 31 | 32 | private: 33 | }; 34 | } 35 | -------------------------------------------------------------------------------- /inc/render/Graphics/GL4/GteGL4TextureRT.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP GL4TextureRT : public GL4Texture2 17 | { 18 | public: 19 | // Construction. 20 | GL4TextureRT(TextureRT const* texture); 21 | static GEObject* Create(void* unused, GraphicsObject const* object); 22 | 23 | // Member access. 24 | inline TextureRT* GetTexture() const 25 | { 26 | return static_cast(mGTObject); 27 | } 28 | 29 | // Returns true of mipmaps need to be generated. 30 | virtual bool CanAutoGenerateMipmaps() const override; 31 | }; 32 | } 33 | -------------------------------------------------------------------------------- /inc/render/Graphics/GL4/GteGL4VertexBuffer.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP GL4VertexBuffer : public GL4Buffer 17 | { 18 | public: 19 | // Construction and destruction. 20 | GL4VertexBuffer(VertexBuffer const* vbuffer); 21 | static GEObject* Create(void* unused, GraphicsObject const* object); 22 | 23 | // Member access. 24 | inline VertexBuffer* GetVertexBuffer() const; 25 | 26 | // TODO: Drawing support? Currently, the enable/disable is in the 27 | // GL4InputLayout class, which assumes OpenGL 4.3 or later. What if the 28 | // application machine does not have OpenGL 4.3? Fall back to the 29 | // glBindBuffer paradigm? 30 | }; 31 | 32 | inline VertexBuffer* GL4VertexBuffer::GetVertexBuffer() const 33 | { 34 | return static_cast(mGTObject); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /inc/render/Graphics/GL4/GteGLFunction.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | namespace gte 5 | { 6 | class GL4Engine; 7 | 8 | class GL : public QOpenGLExtraFunctions 9 | { 10 | public: 11 | static bool initialized(); 12 | static void initialize(QOpenGLContext *context); 13 | 14 | static __forceinline QOpenGLExtraFunctions& function() 15 | { 16 | return *_instance; 17 | } 18 | 19 | static __forceinline GL4Engine* engine() 20 | { 21 | return _engine; 22 | } 23 | 24 | private: 25 | static QOpenGLExtraFunctions *_instance; 26 | static GL4Engine *_engine; 27 | }; 28 | } -------------------------------------------------------------------------------- /inc/render/Graphics/GL4/GteGLSLComputeProgram.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP GLSLComputeProgram : public ComputeProgram 17 | { 18 | public: 19 | // Construction and destruction. 20 | virtual ~GLSLComputeProgram(); 21 | GLSLComputeProgram(GLuint programHandle, GLuint cshaderHandle); 22 | 23 | // Member access. GLEngine needs the program handle for enabling and 24 | // disabling the program. TODO: Do we need the GetCShaderHandle 25 | // function? 26 | inline GLuint GetProgramHandle() const; 27 | inline GLuint GetCShaderHandle() const; 28 | inline GLSLReflection const& GetReflector() const; 29 | 30 | private: 31 | GLuint mProgramHandle, mCShaderHandle; 32 | GLSLReflection mReflector; 33 | }; 34 | 35 | inline GLuint GLSLComputeProgram::GetProgramHandle() const 36 | { 37 | return mProgramHandle; 38 | } 39 | 40 | inline GLuint GLSLComputeProgram::GetCShaderHandle() const 41 | { 42 | return mCShaderHandle; 43 | } 44 | 45 | inline GLSLReflection const& GLSLComputeProgram::GetReflector() const 46 | { 47 | return mReflector; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /inc/render/Graphics/GL4/GteOpenGLHelper.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | //#include 11 | -------------------------------------------------------------------------------- /inc/render/Graphics/GteAmbientLightEffect.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP AmbientLightEffect : public LightingEffect 17 | { 18 | public: 19 | // Construction. 20 | AmbientLightEffect(ProgramFactory& factory, BufferUpdater const& updater, 21 | std::shared_ptr const& material, 22 | std::shared_ptr const& lighting); 23 | 24 | // After you set or modify 'material' or 'lighting', call the update to 25 | // inform any listener that the corresponding constant buffer has changed. 26 | virtual void UpdateMaterialConstant(); 27 | virtual void UpdateLightingConstant(); 28 | 29 | private: 30 | struct InternalMaterial 31 | { 32 | EVector4 emissive; 33 | EVector4 ambient; 34 | }; 35 | 36 | struct InternalLighting 37 | { 38 | EVector4 ambient; 39 | EVector4 attenuation; 40 | }; 41 | 42 | // Shader source code as strings. 43 | static std::string const msGLSLVSSource; 44 | static std::string const msGLSLPSSource; 45 | static std::string const msHLSLSource; 46 | static std::string const* msVSSource[ProgramFactory::PF_NUM_API]; 47 | static std::string const* msPSSource[ProgramFactory::PF_NUM_API]; 48 | }; 49 | 50 | } 51 | -------------------------------------------------------------------------------- /inc/render/Graphics/GteBuffer.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP Buffer : public Resource 17 | { 18 | protected: 19 | // Abstract base class. 20 | Buffer(unsigned int numElements, size_t elementSize, 21 | bool createStorage = true); 22 | }; 23 | 24 | typedef std::function const&)> BufferUpdater; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /inc/render/Graphics/GteComputeProgram.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP ComputeProgram 16 | { 17 | public: 18 | // HLSL uses the class as is. GLSL derives from the class to store 19 | // the shader and program handles. 20 | virtual ~ComputeProgram(); 21 | ComputeProgram(); 22 | 23 | // Member access. 24 | inline std::shared_ptr const& GetCShader() const; 25 | 26 | public: 27 | // INTERNAL USE ONLY. This is used during factory creation of shaders 28 | // and programs. The graphics engines need only const-access to the 29 | // shader objects. 30 | inline void SetCShader(std::shared_ptr const& shader); 31 | 32 | private: 33 | std::shared_ptr mCShader; 34 | }; 35 | 36 | 37 | inline std::shared_ptr const& ComputeProgram::GetCShader() 38 | const 39 | { 40 | return mCShader; 41 | } 42 | 43 | inline void ComputeProgram::SetCShader( 44 | std::shared_ptr const& shader) 45 | { 46 | mCShader = shader; 47 | } 48 | 49 | 50 | } 51 | -------------------------------------------------------------------------------- /inc/render/Graphics/GteComputeShader.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP ComputeShader : public Shader 17 | { 18 | public: 19 | // Construction. 20 | ComputeShader(GLSLReflection const& reflector); 21 | }; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /inc/render/Graphics/GteDrawingState.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP DrawingState : public GraphicsObject 16 | { 17 | protected: 18 | // Abstract base class for grouping state classes. This supports 19 | // simplification and reduction of member functions in the graphics engine 20 | // code. 21 | DrawingState(); 22 | }; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /inc/render/Graphics/GteFontArialW400H18.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP FontArialW400H18 : public Font 16 | { 17 | public: 18 | // Construction. This is an embedded font that is generated by the 19 | // BitmapFontCreator tool. 20 | FontArialW400H18(ProgramFactory& factory, int maxMessageLength); 21 | 22 | private: 23 | static int msWidth; 24 | static int msHeight; 25 | static unsigned char msTexels[]; 26 | static float msCharacterData[]; 27 | }; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /inc/render/Graphics/GteGEDrawTarget.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP GEDrawTarget 16 | { 17 | public: 18 | // Abstract base class. 19 | virtual ~GEDrawTarget(); 20 | protected: 21 | GEDrawTarget(DrawTarget const* gtTarget); 22 | 23 | public: 24 | // Member access. 25 | inline DrawTarget* GetDrawTarget() const; 26 | 27 | protected: 28 | DrawTarget* mTarget; 29 | }; 30 | 31 | inline DrawTarget* GEDrawTarget::GetDrawTarget() const 32 | { 33 | return mTarget; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /inc/render/Graphics/GteGEInputLayoutManager.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class Shader; 16 | class VertexBuffer; 17 | 18 | class GTE_IMPEXP GEInputLayoutManager 19 | { 20 | public: 21 | // Abstract base interface. 22 | virtual ~GEInputLayoutManager() {} 23 | GEInputLayoutManager() {} 24 | 25 | virtual bool Unbind(VertexBuffer const* vbuffer) = 0; 26 | virtual bool Unbind(Shader const* vshader) = 0; 27 | virtual void UnbindAll() = 0; 28 | virtual bool HasElements() const = 0; 29 | }; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /inc/render/Graphics/GteGEObject.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP GEObject 16 | { 17 | public: 18 | // Abstract base class. 19 | virtual ~GEObject(); 20 | protected: 21 | GEObject(GraphicsObject const* gtObject); 22 | 23 | public: 24 | // Member access. 25 | inline GraphicsObject* GetGraphicsObject() const; 26 | 27 | // Support for debugging. 28 | virtual void SetName(std::string const& name) = 0; 29 | inline std::string const& GetName() const; 30 | 31 | protected: 32 | GraphicsObject* mGTObject; 33 | std::string mName; 34 | }; 35 | 36 | inline GraphicsObject* GEObject::GetGraphicsObject() const 37 | { 38 | return mGTObject; 39 | } 40 | 41 | inline std::string const& GEObject::GetName() const 42 | { 43 | return mName; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /inc/render/Graphics/GteGeometryShader.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP GeometryShader : public Shader 16 | { 17 | public: 18 | // Construction. 19 | GeometryShader(GLSLReflection const& reflector); 20 | }; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /inc/render/Graphics/GteIndexFormat.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | // Types of primitives supported by index buffers. 16 | enum GTE_IMPEXP IPType 17 | { 18 | IP_NONE = 0xFFFFFFFF, 19 | IP_POLYPOINT = 0x00000001, 20 | IP_POLYSEGMENT_DISJOINT = 0x00000002, 21 | IP_POLYSEGMENT_CONTIGUOUS = 0x00000004, 22 | IP_TRIMESH = 0x00000008, 23 | IP_TRISTRIP = 0x00000010, 24 | 25 | IP_HAS_POINTS = IP_POLYPOINT, 26 | IP_HAS_SEGMENTS = IP_POLYSEGMENT_DISJOINT | IP_POLYSEGMENT_CONTIGUOUS, 27 | IP_HAS_TRIANGLES = IP_TRIMESH | IP_TRISTRIP, 28 | 29 | IP_NUM_TYPES = 5 // IP_POLYPOINT through IP_TRISTRIP 30 | }; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /inc/render/Graphics/GteIndirectArgumentsBuffer.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP IndirectArgumentsBuffer : public Buffer 16 | { 17 | public: 18 | // Construction. Each element is a 4-byte value. For storing a 19 | // single set of input parameters to a draw call, the layout of 20 | // the buffer should be as shown next. The parameters are in the 21 | // order expected by the Draw* call without the 'Indirect' suffix. 22 | // 23 | // DrawInstancedIndirect: 24 | // UINT VertexCountPerInstance; 25 | // UINT InstanceCount; 26 | // UINT StartVertexLocation; 27 | // UINT StartInstanceLocation; 28 | // 29 | // DrawIndexedInstancedIndirect: 30 | // UINT IndexCountPerInstance; 31 | // UINT InstanceCount; 32 | // UINT StartIndexLocation; 33 | // INT BaseVertexLocation; 34 | // UINT StartInstanceLocation; 35 | // 36 | // DispatchIndirect: 37 | // UINT ThreadsGroupCountX; 38 | // UINT ThreadsGroupCountY; 39 | // UINT ThreadsGroupCountZ; 40 | 41 | IndirectArgumentsBuffer(unsigned int numElements, 42 | bool createStorage = true); 43 | }; 44 | 45 | } 46 | -------------------------------------------------------------------------------- /inc/render/Graphics/GteLightCameraGeometry.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | #include 10 | 11 | namespace gte 12 | { 13 | 14 | struct GTE_IMPEXP LightCameraGeometry 15 | { 16 | // Construction. 17 | LightCameraGeometry(); 18 | 19 | EVector4 lightModelPosition; // default: (0,0,0,1) 20 | EVector4 lightModelDirection; // default: (0,0,-1,0) 21 | EVector4 lightModelUp; // default: (0,1,0,0) 22 | EVector4 lightModelRight; // default: (1,0,0,0) 23 | 24 | EVector4 cameraModelPosition; // default: (0,0,0,1) 25 | EVector4 cameraModelDirection; // default: (0,0,-1,0) 26 | EVector4 cameraModelUp; // default: (0,1,0,0) 27 | EVector4 cameraModelRight; // default: (1,0,0,0) 28 | }; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /inc/render/Graphics/GteLighting.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | #include 10 | #include 11 | namespace gte 12 | { 13 | 14 | struct GTE_IMPEXP Lighting 15 | { 16 | 17 | // Construction. The defaults are listed for each member. The '*' 18 | // channels are not used but are included to match shader-constant 19 | // packing rules. 20 | Lighting(); 21 | 22 | // (r,g,b,*): default (1,1,1,1) 23 | EVector4 ambient; 24 | 25 | // (r,g,b,*): default (1,1,1,1) 26 | EVector4 diffuse; 27 | 28 | // (r,g,b,*): default (1,1,1,1) 29 | EVector4 specular; 30 | 31 | // (angle,cosAngle,sinAngle,exponent): default (pi/2,0,1,1) 32 | EVector4 spotCutoff; 33 | 34 | // Attenuation is: intensity/(constant + linear * (d + quadratic * d) 35 | // where d is the distance from the light position to the vertex position. 36 | // The distance is in model space. If the transformation from model space 37 | // to world space involves uniform scaling, you can include the scaling 38 | // factor in the 'intensity' component (by multiplication). 39 | // 40 | // (constant,linear,quadratic,intensity): default (1,0,0,1) 41 | EVector4 attenuation; 42 | }; 43 | 44 | } 45 | -------------------------------------------------------------------------------- /inc/render/Graphics/GteMaterial.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | #include 10 | namespace gte 11 | { 12 | 13 | class GTE_IMPEXP Material 14 | { 15 | public: 16 | // Construction. 17 | Material(); 18 | 19 | // (r,g,b,*): default (0,0,0,1) 20 | EVector4 emissive; 21 | 22 | // (r,g,b,*): default (0,0,0,1) 23 | EVector4 ambient; 24 | 25 | // (r,g,b,a): default (0,0,0,1) 26 | EVector4 diffuse; 27 | 28 | // (r,g,b,specularPower): default (0,0,0,1) 29 | EVector4 specular; 30 | }; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /inc/render/Graphics/GteMemberLayout.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | namespace gte 15 | { 16 | 17 | // Support for generation of lookup tables for constant buffers and texture 18 | // buffers. Given the name of a member of a buffer, get the offset into the 19 | // buffer memory where the member lives. The layout is specific to the 20 | // shading language (HLSL, GLSL). 21 | struct GTE_IMPEXP MemberLayout 22 | { 23 | std::string name; 24 | unsigned int offset; 25 | unsigned int numElements; 26 | }; 27 | 28 | typedef std::vector BufferLayout; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /inc/render/Graphics/GtePixelShader.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP PixelShader : public Shader 16 | { 17 | public: 18 | // Construction. 19 | PixelShader(GLSLReflection const& reflector); 20 | }; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /inc/render/Graphics/GteRasterizerState.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP RasterizerState : public DrawingState 16 | { 17 | public: 18 | enum GTE_IMPEXP FillMode 19 | { 20 | FILL_SOLID, 21 | FILL_WIREFRAME 22 | }; 23 | 24 | enum GTE_IMPEXP CullMode 25 | { 26 | CULL_NONE, 27 | CULL_FRONT, 28 | CULL_BACK 29 | }; 30 | 31 | // Construction. 32 | RasterizerState(); 33 | 34 | // Member access. The members are intended to be write-once before 35 | // you create an associated graphics state. 36 | FillMode fillMode; // default: FILL_SOLID 37 | CullMode cullMode; // default: CULL_BACK 38 | bool frontCCW; // default: true 39 | int depthBias; // default: 0 40 | float depthBiasClamp; // default: 0 41 | float slopeScaledDepthBias; // default: 0 42 | bool enableDepthClip; // default: true 43 | bool enableScissor; // default: false 44 | bool enableMultisample; // default: false 45 | bool enableAntialiasedLine; // default: false 46 | }; 47 | 48 | } 49 | -------------------------------------------------------------------------------- /inc/render/Graphics/GteRawBuffer.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP RawBuffer : public Buffer 16 | { 17 | public: 18 | // Construction. The element size is always 4 bytes. 19 | RawBuffer(unsigned int numElements, bool createStorage = true); 20 | 21 | public: 22 | // For use by the Shader class for storing reflection information. 23 | static int const shaderDataLookup = 3; 24 | }; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /inc/render/Graphics/GteTextEffect.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | namespace gte 18 | { 19 | 20 | class GTE_IMPEXP TextEffect : public VisualEffect 21 | { 22 | public: 23 | // Construction. 24 | TextEffect(ProgramFactory& factory, 25 | std::shared_ptr const& texture); 26 | 27 | // Support for typesetting. 28 | std::shared_ptr const& GetTranslate() const; 29 | std::shared_ptr const& GetColor() const; 30 | void SetTranslate(float x, float y); 31 | void SetColor(EVector4 const& color); 32 | 33 | private: 34 | std::shared_ptr mTranslate; 35 | std::shared_ptr mColor; 36 | std::shared_ptr mSamplerState; 37 | 38 | // Shader source code as strings. 39 | static std::string const msGLSLVSSource; 40 | static std::string const msGLSLPSSource; 41 | static std::string const msHLSLSource; 42 | static std::string const* msVSSource[ProgramFactory::PF_NUM_API]; 43 | static std::string const* msPSSource[ProgramFactory::PF_NUM_API]; 44 | }; 45 | 46 | } 47 | -------------------------------------------------------------------------------- /inc/render/Graphics/GteTexture1.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP Texture1 : public TextureSingle 16 | { 17 | public: 18 | // Construction. 19 | Texture1(DFType format, unsigned int length, bool hasMipmaps = false, 20 | bool createStorage = true); 21 | 22 | // Texture dimensions. 23 | unsigned int GetLength() const; 24 | }; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /inc/render/Graphics/GteTexture1Array.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP Texture1Array : public TextureArray 16 | { 17 | public: 18 | // Construction. 19 | Texture1Array(unsigned int numItems, DFType format, unsigned int length, 20 | bool hasMipmaps = false, bool createStorage = true); 21 | 22 | // Texture dimensions. 23 | unsigned int GetLength() const; 24 | }; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /inc/render/Graphics/GteTexture2.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP Texture2 : public TextureSingle 16 | { 17 | public: 18 | // Construction. 19 | Texture2(DFType format, unsigned int width, unsigned int height, 20 | bool hasMipmaps = false, bool createStorage = true); 21 | 22 | // Texture dimensions. 23 | unsigned int GetWidth() const; 24 | unsigned int GetHeight() const; 25 | 26 | // If you intend to share this texture among DX11Engine objects, call this 27 | // function before binding the texture to the engine. The Texture2 usage 28 | // must be Resource::GPU_RW. 29 | void MakeShared(); 30 | bool IsShared() const; 31 | 32 | protected: 33 | bool mShared; 34 | }; 35 | 36 | } 37 | -------------------------------------------------------------------------------- /inc/render/Graphics/GteTexture2Array.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP Texture2Array : public TextureArray 16 | { 17 | public: 18 | // Construction. 19 | Texture2Array(unsigned int numItems, DFType format, unsigned int width, 20 | unsigned int height, bool hasMipmaps = false, 21 | bool createStorage = true); 22 | 23 | // Texture dimensions. 24 | unsigned int GetWidth() const; 25 | unsigned int GetHeight() const; 26 | }; 27 | 28 | } 29 | -------------------------------------------------------------------------------- /inc/render/Graphics/GteTexture3.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP Texture3 : public TextureSingle 16 | { 17 | public: 18 | // Construction. 19 | Texture3(DFType format, unsigned int width, unsigned int height, 20 | unsigned int thickness, bool hasMipmaps = false, 21 | bool createStorage = true); 22 | 23 | // Texture dimensions. 24 | unsigned int GetWidth() const; 25 | unsigned int GetHeight() const; 26 | unsigned int GetThickness() const; 27 | }; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /inc/render/Graphics/GteTextureCube.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP TextureCube : public TextureArray 16 | { 17 | public: 18 | // Construction. Cube maps must be square; the 'length' parameter is the 19 | // shared value for width and height. 20 | TextureCube(DFType format, unsigned int length, bool hasMipmaps = false, 21 | bool createStorage = true); 22 | 23 | // The texture width and height are the same value. 24 | unsigned int GetLength() const; 25 | }; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /inc/render/Graphics/GteTextureDS.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP TextureDS : public Texture2 16 | { 17 | public: 18 | // Construction for depth-stencil textures. 19 | TextureDS(DFType format, unsigned int width, unsigned int height, 20 | bool createStorage = true); 21 | }; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /inc/render/Graphics/GteTextureRT.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP TextureRT : public Texture2 16 | { 17 | public: 18 | // Construction for render targets. 19 | TextureRT(DFType format, unsigned int width, unsigned int height, 20 | bool hasMipmaps = false, bool createStorage = true); 21 | }; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /inc/render/Graphics/GteTypedBuffer.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP TypedBuffer : public Buffer 16 | { 17 | protected: 18 | // Abstract base class. 19 | TypedBuffer(unsigned int numElements, size_t elementSize, 20 | bool createStorage = true); 21 | }; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /inc/render/Graphics/GteVertexBuffer.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | namespace gte 14 | { 15 | 16 | class GTE_IMPEXP VertexBuffer : public Buffer 17 | { 18 | public: 19 | // Construction. The first constructor is for typical usage whereby you 20 | // specified the attributes of a vertex format. The second constructor 21 | // is used for SV_VertexID-based drawing where the vertices are read from 22 | // a non-vertex-buffer resource in the vertex shader. 23 | VertexBuffer(VertexFormat const& vformat, unsigned int numVertices, 24 | bool createStorage = true); 25 | VertexBuffer(unsigned int numVertices); 26 | ~VertexBuffer(); 27 | 28 | 29 | // Member access. 30 | VertexFormat const& GetFormat() const; 31 | bool IsFormatted() const; 32 | 33 | // Get pointers to attribute data if it exists for the specified semantic 34 | // and unit. Also, you request that the attribute be one of a list of 35 | // required types (OR-ed bit flags). If you do not care about the type, 36 | // pass DF_UNKNOWN for the required input. If the request fails, a null 37 | // pointer is returned. 38 | char* GetChannel(VASemantic semantic, unsigned int unit, 39 | std::set const& requiredTypes); 40 | 41 | protected: 42 | VertexFormat mVFormat; 43 | 44 | int debug; 45 | }; 46 | 47 | } 48 | -------------------------------------------------------------------------------- /inc/render/Graphics/GteVertexShader.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace gte 13 | { 14 | 15 | class GTE_IMPEXP VertexShader : public Shader 16 | { 17 | public: 18 | // Construction. 19 | VertexShader(GLSLReflection const& reflector); 20 | }; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /inc/render/Graphics/gteCommon.h: -------------------------------------------------------------------------------- 1 | #ifndef SCENE_COMMON_h 2 | #define SCENE_COMMON_h 3 | #include 4 | #include 5 | #include 6 | #include 7 | #endif -------------------------------------------------------------------------------- /inc/render/LowLevel/GteAtomicMinMax.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | // Implementations of atomic minimum and atomic maximum computations. These 15 | // are based on std::atomic_compare_exchange_strong. 16 | 17 | namespace gte 18 | { 19 | 20 | template 21 | T AtomicMin(std::atomic& v0, T const& v1); 22 | 23 | template 24 | T AtomicMax(std::atomic& v0, T const& v1); 25 | 26 | 27 | template 28 | T AtomicMin(std::atomic& v0, T const& v1) 29 | { 30 | T vInitial, vMin; 31 | do 32 | { 33 | vInitial = v0; 34 | vMin = std::min(vInitial, v1); 35 | } while (!std::atomic_compare_exchange_strong(&v0, &vInitial, vMin)); 36 | return vInitial; 37 | } 38 | 39 | template 40 | T AtomicMax(std::atomic& v0, T const& v1) 41 | { 42 | T vInitial, vMax; 43 | do 44 | { 45 | vInitial = v0; 46 | vMax = std::max(vInitial, v1); 47 | } while (!std::atomic_compare_exchange_strong(&v0, &vInitial, vMax)); 48 | return vInitial; 49 | } 50 | 51 | 52 | } 53 | -------------------------------------------------------------------------------- /inc/render/LowLevel/GteTimer.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | #if defined(WIN32) && _MSC_VER < 1900 14 | // MSVS 2013 has an implementation of std::chrono::high_resolution_clock 15 | // that does not use a 64-bit clock (QueryPerformanceCounter). Instead, 16 | // it appears to use a file-system clock that is 24 bits. To obtain 17 | // accurate measurements, we need the 64-bit clock. However, MSVS 2015 18 | // does use a 64-bit clock. 19 | #define GTE_NEEDS_64_BIT_CLOCK 20 | #endif 21 | 22 | #if !defined(GTE_NEEDS_64_BIT_CLOCK) 23 | #include 24 | #endif 25 | 26 | namespace gte 27 | { 28 | 29 | class GTE_IMPEXP Timer 30 | { 31 | public: 32 | // Construction of a high-resolution timer (64-bit). 33 | Timer(); 34 | 35 | // Get the current time relative to the initial time. 36 | int64_t GetNanoseconds() const; 37 | int64_t GetMicroseconds() const; 38 | int64_t GetMilliseconds() const; 39 | double GetSeconds() const; 40 | 41 | // Reset so that the current time is the initial time. 42 | void Reset(); 43 | 44 | private: 45 | #if defined(GTE_NEEDS_64_BIT_CLOCK) 46 | // Internally use QueryPerformanceCounter. 47 | int64_t GetTicks() const; 48 | 49 | int64_t mFrequency, mInitialTicks; 50 | double mInvFrequency; 51 | #else 52 | std::chrono::high_resolution_clock::time_point mInitialTime; 53 | #endif 54 | }; 55 | 56 | } 57 | -------------------------------------------------------------------------------- /inc/render/LowLevel/GteWrapper.h: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | // Wrappers around platform-specific low-level library calls. 14 | 15 | namespace gte 16 | { 17 | 18 | void Memcpy(void* target, void const* source, size_t count); 19 | void Memcpy(wchar_t* target, wchar_t const* source, size_t count); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /inc/vsculpt/Operator/VCommonConfigOp.h: -------------------------------------------------------------------------------- 1 | #ifndef VSCULPT_UTIL_CONFIG_H 2 | #define VSCULPT_UTIL_CONFIG_H 3 | 4 | #include "VKernel/VScene.h" 5 | #include "VOperator.h" 6 | 7 | class VCommonConfigOp : public VOperator 8 | { 9 | public: 10 | VCommonConfigOp(); 11 | virtual ~VCommonConfigOp(); 12 | static bool poll(); 13 | static VOperator* create(); 14 | virtual void setParam(const QString &name, const QVariant &value); 15 | private: 16 | VScene *_scene; 17 | }; 18 | #endif -------------------------------------------------------------------------------- /inc/vsculpt/Operator/VDropMeshOp.h: -------------------------------------------------------------------------------- 1 | #ifndef VSCULPT_VDROP_MESH_OP_H 2 | #define VSCULPT_VDROP_MESH_OP_H 3 | #include "VOperator.h" 4 | #include "VContext.h" 5 | #include "VKernel/VScene.h" 6 | #include "BMesh/BMesh.h" 7 | #include "VKernel/VMeshObject.h" 8 | 9 | class VDropMeshOp : public VOperator 10 | { 11 | public: 12 | VDropMeshOp(); 13 | virtual ~VDropMeshOp(); 14 | 15 | static bool poll(); 16 | static VOperator* create(); 17 | 18 | virtual int invoke(QEvent *ev); 19 | private: 20 | VM::BMesh* import_vcg(const QString& filepath); 21 | 22 | 23 | QPoint _oldMouse; 24 | }; 25 | 26 | #endif -------------------------------------------------------------------------------- /inc/vsculpt/Operator/VManipulatorOp.h: -------------------------------------------------------------------------------- 1 | #ifndef VSCULPT_VMANIPULATOR_OP_H 2 | #define VSCULPT_VMANIPULATOR_OP_H 3 | 4 | #include "VOperator.h" 5 | #include "VKernel/VObject.h" 6 | #include "VbsQt/VbsDef.h" 7 | #include 8 | 9 | class VManipulatorOp : public VOperator 10 | { 11 | public: 12 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW 13 | public: 14 | VManipulatorOp(); 15 | virtual ~VManipulatorOp(); 16 | static bool poll(); 17 | static VOperator* create(); 18 | 19 | virtual int invoke(QEvent *ev); 20 | virtual int modal(QEvent *ev); 21 | private: 22 | void init(); 23 | void apply(); 24 | void finish(); 25 | void cancel(); 26 | private: 27 | VObject *_obj; 28 | VManipulatorNode *_manipulator; 29 | VView3DRegion *_region; 30 | char _transAxis; 31 | char _transMode; 32 | float _scaleSensitivity; 33 | vk::Transform _initialTransform; 34 | Eigen::Vector2f _centerGLMouse; 35 | Eigen::Vector2f _initialGLMouse; 36 | Eigen::Vector2f _curGLMouse; 37 | Eigen::Vector2f _lastGLMouse; 38 | float _referenceZDepth; 39 | 40 | }; 41 | 42 | #endif -------------------------------------------------------------------------------- /inc/vsculpt/Operator/VMeshBooleanOp.h: -------------------------------------------------------------------------------- 1 | #ifndef VSCULPT_MESH_BOOLEAN_OP_H 2 | #define VSCULPT_MESH_BOOLEAN_OP_H 3 | #include "VOperator.h" 4 | #include "VKernel/VMeshObject.h" 5 | 6 | class VMeshBooleanOp : public VOperator{ 7 | public: 8 | VMeshBooleanOp(); 9 | ~VMeshBooleanOp(); 10 | 11 | static bool poll(); 12 | static VOperator* create(); 13 | virtual void execute(); 14 | virtual void cancel(); 15 | private: 16 | VbsDef::BOOLEAN_TYPE _type; 17 | vk::VMeshObject *_hostObj; 18 | vk::VMeshObject *_targetObj; 19 | vk::VMeshObject *_resultObj; 20 | }; 21 | #endif -------------------------------------------------------------------------------- /inc/vsculpt/Operator/VMeshDecimateOp.h: -------------------------------------------------------------------------------- 1 | #ifndef VSCULPT_MESH_DECIMATE_OP_H 2 | #define VSCULPT_MESH_DECIMATE_OP_H 3 | #include "VOperator.h" 4 | #include "VKernel/VMeshObject.h" 5 | 6 | class VMeshDecimateOp : public VOperator{ 7 | public: 8 | VMeshDecimateOp(); 9 | ~VMeshDecimateOp(); 10 | 11 | static bool poll(); 12 | static VOperator* create(); 13 | virtual void execute(); 14 | virtual void cancel(); 15 | private: 16 | vk::VMeshObject *_org_obj; 17 | vk::VMeshObject *_dcmobj; 18 | }; 19 | #endif -------------------------------------------------------------------------------- /inc/vsculpt/Operator/VMeshRemeshOp.h: -------------------------------------------------------------------------------- 1 | #ifndef VSCULPT_MESH_REMESH_OP_H 2 | #define VSCULPT_MESH_REMESH_OP_H 3 | #include "VOperator.h" 4 | #include "VKernel/VMeshObject.h" 5 | 6 | class VMeshRemeshOp : public VOperator{ 7 | public: 8 | VMeshRemeshOp(); 9 | ~VMeshRemeshOp(); 10 | 11 | static bool poll(); 12 | static VOperator* create(); 13 | virtual void execute(); 14 | virtual void cancel(); 15 | private: 16 | vk::VMeshObject *_org_obj; 17 | vk::VMeshObject *_remesh_obj; 18 | }; 19 | #endif -------------------------------------------------------------------------------- /inc/vsculpt/Operator/VMeshSelfIsectOp.h: -------------------------------------------------------------------------------- 1 | #ifndef VSCULPT_VMESH_SELF_ISECT_H 2 | #define VSCULPT_VMESH_SELF_ISECT_H 3 | 4 | #include "VOperator.h" 5 | #include "VKernel/VMeshObject.h" 6 | 7 | class VMeshSelfIsectOp : public VOperator{ 8 | public: 9 | VMeshSelfIsectOp(); 10 | ~VMeshSelfIsectOp(); 11 | 12 | static bool poll(); 13 | static VOperator* create(); 14 | virtual void execute(); 15 | virtual void cancel(); 16 | private: 17 | vk::VMeshObject *_org_obj; 18 | vk::VMeshObject *_isct_obj; 19 | }; 20 | #endif -------------------------------------------------------------------------------- /inc/vsculpt/Operator/VMeshSmoothOp.h: -------------------------------------------------------------------------------- 1 | #ifndef VSCULPT_VSMOOTH_OP_H 2 | #define VSCULPT_VSMOOTH_OP_H 3 | #include "VOperator.h" 4 | #include "VKernel/VMeshObject.h" 5 | class VMeshSmoothOp : public VOperator{ 6 | public: 7 | VMeshSmoothOp(); 8 | ~VMeshSmoothOp(); 9 | 10 | static bool poll(); 11 | static VOperator* create(); 12 | virtual void execute(); 13 | virtual void cancel(); 14 | private: 15 | vk::VMeshObject *_obj; 16 | vk::VMeshObject *_smoothobj; 17 | std::vector _orgvertco; 18 | }; 19 | #endif -------------------------------------------------------------------------------- /inc/vsculpt/Operator/VOperator.h: -------------------------------------------------------------------------------- 1 | #ifndef VSCULPT_VOPERATOR_H 2 | #define VSCULPT_VOPERATOR_H 3 | 4 | #include 5 | #include "VKernel/VScene.h" 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | using namespace vk; 12 | class VOperator 13 | { 14 | public: 15 | /*OP type*/ 16 | typedef enum RET_STATE 17 | { 18 | OP_RET_NONE = 1 << 0, 19 | OP_RET_FINISHED = 1 << 1, 20 | OP_RET_RUNNING = 1 << 2 21 | }RET_STATE; 22 | public: 23 | VOperator(){}; 24 | virtual ~VOperator(){}; 25 | 26 | virtual int invoke(QEvent *ev){ return OP_RET_NONE; }; 27 | virtual int modal(QEvent *ev){ return OP_RET_NONE; }; 28 | virtual void cancel(){}; 29 | virtual void execute(){}; 30 | virtual void setParam(const QString &name, const QVariant &value){ _params[name] = value; } 31 | QVariant param(const QString &name); 32 | 33 | /*for QML UI query information*/ 34 | virtual QVariant query(const QString &name); 35 | virtual QVariantList queryList(const QString &name); 36 | virtual QVariantMap queryMap(const QString &name); 37 | protected: 38 | QVariantMap _params; 39 | }; 40 | 41 | #endif -------------------------------------------------------------------------------- /inc/vsculpt/Operator/VSculptBrushOp.h: -------------------------------------------------------------------------------- 1 | #ifndef VSCULPT_SCULT_BRUSH_OPERATOR_H 2 | #define VSCULPT_SCULT_BRUSH_OPERATOR_H 3 | 4 | #include "VKernel/VScene.h" 5 | #include "VOperator.h" 6 | #include "BezierCurve.h" 7 | #include "StrokeData.h" 8 | #include "brush/SculptStroke.h" 9 | #include "commonDefine.h" 10 | #include "VKernel/VMeshObject.h" 11 | #include 12 | 13 | class VSculptBrushOp : public VOperator 14 | { 15 | public: 16 | VSculptBrushOp(vk::VScene *scene); 17 | virtual ~VSculptBrushOp(); 18 | 19 | static bool poll(); 20 | static VOperator* create(); 21 | 22 | virtual int modal(QEvent *ev); 23 | virtual int invoke(QEvent *ev); 24 | private: 25 | void init(); 26 | void apply(); 27 | void cancel(); 28 | 29 | void add_step(Vector2f cur_mouse, Vector2f last_mouse, Vector2f first_hit_mouse); 30 | bool update(Vector2f cur_mouse, Vector2f last_mouse, Vector2f first_hit_mouse); 31 | bool init_stroke(Vector2f curmouse); 32 | bool is_sample_mouse(); 33 | void sample_mouse(Vector2f start, Vector2f end); 34 | bool is_one_step_stroke(); 35 | 36 | bool pick(Vector2f mouse, Vector3f &hit); 37 | void interpolate_param(); 38 | void init_undo_redo(); 39 | void queue_mouse_range(Vector2f start, Vector2f end); 40 | private: 41 | VScene *_scene; 42 | VMeshObject *_object; 43 | BVHRenderer *_renderer; 44 | VView3DRegion *_region; 45 | 46 | Vector2f _first_hit_mouse; 47 | 48 | Vector2f _last_mouse; 49 | Vector2f _cur_mouse; 50 | int _timerid; 51 | float _detail_size; 52 | float _pixel_radius; 53 | bool _stroke_started; 54 | 55 | StrokeData _data; 56 | 57 | SculptStroke *_stroke; 58 | BezierCurve *_curve; 59 | 60 | std::queue> _queuemouse; 61 | }; 62 | #endif -------------------------------------------------------------------------------- /inc/vsculpt/Operator/VSculptConfigOp.h: -------------------------------------------------------------------------------- 1 | #ifndef VSCULPT_SCCULPT_CONFIG_H 2 | #define VSCULPT_SCCULPT_CONFIG_H 3 | 4 | #include "VKernel/VScene.h" 5 | #include "VOperator.h" 6 | #include "Sculpt/VSculptConfig.h" 7 | 8 | class VSculptConfigOp : public VOperator 9 | { 10 | public: 11 | VSculptConfigOp(vk::VScene *scene); 12 | virtual ~VSculptConfigOp(); 13 | static bool poll(); 14 | static VOperator* create(); 15 | virtual void setParam(const QString &name, const QVariant &value); 16 | private: 17 | VScene *_scene; 18 | VSculptConfig *_config; 19 | }; 20 | #endif -------------------------------------------------------------------------------- /inc/vsculpt/Operator/VView3DEditBoxOp.h: -------------------------------------------------------------------------------- 1 | #ifndef VSCULPT_VVIEW3D_EDIT_BOX_H 2 | #define VSCULPT_VVIEW3D_EDIT_BOX_H 3 | #include "VOperator.h" 4 | class VView3DEditBoxOp : public VOperator 5 | { 6 | public: 7 | VView3DEditBoxOp(); 8 | virtual ~VView3DEditBoxOp(); 9 | static bool poll(); 10 | static VOperator* create(); 11 | 12 | virtual int invoke(QEvent *ev); 13 | virtual int modal(QEvent *ev); 14 | private: 15 | void init(); 16 | void apply(); 17 | Eigen::Vector3f _rotaxis_view; 18 | float _rotangle; 19 | float _rotanglestep; 20 | bool _done; 21 | int _timerid; 22 | VView3DRegion *_region; 23 | Eigen::Vector2f _pos; 24 | }; 25 | 26 | 27 | #endif -------------------------------------------------------------------------------- /inc/vsculpt/Operator/VViewEditOp.h: -------------------------------------------------------------------------------- 1 | #ifndef VSCULPT_VIEW_EDIT_OP_H 2 | #define VSCULPT_VIEW_EDIT_OP_H 3 | #include "VOperator.h" 4 | #include "VContext.h" 5 | #include "VKernel/VScene.h" 6 | #include "BaseLib/MathGeom.h" 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #ifdef DEBUG_DRAW 13 | extern std::vector> g_debug_points; 14 | extern std::vector> g_debug_segments; 15 | #endif 16 | using namespace vk; 17 | 18 | class VViewMoveOp: public VOperator 19 | { 20 | public: 21 | VViewMoveOp(); 22 | virtual ~VViewMoveOp(); 23 | 24 | static bool poll(); 25 | static VOperator* create(); 26 | 27 | virtual int invoke(QEvent *ev); 28 | virtual int modal(QEvent *ev); 29 | private: 30 | void viewMoveApply(const QPoint &curMouse); 31 | QPoint _lastmouse; 32 | VView3DRegion *_region; 33 | }; 34 | 35 | class VViewZoomOp : public VOperator 36 | { 37 | public: 38 | VViewZoomOp(); 39 | virtual ~VViewZoomOp(); 40 | 41 | static bool poll(); 42 | static VOperator* create(); 43 | 44 | virtual int invoke(QEvent *ev); 45 | private: 46 | QPoint _oldMouse; 47 | VView3DRegion *_region; 48 | }; 49 | 50 | class VViewRotateOp : public VOperator 51 | { 52 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW 53 | public: 54 | VViewRotateOp(); 55 | virtual ~VViewRotateOp(); 56 | static bool poll(); 57 | static VOperator* create(); 58 | 59 | virtual int invoke(QEvent *ev); 60 | virtual int modal(QEvent *ev); 61 | private: 62 | Eigen::Vector2f _lastMouse; 63 | VView3DRegion *_region; 64 | }; 65 | 66 | #endif -------------------------------------------------------------------------------- /inc/vsculpt/QtQuickAppViewer.h: -------------------------------------------------------------------------------- 1 | #ifndef QTQUICK2APPLICATIONVIEWER_H 2 | #define QTQUICK2APPLICATIONVIEWER_H 3 | 4 | #include 5 | #include "VEventHandler.h" 6 | #include 7 | #include 8 | 9 | class VView3DRegionQuickItem; 10 | 11 | class QtQuickAppViewer : public QQuickView 12 | { 13 | Q_OBJECT 14 | public: 15 | explicit QtQuickAppViewer(QWindow *parent = 0); 16 | virtual ~QtQuickAppViewer(); 17 | 18 | void setMainQmlFile(const QString &file); 19 | void addImportPath(const QString &path); 20 | void showExpanded(); 21 | virtual bool event(QEvent *ev); 22 | 23 | void onSceneGraphInvalidated(); 24 | void onSceneGraphInitialized(); 25 | void onBeforeRendering(); 26 | void onSceneGraphAboutToStop(); 27 | 28 | void on3DRegionCreated(VView3DRegion *region); 29 | void on3DRegionDestroyed(VView3DRegion *region); 30 | void beginDrawTarget(); 31 | void endDrawTarget(); 32 | private: 33 | VEventHandlerManager *_event_manager; 34 | std::shared_ptr _renderTarget;/*FrameBuffer on which all region are rendered on*/ 35 | std::vector _regions; 36 | Eigen::Vector2f _mousepos; 37 | }; 38 | 39 | #endif // QTQUICK2APPLICATIONVIEWER_H 40 | -------------------------------------------------------------------------------- /inc/vsculpt/VCommon.h: -------------------------------------------------------------------------------- 1 | #ifndef VSCULPT_VCOMMON_H 2 | #define VSCULPT_VCOMMON_H 3 | #define VR_BEGIN_NAMESPACE namespace VR { 4 | #define VR_END_NAMESPACE } 5 | #endif -------------------------------------------------------------------------------- /inc/vsculpt/VOperatorQmlAdaptor.h: -------------------------------------------------------------------------------- 1 | #ifndef VSCULPT_VQML_ADAPTOR_H 2 | #define VSCULPT_VQML_ADAPTOR_H 3 | 4 | #include 5 | #include 6 | #include "Operator/VOperator.h" 7 | #include "Operator/VOpTemplate.h" 8 | class VOperatorQmlAdaptor : public QObject { 9 | Q_OBJECT 10 | Q_PROPERTY(VOpTemplate::OP_TYPE opid READ opid WRITE setOpid NOTIFY opidChanged) 11 | public: 12 | VOperatorQmlAdaptor(); 13 | ~VOperatorQmlAdaptor(); 14 | public: 15 | VOpTemplate::OP_TYPE opid(); 16 | void setOpid(VOpTemplate::OP_TYPE &id); 17 | Q_SIGNALS: 18 | void opidChanged(); 19 | public: 20 | Q_INVOKABLE QVariant query(const QString &name); 21 | Q_INVOKABLE void setParam(const QString &name, const QVariant &val); 22 | Q_INVOKABLE void invoke(); 23 | Q_INVOKABLE void execute(); 24 | Q_INVOKABLE void cancel(); 25 | private: 26 | VOpTemplate::OP_TYPE _opid; 27 | VOperator *_op; 28 | }; 29 | #endif -------------------------------------------------------------------------------- /inc/vsculpt/VView3DRegionQuickItem.h: -------------------------------------------------------------------------------- 1 | #ifndef VSCULPT_VRENDER_QUICK_ITEM_H 2 | #define VSCULPT_VRENDER_QUICK_ITEM_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include "VKernel/VView3DRegion.h" 12 | 13 | class VView3DRegionQuickItem : public QQuickItem 14 | { 15 | Q_OBJECT 16 | Q_PROPERTY(qreal t READ t WRITE setT NOTIFY tChanged) 17 | public: 18 | VView3DRegionQuickItem(); 19 | ~VView3DRegionQuickItem(); 20 | qreal t() const { return m_t; } 21 | void setT(qreal t); 22 | Q_SIGNALS: 23 | void tChanged(); 24 | 25 | public Q_SLOTS: 26 | void sync(); 27 | void cleanup(); 28 | 29 | private Q_SLOTS: 30 | void handleWindowChanged(QQuickWindow *win); 31 | private: 32 | qreal m_t; 33 | vk::VView3DRegion *_region; 34 | }; 35 | 36 | #endif -------------------------------------------------------------------------------- /qml/cube.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhha/digital_sculpting/804edb2757143b87f3ffe6585a7b79b804ccdc80/qml/cube.png -------------------------------------------------------------------------------- /resource/TestForm.ui.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.4 2 | 3 | Item { 4 | width: 400 5 | height: 400 6 | } 7 | -------------------------------------------------------------------------------- /resource/TestForm.ui.qml.autosave: -------------------------------------------------------------------------------- 1 | import QtQuick 2.4 2 | 3 | Item { 4 | width: 400 5 | height: 400 6 | } 7 | -------------------------------------------------------------------------------- /resource/qml.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | qml/main.qml 4 | javascript/qmlcommonresource.js 5 | javascript/qmlcommonutil.js 6 | javascript/vendor/randomColor.js 7 | qml/MainGBSingletonObject.qml 8 | qml/SmoothDialog.qml 9 | qml/main.js 10 | qml/SculptDialog.qml 11 | qml/DecimateDialog.qml 12 | qml/RemeshDialog.qml 13 | qml/BooleanDialog.qml 14 | 15 | 16 | -------------------------------------------------------------------------------- /resource/vsculptres.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = app 2 | 3 | QT += qml quick 4 | CONFIG += c++11 5 | 6 | SOURCES += 7 | 8 | RESOURCES += \ 9 | K3DStudio-2.qrc \ 10 | K3DStudio-3.qrc \ 11 | qml.qrc \ 12 | K3DStudio-4.qrc \ 13 | K3DStudio-5.qrc 14 | 15 | # Additional import path used to resolve QML modules in Qt Creator's code model 16 | QML_IMPORT_PATH = 17 | 18 | # Default rules for deployment. 19 | include(deployment.pri) 20 | -------------------------------------------------------------------------------- /src/BMesh/Tools/BMBisectOp.cpp: -------------------------------------------------------------------------------- 1 | #include "Tools/BMBisectOp.h" 2 | 3 | VM_BEGIN_NAMESPACE 4 | 5 | 6 | BMBisectOp::BMBisectOp() 7 | { 8 | } 9 | 10 | BMBisectOp::~BMBisectOp() 11 | { 12 | } 13 | 14 | void BMBisectOp::execute() 15 | { 16 | const Vector3f &plane_co = *in_slot_data_get("plane_co"); 17 | const Vector3f &plane_no = *in_slot_data_get("plane_no"); 18 | } 19 | 20 | VM_END_NAMESPACE -------------------------------------------------------------------------------- /src/BMesh/Tools/BMeshRemesh.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhha/digital_sculpting/804edb2757143b87f3ffe6585a7b79b804ccdc80/src/BMesh/Tools/BMeshRemesh.cpp -------------------------------------------------------------------------------- /src/BMesh/Tools/BMeshTriangulate.cpp: -------------------------------------------------------------------------------- 1 | #include "Tools/BMeshTriangulate.h" 2 | #include "BaseLib/Point3Dd.h" 3 | #include "BaseLib/MathUtil.h" 4 | #include 5 | 6 | VM_BEGIN_NAMESPACE 7 | BMeshTriangulate::BMeshTriangulate(BMesh *bm, const int quad_method, const int ngon_method, const bool tag_only) 8 | : 9 | _bm(bm), 10 | _quad_method(quad_method), 11 | _ngon_method(ngon_method), 12 | _tag_only(tag_only) 13 | {} 14 | 15 | BMeshTriangulate::~BMeshTriangulate() 16 | { 17 | } 18 | 19 | void BMeshTriangulate::run() 20 | { 21 | std::vector non_tri_faces; 22 | BMFace *face; 23 | BMIter iter; 24 | 25 | BM_ITER_MESH(face, &iter, _bm, BM_FACES_OF_MESH) { 26 | if (face->len > 3) { 27 | if (_tag_only == false || BM_elem_flag_test(face, BM_ELEM_TAG)) { 28 | non_tri_faces.push_back(face); 29 | } 30 | } 31 | } 32 | 33 | for (auto it = non_tri_faces.begin(); it != non_tri_faces.end(); ++it){ 34 | _bm->BM_face_triangulate( 35 | *it, 36 | nullptr, nullptr, nullptr, 37 | _quad_method, _ngon_method, _tag_only); 38 | } 39 | } 40 | 41 | VM_END_NAMESPACE -------------------------------------------------------------------------------- /src/BaseLib/BasePrecompiled.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "BasePrecompiled.h" -------------------------------------------------------------------------------- /src/BaseLib/BoxVertex.cpp: -------------------------------------------------------------------------------- 1 | #include "BoxVertex.h" 2 | #include "BoxPlane.h" 3 | #include "BoxEdge.h" 4 | 5 | BoxVertex::BoxVertex(const Point3Dd& p) { 6 | _p = new Point3Dd(p); 7 | } 8 | 9 | BoxVertex::BoxVertex(Point3Dd* p) { 10 | _p = p; 11 | } 12 | 13 | BoxVertex::~BoxVertex() { 14 | if (_p) { 15 | delete _p; 16 | _p = 0; 17 | } 18 | } 19 | 20 | Point3Dd* BoxVertex::getPoint() { 21 | return _p; 22 | } 23 | 24 | //void BoxVertex::setEdges(BoxEdge* e1, BoxEdge* e2, BoxEdge* e3) { 25 | // _edges[0] = e1; 26 | // _edges[1] = e2; 27 | // _edges[2] = e3; 28 | //} 29 | 30 | void BoxVertex::addBoxEdge(BoxEdge* e) { 31 | _edges.push_back(e); 32 | } 33 | 34 | void BoxVertex::addBoxPlan(BoxPlane* plane) { 35 | _planes.push_back(plane); 36 | } 37 | 38 | std::vector BoxVertex::getPlanes() { 39 | return _planes; 40 | } 41 | 42 | std::vector BoxVertex::getEdges() { 43 | return _edges; 44 | } 45 | 46 | BoxEdge* BoxVertex::getOtherEdge(BoxEdge* e1, BoxEdge* e2) { 47 | for (unsigned i = 0; i < _edges.size(); i++) { 48 | BoxEdge* ei = _edges.at(i); 49 | if (ei != e1 && ei != e2) { 50 | return ei; 51 | } 52 | } 53 | return 0; 54 | } 55 | 56 | void BoxVertex::get3Edges(BoxEdge*& e1, BoxEdge*& e2, BoxEdge*& e3) { 57 | e1 = _edges.at(0); 58 | e2 = _edges.at(1); 59 | e3 = _edges.at(2); 60 | } -------------------------------------------------------------------------------- /src/BaseLib/Point2Df.cpp: -------------------------------------------------------------------------------- 1 | #include "Point2Df.h" 2 | 3 | 4 | //Point2Df::Point2Df(void) 5 | //{ 6 | // _v[0] = 0.0f; 7 | // _v[1] = 0.0f; 8 | //} 9 | // 10 | //Point2Df::Point2Df(const float* coord) 11 | //{ 12 | // _v[0] = coord[0]; 13 | // _v[1] = coord[1]; 14 | //} 15 | //Point2Df::Point2Df(const double* coord) 16 | //{ 17 | // _v[0] = static_cast(coord[0]); 18 | // _v[1] = static_cast(coord[1]); 19 | //} 20 | //Point2Df::Point2Df(const double x, const double y) 21 | //{ 22 | // _v[0] = static_cast(x); 23 | // _v[1] = static_cast(y); 24 | //} 25 | //Point2Df::~Point2Df(void) 26 | //{ 27 | //} 28 | -------------------------------------------------------------------------------- /src/BaseLib/Quadrangle.cpp: -------------------------------------------------------------------------------- 1 | #include "Quadrangle.h" 2 | 3 | namespace BaseType{ 4 | 5 | Quadrangle::Quadrangle(void) 6 | { 7 | } 8 | 9 | Quadrangle::Quadrangle(const Point3Dd& p1, const Point3Dd& p2, 10 | const Point3Dd& p3, const Point3Dd& p4) 11 | { 12 | _vp[0] = p1; 13 | _vp[1] = p2; 14 | _vp[2] = p3; 15 | _vp[3] = p4; 16 | } 17 | 18 | Quadrangle::~Quadrangle(void) 19 | { 20 | } 21 | 22 | }// namespace -------------------------------------------------------------------------------- /src/BaseLib/Segment2Df.cpp: -------------------------------------------------------------------------------- 1 | #include "Segment2Df.h" 2 | #include "Point2Df.h" 3 | 4 | Segment2Df::Segment2Df(void): 5 | _sp(0), 6 | _ep(0) 7 | { 8 | } 9 | 10 | 11 | Segment2Df::Segment2Df(Point2Df* sp, Point2Df* ep): 12 | _sp(sp), 13 | _ep(ep) 14 | {} 15 | 16 | 17 | Segment2Df::~Segment2Df(void) 18 | { 19 | if(_sp){ 20 | delete _sp; 21 | } 22 | if(_ep){ 23 | delete _ep; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/BaseLib/StackWalker.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhha/digital_sculpting/804edb2757143b87f3ffe6585a7b79b804ccdc80/src/BaseLib/StackWalker.cpp -------------------------------------------------------------------------------- /src/BaseLib/intersectpoint.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhha/digital_sculpting/804edb2757143b87f3ffe6585a7b79b804ccdc80/src/BaseLib/intersectpoint.cpp -------------------------------------------------------------------------------- /src/BaseLib/line3D.cpp: -------------------------------------------------------------------------------- 1 | #include "line3d.h" 2 | #include "segment2Dd.h" 3 | #include 4 | 5 | Line3Dd::Line3Dd(const Point3Dd& p, const Point3Dd& v) 6 | : _p(p) 7 | , _v(v) 8 | { 9 | } 10 | bool Line3Dd::intersectPlanarLine(Point3Dd& ip, const Point3Dd& p, const Vector3Dd& v) { 11 | Vector3Dd n1 = _v.crossProduct(v); 12 | Vector3Dd n = n1.crossProduct(v); 13 | int ret = this->intersectPlane(ip, p, n); 14 | return (ret == 1); 15 | } 16 | 17 | 18 | int Line3Dd::intersectPlane( Point3Dd& ip, const Point3Dd& onPoint, const Vector3Dd& normal) const 19 | { 20 | Point3Dd ep = _p + _v; 21 | Vector3Dd u = _p - ep; 22 | Vector3Dd w = _p - onPoint; 23 | double D = normal.scalarProduct( u ); 24 | double N = -normal.scalarProduct( w ); 25 | if( fabs(D) < EPSILON_VAL_){ 26 | if( fabs(N) < EPSILON_VAL_)// == 0 ) 27 | return 2; // in plane 28 | else 29 | return 0; // not intersect 30 | } 31 | double sI = N/D; 32 | ip.v[0] = _p.v[0] + sI * u.v[0]; 33 | ip.v[1] = _p.v[1] + sI * u.v[1]; 34 | ip.v[2] = _p.v[2] + sI * u.v[2]; 35 | return 1; 36 | } -------------------------------------------------------------------------------- /src/BaseLib/matrix4x4d.cpp: -------------------------------------------------------------------------------- 1 | #include "matrix4x4d.h" 2 | 3 | 4 | Matrix4x4d::Matrix4x4d(void) 5 | { 6 | } 7 | 8 | 9 | Matrix4x4d::~Matrix4x4d(void) 10 | { 11 | } 12 | -------------------------------------------------------------------------------- /src/Boolean/bm/bm_isct_bool_include.cpp: -------------------------------------------------------------------------------- 1 | #include "bm/bm_isct_bool_include.h" 2 | #include "bm/bm_isct_boolean.h" 3 | #include "bm/bm_isct_outer_hull_exact.h" 4 | namespace bm_isct 5 | { 6 | BMesh* compute_union(VM::BMesh *bm0, VBvh::BMBvh *bvh0, VM::BMesh *bm1, VBvh::BMBvh *bvh1) 7 | { 8 | BmBoolean boolean(bm0, bvh0, bm1, bvh1); 9 | boolean.compute_union(); 10 | return boolean.result(); 11 | } 12 | 13 | BMesh* compute_difference(VM::BMesh *bm0, VBvh::BMBvh *bvh0, VM::BMesh *bm1, VBvh::BMBvh *bvh1) 14 | { 15 | BmBoolean boolean(bm0, bvh0, bm1, bvh1); 16 | boolean.compute_differnece(); 17 | return boolean.result(); 18 | } 19 | 20 | BMesh* compute_intersection(VM::BMesh *bm0, VBvh::BMBvh *bvh0, VM::BMesh *bm1, VBvh::BMBvh *bvh1) 21 | { 22 | BmBoolean boolean(bm0, bvh0, bm1, bvh1); 23 | boolean.compute_intersection(); 24 | return boolean.result(); 25 | } 26 | 27 | BMesh * resolve_self_isct(VM::BMesh *bm0) 28 | { 29 | BmOuterHullExtract outerhull(bm0); 30 | outerhull.extract(); 31 | return outerhull.result(); 32 | } 33 | 34 | } 35 | 36 | -------------------------------------------------------------------------------- /src/Sculpt/SculptCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "sculpt/SculptCommand.h" 2 | #include "tbb/mutex.h" 3 | #include "tbb/parallel_for.h" 4 | #include 5 | #include 6 | #include 7 | #include "sculpt/SUtil.h" 8 | #include "VKernel/VScene.h" 9 | #include "VKernel/VMeshObject.h" 10 | #include "BaseLib/MathUtil.h" 11 | 12 | //////////////////////////////////////////////////////////////////////////// 13 | VSculptCommand::VSculptCommand(VScene *scene, VMeshObject *obj) 14 | : 15 | _scene(scene), 16 | _obj(obj) 17 | { 18 | } 19 | 20 | VSculptCommand::~VSculptCommand() 21 | { 22 | /*logger::undo must be called earlier*/ 23 | if(_logger) _logger->undo_apply(); 24 | } 25 | 26 | void VSculptCommand::log_data(const std::vector& nodes) 27 | { 28 | _logger = std::shared_ptr(new VSculptLogger(_scene, _obj)); 29 | _logger->log_nodes(nodes); 30 | } 31 | 32 | void VSculptCommand::log_data(VSculptLogger &&logger) 33 | { 34 | _logger = std::shared_ptr(new VSculptLogger(std::move(logger))); 35 | } 36 | 37 | #if 0 38 | bool VSculptCommand::doHook() 39 | { 40 | _state = VUndoEntry::DONE; 41 | return true; 42 | } 43 | 44 | void VSculptCommand::undoHook() 45 | { 46 | if (_scene->objectExist(_obj)){ 47 | _logger->undo(); 48 | 49 | _obj->getBmesh()->BM_mesh_normals_update_parallel(); 50 | _obj->rebuildBVH(); 51 | } 52 | } 53 | 54 | void VSculptCommand::redoHook() 55 | { 56 | if (_scene->objectExist(_obj)){ 57 | _logger->redo(); 58 | 59 | _obj->getBmesh()->BM_mesh_normals_update_parallel(); 60 | _obj->rebuildBVH(); 61 | } 62 | } 63 | 64 | #endif 65 | 66 | -------------------------------------------------------------------------------- /src/VBvh/BMeshBvhNodeSplitter.cpp: -------------------------------------------------------------------------------- 1 | #include "VBvh/BMeshBvhNodeSplitter.h" 2 | #include "VBvh/VBvhUtil.h" 3 | VBVH_BEGIN_NAMESPACE 4 | 5 | BMeshBvhNodeSplitter::BMeshBvhNodeSplitter(BMLeafNode *node, const BMeshBvhContext &bmbvhinfo) 6 | : 7 | _node(node), 8 | _bmbvh_info(bmbvhinfo) 9 | { 10 | _total = node->faces().size(); 11 | _prims = reinterpret_cast(scalable_aligned_malloc(sizeof(VPrimRef) * _total, 32)); 12 | } 13 | 14 | BMeshBvhNodeSplitter::~BMeshBvhNodeSplitter() 15 | { 16 | scalable_aligned_free(_prims); 17 | } 18 | 19 | void BMeshBvhNodeSplitter::run() 20 | { 21 | /*calculate primitive information*/ 22 | BMFacesPrimInfoCompute(_node->faces().data(), _total, _prims, _priminfo, false); 23 | 24 | /*build a bvh node hierarchy from primitive list*/ 25 | VBvhBinBuilder b(_priminfo, _prims, _total, 200, &_bmbvh_info); 26 | b.build(); 27 | 28 | _leafs = std::move(b.leafNodes()); 29 | _root = b.rootNode(); 30 | } 31 | 32 | VBVH_END_NAMESPACE -------------------------------------------------------------------------------- /src/VBvh/common/simd/sse.cpp: -------------------------------------------------------------------------------- 1 | #include "common/simd/sse.h" 2 | 3 | namespace VBvh { 4 | const __m128 _mm_lookupmask_ps[16] = { 5 | _mm_castsi128_ps(_mm_set_epi32( 0, 0, 0, 0)), 6 | _mm_castsi128_ps(_mm_set_epi32( 0, 0, 0,-1)), 7 | _mm_castsi128_ps(_mm_set_epi32( 0, 0,-1, 0)), 8 | _mm_castsi128_ps(_mm_set_epi32( 0, 0,-1,-1)), 9 | _mm_castsi128_ps(_mm_set_epi32( 0,-1, 0, 0)), 10 | _mm_castsi128_ps(_mm_set_epi32( 0,-1, 0,-1)), 11 | _mm_castsi128_ps(_mm_set_epi32( 0,-1,-1, 0)), 12 | _mm_castsi128_ps(_mm_set_epi32( 0,-1,-1,-1)), 13 | _mm_castsi128_ps(_mm_set_epi32(-1, 0, 0, 0)), 14 | _mm_castsi128_ps(_mm_set_epi32(-1, 0, 0,-1)), 15 | _mm_castsi128_ps(_mm_set_epi32(-1, 0,-1, 0)), 16 | _mm_castsi128_ps(_mm_set_epi32(-1, 0,-1,-1)), 17 | _mm_castsi128_ps(_mm_set_epi32(-1,-1, 0, 0)), 18 | _mm_castsi128_ps(_mm_set_epi32(-1,-1, 0,-1)), 19 | _mm_castsi128_ps(_mm_set_epi32(-1,-1,-1, 0)), 20 | _mm_castsi128_ps(_mm_set_epi32(-1,-1,-1,-1)) 21 | }; 22 | } 23 | -------------------------------------------------------------------------------- /src/VKernel/VEffectManager.cpp: -------------------------------------------------------------------------------- 1 | #include "VEffectManager.h" 2 | 3 | VK_BEGIN_NAMESPACE 4 | 5 | VK_END_NAMESPACE -------------------------------------------------------------------------------- /src/VKernel/VNode.cpp: -------------------------------------------------------------------------------- 1 | #include "VNode.h" 2 | #include "VView3DRegion.h" 3 | 4 | using namespace gte; 5 | VK_BEGIN_NAMESPACE 6 | 7 | VNode::VNode(VNode *parent) 8 | : 9 | QObject(parent), 10 | _oflag(0), 11 | _worldTransform(new Transform()), 12 | _localTransform(new Transform()) 13 | { 14 | _localTransform->setIdentity(); 15 | _worldTransform->setIdentity(); 16 | } 17 | 18 | VNode::~VNode() 19 | {} 20 | 21 | 22 | void VNode::accept(VNodeVisitor *visitor) 23 | { 24 | if (visitor){ 25 | visitor->visit(this); 26 | 27 | Q_FOREACH(QObject *cobj, children()){ 28 | VNode *cnode = dynamic_cast(cobj); 29 | if (cnode){ 30 | cnode->accept(visitor); 31 | } 32 | } 33 | } 34 | } 35 | 36 | void VNode::updateWorldTransform() 37 | { 38 | QObject *par = parent(); 39 | VNode *parnode = dynamic_cast(par); 40 | if (parnode){ 41 | *_worldTransform = parnode->worldTransform() * localTransform(); 42 | } 43 | else{ 44 | *_worldTransform = *_localTransform; 45 | } 46 | 47 | Q_FOREACH(QObject *cobj, children()){ 48 | VNode *cnode = dynamic_cast(cobj); 49 | if (cnode){ 50 | cnode->updateWorldTransform(); 51 | } 52 | } 53 | } 54 | 55 | Transform& VNode::worldTransform() 56 | { 57 | return *_worldTransform; 58 | } 59 | 60 | const Transform& VNode::worldTransform() const 61 | { 62 | return *_worldTransform; 63 | } 64 | 65 | Transform& VNode::localTransform() 66 | { 67 | return *_localTransform; 68 | } 69 | 70 | const Transform& VNode::localTransform() const 71 | { 72 | return *_localTransform; 73 | } 74 | 75 | void VNode::syncUpdate() 76 | { 77 | 78 | } 79 | 80 | void VNode::onRender(VView3DRegion *region) 81 | { 82 | } 83 | 84 | 85 | 86 | 87 | VK_END_NAMESPACE -------------------------------------------------------------------------------- /src/VKernel/VObject.cpp: -------------------------------------------------------------------------------- 1 | #include "VObject.h" 2 | 3 | int vk::VObject::ObjectInstanceCount = 0; -------------------------------------------------------------------------------- /src/VKernel/VTextureLoader.cpp: -------------------------------------------------------------------------------- 1 | #include "VTextureLoader.h" 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace gte; 7 | 8 | VK_BEGIN_NAMESPACE 9 | 10 | Texture2* VTextureLoader::load(std::string const& filename) 11 | { 12 | QImage image(QString(filename.c_str())); 13 | image = image.mirrored(); 14 | QImage glImage = image.convertToFormat(QImage::Format_RGBA8888); 15 | DFType gtformat = DF_R8G8B8A8_UNORM; 16 | size_t width = glImage.width(); 17 | size_t height = glImage.height(); 18 | // Create the 2D texture and compute the stride and image size. 19 | std::unique_ptr texture(new Texture2(gtformat, width, height, false)); 20 | size_t const stride = width * texture->GetElementSize(); 21 | size_t const imageSize = stride * height; 22 | memcpy(texture->Get(), glImage.constBits(), imageSize); 23 | return texture.release(); 24 | } 25 | 26 | VK_END_NAMESPACE 27 | -------------------------------------------------------------------------------- /src/VbsQt/VbsDef.cpp: -------------------------------------------------------------------------------- 1 | #include "VbsDef.h" 2 | -------------------------------------------------------------------------------- /src/render/Graphics/GL4/GteGL4ConstantBuffer.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | using namespace gte; 11 | 12 | GL4ConstantBuffer::GL4ConstantBuffer(ConstantBuffer const* cbuffer) 13 | : 14 | GL4Buffer(cbuffer, GL_UNIFORM_BUFFER) 15 | { 16 | Initialize(); 17 | } 18 | 19 | GEObject* GL4ConstantBuffer::Create(void*, GraphicsObject const* object) 20 | { 21 | if (object->GetType() == GT_CONSTANT_BUFFER) 22 | { 23 | return new GL4ConstantBuffer(static_cast(object)); 24 | } 25 | 26 | qCritical("Invalid object type."); 27 | return nullptr; 28 | } 29 | 30 | void GL4ConstantBuffer::AttachToUnit(GLint uniformBufferUnit) 31 | { 32 | GL::function().glBindBufferBase(GL_UNIFORM_BUFFER, uniformBufferUnit, mGLHandle); 33 | } 34 | -------------------------------------------------------------------------------- /src/render/Graphics/GL4/GteGL4DrawingState.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | using namespace gte; 11 | 12 | GL4DrawingState::GL4DrawingState(DrawingState const* gtState) 13 | : 14 | GL4GraphicsObject(gtState) 15 | { 16 | } 17 | -------------------------------------------------------------------------------- /src/render/Graphics/GL4/GteGL4GraphicsObject.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | using namespace gte; 11 | 12 | GL4GraphicsObject::GL4GraphicsObject(GraphicsObject const* gtObject) 13 | : 14 | GEObject(gtObject), 15 | mGLHandle(0) 16 | { 17 | } 18 | 19 | void GL4GraphicsObject::SetName(std::string const& name) 20 | { 21 | // TODO: Determine how to tag OpenGL objects with names? 22 | mName = name; 23 | } 24 | -------------------------------------------------------------------------------- /src/render/Graphics/GL4/GteGL4IndexBuffer.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | using namespace gte; 11 | 12 | GL4IndexBuffer::GL4IndexBuffer(IndexBuffer const* ibuffer) 13 | : 14 | GL4Buffer(ibuffer, GL_ELEMENT_ARRAY_BUFFER) 15 | { 16 | Initialize(); 17 | } 18 | 19 | GEObject* GL4IndexBuffer::Create(void*, GraphicsObject const* object) 20 | { 21 | if (object->GetType() == GT_INDEX_BUFFER) 22 | { 23 | return new GL4IndexBuffer(static_cast(object)); 24 | } 25 | 26 | qCritical("Invalid object type."); 27 | return nullptr; 28 | } 29 | 30 | void GL4IndexBuffer::Enable() 31 | { 32 | GL::function().glBindBuffer(mType, mGLHandle); 33 | } 34 | 35 | void GL4IndexBuffer::Disable() 36 | { 37 | GL::function().glBindBuffer(mType, 0); 38 | } 39 | -------------------------------------------------------------------------------- /src/render/Graphics/GL4/GteGL4TextureDS.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | using namespace gte; 11 | 12 | GL4TextureDS::GL4TextureDS(TextureDS const* texture) 13 | : 14 | GL4Texture2(texture) 15 | { 16 | } 17 | 18 | GEObject* GL4TextureDS::Create(void*, GraphicsObject const* object) 19 | { 20 | if (object->GetType() == GT_TEXTURE_DS) 21 | { 22 | return new GL4TextureDS(static_cast(object)); 23 | } 24 | 25 | qCritical("Invalid object type."); 26 | return nullptr; 27 | } 28 | 29 | bool GL4TextureDS::CanAutoGenerateMipmaps() const 30 | { 31 | return false; 32 | } 33 | -------------------------------------------------------------------------------- /src/render/Graphics/GL4/GteGL4TextureRT.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | using namespace gte; 11 | 12 | GL4TextureRT::GL4TextureRT(TextureRT const* texture) 13 | : 14 | GL4Texture2(texture) 15 | { 16 | } 17 | 18 | GEObject* GL4TextureRT::Create(void*, GraphicsObject const* object) 19 | { 20 | if (object->GetType() == GT_TEXTURE_RT) 21 | { 22 | return new GL4TextureRT(static_cast(object)); 23 | } 24 | 25 | qCritical("Invalid object type."); 26 | return nullptr; 27 | } 28 | 29 | bool GL4TextureRT::CanAutoGenerateMipmaps() const 30 | { 31 | auto texture = GetTexture(); 32 | 33 | return texture && texture->HasMipmaps() && texture->WantAutogenerateMipmaps(); 34 | } 35 | -------------------------------------------------------------------------------- /src/render/Graphics/GL4/GteGL4VertexBuffer.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | using namespace gte; 11 | 12 | GL4VertexBuffer::GL4VertexBuffer(VertexBuffer const* vbuffer) 13 | : 14 | GL4Buffer(vbuffer, GL_ARRAY_BUFFER) 15 | { 16 | Initialize(); 17 | } 18 | 19 | GEObject* GL4VertexBuffer::Create(void*, GraphicsObject const* object) 20 | { 21 | if (object->GetType() == GT_VERTEX_BUFFER) 22 | { 23 | return new GL4VertexBuffer(static_cast(object)); 24 | } 25 | 26 | qCritical("Invalid object type."); 27 | return nullptr; 28 | } 29 | -------------------------------------------------------------------------------- /src/render/Graphics/GL4/GteGLFunction.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace gte 5 | { 6 | GL4Engine *GL::_engine = nullptr; 7 | QOpenGLExtraFunctions *GL::_instance = nullptr; 8 | 9 | bool GL::initialized() 10 | { 11 | return (_engine != nullptr && _instance != nullptr); 12 | } 13 | 14 | void GL::initialize(QOpenGLContext *context) 15 | { 16 | if (!initialized()){ 17 | _instance = new QOpenGLExtraFunctions(context); 18 | _engine = new GL4Engine(); 19 | } 20 | } 21 | 22 | } -------------------------------------------------------------------------------- /src/render/Graphics/GL4/GteGLSLComputeProgram.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | using namespace gte; 11 | 12 | GLSLComputeProgram::~GLSLComputeProgram() 13 | { 14 | if (GL::function().glIsProgram(mProgramHandle)) 15 | { 16 | if (GL::function().glIsShader(mCShaderHandle)) 17 | { 18 | GL::function().glDetachShader(mProgramHandle, mCShaderHandle); 19 | GL::function().glDeleteShader(mCShaderHandle); 20 | } 21 | 22 | GL::function().glDeleteProgram(mProgramHandle); 23 | } 24 | } 25 | 26 | GLSLComputeProgram::GLSLComputeProgram(GLuint programHandle, GLuint cshaderHandle) 27 | : 28 | mProgramHandle(programHandle), 29 | mCShaderHandle(cshaderHandle), 30 | mReflector(programHandle) 31 | { 32 | } 33 | -------------------------------------------------------------------------------- /src/render/Graphics/GL4/GteGLSLVisualProgram.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | using namespace gte; 11 | 12 | GLSLVisualProgram::~GLSLVisualProgram() 13 | { 14 | if (GL::function().glIsProgram(mProgramHandle)) 15 | { 16 | if (GL::function().glIsShader(mVShaderHandle)) 17 | { 18 | GL::function().glDetachShader(mProgramHandle, mVShaderHandle); 19 | GL::function().glDeleteShader(mVShaderHandle); 20 | } 21 | 22 | if (GL::function().glIsShader(mPShaderHandle)) 23 | { 24 | GL::function().glDetachShader(mProgramHandle, mPShaderHandle); 25 | GL::function().glDeleteShader(mPShaderHandle); 26 | } 27 | 28 | if (GL::function().glIsShader(mGShaderHandle)) 29 | { 30 | GL::function().glDetachShader(mProgramHandle, mGShaderHandle); 31 | GL::function().glDeleteShader(mGShaderHandle); 32 | } 33 | 34 | GL::function().glDeleteProgram(mProgramHandle); 35 | } 36 | } 37 | 38 | GLSLVisualProgram::GLSLVisualProgram(GLuint programHandle, 39 | GLuint vshaderHandle, GLuint pshaderHandle, GLuint gshaderHandle) 40 | : 41 | mProgramHandle(programHandle), 42 | mVShaderHandle(vshaderHandle), 43 | mPShaderHandle(pshaderHandle), 44 | mGShaderHandle(gshaderHandle), 45 | mReflector(programHandle) 46 | { 47 | } 48 | -------------------------------------------------------------------------------- /src/render/Graphics/GL4/GteWGLExtensions.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | void* GetOpenGLFunctionPointer(char const* name) 13 | { 14 | return wglGetProcAddress(name); 15 | } 16 | 17 | template 18 | static void GetWGLFunction(char const* name, PWGLFunction& function) 19 | { 20 | function = (PWGLFunction)wglGetProcAddress(name); 21 | } 22 | 23 | 24 | static PFNWGLSWAPINTERVALEXTPROC swglSwapIntervalEXT = nullptr; 25 | static PFNWGLGETSWAPINTERVALEXTPROC swglGetSwapIntervalEXT = nullptr; 26 | 27 | int __stdcall wglSwapIntervalEXT(int interval) 28 | { 29 | int result; 30 | if (swglSwapIntervalEXT) 31 | { 32 | result = swglSwapIntervalEXT(interval); 33 | } 34 | else 35 | { 36 | assert(false); 37 | result = 0; 38 | } 39 | return result; 40 | } 41 | 42 | int __stdcall wglGetSwapIntervalEXT(void) 43 | { 44 | int result; 45 | if (swglGetSwapIntervalEXT) 46 | { 47 | result = swglGetSwapIntervalEXT(); 48 | } 49 | else 50 | { 51 | assert(false); 52 | result = 0; 53 | } 54 | return result; 55 | } 56 | 57 | void InitializeWGL() 58 | { 59 | GetWGLFunction("wglSwapIntervalEXT", swglSwapIntervalEXT); 60 | GetWGLFunction("wglGetSwapIntervalEXT", swglGetSwapIntervalEXT); 61 | } 62 | 63 | -------------------------------------------------------------------------------- /src/render/Graphics/GteBlendState.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | using namespace gte; 11 | 12 | 13 | BlendState::BlendState() 14 | : 15 | enableAlphaToCoverage(false), 16 | enableIndependentBlend(false), 17 | blendColor({ 0.0f, 0.0f, 0.0f, 0.0f }), 18 | sampleMask(0xFFFFFFFFu) 19 | { 20 | mType = GT_BLEND_STATE; 21 | 22 | for (int i = 0; i < NUM_TARGETS; ++i) 23 | { 24 | Target& trg = target[i]; 25 | trg.enable = false; 26 | trg.srcColor = BM_ONE; 27 | trg.dstColor = BM_ZERO; 28 | trg.opColor = OP_ADD; 29 | trg.srcAlpha = BM_ONE; 30 | trg.dstAlpha = BM_ZERO; 31 | trg.opAlpha = OP_ADD; 32 | trg.mask = CW_ENABLE_ALL; 33 | } 34 | } 35 | 36 | -------------------------------------------------------------------------------- /src/render/Graphics/GteBuffer.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | using namespace gte; 10 | 11 | 12 | Buffer::Buffer(unsigned int numElements, size_t elementSize, 13 | bool createStorage) 14 | : 15 | Resource(numElements, elementSize, createStorage) 16 | { 17 | mType = GT_BUFFER; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /src/render/Graphics/GteComputeProgram.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | using namespace gte; 11 | 12 | 13 | ComputeProgram::~ComputeProgram() 14 | { 15 | } 16 | 17 | ComputeProgram::ComputeProgram() 18 | { 19 | } 20 | 21 | -------------------------------------------------------------------------------- /src/render/Graphics/GteComputeShader.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | using namespace gte; 11 | 12 | 13 | 14 | #if defined(GTE_DEV_OPENGL) 15 | ComputeShader::ComputeShader(GLSLReflection const& reflector) 16 | : 17 | Shader(reflector, GLSLReflection::ST_COMPUTE) 18 | { 19 | mType = GT_COMPUTE_SHADER; 20 | } 21 | 22 | #else 23 | ComputeShader::ComputeShader(HLSLShader const& program) 24 | : 25 | Shader(program) 26 | { 27 | mType = GT_COMPUTE_SHADER; 28 | } 29 | 30 | #endif 31 | 32 | -------------------------------------------------------------------------------- /src/render/Graphics/GteConstantBuffer.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | using namespace gte; 11 | 12 | 13 | ConstantBuffer::ConstantBuffer(size_t numBytes, bool allowDynamicUpdate) 14 | : 15 | Buffer(1, GetRoundedNumBytes(numBytes), true) 16 | { 17 | mType = GT_CONSTANT_BUFFER; 18 | mUsage = (allowDynamicUpdate ? DYNAMIC_UPDATE : IMMUTABLE); 19 | memset(mData, 0, mNumBytes); 20 | } 21 | 22 | bool ConstantBuffer::HasMember(std::string const& name) const 23 | { 24 | auto iter = std::find_if(mLayout.begin(), mLayout.end(), 25 | [&name](MemberLayout const& item){ return name == item.name; }); 26 | return iter != mLayout.end(); 27 | } 28 | 29 | size_t ConstantBuffer::GetRoundedNumBytes(size_t numBytes) 30 | { 31 | if (numBytes > 0) 32 | { 33 | size_t remainder = numBytes % 16; 34 | if (remainder == 0) 35 | { 36 | // The number is already a multiple of 16 bytes. 37 | return numBytes; 38 | } 39 | else 40 | { 41 | // Round up to the nearest multiple of 16 bytes. 42 | return numBytes + 16 - remainder; 43 | } 44 | } 45 | else 46 | { 47 | // At least one register must be allocated. 48 | return 16; 49 | } 50 | } 51 | 52 | -------------------------------------------------------------------------------- /src/render/Graphics/GteDepthStencilState.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | using namespace gte; 11 | 12 | 13 | DepthStencilState::DepthStencilState() 14 | : 15 | depthEnable(true), 16 | writeMask(MASK_ALL), 17 | comparison(LESS_EQUAL), 18 | stencilEnable(false), 19 | stencilReadMask(0xFF), 20 | stencilWriteMask(0xFF), 21 | reference(0) 22 | { 23 | mType = GT_DEPTH_STENCIL_STATE; 24 | 25 | frontFace.fail = OP_KEEP; 26 | frontFace.depthFail = OP_KEEP; 27 | frontFace.pass = OP_KEEP; 28 | frontFace.comparison = ALWAYS; 29 | backFace.fail = OP_KEEP; 30 | backFace.depthFail = OP_KEEP; 31 | backFace.pass = OP_KEEP; 32 | backFace.comparison = ALWAYS; 33 | } 34 | 35 | -------------------------------------------------------------------------------- /src/render/Graphics/GteDrawingState.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | using namespace gte; 11 | 12 | 13 | DrawingState::DrawingState() 14 | { 15 | mType = GT_DRAWING_STATE; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /src/render/Graphics/GteGEDrawTarget.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | using namespace gte; 11 | 12 | GEDrawTarget::~GEDrawTarget() 13 | { 14 | } 15 | 16 | GEDrawTarget::GEDrawTarget(DrawTarget const* gtTarget) 17 | : 18 | mTarget(const_cast(gtTarget)) // conceptual constness 19 | { 20 | } 21 | -------------------------------------------------------------------------------- /src/render/Graphics/GteGEObject.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | using namespace gte; 11 | 12 | GEObject::~GEObject() 13 | { 14 | } 15 | 16 | GEObject::GEObject(GraphicsObject const* gtObject) 17 | : 18 | mGTObject(const_cast(gtObject)), // conceptual constness 19 | mName("") 20 | { 21 | } 22 | -------------------------------------------------------------------------------- /src/render/Graphics/GteGeometryShader.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | using namespace gte; 11 | 12 | #if defined(GTE_DEV_OPENGL) 13 | GeometryShader::GeometryShader(GLSLReflection const& reflector) 14 | : 15 | Shader(reflector, GLSLReflection::ST_GEOMETRY) 16 | { 17 | mType = GT_GEOMETRY_SHADER; 18 | } 19 | #else 20 | 21 | GeometryShader::GeometryShader(HLSLShader const& program) 22 | : 23 | Shader(program) 24 | { 25 | mType = GT_GEOMETRY_SHADER; 26 | } 27 | 28 | #endif 29 | 30 | -------------------------------------------------------------------------------- /src/render/Graphics/GteGraphicsObject.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | //#include 9 | #include 10 | using namespace gte; 11 | 12 | GraphicsObject::~GraphicsObject() 13 | { 14 | msLFDMutex.lock(); 15 | { 16 | for (auto listener : msLFDSet) 17 | { 18 | listener->OnDestroy(this); 19 | } 20 | } 21 | msLFDMutex.unlock(); 22 | } 23 | 24 | GraphicsObject::GraphicsObject() 25 | : 26 | mType(GT_GRAPHICS_OBJECT) 27 | { 28 | } 29 | 30 | void GraphicsObject::SubscribeForDestruction(std::shared_ptr const& listener) 31 | { 32 | msLFDMutex.lock(); 33 | { 34 | msLFDSet.insert(listener); 35 | } 36 | msLFDMutex.unlock(); 37 | } 38 | 39 | void GraphicsObject::UnsubscribeForDestruction(std::shared_ptr const& listener) 40 | { 41 | msLFDMutex.lock(); 42 | { 43 | msLFDSet.erase(listener); 44 | } 45 | msLFDMutex.unlock(); 46 | } 47 | 48 | 49 | std::mutex GraphicsObject::msLFDMutex; 50 | std::set> GraphicsObject::msLFDSet; 51 | -------------------------------------------------------------------------------- /src/render/Graphics/GteIndirectArgumentsBuffer.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | //#include 9 | #include 10 | using namespace gte; 11 | 12 | 13 | IndirectArgumentsBuffer::IndirectArgumentsBuffer(unsigned int numElements, 14 | bool createStorage) 15 | : 16 | Buffer(numElements, 4, createStorage) 17 | { 18 | mType = GT_INDIRECT_ARGUMENTS_BUFFER; 19 | } 20 | 21 | -------------------------------------------------------------------------------- /src/render/Graphics/GteLightCameraGeometry.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | 11 | using namespace gte; 12 | 13 | LightCameraGeometry::LightCameraGeometry() 14 | : 15 | lightModelPosition({ 0.0f, 0.0f, 0.0f, 1.0f }), 16 | lightModelDirection({ 0.0f, 0.0f, -1.0f, 0.0f }), 17 | lightModelUp({ 0.0f, 1.0f, 0.0f, 0.0f }), 18 | lightModelRight({ 1.0f, 0.0f, 0.0f, 0.0f }), 19 | cameraModelPosition({ 0.0f, 0.0f, 0.0f, 1.0f }), 20 | cameraModelDirection({ 0.0f, 0.0f, -1.0f, 0.0f }), 21 | cameraModelUp({ 0.0f, 1.0f, 0.0f, 0.0f }), 22 | cameraModelRight({ 1.0f, 0.0f, 0.0f, 0.0f }) 23 | { 24 | } 25 | -------------------------------------------------------------------------------- /src/render/Graphics/GteLighting.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | #include 11 | using namespace gte; 12 | 13 | Lighting::Lighting() 14 | : 15 | ambient({ 1.0f, 1.0f, 1.0f, 1.0f }), 16 | diffuse({ 1.0f, 1.0f, 1.0f, 1.0f }), 17 | specular({ 1.0f, 1.0f, 1.0f, 1.0f }), 18 | spotCutoff({boost::math::constants::half_pi(), 0.0f, 1.0f, 1.0f }), 19 | attenuation({ 1.0f, 0.0f, 0.0f, 1.0f }) 20 | { 21 | } 22 | -------------------------------------------------------------------------------- /src/render/Graphics/GteMaterial.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | using namespace gte; 11 | 12 | Material::Material() 13 | : 14 | emissive({ 0.0f, 0.0f, 0.0f, 1.0f }), 15 | ambient({ 0.0f, 0.0f, 0.0f, 1.0f }), 16 | diffuse({ 0.0f, 0.0f, 0.0f, 1.0f }), 17 | specular({ 0.0f, 0.0f, 0.0f, 1.0f }) 18 | { 19 | } 20 | -------------------------------------------------------------------------------- /src/render/Graphics/GtePixelShader.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | using namespace gte; 11 | 12 | 13 | 14 | 15 | #if defined(GTE_DEV_OPENGL) 16 | PixelShader::PixelShader(GLSLReflection const& reflector) 17 | : 18 | Shader(reflector, GLSLReflection::ST_PIXEL) 19 | { 20 | mType = GT_PIXEL_SHADER; 21 | } 22 | #else 23 | PixelShader::PixelShader(HLSLShader const& program) 24 | : 25 | Shader(program) 26 | { 27 | mType = GT_PIXEL_SHADER; 28 | } 29 | #endif 30 | 31 | -------------------------------------------------------------------------------- /src/render/Graphics/GteProgramDefines.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | using namespace gte; 11 | 12 | 13 | ProgramDefines::ProgramDefines() 14 | { 15 | } 16 | 17 | void ProgramDefines::Update(std::string const& name, std::string const& value) 18 | { 19 | // If an item already exists with the specified name, update it. 20 | for (auto& definition : mDefinitions) 21 | { 22 | if (name == definition.first) 23 | { 24 | definition.second = value; 25 | return; 26 | } 27 | } 28 | 29 | // The item is new, so append it. 30 | mDefinitions.push_back(std::make_pair(name, value)); 31 | } 32 | 33 | void ProgramDefines::Remove(std::string const& name) 34 | { 35 | for (auto iter = mDefinitions.begin(); iter != mDefinitions.end(); ++iter) 36 | { 37 | if (name == iter->first) 38 | { 39 | mDefinitions.erase(iter); 40 | break; 41 | } 42 | } 43 | } 44 | 45 | void ProgramDefines::Clear() 46 | { 47 | mDefinitions.clear(); 48 | } 49 | 50 | -------------------------------------------------------------------------------- /src/render/Graphics/GteRasterizerState.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | using namespace gte; 11 | 12 | 13 | RasterizerState::RasterizerState() 14 | : 15 | fillMode(FILL_SOLID), 16 | cullMode(CULL_BACK), 17 | frontCCW(true), 18 | depthBias(0), 19 | depthBiasClamp(0.0f), 20 | slopeScaledDepthBias(0.0f), 21 | enableDepthClip(true), 22 | enableScissor(false), 23 | enableMultisample(false), 24 | enableAntialiasedLine(false) 25 | { 26 | mType = GT_RASTERIZER_STATE; 27 | } 28 | 29 | -------------------------------------------------------------------------------- /src/render/Graphics/GteRawBuffer.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | //#include 9 | #include 10 | using namespace gte; 11 | 12 | 13 | RawBuffer::RawBuffer(unsigned int numElements, bool createStorage) 14 | : 15 | Buffer(numElements, 4, createStorage) 16 | { 17 | mType = GT_RAW_BUFFER; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /src/render/Graphics/GteSamplerState.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | using namespace gte; 11 | 12 | 13 | SamplerState::SamplerState() 14 | : 15 | filter(MIN_P_MAG_P_MIP_P), 16 | mipLODBias(0.0f), 17 | maxAnisotropy(1), 18 | comparison(NEVER), 19 | borderColor({ 1.0f, 1.0f, 1.0f, 1.0f }), 20 | minLOD(-std::numeric_limits::max()), 21 | maxLOD(std::numeric_limits::max()) 22 | { 23 | mType = GT_SAMPLER_STATE; 24 | 25 | mode[0] = CLAMP; 26 | mode[1] = CLAMP; 27 | mode[2] = CLAMP; 28 | } 29 | 30 | -------------------------------------------------------------------------------- /src/render/Graphics/GteStructuredBuffer.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | #include 8 | #include 9 | using namespace gte; 10 | 11 | 12 | StructuredBuffer::StructuredBuffer(unsigned int numElements, 13 | size_t elementSize, bool createStorage) 14 | : 15 | Buffer(numElements, elementSize, createStorage), 16 | mCounterType(CT_NONE), 17 | mKeepInternalCount(false) 18 | { 19 | mType = GT_STRUCTURED_BUFFER; 20 | } 21 | 22 | StructuredBuffer::CounterType StructuredBuffer::GetCounterType() const 23 | { 24 | return mCounterType; 25 | } 26 | 27 | void StructuredBuffer::MakeAppendConsume() 28 | { 29 | mCounterType = CT_APPEND_CONSUME; 30 | mUsage = SHADER_OUTPUT; 31 | } 32 | 33 | void StructuredBuffer::MakeCounter() 34 | { 35 | mCounterType = CT_COUNTER; 36 | mUsage = SHADER_OUTPUT; 37 | } 38 | 39 | bool StructuredBuffer::GetKeepInternalCount() const 40 | { 41 | return mKeepInternalCount; 42 | } 43 | 44 | void StructuredBuffer::SetKeepInternalCount(bool keepInternalCount) 45 | { 46 | if (mCounterType != CT_NONE) 47 | { 48 | mKeepInternalCount = keepInternalCount; 49 | } 50 | } 51 | 52 | -------------------------------------------------------------------------------- /src/render/Graphics/GteTexture1.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | using namespace gte; 11 | 12 | 13 | Texture1::Texture1(DFType format, unsigned int length, bool hasMipmaps, 14 | bool createStorage) 15 | : 16 | TextureSingle(format, 1, length, 1, 1, hasMipmaps, createStorage) 17 | { 18 | mType = GT_TEXTURE1; 19 | } 20 | 21 | unsigned int Texture1::GetLength() const 22 | { 23 | return TextureSingle::GetDimension(0); 24 | } 25 | 26 | -------------------------------------------------------------------------------- /src/render/Graphics/GteTexture1Array.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | using namespace gte; 11 | 12 | 13 | Texture1Array::Texture1Array(unsigned int numItems, DFType format, 14 | unsigned int length, bool hasMipmaps, bool createStorage) 15 | : 16 | TextureArray(numItems, format, 1, length, 1, 1, hasMipmaps, 17 | createStorage) 18 | { 19 | mType = GT_TEXTURE1_ARRAY; 20 | } 21 | 22 | unsigned int Texture1Array::GetLength() const 23 | { 24 | return TextureArray::GetDimension(0); 25 | } 26 | 27 | -------------------------------------------------------------------------------- /src/render/Graphics/GteTexture2.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | using namespace gte; 11 | 12 | 13 | Texture2::Texture2(DFType format, unsigned int width, unsigned int height, 14 | bool hasMipmaps, bool createStorage) 15 | : 16 | TextureSingle(format, 2, width, height, 1, hasMipmaps, createStorage), 17 | mShared(false) 18 | { 19 | mType = GT_TEXTURE2; 20 | } 21 | 22 | unsigned int Texture2::GetWidth() const 23 | { 24 | return TextureSingle::GetDimension(0); 25 | } 26 | 27 | unsigned int Texture2::GetHeight() const 28 | { 29 | return TextureSingle::GetDimension(1); 30 | } 31 | 32 | void Texture2::MakeShared() 33 | { 34 | // Shared textures are required to be GPU writable. 35 | mUsage = SHADER_OUTPUT; 36 | mShared = true; 37 | } 38 | 39 | bool Texture2::IsShared() const 40 | { 41 | return mShared; 42 | } 43 | 44 | -------------------------------------------------------------------------------- /src/render/Graphics/GteTexture2Array.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | using namespace gte; 11 | 12 | 13 | Texture2Array::Texture2Array(unsigned int numItems, DFType format, 14 | unsigned int width, unsigned int height, bool hasMipmaps, 15 | bool createStorage) 16 | : 17 | TextureArray(numItems, format, 2, width, height, 1, hasMipmaps, 18 | createStorage) 19 | { 20 | mType = GT_TEXTURE2_ARRAY; 21 | } 22 | 23 | unsigned int Texture2Array::GetWidth() const 24 | { 25 | return TextureArray::GetDimension(0); 26 | } 27 | 28 | unsigned int Texture2Array::GetHeight() const 29 | { 30 | return TextureArray::GetDimension(1); 31 | } 32 | 33 | -------------------------------------------------------------------------------- /src/render/Graphics/GteTexture3.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | using namespace gte; 11 | 12 | 13 | Texture3::Texture3(DFType format, unsigned int width, unsigned int height, 14 | unsigned int thickness, bool hasMipmaps, bool createStorage) 15 | : 16 | TextureSingle(format, 3, width, height, thickness, hasMipmaps, 17 | createStorage) 18 | { 19 | mType = GT_TEXTURE3; 20 | } 21 | 22 | unsigned int Texture3::GetWidth() const 23 | { 24 | return TextureSingle::GetDimension(0); 25 | } 26 | 27 | unsigned int Texture3::GetHeight() const 28 | { 29 | return TextureSingle::GetDimension(1); 30 | } 31 | 32 | unsigned int Texture3::GetThickness() const 33 | { 34 | return TextureSingle::GetDimension(2); 35 | } 36 | 37 | -------------------------------------------------------------------------------- /src/render/Graphics/GteTextureArray.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | using namespace gte; 11 | 12 | 13 | TextureArray::TextureArray(unsigned int numItems, DFType format, 14 | unsigned int numDimensions, unsigned int dim0, unsigned int dim1, 15 | unsigned int dim2, bool hasMipmaps, bool createStorage) 16 | : 17 | Texture(numItems, format, numDimensions, dim0, dim1, dim2, 18 | hasMipmaps, createStorage) 19 | { 20 | mType = GT_TEXTURE_ARRAY; 21 | } 22 | 23 | -------------------------------------------------------------------------------- /src/render/Graphics/GteTextureBuffer.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | using namespace gte; 11 | 12 | 13 | TextureBuffer::TextureBuffer(DFType format, unsigned int numElements, 14 | bool allowDynamicUpdate) 15 | : 16 | Buffer(numElements, DataFormat::GetNumBytesPerStruct(format), true), 17 | mFormat(format) 18 | { 19 | mType = GT_TEXTURE_BUFFER; 20 | mUsage = (allowDynamicUpdate ? DYNAMIC_UPDATE : IMMUTABLE); 21 | memset(mData, 0, mNumBytes); 22 | } 23 | 24 | DFType TextureBuffer::GetFormat() const 25 | { 26 | return mFormat; 27 | } 28 | 29 | bool TextureBuffer::HasMember(std::string const& name) const 30 | { 31 | auto iter = std::find_if(mLayout.begin(), mLayout.end(), 32 | [&name](MemberLayout const& item){ return name == item.name; }); 33 | return iter != mLayout.end(); 34 | } 35 | 36 | -------------------------------------------------------------------------------- /src/render/Graphics/GteTextureCube.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | using namespace gte; 11 | 12 | 13 | TextureCube::TextureCube(DFType format, unsigned int length, bool hasMipmaps, 14 | bool createStorage) 15 | : 16 | TextureArray(CubeFaceCount, format, 2, length, length, 1, hasMipmaps, createStorage) 17 | { 18 | mType = GT_TEXTURE_CUBE; 19 | } 20 | 21 | unsigned int TextureCube::GetLength() const 22 | { 23 | return TextureArray::GetDimension(0); 24 | } 25 | 26 | -------------------------------------------------------------------------------- /src/render/Graphics/GteTextureCubeArray.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | using namespace gte; 11 | 12 | 13 | TextureCubeArray::TextureCubeArray(unsigned int numCubes, DFType format, 14 | unsigned int length, bool hasMipmaps, bool createStorage) 15 | : 16 | TextureArray(CubeFaceCount * numCubes, format, 2, length, length, 1, hasMipmaps, 17 | createStorage), 18 | mNumCubes(numCubes) 19 | { 20 | mType = GT_TEXTURE_CUBE_ARRAY; 21 | } 22 | 23 | unsigned int TextureCubeArray::GetNumCubes() const 24 | { 25 | return mNumCubes; 26 | } 27 | 28 | unsigned int TextureCubeArray::GetLength() const 29 | { 30 | return TextureArray::GetDimension(0); 31 | } 32 | 33 | -------------------------------------------------------------------------------- /src/render/Graphics/GteTextureDS.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | using namespace gte; 11 | 12 | 13 | TextureDS::TextureDS(DFType format, unsigned int width, unsigned int height, 14 | bool createStorage) 15 | : 16 | Texture2(DataFormat::IsDepth(format) ? format : DF_D24_UNORM_S8_UINT, 17 | width, height, false, createStorage) 18 | { 19 | mType = GT_TEXTURE_DS; 20 | } 21 | 22 | -------------------------------------------------------------------------------- /src/render/Graphics/GteTextureRT.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | using namespace gte; 11 | 12 | 13 | TextureRT::TextureRT(DFType format, unsigned int width, unsigned int height, 14 | bool hasMipmaps, bool createStorage) 15 | : 16 | Texture2(format, width, height, hasMipmaps, createStorage) 17 | { 18 | mType = GT_TEXTURE_RT; 19 | } 20 | 21 | -------------------------------------------------------------------------------- /src/render/Graphics/GteTextureSingle.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | using namespace gte; 11 | 12 | 13 | TextureSingle::TextureSingle(DFType format, unsigned int numDimensions, 14 | unsigned int dim0, unsigned int dim1, unsigned int dim2, bool hasMipmaps, 15 | bool createStorage) 16 | : 17 | Texture(1, format, numDimensions, dim0, dim1, dim2, hasMipmaps, 18 | createStorage) 19 | { 20 | mType = GT_TEXTURE_SINGLE; 21 | } 22 | 23 | -------------------------------------------------------------------------------- /src/render/Graphics/GteTypedBuffer.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | using namespace gte; 11 | 12 | 13 | TypedBuffer::TypedBuffer(unsigned int numElements, size_t elementSize, 14 | bool createStorage) 15 | : 16 | Buffer(numElements, elementSize, createStorage) 17 | { 18 | mType = GT_TYPED_BUFFER; 19 | } 20 | 21 | -------------------------------------------------------------------------------- /src/render/Graphics/GteVertexShader.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | using namespace gte; 11 | 12 | #if defined(GTE_DEV_OPENGL) 13 | VertexShader::VertexShader(GLSLReflection const& reflector) 14 | : 15 | Shader(reflector, GLSLReflection::ST_VERTEX) 16 | { 17 | mType = GT_VERTEX_SHADER; 18 | } 19 | #else 20 | VertexShader::VertexShader(HLSLShader const& program) 21 | : 22 | Shader(program) 23 | { 24 | mType = GT_VERTEX_SHADER; 25 | } 26 | #endif 27 | 28 | -------------------------------------------------------------------------------- /src/render/Graphics/GteVisualEffect.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | using namespace gte; 11 | 12 | 13 | VisualEffect::~VisualEffect() 14 | { 15 | } 16 | 17 | VisualEffect::VisualEffect() 18 | { 19 | } 20 | 21 | VisualEffect::VisualEffect(std::shared_ptr const& program) 22 | : 23 | mProgram(program) 24 | { 25 | } 26 | 27 | -------------------------------------------------------------------------------- /src/render/Graphics/GteVisualProgram.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | using namespace gte; 11 | 12 | 13 | VisualProgram::~VisualProgram() 14 | { 15 | } 16 | 17 | VisualProgram::VisualProgram() 18 | { 19 | } 20 | 21 | -------------------------------------------------------------------------------- /src/render/LowLevel/GteWrapper.cpp: -------------------------------------------------------------------------------- 1 | // David Eberly, Geometric Tools, Redmond WA 98052 2 | // Copyright (c) 1998-2016 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // http://www.boost.org/LICENSE_1_0.txt 5 | // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt 6 | // File Version: 2.1.0 (2016/01/25) 7 | 8 | #include 9 | #include 10 | #if defined(WIN32) 11 | #include 12 | #include 13 | #endif 14 | 15 | namespace gte 16 | { 17 | 18 | 19 | void Memcpy(void* target, void const* source, size_t count) 20 | { 21 | #if defined(WIN32) 22 | errno_t result = memcpy_s(target, count, source, count); 23 | (void)result; // 0 on success 24 | #else 25 | memcpy(target, source, count); 26 | #endif 27 | } 28 | 29 | void Memcpy(wchar_t* target, wchar_t const* source, size_t count) 30 | { 31 | #if defined(WIN32) 32 | errno_t result = wmemcpy_s(target, count, source, count); 33 | (void)result; // 0 on success 34 | #else 35 | wmemcpy(target, source, count); 36 | #endif 37 | } 38 | 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/vsculpt/Operator/VCommonConfigOp.cpp: -------------------------------------------------------------------------------- 1 | #include "Operator/VCommonConfigOp.h" 2 | #include "VKernel/VContext.h" 3 | #include "VKernel/VMeshObject.h" 4 | #include "VKernel/VManipulatorNode.h" 5 | #include "VbsQt/VbsDef.h" 6 | using namespace vk; 7 | 8 | VCommonConfigOp::VCommonConfigOp() 9 | {} 10 | 11 | VCommonConfigOp::~VCommonConfigOp() 12 | {} 13 | 14 | bool VCommonConfigOp::poll() 15 | { 16 | return VContext::instance()->commonConfig() != nullptr; 17 | } 18 | 19 | VOperator* VCommonConfigOp::create() 20 | { 21 | return new VCommonConfigOp(); 22 | } 23 | 24 | void VCommonConfigOp::setParam(const QString &name, const QVariant &value) 25 | { 26 | if (name == "manipulator"){ 27 | VManipulatorNode *manipulator = VContext::instance()->scene()->manipulatorNode(); 28 | if (manipulator){ 29 | int mode = value.toInt(); 30 | manipulator->setMode(mode); 31 | } 32 | } 33 | else if (name == "render_mode"){ 34 | VbsDef::RENDER_MODE mode = static_cast(value.toInt()); 35 | VObject *obj = VContext::instance()->scene()->activeObject(); 36 | VMeshObject *mobj = dynamic_cast(obj); 37 | if (mobj){ 38 | mobj->setRenderMode(mode); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/vsculpt/Operator/VOperator.cpp: -------------------------------------------------------------------------------- 1 | #include "VOperator.h" 2 | #include "VViewEditOp.h" 3 | #include "VDropMeshOp.h" 4 | #include "VSculptBrushOp.h" 5 | #include "VView3DEditBoxOp.h" 6 | 7 | QVariant VOperator::param(const QString &name) 8 | { 9 | if (_params.find(name) != _params.end()){ 10 | return _params[name]; 11 | } 12 | return QVariant(QVariant::Invalid); 13 | } 14 | 15 | QVariant VOperator::query(const QString &name) 16 | { 17 | return QVariant(); 18 | } 19 | 20 | QVariantList VOperator::queryList(const QString &name) 21 | { 22 | return QVariantList(); 23 | } 24 | 25 | QVariantMap VOperator::queryMap(const QString &name) 26 | { 27 | return QVariantMap(); 28 | } 29 | 30 | -------------------------------------------------------------------------------- /src/vsculpt/Operator/VSculptConfigOp.cpp: -------------------------------------------------------------------------------- 1 | #include "Operator/VSculptConfigOp.h" 2 | #include "VKernel/VContext.h" 3 | #include "VbsQt/VbsDef.h" 4 | using namespace vk; 5 | 6 | VSculptConfigOp::VSculptConfigOp(vk::VScene *scene) 7 | : 8 | _scene(scene), 9 | _config(scene->sculptConfig()) 10 | {} 11 | 12 | VSculptConfigOp::~VSculptConfigOp() 13 | {} 14 | 15 | bool VSculptConfigOp::poll() 16 | { 17 | VScene *scene = VContext::instance()->scene(); 18 | return scene->sculptConfig() != nullptr; 19 | } 20 | 21 | VOperator* VSculptConfigOp::create() 22 | { 23 | return new VSculptConfigOp(VContext::instance()->scene()); 24 | } 25 | 26 | void VSculptConfigOp::setParam(const QString &name, const QVariant &value) 27 | { 28 | if (name == "brush_radius"){ 29 | _config->setBrushPixelSize(value.toFloat()); 30 | } 31 | else if (name == "brush_strength"){ 32 | _config->setBrushStrength(value.toFloat()); 33 | } 34 | else if (name == "detail_size"){ 35 | _config->setBrushDetailsize(value.toFloat()); 36 | } 37 | else if (name == "dynamic_topology"){ 38 | _config->setBrushDynamicTopology(value.toBool()); 39 | } 40 | else if (name == "brush"){ 41 | VbsDef::BRUSH btype = static_cast(value.toInt()); 42 | _config->setBrush(btype); 43 | } 44 | else if (name == "curve"){ 45 | VbsDef::CURVE ctype = static_cast(value.toInt()); 46 | _config->setFalloffCurve(ctype); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/vsculpt/VOperatorQmlAdaptor.cpp: -------------------------------------------------------------------------------- 1 | #include "VOperatorQmlAdaptor.h" 2 | #include 3 | 4 | VOperatorQmlAdaptor::VOperatorQmlAdaptor() 5 | : 6 | _op(nullptr) 7 | {} 8 | 9 | VOperatorQmlAdaptor::~VOperatorQmlAdaptor() 10 | { 11 | if (_op) delete _op; 12 | } 13 | 14 | VOpTemplate::OP_TYPE VOperatorQmlAdaptor::opid() 15 | { 16 | return _opid; 17 | } 18 | 19 | void VOperatorQmlAdaptor::setOpid(VOpTemplate::OP_TYPE &id) 20 | { 21 | if (id != _opid){ 22 | _opid = id; 23 | 24 | if (_op != nullptr){ 25 | delete _op; 26 | _op = nullptr; 27 | } 28 | else{ 29 | _op = VOpTemplate::op_template(_opid).creatorFunc(); 30 | } 31 | 32 | Q_EMIT opidChanged(); 33 | } 34 | } 35 | 36 | QVariant VOperatorQmlAdaptor::query(const QString &name) 37 | { 38 | if (_op) 39 | return _op->query(name); 40 | else 41 | return QVariant(); 42 | } 43 | 44 | void VOperatorQmlAdaptor::setParam(const QString &name, const QVariant &val) 45 | { 46 | if (_op) 47 | _op->setParam(name, val); 48 | } 49 | 50 | Q_INVOKABLE void VOperatorQmlAdaptor::invoke() 51 | { 52 | if (_op) 53 | _op->invoke(nullptr); 54 | } 55 | 56 | Q_INVOKABLE void VOperatorQmlAdaptor::execute() 57 | { 58 | if (_op) 59 | _op->execute(); 60 | } 61 | 62 | Q_INVOKABLE void VOperatorQmlAdaptor::cancel() 63 | { 64 | if (_op) 65 | _op->cancel(); 66 | } 67 | 68 | --------------------------------------------------------------------------------