├── strategy.md ├── Homeworks ├── 0_CppPratices │ ├── project │ │ ├── data │ │ │ ├── P3.txt │ │ │ ├── P4.txt │ │ │ ├── P6.txt │ │ │ ├── P1.txt │ │ │ ├── P2.txt │ │ │ └── P5.txt │ │ ├── src │ │ │ ├── executables │ │ │ │ ├── 1_BasicDArray │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ └── main.cpp │ │ │ │ ├── 2_EfficientDArray │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ └── main.cpp │ │ │ │ ├── 4_list_Polynomial │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ └── main.cpp │ │ │ │ └── 5_map_Polynomial │ │ │ │ │ └── CMakeLists.txt │ │ │ └── libraries │ │ │ │ ├── static │ │ │ │ └── CMakeLists.txt │ │ │ │ └── shared │ │ │ │ └── CMakeLists.txt │ │ ├── CMakeLists.txt │ │ └── cmake │ │ │ └── InitUCMake.cmake │ ├── samples │ │ ├── data │ │ │ ├── P3.txt │ │ │ ├── P4.txt │ │ │ ├── P6.txt │ │ │ ├── P1.txt │ │ │ ├── P2.txt │ │ │ └── P5.txt │ │ ├── src │ │ │ ├── executables │ │ │ │ ├── 1_BasicDArray │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ └── main.cpp │ │ │ │ ├── 2_EfficientDArray │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ └── main.cpp │ │ │ │ ├── 3_TemplateDArray │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ └── main.cpp │ │ │ │ ├── 4_list_Polynomial │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ └── main.cpp │ │ │ │ └── 5_map_Polynomial │ │ │ │ │ └── CMakeLists.txt │ │ │ └── libraries │ │ │ │ ├── static │ │ │ │ └── CMakeLists.txt │ │ │ │ └── shared │ │ │ │ └── CMakeLists.txt │ │ ├── CMakeLists.txt │ │ └── cmake │ │ │ └── InitUCMake.cmake │ └── documents │ │ ├── 1_BasicDArray │ │ ├── C2Cpp │ │ │ ├── bin │ │ │ │ └── README.md │ │ │ ├── src │ │ │ │ ├── Array5 │ │ │ │ │ ├── Array.cpp │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ └── main.cpp │ │ │ │ ├── Array │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ └── test.cpp │ │ │ │ ├── Array0 │ │ │ │ │ └── CMakeLists.txt │ │ │ │ ├── Array1.0 │ │ │ │ │ └── CMakeLists.txt │ │ │ │ ├── Array1.1 │ │ │ │ │ └── CMakeLists.txt │ │ │ │ ├── Array2 │ │ │ │ │ └── CMakeLists.txt │ │ │ │ ├── Array3 │ │ │ │ │ └── CMakeLists.txt │ │ │ │ └── Array4 │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ ├── main.cpp │ │ │ │ │ └── Array.h │ │ │ ├── CMakeLists.txt │ │ │ ├── README.md │ │ │ └── cmake │ │ │ │ └── InitUCMake.cmake │ │ └── README.md │ │ ├── README.md │ │ ├── 3_TemplateDArray │ │ └── README.md │ │ └── 5_map_Polynomial │ │ └── README.md ├── 4_MinSurfMeshPara │ ├── project │ │ ├── src │ │ │ ├── Basic │ │ │ │ ├── Sampler │ │ │ │ │ ├── Sampler2D.cpp │ │ │ │ │ ├── Sampler3D.cpp │ │ │ │ │ ├── AliasMethod.cpp │ │ │ │ │ ├── CosHsSample3D.cpp │ │ │ │ │ └── UniformGridSampler2D.cpp │ │ │ │ ├── ShapeMesh │ │ │ │ │ ├── desktop.ini │ │ │ │ │ ├── SphereMesh.cpp │ │ │ │ │ ├── CapsuleMesh.cpp │ │ │ │ │ └── ShapeMesh.cpp │ │ │ │ ├── Parallel.cpp │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── Operation │ │ │ │ │ └── OpQueue.cpp │ │ │ │ ├── ImgPixelSet.cpp │ │ │ │ └── Math.cpp │ │ │ ├── App │ │ │ │ └── UEngine │ │ │ │ │ ├── .gitignore │ │ │ │ │ ├── UEngine.qrc │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ ├── UEngine.cpp │ │ │ │ │ ├── GenScene.h │ │ │ │ │ ├── main.cpp │ │ │ │ │ └── UEngine.h │ │ │ ├── Engine │ │ │ │ ├── Intersector │ │ │ │ │ └── Intersector.cpp │ │ │ │ ├── RTX │ │ │ │ │ ├── Film.h │ │ │ │ │ ├── BVHNode.h │ │ │ │ │ ├── BVHNode.cpp │ │ │ │ │ ├── FilmTile.h │ │ │ │ │ ├── FilmTile.cpp │ │ │ │ │ ├── RTX_Renderer.cpp │ │ │ │ │ └── Film.cpp │ │ │ │ ├── Scene │ │ │ │ │ ├── SObjLoader.h │ │ │ │ │ ├── Component.cpp │ │ │ │ │ ├── SimpleLoader.h │ │ │ │ │ ├── CmptLight.cpp │ │ │ │ │ └── AssimpLoader.h │ │ │ │ ├── Viewer │ │ │ │ │ ├── Raster.cpp │ │ │ │ │ ├── EnvGenerator.cpp │ │ │ │ │ ├── DLDM_Generator.cpp │ │ │ │ │ ├── ForwardRaster.cpp │ │ │ │ │ ├── PLDM_Generator.cpp │ │ │ │ │ ├── SLDM_Generator.cpp │ │ │ │ │ ├── Picker.h │ │ │ │ │ ├── WireframeRaster.cpp │ │ │ │ │ └── Picker.cpp │ │ │ │ ├── MeshEdit │ │ │ │ │ ├── Simulate.cpp │ │ │ │ │ └── Paramaterize.cpp │ │ │ │ ├── Primitive │ │ │ │ │ ├── TriMesh.cpp │ │ │ │ │ ├── Sphere.cpp │ │ │ │ │ └── Triangle.cpp │ │ │ │ ├── Filter │ │ │ │ │ ├── FilterSinc.cpp │ │ │ │ │ └── FilterMitchell.cpp │ │ │ │ ├── Light │ │ │ │ │ ├── DirectionalLight.cpp │ │ │ │ │ ├── PointLight.cpp │ │ │ │ │ ├── DiskLight.cpp │ │ │ │ │ ├── SphereLight.cpp │ │ │ │ │ ├── CapsuleLight.cpp │ │ │ │ │ ├── SpotLight.cpp │ │ │ │ │ └── AreaLight.cpp │ │ │ │ ├── Material │ │ │ │ │ ├── BSDF_Glass.cpp │ │ │ │ │ ├── BSDF_Mirror.cpp │ │ │ │ │ ├── BSDF.cpp │ │ │ │ │ └── Beckmann.cpp │ │ │ │ └── CMakeLists.txt │ │ │ ├── UI │ │ │ │ ├── Grid.cpp │ │ │ │ ├── Attribute.cpp │ │ │ │ ├── Hierarchy.cpp │ │ │ │ └── CMakeLists.txt │ │ │ ├── OpenGL │ │ │ │ ├── VAO.cpp │ │ │ │ ├── Texture.cpp │ │ │ │ └── CMakeLists.txt │ │ │ └── Qt │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── OpThread.cpp │ │ ├── data │ │ │ ├── .gitignore │ │ │ └── shaders │ │ │ │ ├── .gitignore │ │ │ │ ├── README.md │ │ │ │ ├── Common │ │ │ │ ├── empty.fs │ │ │ │ ├── basic.fs │ │ │ │ ├── basic_T2.fs │ │ │ │ ├── basic_P3.vs │ │ │ │ ├── MVP_P3.vs │ │ │ │ ├── basic_P2T2.vs │ │ │ │ ├── camera.h │ │ │ │ ├── basic_P3T2.vs │ │ │ │ ├── postProcess.fs │ │ │ │ ├── basic_P3N3.vs │ │ │ │ ├── basic_P3N3_invN.vs │ │ │ │ ├── basic_P3N3T2.vs │ │ │ │ ├── basic_P3N3T2_invN.vs │ │ │ │ ├── basic_P3N3T2T3.vs │ │ │ │ └── interpolation.fs │ │ │ │ ├── Engine │ │ │ │ ├── DirectionalLight │ │ │ │ │ ├── genDepth.fs │ │ │ │ │ └── genDepth.vs │ │ │ │ ├── Light │ │ │ │ │ ├── AreaLight.h │ │ │ │ │ ├── DiskLight.h │ │ │ │ │ ├── PointLight.h │ │ │ │ │ ├── SphereLight.h │ │ │ │ │ ├── SpotLight.h │ │ │ │ │ └── CapsuleLight.h │ │ │ │ ├── PointLight │ │ │ │ │ ├── genDepth.vs │ │ │ │ │ ├── genDepth.fs │ │ │ │ │ └── genDepth.gs │ │ │ │ ├── IBL │ │ │ │ │ ├── cubemap.vs │ │ │ │ │ ├── prefilter.fs │ │ │ │ │ ├── brdf.fs │ │ │ │ │ ├── irradiance_convolution.fs │ │ │ │ │ └── equirectangular_to_cubemap.fs │ │ │ │ ├── DeferredPipeline │ │ │ │ │ ├── postProcess.fs │ │ │ │ │ ├── GBuffer_Emission.fs │ │ │ │ │ └── GBuffer_Diffuse.fs │ │ │ │ ├── Skybox │ │ │ │ │ ├── skybox.vs │ │ │ │ │ └── skybox.fs │ │ │ │ └── BRDF │ │ │ │ │ └── Diffuse.h │ │ │ │ └── Math │ │ │ │ ├── line.h │ │ │ │ ├── quat.h │ │ │ │ ├── basic.h │ │ │ │ ├── plane.h │ │ │ │ ├── sample.h │ │ │ │ ├── Segment.h │ │ │ │ └── intersect.h │ │ ├── include │ │ │ ├── .gitignore │ │ │ ├── Basic │ │ │ │ ├── Math.h │ │ │ │ ├── Node.h │ │ │ │ ├── Timer.h │ │ │ │ ├── HeapObj.h │ │ │ │ ├── LStorage.h │ │ │ │ ├── Op │ │ │ │ │ ├── LambdaOp.h │ │ │ │ │ ├── Op.h │ │ │ │ │ └── OpQueue.h │ │ │ │ ├── Sampler │ │ │ │ │ ├── Sampler2D.h │ │ │ │ │ ├── UniformGridSampler2D.h │ │ │ │ │ ├── Sampler3D.h │ │ │ │ │ ├── CosHsSampler3D.h │ │ │ │ │ ├── BasicSampler.h │ │ │ │ │ └── AliasMethod.h │ │ │ │ ├── ImgPixelSet.h │ │ │ │ ├── ArgManager.h │ │ │ │ ├── ShapeMesh │ │ │ │ │ ├── ShapeMesh.h │ │ │ │ │ ├── PlaneMesh.h │ │ │ │ │ ├── CubeMesh.h │ │ │ │ │ ├── DiskMesh.h │ │ │ │ │ ├── SphereMesh.h │ │ │ │ │ └── CapsuleMesh.h │ │ │ │ ├── TypeMap.h │ │ │ │ ├── Array2D.h │ │ │ │ ├── Geometry.h │ │ │ │ └── File.h │ │ │ ├── OpenGL │ │ │ │ └── Camera.h │ │ │ ├── UI │ │ │ │ ├── Hierarchy.h │ │ │ │ └── Setting.h │ │ │ ├── Engine │ │ │ │ ├── Light │ │ │ │ │ ├── Light.h │ │ │ │ │ ├── AreaLight.h │ │ │ │ │ ├── DiskLight.h │ │ │ │ │ ├── PointLight.h │ │ │ │ │ ├── SphereLight.h │ │ │ │ │ ├── SpotLight.h │ │ │ │ │ ├── CapsuleLight.h │ │ │ │ │ ├── DirectionalLight.h │ │ │ │ │ └── InfiniteAreaLight.h │ │ │ │ ├── Material │ │ │ │ │ ├── GGX.h │ │ │ │ │ ├── Beckmann.h │ │ │ │ │ ├── SchlickGGX.h │ │ │ │ │ ├── BSDF_Frostbite.h │ │ │ │ │ ├── BSDF_MetalWorkflow.h │ │ │ │ │ ├── MicrofacetDistribution.h │ │ │ │ │ ├── AllBSDFs.h │ │ │ │ │ ├── Material.h │ │ │ │ │ ├── Gooch.h │ │ │ │ │ └── BSDF_Mirror.h │ │ │ │ ├── Scene │ │ │ │ │ ├── SObj.h │ │ │ │ │ ├── AllComponents.h │ │ │ │ │ ├── Component.h │ │ │ │ │ ├── CmptMaterial.h │ │ │ │ │ ├── CmptGeometry.h │ │ │ │ │ └── CmptLight.h │ │ │ │ ├── Viewer │ │ │ │ │ ├── Raster.h │ │ │ │ │ ├── BVHAccel.h │ │ │ │ │ ├── PathTracer.h │ │ │ │ │ ├── RayTracer.h │ │ │ │ │ ├── Ray.h │ │ │ │ │ ├── WireframeRaster.h │ │ │ │ │ └── Roamer.h │ │ │ │ ├── MeshEdit │ │ │ │ │ ├── Simulate.h │ │ │ │ │ ├── Paramaterize.h │ │ │ │ │ ├── Glue.h │ │ │ │ │ └── MST.h │ │ │ │ ├── Primitive │ │ │ │ │ ├── Capsule.h │ │ │ │ │ ├── Plane.h │ │ │ │ │ ├── Sphere.h │ │ │ │ │ ├── Triangle.h │ │ │ │ │ ├── Primitive.h │ │ │ │ │ ├── Shape.h │ │ │ │ │ └── Disk.h │ │ │ │ ├── Intersector │ │ │ │ │ ├── VisibilityChecker.h │ │ │ │ │ ├── ClosestIntersector.h │ │ │ │ │ └── Intersector.h │ │ │ │ ├── Filter │ │ │ │ │ ├── FilterBox.h │ │ │ │ │ ├── ImgFilter.h │ │ │ │ │ ├── FilterTriangle.h │ │ │ │ │ ├── FilterSinc.h │ │ │ │ │ ├── FilterMitchell.h │ │ │ │ │ └── FilterGaussian.h │ │ │ │ └── Engine.h │ │ │ ├── _deps │ │ │ │ └── README.md │ │ │ └── Qt │ │ │ │ ├── OpThread.h │ │ │ │ └── PaintImgOpCreator.h │ │ └── config │ │ │ └── ROOT_PATH.h.in │ ├── README.md │ └── documents │ │ └── obj.md ├── 7_SimulationTaichi │ ├── project │ │ ├── src │ │ │ ├── app │ │ │ │ └── CMakeLists.txt │ │ │ └── example │ │ │ │ ├── 03_cubes │ │ │ │ └── CMakeLists.txt │ │ │ │ ├── 00_mls_mpm88 │ │ │ │ └── CMakeLists.txt │ │ │ │ ├── 01_mls_mpm88_x │ │ │ │ └── CMakeLists.txt │ │ │ │ ├── 02_snowball │ │ │ │ └── CMakeLists.txt │ │ │ │ └── 04_fountain │ │ │ │ └── CMakeLists.txt │ │ └── README.md │ └── README.md ├── 8_Shader │ ├── project │ │ ├── src │ │ │ ├── tool │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── SimpleLoader.h │ │ │ └── app │ │ │ │ ├── 0_displacement_normal │ │ │ │ └── CMakeLists.txt │ │ │ │ ├── 1_denoise │ │ │ │ └── CMakeLists.txt │ │ │ │ └── 2_shadow │ │ │ │ └── CMakeLists.txt │ │ ├── data │ │ │ ├── shaders │ │ │ │ ├── empty.frag │ │ │ │ ├── p3.vert │ │ │ │ ├── p3t2n3.vert │ │ │ │ ├── p3t2n3_denoise.vert │ │ │ │ └── dn.vert │ │ │ ├── models │ │ │ │ └── CMakeLists.txt │ │ │ └── textures │ │ │ │ └── CMakeLists.txt │ │ └── include │ │ │ └── _deps │ │ │ └── CMakeLists.txt │ └── README.md ├── 1_MiniDraw │ ├── documents │ │ ├── example │ │ │ ├── src │ │ │ │ └── example │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ ├── example.qrc │ │ │ │ │ ├── main.cpp │ │ │ │ │ ├── example.h │ │ │ │ │ └── example.cpp │ │ │ ├── CMakeLists.txt │ │ │ ├── README.md │ │ │ └── cmake │ │ │ │ └── InitUCMake.cmake │ │ └── hello │ │ │ ├── src │ │ │ └── hello │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── main.cpp │ │ │ │ ├── mainwindow.h │ │ │ │ ├── mainwindow.ui │ │ │ │ └── mainwindow.cpp │ │ │ ├── CMakeLists.txt │ │ │ ├── README.md │ │ │ └── cmake │ │ │ └── InitUCMake.cmake │ ├── project │ │ ├── src │ │ │ └── App │ │ │ │ ├── minidraw.qrc │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── Line.h │ │ │ │ ├── Rect.h │ │ │ │ ├── Line.cpp │ │ │ │ ├── shape.cpp │ │ │ │ ├── Rect.cpp │ │ │ │ ├── main.cpp │ │ │ │ ├── shape.h │ │ │ │ ├── viewwidget.ui │ │ │ │ ├── minidraw.h │ │ │ │ ├── minidraw.ui │ │ │ │ └── viewwidget.h │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ └── cmake │ │ │ └── InitUCMake.cmake │ └── README.md ├── 2_ImageWarping │ ├── project │ │ ├── data │ │ │ └── test.png │ │ ├── src │ │ │ ├── App │ │ │ │ ├── Resources │ │ │ │ │ └── images │ │ │ │ │ │ ├── new.jpg │ │ │ │ │ │ ├── open.jpg │ │ │ │ │ │ └── save.jpg │ │ │ │ ├── main.cpp │ │ │ │ ├── mainwindow.qrc │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── mainwindow.ui │ │ │ │ └── ImageWidget.h │ │ │ └── _deps │ │ │ │ └── eigen │ │ │ │ └── CMakeLists.txt │ │ ├── CMakeLists.txt │ │ ├── cmake │ │ │ └── InitUCMake.cmake │ │ └── README.md │ └── documents │ │ ├── ann_example │ │ ├── src │ │ │ └── test │ │ │ │ └── CMakeLists.txt │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ └── cmake │ │ │ └── InitUCMake.cmake │ │ └── eigen_example │ │ ├── src │ │ ├── test │ │ │ └── 00_LinearEquation │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── main.cpp │ │ └── _deps │ │ │ └── eigen │ │ │ └── CMakeLists.txt │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ └── cmake │ │ └── InitUCMake.cmake ├── 9_PathTracing │ ├── project │ │ ├── src │ │ │ ├── PathTracer │ │ │ │ └── CMakeLists.txt │ │ │ └── UEditor │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── Editor.h │ │ │ │ ├── Cmpt │ │ │ │ ├── ArcBall.h │ │ │ │ ├── Roamer.h │ │ │ │ ├── PathTracerAgency.h │ │ │ │ ├── Hierarchy.h │ │ │ │ ├── Inspector.h │ │ │ │ └── detail │ │ │ │ │ └── Hierarchy.inl │ │ │ │ └── GenScene.h │ │ ├── data │ │ │ ├── shaders │ │ │ │ ├── img.fs │ │ │ │ ├── p2t2.vs │ │ │ │ ├── env.vs │ │ │ │ ├── p3t2.vs │ │ │ │ ├── postprocess.fs │ │ │ │ ├── env.fs │ │ │ │ ├── light.fs │ │ │ │ └── p3t2n3t3.vs │ │ │ └── textures │ │ │ │ └── CMakeLists.txt │ │ └── CMakeLists.txt │ └── README.md ├── 6_MassSpring │ ├── documents │ │ └── tetgen │ │ │ ├── data │ │ │ ├── cube.stl │ │ │ └── cube.poly │ │ │ ├── src │ │ │ ├── TetGene │ │ │ │ ├── Tet_generate.cpp │ │ │ │ ├── main.cpp │ │ │ │ ├── Tet_generate.h │ │ │ │ ├── globalFunctions.h │ │ │ │ └── CMakeLists.txt │ │ │ └── CMakeLists.txt │ │ │ └── README.md │ ├── README.md │ └── project │ │ └── README.md ├── 3_PoissonImageEditing │ ├── documents │ │ ├── opencv_example │ │ │ ├── src │ │ │ │ └── test │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ ├── Resources │ │ │ │ │ └── images │ │ │ │ │ │ ├── open.jpg │ │ │ │ │ │ └── save.jpg │ │ │ │ │ ├── mainwindow.qrc │ │ │ │ │ ├── main.cpp │ │ │ │ │ └── mainwindow.ui │ │ │ ├── CMakeLists.txt │ │ │ └── cmake │ │ │ │ └── InitUCMake.cmake │ │ └── ScanningLine.md │ ├── project │ │ ├── src │ │ │ └── App │ │ │ │ ├── Resources │ │ │ │ └── images │ │ │ │ │ ├── open.jpg │ │ │ │ │ └── save.jpg │ │ │ │ ├── mainwindow.qrc │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── main.cpp │ │ │ │ ├── ChildWindow.cpp │ │ │ │ ├── ChildWindow.h │ │ │ │ └── mainwindow.ui │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ └── cmake │ │ │ └── InitUCMake.cmake │ └── README.md └── 5_ARAP │ ├── README.md │ └── project │ └── README.md ├── .gitignore ├── Softwares └── Qt.md └── LICENSE /strategy.md: -------------------------------------------------------------------------------- 1 | # 攻略 2 | 3 | 暂无内容。 4 | -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/project/data/P3.txt: -------------------------------------------------------------------------------- 1 | P 2 2 | 1 2 3 | 4 -3 -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/project/data/P4.txt: -------------------------------------------------------------------------------- 1 | P 2 2 | 1 4 3 | 4 -3 -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/project/data/P6.txt: -------------------------------------------------------------------------------- 1 | P 2 2 | 2 4 3 | 3 -2 -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/samples/data/P3.txt: -------------------------------------------------------------------------------- 1 | P 2 2 | 1 2 3 | 4 -3 -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/samples/data/P4.txt: -------------------------------------------------------------------------------- 1 | P 2 2 | 1 4 3 | 4 -3 -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/samples/data/P6.txt: -------------------------------------------------------------------------------- 1 | P 2 2 | 2 4 3 | 3 -2 -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Basic/Sampler/Sampler2D.cpp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Basic/Sampler/Sampler3D.cpp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/.gitignore: -------------------------------------------------------------------------------- 1 | out/ 2 | *.txt 3 | -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/documents/1_BasicDArray/C2Cpp/bin/README.md: -------------------------------------------------------------------------------- 1 | 程序默认的工作路径 -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/App/UEngine/.gitignore: -------------------------------------------------------------------------------- 1 | Resources/ 2 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Engine/Intersector/Intersector.cpp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Homeworks/7_SimulationTaichi/project/src/app/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_AddTarget(MODE "EXE" TEST ON) 2 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/.gitignore: -------------------------------------------------------------------------------- 1 | App/RTGIwRRF/ 2 | CppUtil/ 3 | _DEBUG_* 4 | -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/documents/1_BasicDArray/C2Cpp/src/Array5/Array.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "Array.h" 3 | 4 | -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/project/data/P1.txt: -------------------------------------------------------------------------------- 1 | P 8 2 | 0 2 3 | 5 -3 4 | 12 5 5 | 2 6 6 | 5 7 7 | 3 -4 8 | 2 9 9 | 2 2 -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/samples/data/P1.txt: -------------------------------------------------------------------------------- 1 | P 8 2 | 0 2 3 | 5 -3 4 | 12 5 5 | 2 6 6 | 5 7 7 | 3 -4 8 | 2 9 9 | 2 2 -------------------------------------------------------------------------------- /Homeworks/7_SimulationTaichi/project/src/example/03_cubes/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_AddTarget(MODE "EXE" TEST ON) 2 | -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/project/data/P2.txt: -------------------------------------------------------------------------------- 1 | P 8 2 | 0 4 3 | 4 -3 4 | 11 4 5 | 3 -4 6 | 4 7 7 | 7 -4 8 | 4 -8 9 | 6 4 -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/samples/data/P2.txt: -------------------------------------------------------------------------------- 1 | P 8 2 | 0 4 3 | 4 -3 4 | 11 4 5 | 3 -4 6 | 4 7 7 | 7 -4 8 | 4 -8 9 | 6 4 -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Basic/ShapeMesh/desktop.ini: -------------------------------------------------------------------------------- 1 | [LocalizedFileNames] 2 | Cube.cpp=@Cube.cpp,0 3 | -------------------------------------------------------------------------------- /Homeworks/7_SimulationTaichi/project/src/example/00_mls_mpm88/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_AddTarget(MODE "EXE" TEST ON) 2 | -------------------------------------------------------------------------------- /Homeworks/7_SimulationTaichi/project/src/example/01_mls_mpm88_x/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_AddTarget(MODE "EXE" TEST ON) 2 | -------------------------------------------------------------------------------- /Homeworks/7_SimulationTaichi/project/src/example/02_snowball/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_AddTarget(MODE "EXE" TEST ON) 2 | -------------------------------------------------------------------------------- /Homeworks/7_SimulationTaichi/project/src/example/04_fountain/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_AddTarget(MODE "EXE" TEST ON) 2 | -------------------------------------------------------------------------------- /Homeworks/8_Shader/project/src/tool/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_AddTarget(MODE "LIB" LIBS "Ubpa::UGM_core;Ubpa::UGL_core") 2 | -------------------------------------------------------------------------------- /Homeworks/1_MiniDraw/documents/example/src/example/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_AddTarget(MODE "EXE" QT ON LIBS "Qt5::Widgets") 2 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/README.md: -------------------------------------------------------------------------------- 1 | 引擎内部实现了 `#include` 功能,生成的 `_DEBUG_*.h` 文件是用于 debug 的 2 | 3 | -------------------------------------------------------------------------------- /Homeworks/8_Shader/project/data/shaders/empty.frag: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | void main() 4 | { 5 | // empty 6 | } 7 | -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/project/src/executables/1_BasicDArray/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_AddTarget( 2 | TEST 3 | MODE EXE 4 | ) 5 | -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/samples/src/executables/1_BasicDArray/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_AddTarget( 2 | TEST 3 | MODE EXE 4 | ) 5 | -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/documents/1_BasicDArray/C2Cpp/src/Array/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_AddTarget( 2 | TEST 3 | MODE EXE 4 | ) 5 | -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/documents/1_BasicDArray/C2Cpp/src/Array0/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_AddTarget( 2 | TEST 3 | MODE EXE 4 | ) 5 | -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/documents/1_BasicDArray/C2Cpp/src/Array1.0/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_AddTarget( 2 | TEST 3 | MODE EXE 4 | ) 5 | -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/documents/1_BasicDArray/C2Cpp/src/Array1.1/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_AddTarget( 2 | TEST 3 | MODE EXE 4 | ) 5 | -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/documents/1_BasicDArray/C2Cpp/src/Array2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_AddTarget( 2 | TEST 3 | MODE EXE 4 | ) 5 | -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/documents/1_BasicDArray/C2Cpp/src/Array3/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_AddTarget( 2 | TEST 3 | MODE EXE 4 | ) 5 | -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/documents/1_BasicDArray/C2Cpp/src/Array4/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_AddTarget( 2 | TEST 3 | MODE EXE 4 | ) 5 | -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/documents/1_BasicDArray/C2Cpp/src/Array5/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_AddTarget( 2 | TEST 3 | MODE EXE 4 | ) 5 | -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/project/src/executables/2_EfficientDArray/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_AddTarget( 2 | TEST 3 | MODE EXE 4 | ) 5 | -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/samples/src/executables/2_EfficientDArray/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_AddTarget( 2 | TEST 3 | MODE EXE 4 | ) 5 | -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/samples/src/executables/3_TemplateDArray/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_AddTarget( 2 | TEST 3 | MODE EXE 4 | ) 5 | -------------------------------------------------------------------------------- /Homeworks/1_MiniDraw/project/src/App/minidraw.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Common/empty.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | in vec4 FragPos; 3 | 4 | void main() 5 | { 6 | } -------------------------------------------------------------------------------- /Homeworks/1_MiniDraw/documents/example/src/example/example.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Homeworks/1_MiniDraw/project/src/App/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_AddTarget( 2 | TEST 3 | QT 4 | MODE EXE 5 | LIB 6 | Qt5::Widgets 7 | ) 8 | -------------------------------------------------------------------------------- /Homeworks/2_ImageWarping/project/data/test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/2_ImageWarping/project/data/test.png -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/App/UEngine/UEngine.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Homeworks/9_PathTracing/project/src/PathTracer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_AddTarget( 2 | MODE STATIC 3 | LIB 4 | Ubpa::UEngine_core 5 | ) 6 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/.gitignore: -------------------------------------------------------------------------------- 1 | glad/ 2 | glm/ 3 | KHR/ 4 | GLFW/glfw3.h 5 | GLFW/glfw3native.h 6 | Eigen/ 7 | HEMesh/ 8 | -------------------------------------------------------------------------------- /Homeworks/1_MiniDraw/documents/hello/src/hello/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_AddTarget( 2 | TEST 3 | QT 4 | MODE EXE 5 | LIB 6 | Qt5::Widgets 7 | ) 8 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/UI/Grid.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/src/UI/Grid.cpp -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/project/data/P5.txt: -------------------------------------------------------------------------------- 1 | P 10 2 | 3 -3 3 | 2 3 4 | 10 40 5 | 30 -14 6 | 24 17 7 | 71 -24 8 | 42 -18 9 | 61 24 10 | 9 -45 11 | 2 -2 -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/samples/data/P5.txt: -------------------------------------------------------------------------------- 1 | P 10 2 | 3 -3 3 | 2 3 4 | 10 40 5 | 30 -14 6 | 24 17 7 | 71 -24 8 | 42 -18 9 | 61 24 10 | 9 -45 11 | 2 -2 -------------------------------------------------------------------------------- /Homeworks/2_ImageWarping/documents/ann_example/src/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_AddTarget( 2 | TEST 3 | MODE EXE 4 | LIB 5 | Ubpa::UANN_ann 6 | ) 7 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Engine/DirectionalLight/genDepth.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | in vec4 FragPos; 3 | 4 | void main() 5 | { 6 | } -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/OpenGL/VAO.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/src/OpenGL/VAO.cpp -------------------------------------------------------------------------------- /Homeworks/6_MassSpring/documents/tetgen/data/cube.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/6_MassSpring/documents/tetgen/data/cube.stl -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/documents/1_BasicDArray/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/0_CppPratices/documents/1_BasicDArray/README.md -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Basic/Math.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/include/Basic/Math.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Basic/Node.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/include/Basic/Node.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Basic/Timer.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/include/Basic/Timer.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Engine/RTX/Film.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/src/Engine/RTX/Film.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/UI/Attribute.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/src/UI/Attribute.cpp -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/UI/Hierarchy.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/src/UI/Hierarchy.cpp -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Math/line.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/data/shaders/Math/line.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Math/quat.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/data/shaders/Math/quat.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Basic/HeapObj.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/include/Basic/HeapObj.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Basic/LStorage.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/include/Basic/LStorage.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/OpenGL/Camera.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/include/OpenGL/Camera.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/UI/Hierarchy.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/include/UI/Hierarchy.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Engine/RTX/BVHNode.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/src/Engine/RTX/BVHNode.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/OpenGL/Texture.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/src/OpenGL/Texture.cpp -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Math/basic.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/data/shaders/Math/basic.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Math/plane.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/data/shaders/Math/plane.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Math/sample.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/data/shaders/Math/sample.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Engine/RTX/BVHNode.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/src/Engine/RTX/BVHNode.cpp -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Engine/RTX/FilmTile.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/src/Engine/RTX/FilmTile.h -------------------------------------------------------------------------------- /Homeworks/2_ImageWarping/project/src/App/Resources/images/new.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/2_ImageWarping/project/src/App/Resources/images/new.jpg -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Math/Segment.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/data/shaders/Math/Segment.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Math/intersect.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/data/shaders/Math/intersect.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Basic/Op/LambdaOp.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/include/Basic/Op/LambdaOp.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Light/Light.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/include/Engine/Light/Light.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Material/GGX.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/include/Engine/Material/GGX.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Scene/SObj.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/include/Engine/Scene/SObj.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/App/UEngine/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_GetTargetName(UI "${PROJECT_SOURCE_DIR}/src/UI") 2 | 3 | Ubpa_AddTarget(MODE "EXE" QT ON LIBS ${UI}) 4 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/App/UEngine/UEngine.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/src/App/UEngine/UEngine.cpp -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Engine/RTX/FilmTile.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/src/Engine/RTX/FilmTile.cpp -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Engine/Scene/SObjLoader.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/src/Engine/Scene/SObjLoader.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Engine/Viewer/Raster.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/src/Engine/Viewer/Raster.cpp -------------------------------------------------------------------------------- /Homeworks/2_ImageWarping/project/src/App/Resources/images/open.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/2_ImageWarping/project/src/App/Resources/images/open.jpg -------------------------------------------------------------------------------- /Homeworks/2_ImageWarping/project/src/App/Resources/images/save.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/2_ImageWarping/project/src/App/Resources/images/save.jpg -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Viewer/Raster.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/include/Engine/Viewer/Raster.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Engine/RTX/RTX_Renderer.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/src/Engine/RTX/RTX_Renderer.cpp -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/project/src/executables/1_BasicDArray/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/0_CppPratices/project/src/executables/1_BasicDArray/main.cpp -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/samples/src/executables/1_BasicDArray/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/0_CppPratices/samples/src/executables/1_BasicDArray/main.cpp -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Light/AreaLight.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/include/Engine/Light/AreaLight.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Light/DiskLight.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/include/Engine/Light/DiskLight.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Light/PointLight.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/include/Engine/Light/PointLight.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Light/SphereLight.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/include/Engine/Light/SphereLight.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Light/SpotLight.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/include/Engine/Light/SpotLight.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Material/Beckmann.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/include/Engine/Material/Beckmann.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/MeshEdit/Simulate.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/include/Engine/MeshEdit/Simulate.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Primitive/Capsule.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/include/Engine/Primitive/Capsule.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Primitive/Plane.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/include/Engine/Primitive/Plane.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Primitive/Sphere.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/include/Engine/Primitive/Sphere.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Viewer/BVHAccel.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/include/Engine/Viewer/BVHAccel.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Viewer/PathTracer.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/include/Engine/Viewer/PathTracer.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Viewer/RayTracer.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/include/Engine/Viewer/RayTracer.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Basic/Sampler/AliasMethod.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/src/Basic/Sampler/AliasMethod.cpp -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Basic/ShapeMesh/SphereMesh.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/src/Basic/ShapeMesh/SphereMesh.cpp -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Engine/MeshEdit/Simulate.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/src/Engine/MeshEdit/Simulate.cpp -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Engine/Primitive/TriMesh.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/src/Engine/Primitive/TriMesh.cpp -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Engine/Viewer/EnvGenerator.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/src/Engine/Viewer/EnvGenerator.cpp -------------------------------------------------------------------------------- /Homeworks/6_MassSpring/documents/tetgen/src/TetGene/Tet_generate.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/6_MassSpring/documents/tetgen/src/TetGene/Tet_generate.cpp -------------------------------------------------------------------------------- /Homeworks/3_PoissonImageEditing/documents/opencv_example/src/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_AddTarget( 2 | QT 3 | TEST 4 | MODE EXE 5 | LIB 6 | Qt5::Widgets 7 | opencv_world 8 | ) 9 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Light/CapsuleLight.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/include/Engine/Light/CapsuleLight.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Material/SchlickGGX.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/include/Engine/Material/SchlickGGX.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Primitive/Triangle.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/include/Engine/Primitive/Triangle.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Basic/Sampler/CosHsSample3D.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/src/Basic/Sampler/CosHsSample3D.cpp -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Basic/ShapeMesh/CapsuleMesh.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/src/Basic/ShapeMesh/CapsuleMesh.cpp -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Engine/Viewer/DLDM_Generator.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/src/Engine/Viewer/DLDM_Generator.cpp -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Engine/Viewer/ForwardRaster.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/src/Engine/Viewer/ForwardRaster.cpp -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Engine/Viewer/PLDM_Generator.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/src/Engine/Viewer/PLDM_Generator.cpp -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Engine/Viewer/SLDM_Generator.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/src/Engine/Viewer/SLDM_Generator.cpp -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/project/src/executables/2_EfficientDArray/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/0_CppPratices/project/src/executables/2_EfficientDArray/main.cpp -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/samples/src/executables/2_EfficientDArray/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/0_CppPratices/samples/src/executables/2_EfficientDArray/main.cpp -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/samples/src/executables/3_TemplateDArray/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/0_CppPratices/samples/src/executables/3_TemplateDArray/main.cpp -------------------------------------------------------------------------------- /Homeworks/3_PoissonImageEditing/project/src/App/Resources/images/open.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/3_PoissonImageEditing/project/src/App/Resources/images/open.jpg -------------------------------------------------------------------------------- /Homeworks/3_PoissonImageEditing/project/src/App/Resources/images/save.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/3_PoissonImageEditing/project/src/App/Resources/images/save.jpg -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Engine/Light/AreaLight.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/data/shaders/Engine/Light/AreaLight.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Engine/Light/DiskLight.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/data/shaders/Engine/Light/DiskLight.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Engine/Light/PointLight.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/data/shaders/Engine/Light/PointLight.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Engine/Light/SphereLight.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/data/shaders/Engine/Light/SphereLight.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Engine/Light/SpotLight.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/data/shaders/Engine/Light/SpotLight.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Light/DirectionalLight.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/include/Engine/Light/DirectionalLight.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/App/UEngine/GenScene.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Ubpa { 6 | class Scene; 7 | Ptr GenScene(int n); 8 | } 9 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Engine/Light/CapsuleLight.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/data/shaders/Engine/Light/CapsuleLight.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Light/InfiniteAreaLight.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/include/Engine/Light/InfiniteAreaLight.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Material/BSDF_Frostbite.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/include/Engine/Material/BSDF_Frostbite.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Material/BSDF_MetalWorkflow.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/include/Engine/Material/BSDF_MetalWorkflow.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Intersector/VisibilityChecker.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/include/Engine/Intersector/VisibilityChecker.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Intersector/ClosestIntersector.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/include/Engine/Intersector/ClosestIntersector.h -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Material/MicrofacetDistribution.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/4_MinSurfMeshPara/project/include/Engine/Material/MicrofacetDistribution.h -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/project/src/libraries/static/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_AddTarget( 2 | TEST 3 | MODE STATIC 4 | INC 5 | "include" 6 | SOURCE 7 | "${PROJECT_SOURCE_DIR}/include/PolynomialMap.h" 8 | ) 9 | -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/samples/src/libraries/static/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_AddTarget( 2 | TEST 3 | MODE STATIC 4 | INC 5 | "include" 6 | SOURCE 7 | "${PROJECT_SOURCE_DIR}/include/PolynomialMap.h" 8 | ) 9 | -------------------------------------------------------------------------------- /Homeworks/1_MiniDraw/project/src/App/Line.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Shape.h" 4 | 5 | class Line : public Shape { 6 | public: 7 | Line(); 8 | ~Line(); 9 | 10 | void Draw(QPainter& painter); 11 | }; 12 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/config/ROOT_PATH.h.in: -------------------------------------------------------------------------------- 1 | #ifndef _ROOT_PATH_H_ 2 | #define _ROOT_PATH_H_ 3 | 4 | #include 5 | 6 | const std::string ROOT_PATH("${CMAKE_SOURCE_DIR}/"); 7 | 8 | #endif //!_ROOT_PATH_H_ -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Common/basic.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | layout (location = 0) out vec4 FragColor; 3 | 4 | uniform vec3 color; 5 | 6 | void main() 7 | { 8 | FragColor = vec4(color, 1.0); 9 | } -------------------------------------------------------------------------------- /Homeworks/1_MiniDraw/project/src/App/Rect.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Shape.h" 4 | 5 | class Rect : public Shape { 6 | public: 7 | Rect(); 8 | ~Rect(); 9 | 10 | void Draw(QPainter& painter); 11 | }; 12 | 13 | -------------------------------------------------------------------------------- /Homeworks/3_PoissonImageEditing/documents/opencv_example/src/test/Resources/images/open.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/3_PoissonImageEditing/documents/opencv_example/src/test/Resources/images/open.jpg -------------------------------------------------------------------------------- /Homeworks/3_PoissonImageEditing/documents/opencv_example/src/test/Resources/images/save.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ubpa/USTC_CG/HEAD/Homeworks/3_PoissonImageEditing/documents/opencv_example/src/test/Resources/images/save.jpg -------------------------------------------------------------------------------- /Homeworks/9_PathTracing/project/src/UEditor/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_GetTargetName(pathtracer ${PROJECT_SOURCE_DIR}/src/PathTracer) 2 | 3 | Ubpa_AddTarget( 4 | MODE EXE 5 | LIB 6 | Ubpa::UEngine_core 7 | ${pathtracer} 8 | ) 9 | -------------------------------------------------------------------------------- /Homeworks/1_MiniDraw/project/src/App/Line.cpp: -------------------------------------------------------------------------------- 1 | #include "Line.h" 2 | 3 | Line::Line() 4 | { 5 | } 6 | 7 | Line::~Line() 8 | { 9 | } 10 | 11 | void Line::Draw(QPainter& painter) 12 | { 13 | painter.drawLine(start, end); 14 | } 15 | -------------------------------------------------------------------------------- /Homeworks/6_MassSpring/documents/tetgen/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #生成 exe 就 "EXE",生成 lib 就 "LIB",生成 dll 就 "DLL" 2 | set(mode "EXE") 3 | set(TARGET_PREFIX "") 4 | 5 | Ubpa_GetDirName(DIRNAME) 6 | set(FOLDER_NAME ${DIRNAME}) 7 | 8 | Ubpa_AddSubDirs() -------------------------------------------------------------------------------- /Homeworks/2_ImageWarping/documents/eigen_example/src/test/00_LinearEquation/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_GetTargetName(eigen "${PROJECT_SOURCE_DIR}/src/_deps/eigen") 2 | 3 | Ubpa_AddTarget( 4 | TEST 5 | MODE EXE 6 | LIB 7 | ${eigen} 8 | ) 9 | -------------------------------------------------------------------------------- /Homeworks/3_PoissonImageEditing/project/src/App/mainwindow.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | Resources/images/open.jpg 4 | Resources/images/save.jpg 5 | 6 | 7 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Engine/PointLight/genDepth.vs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | layout (location = 0) in vec3 aPos; 3 | 4 | uniform mat4 model; 5 | 6 | void main() 7 | { 8 | gl_Position = model * vec4(aPos, 1.0); 9 | } -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/_deps/README.md: -------------------------------------------------------------------------------- 1 | # 依赖 2 | 3 | - [stb_image.h](https://github.com/nothings/stb/blob/master/stb_image.h) 4 | - [stb_image_write.h](https://github.com/nothings/stb/blob/master/stb_image_write.h) 5 | 6 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Basic/Parallel.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace Ubpa; 4 | 5 | #include 6 | 7 | Parallel::Parallel() 8 | : coreNum(static_cast(omp_get_num_procs())) { } 9 | 10 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Basic/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_GlobGroupSrcs(RST sources PATHS 2 | ${CMAKE_CURRENT_SOURCE_DIR} 3 | "${PROJECT_SOURCE_DIR}/include/Basic" 4 | ) 5 | 6 | Ubpa_AddTarget(MODE "LIB" SOURCES ${sources} LIBS Ubpa::UGM_core) 7 | -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/project/src/executables/4_list_Polynomial/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_GetTargetName(sharedPolynomialList "${PROJECT_SOURCE_DIR}/src/libraries/shared") 2 | Ubpa_AddTarget( 3 | TEST 4 | MODE EXE 5 | LIB 6 | ${sharedPolynomialList} 7 | ) 8 | -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/samples/src/executables/4_list_Polynomial/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_GetTargetName(sharedPolynomialList "${PROJECT_SOURCE_DIR}/src/libraries/shared") 2 | Ubpa_AddTarget( 3 | TEST 4 | MODE EXE 5 | LIB 6 | ${sharedPolynomialList} 7 | ) 8 | -------------------------------------------------------------------------------- /Homeworks/3_PoissonImageEditing/documents/opencv_example/src/test/mainwindow.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | Resources/images/open.jpg 4 | Resources/images/save.jpg 5 | 6 | 7 | -------------------------------------------------------------------------------- /Homeworks/9_PathTracing/project/data/shaders/img.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | out vec4 FragColor; 3 | 4 | in vec2 TexCoord; 5 | 6 | // texture samplers 7 | uniform sampler2D img; 8 | 9 | void main() 10 | { 11 | FragColor = texture(img, TexCoord); 12 | } 13 | -------------------------------------------------------------------------------- /Homeworks/1_MiniDraw/documents/example/src/example/main.cpp: -------------------------------------------------------------------------------- 1 | #include "example.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | example w; 8 | w.show(); 9 | return a.exec(); 10 | } 11 | -------------------------------------------------------------------------------- /Homeworks/2_ImageWarping/project/src/App/main.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | MainWindow w; 8 | w.show(); 9 | return a.exec(); 10 | } 11 | -------------------------------------------------------------------------------- /Homeworks/3_PoissonImageEditing/project/src/App/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_GetTargetName(eigen "${PROJECT_SOURCE_DIR}/src/_deps/eigen") 2 | 3 | Ubpa_AddTarget( 4 | TEST 5 | QT 6 | MODE EXE 7 | LIB 8 | ${eigen} 9 | Qt5::Widgets 10 | opencv_world 11 | ) 12 | -------------------------------------------------------------------------------- /Homeworks/3_PoissonImageEditing/project/src/App/main.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | #include 3 | 4 | int main(int argc, char* argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | MainWindow w; 8 | w.show(); 9 | return a.exec(); 10 | } 11 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Common/basic_T2.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | out vec4 FragColor; 3 | 4 | in vec2 TexCoords; 5 | 6 | uniform sampler2D texture0; 7 | 8 | void main(){ 9 | FragColor = vec4(texture(texture0, TexCoords).rgb, 1.0f); 10 | } -------------------------------------------------------------------------------- /Homeworks/1_MiniDraw/documents/hello/src/hello/main.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | MainWindow w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Basic/Sampler/Sampler2D.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Ubpa { 6 | class Sampler2D { 7 | public: 8 | virtual const valf2 GetSample() const = 0; 9 | virtual ~Sampler2D() {} 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /Homeworks/2_ImageWarping/project/src/App/mainwindow.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | Resources/images/new.jpg 4 | Resources/images/open.jpg 5 | Resources/images/save.jpg 6 | 7 | 8 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Common/basic_P3.vs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | #include "camera.h" 4 | 5 | layout (location = 0) in vec3 aPos; 6 | 7 | uniform mat4 model; 8 | 9 | void main(){ 10 | gl_Position = projection * view * model * vec4(aPos,1.0); 11 | } -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Basic/Sampler/UniformGridSampler2D.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Sampler2D.h" 4 | 5 | namespace Ubpa { 6 | class UniformGridSampler2D : public Sampler2D { 7 | public: 8 | virtual const valf2 GetSample() const; 9 | }; 10 | } 11 | -------------------------------------------------------------------------------- /Homeworks/1_MiniDraw/project/src/App/shape.cpp: -------------------------------------------------------------------------------- 1 | #include "Shape.h" 2 | 3 | Shape::Shape() 4 | { 5 | } 6 | 7 | Shape::~Shape() 8 | { 9 | } 10 | 11 | void Shape::set_start(QPoint s) 12 | { 13 | start = s; 14 | } 15 | 16 | void Shape::set_end(QPoint e) 17 | { 18 | end = e; 19 | } 20 | -------------------------------------------------------------------------------- /Homeworks/3_PoissonImageEditing/documents/opencv_example/src/test/main.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | MainWindow w; 8 | w.show(); 9 | return a.exec(); 10 | } 11 | -------------------------------------------------------------------------------- /Homeworks/1_MiniDraw/project/src/App/Rect.cpp: -------------------------------------------------------------------------------- 1 | #include "Rect.h" 2 | 3 | Rect::Rect() 4 | { 5 | } 6 | 7 | Rect::~Rect() 8 | { 9 | } 10 | 11 | void Rect::Draw(QPainter& painter) 12 | { 13 | painter.drawRect(start.x(), start.y(), 14 | end.x() - start.x(), end.y() - start.y()); 15 | } 16 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Common/MVP_P3.vs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | layout (location = 0) in vec3 aPos; 3 | 4 | uniform mat4 model; 5 | uniform mat4 view; 6 | uniform mat4 proj; 7 | 8 | void main() 9 | { 10 | gl_Position = proj * view * model * vec4(aPos, 1.0); 11 | } -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Engine/DirectionalLight/genDepth.vs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | layout (location = 0) in vec3 aPos; 3 | 4 | uniform mat4 model; 5 | uniform mat4 lightProjView; 6 | 7 | void main() 8 | { 9 | gl_Position = lightProjView * model * vec4(aPos, 1.0); 10 | } -------------------------------------------------------------------------------- /Homeworks/8_Shader/project/data/shaders/p3.vert: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | layout (location = 0) in vec3 aPos; 4 | 5 | uniform mat4 projection; 6 | uniform mat4 view; 7 | uniform mat4 model; 8 | 9 | void main() 10 | { 11 | gl_Position = projection * view * model * vec4(aPos, 1.0); 12 | } 13 | -------------------------------------------------------------------------------- /Homeworks/8_Shader/project/data/models/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_DownloadFile( 2 | https://ubpa.github.io/USTC_CG_Data/Homeworks/08_Shader/models/spot_triangulated_good.obj 3 | ${CMAKE_CURRENT_SOURCE_DIR}/spot_triangulated_good.obj 4 | SHA256 6B24ADB11D65CF3658FA76BC1D589525E51AB997E442859EAC7CA3211B8E0357 5 | ) 6 | -------------------------------------------------------------------------------- /Homeworks/9_PathTracing/project/data/shaders/p2t2.vs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | layout (location = 0) in vec2 aPos; 3 | layout (location = 1) in vec2 aTexCoord; 4 | 5 | out vec2 TexCoord; 6 | 7 | void main() 8 | { 9 | TexCoord = aTexCoord; 10 | gl_Position = vec4(aPos.x, aPos.y, 0.0, 1.0); 11 | } 12 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Common/basic_P2T2.vs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | layout (location = 0) in vec2 aPos; 4 | layout (location = 1) in vec2 aTexCoords; 5 | 6 | out vec2 TexCoords; 7 | 8 | void main() 9 | { 10 | TexCoords = aTexCoords; 11 | gl_Position = vec4(aPos, 0.0, 1.0); 12 | } -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Qt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_GlobGroupSrcs(RST sources PATHS 2 | ${CMAKE_CURRENT_SOURCE_DIR} 3 | "${PROJECT_SOURCE_DIR}/include/Qt" 4 | ) 5 | Ubpa_GetTargetName(Basic "${PROJECT_SOURCE_DIR}/src/Basic") 6 | Ubpa_AddTarget(MODE "LIB" QT ON SOURCES ${sources} LIBS "${Basic};Qt5::Widgets") 7 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Basic/Sampler/Sampler3D.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Ubpa { 6 | class Sampler3D { 7 | public: 8 | virtual const valf3 GetSample() = 0; 9 | virtual const valf3 GetSample(float& pd) = 0; 10 | virtual ~Sampler3D() {} 11 | }; 12 | } 13 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Engine/Scene/Component.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | using namespace Ubpa; 6 | 7 | void Component::Init_AfterGenPtr() { 8 | auto sobj = GetSObj(); 9 | if (sobj) 10 | sobj->AttachComponent(This()); 11 | } 12 | -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/documents/1_BasicDArray/C2Cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10 FATAL_ERROR) 2 | 3 | project(C2Cpp VERSION 1.0) 4 | message(STATUS "[Project] ${PROJECT_NAME}") 5 | 6 | include(cmake/InitUCMake.cmake) 7 | Ubpa_InitUCMake() 8 | 9 | Ubpa_InitProject() 10 | 11 | Ubpa_AddSubDirsRec(src) 12 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Engine/Scene/SimpleLoader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | namespace Ubpa { 8 | class SObj; 9 | namespace SimpleLoader { 10 | Ptr LoadObj(const std::string& path); 11 | Ptr LoadTet(const std::string& path); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/project/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10 FATAL_ERROR) 2 | 3 | project(CppPractices VERSION 1.0) 4 | message(STATUS "[Project] ${PROJECT_NAME} ${PROJECT_VERSION}") 5 | 6 | include(cmake/InitUCMake.cmake) 7 | Ubpa_InitUCMake() 8 | 9 | Ubpa_InitProject() 10 | 11 | Ubpa_AddSubDirsRec(src) 12 | -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/samples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10 FATAL_ERROR) 2 | 3 | project(CppPractices VERSION 1.0) 4 | message(STATUS "[Project] ${PROJECT_NAME} ${PROJECT_VERSION}") 5 | 6 | include(cmake/InitUCMake.cmake) 7 | Ubpa_InitUCMake() 8 | 9 | Ubpa_InitProject() 10 | 11 | Ubpa_AddSubDirsRec(src) 12 | -------------------------------------------------------------------------------- /Homeworks/1_MiniDraw/project/src/App/main.cpp: -------------------------------------------------------------------------------- 1 | #include "minidraw.h" 2 | #include 3 | 4 | int main(int argc, char* argv[]) { 5 | _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF); 6 | 7 | QApplication a(argc, argv); 8 | MiniDraw w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Homeworks/2_ImageWarping/documents/eigen_example/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14 FATAL_ERROR) 2 | 3 | project(eigen_example VERSION 1.0) 4 | message(STATUS "[Project] ${PROJECT_NAME}") 5 | 6 | include(cmake/InitUCMake.cmake) 7 | Ubpa_InitUCMake() 8 | 9 | Ubpa_InitProject() 10 | 11 | Ubpa_AddSubDirsRec(src) 12 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Engine/IBL/cubemap.vs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | layout (location = 0) in vec3 aPos; 3 | 4 | out vec3 WorldPos; 5 | 6 | uniform mat4 projection; 7 | uniform mat4 view; 8 | 9 | void main() 10 | { 11 | WorldPos = aPos; 12 | gl_Position = projection * view * vec4(WorldPos, 1.0); 13 | } -------------------------------------------------------------------------------- /Homeworks/2_ImageWarping/project/src/App/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_GetTargetName(eigen "${PROJECT_SOURCE_DIR}/src/_deps/eigen") 2 | 3 | set(libs "${eigen};Qt5::Widgets") 4 | 5 | if(USE_ANN) 6 | list(APPEND libs "Ubpa::UANN_ann") 7 | endif() 8 | 9 | Ubpa_AddTarget( 10 | TEST 11 | QT 12 | MODE EXE 13 | LIB 14 | ${libs} 15 | ) 16 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Common/camera.h: -------------------------------------------------------------------------------- 1 | // 160 2 | layout (std140) uniform Camera{ 3 | mat4 view; // 64 0 64 4 | mat4 projection; // 64 64 64 5 | vec3 viewPos; // 12 128 144 6 | float nearPlane; // 4 144 148 7 | float farPlane; // 4 148 152 8 | float fov; // 4 152 156 9 | float ar; // 4 156 160 10 | }; 11 | -------------------------------------------------------------------------------- /Homeworks/1_MiniDraw/project/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14 FATAL_ERROR) 2 | 3 | project(MiniDraw VERSION 1.0) 4 | message(STATUS "[Project] ${PROJECT_NAME}") 5 | 6 | include(cmake/InitUCMake.cmake) 7 | Ubpa_InitUCMake() 8 | 9 | Ubpa_InitProject() 10 | 11 | Ubpa_QtInit(COMPONENTS Widgets) 12 | 13 | Ubpa_AddSubDirsRec(src) 14 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/OpenGL/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_GlobGroupSrcs(RST sources PATHS 2 | ${CMAKE_CURRENT_SOURCE_DIR} 3 | "${PROJECT_SOURCE_DIR}/include/OpenGL" 4 | ) 5 | add_definitions(-DUSE_QT_OPENGL_API) 6 | Ubpa_GetTargetName(Basic "${PROJECT_SOURCE_DIR}/src/Basic") 7 | Ubpa_AddTarget(MODE "LIB" SOURCES ${sources} LIBS ${Basic} Qt5::Widgets) 8 | -------------------------------------------------------------------------------- /Homeworks/1_MiniDraw/documents/example/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14 FATAL_ERROR) 2 | 3 | project(QtExample VERSION 1.0) 4 | message(STATUS "[Project] ${PROJECT_NAME}") 5 | 6 | include(cmake/InitUCMake.cmake) 7 | Ubpa_InitUCMake() 8 | 9 | Ubpa_InitProject() 10 | 11 | Ubpa_QtInit(COMPONENTS Widgets) 12 | 13 | Ubpa_AddSubDirsRec(src) 14 | -------------------------------------------------------------------------------- /Homeworks/1_MiniDraw/documents/hello/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14 FATAL_ERROR) 2 | 3 | project(QtExample VERSION 1.0) 4 | message(STATUS "[Project] ${PROJECT_NAME}") 5 | 6 | include(cmake/InitUCMake.cmake) 7 | Ubpa_InitUCMake() 8 | 9 | Ubpa_InitProject() 10 | 11 | Ubpa_QtInit(COMPONENTS Widgets) 12 | 13 | Ubpa_AddSubDirsRec(src) 14 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Scene/AllComponents.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | -------------------------------------------------------------------------------- /Homeworks/8_Shader/project/src/app/0_displacement_normal/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_GetTargetName(tool "${PROJECT_SOURCE_DIR}/src/tool") 2 | set(src 3 | ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp 4 | ${PROJECT_SOURCE_DIR}/data/shaders/dn.vert 5 | ${PROJECT_SOURCE_DIR}/data/shaders/light_dn.frag) 6 | Ubpa_AddTarget(MODE "EXE" SOURCES ${src} LIBS "Ubpa::UGL_core;glfw;${tool}") 7 | -------------------------------------------------------------------------------- /Homeworks/8_Shader/project/src/app/1_denoise/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(src 2 | ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp 3 | ${PROJECT_SOURCE_DIR}/data/shaders/p3t2n3_denoise.vert 4 | ${PROJECT_SOURCE_DIR}/data/shaders/light.frag) 5 | 6 | Ubpa_GetTargetName(tool "${PROJECT_SOURCE_DIR}/src/tool") 7 | Ubpa_AddTarget(MODE "EXE" SOURCES ${src} LIBS "Ubpa::UGL_core;glfw;${tool}") 8 | -------------------------------------------------------------------------------- /Homeworks/2_ImageWarping/documents/ann_example/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14 FATAL_ERROR) 2 | 3 | project(ann_example VERSION 1.0) 4 | message(STATUS "[Project] ${PROJECT_NAME}") 5 | 6 | include(cmake/InitUCMake.cmake) 7 | Ubpa_InitUCMake() 8 | 9 | Ubpa_InitProject() 10 | 11 | Ubpa_AddDep(UANN 0.2.0) 12 | 13 | Ubpa_AddSubDirsRec(src) 14 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Intersector/Intersector.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Ubpa { 6 | class SObj; 7 | 8 | class Sphere; 9 | class Plane; 10 | class Triangle; 11 | class TriMesh; 12 | class BVHAccel; 13 | class Disk; 14 | class Capsule; 15 | 16 | class Intersector { }; 17 | } 18 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Basic/Sampler/UniformGridSampler2D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | using namespace Ubpa; 6 | 7 | const valf2 UniformGridSampler2D::GetSample() const { 8 | 9 | float x = Math::Rand_F(); 10 | float y = Math::Rand_F(); 11 | 12 | return valf2(x, y); 13 | } 14 | -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/project/src/executables/5_map_Polynomial/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_GetTargetName(sharedPolynomialList "${PROJECT_SOURCE_DIR}/src/libraries/shared") 2 | Ubpa_GetTargetName(staticPolynomialMap "${PROJECT_SOURCE_DIR}/src/libraries/static") 3 | Ubpa_AddTarget( 4 | TEST 5 | MODE EXE 6 | LIB 7 | ${sharedPolynomialList} 8 | ${staticPolynomialMap} 9 | ) 10 | -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/samples/src/executables/5_map_Polynomial/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_GetTargetName(sharedPolynomialList "${PROJECT_SOURCE_DIR}/src/libraries/shared") 2 | Ubpa_GetTargetName(staticPolynomialMap "${PROJECT_SOURCE_DIR}/src/libraries/static") 3 | Ubpa_AddTarget( 4 | TEST 5 | MODE EXE 6 | LIB 7 | ${sharedPolynomialList} 8 | ${staticPolynomialMap} 9 | ) 10 | -------------------------------------------------------------------------------- /Homeworks/9_PathTracing/project/data/shaders/env.vs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | layout (location = 0) in vec3 aPos; 3 | 4 | out vec3 TexCoord; 5 | 6 | uniform mat4 view; 7 | uniform mat4 projection; 8 | 9 | void main() 10 | { 11 | TexCoord = aPos; 12 | mat4 viewNoT = mat4(mat3(view)); 13 | vec4 pos = projection * viewNoT * vec4(aPos, 1.0); 14 | gl_Position = pos.xyww; 15 | } 16 | -------------------------------------------------------------------------------- /Homeworks/9_PathTracing/project/data/textures/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_DownloadFile( 2 | https://cdn.jsdelivr.net/gh/Ubpa/USTC_CG_data@master/Homeworks/09_PathTracing/newport_loft.hdr 3 | # https://ubpa.github.io/USTC_CG_Data/Homeworks/09_PathTracing/newport_loft.hdr 4 | ${CMAKE_CURRENT_LIST_DIR}/newport_loft.hdr 5 | SHA256 F521688AB09B3E748341921D0C8C114D1256E6CA9E94C6E6783B9952B0042C44 6 | ) 7 | -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/documents/1_BasicDArray/C2Cpp/src/Array4/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #include "Array.h" 5 | 6 | void main() 7 | { 8 | DArray pa; 9 | 10 | //pa.InitArray( ); 11 | 12 | pa.SetArraySize( 3 ); 13 | pa.SetValue( 0, 1.0 ); 14 | pa.SetValue( 1, 2.0 ); 15 | pa.SetValue( 2, 3.0 ); 16 | 17 | pa.PrintArray( ); 18 | 19 | //pa.FreeArray( ); 20 | } 21 | -------------------------------------------------------------------------------- /Homeworks/2_ImageWarping/project/src/_deps/eigen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_DownloadZip( 2 | https://cdn.jsdelivr.net/gh/Ubpa/UData@master/common/eigen/eigen_3_3_7.zip 3 | eigen_3_3_7.zip 4 | SHA256 6D5CBC4C70A7B175439DEE0942C6794EB454493D3585973F7D4976D0820321E2 5 | ) 6 | 7 | Ubpa_AddTarget( 8 | TEST 9 | MODE INTERFACE 10 | ADD_CURRENT_TO NONE 11 | INC 12 | "src/_deps/eigen" 13 | ) 14 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Common/basic_P3T2.vs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | #include "camera.h" 4 | 5 | layout (location = 0) in vec3 aPos; 6 | layout (location = 1) in vec2 aTexCoords; 7 | 8 | uniform mat4 model; 9 | 10 | out vec2 TexCoords; 11 | 12 | void main(){ 13 | TexCoords = aTexCoords; 14 | 15 | gl_Position = projection * view * model * vec4(aPos,1.0); 16 | } -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Engine/Filter/FilterSinc.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | using namespace Ubpa; 6 | 7 | float FilterSinc::WindowSinc(float x, float radius) const { 8 | x = std::abs(x); 9 | if (x > radius) 10 | return 0; 11 | const auto lanczos = Math::Sinc(x / tau); 12 | return Math::Sinc(x) * lanczos; 13 | } 14 | -------------------------------------------------------------------------------- /Homeworks/1_MiniDraw/project/README.md: -------------------------------------------------------------------------------- 1 | # 作业项目 2 | 3 | ## 目录结构 4 | 5 | 本项目目录包含以下若干子目录: 6 | 7 | - [`src/`](src/):本次作业项目的源代码 8 | 9 | ## 其他说明 10 | 11 | - Qt:[简易说明](../../../Softwares/Qt.md) 12 | - CMake-GUI 在 configure 的时候,Optional platform for generator 要选 **x64** 13 | - CMake 一开始会拉取 [UCMake](https://github.com/Ubpa/UCMake),所以会稍微久一点,拉取的 UCMake 位于 `build/_deps/`,内含一些自定义函数 `Ubpa_xxx` 14 | 15 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Basic/Op/Op.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Ubpa { 6 | class Op : public HeapObj { 7 | protected: 8 | Op(bool isHold = true) :isHold(isHold) { } 9 | virtual ~Op() = default; 10 | 11 | public: 12 | void operator()() { Run(); } 13 | virtual void Run() = 0; 14 | 15 | public: 16 | bool isHold; 17 | }; 18 | } 19 | -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/documents/1_BasicDArray/C2Cpp/src/Array4/Array.h: -------------------------------------------------------------------------------- 1 | 2 | class DArray 3 | { 4 | private: 5 | int n; // the size of the array 6 | double *pData; // the data of the array 7 | 8 | public: 9 | DArray(); 10 | ~DArray(); 11 | int InitArray( ); 12 | int SetArraySize( int size ); 13 | int FreeArray( ); 14 | int SetValue( int k, double value ); 15 | int PrintArray( ); 16 | }; 17 | 18 | -------------------------------------------------------------------------------- /Homeworks/2_ImageWarping/documents/eigen_example/src/_deps/eigen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_DownloadZip( 2 | https://cdn.jsdelivr.net/gh/Ubpa/UData@master/common/eigen/eigen_3_3_7.zip 3 | eigen_3_3_7.zip 4 | SHA256 6D5CBC4C70A7B175439DEE0942C6794EB454493D3585973F7D4976D0820321E2 5 | ) 6 | 7 | Ubpa_AddTarget( 8 | TEST 9 | MODE INTERFACE 10 | ADD_CURRENT_TO NONE 11 | INC 12 | "src/_deps/eigen" 13 | ) 14 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Basic/Sampler/CosHsSampler3D.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Sampler3D.h" 4 | 5 | namespace Ubpa { 6 | class CosHsSampler3D : public Sampler3D { 7 | public: 8 | virtual const valf3 GetSample(); 9 | 10 | // Also returns the probability density at the sample point for use in importance sampling. 11 | virtual const valf3 GetSample(float& pd); 12 | }; 13 | } 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | resources/ 2 | build/ 3 | lib/ 4 | students/ 5 | .vs/ 6 | _deps/ 7 | 8 | *Config.h 9 | 10 | *.obj 11 | *.uscene 12 | 13 | *.bmp 14 | *.png 15 | *.jpg 16 | *.gif 17 | *.mp4 18 | *.pdf 19 | 20 | *.html 21 | 22 | *.rar 23 | *.zip 24 | 25 | *.doc 26 | *.docx 27 | *.ppt 28 | *.pptx 29 | 30 | *.filters 31 | *.vcxproj 32 | *.log 33 | *.sln 34 | *.user 35 | *.dll 36 | *.lib 37 | *.exe 38 | *.ilk 39 | *.pdb 40 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Engine/Light/DirectionalLight.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace Ubpa; 4 | 5 | using namespace std; 6 | 7 | const rgbf DirectionalLight::Sample_L(const pointf3 & p, normalf & wi, float & distToLight, float & PD) const { 8 | cout << "WARNING::DirectionalLight:" << endl 9 | << "\t" << "not implemented" << endl; 10 | return 0.f; 11 | } 12 | -------------------------------------------------------------------------------- /Homeworks/3_PoissonImageEditing/project/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14 FATAL_ERROR) 2 | 3 | project(PoissonImageEditing VERSION 1.0) 4 | message(STATUS "[Project] ${PROJECT_NAME}") 5 | 6 | include(cmake/InitUCMake.cmake) 7 | Ubpa_InitUCMake() 8 | 9 | Ubpa_InitProject() 10 | 11 | Ubpa_QtInit(COMPONENTS Core Gui Widgets) 12 | 13 | find_package(OpenCV REQUIRED) 14 | 15 | Ubpa_AddSubDirsRec(src) 16 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Primitive/Primitive.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Shape.h" 4 | 5 | namespace Ubpa { 6 | // renderable 7 | class Primitive : public Shape { 8 | protected: 9 | Primitive() = default; 10 | virtual ~Primitive() = default; 11 | 12 | public: 13 | virtual const Ptr GetPrimitive() override { 14 | return This(); 15 | } 16 | }; 17 | } 18 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/UI/Setting.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Ubpa { 6 | class Setting : public Grid { 7 | public: 8 | using Grid::Grid; 9 | 10 | protected: 11 | virtual ~Setting() = default; 12 | 13 | public: 14 | static Ptr GetInstance() { 15 | static auto instance = Ubpa::New(); 16 | return instance; 17 | } 18 | }; 19 | } 20 | -------------------------------------------------------------------------------- /Homeworks/9_PathTracing/project/data/shaders/p3t2.vs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | layout (location = 0) in vec3 aPos; 3 | layout (location = 1) in vec2 aTexCoord; 4 | 5 | out vec2 TexCoord; 6 | 7 | uniform mat4 model; 8 | uniform mat4 view; 9 | uniform mat4 projection; 10 | 11 | void main() 12 | { 13 | gl_Position = projection * view * model * vec4(aPos, 1.0f); 14 | TexCoord = vec2(aTexCoord.x, 1.0 - aTexCoord.y); 15 | } -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Engine/DeferredPipeline/postProcess.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | out vec3 FragColor; 3 | 4 | in vec2 TexCoords; 5 | 6 | uniform sampler2D img; 7 | 8 | void main(){ 9 | vec3 color = texture(img, TexCoords).xyz; 10 | 11 | // HDR tonemapping 12 | color = color / (vec3(1.0)+color); 13 | 14 | // gamma 15 | color = pow(color, vec3(1.0/2.2)); 16 | 17 | FragColor = color; 18 | } -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/documents/1_BasicDArray/C2Cpp/README.md: -------------------------------------------------------------------------------- 1 | # C to C++ 2 | 3 | 此为 [1_BasicDArray](../) 和 [3_TemplateDArray](../../3_TemplateDArray/) 中的相关项目 4 | 5 | 包含七个子项目 6 | 7 | - Array:固定长度数组 8 | - Array0:动态数组功能实现 9 | - Array 1.0:用 `struct` 打包 `p` 和 `n`,引用形式 10 | - Array 1.1:用 `struct` 打包 `p` 和 `n`,指针形式 11 | - Array 2:函数放到 `struct` 中 12 | - Array 3:改用 `class` 13 | - Array 4:头文件和实现文件 14 | - Array 5:模板 `template` 15 | 16 | -------------------------------------------------------------------------------- /Homeworks/3_PoissonImageEditing/documents/opencv_example/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14 FATAL_ERROR) 2 | 3 | project(OpenCV_Example VERSION 1.0) 4 | message(STATUS "[Project] ${PROJECT_NAME}") 5 | 6 | include(cmake/InitUCMake.cmake) 7 | Ubpa_InitUCMake() 8 | 9 | Ubpa_InitProject() 10 | 11 | Ubpa_QtInit(COMPONENTS Core Gui Widgets) 12 | 13 | find_package(OpenCV REQUIRED) 14 | 15 | Ubpa_AddSubDirsRec(src) 16 | -------------------------------------------------------------------------------- /Homeworks/3_PoissonImageEditing/project/src/App/ChildWindow.cpp: -------------------------------------------------------------------------------- 1 | #include "ChildWindow.h" 2 | #include "ImageWidget.h" 3 | 4 | 5 | ChildWindow::ChildWindow(void) 6 | { 7 | imagewidget_ = new ImageWidget(this); 8 | setCentralWidget(imagewidget_); 9 | } 10 | 11 | 12 | ChildWindow::~ChildWindow(void) 13 | { 14 | } 15 | 16 | bool ChildWindow::LoadFile(QString filename) 17 | { 18 | imagewidget_->Open(filename); 19 | return true; 20 | } -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Basic/ImgPixelSet.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace Ubpa { 7 | class ImgPixelSet : public RandSet { 8 | public: 9 | ImgPixelSet(); 10 | ImgPixelSet(size_t width, size_t height); 11 | 12 | using RandSet::RandPick; 13 | std::vector RandPick(size_t n); 14 | std::vector PickAll(); 15 | }; 16 | } 17 | -------------------------------------------------------------------------------- /Homeworks/6_MassSpring/documents/tetgen/src/TetGene/main.cpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Tet_generate.h" 3 | #include "tetgen.h" 4 | 5 | #include 6 | 7 | using namespace std; 8 | 9 | int main() 10 | { 11 | tetgenio *a; 12 | tetgenio *c; 13 | CTet_generate b; 14 | a = b.poly_in("../data/cube.poly"); 15 | c = b.tet_out(a); 16 | cout << c->numberofpoints << endl; 17 | b.tet_output(c, "../data/2.tet"); 18 | return 0; 19 | } -------------------------------------------------------------------------------- /Homeworks/1_MiniDraw/project/src/App/shape.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class Shape 6 | { 7 | public: 8 | Shape(); 9 | virtual ~Shape(); 10 | virtual void Draw(QPainter& paint) = 0; 11 | void set_start(QPoint s); 12 | void set_end(QPoint e); 13 | 14 | public: 15 | enum Type 16 | { 17 | kDefault = 0, 18 | kLine = 1, 19 | kRect = 2, 20 | }; 21 | 22 | protected: 23 | QPoint start; 24 | QPoint end; 25 | }; 26 | 27 | -------------------------------------------------------------------------------- /Homeworks/6_MassSpring/documents/tetgen/src/TetGene/Tet_generate.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "tetgen.h" 3 | #include "Vec.h" 4 | 5 | using trimesh::vec; 6 | 7 | class CTet_generate 8 | { 9 | public: 10 | CTet_generate(void); 11 | ~CTet_generate(void); 12 | tetgenio* poly_in(char* filename); 13 | tetgenio* tet_out(tetgenio* in); 14 | void tet_output(tetgenio *a, char* filename); 15 | //vec get_normal(tetgenio* tet, int index); 16 | }; 17 | 18 | -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/project/src/libraries/shared/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(c_options "") 2 | if(MSVC) 3 | list(APPEND c_options "/wd4251") 4 | endif() 5 | 6 | Ubpa_AddTarget( 7 | TEST 8 | MODE SHARED 9 | INC 10 | "include" 11 | DEFINE 12 | Ubpa_AsShared_PolynomialList 13 | DEFINE_PRIVATE 14 | Ubpa_Export_PolynomialList 15 | C_OPTION 16 | ${c_options} 17 | SOURCE 18 | "${PROJECT_SOURCE_DIR}/include/PolynomialList.h" 19 | ) 20 | -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/samples/src/libraries/shared/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(c_options "") 2 | if(MSVC) 3 | list(APPEND c_options "/wd4251") 4 | endif() 5 | 6 | Ubpa_AddTarget( 7 | TEST 8 | MODE SHARED 9 | INC 10 | "include" 11 | DEFINE 12 | Ubpa_AsShared_PolynomialList 13 | DEFINE_PRIVATE 14 | Ubpa_Export_PolynomialList 15 | C_OPTION 16 | ${c_options} 17 | SOURCE 18 | "${PROJECT_SOURCE_DIR}/include/PolynomialList.h" 19 | ) 20 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Primitive/Shape.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | namespace Ubpa { 8 | class Primitive; 9 | 10 | class Shape : public HeapObj { 11 | protected: 12 | Shape() = default; 13 | virtual ~Shape() = default; 14 | 15 | public: 16 | virtual const bboxf3 GetBBox() const = 0; 17 | virtual const Ptr GetPrimitive() = 0; 18 | }; 19 | } 20 | -------------------------------------------------------------------------------- /Homeworks/9_PathTracing/project/src/UEditor/Editor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Ubpa { 6 | class Editor { 7 | public: 8 | Read scene; 9 | 10 | static Editor& Instance() noexcept { 11 | static Editor instance; 12 | return instance; 13 | } 14 | 15 | void SetCamera(SObj* cameraobj); 16 | 17 | static void OnRegister(); 18 | 19 | private: 20 | Editor(); 21 | ~Editor(); 22 | }; 23 | } 24 | -------------------------------------------------------------------------------- /Homeworks/2_ImageWarping/project/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14 FATAL_ERROR) 2 | 3 | project(ImageWarping VERSION 1.0) 4 | message(STATUS "[Project] ${PROJECT_NAME}") 5 | 6 | include(cmake/InitUCMake.cmake) 7 | Ubpa_InitUCMake() 8 | 9 | Ubpa_InitProject() 10 | 11 | Ubpa_QtInit(COMPONENTS Widgets) 12 | 13 | set(USE_ANN FALSE CACHE BOOL "use ANN") 14 | if(USE_ANN) 15 | Ubpa_AddDep(UANN 0.2.0) 16 | endif() 17 | 18 | Ubpa_AddSubDirsRec(src) 19 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Engine/IBL/prefilter.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | #include "../../Math/sample.h" 4 | #include "../BRDF/FDG.h" 5 | 6 | out vec4 FragColor; 7 | in vec3 WorldPos; 8 | 9 | uniform samplerCube environmentMap; 10 | uniform float roughness; 11 | uniform float resolution; 12 | 13 | void main() 14 | { 15 | // TODO 16 | vec3 prefilteredColor = vec3(1,1,1); 17 | 18 | FragColor = vec4(prefilteredColor, 1.0); 19 | } 20 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Material/AllBSDFs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Material/Material.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | namespace Ubpa { 12 | class Image; 13 | 14 | class Material : public HeapObj { 15 | protected: 16 | Material() = default; 17 | virtual ~Material() = default; 18 | }; 19 | } 20 | -------------------------------------------------------------------------------- /Homeworks/8_Shader/project/src/app/2_shadow/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(src 2 | ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp 3 | ${PROJECT_SOURCE_DIR}/data/shaders/p3t2n3.vert 4 | ${PROJECT_SOURCE_DIR}/data/shaders/p3.vert 5 | ${PROJECT_SOURCE_DIR}/data/shaders/light_shadow.frag 6 | ${PROJECT_SOURCE_DIR}/data/shaders/empty.frag 7 | ) 8 | 9 | Ubpa_GetTargetName(tool "${PROJECT_SOURCE_DIR}/src/tool") 10 | Ubpa_AddTarget(MODE "EXE" SOURCES ${src} LIBS "Ubpa::UGL_core;glfw;${tool}") 11 | -------------------------------------------------------------------------------- /Homeworks/2_ImageWarping/documents/eigen_example/README.md: -------------------------------------------------------------------------------- 1 | # Eigen 示例 2 | 3 | ## 目录结构 4 | 5 | 本项目目录包含以下若干子目录: 6 | 7 | - [src/](src/):源代码 8 | - [include/](include/):头文件 9 | - [_deps/](include/_deps/):依赖 10 | 11 | ## 其他说明 12 | 13 | - Qt:[简易说明](../../../Softwares/Qt.md) 14 | - CMake-GUI 在 configure 的时候,Optional platform for generator 要选 **x64** 15 | - CMake 一开始会拉取 [UCMake](https://github.com/Ubpa/UCMake),所以会稍微久一点,拉取的 UCMake 位于 `build/_deps/`,内含一些自定义函数 `Ubpa_xxx` 16 | 17 | -------------------------------------------------------------------------------- /Homeworks/9_PathTracing/README.md: -------------------------------------------------------------------------------- 1 | # 9. 路径追踪算法 2 | 3 | > Path Tracing 4 | 5 | ## 作业递交 6 | 7 | - 递交内容:程序代码及实验报告(可选:演示视频) 8 | - 递交时间:2020 年 5 月 2 日星期六 9 | 10 | ## 作业要求 11 | 12 | - 实现路径追踪算法 13 | - 环境光贴图重要性采样 14 | - 搭建场景(代码,json)并渲染 15 | 16 | 17 | ## 提供的材料 18 | 19 | 根据上述要求和方法根据两个文件夹`(1) documents`和`(2) project`的内容进行练习。 20 | 21 | ### (1) 说明文档 `documents` [->](documents/) 22 | 23 | 本次作业的要求说明和一些辅助资料 24 | 25 | ### (2) 作业项目 `project` [->](project/) 26 | 27 | 本次作业的基础代码框架 28 | 29 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Engine/Material/BSDF_Glass.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | using namespace Ubpa; 6 | 7 | using namespace Ubpa::Math; 8 | 9 | using namespace std; 10 | 11 | const rgbf BSDF_Glass::Sample_f(const normalf & wo, const pointf2 & texcoord, normalf & wi, float & PD) { 12 | cout << "WARNING::BSDF_Glass:" << endl 13 | << "\t" << "not implemented" << endl; 14 | return 0.f; 15 | } 16 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Engine/Material/BSDF_Mirror.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | using namespace Ubpa; 6 | 7 | using namespace Ubpa::Math; 8 | 9 | using namespace std; 10 | 11 | const rgbf BSDF_Mirror::Sample_f(const normalf & wo, const pointf2 & texcoord, normalf & wi, float & PD) { 12 | cout << "WARNING::BSDF_Mirror:" << endl 13 | << "\t" << "not implemented" << endl; 14 | return 0.f; 15 | } 16 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Basic/ArgManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace Ubpa { 8 | class ArgManager { 9 | public: 10 | ArgManager(int argc, char** argv); 11 | std::vector GetAll(const std::string& key); 12 | std::string Get(const std::string& key, size_t idx, const std::string& defaultValue = ""); 13 | private: 14 | std::map> pairs; 15 | }; 16 | } 17 | -------------------------------------------------------------------------------- /Homeworks/8_Shader/project/include/_deps/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_DownloadFile( 2 | https://ubpa.github.io/USTC_CG_Data/Homeworks/08_Shader/stb_image.h 3 | ${CMAKE_CURRENT_SOURCE_DIR}/stb_image.h 4 | SHA256 73b55b976e61debbb7bc10d5b31c8f043ab5d966e67f75258e0d3f57f2a0321e 5 | ) 6 | 7 | Ubpa_DownloadFile( 8 | https://ubpa.github.io/UData/common/include/stb_image_write.h 9 | ${CMAKE_CURRENT_SOURCE_DIR}/stb_image_write.h 10 | SHA256 F34D6E55C7BB69C98BF66F191A7636A0B022047BCE7C7B16A9A9F356046FDC8A 11 | ) 12 | -------------------------------------------------------------------------------- /Homeworks/6_MassSpring/README.md: -------------------------------------------------------------------------------- 1 | # 6. 质点弹簧系统仿真 2 | 3 | 4 | ## 作业递交 5 | 6 | - 递交内容:程序代码及实验报告(含仿真动画视频) 7 | - 递交时间:2020 年 3 月 29 日星期日 8 | 9 | ## 作业要求 10 | 11 | - 在给定的网格框架上完成作业,实现 12 | - 质点弹簧仿真模型的欧拉隐式方法 13 | - 质点弹簧仿真模型的加速模拟方法 14 | - 学习使用 Tetgen 库生成四面体剖分 15 | 16 | 17 | ## 提供的材料 18 | 19 | 根据上述要求和方法根据两个文件夹`(1) documents`和`(2) project`的内容进行练习。 20 | 21 | ### (1) 说明文档 `documents` [->](documents/) 22 | 23 | 本次作业的要求说明和一些辅助资料 24 | 25 | ### (2) 作业项目 `project` [->](project/) 26 | 27 | 本次作业的基础代码框架 28 | 29 | -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/project/src/executables/4_list_Polynomial/main.cpp: -------------------------------------------------------------------------------- 1 | #include "PolynomialList.h" 2 | 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | int main(int argc, char** argv) { 9 | PolynomialList p1("../data/P3.txt"); 10 | PolynomialList p2("../data/P4.txt"); 11 | PolynomialList p3; 12 | p1.Print(); 13 | p2.Print(); 14 | 15 | p3 = p1 + p2; 16 | p3.Print(); 17 | p3 = p1 - p2; 18 | p3.Print(); 19 | 20 | p3 = p1 * p2; 21 | p3.Print(); 22 | 23 | return 0; 24 | } -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/samples/src/executables/4_list_Polynomial/main.cpp: -------------------------------------------------------------------------------- 1 | #include "PolynomialList.h" 2 | 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | int main(int argc, char** argv) { 9 | PolynomialList p1("../data/P3.txt"); 10 | PolynomialList p2("../data/P4.txt"); 11 | PolynomialList p3; 12 | p1.Print(); 13 | p2.Print(); 14 | 15 | p3 = p1 + p2; 16 | p3.Print(); 17 | p3 = p1 - p2; 18 | p3.Print(); 19 | 20 | p3 = p1 * p2; 21 | p3.Print(); 22 | 23 | return 0; 24 | } -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Primitive/Disk.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Primitive.h" 4 | 5 | namespace Ubpa { 6 | class Disk : public Primitive { 7 | public: 8 | Disk() = default; 9 | 10 | public: 11 | static const Ptr New() { 12 | return Ubpa::New(); 13 | } 14 | 15 | protected: 16 | virtual ~Disk() = default; 17 | 18 | public: 19 | virtual const bboxf3 GetBBox() const override { 20 | return { {-1,-0.001,-1}, {1,0.001,1} }; 21 | } 22 | }; 23 | } 24 | -------------------------------------------------------------------------------- /Homeworks/8_Shader/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # 8. 着色器 4 | 5 | ## 作业递交 6 | 7 | - 递交内容:程序代码及实验报告(可选:演示视频) 8 | - 递交时间:2020 年 4 月 19 日星期日 9 | 10 | ## 作业要求 11 | 12 | - 实现 normal map 和 displacement map 13 | - 利用 displacement map 在 vertex shader 中进行简单降噪 14 | - 实现点光源阴影(可选) 15 | 16 | 17 | ## 提供的材料 18 | 19 | 根据上述要求和方法根据两个文件夹`(1) documents`和`(2) project`的内容进行练习。 20 | 21 | ### (1) 说明文档 `documents` [->](documents/) 22 | 23 | 本次作业的要求说明和一些辅助资料 24 | 25 | ### (2) 作业项目 `project` [->](project/) 26 | 27 | 本次作业的基础代码框架 28 | 29 | -------------------------------------------------------------------------------- /Homeworks/2_ImageWarping/documents/ann_example/README.md: -------------------------------------------------------------------------------- 1 | # ANN 示例 2 | 3 | ## 目录结构 4 | 5 | 本项目目录包含以下若干子目录: 6 | 7 | - [src/](src/):源代码 8 | 9 | ## 使用说明 10 | 11 | ### 搭建工程 12 | 13 | CMake 三连即可 14 | 15 | ### ANN 16 | 17 | [官方网站](http://www.cs.umd.edu/~mount/ANN/) 提供的源码不包含 CMakeLists.txt,因此我们将其改成 CMake 后移植到了 GitHub 上,详见 [Ubpa | UANN](https://github.com/Ubpa/UANN) 18 | 19 | 项目中的 `UANN_test` 和 `UANN_sample` 的使用方法也请参考 [Ubpa | UANN](https://github.com/Ubpa/UANN) 20 | 21 | 本示例项目提供了[简单的使用方法](src/test/main.cpp) 22 | 23 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Engine/PointLight/genDepth.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | in vec4 FragPos; 3 | 4 | uniform vec3 lightPos; 5 | uniform float lightFar; 6 | 7 | void main() 8 | { 9 | // get distance between fragment and light source 10 | float lightDistance = length(FragPos.xyz - lightPos); 11 | 12 | // map to [0;1] range by dividing by lightFar 13 | lightDistance = lightDistance / lightFar; 14 | 15 | // Write this as modified depth 16 | gl_FragDepth = lightDistance; 17 | } -------------------------------------------------------------------------------- /Homeworks/9_PathTracing/project/src/UEditor/Cmpt/ArcBall.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace Ubpa::Cmpt { 7 | class Hierarchy; 8 | 9 | class ArcBall : public Component { 10 | public: 11 | bool reverse_x{ false }; 12 | bool reverse_y{ true }; 13 | float speed{ 1.f }; 14 | 15 | void OnUpdate(const Hierarchy* hierarchy); 16 | 17 | static void OnRegister(); 18 | 19 | private: 20 | vecf3 sphere_p0; 21 | quatf rot; 22 | }; 23 | } 24 | -------------------------------------------------------------------------------- /Homeworks/6_MassSpring/documents/tetgen/src/TetGene/globalFunctions.h: -------------------------------------------------------------------------------- 1 | #ifndef GLOBALFUNCTIONS_H 2 | #define GLOBALFUNCTIONS_H 3 | 4 | template 5 | void SafeDelete(object *ptr) 6 | { 7 | if (ptr != NULL) 8 | { 9 | delete ptr; 10 | ptr = NULL; 11 | } 12 | } 13 | 14 | template 15 | void SafeDeletes(object *ptr) 16 | { 17 | if (ptr != NULL) 18 | { 19 | delete[] ptr; 20 | ptr = NULL; 21 | } 22 | } 23 | 24 | 25 | #endif // GLOBALFUNCTIONS_H 26 | -------------------------------------------------------------------------------- /Homeworks/9_PathTracing/project/src/UEditor/GenScene.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Ubpa { 6 | class Scene; 7 | 8 | class SceneGenerator { 9 | public: 10 | static SceneGenerator& Instance() { 11 | static SceneGenerator instance; 12 | return instance; 13 | } 14 | 15 | Scene* GenScene(const std::string& path); 16 | // n : [0, 0] 17 | Scene* GenScene(size_t n); 18 | 19 | void PrintSerializedScene(Scene* scene); 20 | 21 | private: 22 | SceneGenerator(); 23 | }; 24 | } 25 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Qt/OpThread.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace Ubpa; 6 | 7 | using namespace std; 8 | 9 | OpThread::OpThread(Ptr op) 10 | : op(op), isStop(false) { 11 | qRegisterMetaType>("Ptr"); 12 | } 13 | 14 | void OpThread::run() { 15 | isStop = false; 16 | 17 | if(op!=nullptr) 18 | op->Run(); 19 | 20 | isStop = true; 21 | } 22 | 23 | void OpThread::UI_Op_Run(Ptr op) { 24 | emit UI_Op(op); 25 | } 26 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/UI/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_GlobGroupSrcs(RST sources PATHS 2 | ${CMAKE_CURRENT_SOURCE_DIR} 3 | "${PROJECT_SOURCE_DIR}/include/UI" 4 | ) 5 | 6 | Ubpa_GetTargetName(Basic "${PROJECT_SOURCE_DIR}/src/Basic") 7 | Ubpa_GetTargetName(OpenGL "${PROJECT_SOURCE_DIR}/src/OpenGL") 8 | Ubpa_GetTargetName(Qt "${PROJECT_SOURCE_DIR}/src/Qt") 9 | Ubpa_GetTargetName(Engine "${PROJECT_SOURCE_DIR}/src/Engine") 10 | 11 | Ubpa_AddTarget(MODE "LIB" QT ON SOURCES ${sources} LIBS ${Basic} ${OpenGL} ${Qt} ${Engine}) 12 | -------------------------------------------------------------------------------- /Homeworks/9_PathTracing/project/data/shaders/postprocess.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | out vec4 FragColor; 3 | 4 | in vec2 TexCoord; 5 | 6 | // texture samplers 7 | uniform sampler2D img; 8 | 9 | void main() 10 | { 11 | const float gamma = 2.2; 12 | 13 | vec3 hdrColor = texture(img, TexCoord).rgb; 14 | 15 | // Reinhard tone mapping 16 | vec3 mapped = hdrColor / (hdrColor + vec3(1.0)); 17 | 18 | // Gamma correction 19 | mapped = pow(mapped, vec3(1.0 / gamma)); 20 | 21 | FragColor = vec4(mapped, 1.0); 22 | } 23 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Basic/ShapeMesh/ShapeMesh.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | namespace Ubpa { 8 | class ShapeMesh { 9 | public: 10 | ShapeMesh(unsigned vertexNum, unsigned triNum = 0); 11 | float* GetPosArr(); 12 | unsigned GetVertexNum() { return vertexNum; } 13 | unsigned GetTriNum() { return triNum; } 14 | unsigned GetPosArrSize(); 15 | protected: 16 | std::vector posArr; 17 | unsigned vertexNum; 18 | unsigned triNum; 19 | }; 20 | } 21 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Basic/ShapeMesh/ShapeMesh.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace Ubpa; 4 | 5 | using namespace std; 6 | 7 | ShapeMesh::ShapeMesh(unsigned vertexNum, unsigned triNum) 8 | : vertexNum(vertexNum), triNum(triNum){ 9 | posArr = vector(vertexNum); 10 | } 11 | 12 | float * ShapeMesh::GetPosArr() { 13 | return posArr.front().data(); 14 | } 15 | 16 | unsigned ShapeMesh::GetPosArrSize() { 17 | return static_cast(posArr.size() * 3 * sizeof(float)); 18 | } 19 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Engine/Filter/FilterMitchell.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace Ubpa; 4 | 5 | float FilterMitchell::Mitchell1D(float x) const { 6 | x = std::abs(2 * x); 7 | if (x > 1) 8 | return ((-B - 6 * C) * x * x * x 9 | + (6 * B + 30 * C) * x * x 10 | + (-12 * B - 48 * C) * x 11 | + (8 * B + 24 * C)) * (1.f / 6.f); 12 | else 13 | return ((12 - 9 * B - 6 * C) * x * x * x 14 | + (-18 + 12 * B + 6 * C) * x * x 15 | + (6 - 2 * B)) * (1.f / 6.f); 16 | } 17 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Scene/Component.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Ubpa { 6 | class SObj; 7 | 8 | class Component : public HeapObj { 9 | protected: 10 | Component(Ptr sobj) : wSObj(sobj) { } 11 | virtual ~Component() = default; 12 | 13 | protected: 14 | virtual void Init_AfterGenPtr() override; 15 | 16 | public: 17 | const Ptr GetSObj() const { return wSObj.lock(); } 18 | 19 | private: 20 | friend SObj; 21 | WPtr wSObj; 22 | }; 23 | } 24 | -------------------------------------------------------------------------------- /Homeworks/6_MassSpring/documents/tetgen/src/TetGene/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #项目名,默认为目录名 2 | Ubpa_GetDirName(DIRNAME) 3 | set(targetName "${TARGET_PREFIX}${DIRNAME}") 4 | #多个源文件用 ';' 分隔 5 | #如:set(sources "main.cpp;src_2.cpp;help.h") 6 | file(GLOB sources 7 | "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp" 8 | "${CMAKE_CURRENT_SOURCE_DIR}/*.cxx" 9 | "${CMAKE_CURRENT_SOURCE_DIR}/*.h" 10 | ) 11 | #多个库文件用 ';' 分隔,如果为空,则为 "" 12 | #如:set(libs "targetName;xxx.lib") 13 | set(libs "") 14 | Ubpa_SetupTarget(MODE ${mode} NAME ${targetName} SOURCES ${sources} LIBS ${libs}) 15 | -------------------------------------------------------------------------------- /Homeworks/9_PathTracing/project/src/UEditor/Cmpt/Roamer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace Ubpa::Cmpt { 8 | class L2W; 9 | class Position; 10 | class Rotation; 11 | 12 | class Roamer : public Component { 13 | public: 14 | float move_speed = 5.f; 15 | float rotate_speed = 0.1f; 16 | 17 | void OnUpdate(CmptTag::LastFrame l2w, Position* pos, Rotation* rot); 18 | 19 | static void OnRegist(); 20 | }; 21 | } 22 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Common/postProcess.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | out vec4 FragColor; 3 | 4 | in vec2 TexCoords; 5 | 6 | uniform sampler2D image; 7 | 8 | uniform bool needTonemap = false; 9 | uniform bool needGamma = false; 10 | 11 | void main(){ 12 | vec3 color = texture(image, TexCoords).rgb; 13 | 14 | 15 | // HDR tonemapping 16 | if(needTonemap) 17 | color = color / (vec3(1.0)+color); 18 | 19 | // gamma 20 | if(needGamma) 21 | color = pow(color, vec3(1.0/2.2)); 22 | 23 | FragColor = vec4(color, 1.0f); 24 | } 25 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Engine/Light/PointLight.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace Ubpa; 4 | 5 | using namespace std; 6 | 7 | float PointLight::Fwin(float d, float radius) { 8 | cout << "WARNING::PointLight:" << endl 9 | << "\t" << "not implemented" << endl; 10 | return 0.f; 11 | } 12 | 13 | const rgbf PointLight::Sample_L(const pointf3 & p, normalf & wi, float & distToLight, float & PD) const { 14 | cout << "WARNING::PointLight:" << endl 15 | << "\t" << "not implemented" << endl; 16 | return 0.f; 17 | } 18 | -------------------------------------------------------------------------------- /Homeworks/6_MassSpring/project/README.md: -------------------------------------------------------------------------------- 1 | # 作业完成说明 2 | 3 | ## 项目说明 4 | 5 | - 读取 *.obj 格式面网格或 *.tet 格式的体网格,生成类 MassSpring 用于传输用于模拟的网格数据 6 | - MassSpring 类中存储了模拟方法类 Simulate; 7 | - 程序 UI 窗口最上方设置两个按钮分别为开始(或继续)模拟时间计时和停止时间计时 8 | - attribute中新添了Simulation组件用于设置模拟的一些参数 9 | 10 | 11 | ## 作业完成步骤 12 | 13 | - 本次作业主要完成类 Simulation 中 Init 和 SimulateOnce 接口函数,前者主要初始化一些模拟用到的矩阵和辅助变量,会在每次更改模拟参数(如劲度系数)时调用从而修改相应的一些辅助变量;后者则是更新下一帧的位置position和速度velocity; 14 | - 模拟只需要顶点的位置和边的索引信息(边索引为点的序号的列表,每两个序号表示一条边由哪两个点连接),均已在Simulation中建立完成 15 | 16 | ## 具体实施步骤 17 | 18 | - 根据20-80原则思考应该如何逐步完成? 19 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Filter/FilterBox.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ImgFilter.h" 4 | 5 | namespace Ubpa { 6 | class FilterBox : public ImgFilter { 7 | public: 8 | FilterBox(const vecf2& radius) : ImgFilter(radius) { } 9 | 10 | protected: 11 | virtual ~FilterBox() = default; 12 | 13 | public: 14 | const Ptr New(const vecf2& radius) { 15 | return Ubpa::New(radius); 16 | } 17 | 18 | public: 19 | virtual float Evaluate(const pointf2& p) const override { 20 | return 1; 21 | } 22 | }; 23 | } 24 | -------------------------------------------------------------------------------- /Homeworks/1_MiniDraw/documents/example/README.md: -------------------------------------------------------------------------------- 1 | # Example 2 | 3 | ## 目录结构 4 | 5 | 本项目目录包含以下若干子目录: 6 | 7 | - `\src`:本次作业项目的源代码 8 | 9 | ## 其他说明 10 | 11 | - Qt:[简易说明](../../../Softwares/Qt.md) 12 | - CMake-GUI 在 configure 的时候,Optional platform for generator 要选 **x64** 13 | - CMake 一开始会拉取 [UCMake](https://github.com/Ubpa/UCMake),所以会稍微久一点,拉取的 UCMake 位于 `build/_deps/`,内含一些 CMake 的自定义函数 `Ubpa_xxx`,详细请看 [UbpaTool.cmake](https://github.com/Ubpa/UCMake/blob/master/cmake/UbpaTool.cmake),构建好的工程中会自带一些 UCMake 中的[示例项目](https://github.com/Ubpa/UCMake/tree/master/src),可以查看模仿 14 | 15 | -------------------------------------------------------------------------------- /Homeworks/1_MiniDraw/documents/hello/README.md: -------------------------------------------------------------------------------- 1 | # Example 2 | 3 | ## 目录结构 4 | 5 | 本项目目录包含以下若干子目录: 6 | 7 | - `\src`:本次作业项目的源代码 8 | 9 | ## 其他说明 10 | 11 | - Qt:[简易说明](../../../Softwares/Qt.md) 12 | - CMake-GUI 在 configure 的时候,Optional platform for generator 要选 **x64** 13 | - CMake 一开始会拉取 [UCMake](https://github.com/Ubpa/UCMake),所以会稍微久一点,拉取的 UCMake 位于 `build/_deps/`,内含一些 CMake 的自定义函数 `Ubpa_xxx`,详细请看 [UbpaTool.cmake](https://github.com/Ubpa/UCMake/blob/master/cmake/UbpaTool.cmake),构建好的工程中会自带一些 UCMake 中的[示例项目](https://github.com/Ubpa/UCMake/tree/master/src),可以查看模仿 14 | 15 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/MeshEdit/Paramaterize.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Ubpa { 6 | class TriMesh; 7 | class MinSurf; 8 | 9 | // mesh boundary == 1 10 | class Paramaterize : public HeapObj { 11 | public: 12 | Paramaterize(Ptr triMesh); 13 | public: 14 | static const Ptr New(Ptr triMesh) { 15 | return Ubpa::New(triMesh); 16 | } 17 | public: 18 | void Clear(); 19 | bool Init(Ptr triMesh); 20 | 21 | bool Run(); 22 | }; 23 | } 24 | -------------------------------------------------------------------------------- /Homeworks/1_MiniDraw/documents/example/src/example/example.h: -------------------------------------------------------------------------------- 1 | #ifndef EXAMPLE_H 2 | #define EXAMPLE_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include "ui_example.h" 8 | 9 | class example : public QMainWindow 10 | { 11 | Q_OBJECT 12 | 13 | public: 14 | example(QWidget *parent = 0); 15 | ~example(); 16 | 17 | QMenu *pMenutest; 18 | QAction *pAction; 19 | QToolBar *main_toolbar_; 20 | 21 | private slots: 22 | void hello(); 23 | 24 | private: 25 | Ui::exampleClass ui; 26 | }; 27 | 28 | #endif // EXAMPLE_H 29 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Filter/ImgFilter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | namespace Ubpa { 9 | class ImgFilter : public HeapObj { 10 | protected: 11 | ImgFilter(const vecf2& radius) : 12 | radius(radius), invRadius(1.0f / radius[0], 1.0f / radius[1]) { } 13 | virtual ~ImgFilter() = default; 14 | 15 | public: 16 | virtual float Evaluate(const pointf2& p) const = 0; 17 | 18 | public: 19 | const vecf2 radius; 20 | const vecf2 invRadius; 21 | }; 22 | } 23 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Material/Gooch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | namespace Ubpa { 8 | class Gooch : public Material { 9 | public: 10 | Gooch(const rgbf& colorFactor = rgbf(1.0f)) :colorFactor(colorFactor) {} 11 | virtual ~Gooch() = default; 12 | 13 | public: 14 | static Ptr New(const rgbf& colorFactor = rgbf(1.0f)) { 15 | return Ubpa::New(colorFactor); 16 | } 17 | 18 | public: 19 | rgbf colorFactor; 20 | Ptr colorTexture; 21 | }; 22 | } 23 | -------------------------------------------------------------------------------- /Homeworks/3_PoissonImageEditing/README.md: -------------------------------------------------------------------------------- 1 | # 3. 泊松图像编辑 (Poisson Image Editing) 2 | 3 | 4 | ## 作业递交 5 | 6 | - 递交内容:程序代码及实验报告 7 | - 递交时间:2020 年 3 月 8 日星期日 8 | 9 | ## 作业要求 10 | 11 | - 实现 Poisson Image Editing 算法 12 | - 实现多边形光栅化的[扫描线转换算法](documents/ScanningLine.md) 13 | - 学习使用Eigen库求解大型稀疏方程组 14 | - 学习使用 OpenCV 15 | - 实时拖动区域显示结果(Optional) 16 | - 矩阵预分解 17 | 18 | 19 | ## 提供的材料 20 | 21 | 根据上述要求和方法根据两个文件夹`(1) documents`和`(2) project`的内容进行练习。 22 | 23 | ### (1) 说明文档 `documents` [->](documents/) 24 | 25 | 本次作业的要求说明和一些辅助资料 26 | 27 | ### (2) 作业项目 `project` [->](project/) 28 | 29 | 本次作业的基础代码框架 30 | 31 | -------------------------------------------------------------------------------- /Homeworks/3_PoissonImageEditing/project/src/App/ChildWindow.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | QT_BEGIN_NAMESPACE 5 | class QImage; 6 | class QPainter; 7 | class QRect; 8 | class ImageWidget; 9 | QT_END_NAMESPACE 10 | 11 | class ChildWindow : 12 | public QMainWindow 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | ChildWindow(void); 18 | ~ChildWindow(void); 19 | 20 | bool LoadFile(QString filename); 21 | QString current_file() { return current_file_; } 22 | 23 | public slots: 24 | 25 | 26 | public: 27 | ImageWidget *imagewidget_; 28 | QString current_file_; 29 | }; 30 | 31 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/MeshEdit/Glue.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Ubpa { 6 | class TriMesh; 7 | class Glue : public HeapObj { 8 | public: 9 | Glue(Ptr triMesh) { Init(triMesh); } 10 | 11 | public: 12 | static const Ptr New(Ptr triMesh) { 13 | return Ubpa::New(triMesh); 14 | } 15 | 16 | public: 17 | void Init(Ptr triMesh) { this->triMesh = triMesh; } 18 | void Clear() { triMesh = nullptr; } 19 | bool Run(); 20 | 21 | private: 22 | Ptr triMesh; 23 | }; 24 | } 25 | -------------------------------------------------------------------------------- /Homeworks/9_PathTracing/project/src/UEditor/Cmpt/PathTracerAgency.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace Ubpa::Cmpt { 7 | class SObjPtr; 8 | class Material; 9 | class Camera; 10 | class L2W; 11 | class SObjPtr; 12 | 13 | class PathTracerAgency : public Component { 14 | public: 15 | [[range("1,")]] 16 | size_t spp{ 2 }; 17 | [[range("100,")]] 18 | size_t width{ 400 }; 19 | 20 | void OnUpdate(const Cmpt::Camera* cam, const Cmpt::L2W* l2w, const SObjPtr* ptr); 21 | static void OnRegister(); 22 | }; 23 | } 24 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Engine/IBL/brdf.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | #include "../../Math/sample.h" 4 | #include "../BRDF/FDG.h" 5 | #include "../../Math/quat.h" 6 | 7 | out vec3 FragColor; 8 | in vec2 TexCoords; 9 | 10 | // ---------------------------------------------------------------------------- 11 | vec3 IntegrateBRDF(float NdotV, float roughness) 12 | { 13 | // TODO 14 | return vec3(1,1,1); 15 | } 16 | // ---------------------------------------------------------------------------- 17 | void main() 18 | { 19 | FragColor = IntegrateBRDF(TexCoords.x, TexCoords.y); 20 | } 21 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Engine/Material/BSDF.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #include 6 | 7 | using namespace Ubpa; 8 | 9 | const normalf BSDF::TangentSpaceNormalToWorld(const normalf & worldTangent, const normalf & worldNormal, const normalf & tangentSpaceNormal) { 10 | const normalf bitangent = worldTangent.cross(worldNormal); 11 | matf3 TBN(worldTangent.cast_to(), bitangent.cast_to(), worldNormal.cast_to()); 12 | return (TBN * tangentSpaceNormal.cast_to()).normalize().cast_to(); 13 | } 14 | -------------------------------------------------------------------------------- /Homeworks/9_PathTracing/project/src/UEditor/Cmpt/Hierarchy.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | namespace Ubpa { 8 | class SObj; 9 | } 10 | 11 | namespace Ubpa::Cmpt { 12 | class 13 | [[description("Multi-Scene Viewer")]] 14 | Hierarchy : public Component { 15 | public: 16 | Read selected_sobj; 17 | 18 | Hierarchy(); 19 | 20 | void OnUpdate(); 21 | 22 | static void OnRegister(); 23 | 24 | private: 25 | void View_SObj(SObj* sobj); 26 | 27 | int base_flags;// ImGuiTreeNodeFlags 28 | }; 29 | } 30 | -------------------------------------------------------------------------------- /Homeworks/9_PathTracing/project/data/shaders/env.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | #define PI 3.1415926 4 | 5 | out vec3 FragColor; 6 | 7 | in vec3 TexCoord; 8 | 9 | uniform vec3 EnvLight_color; 10 | uniform float EnvLight_intensity; 11 | uniform sampler2D EnvLight_texture; 12 | 13 | void main() 14 | { 15 | vec3 nTexCoord = normalize(TexCoord); 16 | float u = (atan(-nTexCoord.x, -nTexCoord.z) / PI + 1) / 2; 17 | float v = acos(nTexCoord.y) / PI; // reverse: 1 - acos(nTexCoord.y) / PI; 18 | vec3 env = EnvLight_color * EnvLight_intensity * texture(EnvLight_texture, vec2(u, v)).rgb; 19 | FragColor = env; 20 | } 21 | -------------------------------------------------------------------------------- /Homeworks/3_PoissonImageEditing/documents/ScanningLine.md: -------------------------------------------------------------------------------- 1 | # 多边形的扫描转换算法 2 | 3 | 多边形的扫描转换算法是多边形区域光栅化(求解一个平面多边形区域的内部像素)的经典算法,可在任何一本计算机图形学的课本上都能找到,网上也有不少详细介绍资料。 4 | 5 | 算法的基本思想是:通过维持一个特别的数据结构(结构中保存扫描线与多边形的交点)进行填充。 6 | 7 | ![https://cdn.jsdelivr.net/gh/Ubpa/USTC_CG_Data@master/Homeworks/03_PoissonImageEditing/scan_line.jpg](https://cdn.jsdelivr.net/gh/Ubpa/USTC_CG_Data@master/Homeworks/03_PoissonImageEditing/scan_line.jpg) 8 | 9 | > 图片无法加载则访问该链接:[USTC_CG_Data@master/Homeworks/03_PoissonImageEditing/scan_line.jpg](https://cdn.jsdelivr.net/gh/Ubpa/USTC_CG_Data@master/Homeworks/03_PoissonImageEditing/scan_line.jpg) 10 | 11 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Common/basic_P3N3.vs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | #include "camera.h" 4 | 5 | layout (location = 0) in vec3 aPos; 6 | layout (location = 1) in vec3 aNormal; 7 | 8 | out VS_OUT { 9 | vec3 FragPos; 10 | vec3 Normal; 11 | } vs_out; 12 | 13 | uniform mat4 model; 14 | 15 | void main() 16 | { 17 | vec4 worldPos = model * vec4(aPos, 1.0); 18 | vs_out.FragPos = worldPos.xyz; 19 | 20 | mat3 normalMatrix = transpose(inverse(mat3(model))); 21 | vs_out.Normal = normalize(normalMatrix * aNormal); 22 | 23 | gl_Position = projection * view * worldPos; 24 | } -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/App/UEngine/main.cpp: -------------------------------------------------------------------------------- 1 | #include "UEngine.h" 2 | #include 3 | 4 | #include 5 | #include 6 | 7 | int main(int argc, char *argv[]) 8 | { 9 | QApplication a(argc, argv); 10 | 11 | // load style sheet 12 | QFile f(":qdarkstyle/Resources/style.qss"); 13 | if (f.exists()){ 14 | f.open(QFile::ReadOnly | QFile::Text); 15 | QTextStream ts(&f); 16 | qApp->setStyleSheet(ts.readAll()); 17 | } 18 | else 19 | printf("Unable to set stylesheet, file not found\n"); 20 | 21 | UEngine w; 22 | w.show(); 23 | return a.exec(); 24 | } 25 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Engine/Light/DiskLight.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | using namespace Ubpa; 6 | using namespace std; 7 | 8 | const rgbf DiskLight::Sample_L(const pointf3 & p, normalf & wi, float & distToLight, float & PD) const { 9 | cout << "WARNING::DiskLight:" << endl 10 | << "\t" << "not implemented" << endl; 11 | return 0.f; 12 | } 13 | 14 | float DiskLight::PDF(const pointf3 & p, const normalf & wi) const { 15 | cout << "WARNING::DiskLight:" << endl 16 | << "\t" << "not implemented" << endl; 17 | return 0.f; 18 | } 19 | -------------------------------------------------------------------------------- /Homeworks/3_PoissonImageEditing/project/README.md: -------------------------------------------------------------------------------- 1 | # 作业项目 2 | 3 | ## 文件说明 4 | 5 | - [src/](src/):源代码 6 | - [data/](data/):资源文件夹(目前为空) 7 | 8 | ## 使用说明 9 | 10 | ### 测试图片 11 | 12 | 本次作业涉及的测试图片下载方式参考 [data/README.md](data/README.md) 13 | 14 | ### OpenCV 配置 15 | 16 | 本次实验必须用到 OpenCV,**配置方式**和**使用示例**务必参考项目 [documents/opencv_example](../documents/opencv_example) 17 | 18 | ## 其他说明 19 | 20 | - Qt:[简易说明](../../../Softwares/Qt.md) 21 | - CMake-GUI 在 configure 的时候,Optional platform for generator 要选 **x64** 22 | - CMake 一开始会拉取 [UCMake](https://github.com/Ubpa/UCMake),所以会稍微久一点,拉取的 UCMake 位于 `build/_deps/`,内含一些自定义函数 `Ubpa_xxx` 23 | 24 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Basic/ShapeMesh/PlaneMesh.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ShapeMesh.h" 4 | 5 | #include 6 | 7 | namespace Ubpa { 8 | class PlaneMesh : public ShapeMesh { 9 | public: 10 | PlaneMesh(); 11 | float* GetNormalArr(); 12 | float* GetTexCoordsArr(); 13 | unsigned* GetIndexArr(); 14 | unsigned GetNormalArrSize(); 15 | unsigned GetTexCoordsArrSize(); 16 | unsigned GetIndexArrSize(); 17 | protected: 18 | std::vector> normalArr; 19 | std::vector> texCoordsArr; 20 | std::vector> indexArr; 21 | }; 22 | } 23 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Engine/Skybox/skybox.vs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | layout (location = 0) in vec3 aPos; 3 | 4 | out vec3 TexCoords; 5 | 6 | // 160 7 | layout (std140) uniform Camera{ 8 | mat4 view; // 64 0 64 9 | mat4 projection; // 64 64 64 10 | vec3 viewPos; // 12 128 144 11 | float nearPlane; // 4 144 148 12 | float farPlane; // 4 148 152 13 | float fov; // 4 152 156 14 | float ar; // 4 156 160 15 | }; 16 | 17 | void main() 18 | { 19 | TexCoords = aPos; 20 | mat4 viewNoT = mat4(mat3(view)); 21 | vec4 pos = projection * viewNoT * vec4(aPos, 1.0); 22 | gl_Position = pos.xyww; 23 | } 24 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Basic/TypeMap.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace Ubpa { 7 | using TypeInfoRef = std::reference_wrapper; 8 | 9 | struct Hasher { 10 | std::size_t operator()(TypeInfoRef code) const 11 | { 12 | return code.get().hash_code(); 13 | } 14 | }; 15 | 16 | struct EqualTo { 17 | bool operator()(TypeInfoRef lhs, TypeInfoRef rhs) const 18 | { 19 | return lhs.get() == rhs.get(); 20 | } 21 | }; 22 | 23 | template 24 | using TypeMap = std::unordered_map; 25 | } 26 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Engine.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include 18 | #include 19 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Engine/Light/SphereLight.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | using namespace Ubpa; 6 | 7 | using namespace std; 8 | 9 | const rgbf SphereLight::Sample_L(const pointf3 & p, normalf & wi, float & distToLight, float & PD) const { 10 | cout << "WARNING::SphereLight:" << endl 11 | << "\t" << "not implemented" << endl; 12 | return 0.f; 13 | } 14 | 15 | float SphereLight::PDF(const pointf3 & p, const normalf & wi) const { 16 | cout << "WARNING::SphereLight:" << endl 17 | << "\t" << "not implemented" << endl; 18 | return 0.f; 19 | } 20 | -------------------------------------------------------------------------------- /Homeworks/1_MiniDraw/documents/hello/src/hello/mainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class MainWindow; 8 | } 9 | 10 | class MainWindow : public QMainWindow 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit MainWindow(QWidget *parent = nullptr); 16 | ~MainWindow(); 17 | 18 | 19 | private: 20 | Ui::MainWindow *ui; 21 | 22 | QAction* hello_world_action_; 23 | QMenu* main_menu_; 24 | QToolBar* main_toolbar_; 25 | void CreateButtons(); 26 | 27 | private slots: 28 | void HelloWorld(); 29 | }; 30 | 31 | #endif // MAINWINDOW_H 32 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Engine/Viewer/Picker.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace Ubpa { 7 | class Viewer; 8 | 9 | class ClosestIntersector; 10 | 11 | class Picker final : public HeapObj { 12 | public: 13 | Picker(Viewer* viewer); 14 | 15 | public: 16 | static const Ptr New(Viewer* viewer) { 17 | return Ubpa::New(viewer); 18 | } 19 | 20 | protected: 21 | virtual ~Picker() = default; 22 | 23 | public: 24 | void Init(); 25 | 26 | Viewer* GetViewer() const { return viewer; } 27 | 28 | private: 29 | Viewer* viewer; 30 | }; 31 | } 32 | -------------------------------------------------------------------------------- /Homeworks/7_SimulationTaichi/project/README.md: -------------------------------------------------------------------------------- 1 | # 项目说明 2 | 3 | ## 简介 4 | 5 | - 本项目是 Taichi 的简单使用,包含了若干示例代码: 6 | - example_00_mls_mpm88:为作者提供的示例代码 7 | - example_01_mls_mpm88_x:同上,规范了格式、注释等 8 | - example_02_mls_mpm88_snowball:为我们提供的示例,两团雪在空中碰撞掉落地上的仿真 9 | - example_03_mls_mpm88_cubes:为我们提供的示例,三个方块(2个雪块和1个刚性块)碰撞掉落地上的仿真 10 | - example_04_mls_mpm88_fountain:为我们提供的示例,一个不断喷出水的喷泉的仿真 11 | 12 | - 本次作业通过需要修改 [src/app/main.cpp](src/app/main.cpp) 来完成各种仿真结果 13 | 14 | ### 项目配置 15 | 16 | - 下载库文件 [taichi.h](https://cdn.jsdelivr.net/gh/Ubpa/USTC_CG_Data@master/Homeworks/07_SimulationTaichi/mls_mpm88/taichi.h) 并放到 `include/_deps/` 中(自行创建文件夹) 17 | 18 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Basic/ShapeMesh/CubeMesh.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ShapeMesh.h" 4 | 5 | namespace Ubpa { 6 | class CubeMesh : public ShapeMesh { 7 | public: 8 | CubeMesh(); 9 | float* GetNormalArr(); 10 | float* GetTexCoordsArr(); 11 | unsigned* GetIndexArr(); 12 | unsigned GetNormalArrSize(); 13 | unsigned GetTexCoordsArrSize(); 14 | unsigned GetIndexArrSize(); 15 | protected: 16 | std::vector> normalArr; 17 | std::vector> texCoordsArr; 18 | std::vector> indexArr; 19 | static const float CubeMeshData[192]; 20 | }; 21 | } 22 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Basic/Sampler/BasicSampler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace Ubpa { 8 | namespace BasicSampler { 9 | const pointf2 UniformInSquare(); 10 | 11 | // Concentric 12 | const pointf2 UniformInDisk(); 13 | 14 | const pointf2 UniformOnDisk(); 15 | 16 | //const pointf3 UniformInSphereMesh(); 17 | 18 | const vecf3 UniformOnSphere(); 19 | const vecf3 UniformOnSphere(float& pd); 20 | float PDofUniformOnSphere(); 21 | 22 | const vecf3 CosOnHalfSphereMesh(); 23 | 24 | const vecf3 CosOnSphereMesh(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Homeworks/9_PathTracing/project/src/UEditor/Cmpt/Inspector.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include 8 | 9 | namespace Ubpa { 10 | class SObj; 11 | } 12 | 13 | namespace Ubpa::Cmpt { 14 | class Hierarchy; 15 | 16 | class 17 | [[description("SObj's components Viewer")]] 18 | Inspector : public Component/*, public VarPtrVisitor*/ { 19 | public: 20 | 21 | void OnUpdate(const Hierarchy* hierarchy); 22 | 23 | static void OnRegister(); 24 | 25 | protected: 26 | class Viewer_Cmpt; 27 | class Viewer_Obj; 28 | class Viewer_Var; 29 | }; 30 | } 31 | -------------------------------------------------------------------------------- /Homeworks/1_MiniDraw/project/src/App/viewwidget.ui: -------------------------------------------------------------------------------- 1 | 2 | ViewWidget 3 | 4 | 5 | ViewWidget 6 | 7 | 8 | 9 | 0 10 | 0 11 | 400 12 | 300 13 | 14 | 15 | 16 | ViewWidget 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Homeworks/1_MiniDraw/documents/example/src/example/example.cpp: -------------------------------------------------------------------------------- 1 | #include "example.h" 2 | 3 | example::example(QWidget *parent) 4 | : QMainWindow(parent) 5 | { 6 | ui.setupUi(this); 7 | pAction = new QAction(tr("&hello"),this); 8 | 9 | pMenutest = menuBar()->addMenu(tr("&Test")); 10 | pMenutest->addAction(pAction); 11 | 12 | main_toolbar_ = addToolBar(tr("&Main")); 13 | main_toolbar_->addAction(pAction); 14 | 15 | connect(pAction, &QAction::triggered, this, &example::hello); 16 | } 17 | 18 | example::~example() 19 | { 20 | 21 | } 22 | 23 | void example::hello() 24 | { 25 | QMessageBox::information(NULL, "Hello", "Hello, Qt", QMessageBox::Yes); 26 | } 27 | -------------------------------------------------------------------------------- /Homeworks/1_MiniDraw/project/src/App/minidraw.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | class MiniDraw : public QMainWindow { 10 | Q_OBJECT 11 | 12 | public: 13 | MiniDraw(QWidget* parent = 0); 14 | ~MiniDraw(); 15 | 16 | QMenu* pMenu; 17 | QToolBar* pToolBar; 18 | QAction* Action_About; 19 | QAction* Action_Line; 20 | QAction* Action_Rect; 21 | 22 | void Creat_Menu(); 23 | void Creat_ToolBar(); 24 | void Creat_Action(); 25 | 26 | void AboutBox(); 27 | 28 | private: 29 | Ui::MiniDrawClass ui; 30 | ViewWidget* view_widget_; 31 | }; 32 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Scene/CmptMaterial.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Ubpa { 6 | class Material; 7 | 8 | class CmptMaterial : public Component { 9 | public: 10 | CmptMaterial(Ptr sobj = nullptr, Ptr material = nullptr) 11 | : Component(sobj), material(material) { } 12 | 13 | public: 14 | static const Ptr New(Ptr sobj, Ptr material) { 15 | return Ubpa::New(sobj, material); 16 | } 17 | 18 | protected: 19 | virtual ~CmptMaterial() = default; 20 | 21 | public: 22 | Ptr material; 23 | }; 24 | } 25 | -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/documents/README.md: -------------------------------------------------------------------------------- 1 | # 作业说明文档 2 | 3 | 以下是本次热身练习(包含5个小练习)的学习目标。 4 | 5 | ## [1. 基础的动态数组](1_BasicDArray/) 6 | 7 | - 对于只有C语言编程基础的同学:初步学习从C语言编程到C++语言编程的过渡 8 | - 初步了解类(对象)的编写,了解构造函数、析构函数、函数重载等 9 | - 熟悉和巩固指针、动态内存分配的机制与操作 10 | 11 | ## [2. 高效的动态数组](2_EfficientDArray/) 12 | 13 | - 进一步巩固指针、动态内存分配的机制与操作 14 | - 深刻理解对象的 public 接口的重要性 15 | 16 | ## [3. 模板动态数组](3_TemplateDArray/) 17 | 18 | - 学习和使用 template 模板 19 | - 初步了解和使用STL的vector,并深刻理解其原理与机制 20 | 21 | ## [4. 基于 `list` 的多项式类](4_list_Polynomial/) 22 | 23 | - 了解动态库的编写与使用 24 | - 学习 STL 的 `list` 的使用 25 | 26 | ## [5. 基于 `map` 的多项式类](5_map_Polynomial/) 27 | 28 | - 了解静态库的编写与使用 29 | - 学习 STL 的 `map` 的使用 30 | 31 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Scene/CmptGeometry.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Ubpa { 6 | class Primitive; 7 | 8 | class CmptGeometry : public Component { 9 | public: 10 | CmptGeometry(Ptr sobj = nullptr, Ptr primitive = nullptr) 11 | : Component(sobj), primitive(primitive) { } 12 | 13 | public: 14 | static const Ptr New(Ptr sobj, Ptr primitive) { 15 | return Ubpa::New(sobj, primitive); 16 | } 17 | 18 | protected: 19 | virtual ~CmptGeometry() = default; 20 | 21 | public: 22 | Ptr primitive; 23 | }; 24 | } 25 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Engine/Light/CapsuleLight.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | 6 | using namespace Ubpa; 7 | 8 | using namespace std; 9 | 10 | const rgbf CapsuleLight::Sample_L(const pointf3 & p, normalf & wi, float & distToLight, float & PD) const { 11 | cout << "WARNING::CapsuleLight:" << endl 12 | << "\t" << "not implemented" << endl; 13 | return 0.f; 14 | } 15 | 16 | float CapsuleLight::PDF(const pointf3 & p, const normalf & wi) const { 17 | cout << "WARNING::CapsuleLight:" << endl 18 | << "\t" << "not implemented" << endl; 19 | return 0.f; 20 | } 21 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Viewer/Ray.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Ubpa { 6 | class Ray : public rayf3 { 7 | public: 8 | Ray(const pointf3& origin = pointf3(0.f, 0.f, 0.f), const vecf3& dir = vecf3(1.f, 1.f, 1.f), float tMin = 0.001f, float tMax = FLT_MAX) 9 | : rayf3(origin, dir), tMin(tMin), tMax(tMax) { } 10 | 11 | public: 12 | const pointf3 StartPos() const { return (*this)(tMin); } 13 | const pointf3 EndPos() const { return (*this)(tMax); } 14 | 15 | const valf3 InvDir() const { return{ 1.f / d[0], 1.f / d[1], 1.f / d[2] }; } 16 | 17 | public: 18 | float tMin; 19 | float tMax; 20 | }; 21 | } 22 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Filter/FilterTriangle.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ImgFilter.h" 4 | 5 | namespace Ubpa { 6 | class FilterTriangle : public ImgFilter { 7 | public: 8 | FilterTriangle(const vecf2& radius) : ImgFilter(radius) { } 9 | 10 | protected: 11 | virtual ~FilterTriangle() = default; 12 | 13 | public: 14 | const Ptr New(const vecf2& radius) { 15 | return Ubpa::New(radius); 16 | } 17 | 18 | public: 19 | virtual float Evaluate(const pointf2& p) const override { 20 | const auto delta = (radius - vecf2(p.Abs())).MaxWith({ 0,0 }); 21 | return delta[0] * delta[1]; 22 | } 23 | }; 24 | } 25 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Viewer/WireframeRaster.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Ubpa { 6 | class WireframeRaster : public ForwardRaster { 7 | public: 8 | WireframeRaster(RawAPI_OGLW* pOGLW, Ptr scene, Ptr camera) 9 | : ForwardRaster(pOGLW, scene, camera) { } 10 | 11 | public: 12 | static Ptr New(RawAPI_OGLW* pOGLW, Ptr scene, Ptr camera) { 13 | return Ubpa::New(pOGLW, scene, camera); 14 | } 15 | 16 | protected: 17 | virtual ~WireframeRaster() = default; 18 | 19 | public: 20 | virtual void Init() override; 21 | }; 22 | } 23 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Basic/Operation/OpQueue.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | using namespace Ubpa; 6 | 7 | using namespace std; 8 | 9 | void OpQueue::Push(Ptr op) { 10 | if (op != nullptr) 11 | opList.push_back(op); 12 | } 13 | 14 | void OpQueue::Run() { 15 | stack< list>::const_iterator > removeIts; 16 | for (auto it = opList.cbegin(); it != opList.cend(); ++it) { 17 | (*it)->Run(); 18 | if (!(*it)->isHold) 19 | removeIts.push(it); 20 | } 21 | 22 | while (!removeIts.empty()) { 23 | opList.erase(removeIts.top()); 24 | removeIts.pop(); 25 | } 26 | 27 | if (opList.empty()) 28 | isHold = false; 29 | } 30 | -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/documents/1_BasicDArray/C2Cpp/src/Array5/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #include "Array.h" 5 | 6 | void main() 7 | { 8 | // test double array 9 | DArray pa; 10 | 11 | //pa.InitArray( ); 12 | 13 | pa.SetArraySize( 3 ); 14 | pa.SetValue( 0, 1.0 ); 15 | pa.SetValue( 1, 2.0 ); 16 | pa.SetValue( 2, 3.0 ); 17 | 18 | pa.PrintArray( ); 19 | 20 | //pa.FreeArray( ); 21 | 22 | 23 | 24 | // test int array 25 | DArray pb; 26 | 27 | //pb.InitArray( ); 28 | 29 | pb.SetArraySize( 3 ); 30 | pb.SetValue( 0, 10 ); 31 | pb.SetValue( 1, 11 ); 32 | pb.SetValue( 2, 12 ); 33 | 34 | pb.PrintArray( ); 35 | 36 | //pb.FreeArray( ); 37 | } 38 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Common/basic_P3N3_invN.vs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | #include "camera.h" 4 | 5 | layout (location = 0) in vec3 aPos; 6 | layout (location = 1) in vec3 aNormal; 7 | 8 | out VS_OUT { 9 | vec3 FragPos; 10 | vec3 Normal; 11 | } vs_out; 12 | 13 | uniform mat4 model; 14 | 15 | uniform bool invertedNormals; 16 | 17 | void main() 18 | { 19 | vec4 worldPos = model * vec4(aPos, 1.0); 20 | vs_out.FragPos = worldPos.xyz; 21 | 22 | mat3 normalMatrix = transpose(inverse(mat3(model))); 23 | vs_out.Normal = normalize(normalMatrix * (invertedNormals ? -aNormal : aNormal)); 24 | 25 | gl_Position = projection * view * worldPos; 26 | } -------------------------------------------------------------------------------- /Homeworks/6_MassSpring/documents/tetgen/data/cube.poly: -------------------------------------------------------------------------------- 1 | # Part 1 - node list 2 | # node count, 3 dim, no attribute, no boundary marker 3 | 8 3 0 0 4 | # Node index, node coordinates 5 | 0 0.0 0.0 0.0 6 | 1 2.0 0.0 0.0 7 | 2 2.0 2.5 0.0 8 | 3 0.0 2.5 0.0 9 | 4 0.0 0.0 2.0 10 | 5 2.0 0.0 2.0 11 | 6 2.0 2.5 2.0 12 | 7 0.0 2.5 2.0 13 | # Part 2 - facet list 14 | # facet count, with boundary marker 15 | 6 1 16 | # facets 17 | 1 18 | 4 0 1 2 3 # front 19 | 1 20 | 4 4 5 6 7 # back 21 | 1 0 2 #boundary marker 2 22 | 4 0 1 5 4 # bottom 23 | 1 24 | 4 1 2 6 5 # right 25 | 1 26 | 4 2 3 7 6 # top 27 | 1 28 | 4 3 0 4 7 # left 29 | # Part 3 - hole list 30 | 0 # no hole 31 | # Part 4 - region list 32 | 0 # no region -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Basic/ShapeMesh/DiskMesh.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ShapeMesh.h" 4 | 5 | #include 6 | 7 | namespace Ubpa { 8 | class DiskMesh : public ShapeMesh { 9 | public: 10 | DiskMesh(unsigned n); 11 | float* GetNormalArr(); 12 | float* GetTexCoordsArr(); 13 | unsigned* GetIndexArr(); 14 | float* GetTangentArr(); 15 | unsigned GetNormalArrSize(); 16 | unsigned GetTexCoordsArrSize(); 17 | unsigned GetIndexArrSize(); 18 | unsigned GetTangentArrSize(); 19 | protected: 20 | std::vector normalArr; 21 | std::vector texCoordsArr; 22 | std::vector indexArr; 23 | std::vector tangentArr; 24 | }; 25 | } 26 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Engine/Viewer/WireframeRaster.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | 16 | #include 17 | 18 | using namespace Ubpa; 19 | 20 | using namespace Define; 21 | using namespace std; 22 | 23 | void WireframeRaster::Init() { 24 | ForwardRaster::Init(); 25 | 26 | glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); 27 | 28 | SetDrawSky(false); 29 | } 30 | -------------------------------------------------------------------------------- /Homeworks/8_Shader/project/data/shaders/p3t2n3.vert: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | layout (location = 0) in vec3 aPos; 4 | layout (location = 1) in vec2 aTexCoord; 5 | layout (location = 2) in vec3 aNormal; 6 | 7 | out VS_OUT { 8 | vec3 WorldPos; 9 | vec2 TexCoord; 10 | vec3 Normal; 11 | } vs_out; 12 | 13 | uniform mat4 projection; 14 | uniform mat4 view; 15 | uniform mat4 model; 16 | 17 | void main() 18 | { 19 | vec4 worldPos = model * vec4(aPos, 1.0); 20 | 21 | vs_out.WorldPos = worldPos.xyz / worldPos.w; 22 | vs_out.TexCoord = aTexCoord; 23 | vs_out.Normal = normalize(transpose(inverse(mat3(model))) * aNormal); 24 | 25 | gl_Position = projection * view * worldPos; 26 | } 27 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Basic/Array2D.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Ubpa { 6 | template 7 | class Array2D { 8 | public: 9 | static constexpr int width = W; 10 | static constexpr int height = H; 11 | static constexpr int size = W * H; 12 | 13 | public: 14 | T& At(int x, int y) { return this->operator()(x, y); } 15 | T& operator()(int x, int y) { 16 | assert(x >= 0 && x < W - 1); 17 | assert(y >= 0 && y < H - 1); 18 | return data[y * W + x]; 19 | } 20 | 21 | const T* GetData() const& { data.data(); } 22 | T* GetData()& { data.data(); } 23 | 24 | private: 25 | std::array data; 26 | }; 27 | } 28 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Basic/ShapeMesh/SphereMesh.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ShapeMesh.h" 4 | 5 | #include 6 | 7 | namespace Ubpa { 8 | class SphereMesh : public ShapeMesh { 9 | public: 10 | SphereMesh(unsigned n); 11 | float* GetNormalArr(); 12 | float* GetTexCoordsArr(); 13 | unsigned* GetIndexArr(); 14 | float* GetTangentArr(); 15 | unsigned GetNormalArrSize(); 16 | unsigned GetTexCoordsArrSize(); 17 | unsigned GetIndexArrSize(); 18 | unsigned GetTangentArrSize(); 19 | protected: 20 | std::vector normalArr; 21 | std::vector texCoordsArr; 22 | std::vector indexArr; 23 | std::vector tangentArr; 24 | }; 25 | } 26 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Engine/Material/Beckmann.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | using namespace Ubpa; 6 | using namespace std; 7 | 8 | float Beckmann::D(const normalf & wh) const { 9 | cout << "WARNING::Beckmann:" << endl 10 | << "\t" << "not implemented" << endl; 11 | return 0.f; 12 | } 13 | 14 | float Beckmann::Lambda(const normalf & w) const { 15 | cout << "WARNING::Beckmann:" << endl 16 | << "\t" << "not implemented" << endl; 17 | return 0.f; 18 | } 19 | 20 | const normalf Beckmann::Sample_wh() const { 21 | cout << "WARNING::Beckmann:" << endl 22 | << "\t" << "not implemented" << endl; 23 | return 0.f; 24 | } 25 | -------------------------------------------------------------------------------- /Homeworks/8_Shader/project/src/tool/SimpleLoader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Ubpa { 6 | namespace SimpleLoader { 7 | class OGLResources { 8 | public: 9 | ~OGLResources(); 10 | gl::VertexArray* va{ nullptr }; 11 | std::map name2vb; 12 | gl::ElementBuffer* eb{ nullptr }; 13 | std::vector positions; 14 | std::vector normals; 15 | std::vector texcoords; 16 | std::vector indices; 17 | std::vector tangents; 18 | }; 19 | 20 | // noise: position[p] += 0.05 * Xi * normal[p], Xi is random in [0, 1] 21 | OGLResources* LoadObj(const std::string& path, bool noise = false); 22 | } 23 | } -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/project/cmake/InitUCMake.cmake: -------------------------------------------------------------------------------- 1 | macro(Ubpa_InitUCMake) 2 | include(FetchContent) 3 | set(UCMake_VERSION 0.6.0) 4 | message(STATUS "find package: UCMake ${UCMake_VERSION}") 5 | find_package(UCMake ${UCMake_VERSION} QUIET) 6 | if(NOT UCMake_FOUND) 7 | message(STATUS "UCMake ${UCMake_VERSION} not found") 8 | set(_address "https://github.com/Ubpa/UCMake") 9 | message(STATUS "fetch: ${_address} with tag ${UCMake_VERSION}") 10 | FetchContent_Declare( 11 | UCMake 12 | GIT_REPOSITORY ${_address} 13 | GIT_TAG ${UCMake_VERSION} 14 | ) 15 | FetchContent_MakeAvailable(UCMake) 16 | message(STATUS "UCMake ${UCMake_VERSION} build done") 17 | endif() 18 | endmacro() 19 | -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/samples/cmake/InitUCMake.cmake: -------------------------------------------------------------------------------- 1 | macro(Ubpa_InitUCMake) 2 | include(FetchContent) 3 | set(UCMake_VERSION 0.6.0) 4 | message(STATUS "find package: UCMake ${UCMake_VERSION}") 5 | find_package(UCMake ${UCMake_VERSION} QUIET) 6 | if(NOT UCMake_FOUND) 7 | message(STATUS "UCMake ${UCMake_VERSION} not found") 8 | set(_address "https://github.com/Ubpa/UCMake") 9 | message(STATUS "fetch: ${_address} with tag ${UCMake_VERSION}") 10 | FetchContent_Declare( 11 | UCMake 12 | GIT_REPOSITORY ${_address} 13 | GIT_TAG ${UCMake_VERSION} 14 | ) 15 | FetchContent_MakeAvailable(UCMake) 16 | message(STATUS "UCMake ${UCMake_VERSION} build done") 17 | endif() 18 | endmacro() 19 | -------------------------------------------------------------------------------- /Homeworks/1_MiniDraw/project/cmake/InitUCMake.cmake: -------------------------------------------------------------------------------- 1 | macro(Ubpa_InitUCMake) 2 | include(FetchContent) 3 | set(UCMake_VERSION 0.6.1) 4 | message(STATUS "find package: UCMake ${UCMake_VERSION}") 5 | find_package(UCMake ${UCMake_VERSION} QUIET) 6 | if(NOT UCMake_FOUND) 7 | message(STATUS "UCMake ${UCMake_VERSION} not found") 8 | set(_address "https://github.com/Ubpa/UCMake") 9 | message(STATUS "fetch: ${_address} with tag ${UCMake_VERSION}") 10 | FetchContent_Declare( 11 | UCMake 12 | GIT_REPOSITORY ${_address} 13 | GIT_TAG ${UCMake_VERSION} 14 | ) 15 | FetchContent_MakeAvailable(UCMake) 16 | message(STATUS "UCMake ${UCMake_VERSION} build done") 17 | endif() 18 | endmacro() 19 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Engine/Light/SpotLight.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace Ubpa; 4 | 5 | using namespace std; 6 | 7 | float SpotLight::Fwin(float d, float radius) { 8 | cout << "WARNING::SpotLight:" << endl 9 | << "\t" << "not implemented" << endl; 10 | return 0.f; 11 | } 12 | 13 | const rgbf SpotLight::Sample_L(const pointf3 & p, normalf & wi, float & distToLight, float & PD) const { 14 | cout << "WARNING::SpotLight:" << endl 15 | << "\t" << "not implemented" << endl; 16 | return 0.f; 17 | } 18 | 19 | float SpotLight::Falloff(const normalf & wi) const { 20 | cout << "WARNING::SpotLight:" << endl 21 | << "\t" << "not implemented" << endl; 22 | return 0.f; 23 | } 24 | -------------------------------------------------------------------------------- /Homeworks/1_MiniDraw/documents/hello/cmake/InitUCMake.cmake: -------------------------------------------------------------------------------- 1 | macro(Ubpa_InitUCMake) 2 | include(FetchContent) 3 | set(UCMake_VERSION 0.6.1) 4 | message(STATUS "find package: UCMake ${UCMake_VERSION}") 5 | find_package(UCMake ${UCMake_VERSION} QUIET) 6 | if(NOT UCMake_FOUND) 7 | message(STATUS "UCMake ${UCMake_VERSION} not found") 8 | set(_address "https://github.com/Ubpa/UCMake") 9 | message(STATUS "fetch: ${_address} with tag ${UCMake_VERSION}") 10 | FetchContent_Declare( 11 | UCMake 12 | GIT_REPOSITORY ${_address} 13 | GIT_TAG ${UCMake_VERSION} 14 | ) 15 | FetchContent_MakeAvailable(UCMake) 16 | message(STATUS "UCMake ${UCMake_VERSION} build done") 17 | endif() 18 | endmacro() 19 | -------------------------------------------------------------------------------- /Homeworks/2_ImageWarping/project/cmake/InitUCMake.cmake: -------------------------------------------------------------------------------- 1 | macro(Ubpa_InitUCMake) 2 | include(FetchContent) 3 | set(UCMake_VERSION 0.6.0) 4 | message(STATUS "find package: UCMake ${UCMake_VERSION}") 5 | find_package(UCMake ${UCMake_VERSION} QUIET) 6 | if(NOT UCMake_FOUND) 7 | message(STATUS "UCMake ${UCMake_VERSION} not found") 8 | set(_address "https://github.com/Ubpa/UCMake") 9 | message(STATUS "fetch: ${_address} with tag ${UCMake_VERSION}") 10 | FetchContent_Declare( 11 | UCMake 12 | GIT_REPOSITORY ${_address} 13 | GIT_TAG ${UCMake_VERSION} 14 | ) 15 | FetchContent_MakeAvailable(UCMake) 16 | message(STATUS "UCMake ${UCMake_VERSION} build done") 17 | endif() 18 | endmacro() 19 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Common/basic_P3N3T2.vs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | #include "camera.h" 4 | 5 | layout (location = 0) in vec3 aPos; 6 | layout (location = 1) in vec3 aNormal; 7 | layout (location = 2) in vec2 aTexCoords; 8 | 9 | out VS_OUT { 10 | vec3 FragPos; 11 | vec3 Normal; 12 | vec2 TexCoords; 13 | } vs_out; 14 | 15 | uniform mat4 model; 16 | 17 | void main() 18 | { 19 | vec4 worldPos = model * vec4(aPos, 1.0); 20 | vs_out.FragPos = worldPos.xyz; 21 | vs_out.TexCoords = aTexCoords; 22 | 23 | mat3 normalMatrix = transpose(inverse(mat3(model))); 24 | vs_out.Normal = normalize(normalMatrix * aNormal); 25 | 26 | gl_Position = projection * view * worldPos; 27 | } -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Basic/Op/OpQueue.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Op.h" 4 | 5 | #include 6 | 7 | namespace Ubpa { 8 | class OpQueue final : public Op { 9 | public: 10 | OpQueue(bool isHold = true) : Op(isHold) { } 11 | 12 | public: 13 | static const Ptr New(bool isHold = true) { return Ubpa::New(isHold); } 14 | 15 | public: 16 | void Push(Ptr op); 17 | OpQueue& operator<<(Ptr op) { 18 | Push(op); 19 | return *this; 20 | } 21 | 22 | virtual void Run() override; 23 | 24 | bool IsEmpty() const { return opList.empty(); } 25 | 26 | private: 27 | virtual ~OpQueue() = default; 28 | 29 | private: 30 | std::list> opList; 31 | }; 32 | } 33 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Scene/CmptLight.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | namespace Ubpa { 8 | class Light; 9 | 10 | class CmptLight : public Component { 11 | public: 12 | CmptLight(Ptr sobj = nullptr, Ptr light = nullptr) 13 | : Component(sobj), light(light) { } 14 | 15 | public: 16 | static const Ptr New(Ptr sobj, Ptr light) { 17 | return Ubpa::New(sobj, light); 18 | } 19 | 20 | protected: 21 | virtual ~CmptLight() = default; 22 | 23 | public: 24 | transformf GetLightToWorldMatrixWithoutScale() const; 25 | 26 | public: 27 | Ptr light; 28 | }; 29 | } 30 | -------------------------------------------------------------------------------- /Homeworks/1_MiniDraw/documents/example/cmake/InitUCMake.cmake: -------------------------------------------------------------------------------- 1 | macro(Ubpa_InitUCMake) 2 | include(FetchContent) 3 | set(UCMake_VERSION 0.6.1) 4 | message(STATUS "find package: UCMake ${UCMake_VERSION}") 5 | find_package(UCMake ${UCMake_VERSION} QUIET) 6 | if(NOT UCMake_FOUND) 7 | message(STATUS "UCMake ${UCMake_VERSION} not found") 8 | set(_address "https://github.com/Ubpa/UCMake") 9 | message(STATUS "fetch: ${_address} with tag ${UCMake_VERSION}") 10 | FetchContent_Declare( 11 | UCMake 12 | GIT_REPOSITORY ${_address} 13 | GIT_TAG ${UCMake_VERSION} 14 | ) 15 | FetchContent_MakeAvailable(UCMake) 16 | message(STATUS "UCMake ${UCMake_VERSION} build done") 17 | endif() 18 | endmacro() 19 | -------------------------------------------------------------------------------- /Homeworks/3_PoissonImageEditing/project/cmake/InitUCMake.cmake: -------------------------------------------------------------------------------- 1 | macro(Ubpa_InitUCMake) 2 | include(FetchContent) 3 | set(UCMake_VERSION 0.6.0) 4 | message(STATUS "find package: UCMake ${UCMake_VERSION}") 5 | find_package(UCMake ${UCMake_VERSION} QUIET) 6 | if(NOT UCMake_FOUND) 7 | message(STATUS "UCMake ${UCMake_VERSION} not found") 8 | set(_address "https://github.com/Ubpa/UCMake") 9 | message(STATUS "fetch: ${_address} with tag ${UCMake_VERSION}") 10 | FetchContent_Declare( 11 | UCMake 12 | GIT_REPOSITORY ${_address} 13 | GIT_TAG ${UCMake_VERSION} 14 | ) 15 | FetchContent_MakeAvailable(UCMake) 16 | message(STATUS "UCMake ${UCMake_VERSION} build done") 17 | endif() 18 | endmacro() 19 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Engine/PointLight/genDepth.gs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | layout (triangles) in; 3 | layout (triangle_strip, max_vertices=18) out; 4 | 5 | uniform mat4 shadowMatrices[6]; 6 | 7 | out vec4 FragPos; // FragPos from GS (output per emitvertex) 8 | 9 | void main() 10 | { 11 | for(int face = 0; face < 6; ++face) 12 | { 13 | gl_Layer = face; // built-in variable that specifies to which face we render. 14 | for(int i = 0; i < 3; ++i) // for each triangle's vertices 15 | { 16 | FragPos = gl_in[i].gl_Position; 17 | gl_Position = shadowMatrices[face] * FragPos; 18 | EmitVertex(); 19 | } 20 | EndPrimitive(); 21 | } 22 | } -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Engine/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_GlobGroupSrcs(RST sources PATHS 2 | ${CMAKE_CURRENT_SOURCE_DIR} 3 | "${PROJECT_SOURCE_DIR}/include/Engine" 4 | ) 5 | Ubpa_GetTargetName(OpenGL "${PROJECT_SOURCE_DIR}/src/OpenGL") 6 | Ubpa_GetTargetName(Qt "${PROJECT_SOURCE_DIR}/src/Qt") 7 | 8 | set(libs ${OpenGL} ${Qt} Qt5::Widgets) 9 | 10 | if(TARGET assimp::assimp) 11 | list(APPEND libs assimp::assimp) 12 | add_definitions(-DUSE_ASSIMP) 13 | endif() 14 | 15 | if(TARGET tinyxml2::tinyxml2) 16 | list(APPEND libs tinyxml2::tinyxml2) 17 | add_definitions(-DUSE_TINYXML2) 18 | endif() 19 | 20 | list(APPEND libs Ubpa::UHEMesh_core Ubpa::UDP_core) 21 | 22 | Ubpa_AddTarget(MODE "LIB" SOURCES ${sources} LIBS ${libs}) 23 | -------------------------------------------------------------------------------- /Homeworks/2_ImageWarping/documents/ann_example/cmake/InitUCMake.cmake: -------------------------------------------------------------------------------- 1 | macro(Ubpa_InitUCMake) 2 | include(FetchContent) 3 | set(UCMake_VERSION 0.6.0) 4 | message(STATUS "find package: UCMake ${UCMake_VERSION}") 5 | find_package(UCMake ${UCMake_VERSION} QUIET) 6 | if(NOT UCMake_FOUND) 7 | message(STATUS "UCMake ${UCMake_VERSION} not found") 8 | set(_address "https://github.com/Ubpa/UCMake") 9 | message(STATUS "fetch: ${_address} with tag ${UCMake_VERSION}") 10 | FetchContent_Declare( 11 | UCMake 12 | GIT_REPOSITORY ${_address} 13 | GIT_TAG ${UCMake_VERSION} 14 | ) 15 | FetchContent_MakeAvailable(UCMake) 16 | message(STATUS "UCMake ${UCMake_VERSION} build done") 17 | endif() 18 | endmacro() 19 | -------------------------------------------------------------------------------- /Homeworks/2_ImageWarping/documents/eigen_example/src/test/00_LinearEquation/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | using namespace std; 6 | using namespace Eigen; 7 | 8 | int main() { 9 | MatrixXf A(4, 4); 10 | 11 | float data[4][4] = { 12 | {1, 0, 0, 0}, 13 | {0, 1, 0, 0}, 14 | {0, 0, 1, 0}, 15 | {0, 0, 0, 1} 16 | }; 17 | 18 | for (size_t row = 0; row < 4; row++) { 19 | for (size_t col = 0; col < 4; col++) 20 | A(row, col) = data[row][col]; 21 | } 22 | 23 | MatrixXf b(4, 2); 24 | for (size_t row = 0; row < 4; row++) { 25 | b(row, 0) = 1; 26 | b(row, 1) = 2; 27 | } 28 | 29 | MatrixXf x = A.colPivHouseholderQr().solve(b); 30 | 31 | cout << x << endl; 32 | 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /Homeworks/2_ImageWarping/documents/eigen_example/cmake/InitUCMake.cmake: -------------------------------------------------------------------------------- 1 | macro(Ubpa_InitUCMake) 2 | include(FetchContent) 3 | set(UCMake_VERSION 0.6.0) 4 | message(STATUS "find package: UCMake ${UCMake_VERSION}") 5 | find_package(UCMake ${UCMake_VERSION} QUIET) 6 | if(NOT UCMake_FOUND) 7 | message(STATUS "UCMake ${UCMake_VERSION} not found") 8 | set(_address "https://github.com/Ubpa/UCMake") 9 | message(STATUS "fetch: ${_address} with tag ${UCMake_VERSION}") 10 | FetchContent_Declare( 11 | UCMake 12 | GIT_REPOSITORY ${_address} 13 | GIT_TAG ${UCMake_VERSION} 14 | ) 15 | FetchContent_MakeAvailable(UCMake) 16 | message(STATUS "UCMake ${UCMake_VERSION} build done") 17 | endif() 18 | endmacro() 19 | -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/documents/1_BasicDArray/C2Cpp/cmake/InitUCMake.cmake: -------------------------------------------------------------------------------- 1 | macro(Ubpa_InitUCMake) 2 | include(FetchContent) 3 | set(UCMake_VERSION 0.6.0) 4 | message(STATUS "find package: UCMake ${UCMake_VERSION}") 5 | find_package(UCMake ${UCMake_VERSION} QUIET) 6 | if(NOT UCMake_FOUND) 7 | message(STATUS "UCMake ${UCMake_VERSION} not found") 8 | set(_address "https://github.com/Ubpa/UCMake") 9 | message(STATUS "fetch: ${_address} with tag ${UCMake_VERSION}") 10 | FetchContent_Declare( 11 | UCMake 12 | GIT_REPOSITORY ${_address} 13 | GIT_TAG ${UCMake_VERSION} 14 | ) 15 | FetchContent_MakeAvailable(UCMake) 16 | message(STATUS "UCMake ${UCMake_VERSION} build done") 17 | endif() 18 | endmacro() 19 | -------------------------------------------------------------------------------- /Homeworks/3_PoissonImageEditing/documents/opencv_example/cmake/InitUCMake.cmake: -------------------------------------------------------------------------------- 1 | macro(Ubpa_InitUCMake) 2 | include(FetchContent) 3 | set(UCMake_VERSION 0.6.0) 4 | message(STATUS "find package: UCMake ${UCMake_VERSION}") 5 | find_package(UCMake ${UCMake_VERSION} QUIET) 6 | if(NOT UCMake_FOUND) 7 | message(STATUS "UCMake ${UCMake_VERSION} not found") 8 | set(_address "https://github.com/Ubpa/UCMake") 9 | message(STATUS "fetch: ${_address} with tag ${UCMake_VERSION}") 10 | FetchContent_Declare( 11 | UCMake 12 | GIT_REPOSITORY ${_address} 13 | GIT_TAG ${UCMake_VERSION} 14 | ) 15 | FetchContent_MakeAvailable(UCMake) 16 | message(STATUS "UCMake ${UCMake_VERSION} build done") 17 | endif() 18 | endmacro() 19 | -------------------------------------------------------------------------------- /Homeworks/7_SimulationTaichi/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # 7. 基于 Taichi 的仿真 4 | 5 | ## 作业递交 6 | 7 | - 递交内容:程序代码及实验报告(或含仿真视频) 8 | - 递交时间:2020 年 4 月 5 日星期日 9 | 10 | ## 作业要求 11 | 12 | - 构建不同的模拟场景★ 13 | - 使用 `add_objec` 函数设计自己的模拟场景(可以改变模拟物体的形状、粒子数目、初始位置、初始速度等等) 14 | - 探究参数空间:通过调整不同的参数设置体会不同参数对仿真结果的影响★★ 15 | - 比如:探究杨氏模量E对雪模拟的影响,结合其背后的物理原理进行比较分析 16 | - 探究其他算法和模型:通过改变物理模型、改变模拟算法实现新的模拟结果★★★ 17 | - 比如:水冲击弹性物体的模拟 18 | - 渲染与绘制(可选 ★★★★★) 19 | - 学习使用商业软件(如Houdini、Blender等)对结果进行渲染 20 | - 【注:3D粒子更合适光照渲染,因此此处不作要求】 21 | 22 | 23 | ## 提供的材料 24 | 25 | 根据上述要求和方法根据两个文件夹`(1) documents`和`(2) project`的内容进行练习。 26 | 27 | ### (1) 说明文档 `documents` [->](documents/) 28 | 29 | 本次作业的要求说明和一些辅助资料 30 | 31 | ### (2) 作业项目 `project` [->](project/) 32 | 33 | 本次作业的基础代码框架 34 | 35 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/README.md: -------------------------------------------------------------------------------- 1 | # 4. 极小曲面和网格参数化 2 | 3 | 4 | ## 作业递交 5 | 6 | - 递交内容:程序代码及实验报告 7 | - 递交时间:2020 年 3 月 15 日星期日 8 | 9 | ## 作业要求 10 | 11 | - 初步了解 \*.obj 格式的 3D 数据(\*.obj, \*.mtl) 12 | - 使用 Win10 自带的 “3D 查看器” 查看 obj 数据文件 13 | - 安装并使用开源3D几何处理框架 [MeshLab](http://www.meshlab.net) 查看 3D 数据文件 (MeshLab 功能多,可多学习使用) 14 | - 学习三角网格的数据结构及操作 15 | - 使用 UEngine 网格程序框架 16 | - 寻找**非封闭**网格曲面的边界 17 | - 实现极小曲面与网格参数化 18 | - 极小曲面:边界固定,求解稀疏方程组 19 | - 参数化:边界映射到平面凸多边形,求解稀疏方程组 20 | - 巩固使用 Eigen 库求解稀疏线性方程组 21 | 22 | 23 | ## 提供的材料 24 | 25 | 根据上述要求和方法根据两个文件夹`(1) documents`和`(2) project`的内容进行练习。 26 | 27 | ### (1) 说明文档 `documents` [->](documents/) 28 | 29 | 本次作业的要求说明和一些辅助资料 30 | 31 | ### (2) 作业项目 `project` [->](project/) 32 | 33 | 本次作业的基础代码框架 34 | 35 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Engine/IBL/irradiance_convolution.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | #include "../../Math/sample.h" 4 | 5 | out vec3 FragColor; 6 | in vec3 WorldPos; 7 | 8 | uniform samplerCube environmentMap; 9 | 10 | void main() 11 | { 12 | // The world vector acts as the normal of a tangent surface 13 | // from the origin, aligned to WorldPos. Given this normal, calculate all 14 | // incoming radiance of the environment. The result of this radiance 15 | // is the radiance of light coming from -Normal direction, which is what 16 | // we use in the PBR shader to sample irradiance. 17 | vec3 N = normalize(WorldPos); 18 | 19 | vec3 irradiance = vec3(0.0); 20 | 21 | // TODO 22 | 23 | FragColor = irradiance; 24 | } 25 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Filter/FilterSinc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ImgFilter.h" 4 | 5 | namespace Ubpa { 6 | class FilterSinc : public ImgFilter { 7 | public: 8 | FilterSinc(const vecf2& radius, float tau) : ImgFilter(radius), tau(tau) { } 9 | 10 | protected: 11 | virtual ~FilterSinc() = default; 12 | 13 | public: 14 | const Ptr New(const vecf2& radius, float tau) { 15 | return Ubpa::New(radius, tau); 16 | } 17 | 18 | public: 19 | virtual float Evaluate(const pointf2& p) const override { 20 | return WindowSinc(p[0], radius[0]) * WindowSinc(p[1], radius[1]); 21 | } 22 | 23 | private: 24 | float WindowSinc(float x, float radius) const; 25 | 26 | private: 27 | const float tau; 28 | }; 29 | } 30 | -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/documents/1_BasicDArray/C2Cpp/src/Array/test.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "Array.h" 4 | 5 | int main() 6 | { 7 | Array a; 8 | a.InsertAt(0, 2.1); 9 | a.Display(); 10 | 11 | a.PushBack(3.0); 12 | a.PushBack(3.1); 13 | a.PushBack(3.2); 14 | a.Display(); 15 | 16 | a.DeleteAt(0); 17 | a.Display(); 18 | a.InsertAt(0, 4.1); 19 | a.Display(); 20 | 21 | Array b; 22 | b.PushBack(21); 23 | b.Display(); 24 | b.DeleteAt(0); 25 | b.Display(); 26 | b.PushBack(22); 27 | b.SetSize(5); 28 | b.Display(); 29 | 30 | Array c(5, 3.4); 31 | c.PushBack(5.5); 32 | c.Display(); 33 | c.SetSize(10); 34 | c.Display(); 35 | 36 | Array d; 37 | 38 | for (int i = 0; i < 17; i++) 39 | { 40 | d.PushBack(i); 41 | d.Display(); 42 | } 43 | return 0; 44 | } -------------------------------------------------------------------------------- /Homeworks/1_MiniDraw/documents/hello/src/hello/mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | MainWindow 3 | 4 | 5 | 6 | 0 7 | 0 8 | 400 9 | 300 10 | 11 | 12 | 13 | MainWindow 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Basic/Sampler/AliasMethod.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Ubpa { 6 | class AliasMethod { 7 | public: 8 | AliasMethod(const std::vector& distribution = std::vector()) { 9 | Init(distribution); 10 | } 11 | 12 | public: 13 | void Init(const std::vector& distribution); 14 | 15 | void Clear() { table.clear(); } 16 | 17 | // 0, 1, ..., n - 1 18 | int Sample() const; 19 | int Sample(double& p) const; 20 | 21 | double P(int i) const; 22 | 23 | private: 24 | struct Item { 25 | Item() :u(-1), k(-1) {} 26 | 27 | double p; // orig probability 28 | double u; // choose probability 29 | int k; // alias 30 | }; 31 | 32 | std::vector table; 33 | }; 34 | } 35 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Common/basic_P3N3T2_invN.vs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | #include "camera.h" 4 | 5 | layout (location = 0) in vec3 aPos; 6 | layout (location = 1) in vec3 aNormal; 7 | layout (location = 2) in vec2 aTexCoords; 8 | 9 | out VS_OUT { 10 | vec3 FragPos; 11 | vec3 Normal; 12 | vec2 TexCoords; 13 | } vs_out; 14 | 15 | uniform mat4 model; 16 | 17 | uniform bool invertedNormals; 18 | 19 | void main() 20 | { 21 | vec4 worldPos = model * vec4(aPos, 1.0); 22 | vs_out.FragPos = worldPos.xyz; 23 | vs_out.TexCoords = aTexCoords; 24 | 25 | mat3 normalMatrix = transpose(inverse(mat3(model))); 26 | vs_out.Normal = normalize(normalMatrix * (invertedNormals ? -aNormal : aNormal)); 27 | 28 | gl_Position = projection * view * worldPos; 29 | } -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Engine/Light/AreaLight.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | using namespace Ubpa; 6 | using namespace std; 7 | 8 | const rgbf AreaLight::Sample_L(const pointf3 & p, normalf & wi, float & distToLight, float & PD) const { 9 | cout << "WARNING::AreaLight:" << endl 10 | << "\t" << "not implemented" << endl; 11 | return 0.f; 12 | } 13 | 14 | float AreaLight::PDF(const pointf3 & p, const normalf & wi) const { 15 | cout << "WARNING::AreaLight:" << endl 16 | << "\t" << "not implemented" << endl; 17 | return 0.f; 18 | } 19 | 20 | bool AreaLight::Hit(const pointf3 & p, const vecf3 & dirToLight, pointf3 & hitPos) const { 21 | cout << "WARNING::AreaLight:" << endl 22 | << "\t" << "not implemented" << endl; 23 | return false; 24 | } 25 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Basic/ShapeMesh/CapsuleMesh.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ShapeMesh.h" 4 | 5 | #include 6 | 7 | namespace Ubpa { 8 | class CapsuleMesh : public ShapeMesh { 9 | public: 10 | CapsuleMesh(unsigned n, float height = 2.f); 11 | float* GetNormalArr(); 12 | float* GetTexCoordsArr(); 13 | unsigned* GetIndexArr(); 14 | float* GetTangentArr(); 15 | unsigned GetNormalArrSize(); 16 | unsigned GetTexCoordsArrSize(); 17 | unsigned GetIndexArrSize(); 18 | unsigned GetTangentArrSize(); 19 | 20 | float GetHeight() const { return height; } 21 | 22 | protected: 23 | std::vector normalArr; 24 | std::vector texCoordsArr; 25 | std::vector indexArr; 26 | std::vector tangentArr; 27 | 28 | private: 29 | float height; 30 | }; 31 | } 32 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Filter/FilterMitchell.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ImgFilter.h" 4 | 5 | namespace Ubpa { 6 | class FilterMitchell : public ImgFilter { 7 | public: 8 | FilterMitchell(const vecf2& radius, float B, float C) : ImgFilter(radius), B(B), C(C) { } 9 | 10 | protected: 11 | virtual ~FilterMitchell() = default; 12 | 13 | public: 14 | static const Ptr New(const vecf2& radius, float B, float C) { 15 | return Ubpa::New(radius, B, C); 16 | } 17 | 18 | public: 19 | virtual float Evaluate(const pointf2& p) const override { 20 | return Mitchell1D(p[0] * invRadius[0]) * Mitchell1D(p[1] * invRadius[1]); 21 | } 22 | 23 | private: 24 | float Mitchell1D(float x) const; 25 | 26 | private: 27 | const float B; 28 | const float C; 29 | }; 30 | } 31 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Engine/Scene/CmptLight.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include 8 | 9 | using namespace Ubpa; 10 | 11 | using namespace std; 12 | 13 | transformf CmptLight::GetLightToWorldMatrixWithoutScale() const { 14 | auto tsfm = transformf::eye(); 15 | 16 | for (auto cur = GetSObj(); cur != nullptr; cur = cur->GetParent()) { 17 | auto cmptTransform = cur->GetComponent(); 18 | if (!cmptTransform) 19 | continue; 20 | 21 | auto pos = cmptTransform->GetPosition(); 22 | auto rotation = cmptTransform->GetRotation(); 23 | // tsfm = T * R * tsfm 24 | tsfm = transformf(pos.cast_to()) * transformf(rotation) * tsfm; 25 | } 26 | 27 | return tsfm; 28 | } 29 | -------------------------------------------------------------------------------- /Homeworks/9_PathTracing/project/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14 FATAL_ERROR) 2 | 3 | project(HW9 VERSION 0.0.7) 4 | message(STATUS "[Project] ${PROJECT_NAME}") 5 | 6 | set(CMAKE_DEBUG_POSTFIX "d") 7 | 8 | include(FetchContent) 9 | 10 | message(STATUS "find package: UCMake 0.5.3") 11 | find_package(UCMake 0.5.3 QUIET) 12 | if(NOT UCMake_FOUND) 13 | message(STATUS "UCMake 0.5.3 not found") 14 | message(STATUS "fetch: UCMake 0.5.3") 15 | set(_address "https://github.com/Ubpa/UCMake") 16 | FetchContent_Declare( 17 | UCMake 18 | GIT_REPOSITORY ${_address} 19 | GIT_TAG "0.5.3" 20 | ) 21 | FetchContent_MakeAvailable(UCMake) 22 | message(STATUS "UCMake 0.5.3 build done") 23 | endif() 24 | 25 | Ubpa_InitProject() 26 | 27 | Ubpa_AddDep(UEngine 0.0.7) 28 | 29 | Ubpa_AddSubDirsRec(data) 30 | Ubpa_AddSubDirsRec(src) 31 | -------------------------------------------------------------------------------- /Homeworks/2_ImageWarping/project/README.md: -------------------------------------------------------------------------------- 1 | # 作业项目 2 | 3 | ## 目录结构 4 | 5 | 本项目目录包含以下若干子目录: 6 | 7 | - [src/](src/):源代码 8 | 9 | ## 使用说明 10 | 11 | ### Eigen 12 | 13 | 如需 Eigen,参考 [Eigen 示例项目](../documents/eigen_example) 14 | 15 | ### ANN (Optional) 16 | 17 | 如需 ANN,参考 [ANN 示例项目](../documents/ann_example/) 18 | 19 | 对于本项目,在 CMake 进行 Configure 后,配置框中找到 `USE_ANN` 并勾选上,然后重新 Configure 后再 Generate 和 Open Project 即可完成配置 20 | 21 | ## 其他说明 22 | 23 | - Qt:[简易说明](../../../Softwares/Qt.md) 24 | - CMake-GUI 在 configure 的时候,Optional platform for generator 要选 **x64** 25 | - CMake 一开始会拉取 [UCMake](https://github.com/Ubpa/UCMake),所以会稍微久一点,拉取的 UCMake 位于 `build/_deps/`,内含一些 CMake 的自定义函数 `Ubpa_xxx`,详细请看 [UbpaTool.cmake](https://github.com/Ubpa/UCMake/blob/master/cmake/UbpaTool.cmake),构建好的工程中会自带一些 UCMake 中的[示例项目](https://github.com/Ubpa/UCMake/tree/master/src),可以查看模仿 26 | 27 | -------------------------------------------------------------------------------- /Homeworks/9_PathTracing/project/data/shaders/light.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | layout (location = 0) out vec4 GBuffer0; 4 | layout (location = 1) out vec4 GBuffer1; 5 | layout (location = 2) out vec4 GBuffer2; 6 | layout (location = 3) out vec4 GBuffer3; 7 | 8 | // layout : light 9 | // x y z w 10 | // 0 [radiance] 0 11 | // 1 0 0 0 0 12 | // 2 0 0 0 1.5 13 | // 3 0 0 0 0 14 | 15 | in VS_OUT { 16 | vec3 WorldPos; 17 | vec2 TexCoord; 18 | mat3 TBN; 19 | } vs_out; 20 | 21 | uniform vec3 radiance_factor; 22 | uniform sampler2D radiance_texture; 23 | 24 | void main() 25 | { 26 | vec3 radiance = radiance_factor * texture(radiance_texture, vs_out.TexCoord).rgb; 27 | 28 | GBuffer0 = vec4(radiance, 0); 29 | GBuffer1 = vec4(0, 0, 0, 0); 30 | GBuffer2 = vec4(0, 0, 0, 1.5); 31 | GBuffer3 = vec4(0, 0, 0, 0); 32 | } 33 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Engine/DeferredPipeline/GBuffer_Emission.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | layout (location = 0) out vec4 GBuffer0; 4 | layout (location = 1) out vec4 GBuffer1; 5 | layout (location = 2) out vec4 GBuffer2; 6 | layout (location = 3) out vec4 GBuffer3; 7 | 8 | // layout 9 | // x y z w 10 | // 0 [ pos ] ID 11 | // 1 [ norm ] 12 | // 2 [ L ] 13 | // 3 14 | 15 | in VS_OUT { 16 | vec3 FragPos; 17 | vec3 Normal; 18 | vec2 TexCoords; 19 | vec3 Tangent; 20 | } fs_in; 21 | 22 | struct BSDF_Emission { 23 | vec3 L; 24 | }; 25 | 26 | uniform BSDF_Emission emission; 27 | uniform int ID; 28 | 29 | void main() { 30 | // pack GBuffer 31 | GBuffer0 = vec4(fs_in.FragPos, ID); 32 | GBuffer1 = vec4(normalize(fs_in.Normal), 0); 33 | GBuffer2 = vec4(emission.L, 0); 34 | GBuffer3 = vec4(0); 35 | } 36 | -------------------------------------------------------------------------------- /Homeworks/1_MiniDraw/project/src/App/minidraw.ui: -------------------------------------------------------------------------------- 1 | 2 | MiniDrawClass 3 | 4 | 5 | MiniDrawClass 6 | 7 | 8 | 9 | 0 10 | 0 11 | 600 12 | 400 13 | 14 | 15 | 16 | MiniDraw 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Basic/Geometry.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace Ubpa { 7 | namespace Geometry { 8 | template 9 | bool IsConvexPolygon(const std::vector>& points) { 10 | assert(points.size() >= 4); 11 | std::vector> vecs(points.size()); 12 | std::vector> norms(points.size()); 13 | for (size_t i = 0; i < points.size(); i++) { 14 | size_t next = (i + 1) % points.size(); 15 | vecs[i] = points[next] - points[i]; 16 | } 17 | for (size_t i = 0; i < vecs.size(); i++) { 18 | size_t next = (i + 1) % points.size(); 19 | norms[i] = vecs[i].cross(vecs[next]); 20 | for (size_t j = 0; j < i; j++) { 21 | if (norms[j].dot(norms[i]) < static_cast(0)) 22 | return false; 23 | } 24 | } 25 | return true; 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Viewer/Roamer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Ubpa { 6 | class RawAPI_OGLW; 7 | class Camera; 8 | 9 | class Roamer final : public HeapObj { 10 | public: 11 | Roamer(RawAPI_OGLW* pOGLW); 12 | 13 | public: 14 | static const Ptr New(RawAPI_OGLW* pOGLW) { 15 | return Ubpa::New(pOGLW); 16 | } 17 | 18 | protected: 19 | virtual ~Roamer() = default; 20 | 21 | public: 22 | void Init(); 23 | void SetWH(int w, int h); 24 | 25 | RawAPI_OGLW* GetOGLW() { return pOGLW; } 26 | Ptr GetCamera() { return camera; } 27 | 28 | public: 29 | void SetLock(bool isLock) { lock = isLock; } 30 | 31 | private: 32 | void ListenerInit(); 33 | void UpdateCamera(); 34 | 35 | RawAPI_OGLW* pOGLW; 36 | unsigned int cameraUBO; 37 | Ptr camera; 38 | bool lock; 39 | }; 40 | } 41 | -------------------------------------------------------------------------------- /Homeworks/5_ARAP/README.md: -------------------------------------------------------------------------------- 1 | # 5. ARAP参数化 2 | 3 | 4 | ## 作业递交 5 | 6 | - 递交内容:程序代码及实验报告 7 | - 递交时间:2020 年 3 月 22 日星期日 8 | 9 | ## 作业要求 10 | 11 | - 在给定的网格框架上完成作业,实现 12 | - ASAP (As-similar-as-possible) 参数化算法 13 | - ARAP (As-rigid-as-possible) 参数化算法 14 | - Hybrid 参数化方法(可选) 15 | - 对各种参数化方法(包括作业4的Floater方法、ASAP/ARAP方法等)进行比较 16 | - 继续学习和巩固三角网格的数据结构及编程 17 | - 学习和实现矩阵的 SVD 分解 18 | - 进一步巩固使用 Eigen 库求解大型稀疏线性方程组 19 | 20 | 21 | ## 提供的材料 22 | 23 | 根据上述要求和方法根据两个文件夹`(1) documents`和`(2) project`的内容进行练习。 24 | 25 | ### (1) 说明文档 `documents` [->](documents/) 26 | 27 | 本次作业的要求说明和一些辅助资料 28 | 29 | ### (2) 作业项目 `project` [->](project/) 30 | 31 | 本次作业的基础代码框架 32 | 33 | ## 参考文献 34 | 35 | [^08Liu]: Liu, Ligang, et al. "[**A local/global approach to mesh parameterization.**](http://cs.harvard.edu/~sjg/papers/arap.pdf)" *Computer Graphics Forum*. Vol. 27. No. 5. Oxford, UK: Blackwell Publishing Ltd, 2008. 36 | 37 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Engine/BRDF/Diffuse.h: -------------------------------------------------------------------------------- 1 | #ifndef BRDF_DIFFUSE_H 2 | #define BRDF_DIFFUSE_H 3 | 4 | #include "../../Math/basic.h" 5 | 6 | // ------------------------------ 接口 ------------------------------ 7 | 8 | void BRDF_Diffuse(out vec3 fd, out vec3 fs, vec3 albedo); 9 | vec3 BRDF_Diffuse(vec3 albedo); 10 | 11 | // diffuse 12 | vec3 BRDFd_Diffuse(vec3 albedo); 13 | // specular 14 | vec3 BRDFs_Diffuse(vec3 albedo); 15 | 16 | // ------------------------------ 实现 ------------------------------ 17 | 18 | vec3 BRDFd_Diffuse(vec3 albedo) { 19 | return albedo * INV_PI; 20 | } 21 | 22 | vec3 BRDFs_Diffuse(vec3 albedo) { 23 | return vec3(0); 24 | } 25 | 26 | void BRDF_Diffuse(out vec3 fd, out vec3 fs, vec3 albedo) { 27 | fd = albedo * INV_PI; 28 | fs = vec3(0); 29 | } 30 | 31 | vec3 BRDF_Diffuse(vec3 albedo) { 32 | return albedo * INV_PI; 33 | } 34 | 35 | #endif // !BRDF_DIFFUSE_H 36 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/MeshEdit/MST.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ShortestPath.h" 4 | 5 | #include 6 | 7 | #include 8 | 9 | #include 10 | 11 | #include 12 | 13 | #include 14 | 15 | namespace Ubpa { 16 | class TriMesh; 17 | class Paramaterize; 18 | 19 | class MST : public HeapObj { 20 | public: 21 | MST(Ptr triMeshObj); 22 | public: 23 | static const Ptr New(Ptr triMeshObj) { 24 | return Ubpa::New(triMeshObj); 25 | } 26 | public: 27 | void Clear(); 28 | bool Init(Ptr triMeshObj); 29 | 30 | bool Run(); 31 | Ptr GetTreeObj(); 32 | 33 | private: 34 | const std::vector> FindMST(const std::vector& vertices); 35 | 36 | private: 37 | Ptr shortestPath; 38 | Ptr treeObj; 39 | }; 40 | } 41 | -------------------------------------------------------------------------------- /Homeworks/1_MiniDraw/documents/hello/src/hello/mainwindow.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | #include "ui_mainwindow.h" 3 | 4 | #include 5 | 6 | MainWindow::MainWindow(QWidget *parent) : 7 | QMainWindow(parent), 8 | ui(new Ui::MainWindow) 9 | { 10 | ui->setupUi(this); 11 | CreateButtons(); 12 | } 13 | 14 | MainWindow::~MainWindow() 15 | { 16 | delete ui; 17 | } 18 | 19 | void MainWindow::HelloWorld() { 20 | QMessageBox::about(this, tr("Hello world"), 21 | tr("Well done! Go ahead.")); 22 | } 23 | 24 | void MainWindow::CreateButtons() 25 | { 26 | hello_world_action_ = new QAction(tr("&Hello world"), this); 27 | connect(hello_world_action_, &QAction::triggered, this, &MainWindow::HelloWorld); 28 | main_menu_ = menuBar()->addMenu(tr("&Main")); 29 | main_menu_->addAction(hello_world_action_); 30 | main_toolbar_ = addToolBar(tr("&Main")); 31 | main_toolbar_->addAction(hello_world_action_); 32 | } 33 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Engine/Viewer/Picker.cpp: -------------------------------------------------------------------------------- 1 | #include "Picker.h" 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | 16 | #include 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | #include 24 | 25 | using namespace Ubpa; 26 | 27 | using namespace std; 28 | 29 | Picker::Picker(Viewer * viewer) 30 | : viewer(viewer) { } 31 | 32 | void Picker::Init() { 33 | cout << "WARNING::Picker::Init:" << endl 34 | << "\t" << "not implemented" << endl; 35 | } 36 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Basic/ImgPixelSet.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace Ubpa; 4 | 5 | using namespace std; 6 | 7 | ImgPixelSet::ImgPixelSet() { 8 | 9 | } 10 | 11 | ImgPixelSet::ImgPixelSet(size_t width, size_t height) { 12 | data.reserve(width * height); 13 | for (size_t i = 0; i < width; i++) { 14 | for (size_t j = 0; j < height; j++) { 15 | Insert(valu2(i, j)); 16 | } 17 | } 18 | } 19 | 20 | vector ImgPixelSet::RandPick(size_t n) { 21 | vector pixels; 22 | 23 | const size_t num = min(Size(), n); 24 | pixels.reserve(num); 25 | 26 | for (size_t i=0; i < num; i++) 27 | pixels.push_back(RandPick()); 28 | 29 | return pixels; 30 | } 31 | 32 | std::vector ImgPixelSet::PickAll() { 33 | vector pixels; 34 | const size_t num = Size(); 35 | 36 | for (size_t i = 0; i < num; i++) 37 | pixels.push_back(RandPick()); 38 | 39 | return pixels; 40 | } 41 | -------------------------------------------------------------------------------- /Homeworks/9_PathTracing/project/data/shaders/p3t2n3t3.vs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | layout (location = 0) in vec3 aPos; 4 | layout (location = 1) in vec2 aTexCoord; 5 | layout (location = 2) in vec3 aNormal; 6 | layout (location = 3) in vec3 aTangent; 7 | 8 | out VS_OUT { 9 | vec3 WorldPos; 10 | vec2 TexCoord; 11 | mat3 TBN; 12 | } vs_out; 13 | 14 | uniform mat4 projection; 15 | uniform mat4 view; 16 | uniform mat4 model; 17 | 18 | void main() 19 | { 20 | vec4 worldPos = model * vec4(aPos, 1.0); 21 | vs_out.WorldPos = worldPos.xyz / worldPos.w; 22 | 23 | vs_out.TexCoord = aTexCoord; 24 | 25 | mat3 normalMatrix = transpose(inverse(mat3(model))); 26 | 27 | vec3 N = normalize(normalMatrix * aNormal); 28 | vec3 T = mat3(model) * aTangent; 29 | T = normalize(T - dot(T, N) * N); 30 | vec3 B = cross(N, T); 31 | vs_out.TBN = mat3(T, B, N); 32 | 33 | gl_Position = projection * view * worldPos; 34 | } 35 | -------------------------------------------------------------------------------- /Homeworks/2_ImageWarping/project/src/App/mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | MainWindowClass 3 | 4 | 5 | MainWindowClass 6 | 7 | 8 | 9 | 0 10 | 0 11 | 600 12 | 400 13 | 14 | 15 | 16 | MainWindow 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Engine/Skybox/skybox.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | out vec4 FragColor; 3 | 4 | in vec3 TexCoords; 5 | 6 | // 32 7 | layout (std140) uniform Environment{ 8 | vec3 colorFactor; // 12 0 9 | float intensity; // 4 12 10 | bool haveSkybox; // 4 16 11 | bool haveEnvironment; // 4 20 12 | }; 13 | 14 | uniform samplerCube skybox; 15 | uniform bool needGamma = false; 16 | 17 | vec3 GetEnvironment(vec3 texcoord); 18 | 19 | void main() 20 | { 21 | vec3 ambient = GetEnvironment(TexCoords); 22 | 23 | // gamma 24 | if(needGamma) 25 | ambient = pow(ambient, vec3(1.0/2.2)); 26 | 27 | FragColor = vec4(ambient, 1); 28 | } 29 | 30 | vec3 GetEnvironment(vec3 texcoord) { 31 | if(!haveEnvironment) 32 | return vec3(0); 33 | 34 | if(!haveSkybox) 35 | return intensity * colorFactor; 36 | 37 | return intensity * colorFactor * texture(skybox, texcoord).rgb; 38 | } 39 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Engine/MeshEdit/Paramaterize.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #include 6 | 7 | using namespace Ubpa; 8 | 9 | using namespace std; 10 | 11 | Paramaterize::Paramaterize(Ptr triMesh) { 12 | // TODO 13 | cout << "Paramaterize::Paramaterize:" << endl 14 | << "\t" << "not implemented" << endl; 15 | } 16 | 17 | void Paramaterize::Clear() { 18 | // TODO 19 | cout << "Paramaterize::Clear:" << endl 20 | << "\t" << "not implemented" << endl; 21 | } 22 | 23 | bool Paramaterize::Init(Ptr triMesh) { 24 | // TODO 25 | cout << "Paramaterize::Init:" << endl 26 | << "\t" << "not implemented" << endl; 27 | 28 | return false; 29 | } 30 | 31 | bool Paramaterize::Run() { 32 | // TODO 33 | cout << "Paramaterize::Init:" << endl 34 | << "\t" << "not implemented" << endl; 35 | return false; 36 | } 37 | -------------------------------------------------------------------------------- /Homeworks/8_Shader/project/data/shaders/p3t2n3_denoise.vert: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | layout (location = 0) in vec3 aPos; 4 | layout (location = 1) in vec2 aTexCoord; 5 | layout (location = 2) in vec3 aNormal; 6 | 7 | out VS_OUT { 8 | vec3 WorldPos; 9 | vec2 TexCoord; 10 | vec3 Normal; 11 | } vs_out; 12 | 13 | uniform mat4 projection; 14 | uniform mat4 view; 15 | uniform mat4 model; 16 | 17 | uniform sampler2D displacementmap; 18 | uniform float displacement_bias; 19 | uniform float displacement_scale; 20 | uniform float displacement_lambda; 21 | uniform bool have_denoise; 22 | 23 | void main() 24 | { 25 | // TODO: HW8 - 1_denoise | denoise 26 | vec4 worldPos = model * vec4(aPos, 1.0); 27 | 28 | vs_out.WorldPos = worldPos.xyz / worldPos.w; 29 | vs_out.TexCoord = aTexCoord; 30 | vs_out.Normal = normalize(transpose(inverse(mat3(model))) * aNormal); 31 | 32 | gl_Position = projection * view * worldPos; 33 | } 34 | -------------------------------------------------------------------------------- /Homeworks/1_MiniDraw/project/src/App/viewwidget.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Shape.h" 6 | #include "Line.h" 7 | #include "Rect.h" 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | class ViewWidget : public QWidget 16 | { 17 | Q_OBJECT 18 | 19 | public: 20 | ViewWidget(QWidget* parent = 0); 21 | ~ViewWidget(); 22 | 23 | private: 24 | Ui::ViewWidget ui; 25 | 26 | private: 27 | bool draw_status_; 28 | QPoint start_point_; 29 | QPoint end_point_; 30 | Shape::Type type_; 31 | Shape* shape_; 32 | std::vector shape_list_; 33 | 34 | 35 | public: 36 | void mousePressEvent(QMouseEvent* event); 37 | void mouseMoveEvent(QMouseEvent* event); 38 | void mouseReleaseEvent(QMouseEvent* event); 39 | 40 | public: 41 | void paintEvent(QPaintEvent*); 42 | signals: 43 | public slots: 44 | void setLine(); 45 | void setRect(); 46 | 47 | }; 48 | -------------------------------------------------------------------------------- /Homeworks/3_PoissonImageEditing/project/src/App/mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | MainWindowClass 3 | 4 | 5 | MainWindowClass 6 | 7 | 8 | 9 | 0 10 | 0 11 | 600 12 | 400 13 | 14 | 15 | 16 | MainWindow 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Common/basic_P3N3T2T3.vs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | #include "camera.h" 4 | 5 | layout (location = 0) in vec3 aPos; 6 | layout (location = 1) in vec3 aNormal; 7 | layout (location = 2) in vec2 aTexCoords; 8 | layout (location = 3) in vec3 aTangent; 9 | 10 | out VS_OUT { 11 | vec3 FragPos; 12 | vec3 Normal; 13 | vec2 TexCoords; 14 | vec3 Tangent; 15 | } vs_out; 16 | 17 | uniform mat4 model; 18 | 19 | void main() 20 | { 21 | vec4 worldPos = model * vec4(aPos, 1.0); 22 | vs_out.FragPos = worldPos.xyz / worldPos.w; 23 | vs_out.TexCoords = aTexCoords; 24 | 25 | mat3 normalMatrix = transpose(inverse(mat3(model))); 26 | 27 | vec3 N = normalize(normalMatrix * aNormal); 28 | vs_out.Normal = N; 29 | 30 | vec3 T = normalize(normalMatrix * aTangent); 31 | vs_out.Tangent = normalize(T - dot(T, N) * N); 32 | 33 | gl_Position = projection * view * worldPos; 34 | } 35 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Engine/RTX/Film.cpp: -------------------------------------------------------------------------------- 1 | #include "Film.h" 2 | 3 | #include "FilmTile.h" 4 | 5 | #include 6 | #include 7 | 8 | using namespace Ubpa; 9 | 10 | Film::Film(Ptr img, Ptr filter) 11 | : resolution(img->GetWidth(), img->GetHeight()), 12 | pixels(img->GetWidth(), std::vector(img->GetHeight())), 13 | frame({ 0,0 }, { img->GetWidth(),img->GetHeight() }), 14 | filter(filter), 15 | img(img) 16 | { 17 | assert(img != nullptr && img->IsValid()); 18 | assert(img->GetChannel() == 3); 19 | } 20 | 21 | const Ptr Film::GenFilmTile(const bboxi2 & frame) const { 22 | return FilmTile::New(frame, filter); 23 | } 24 | 25 | void Film::MergeFilmTile(Ptr filmTile) { 26 | for (const auto pos : filmTile->AllPos()) { 27 | pixels[pos[0]][pos[1]] += filmTile->At(pos); 28 | img->SetPixel(pos, pixels[pos[0]][pos[1]].ToRadiance()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Engine/Scene/AssimpLoader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | struct aiNode; 11 | struct aiMesh; 12 | struct aiScene; 13 | struct aiMaterial; 14 | enum aiTextureType; 15 | 16 | namespace Ubpa { 17 | class Image; 18 | class SObj; 19 | class TriMesh; 20 | 21 | namespace AssimpLoader { 22 | const Ptr Load(const std::string& path); 23 | using Str2Img = std::map>; 24 | const Ptr LoadNode(Str2Img& str2img, const std::string& dir, aiNode* node, const aiScene* scene); 25 | void LoadMesh(Str2Img& str2img, const std::string& dir, aiMesh* mesh, const aiScene* scene, Ptr sobj); 26 | const Ptr LoadTet(const std::string& dir); 27 | Ptr LoadTexture(Str2Img& str2img, const std::string& dir, aiMaterial* material, aiTextureType type); 28 | }; 29 | } 30 | -------------------------------------------------------------------------------- /Homeworks/1_MiniDraw/README.md: -------------------------------------------------------------------------------- 1 | # 1. 画图小工具 MiniDraw 2 | 3 | > 预备: 4 | > - 安装 Qt,查看[简易说明](../../Softwares/Qt.md) 5 | > 6 | > 作业步骤: 7 | > - 查看[文档](documents/),内含多个小教程 8 | > - 完成项目 [project](project/) 9 | > - 按照[作业规范](../README.md)提交作业 10 | 11 | ## 作业递交 12 | 13 | - 递交内容:程序代码及实验报告 14 | - 递交时间:2020 年 2 月 23 日星期日 15 | 16 | ## 要求 17 | 18 | - 写一个画图小程序 MiniDraw,要求画直线 (Line),椭圆 (Ellipse),矩形 (Rectangle),多边形 (Polygon) 等图形元素(图元) 19 | - 每种图元需用一个类(对象)来封装,如 `CLine`,`CEllipse`,`CRect`,`CPolygon`,`CFreehand` 20 | - 各种图元从一个父类来继承,如 `CFigure` 21 | - 学习类的继承和多态 22 | 23 | ## 目的 24 | 25 | - 学习 Qt 窗口编程 26 | - STL `vector` 等的使用 27 | - 学习鼠标操作 28 | - GDI 画图 29 | - 学习面向对象编程 30 | - 巩固类的封装性 31 | - 学习体会类的继承和多态 32 | - 多使用 Online Help 33 | 34 | ## 提供的材料 35 | 36 | 根据上述要求和方法根据两个文件夹`(1) documents`和`(2) project`的内容进行练习。 37 | 38 | ### (1) 说明文档 `documents` [->](documents/) 39 | 40 | 本次作业的要求说明和一些辅助资料 41 | 42 | ### (2) 作业项目 `project` [->](project/) 43 | 44 | 本次作业的基础代码框架 45 | 46 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Engine/Primitive/Sphere.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | using namespace Ubpa; 6 | 7 | const pointf2 Sphere::TexcoordOf(const normalf & normal) { 8 | auto nDir = normal.normalize(); 9 | const float phi = std::atan2(-nDir[0], -nDir[2]) + PI; 10 | const float theta = acos(nDir[1]); 11 | 12 | const auto u = phi / (2.f * PI); 13 | const auto v = theta / PI; 14 | return pointf2(u, v); 15 | } 16 | 17 | const normalf Sphere::TangentOf(const normalf & normal) { 18 | auto nDir = normal.normalize(); 19 | const float phi = std::atan2(-nDir[0], -nDir[2]) + PI; 20 | 21 | return normalf(cos(phi), 0, -sin(phi)); 22 | } 23 | 24 | const normalf Sphere::SphereCoord::ToDir() const { 25 | const auto sinTheta = sin(theta); 26 | 27 | float x = sinTheta * sin(phi); 28 | float y = cos(theta); 29 | float z = sinTheta * cos(phi); 30 | return { x,y,z }; 31 | } 32 | -------------------------------------------------------------------------------- /Softwares/Qt.md: -------------------------------------------------------------------------------- 1 | # QT 简略使用说明 2 | 3 | ## 安装 4 | 5 | - 打开[官网](https://www.qt.io/) 6 | - 点击右上角的 "Download. Try. Buy" 7 | - 点击 "Downloads for open sources users" 的 "Go open source"(此时需要登录)得到下载器 8 | - 打开下载器,选择 Qt 5.12.2 的 MSVC 2017 64-bit(可以用于 VS2019) 9 | - 将 `YOUR_PATH_TO/Qt5/msvc 2017 64/bin` 加入到环境变量 `Path` 中([配置方法](https://jingyan.baidu.com/article/7908e85ce8ddd3af491ad27c.html)) 10 | - VS 2019 菜单栏->扩展->管理扩展,搜索 Qt,找到 Qt Visual Studio Tools 并安装(需退出 VS),该工具以便在 VS 中打开 *.qrc 和 *.ui 文件时可以自动打开 Qt Resource Editor 和 Qt Designer 11 | - 安装 Qt Visual Studio Tools 成功后,重启 VS,菜单栏->扩展->Qt VS Tool->Qt Options,在弹出的窗口中 12 | - Qt Versions 下选择 Add,添加 path 为 `YOUR_PATH_TO/Qt5/msvc 2017 64` 13 | - Qt Default Settings 下 Ask before checkout files 选择 **False** 14 | 15 | ## 入门 16 | 17 | Qt 的使用资料众多。本课程需要 Qt 相关技能不多,主要靠模仿和查阅官方文档的方式解决具体问题 18 | 19 | 建议可以花 1-2 天的时间跟一下教程,如 [跟小豆君学Qt](https://zhuanlan.zhihu.com/c_119081535) 20 | 21 | 作业 1 包含了[入门教程](../Homeworks/1_MiniDraw/documents/) 22 | 23 | -------------------------------------------------------------------------------- /Homeworks/3_PoissonImageEditing/documents/opencv_example/src/test/mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | MainWindowClass 3 | 4 | 5 | MainWindowClass 6 | 7 | 8 | 9 | 0 10 | 0 11 | 600 12 | 400 13 | 14 | 15 | 16 | MainWindow 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Basic/Math.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | using namespace Ubpa; 7 | 8 | using namespace std; 9 | 10 | static uniform_int_distribution uiMap; 11 | static uniform_int_distribution iMap; 12 | static uniform_real_distribution fMap(0.0f,1.0f); 13 | static uniform_real_distribution fMap_exclude1(0.0f, 0.99999999f); 14 | static uniform_real_distribution dMap(0.0,1.0); 15 | static default_random_engine engine; 16 | 17 | int Math::Rand_I() { 18 | return iMap(engine); 19 | } 20 | 21 | unsigned int Math::Rand_UI() { 22 | return uiMap(engine); 23 | } 24 | 25 | float Math::Rand_F() { 26 | return fMap(engine); 27 | } 28 | 29 | float Math::Rand_F_exclude1() { 30 | return fMap_exclude1(engine); 31 | } 32 | 33 | double Math::Rand_D() { 34 | return dMap(engine); 35 | } 36 | 37 | void Math::RandSetSeedByCurTime() { 38 | engine.seed(clock()); 39 | } 40 | -------------------------------------------------------------------------------- /Homeworks/6_MassSpring/documents/tetgen/README.md: -------------------------------------------------------------------------------- 1 | # TetGen 使用指南 2 | 3 | ## Tetgen 说明 4 | 5 | - Tetgen 为生成四面体网格剖分的开源库 6 | - Tetgen 官网[->](http://www.wias-berlin.de/software/tetgen) 7 | - Tetgen 官方文档下载[->](http://wias-berlin.de/software/tetgen/1.5/doc/manual/manual.pdf) 8 | 9 | ## 四面体网格数据文件格式 10 | 11 | 12 | - tet 网格数据文件的格式与三角网格数据 obj 文件的格式很类似,包含点的列表和四面体的列表;与 obj 文件不一样的是,顶点的索引是从 0 开始 (obj 文件的索引是从 1 开始) 13 | - 下面为一个两个四面体构成的网格的例子,第一行格式:tet 后为顶点数和四面体数 14 | 15 | ``` 16 | tet 5 2 17 | 0 0 0 18 | 0 1 0 19 | 0 0 1 20 | 1 0 0 21 | 1 1 1 22 | 0 1 2 3 23 | 1 2 3 4 24 | ``` 25 | 26 | 其中第2-6行表示5个顶点的坐标,最后两行表示两个四面体的顶点索引,例如第一个四面体由序号为0,1,2,3的顶点构成 27 | 28 | 29 | ## 四面体网格数据生成方法 30 | 31 | - 本示范代码中的 main.cpp 设置读入表面网格文件路径(代码写的接口支持.stl, . poly)和输出网格路径(输出四面体网格为自定义格式.tet) 32 | - poly文件可参考 Tetgen 官方文档 33 | - Tetgen 中可通过设置一些参数来控制生成四面体网格的质量,详细可参考 Tetgen 的官方说明文档 34 | - 例子:在类 CTet_generate 的 tet_out 函数中设置,例如这里的代码中参数为"pqnnfea0.1z",其中0.1为生成网格最大四面体体积,对大模型要适当调大该参数,否则生成网格会过于稠密;注意:代码使用时读取文件后需要在控制台窗口中敲击回车才会继续运行 35 | 36 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Common/interpolation.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | out vec4 FragColor; 3 | 4 | in vec2 TexCoords; 5 | 6 | uniform sampler2D image; 7 | 8 | uniform float weight[5] = float[] (0.4714, 0.1945945946, 0.1216216216, 0.0540540541, 0.0162162162); 9 | 10 | void main() 11 | { 12 | vec3 result = vec3(0); 13 | 14 | result = texture(image, TexCoords).rgb; 15 | if(result != vec3(0)){ 16 | FragColor = vec4(result,1.0f); 17 | }else{ 18 | vec2 tex_offset = 1.0 / textureSize(image, 0); // gets size of single texel 19 | float weightSum = 0; 20 | for(int i=0;i<9;i++){ 21 | for(int j=0;j<9;j++){ 22 | vec3 tmpColor; 23 | tmpColor = texture(image, TexCoords + vec2(tex_offset.x * (i - 4), tex_offset.y * (j - 4))).rgb; 24 | if(tmpColor != vec3(0)){ 25 | float w = weight[abs(i-4)]*weight[abs(j-4)]; 26 | result += tmpColor * w; 27 | weightSum += w; 28 | } 29 | } 30 | } 31 | FragColor = vec4(result / weightSum, 1.0); 32 | } 33 | } -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/documents/3_TemplateDArray/README.md: -------------------------------------------------------------------------------- 1 | # 3. 模板动态数组 2 | 3 | > **Template** **D**ynamic **Array** (TemplateDArray) 4 | > 5 | > --- 6 | > 7 | > **注:** 如果你正在接受这些编程训练,表示你已经同意我们之间的版权协议。请严禁将这些练习的代码(包括你自己的代码)在不经允许的情况下在公共网上公布和散播。一经发现,后果自负。谢谢!-刘利刚 (ligang.liu@gmail.com) 8 | 9 | ## 问题 10 | 11 | 现在实现的类已经比较好了,用户使用起来很方便。 12 | 13 | 但是,新的问题又出来了。 14 | 15 | 上述的动态数组只能存储 `double` 类型的数据。想象一下,另一个用户也想用这个动态数组,但是他处理的数据是 `int` 类型的,该如何办? 16 | 17 | 当然,你可以再写一个基于 `int` 类型的动态数组类,你发现,大部分的代码都不要改动,只要将类型 `double` 变成 `int` 即可。 18 | 19 | 如果另一个用户需要处理的是 `float` 类型,还有用户处理的是 `char` 类型的….该怎么办? 20 | 21 | 这样做的缺点很显然: 22 | 23 | - 这些类的代码大同小异,代码冗余; 24 | - 当对这个类进行修改时,所有的这些类都要同时改,不利于代码维护; 25 | 26 | 有无办法解决这个问题?即,如果能把变量的“类型”也当作一个“变量”,不就可以了吗?这个在 C 中是不能解决的,但是在 C++ 中,有一种新的机制 `template`,就可以解决上述问题。`Template` 的使用非常简单,大致的形式见:[Array5](../1_BasicDArray/C2Cpp/src/Array5) 27 | 28 | `Template` 的学习是“泛型编程”的基础,务必要掌握! 29 | 30 | ## 作业要求 31 | 32 | - 将上一个作业改为 `template` 类,并做充分测试; 33 | - 注意:对于 `template` 类,需要将 `*.cpp` 的实现代码放在 `*.h` 中,才能编译通过。其他情况都需分开。 34 | 35 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Qt/OpThread.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | namespace Ubpa { 8 | class Op; 9 | 10 | class OpThread : public QThread, public HeapObj { 11 | Q_OBJECT 12 | public: 13 | OpThread(Ptr op = nullptr); 14 | 15 | public: 16 | static const Ptr New(Ptr op = nullptr) { 17 | return Ubpa::New(op); 18 | } 19 | 20 | protected: 21 | virtual ~OpThread() = default; 22 | 23 | public: 24 | void SetOp(Ptr op) { this->op = op; } 25 | void Stop() { isStop = true; } 26 | bool IsStop() const { return isStop; } 27 | 28 | signals: 29 | void UI_Op(Ptr op); 30 | 31 | public: 32 | template 33 | void UIConnect(T* obj, void (T::* f)(Ptr op)) { 34 | connect(this, &OpThread::UI_Op, obj, f); 35 | } 36 | void UI_Op_Run(Ptr op); 37 | 38 | protected: 39 | virtual void run(); 40 | 41 | private: 42 | volatile bool isStop; 43 | Ptr op; 44 | }; 45 | } 46 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Filter/FilterGaussian.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ImgFilter.h" 4 | 5 | namespace Ubpa { 6 | class FilterGaussian : public ImgFilter { 7 | public: 8 | FilterGaussian(const vecf2& radius, float alpha) 9 | : ImgFilter(radius), alpha(alpha), 10 | expX(std::exp(-alpha * radius[0] * radius[0])), 11 | expY(std::exp(-alpha * radius[1] * radius[1])) { } 12 | 13 | protected: 14 | virtual ~FilterGaussian() = default; 15 | 16 | public: 17 | const Ptr New(const vecf2& radius, float alpha) { 18 | return Ubpa::New(radius, alpha); 19 | } 20 | 21 | public: 22 | virtual float Evaluate(const pointf2& p) const override { 23 | return Gaussian(p[0], expX) * Gaussian(p[1], expY); 24 | } 25 | 26 | private: 27 | float Gaussian(float d, float expv) const { 28 | return std::max(0.f, std::exp(-alpha * d * d) - expv); 29 | } 30 | 31 | private: 32 | const float alpha; 33 | const float expX; 34 | const float expY; 35 | }; 36 | } 37 | -------------------------------------------------------------------------------- /Homeworks/8_Shader/project/data/textures/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | Ubpa_DownloadFile( 2 | https://ubpa.github.io/USTC_CG_Data/Homeworks/08_Shader/textures/cg_displacementmap.jpg 3 | ${CMAKE_CURRENT_SOURCE_DIR}/cg_displacementmap.jpg 4 | SHA256 53930B93846B139B8B86E965F77CD573BA50ABDDBD6E59EAE2052FA6C872F644 5 | ) 6 | 7 | Ubpa_DownloadFile( 8 | https://ubpa.github.io/USTC_CG_Data/Homeworks/08_Shader/textures/cg_normalmap.jpg 9 | ${CMAKE_CURRENT_SOURCE_DIR}/cg_normalmap.jpg 10 | SHA256 F92E45424339FCDDBC135C61524121C040F8945DC4ECC704C4BED75EF302EB49 11 | ) 12 | 13 | Ubpa_DownloadFile( 14 | https://ubpa.github.io/USTC_CG_Data/Homeworks/08_Shader/textures/checkerboard.png 15 | ${CMAKE_CURRENT_SOURCE_DIR}/checkerboard.png 16 | SHA256 AFFAF3FAD86E19BF9A14B3123BC40215DAA7A4A2EF7904D2E823CCA237CCE640 17 | ) 18 | 19 | Ubpa_DownloadFile( 20 | https://ubpa.github.io/USTC_CG_Data/Homeworks/08_Shader/textures/spot_albedo.png 21 | ${CMAKE_CURRENT_SOURCE_DIR}/spot_albedo.png 22 | SHA256 CDDABBAE52A666173E7953E238B88340D285044DC20B36F8ED3F1A41DB534FA5 23 | ) 24 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Engine/IBL/equirectangular_to_cubemap.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | #include "../../Math/basic.h" 4 | 5 | out vec4 FragColor; 6 | in vec3 WorldPos; 7 | 8 | uniform sampler2D equirectangularMap; 9 | 10 | float atan2(float y, float x); 11 | 12 | vec2 TexcoordOf(vec3 dir); 13 | 14 | void main() 15 | { 16 | vec2 uv = TexcoordOf(normalize(WorldPos)); 17 | vec3 color = texture(equirectangularMap, uv).rgb; 18 | 19 | FragColor = vec4(color, 1.0); 20 | } 21 | 22 | float atan2(float y, float x) { 23 | if(x > 0) 24 | return atan(y/x); 25 | else if(x < 0) { 26 | if(y >= 0) 27 | return atan(y/x) + PI; 28 | else 29 | return atan(y/x) - PI; 30 | } 31 | else // x == 0 32 | return sign(y) * HALF_PI; 33 | } 34 | 35 | vec2 TexcoordOf(vec3 dir) { 36 | float phi = atan2(-dir.x, -dir.z) + PI; 37 | float theta = acos(dir.y); 38 | 39 | float u = phi * INV_TWO_PI; 40 | float v = theta * INV_PI; 41 | return vec2(u,v); 42 | } 43 | -------------------------------------------------------------------------------- /Homeworks/2_ImageWarping/project/src/App/ImageWidget.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | QT_BEGIN_NAMESPACE 5 | class QImage; 6 | class QPainter; 7 | QT_END_NAMESPACE 8 | 9 | class ImageWidget : 10 | public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | ImageWidget(void); 16 | ~ImageWidget(void); 17 | 18 | protected: 19 | void paintEvent(QPaintEvent *paintevent); 20 | 21 | public slots: 22 | // File IO 23 | void Open(); // Open an image file, support ".bmp, .png, .jpg" format 24 | void Save(); // Save image to current file 25 | void SaveAs(); // Save image to another file 26 | 27 | // Image processing 28 | void Invert(); // Invert pixel value in image 29 | void Mirror(bool horizontal=false, bool vertical=true); // Mirror image vertically or horizontally 30 | void TurnGray(); // Turn image to gray-scale map 31 | void Restore(); // Restore image to origin 32 | 33 | private: 34 | QImage *ptr_image_; // image 35 | QImage *ptr_image_backup_; 36 | }; 37 | 38 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/Engine/Primitive/Triangle.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | 6 | using namespace Ubpa; 7 | 8 | const bboxf3 Triangle::GetBBox() const { 9 | const auto & positions = mesh.lock()->GetPositions(); 10 | 11 | pointf3 pArr[3] = { 12 | positions[idx[0]], 13 | positions[idx[1]], 14 | positions[idx[2]] 15 | }; 16 | 17 | pointf3 minP = pointf3::min(pointf3::min(pArr[0],pArr[1]),pArr[2]); 18 | pointf3 maxP = pointf3::max(pointf3::max(pArr[0], pArr[1]), pArr[2]); 19 | 20 | for (int dim = 0; dim < 3; dim++) { 21 | if (minP[dim] == maxP[dim]) { 22 | minP[dim] -= 0.001f; 23 | maxP[dim] += 0.001f; 24 | } 25 | } 26 | 27 | return bboxf3(minP, maxP); 28 | } 29 | 30 | float Triangle::GetArea() const { 31 | const auto & positions = mesh.lock()->GetPositions(); 32 | const auto e1 = positions[idx[1]] - positions[idx[0]]; 33 | const auto e2 = positions[idx[2]] - positions[idx[0]]; 34 | 35 | return 0.5f * e1.cross(e2).norm(); 36 | } 37 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Qt/PaintImgOpCreator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Ubpa { 6 | class Op; 7 | class Image; 8 | 9 | class RawAPI_OGLW; 10 | 11 | class PaintImgOpCreator { 12 | public: 13 | PaintImgOpCreator(RawAPI_OGLW* pOGLW); 14 | 15 | public: 16 | class PaintImgOp final : public HeapObj { 17 | friend class PaintImgOpCreator; 18 | 19 | public: 20 | PaintImgOp(RawAPI_OGLW* pOGLW); 21 | 22 | public: 23 | static const Ptr New(RawAPI_OGLW* pOGLW) { 24 | return Ubpa::New(pOGLW); 25 | } 26 | 27 | public: 28 | bool SetOp(int w, int h); 29 | RawAPI_OGLW* GetOGLW() { return pOGLW; } 30 | Ptr GetImg() { return img; } 31 | 32 | private: 33 | RawAPI_OGLW* pOGLW; 34 | 35 | Ptr initOp; 36 | Ptr paintOp; 37 | Ptr resizeOp; 38 | Ptr img; 39 | 40 | private: 41 | virtual ~PaintImgOp() = default; 42 | }; 43 | 44 | Ptr GenScenePaintOp(); 45 | 46 | private: 47 | RawAPI_OGLW* pOGLW; 48 | }; 49 | } 50 | -------------------------------------------------------------------------------- /Homeworks/8_Shader/project/data/shaders/dn.vert: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | layout (location = 0) in vec3 aPos; 4 | layout (location = 1) in vec2 aTexCoord; 5 | layout (location = 2) in vec3 aNormal; 6 | layout (location = 3) in vec3 aTangent; 7 | 8 | out VS_OUT { 9 | vec3 WorldPos; 10 | vec2 TexCoord; 11 | mat3 TBN; 12 | } vs_out; 13 | 14 | uniform mat4 projection; 15 | uniform mat4 view; 16 | uniform mat4 model; 17 | 18 | uniform sampler2D displacementmap; 19 | uniform float displacement_coefficient; 20 | 21 | void main() 22 | { 23 | // TODO HW8 - 0_displacement_normal | calculate displacement 24 | vec4 worldPos = model * vec4(aPos, 1.0); 25 | vs_out.WorldPos = worldPos.xyz / worldPos.w; 26 | 27 | vs_out.TexCoord = aTexCoord; 28 | 29 | mat3 normalMatrix = transpose(inverse(mat3(model))); 30 | 31 | // TODO HW8 - 0_displacement_normal | calculate TBN 32 | vec3 N = normalize(normalMatrix * aNormal); 33 | vec3 T = vec3(0); 34 | vec3 B = vec3(0); 35 | vs_out.TBN = mat3(T, B, N); 36 | 37 | gl_Position = projection * view * worldPos; 38 | } 39 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Basic/File.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace Ubpa { 7 | class File { 8 | public: 9 | enum Mode { 10 | READ, 11 | WRITE 12 | }; 13 | 14 | File(const std::string& fileName, Mode mode); 15 | 16 | ~File(); 17 | 18 | bool Check(Mode mode) const; 19 | 20 | int Printf(const char* format, ...); 21 | 22 | int Scanf(const char* format, ...) const; 23 | 24 | std::string ReadLine() const; 25 | 26 | std::string ReadAll() const; 27 | std::vector ReadAllLines() const; 28 | 29 | bool IsEnd() const; 30 | 31 | bool IsValid() const; 32 | 33 | void Close(); 34 | 35 | public: // static 36 | static const std::string ReadAll(const std::string& fileName); 37 | static const std::vector ReadAllLines(const std::string& fileName); 38 | static bool IsSame(const std::string& fileName0, const std::string& fileName1); 39 | 40 | private: 41 | std::string ModeToStr(Mode mode); 42 | 43 | FILE* pF; 44 | Mode mode; 45 | std::string fileName; 46 | }; 47 | } 48 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/include/Engine/Material/BSDF_Mirror.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Ubpa { 6 | class BSDF_Mirror : public BSDF { 7 | public: 8 | BSDF_Mirror(const rgbf& reflectance = rgbf(1.f)) : reflectance(reflectance) { } 9 | 10 | public: 11 | static const Ptr New(const rgbf& reflectance = rgbf(1.f)) { 12 | return Ubpa::New(reflectance); 13 | } 14 | 15 | protected: 16 | virtual ~BSDF_Mirror() = default; 17 | 18 | public: 19 | virtual const rgbf F(const normalf& wo, const normalf& wi, const pointf2& texcoord) override { return rgbf(0.f); }; 20 | 21 | // probability density function 22 | virtual float PDF(const normalf& wo, const normalf& wi, const pointf2& texcoord) override { return 0; } 23 | 24 | // PD is probability density 25 | // return albedo 26 | virtual const rgbf Sample_f(const normalf& wo, const pointf2& texcoord, normalf& wi, float& PD) override; 27 | 28 | virtual bool IsDelta() const override { return true; } 29 | 30 | public: 31 | rgbf reflectance; 32 | }; 33 | } 34 | -------------------------------------------------------------------------------- /Homeworks/9_PathTracing/project/src/UEditor/Cmpt/detail/Hierarchy.inl: -------------------------------------------------------------------------------- 1 | /* 2 | Generated by Ubpa::UScene_parser 3 | Any changes to this file will be overwritten by the next CMake run 4 | ---- 5 | Usage: 6 | #include "this-file" // in cpp 7 | */ 8 | 9 | #include 10 | 11 | #include 12 | 13 | namespace Ubpa::Cmpt::detail::dynamic_reflection { 14 | void ReflRegister_Hierarchy() { 15 | Reflection::Instance() // name : class Ubpa::Cmpt::Hierarchy 16 | ; 17 | if constexpr (std::is_base_of_v) { 18 | Reflection::Instance().RegisterConstructor([](SObj* sobj) { 19 | if constexpr (std::is_base_of_v) { 20 | if constexpr (Ubpa::detail::SObj_::IsNecessaryCmpt) 21 | return sobj->Get(); 22 | else 23 | return sobj->GetOrAttach(); 24 | }; 25 | }); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Homeworks/5_ARAP/project/README.md: -------------------------------------------------------------------------------- 1 | # 作业完成说明 2 | 3 | ## 项目配置方式更新 4 | 5 | > 2020/03/18 6 | 7 | 1. 删除 [4_MinSurfMeshPara/project/external](../4_MinSurfMeshPara/project/external) 文件夹 8 | 2. 拉取更新(更新了较多文件,如有冲突,谨慎解决) 9 | 3. 下载 Ubpa 库 [Ubpa_20200318.zip](https://cdn.jsdelivr.net/gh/Ubpa/USTC_CG_Data@master/Homeworks/Ubpa/Ubpa_20200318.zip)(包含 UCMake,UTemplate,UDP,UGM,UHEMesh),将其中的文件夹 `Ubpa/` 放到合适的位置,并将 `/bin`(``要替换成具体路径)加入到系统环境变量 `Path` 中 10 | 5. cmake 三连即可,包含多次 `find_package`,如上述配置成功则能找到具体的库,否则会自动 git clone 到 build/_deps 中,并加入到 UEngine 中一并编译 11 | 12 | ## 作业完成步骤 13 | 14 | 本次作业在 [作业 4 的框架](../../4_MinSurfMeshPara/project) 上完成所要求的参数化方法(ASAP, ARAP方法),模仿作业4使用半边数据结构来实现算法。 15 | 16 | 参考步骤如下: 17 | 18 | - 模仿 [Paramaterize.h](../../4_MinSurfMeshPara/project/include/Engine/MeshEdit/Paramaterize.h) 和 [Paramaterize.cpp](../../4_MinSurfMeshPara/project/src/Engine/MeshEdit/Paramaterize.cpp) 新建文件 ASAP.h,ASAP.cpp,ARAP.h,ARAP.cpp 等 19 | - 在 [Attribute.cpp](../../4_MinSurfMeshPara/project/src/UI/Attribute.cpp) 中模仿已有示例给 ASAP 方法和 ARAP 方法各添加一个按钮,或者添加适当的 UI 进行参数化的方法选择,从而简化交互 20 | - 参数化后也须显示纹理映射结果 21 | 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Ubp.a 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /Homeworks/0_CppPratices/documents/5_map_Polynomial/README.md: -------------------------------------------------------------------------------- 1 | # 5. 基于 map 的多项式类 2 | 3 | > **注:** 如果你正在接受这些编程训练,表示你已经同意我们之间的版权协议。请严禁将这些练习的代码(包括你自己的代码)在不经允许的情况下在公共网上公布和散播。一经发现,后果自负。谢谢!-刘利刚 (ligang.liu@gmail.com) 4 | 5 | ## 静态库 6 | 7 | 所谓**程序库**,一般是软件作者为了发布方便、替换方便或二次开发目的,而发布的一组可以单独与应用程序进行 compile time 或 runtime 链接的二进制可重定位目标码文件。通俗一点说,所谓一个库,就是一个文件,这个文件可以在编译时由编译器直接链接到可执行程序中,也可以在运行时由操作系统的 runtime enviroment 根据需要动态加载到内存中。一组库,就形成了一个发布包,当然,具体发布多少个库,完全由库提供商自己决定。 8 | 9 | 所谓**静态库**,就是在静态编译时由编译器到指定目录寻找并且进行链接,一旦链接完成,最终的可执行程序中就包含了该库文件中的所有有用信息,包括代码段、数据段等。所谓动态库,就是在应用程序运行时,由操作系统根据应用程序的请求,动态到指定目录下寻找并装载入内存中,同时需要进行地址重定向。 win32 平台下,静态库通常后缀为 .lib,动态库为 .dll。相对于动态库,静态库的优点在于直接被链接进可执行程序中,之后,该可执行程序就不再依赖于运行环境的设置了(当然仍然会依赖于 CPU 指令集和操作系统支持的可执行文件格式等硬性限制)。而动态库的优点在于,用户甚至可以在程序运行时随时替换该动态库,这就构成了动态插件系统的基础。具体使用静态库和动态库,由程序员根据需要自己决定。 10 | 11 | ## 作业目的 12 | 13 | 作业 1.4 的 `Polynomial` 也可以使用 STL 中的 `map` 类来实现同样的功能。对于 `Polynomial`,它其实就是一个稀疏向量,用 `map` 是更自然的表示,而且从效率上更高。 14 | 15 | 学会生成静态库 lib 及使用静态库; 16 | 17 | ## 作业要求 18 | 19 | - 使用 `map` 来实现 `polynomial` 类; 20 | - 对比一下利用 `list `和利用 `map` 实现的 `polynomial` 类:随机生成多项式,当输入的多项式非零项个数较大,且不按次数顺序排列时,两种实现方式的效率;加、减、乘运算的效率,等。感受两种容器的时间复杂度的不同。 21 | 22 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/documents/obj.md: -------------------------------------------------------------------------------- 1 | # obj 三维网格文件 2 | 3 | OBJ 三维网格文件不需要任何[文件头](http://baike.baidu.com/view/1606305.htm)(File Header),可以使用几行文件信息的注释作为文件的开头。OBJ 文件由一行行文本组成,注释行以符号“#”为开头,空格和空行可以随意加到文件中以增加文件的可读性。多行可以逻辑地连接在一起表示一行,方法是在每一行最后添加一个连接符(\)。注意连接符(\)后面不能出现空格或Tab格,否则将导致文件出错。 4 | 5 | 更详细的OBJ 三维网格文件的格式说明可查看课程百度云目录"Homework/Homework4/三角网格数据/MeshFileFormat"。 6 | 7 | 在这仅列出了常使用的数据类型: 8 | 9 | **数据(Vertex data):** 10 | 11 | - v 网格顶点(Geometric vertices) 12 | - vn 顶点法向量(Vertex normals) 13 | - vt [纹理贴图](http://baike.baidu.com/view/366383.htm)坐标(Texture coordinates) 14 | - vp 参数空格顶点 (Parameter space vertices) 15 | - f 网格的面,由若干顶点(序号)组成。在OBJ中,顶点序号是从1(而不是0)开始的。 16 | 17 | **材质(Material data):** 18 | 19 | OBJ 文件不包含面的颜色定义信息,不过可以引用材质库,材质库信息储存在一个后缀是".mtl"的独立文件中。关键字"mtllib"即材质库的意思。 20 | 21 | 材质库中包含材质的漫射(diffuse),环境(ambient),光泽(specular)的 RGB (红绿蓝)的定义值,以及反射(specularity),折射(refraction),透明度(transparency)等其它特征。 22 | 23 | **一个例子** 24 | 25 | 下面是一个多边形的例子: 26 | 27 | ``` 28 | v -2 0 0 29 | v -1 1 0 30 | v 1 1 0 31 | v 2 0 0 32 | v 1 -1 0 33 | v -1 -1 0 34 | v 0 0 0 35 | f 1 6 2 36 | f 6 7 2 37 | f 6 5 7 38 | f 2 7 3 39 | f 7 5 3 40 | f 3 5 4 41 | ``` 42 | 43 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/data/shaders/Engine/DeferredPipeline/GBuffer_Diffuse.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | layout (location = 0) out vec4 GBuffer0; 4 | layout (location = 1) out vec4 GBuffer1; 5 | layout (location = 2) out vec4 GBuffer2; 6 | layout (location = 3) out vec4 GBuffer3; 7 | 8 | // layout 9 | // x y z w 10 | // 0 [ pos ] ID 11 | // 1 [ norm ] 1 12 | // 2 [ albedo ] 0 13 | // 3 1 14 | 15 | in VS_OUT { 16 | vec3 FragPos; 17 | vec3 Normal; 18 | vec2 TexCoords; 19 | vec3 Tangent; 20 | } fs_in; 21 | 22 | struct BSDF_Diffuse { 23 | vec3 colorFactor; 24 | bool haveAlbedoTexture; 25 | sampler2D albedoTexture; 26 | }; 27 | 28 | uniform BSDF_Diffuse diffuse; 29 | uniform int ID; 30 | 31 | void main() { 32 | // 获取属性值 33 | vec3 albedo = diffuse.colorFactor; 34 | if(diffuse.haveAlbedoTexture) { 35 | albedo *= texture(diffuse.albedoTexture, fs_in.TexCoords).xyz; 36 | } 37 | 38 | // pack GBuffer 39 | GBuffer0 = vec4(fs_in.FragPos, ID); 40 | GBuffer1 = vec4(normalize(fs_in.Normal), 1); 41 | GBuffer2 = vec4(albedo, 0); 42 | GBuffer3 = vec4(0, 0, 0, 1); 43 | } 44 | -------------------------------------------------------------------------------- /Homeworks/4_MinSurfMeshPara/project/src/App/UEngine/UEngine.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "ui_UEngine.h" 5 | 6 | #include 7 | #include 8 | 9 | namespace Ubpa { 10 | class Op; 11 | class Scene; 12 | class Viewer; 13 | class RTX_Renderer; 14 | class PathTracer; 15 | } 16 | 17 | using namespace Ubpa; 18 | 19 | class UEngine : public QMainWindow 20 | { 21 | Q_OBJECT 22 | 23 | 24 | public: 25 | UEngine(QWidget *parent = Q_NULLPTR); 26 | 27 | public: 28 | Ptr GetScene()const { return scene; } 29 | 30 | private slots: 31 | void on_btn_RenderStart_clicked(); 32 | void on_btn_RenderStop_clicked(); 33 | void on_btn_SaveRasterImg_clicked(); 34 | void on_btn_SaveRayTracerImg_clicked(); 35 | void updateSimulate(); 36 | void UI_Op(Ptr op); 37 | 38 | private: 39 | void InitSetting(); 40 | 41 | private: 42 | Ui::UEngineClass ui; 43 | Ptr paintImgOp; 44 | Ptr scene; 45 | Ptr viewer; 46 | Ptr rtxRenderer; 47 | 48 | private: 49 | // setting 50 | int maxDepth; 51 | int maxLoop; 52 | }; 53 | --------------------------------------------------------------------------------