1 Commits

Author SHA1 Message Date
Endertom e50e2987c9 Caricamento v0.2 2026-05-31 10:42:30 +02:00
29 changed files with 3411 additions and 16687 deletions
+11 -3
View File
@@ -12,12 +12,20 @@ FetchContent_Declare(SFML
SYSTEM)
FetchContent_MakeAvailable(SFML)
FetchContent_Declare(
glm
GIT_REPOSITORY https://github.com/g-truc/glm.git
GIT_TAG 0af55ccecd98d4e5a8d1fad7de25ba429d60e863 #refs/tags/1.0.1
)
FetchContent_MakeAvailable(glm)
set(METHODS_PATH "./src/*/methods/*.cpp")
#V1
set(VERSION "V1")
set(VERSION "V2")
file(GLOB_RECURSE METHODS_SRC "${METHODS_PATH}")
add_executable(main${VERSION} ./src/testMain.cpp ${METHODS_SRC} )
target_compile_features(main${VERSION} PRIVATE cxx_std_17)
target_link_libraries(main${VERSION} PRIVATE SFML::Graphics)
target_link_libraries(main${VERSION} PRIVATE SFML::Graphics glm)
+7 -2
View File
@@ -1,7 +1,7 @@
# FCG_VisualizzatoreCamminata
Nella versione versione v0.1 è presente la base del progetto.
## Nella versione versione v0.1 è presente la base del progetto.
- La gerarchia dei file e delle classi
@@ -17,10 +17,15 @@ Per questione di debug tutti i pezzi rappresentati si possono trascinare e ruota
Per spostare l'intera scena si tiene premuto il tasto centrale del mouse.
## Nella versione v0.2:
- Applicato refactoring di diverse classi
- Aggiustato calcolo dei pivot implementando le rotazioni con algebra affine e glm
- Aggiuta classe caviglia (per differenziarla dalla coscia)
Per compliare:
cmake --build
Per lanciare:
./build/bin/mainV1
./build/bin/mainV2
@@ -1107,7 +1107,7 @@
}
],
"type" : "INTERNAL",
"value" : "8"
"value" : "10"
},
{
"name" : "CMAKE_OBJCOPY",
@@ -1653,6 +1653,18 @@
"type" : "BOOL",
"value" : "ON"
},
{
"name" : "FETCHCONTENT_SOURCE_DIR_GLM",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : "When not empty, overrides where to find pre-populated content for glm"
}
],
"type" : "PATH",
"value" : ""
},
{
"name" : "FETCHCONTENT_SOURCE_DIR_SFML",
"properties" :
@@ -1677,6 +1689,18 @@
"type" : "BOOL",
"value" : "OFF"
},
{
"name" : "FETCHCONTENT_UPDATES_DISCONNECTED_GLM",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : "Enables UPDATE_DISCONNECTED behavior just for population of glm"
}
],
"type" : "BOOL",
"value" : "OFF"
},
{
"name" : "FETCHCONTENT_UPDATES_DISCONNECTED_SFML",
"properties" :
@@ -1869,6 +1893,234 @@
"type" : "FILEPATH",
"value" : "/usr/bin/git"
},
{
"name" : "GLM_BUILD_INSTALL",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : "Generate the install target"
}
],
"type" : "BOOL",
"value" : "OFF"
},
{
"name" : "GLM_BUILD_LIBRARY",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : "Build dynamic/static library"
}
],
"type" : "BOOL",
"value" : "ON"
},
{
"name" : "GLM_BUILD_TESTS",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : "Build the test programs"
}
],
"type" : "BOOL",
"value" : "OFF"
},
{
"name" : "GLM_DISABLE_AUTO_DETECTION",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : "Disable platform, compiler, arch and C++ language detection"
}
],
"type" : "BOOL",
"value" : "OFF"
},
{
"name" : "GLM_ENABLE_CXX_11",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : "Enable C++ 11"
}
],
"type" : "BOOL",
"value" : "OFF"
},
{
"name" : "GLM_ENABLE_CXX_14",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : "Enable C++ 14"
}
],
"type" : "BOOL",
"value" : "OFF"
},
{
"name" : "GLM_ENABLE_CXX_17",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : "Enable C++ 17"
}
],
"type" : "BOOL",
"value" : "OFF"
},
{
"name" : "GLM_ENABLE_CXX_20",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : "Enable C++ 20"
}
],
"type" : "BOOL",
"value" : "OFF"
},
{
"name" : "GLM_ENABLE_CXX_98",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : "Enable C++ 98"
}
],
"type" : "BOOL",
"value" : "OFF"
},
{
"name" : "GLM_ENABLE_FAST_MATH",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : "Enable fast math optimizations"
}
],
"type" : "BOOL",
"value" : "OFF"
},
{
"name" : "GLM_ENABLE_LANG_EXTENSIONS",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : "Enable language extensions"
}
],
"type" : "BOOL",
"value" : "OFF"
},
{
"name" : "GLM_ENABLE_SIMD_AVX",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : "Enable AVX optimizations"
}
],
"type" : "BOOL",
"value" : "OFF"
},
{
"name" : "GLM_ENABLE_SIMD_AVX2",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : "Enable AVX2 optimizations"
}
],
"type" : "BOOL",
"value" : "OFF"
},
{
"name" : "GLM_ENABLE_SIMD_SSE2",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : "Enable SSE2 optimizations"
}
],
"type" : "BOOL",
"value" : "OFF"
},
{
"name" : "GLM_ENABLE_SIMD_SSE3",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : "Enable SSE3 optimizations"
}
],
"type" : "BOOL",
"value" : "OFF"
},
{
"name" : "GLM_ENABLE_SIMD_SSE4_1",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : "Enable SSE 4.1 optimizations"
}
],
"type" : "BOOL",
"value" : "OFF"
},
{
"name" : "GLM_ENABLE_SIMD_SSE4_2",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : "Enable SSE 4.2 optimizations"
}
],
"type" : "BOOL",
"value" : "OFF"
},
{
"name" : "GLM_ENABLE_SIMD_SSSE3",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : "Enable SSSE3 optimizations"
}
],
"type" : "BOOL",
"value" : "OFF"
},
{
"name" : "GLM_FORCE_PURE",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : "Force 'pure' instructions"
}
],
"type" : "BOOL",
"value" : "OFF"
},
{
"name" : "OGG_INCLUDE_DIR",
"properties" :
@@ -4636,6 +4888,42 @@
],
"type" : "INTERNAL",
"value" : "/usr/local"
},
{
"name" : "glm_BINARY_DIR",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : "Value Computed by CMake"
}
],
"type" : "STATIC",
"value" : "/home/endertom/Documenti/ProgettoFinaleRep/FCG_VisualizzatoreCamminata/build/_deps/glm-build"
},
{
"name" : "glm_IS_TOP_LEVEL",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : "Value Computed by CMake"
}
],
"type" : "STATIC",
"value" : "OFF"
},
{
"name" : "glm_SOURCE_DIR",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : "Value Computed by CMake"
}
],
"type" : "STATIC",
"value" : "/home/endertom/Documenti/ProgettoFinaleRep/FCG_VisualizzatoreCamminata/build/_deps/glm-src"
}
],
"kind" : "cache",
@@ -147,6 +147,26 @@
"isExternal" : true,
"path" : "/usr/share/cmake-4.2/Modules/FetchContent/CMakeLists.cmake.in"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/usr/share/cmake-4.2/Modules/FindGit.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/usr/share/cmake-4.2/Modules/FindPackageHandleStandardArgs.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/usr/share/cmake-4.2/Modules/FindPackageMessage.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/usr/share/cmake-4.2/Modules/FetchContent/CMakeLists.cmake.in"
},
{
"isGenerated" : true,
"path" : "build/_deps/sfml-src/CMakeLists.txt"
@@ -535,6 +555,19 @@
{
"isGenerated" : true,
"path" : "build/_deps/sfml-src/src/SFML/Audio/Dependencies.cmake.in"
},
{
"isGenerated" : true,
"path" : "build/_deps/glm-src/CMakeLists.txt"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/usr/share/cmake-4.2/Modules/GNUInstallDirs.cmake"
},
{
"isGenerated" : true,
"path" : "build/_deps/glm-src/glm/CMakeLists.txt"
}
],
"kind" : "cmakeFiles",
@@ -234,6 +234,13 @@
"jsonFile" : "target-freetype-Debug-abdfbd050f0222558c4d.json",
"name" : "freetype",
"projectIndex" : 1
},
{
"directoryIndex" : 9,
"id" : "glm-header-only::@ce54d98d7b326a3e12a8",
"jsonFile" : "target-glm-header-only-Debug-ba11e7860c401de4a955.json",
"name" : "glm-header-only",
"projectIndex" : 2
}
],
"directories" :
@@ -246,7 +253,8 @@
"build" : ".",
"childIndexes" :
[
1
1,
8
],
"hasInstallRule" : true,
"jsonFile" : "directory-.-Debug-9ad1a58d4644cf6543fa.json",
@@ -258,7 +266,7 @@
"source" : ".",
"targetIndexes" :
[
0
1
]
},
{
@@ -268,7 +276,7 @@
2
],
"hasInstallRule" : true,
"jsonFile" : "directory-_deps.sfml-build-Debug-dfee4a8ac98e62d8aa87.json",
"jsonFile" : "directory-_deps.sfml-build-Debug-9e99fff3adb968d44f8e.json",
"minimumCMakeVersion" :
{
"string" : "3.22"
@@ -304,7 +312,7 @@
],
"build" : "_deps/sfml-build/src/SFML/System",
"hasInstallRule" : true,
"jsonFile" : "directory-_deps.sfml-build.src.SFML.System-Debug-a8a648ac157acad150c5.json",
"jsonFile" : "directory-_deps.sfml-build.src.SFML.System-Debug-8ed26fbff62444cac103.json",
"minimumCMakeVersion" :
{
"string" : "3.22"
@@ -314,7 +322,7 @@
"source" : "build/_deps/sfml-src/src/SFML/System",
"targetIndexes" :
[
4
5
]
},
{
@@ -347,7 +355,7 @@
],
"build" : "_deps/sfml-build/src/SFML/Window",
"hasInstallRule" : true,
"jsonFile" : "directory-_deps.sfml-build.src.SFML.Window-Debug-be3f1b58265dd0b182ad.json",
"jsonFile" : "directory-_deps.sfml-build.src.SFML.Window-Debug-bc441d344f43ebac1e95.json",
"minimumCMakeVersion" :
{
"string" : "3.22"
@@ -357,13 +365,13 @@
"source" : "build/_deps/sfml-src/src/SFML/Window",
"targetIndexes" :
[
5
6
]
},
{
"build" : "_deps/sfml-build/src/SFML/Network",
"hasInstallRule" : true,
"jsonFile" : "directory-_deps.sfml-build.src.SFML.Network-Debug-2e3db7a0b897a8f2912c.json",
"jsonFile" : "directory-_deps.sfml-build.src.SFML.Network-Debug-2df01c5cf9c0481e3681.json",
"minimumCMakeVersion" :
{
"string" : "3.22"
@@ -373,7 +381,7 @@
"source" : "build/_deps/sfml-src/src/SFML/Network",
"targetIndexes" :
[
3
4
]
},
{
@@ -383,7 +391,7 @@
],
"build" : "_deps/sfml-build/src/SFML/Graphics",
"hasInstallRule" : true,
"jsonFile" : "directory-_deps.sfml-build.src.SFML.Graphics-Debug-d9a9bb084c70b51401a2.json",
"jsonFile" : "directory-_deps.sfml-build.src.SFML.Graphics-Debug-882c334f5d5ccd802105.json",
"minimumCMakeVersion" :
{
"string" : "3.22"
@@ -393,7 +401,7 @@
"source" : "build/_deps/sfml-src/src/SFML/Graphics",
"targetIndexes" :
[
2
3
]
},
{
@@ -408,7 +416,7 @@
],
"build" : "_deps/sfml-build/src/SFML/Audio",
"hasInstallRule" : true,
"jsonFile" : "directory-_deps.sfml-build.src.SFML.Audio-Debug-a33c3c7d6b217e553221.json",
"jsonFile" : "directory-_deps.sfml-build.src.SFML.Audio-Debug-6b2b3af0fd9759ab7812.json",
"minimumCMakeVersion" :
{
"string" : "3.22"
@@ -418,7 +426,41 @@
"source" : "build/_deps/sfml-src/src/SFML/Audio",
"targetIndexes" :
[
1
2
]
},
{
"build" : "_deps/glm-build",
"childIndexes" :
[
9
],
"jsonFile" : "directory-_deps.glm-build-Debug-c62d847c2156f7f8634f.json",
"minimumCMakeVersion" :
{
"string" : "3.6"
},
"parentIndex" : 0,
"projectIndex" : 2,
"source" : "build/_deps/glm-src"
},
{
"abstractTargetIndexes" :
[
33
],
"build" : "_deps/glm-build/glm",
"jsonFile" : "directory-_deps.glm-build.glm-Debug-ee2f18c9a18ae24a8c8e.json",
"minimumCMakeVersion" :
{
"string" : "3.6"
},
"parentIndex" : 8,
"projectIndex" : 2,
"source" : "build/_deps/glm-src/glm",
"targetIndexes" :
[
0
]
}
],
@@ -432,7 +474,8 @@
],
"childIndexes" :
[
1
1,
2
],
"directoryIndexes" :
[
@@ -441,7 +484,7 @@
"name" : "CMakeSFMLProject",
"targetIndexes" :
[
0
1
]
},
{
@@ -494,21 +537,45 @@
"parentIndex" : 0,
"targetIndexes" :
[
1,
2,
3,
4,
5
5,
6
]
},
{
"abstractTargetIndexes" :
[
33
],
"directoryIndexes" :
[
8,
9
],
"name" : "glm",
"parentIndex" : 0,
"targetIndexes" :
[
0
]
}
],
"targets" :
[
{
"directoryIndex" : 9,
"id" : "glm::@ce54d98d7b326a3e12a8",
"jsonFile" : "target-glm-Debug-244f6aa87d17e32353a7.json",
"name" : "glm",
"projectIndex" : 2
},
{
"directoryIndex" : 0,
"id" : "mainV1::@6890427a1f51a3e7e1df",
"jsonFile" : "target-mainV1-Debug-5ee4cebbd3969ed04364.json",
"name" : "mainV1",
"id" : "mainV2::@6890427a1f51a3e7e1df",
"jsonFile" : "target-mainV2-Debug-13e85d69c1816e9e6763.json",
"name" : "mainV2",
"projectIndex" : 0
},
{
@@ -0,0 +1,19 @@
{
"backtraceGraph" :
{
"commands" : [],
"files" : [],
"nodes" : []
},
"codemodelVersion" :
{
"major" : 2,
"minor" : 9
},
"installers" : [],
"paths" :
{
"build" : "_deps/glm-build",
"source" : "build/_deps/glm-src"
}
}
@@ -0,0 +1,19 @@
{
"backtraceGraph" :
{
"commands" : [],
"files" : [],
"nodes" : []
},
"codemodelVersion" :
{
"major" : 2,
"minor" : 9
},
"installers" : [],
"paths" :
{
"build" : "_deps/glm-build/glm",
"source" : "build/_deps/glm-src/glm"
}
}
@@ -242,7 +242,7 @@
[
{
"id" : "sfml-system::@8cb1db2982443611e568",
"index" : 4
"index" : 5
}
],
"paths" :
@@ -260,7 +260,7 @@
[
{
"id" : "sfml-window::@5730451e331e3690ae65",
"index" : 5
"index" : 6
}
],
"paths" :
@@ -278,7 +278,7 @@
[
{
"id" : "sfml-network::@d7f79968b2699e7782cb",
"index" : 3
"index" : 4
}
],
"paths" :
@@ -296,7 +296,7 @@
[
{
"id" : "sfml-graphics::@98af38147d5fa7e70f61",
"index" : 2
"index" : 3
}
],
"paths" :
@@ -314,7 +314,7 @@
[
{
"id" : "sfml-audio::@a153e5727587c53fce98",
"index" : 1
"index" : 2
}
],
"paths" :
@@ -52,7 +52,7 @@
"_deps/sfml-build/lib/libsfml-audio-s-d.a"
],
"targetId" : "sfml-audio::@a153e5727587c53fce98",
"targetIndex" : 1,
"targetIndex" : 2,
"type" : "target"
},
{
@@ -52,7 +52,7 @@
"_deps/sfml-build/lib/libsfml-graphics-s-d.a"
],
"targetId" : "sfml-graphics::@98af38147d5fa7e70f61",
"targetIndex" : 2,
"targetIndex" : 3,
"type" : "target"
},
{
@@ -46,7 +46,7 @@
"_deps/sfml-build/lib/libsfml-network-s-d.a"
],
"targetId" : "sfml-network::@d7f79968b2699e7782cb",
"targetIndex" : 3,
"targetIndex" : 4,
"type" : "target"
}
],
@@ -52,7 +52,7 @@
"_deps/sfml-build/lib/libsfml-system-s-d.a"
],
"targetId" : "sfml-system::@8cb1db2982443611e568",
"targetIndex" : 4,
"targetIndex" : 5,
"type" : "target"
},
{
@@ -52,7 +52,7 @@
"_deps/sfml-build/lib/libsfml-window-s-d.a"
],
"targetId" : "sfml-window::@5730451e331e3690ae65",
"targetIndex" : 5,
"targetIndex" : 6,
"type" : "target"
},
{
@@ -26,7 +26,7 @@
"objects" :
[
{
"jsonFile" : "codemodel-v2-32cc683d1353c8d76846.json",
"jsonFile" : "codemodel-v2-dbb57b2013933c842c1b.json",
"kind" : "codemodel",
"version" :
{
@@ -35,7 +35,7 @@
}
},
{
"jsonFile" : "cache-v2-bfa9fbd295e1c2548deb.json",
"jsonFile" : "cache-v2-cf38a27fbc2746147de0.json",
"kind" : "cache",
"version" :
{
@@ -44,7 +44,7 @@
}
},
{
"jsonFile" : "cmakeFiles-v1-c1c7adbe1bc85952b01c.json",
"jsonFile" : "cmakeFiles-v1-55a603bab8f1f7b9a9db.json",
"kind" : "cmakeFiles",
"version" :
{
@@ -90,7 +90,7 @@
"responses" :
[
{
"jsonFile" : "cache-v2-bfa9fbd295e1c2548deb.json",
"jsonFile" : "cache-v2-cf38a27fbc2746147de0.json",
"kind" : "cache",
"version" :
{
@@ -99,7 +99,7 @@
}
},
{
"jsonFile" : "codemodel-v2-32cc683d1353c8d76846.json",
"jsonFile" : "codemodel-v2-dbb57b2013933c842c1b.json",
"kind" : "codemodel",
"version" :
{
@@ -117,7 +117,7 @@
}
},
{
"jsonFile" : "cmakeFiles-v1-c1c7adbe1bc85952b01c.json",
"jsonFile" : "cmakeFiles-v1-55a603bab8f1f7b9a9db.json",
"kind" : "cmakeFiles",
"version" :
{
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,41 @@
{
"abstract" : true,
"backtrace" : 1,
"backtraceGraph" :
{
"commands" :
[
"add_library"
],
"files" :
[
"build/_deps/glm-src/glm/CMakeLists.txt"
],
"nodes" :
[
{
"file" : 0
},
{
"command" : 0,
"file" : 0,
"line" : 45,
"parent" : 0
}
]
},
"codemodelVersion" :
{
"major" : 2,
"minor" : 9
},
"id" : "glm-header-only::@ce54d98d7b326a3e12a8",
"name" : "glm-header-only",
"paths" :
{
"build" : "_deps/glm-build/glm",
"source" : "build/_deps/glm-src/glm"
},
"sources" : [],
"type" : "INTERFACE_LIBRARY"
}
@@ -2,7 +2,7 @@
"artifacts" :
[
{
"path" : "bin/mainV1"
"path" : "bin/mainV2"
}
],
"backtrace" : 1,
@@ -31,13 +31,13 @@
{
"command" : 0,
"file" : 0,
"line" : 21,
"line" : 29,
"parent" : 0
},
{
"command" : 1,
"file" : 0,
"line" : 23,
"line" : 31,
"parent" : 0
},
{
@@ -125,6 +125,10 @@
{
"backtrace" : 2,
"id" : "sfml-graphics::@98af38147d5fa7e70f61"
},
{
"backtrace" : 2,
"id" : "glm::@ce54d98d7b326a3e12a8"
}
],
"compileGroups" :
@@ -145,6 +149,10 @@
],
"includes" :
[
{
"backtrace" : 2,
"path" : "/home/endertom/Documenti/ProgettoFinaleRep/FCG_VisualizzatoreCamminata/build/_deps/glm-src"
},
{
"backtrace" : 2,
"isSystem" : true,
@@ -177,9 +185,13 @@
{
"backtrace" : 2,
"id" : "sfml-graphics::@98af38147d5fa7e70f61"
},
{
"backtrace" : 2,
"id" : "glm::@ce54d98d7b326a3e12a8"
}
],
"id" : "mainV1::@6890427a1f51a3e7e1df",
"id" : "mainV2::@6890427a1f51a3e7e1df",
"link" :
{
"commandFragments" :
@@ -193,6 +205,11 @@
"fragment" : "_deps/sfml-build/lib/libsfml-graphics-s-d.a",
"role" : "libraries"
},
{
"backtrace" : 2,
"fragment" : "_deps/glm-build/glm/libglm.a",
"role" : "libraries"
},
{
"backtrace" : 4,
"fragment" : "_deps/sfml-build/lib/libsfml-window-s-d.a",
@@ -271,10 +288,14 @@
{
"backtrace" : 2,
"id" : "sfml-graphics::@98af38147d5fa7e70f61"
},
{
"backtrace" : 2,
"id" : "glm::@ce54d98d7b326a3e12a8"
}
],
"name" : "mainV1",
"nameOnDisk" : "mainV1",
"name" : "mainV2",
"nameOnDisk" : "mainV2",
"paths" :
{
"build" : ".",
BIN
View File
Binary file not shown.
-16515
View File
File diff suppressed because it is too large Load Diff
-44
View File
@@ -1,44 +0,0 @@
#include<math.h>
#include"rb_class.cpp"
#include<time.h>
/*
Questo namespace deve contenere le funzioni di gestione della fisica del motore.
Ogni moto in questo engine sarà ti tipo uniformemente accelerato per dare una semplificazione della realtà.
Le funzioni necessarie sono:
- Calcolo velocità, richiede:
(Oggetto rigidbody)
(time di partenza, time di arrivo o delta t)
(Accelerazione media)
(velocità iniziale)
- Calcolo rotazione, richiede:
(Oggetto rigidbody)
(time di partenza, time di arrivo o delta t)
(Accelerazione tangenziale)
(RAD/s iniziale)
- Calcolo accelerazione, deve modificare i valori di accelerazione su oggetti di tipo rigidbody, richiede:
(Oggetto rigidbody)
- Calcolo posizione, deve calcolare la posizione di un rigidbody in in un intervallo di tempo
- Calcolo energia potenziale
- Calcolo inerzia
- Calcolo energia meccanica
*/
using namespace rb;
namespace fis{
void calcVel(rigidbody body, const time_t Dtime);
void calcRot(rigidbody body, const time_t Dtime);
void calcAcc(rigidbody body, const std::vector<float> Dacc);
void calcTanAcc(rigidbody body, const std::vector<float> Dacc);
void calcPos(rigidbody body, const time_t Dtime);
}
+1
View File
@@ -2,6 +2,7 @@
#include "csv/headers/csv.hpp"
#include "sfml_util.cpp"
#include "pieces/headers/coscia.hpp"
#include "pieces/headers/caviglia.hpp"
#include "pieces/headers/sensore.hpp"
#include "joints/headers/rigid_joint.hpp"
#include "joints/headers/pivot_joint.hpp"
+1
View File
@@ -1,4 +1,5 @@
#include "../../pieces/headers/piece_interface.hpp"
#include <glm/glm.hpp>
#ifndef JOINT_INTERFACE_H
#define JOINT_INTERFACE_H
+25 -37
View File
@@ -4,55 +4,43 @@
void PivotJoint::rotate(unsigned int id){
rb::Vector3_s fRot = father->body.getRot();
rb::Vector3 fPos = father->body.getPos();
rb::Vector3_s cRot = childs[id]->body.getRot();
//// sposto l'origine passivamente su tutti gli assi ////
float r1 = sqrt(pow(pivot[0],2)+pow(pivot[2],2)); //calcolo modulo dell'offset (per ora solo sul piano xz)
float r2 = sqrt(pow(offset[id][0],2)+pow(offset[id][2],2));
if (r1>ZERO_INT){
float alpha = float (fRot[2] - oldRot[2]);
float cosA = glm::cos(alpha);
float sinA = glm::sin(alpha);
float sign = pivot[2] >= 0 ? 1 : -1;
float beta = float (cRot[2] - oldCRot[id][2]);
float cosB = glm::cos(beta);
float sinB = glm::sin(beta);
glm::mat3 R1 = glm::mat3(
/*cos*/ cosA, /*sin*/ sinA, 0,
/*-sin*/ -sinA , /*cos*/ cosA, 0,
0, 0, 1
);
glm::mat3 R2 = glm::mat3(
/*cos*/ cosB, /*sin*/ sinB, 0,
/*-sin*/ -sinB , /*cos*/ cosB, 0,
0, 0, 1
);
glm::vec3 pivotNXZ = R1 * glm::vec3(pivot[0],pivot[2],1);
pivot = rb::Vector3{pivotNXZ[0],pivot[1],pivotNXZ[1]};
glm::vec3 offsetNXZ = R2 * glm::vec3(offset[id][0],offset[id][2],1);
offset[id] = rb::Vector3{offsetNXZ[0],offset[id][1],offsetNXZ[1]};
sf::Angle alpha = sf::radians(fRot[2] - oldRot[2]); // angolo aggiunto
sf::Angle alpha1 = sf::radians(acos(sign * pivot[0]/r1)); // angolo rispetto alla posizione del pivot
sf::Angle alpha2 = alpha + alpha1;
sf::Vector2f tmpCoordsX = sf::Vector2f(r1,alpha2);
pivot = {sign * tmpCoordsX.x,pivot[1],sign * tmpCoordsX.y};
//calcolo la posizione in base alla rotazione del child
sign = offset[id][2] >= 0 ? 1 : -1;
sf::Angle beta = sf::radians(cRot[2] - oldCRot[id][2]);
sf::Angle beta1 = sf::radians(acos(sign * offset[id][0]/r2));
sf::Angle beta2 = beta + beta1;
sf::Vector2f tmpCoordsC = sf::Vector2f(r2,beta2);
offset[id] = {sign * tmpCoordsC.x,offset[id][1],sign * tmpCoordsC.y};
//ora devo muovere il child rispetto al nuovo offset
rb::Vector3 pivotPos = father->body.getPos()+father->globalPos+pivot;
rb::Vector3 cPos = childs[id]->body.getPos() + childs[id]->globalPos;
rb::Vector3 tmpChild = pivotPos + offset[id];
childs[id]->body.setPos(tmpChild - childs[id]->globalPos);
}
childs[id]->body.setPos(rb::Vector3{fPos[0]+offset[id][0]+pivot[0],fPos[1]+offset[id][1]+pivot[1],fPos[2]+offset[id][2]+pivot[2]});
oldRot = fRot; //aggiorno la rotazione per il ciclo successivo
oldCRot[id] = cRot;
// r cosA = x -> x/r = cosA
/*
Devo spostare l'offset per poter ricalcolare la posizione relativa dei child rispetto al father dopo aver eseguito la rotazione.
La rotazione va eseguita nella posizione del mondo, ovvero sulle coordinate di body
Le coordinate camera non vanno toccate, determinano solo lo spostamento rispetto alla telecamera
*/
}
void PivotJoint::traslate(unsigned int id){
+20 -35
View File
@@ -2,55 +2,40 @@
#define ZERO_INT 0.00001
//using namespace glm;
void RigidJoint::rotate(unsigned int id){
rb::Vector3_s fRot = father->body.getRot();
rb::Vector3_s fRotOld = childs[id]->body.getRot() - rotOffset[id];
rb::Vector3 cPos = childs[id]->body.getPos() + childs[id]->globalPos;
rb::Vector3 fPos = father->body.getPos();
rb::Vector3 cPos = childs[id]->body.getPos();
childs[id]->body.setRot(fRot + rotOffset[id]);
//// sposto l'origine passivamente su tutti gli assi ////
//se si muove il child devo muovere anche il padre -> devo trovare la differenza di posizione prima di ricalcolare l'offset
/*
if (cPos != oldCPos[id]);*/
float r = sqrt(pow(offset[id][0],2)+pow(offset[id][2],2)); //calcolo modulo dell'offset (per ora solo sul piano xz)
// sposto il alla distanza offset rispetto all'origine R*pos
// calcolo alpha angolo
if (r>ZERO_INT){
float alpha = float (fRot[2] - fRotOld[2]);
float cosA = glm::cos(alpha);
float sinA = glm::sin(alpha);
float sign = offset[id][2] >= 0 ? 1 : -1;
glm::mat3 R = glm::mat3(
/*cos*/ cosA, /*sin*/ sinA, 0,
/*-sin*/ -sinA , /*cos*/ cosA, 0,
0, 0, 1
);
//sposto il child all'origine rispetto al padre
sf::Angle alpha = sf::radians(fRot[2] - fRotOld[2]); // angolo aggiunto
sf::Angle alpha1 = sf::radians(acos(sign * offset[id][0]/r)); // angolo rispetto alla posizione del child
sf::Angle beta = alpha + alpha1;
glm::vec3 XZ_cPos = {offset[id][0],offset[id][2],1};
glm::vec3 resRot = R * XZ_cPos;
sf::Vector2f tmpCoordsX = sf::Vector2f(r,beta);
offset[id] = {sign * tmpCoordsX.x,offset[id][1],sign * tmpCoordsX.y};
offset[id][0] = resRot[0] ;
offset[id][2] = resRot[1] ;
//ora devo muovere il child rispetto al nuovo offset
childs[id]->body.setPos({fPos[0]-offset[id][0],offset[id][1],fPos[2] -offset[id][2]});
rb::Vector3 fPos = father->body.getPos() + father->globalPos;
rb::Vector3 tmpChild = fPos + offset[id];
childs[id]->body.setPos(tmpChild - childs[id]->globalPos);
}
else{
childs[id]->body.setPos(father->body.getPos()+father->globalPos-childs[id]->globalPos);
}
// r cosA = x -> x/r = cosA
/*
Devo spostare l'offset per poter ricalcolare la posizione relativa dei child rispetto al father dopo aver eseguito la rotazione.
La rotazione va eseguita nella posizione del mondo, ovvero sulle coordinate di body
Le coordinate camera non vanno toccate, determinano solo lo spostamento rispetto alla telecamera
*/
}
void RigidJoint::traslate(unsigned int id){
+20
View File
@@ -0,0 +1,20 @@
#include "piece_interface.hpp"
#ifndef CAVIGLIA_H
#define CAVIGLIA_H
const sf::Vector2f caviglia_Dim = {60, 200};
const sf::Color caviglia_Col = sf::Color(230,160,11,255);
class Caviglia : public PieceInterface{
public:
Caviglia(rb::Vector3 coords, _Float16 mass);
~Caviglia();
void update(sf::Clock cl) override;
sf::Shape* draw(ReferencePlane plane) override;
};
#endif
+1 -6
View File
@@ -1,17 +1,12 @@
#include <SFML/Graphics.hpp>
#include <math.h>
#include "../../rigidbody/headers/rb.hpp"
//#include "../../joints/headers/joint_interface.hpp"
#ifndef PIECE_INTERFACE_H
#define PIECE_INTERFACE_H
// costanti
const sf::Vector2f caviglia_Dim = {50, 200};
const sf::Color caviglia_Col = sf::Color::Red;
enum class ReferencePlane {
XY,
YZ,
+40
View File
@@ -0,0 +1,40 @@
#include "../headers/caviglia.hpp"
Caviglia::Caviglia(rb::Vector3 coords, _Float16 mass){
size = caviglia_Dim;
rb::Vector3 com = {size.x/2,0, size.y/2};
body = rb::rigidbody(coords, com, mass);
color = caviglia_Col;
shape = new sf::RectangleShape(size);
shape->setOrigin({size.x/2,size.y/2});
globalPos = {0,0,0};
}
Caviglia::~Caviglia(){
delete shape;
}
void Caviglia::update(sf::Clock cl){
//body.step(cl);
}
sf::Shape* Caviglia::draw(ReferencePlane plane){
shape->setFillColor(color);
rb::Vector3 tmpPos = body.getPos();
rb::Vector3_s tmpRot = body.getRot();
switch (plane)
{
case ReferencePlane::XZ:
shape->setPosition({tmpPos[0]+globalPos[0],tmpPos[2]+globalPos[2]});
shape->setRotation(sf::Angle(sf::radians(tmpRot[2])));
break;
default:
break;
}
return shape;
}
+2 -2
View File
@@ -4,10 +4,10 @@
Sensore::Sensore(rb::Vector3 coords, _Float16 mass){
size = sensore_Dim;
rb::Vector3 com = {size.x/2,0, size.y/2};
body = rb::rigidbody({0,0,0}, com, mass);
body = rb::rigidbody(coords, com, mass);
color = sensore_Col;
shape = new sf::RectangleShape(size);
globalPos = coords;
globalPos = {0,0,0};
}
Sensore::Sensore(rb::Vector3 coords, _Float16 mass, unsigned int st, unsigned int dataIntvl, std::vector<std::vector<float>> data) : Sensore(coords, mass){
+1 -1
View File
@@ -51,7 +51,7 @@ void rigidbody::setRot(const Vector3_s Nrot){
if (Nrot.size() != 3) throw "Vel vector must be 3 in lenght!";
int i = 0;
for (float axis : Nrot){
for (_Float16 axis : Nrot){
rot[i] = axis;
i++;
}