diff --git a/Jusin154_Team3D/Editor/Bin/Resources/Models/River/River.bin b/Jusin154_Team3D/Editor/Bin/Resources/Models/River/River.bin new file mode 100644 index 000000000..910f8d534 Binary files /dev/null and b/Jusin154_Team3D/Editor/Bin/Resources/Models/River/River.bin differ diff --git a/Jusin154_Team3D/Editor/Bin/Resources/Models/River/River.fbx b/Jusin154_Team3D/Editor/Bin/Resources/Models/River/River.fbx new file mode 100644 index 000000000..203e8798d --- /dev/null +++ b/Jusin154_Team3D/Editor/Bin/Resources/Models/River/River.fbx @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2762239d146687126493a9570b1f6886c3a6b7e90c49122004d1cc77442b9e95 +size 27084 diff --git a/Jusin154_Team3D/Editor/Bin/Resources/Models/River/River.xml b/Jusin154_Team3D/Editor/Bin/Resources/Models/River/River.xml new file mode 100644 index 000000000..95b6c480c --- /dev/null +++ b/Jusin154_Team3D/Editor/Bin/Resources/Models/River/River.xml @@ -0,0 +1,13 @@ + + 0 0 0 + + 0 + 0 + + + 1467551853680 + -1709.49 -178.66 -1426.87 -1404.85 -182.306 -891.669 -1654.53 -164.585 -1313.33 -1502.73 -182.458 -931.221 -1728.09 -177.634 -1206.21 -1247.76 -173.513 -900.589 -1346.12 -168.466 -821.238 -1083.48 -159.643 -1034.68 -1023.65 -151.663 -1817.78 -933.248 -153.455 -1156.85 -795.953 -150.493 -1268.32 -1263.83 -176.661 -1750.63 -1272.32 -211.583 -2046.52 -1813.04 -179.199 -1509.44 -2070.91 -229.973 -1788.75 -1151.11 -165.008 -1858.52 -1282.02 -213.198 -2179.34 -757.981 -141.083 -1792.41 -1976.86 -226.87 -2145.67 -2259.28 -362.092 -1854.41 -1542.28 -269.658 -2507.65 -1297.34 -233.87 -2309.37 -1306.91 -280.165 -2433.58 -1463.42 -650.493 -2572.28 -1320.2 -507.024 -2582.75 -1279.1 -603.238 -2693.51 -1237.69 -444.559 -2658.77 -515.187 -146.636 -1496.11 -492.596 -148.804 -1514.27 -520.375 -147.177 -1491.87 -595.25 -147.361 -1552.87 -691.998 -149.493 -1352.63 -678.322 -146.454 -1658.45 -896.851 -142.856 -1781.86 -768.304 -139.426 -1750.93 14.886 -145.99 -671.533 49.4275 -104.49 -853.169 81.8948 -174.067 -805.37 14.3467 -100.068 -889.839 -12.4353 -92.3657 -948.309 -183.984 -138.01 -1052.49 233.702 -126.705 -632.83 361.03 -121.933 -596.065 376.216 -116.443 -636.556 457.555 -126.751 -510.538 541.817 -127.596 -406.874 -345.386 -165.596 320.185 -618.702 -153.91 -175.508 -635.051 -147.675 47.6023 -456.094 -155.051 246.742 -549.771 -148.977 151.739 -711.486 -148.748 -61.9676 -783.301 -174.759 -171.097 -1245.18 -146.638 -616.945 -907.151 -187.231 -204.456 -900.892 -154.096 -920.285 -1278.99 -151.55 -719.114 -1334.71 -165.778 -807.556 -1346.12 -168.466 -821.239 -1247.76 -173.513 -900.589 -1083.48 -159.643 -1034.68 -933.248 -153.455 -1156.85 -795.953 -150.493 -1268.32 -691.998 -149.493 -1352.63 -268.295 -153.858 -1154.9 -209.562 -157.421 -1138.95 -367.302 -157.936 -1240.58 -409.34 -152.708 -1366.68 -379.754 -152.087 -1396 -494.309 -147.113 -1470.63 -520.375 -147.177 -1491.87 -515.187 -146.636 -1496.11 -492.596 -148.804 -1514.27 -1386.15 -166.243 -788.954 -1349.74 -167.248 -818.387 -1346.21 -168.474 -821.159 -2071.51 -216.711 -1767.01 -1870.14 -175.201 -1543.83 -759.274 -149.059 -52.9761 -459.12 -153.96 313.362 -456.142 -155.047 246.711 -1334.66 -165.749 -807.266 -1386.15 -166.243 -788.955 -1349.74 -167.248 -818.387 -1346.21 -168.474 -821.159 + 46 80 79 47 46 35 45 35 46 49 46 48 80 50 79 48 79 50 46 47 48 50 49 48 78 79 51 43 44 45 44 42 45 42 44 43 45 42 35 43 41 42 41 37 35 41 35 42 37 36 35 36 38 35 36 39 38 39 40 38 40 35 38 64 40 65 35 55 47 35 40 55 40 64 55 55 64 66 47 51 48 51 47 52 52 54 78 51 52 78 47 55 52 54 52 53 53 52 55 56 81 53 53 81 82 66 67 55 55 63 62 55 62 61 61 60 55 53 55 56 55 57 56 59 58 55 57 55 58 60 59 55 83 82 81 84 83 81 6 5 1 74 3 73 74 75 3 1 3 75 1 2 3 2 4 3 66 64 65 68 67 66 67 68 69 69 68 71 72 71 68 71 70 69 70 63 69 55 69 63 67 69 55 30 31 29 32 10 30 31 30 10 9 10 8 9 8 7 28 17 27 27 17 29 30 29 17 30 17 32 34 32 17 32 8 10 32 34 33 33 8 32 33 17 8 34 17 33 17 15 8 2 1 0 1 5 0 7 0 5 0 7 8 8 11 0 8 15 11 12 13 0 11 12 0 77 4 0 4 2 0 77 0 13 12 14 13 13 14 76 14 19 76 77 13 76 15 12 11 16 12 15 16 18 14 14 12 16 18 19 14 21 20 16 20 21 22 16 20 18 23 22 24 20 22 23 25 23 24 26 25 24 + 78 88 83 1 77 69 83 72 16 0 0 0 1 0 0 0 6 0 0 0 85 0 0 0 104 0 0 0 199 175 213 196 246 168 50 195 253 91 178 196 71 155 175 196 95 78 54 195 207 234 94 196 22 209 206 196 196 149 36 195 120 42 164 196 111 215 187 196 62 117 54 195 43 206 104 196 200 2 216 196 88 162 49 195 212 198 150 196 116 248 155 196 80 131 45 195 173 37 97 196 180 67 168 196 88 119 40 195 66 79 77 196 124 111 135 196 163 164 31 195 187 85 129 196 72 233 127 196 196 169 23 195 215 56 227 196 226 79 105 196 122 116 25 195 90 155 144 196 6 253 70 196 62 126 22 195 56 138 158 196 178 250 157 196 66 169 48 195 49 212 218 196 71 10 159 196 86 149 83 195 189 208 255 196 48 161 226 196 235 50 51 195 23 174 188 196 128 110 1 197 13 249 101 195 232 151 223 196 174 227 143 196 246 1 37 195 152 80 232 196 195 64 160 196 204 50 85 195 107 53 8 197 194 126 61 196 54 21 13 195 247 12 224 196 169 27 247 196 156 222 98 195 171 26 6 197 124 52 13 197 199 11 181 195 24 205 231 196 244 200 192 196 43 212 134 195 121 186 28 197 223 42 162 196 203 222 105 195 253 85 16 197 27 93 163 196 46 21 140 195 58 25 24 197 91 237 182 196 140 159 34 196 131 196 32 197 101 6 165 196 11 131 253 195 238 107 33 197 26 227 159 196 54 207 22 196 44 88 40 197 248 181 154 196 130 71 222 195 69 44 38 197 241 203 0 196 208 162 18 195 141 3 187 196 63 76 246 195 212 205 20 195 141 72 189 196 254 23 2 196 106 45 19 195 206 123 186 196 1 208 20 196 106 92 19 195 213 27 194 196 227 255 44 196 54 126 21 195 44 20 169 196 149 148 41 196 63 116 18 195 132 78 207 196 120 54 96 196 67 219 14 195 113 187 222 196 115 19 64 196 14 109 11 195 215 221 218 196 232 44 110 65 133 253 17 195 28 226 39 196 205 181 69 66 22 251 208 194 204 74 85 196 33 202 163 66 56 17 46 195 169 87 73 196 234 139 101 65 4 35 200 194 184 117 94 196 237 246 70 193 64 187 184 194 195 19 109 196 0 252 55 195 123 2 10 195 184 143 131 196 183 179 105 67 245 104 253 194 31 53 30 196 231 131 180 67 155 221 243 194 34 4 21 196 175 27 188 67 13 227 232 194 150 35 31 196 12 199 228 67 130 128 253 194 222 68 255 195 75 116 7 68 22 49 255 194 219 111 203 195 101 177 172 195 146 152 37 195 177 23 160 67 233 172 26 196 19 233 25 195 42 130 47 195 72 195 30 196 180 172 19 195 191 104 62 66 11 12 228 195 24 13 27 195 10 190 118 67 85 113 9 196 52 250 20 195 79 189 23 67 24 223 49 196 141 191 20 195 223 222 119 194 72 211 67 196 65 194 46 195 190 24 43 195 224 165 155 196 57 163 18 195 116 60 26 196 177 201 98 196 24 59 59 195 203 116 76 195 16 57 97 196 169 24 26 195 57 18 102 196 172 223 159 196 191 140 23 195 78 199 51 196 147 214 166 196 17 199 37 195 157 227 73 196 182 67 168 196 91 119 40 195 71 79 77 196 120 248 155 196 81 131 45 195 172 37 97 196 126 111 135 196 164 164 31 195 188 85 129 196 227 79 105 196 121 116 25 195 92 155 144 196 3 253 70 196 61 126 22 195 60 138 158 196 222 255 44 196 54 126 21 195 50 20 169 196 199 37 134 195 143 219 25 195 243 92 144 196 196 143 81 195 217 107 29 195 104 94 142 196 182 166 183 195 137 239 29 195 178 18 155 196 119 171 204 195 39 181 24 195 179 213 170 196 143 224 189 195 72 22 24 195 28 128 174 196 152 39 247 195 13 29 19 195 68 212 183 196 2 24 2 196 106 45 19 195 208 123 186 196 244 203 0 196 207 162 18 195 143 3 187 196 69 76 246 195 211 205 20 195 143 72 189 196 165 68 173 196 41 62 38 195 22 61 69 196 166 183 168 196 141 63 39 195 194 152 76 196 215 70 168 196 114 121 40 195 37 74 77 196 43 120 1 197 252 181 88 195 67 224 220 196 122 196 233 196 140 51 47 195 125 250 192 196 130 209 61 196 12 15 21 195 126 231 83 194 82 143 229 195 202 245 25 195 81 174 156 67 46 18 228 195 239 11 27 195 228 181 118 67 37 213 166 196 207 191 37 195 13 209 73 196 166 68 173 196 42 62 38 195 27 61 69 196 168 183 168 196 143 63 39 195 199 152 76 196 217 70 168 196 117 121 40 195 40 74 77 196 46 80 79 47 46 35 45 35 46 49 46 48 80 50 79 48 79 50 46 47 48 50 49 48 78 79 51 43 44 45 44 42 45 42 44 43 45 42 35 43 41 42 41 37 35 41 35 42 37 36 35 36 38 35 36 39 38 39 40 38 40 35 38 64 40 65 35 55 47 35 40 55 40 64 55 55 64 66 47 51 48 51 47 52 52 54 78 51 52 78 47 55 52 54 52 53 53 52 55 56 81 53 53 81 82 66 67 55 55 63 62 55 62 61 61 60 55 53 55 56 55 57 56 59 58 55 57 55 58 60 59 55 83 82 81 84 83 81 6 5 1 74 3 73 74 75 3 1 3 75 1 2 3 2 4 3 66 64 65 68 67 66 67 68 69 69 68 71 72 71 68 71 70 69 70 63 69 55 69 63 67 69 55 30 31 29 32 10 30 31 30 10 9 10 8 9 8 7 28 17 27 27 17 29 30 29 17 30 17 32 34 32 17 32 8 10 32 34 33 33 8 32 33 17 8 34 17 33 17 15 8 2 1 0 1 5 0 7 0 5 0 7 8 8 11 0 8 15 11 12 13 0 11 12 0 77 4 0 4 2 0 77 0 13 12 14 13 13 14 76 14 19 76 77 13 76 15 12 11 16 12 15 16 18 14 14 12 16 18 19 14 21 20 16 20 21 22 16 20 18 23 22 24 20 22 23 25 23 24 26 25 24 103 0 0 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 66 86 52 32 3 0 0 0 210 174 86 196 244 182 185 195 54 85 148 196 224 192 1 69 4 0 0 0 151 53 141 61 213 160 162 60 126 89 168 61 149 29 119 61 55 73 94 60 197 197 160 61 1 0 0 0 76 0 0 0 246 204 21 35 25 158 56 232 1 128 185 189 201 190 111 242 191 221 105 229 40 219 200 213 1 128 86 212 136 223 220 215 12 197 239 15 14 191 95 2 1 128 162 211 174 167 53 210 84 37 0 0 132 71 0 0 124 96 0 0 4 128 0 0 242 220 21 35 252 212 164 233 246 204 247 0 75 255 21 35 106 223 68 219 106 223 124 213 236 224 105 229 191 221 105 229 22 224 239 15 168 247 239 15 12 197 69 247 239 210 194 235 7 0 0 0 132 167 0 0 124 192 0 0 4 224 0 0 155 204 241 215 120 177 241 215 188 179 56 232 25 158 55 175 40 219 124 213 40 219 200 213 219 221 200 213 25 220 157 208 72 246 95 2 68 212 125 247 14 191 78 225 151 193 190 216 73 3 0 0 84 5 1 0 130 39 1 0 2 64 1 0 72 153 185 189 1 128 159 173 1 128 120 181 0 144 222 175 93 214 86 212 192 184 157 208 192 184 126 208 1 128 158 194 191 158 162 211 191 158 251 195 111 152 228 168 1 128 60 149 84 101 1 0 132 135 1 0 84 165 1 0 4 192 1 0 121 212 28 224 201 190 21 212 203 216 111 242 157 194 128 229 184 226 220 215 136 223 220 215 236 224 200 213 150 224 214 213 211 170 196 181 174 167 228 192 10 184 84 199 158 169 53 210 172 226 1 0 132 7 2 0 130 39 2 0 2 64 2 0 5 220 164 233 5 220 70 226 5 220 164 233 252 212 70 226 106 223 124 213 180 225 124 213 106 223 124 213 180 225 45 213 67 2 239 15 67 2 152 15 168 247 239 15 14 253 152 15 101 0 0 0 163 0 0 0 197 0 0 0 3 1 0 0 147 245 247 0 204 240 23 244 246 204 247 0 246 204 23 244 70 227 105 229 6 225 68 216 173 225 68 216 236 224 68 216 252 205 150 222 30 201 161 203 252 205 69 247 12 197 53 210 101 2 0 0 163 2 0 0 197 2 0 0 5 3 0 0 116 20 21 35 215 0 21 35 215 0 97 23 75 255 52 3 228 230 122 222 70 227 122 222 191 221 235 225 70 227 105 229 192 225 194 235 22 224 194 235 117 215 88 226 239 210 150 222 39 1 0 0 133 1 0 0 199 1 0 0 37 2 0 0 246 204 241 215 116 185 73 205 99 180 97 175 120 177 97 175 156 221 176 211 40 219 200 213 98 223 200 213 73 223 200 213 68 212 125 247 68 212 125 247 163 217 78 225 163 217 78 225 195 3 0 0 229 3 0 0 35 4 0 0 67 4 0 0 157 194 56 232 98 180 172 197 188 179 172 197 0 0 0 0 150 224 246 212 97 223 200 213 219 221 163 211 0 0 0 0 14 191 53 210 68 212 78 225 212 206 209 215 0 0 0 0 105 4 0 0 229 4 0 0 39 5 0 0 255 255 255 255 25 158 11 165 105 176 55 175 221 170 215 168 0 0 0 0 25 220 157 208 32 220 72 208 25 220 35 208 0 0 0 0 151 193 162 211 52 213 190 216 191 211 190 216 0 0 0 0 69 6 0 0 135 5 0 0 231 5 0 0 255 255 255 255 38 159 217 185 38 159 185 189 38 159 185 189 72 153 44 174 32 220 10 210 216 220 86 212 216 220 86 212 93 214 35 205 49 188 162 211 158 169 132 204 174 167 0 185 191 158 0 185 167 9 0 0 3 10 0 0 37 10 0 0 101 10 0 0 12 150 224 148 12 150 81 145 173 138 159 173 1 128 157 138 216 220 157 208 189 220 143 205 191 210 104 204 192 184 143 205 163 182 251 195 163 182 0 185 191 158 229 180 224 167 229 180 165 10 0 0 227 10 0 0 3 11 0 0 39 11 0 0 235 183 120 181 94 183 120 181 173 138 159 173 1 128 1 128 93 214 126 208 12 214 126 208 191 210 21 195 192 184 175 190 191 158 228 168 111 152 134 163 111 152 255 166 9 154 255 166 131 11 0 0 163 11 0 0 197 11 0 0 3 12 0 0 159 168 255 172 0 144 255 172 159 168 98 171 23 173 222 175 223 200 158 194 240 202 158 194 1 128 93 178 1 128 1 128 213 136 143 147 213 136 60 149 68 133 232 134 1 128 1 128 37 12 0 0 99 12 0 0 133 12 0 0 197 12 0 0 14 213 28 224 14 213 165 222 14 213 118 217 121 212 21 212 184 226 98 215 1 227 98 215 1 227 98 215 46 227 220 215 211 170 142 181 211 170 196 181 211 170 187 178 211 170 122 173 67 8 0 0 101 8 0 0 163 8 0 0 195 8 0 0 1 198 21 212 1 198 21 212 1 198 237 206 201 190 237 206 40 226 214 213 40 226 220 215 40 226 220 215 136 223 98 215 158 169 228 192 158 169 122 173 158 169 224 168 174 167 208 166 227 8 0 0 5 9 0 0 69 9 0 0 131 9 0 0 207 232 111 242 208 226 106 231 203 216 255 223 0 0 0 0 236 224 55 212 243 225 200 213 149 226 200 213 0 0 0 0 169 189 84 199 10 184 255 187 231 184 178 188 0 0 0 0 133 6 0 0 199 6 0 0 37 7 0 0 255 255 255 255 157 194 119 204 246 204 128 229 232 210 79 222 0 0 0 0 150 224 172 212 173 225 165 213 99 226 214 213 0 0 0 0 158 169 132 204 29 186 53 210 48 177 228 192 0 0 0 0 5 8 0 0 101 7 0 0 167 7 0 0 255 255 255 255 44 88 40 58 124 52 13 197 140 159 34 196 44 88 40 197 75 116 7 68 64 187 184 194 177 23 160 67 104 0 0 0 40 0 32 8 24 56 0 40 56 32 16 0 8 24 40 40 24 48 24 40 16 24 16 16 40 16 24 8 16 32 8 48 8 40 32 0 16 16 8 32 16 8 32 8 40 56 40 56 40 32 8 24 40 32 0 32 40 40 8 0 0 16 0 32 8 32 56 40 32 8 40 0 56 40 56 56 56 40 0 32 32 32 24 8 0 40 24 40 32 16 48 40 32 32 24 0 40 40 56 48 16 40 8 40 + + diff --git a/Jusin154_Team3D/Editor/Default/Editor.cpp b/Jusin154_Team3D/Editor/Default/Editor.cpp index a75795a2a..de7b2d51e 100644 --- a/Jusin154_Team3D/Editor/Default/Editor.cpp +++ b/Jusin154_Team3D/Editor/Default/Editor.cpp @@ -24,6 +24,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, { #ifdef _DEBUG _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); + //_CrtSetBreakAlloc(1157440); #endif UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); diff --git a/Jusin154_Team3D/Editor/Private/Dummy_PhysXMesh.cpp b/Jusin154_Team3D/Editor/Private/Dummy_PhysXMesh.cpp index 81f406d7d..e04209a61 100644 --- a/Jusin154_Team3D/Editor/Private/Dummy_PhysXMesh.cpp +++ b/Jusin154_Team3D/Editor/Private/Dummy_PhysXMesh.cpp @@ -89,17 +89,16 @@ HRESULT CDummy_PhysXMesh::Ready_Components(void* pArg) m_pTransformCom->Rotation(pBox->vRotRPY.x, pBox->vRotRPY.y, pBox->vRotRPY.z); + CModel* pModel = (CModel*)m_pGameInstance->Find_Asset_Prototype(g_iStaticLevel, TEXT("Prototype_Component_River_Col_Model")); + _uint iNumMesh = pModel->Get_NumMeshes(); + + CRigidBody::RIGIDBODY_DESC Desc{}; + Desc.eType = ACTOR::TRIANGLEMESH; + for (_uint i = 0; i< iNumMesh; ++i) { // RIGID_BODY - CRigidBody::RIGIDBODY_DESC Desc{}; - Desc.tRigidStaticDesc.pMeshKey = TEXT("PhysX_Plane"); + Desc.tRigidStaticDesc.szMeshName = pModel->Get_MeshName(i); - if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("PHYSX_Static_Object"), (CComponent**)&m_pRigidBody, &Desc))) { - return E_FAIL; - } - - m_pActor = m_pGameInstance->Add_StaticActor(*m_pRigidBody); - if (nullptr == m_pActor) { - assert(false); + if (FAILED(Add_Asset_Component(g_iStaticLevel, CMyTools::ToWstring(pModel->Get_MeshName(i)).c_str(), nullptr, &Desc))) { return E_FAIL; } } @@ -155,7 +154,6 @@ void CDummy_PhysXMesh::Free() { __super::Free(); - SAFE_RELEASE(m_pRigidBody); //SAFE_RELEASE(m_pModelCom); //SAFE_RELEASE(m_pShaderCom); } diff --git a/Jusin154_Team3D/Editor/Private/Dummy_PhysXPlayable.cpp b/Jusin154_Team3D/Editor/Private/Dummy_PhysXPlayable.cpp index 079e900c1..ceca6eb28 100644 --- a/Jusin154_Team3D/Editor/Private/Dummy_PhysXPlayable.cpp +++ b/Jusin154_Team3D/Editor/Private/Dummy_PhysXPlayable.cpp @@ -130,6 +130,8 @@ CGameObject* CDummy_PhysXPlayable::Clone(void* pArg, CGameObject* pOwner) void CDummy_PhysXPlayable::Free() { __super::Free(); + + SAFE_RELEASE(m_pCharacter_Controller); } void CDummy_PhysXPlayable::Describe_Entity() diff --git a/Jusin154_Team3D/Editor/Private/Level_PhysXLab.cpp b/Jusin154_Team3D/Editor/Private/Level_PhysXLab.cpp index 17f7a08d5..072ec1188 100644 --- a/Jusin154_Team3D/Editor/Private/Level_PhysXLab.cpp +++ b/Jusin154_Team3D/Editor/Private/Level_PhysXLab.cpp @@ -7,6 +7,7 @@ #include "Terrain.h" #include "Dummy_PhysXBox.h" #include "Dummy_PhysXPlayable.h" +#include "Dummy_PhysXMesh.h" CLevel_PhysXLab::CLevel_PhysXLab(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, LEVEL eLevelID) : CLevel{ pDevice, pContext, ENUM_CLASS(eLevelID) } @@ -99,13 +100,23 @@ HRESULT CLevel_PhysXLab::Ready_Layer_PhysXObjects(const _wstring& strLayerTag) } } - CDummy_PhysXPlayable::BOXSTARTPOS_DESC Desc{}; - Desc.vPos = { 0.f, 10.f, 0.f }; - Desc.vRotRPY = { 0.f, 0.f, 0.f }; - if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, LAYER_PLAYER, &Desc))) { - return E_FAIL; + { + CDummy_PhysXPlayable::BOXSTARTPOS_DESC Desc{}; + Desc.vPos = { 0.f, 10.f, 0.f }; + Desc.vRotRPY = { 0.f, 0.f, 0.f }; + if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, LAYER_PLAYER, &Desc))) { + return E_FAIL; + } } + { + CDummy_PhysXMesh::BOXSTARTPOS_DESC Desc{}; + Desc.vPos = { 0.f, 10.f, 0.f }; + Desc.vRotRPY = { 0.f, 0.f, 0.f }; + if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, LAYER_CHUNK, &Desc))) { + return E_FAIL; + } + } return S_OK; } diff --git a/Jusin154_Team3D/Editor/Private/Loader.cpp b/Jusin154_Team3D/Editor/Private/Loader.cpp index 65ac29432..79fd65e57 100644 --- a/Jusin154_Team3D/Editor/Private/Loader.cpp +++ b/Jusin154_Team3D/Editor/Private/Loader.cpp @@ -491,13 +491,26 @@ HRESULT CLoader::Loading_For_PhysXLevel() m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("PHYSX_DYNAMIC_BOX"), CRigidBody::Create(m_pDevice, m_pContext, Desc)); } + + if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Prototype_Component_River_Col_Model"), + //CModel::Create(m_pDevice, m_pContext, MODEL::ENVIROMENT, "../Bin/Resources/Models/River/River.fbx", XMMatrixScaling(0.001f, 0.001f, 0.001f) * XMMatrixIdentity())))){ + CModel::Create(m_pDevice, m_pContext, MODEL::ENVIROMENT, "../Bin/Resources/Models/River/River.bin", XMMatrixScaling(0.001f, 0.001f, 0.001f) * XMMatrixIdentity())))){ + return E_FAIL; + } + { + CModel* pModel = (CModel*)m_pGameInstance->Find_Asset_Prototype(g_iStaticLevel, TEXT("Prototype_Component_River_Col_Model")); + _uint iNumMesh = pModel->Get_NumMeshes(); + CRigidBody::RIGIDBODY_PROTOTYPEDESC Desc{}; - Desc.tRigidStaticDesc.pMeshKey = TEXT("PhysX_Plane"); - Desc.tRigidStaticDesc.vMatInfo = _float3(0.5f, 0.5f, 0.6f); - Desc.tRigidStaticDesc.pMesh = ; - - m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("PHYSX_DYNAMIC_BOX"), CRigidBody::Create(m_pDevice, m_pContext, Desc)); + for (_uint i = 0; i < iNumMesh; ++i) { + Desc.eType = ACTOR::TRIANGLEMESH; + Desc.tRigidStaticDesc.szMeshName = pModel->Get_MeshName(i); + Desc.tRigidStaticDesc.vMatInfo = _float3(0.5f, 0.5f, 0.6f); + if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, CMyTools::ToWstring(Desc.tRigidStaticDesc.szMeshName).c_str(), CRigidBody::Create(m_pDevice, m_pContext, Desc)))) { + return E_FAIL; + } + } } { m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("PHYSX_CCT_CAPSULE"), CCharacter_Controller::Create(m_pDevice, m_pContext)); diff --git a/Jusin154_Team3D/Editor/Public/Dummy_PhysXMesh.h b/Jusin154_Team3D/Editor/Public/Dummy_PhysXMesh.h index a4feef353..e5fb2d5ea 100644 --- a/Jusin154_Team3D/Editor/Public/Dummy_PhysXMesh.h +++ b/Jusin154_Team3D/Editor/Public/Dummy_PhysXMesh.h @@ -31,8 +31,6 @@ class CDummy_PhysXMesh final : public CGameObject virtual HRESULT Render() override; private: - CRigidBody* m_pRigidBody = { nullptr }; - const PSX::PxRigidStatic* m_pActor = { nullptr }; private: virtual HRESULT Initialize_Prototype() override; diff --git a/Jusin154_Team3D/Engine/Private/Character_Controller.cpp b/Jusin154_Team3D/Engine/Private/Character_Controller.cpp index 0eec5a5d3..6cc49ee53 100644 --- a/Jusin154_Team3D/Engine/Private/Character_Controller.cpp +++ b/Jusin154_Team3D/Engine/Private/Character_Controller.cpp @@ -204,10 +204,6 @@ CComponent* CCharacter_Controller::Clone(void* pArg, class CGameObject* pOwner) void CCharacter_Controller::Free() { __super::Free(); - - if (nullptr != m_pController) { - m_pController->release(); - } } void CCharacter_Controller::Describe_Entity() diff --git a/Jusin154_Team3D/Engine/Private/GameInstance.cpp b/Jusin154_Team3D/Engine/Private/GameInstance.cpp index 4df187117..963ed2cb7 100644 --- a/Jusin154_Team3D/Engine/Private/GameInstance.cpp +++ b/Jusin154_Team3D/Engine/Private/GameInstance.cpp @@ -541,10 +541,12 @@ PSX::PxMaterial* CGameInstance::Get_Material(_float3& vMatInfo) { return m_pPhysX_Manager->Get_Material(vMatInfo); } -HRESULT CGameInstance::Create_TriangleMesh(const _wstring& wstrMeshKey, CMesh* pMesh) + +void CGameInstance::RegistTriMesh(const _char* pName, PSX::PxTriangleMesh* pPxTriMesh) { - return m_pPhysX_Manager->Create_TriangleMesh(wstrMeshKey, pMesh); + return m_pPhysX_Manager->RegistTriMesh(pName, pPxTriMesh); } + PSX::PxShape* CGameInstance::Create_Shape(ACTOR eType, _float3& vhalfGeometryInfo, PSX::PxMaterial& pxMaterial, _bool bExclusive, PSX::PxShapeFlags ePxShapeFlag) { return m_pPhysX_Manager->Create_Shape(eType, vhalfGeometryInfo, pxMaterial, bExclusive, ePxShapeFlag); @@ -573,6 +575,18 @@ void CGameInstance::ReleaseController(_uint iControllerIndex) { m_pPhysX_Manager->ReleaseController(iControllerIndex); } +HRESULT CGameInstance::ConvertToTriMeshes(vector& Meshes, vector& pxTriMeshes) +{ + return m_pPhysX_Manager->ConvertToTriMeshes(Meshes, pxTriMeshes); +} +_bool CGameInstance::SaveTriMeshes(const _char* pPath, vector& TriMeshes) +{ + return m_pPhysX_Manager->SaveTriMeshes(pPath, TriMeshes); +} +_bool CGameInstance::LoadTriMeshes(const _char* pPath, vector& TriMeshes) +{ + return m_pPhysX_Manager->LoadTriMeshes(pPath, TriMeshes); +} #pragma endregion bool CGameInstance::Key_Pressing(int _iKey) diff --git a/Jusin154_Team3D/Engine/Private/Mesh.cpp b/Jusin154_Team3D/Engine/Private/Mesh.cpp index e3b95e636..86001e55a 100644 --- a/Jusin154_Team3D/Engine/Private/Mesh.cpp +++ b/Jusin154_Team3D/Engine/Private/Mesh.cpp @@ -90,14 +90,16 @@ HRESULT CMesh::Initialize_Prototype(MODEL eType, vector& Bones, co _uint* pIndices = new _uint[m_iNumIndices]; ZeroMemory(pIndices, sizeof(_uint) * m_iNumIndices); + m_pIndices = new _uint[m_iNumIndices]; + ZeroMemory(m_pIndices, sizeof(_uint) * m_iNumIndices); + _uint iNumIndices = {}; for (size_t i = 0; i < pAIMesh->mNumFaces; i++) { - - pIndices[iNumIndices++] = pAIMesh->mFaces[i].mIndices[0]; - pIndices[iNumIndices++] = pAIMesh->mFaces[i].mIndices[1]; - pIndices[iNumIndices++] = pAIMesh->mFaces[i].mIndices[2]; + pIndices[iNumIndices++] = m_pIndices[iNumIndices] = pAIMesh->mFaces[i].mIndices[0]; + pIndices[iNumIndices++] = m_pIndices[iNumIndices] = pAIMesh->mFaces[i].mIndices[1]; + pIndices[iNumIndices++] = m_pIndices[iNumIndices] = pAIMesh->mFaces[i].mIndices[2]; } @@ -352,7 +354,7 @@ HRESULT CMesh::Ready_VertexBuffer_For_Anim(HANDLE hFile, DWORD& dwByte) return S_OK; } -HRESULT CMesh::Ready_VertexBuffer_For_NonAnim(SaveMesh* _SaveMesh, _fmatrix PreTransformMatrix) +HRESULT CMesh::Ready_VertexBuffer_For_NonAnim(SaveMesh* SaveMesh, _fmatrix PreTransformMatrix) { m_iVertexStride = sizeof(VTXMESH); D3D11_BUFFER_DESC VBDesc{}; @@ -371,23 +373,23 @@ HRESULT CMesh::Ready_VertexBuffer_For_NonAnim(SaveMesh* _SaveMesh, _fmatrix PreT for (_uint i = 0; i < m_iNumVertices; ++i) { - memcpy(&pVertices[i].vPosition, &_SaveMesh->Vertices[i].Pos, sizeof(_float3)); + memcpy(&pVertices[i].vPosition, &SaveMesh->Vertices[i].Pos, sizeof(_float3)); XMStoreFloat3(&pVertices[i].vPosition, XMVector3TransformCoord(XMLoadFloat3(&pVertices[i].vPosition), PreTransformMatrix)); - memcpy(&pVertices[i].vNormal, &_SaveMesh->Vertices[i].Normal, sizeof(_float3)); + memcpy(&pVertices[i].vNormal, &SaveMesh->Vertices[i].Normal, sizeof(_float3)); XMStoreFloat3(&pVertices[i].vNormal, XMVector3Normalize(XMVector3TransformNormal(XMLoadFloat3(&pVertices[i].vNormal), PreTransformMatrix))); - memcpy(&pVertices[i].vTangent, &_SaveMesh->Vertices[i].Tan, sizeof(_float3)); + memcpy(&pVertices[i].vTangent, &SaveMesh->Vertices[i].Tan, sizeof(_float3)); XMStoreFloat3(&pVertices[i].vTangent, XMVector3Normalize(XMVector3TransformNormal(XMLoadFloat3(&pVertices[i].vTangent), PreTransformMatrix))); - memcpy(&pVertices[i].vBinormal, &_SaveMesh->Vertices[i].BiNoraml, sizeof(_float3)); + memcpy(&pVertices[i].vBinormal, &SaveMesh->Vertices[i].BiNoraml, sizeof(_float3)); XMStoreFloat3(&pVertices[i].vBinormal, XMVector3Normalize(XMVector3TransformNormal(XMLoadFloat3(&pVertices[i].vBinormal), PreTransformMatrix))); - pVertices[i].vTexcoord = _SaveMesh->Vertices[i].UV; + pVertices[i].vTexcoord = SaveMesh->Vertices[i].UV; } D3D11_SUBRESOURCE_DATA InitialVBData{}; @@ -420,6 +422,7 @@ HRESULT CMesh::Ready_VertexBuffer_For_Anim(const CModel* pModel, SaveMesh* _Save for (_uint i = 0; i < m_iNumVertices; ++i) { + memcpy(&m_pVertexPositions[i], &_SaveMesh->Vertices[i].Pos, sizeof(_float3)); memcpy(&pVertices[i].vPosition, &_SaveMesh->Vertices[i].Pos, sizeof(_float3)); if (_SaveMesh->Vertices[i].bHasNormal) memcpy(&pVertices[i].vNormal, &_SaveMesh->Vertices[i].Normal, sizeof(_float3)); @@ -604,26 +607,40 @@ HRESULT CMesh::SaveAsBinary(HANDLE hFile, DWORD& dwByte) return S_OK; } -PSX::PxTriangleMesh* CMesh::ConvertToPxMesh(const PSX::PxCookingParams* pParam) +PSX::PxTriangleMesh* CMesh::ConvertToPxMesh(const PSX::PxCookingParams* pParam, PSX::PxPhysics* pPhysX) { - PSX::PxTriangleMeshDesc Desc; + PSX::PxTriangleMeshDesc tMeshDesc; vector Vertices; vector Triangles; { - Desc.points.count = m_iNumVertices; - Desc.points.stride = sizeof(PSX::PxVec3); + tMeshDesc.points.count = m_iNumVertices; + tMeshDesc.points.stride = sizeof(PSX::PxVec3); Vertices.resize(m_iNumVertices); memcpy_s(Vertices.data(), sizeof(PSX::PxVec3) * m_iNumVertices, m_pVertexPositions, sizeof(_float3) * m_iNumVertices); - Desc.points.data = Vertices.data(); + tMeshDesc.points.data = Vertices.data(); } { - Desc.triangles.count = m_iNumIndices / 3; - Desc.triangles.stride = sizeof(PSX::PxU32) * 3; + tMeshDesc.triangles.count = m_iNumIndices / 3; + tMeshDesc.triangles.stride = sizeof(PSX::PxU32) * 3; Triangles.resize(m_iNumIndices); memcpy_s(Triangles.data(), sizeof(PSX::PxU32) * m_iNumIndices, m_pIndices, sizeof(PSX::PxU32) * m_iNumIndices); - Desc.triangles.data = Triangles.data(); + tMeshDesc.triangles.data = Triangles.data(); } - PSX::PxTriangleMesh* pTriangleMesh = PxCreateTriangleMesh(*pParam, Desc); + PSX::PxDefaultMemoryOutputStream streamWriteBuffer = {}; + PSX::PxTriangleMeshCookingResult::Enum eCookResult = {}; + const _bool bCooked = PxCookTriangleMesh(*pParam, tMeshDesc, streamWriteBuffer, &eCookResult); + if (false == bCooked) { + assert(false); + return nullptr; + } + + PSX::PxDefaultMemoryInputData readBuff(streamWriteBuffer.getData(), streamWriteBuffer.getSize()); + PSX::PxTriangleMesh* pTriangleMesh = pPhysX->createTriangleMesh(readBuff); + if (nullptr == pTriangleMesh) { + assert(false); + return nullptr; + } + return pTriangleMesh; } @@ -647,6 +664,7 @@ HRESULT CMesh::Ready_VertexBuffer_For_NonAnim(const aiMesh* pAIMesh, _fmatrix Pr for (_uint i = 0; i < m_iNumVertices; ++i) { memcpy(&pVertices[i].vPosition, &pAIMesh->mVertices[i], sizeof(_float3)); + memcpy(&m_pVertexPositions[i], &pAIMesh->mVertices[i], sizeof(_float3)); XMStoreFloat3(&pVertices[i].vPosition, XMVector3TransformCoord(XMLoadFloat3(&pVertices[i].vPosition), PreTransformMatrix)); memcpy(&pVertices[i].vNormal, &pAIMesh->mNormals[i], sizeof(_float3)); XMStoreFloat3(&pVertices[i].vNormal, XMVector3Normalize(XMVector3TransformNormal(XMLoadFloat3(&pVertices[i].vNormal), PreTransformMatrix))); @@ -688,6 +706,7 @@ HRESULT CMesh::Ready_VertexBuffer_For_Anim(vector& Bones, const ai for (_uint i = 0; i < m_iNumVertices; ++i) { memcpy(&pVertices[i].vPosition, &pAIMesh->mVertices[i], sizeof(_float3)); + memcpy(&m_pVertexPositions[i], &pAIMesh->mVertices[i], sizeof(_float3)); memcpy(&pVertices[i].vNormal, &pAIMesh->mNormals[i], sizeof(_float3)); memcpy(&pVertices[i].vTangent, &pAIMesh->mTangents[i], sizeof(_float3)); memcpy(&pVertices[i].vBinormal, &pAIMesh->mBitangents[i], sizeof(_float3)); diff --git a/Jusin154_Team3D/Engine/Private/Model.cpp b/Jusin154_Team3D/Engine/Private/Model.cpp index e059cff21..0cb830ce0 100644 --- a/Jusin154_Team3D/Engine/Private/Model.cpp +++ b/Jusin154_Team3D/Engine/Private/Model.cpp @@ -262,6 +262,11 @@ const _float4x4* CModel::Get_BoneMatrixPtr(const _char* pBoneName) const return (*iter)->Get_CombinedTransformationMatrixPtr(); } +const _char* CModel::Get_MeshName(_uint iIndex) +{ + return m_Meshes[iIndex]->Get_Name(); +} + _matrix CModel::Get_BoneMatrix(_uint iBoneIndex) { @@ -340,6 +345,17 @@ HRESULT CModel::Ready_Meshes(MODEL eType, const aiScene* pAIScene, _fmatrix& Pre return S_OK; } +HRESULT CModel::Ready_PhysXMeshes(MODEL eType) +{ + m_iNumPhysXMeshes = m_iNumMeshes; + + m_TriMeshes.reserve(m_iNumMeshes); + + m_pGameInstance->ConvertToTriMeshes(m_Meshes, m_TriMeshes); + + return S_OK; +} + HRESULT CModel::Ready_Materials(const aiScene* pAIScene, const _char* pModelFilePath) { m_iNumMaterials = pAIScene->mNumMaterials; @@ -794,6 +810,9 @@ HRESULT CModel::Assimp_Model_Load(const _char* pModelFilePath, MODEL eType, _fma if (FAILED(Ready_Materials_FromFile(m_pAIScene, pModelFilePath))) { return E_FAIL; } + if (FAILED(Ready_PhysXMeshes(eType))) { + return E_FAIL; + } } else { @@ -836,7 +855,12 @@ HRESULT CModel::Initialize_Prototype(MODEL eType, const _char* pModelFilePath, _ if (strcmp(".bin", szEXT) == 0) { + _char Temp[256]; + strcpy_s(Temp, szDir); + strcat_s(Temp, szName); + strcat_s(Temp, ".bin"); LoadData(pModelFilePath); + m_pGameInstance->LoadTriMeshes(pModelFilePath, m_TriMeshes); } else if (strcmp(".fbx", szEXT) == 0) { @@ -846,10 +870,15 @@ HRESULT CModel::Initialize_Prototype(MODEL eType, const _char* pModelFilePath, _ strcat_s(Temp, ".bin"); Assimp_Model_Load(pModelFilePath, eType, PreTransformMatrix, 0); SaveAssimpModel(Temp); + m_pGameInstance->SaveTriMeshes(pModelFilePath, m_TriMeshes); + for (_uint i = 0; i < m_iNumMeshes; ++i) { + m_pGameInstance->RegistTriMesh(m_Meshes[i]->Get_Name(), m_TriMeshes[i]); + } return S_OK; } m_pSaveModel = m_pGameInstance->Load_SaveModel(pModelFilePath); + m_eType = eType; XMStoreFloat4x4(&m_PreTransformMatrix, PreTransformMatrix); @@ -868,6 +897,9 @@ HRESULT CModel::Initialize_Prototype(MODEL eType, const _char* pModelFilePath, _ return E_FAIL; } + for (_uint i = 0; i < m_iNumMeshes; ++i) { + m_pGameInstance->RegistTriMesh(m_Meshes[i]->Get_Name(), m_TriMeshes[i]); + } return S_OK; diff --git a/Jusin154_Team3D/Engine/Private/PhysX_Manager.cpp b/Jusin154_Team3D/Engine/Private/PhysX_Manager.cpp index 81a790016..f1072ddcd 100644 --- a/Jusin154_Team3D/Engine/Private/PhysX_Manager.cpp +++ b/Jusin154_Team3D/Engine/Private/PhysX_Manager.cpp @@ -79,7 +79,6 @@ const PSX::PxRigidStatic* CPhysX_Manager::Add_StaticActor(CRigidBody& RigidBody) pPxMeshGeometry = iter->second; } - PSX::PxRigidStatic* pActor = m_pPhysics->createRigidStatic(pxWorldMatrix); PSX::PxShape* pShape = PSX::PxRigidActorExt::createExclusiveShape(*pActor, *pPxMeshGeometry, *RigidBody.Get_PxMaterial()); @@ -122,19 +121,100 @@ PSX::PxShape* CPhysX_Manager::Create_Shape(ACTOR eType, _float3& vhalfGeometryIn return pShape; } -HRESULT CPhysX_Manager::Create_TriangleMesh(const _wstring& wstrMeshKey, CMesh* pMesh) +void CPhysX_Manager::RegistTriMesh(const _char* pName, PSX::PxTriangleMesh* pPxTriMesh) { + m_TriangleMeshes.emplace(CMyTools::ToWstring(pName), pPxTriMesh); + + PSX::PxTriangleMeshGeometry* pGeometry = new PSX::PxTriangleMeshGeometry(pPxTriMesh); + pGeometry->meshFlags |= PSX::PxMeshGeometryFlag::eDOUBLE_SIDED; + m_TriangleMeshGeometry.emplace(CMyTools::ToWstring(pName), pGeometry); +} + +HRESULT CPhysX_Manager::ConvertToTriMeshes(vector& Meshes, vector& pxTriMeshes) { - - PSX::PxTriangleMesh* pTriangleMesh = pMesh->ConvertToPxMesh(m_pCookingParam); - if (nullptr != pTriangleMesh) { - m_TriangleMeshes.emplace(wstrMeshKey, pTriangleMesh); - - PSX::PxTriangleMeshGeometry* pGeometry = new PSX::PxTriangleMeshGeometry(pTriangleMesh); - pGeometry->meshFlags |= PSX::PxMeshGeometryFlag::eDOUBLE_SIDED; - m_TriangleMeshGeometry.emplace(wstrMeshKey, pGeometry); - return S_OK; + for (size_t i = 0; i < Meshes.size(); ++i) + { + PSX::PxTriangleMesh* pTriangleMesh = Meshes[i]->ConvertToPxMesh(m_pCookingParam, m_pPhysics); + if (nullptr == pTriangleMesh) { + return E_FAIL; + } + pxTriMeshes.push_back(pTriangleMesh); } - return E_FAIL; + pxTriMeshes.shrink_to_fit(); + + return S_OK; +} + +_bool CPhysX_Manager::SaveTriMeshes(const _char* pPath, vector& TriMeshes) +{ + filesystem::path pathPhysX = pPath; + pathPhysX.replace_extension(".xml"); + if (TriMeshes.empty()){ + return false; + } + + filesystem::create_directories(pathPhysX.parent_path()); + + + PSX::PxSerializationRegistry* pSerializationRegistry = PSX::PxSerialization::createSerializationRegistry(*m_pPhysics); + PSX::PxCollection* pCollections = PxCreateCollection(); + if (nullptr == pCollections) { + pSerializationRegistry->release(); + assert(pCollections); + return false; + } + + for (PSX::PxTriangleMesh* pTriMesh : TriMeshes) { + pCollections->add(*pTriMesh); + } + + PSX::PxSerialization::complete(*pCollections, *pSerializationRegistry); + PSX::PxDefaultFileOutputStream out(pathPhysX.string().c_str()); + PSX::PxCollection* extRefs = PxCreateCollection(); + const _bool ok = PSX::PxSerialization::serializeCollectionToXml(out, *pCollections, *pSerializationRegistry, m_pCookingParam, extRefs); + //const _bool ok = PSX::PxSerialization::serializeCollectionToBinary(out, *pCollections, *pSerializationRegistry, extRefs); + + extRefs->release(); + pCollections->release(); + pSerializationRegistry->release(); + assert(ok); + return ok; +} + +_bool CPhysX_Manager::LoadTriMeshes(const _char* pPath, vector& TriMeshes) +{ + filesystem::path pathPhysX = pPath; + pathPhysX.replace_extension(".xml"); + + PSX::PxSerializationRegistry* pSerializationRegistry = PSX::PxSerialization::createSerializationRegistry(*m_pPhysics); + + PSX::PxDefaultFileInputData InputData(pathPhysX.string().c_str()); + PSX::PxCollection* extRefs = PxCreateCollection(); + + //PSX::PxCollection* pCollections = PSX::PxSerialization::createCollectionFromBinary(&InputData, *pSerializationRegistry, extRefs); + PSX::PxCollection* pCollections = PSX::PxSerialization::createCollectionFromXml(InputData, *m_pCookingParam, *pSerializationRegistry, extRefs); + if (nullptr == pCollections) { + extRefs->release(); + pSerializationRegistry->release(); + assert(pCollections); + return false; + } + + const PSX::PxU32 iNumTriMeshes = pCollections->getNbObjects(); + TriMeshes.reserve(iNumTriMeshes); + for (PSX::PxU32 i = 0; i < iNumTriMeshes; ++i) { + PSX::PxBase& pObject = pCollections->getObject(i); + + if (pObject.getConcreteType() == PSX::PxConcreteType::eTRIANGLE_MESH_BVH34) { + PSX::PxTriangleMesh* pTriMesh = static_cast(&pObject); + pTriMesh->acquireReference(); + TriMeshes.push_back(pTriMesh); + } + } + + extRefs->release(); + pCollections->release(); + pSerializationRegistry->release(); + return true; } PSX::PxTriangleMesh* CPhysX_Manager::Find_TriangleMesh(const _wstring& wstrMeshKey) @@ -314,27 +394,27 @@ HRESULT CPhysX_Manager::Initialize() #ifdef 기무리 physx::PxMaterial* pMaterial = m_pPhysics->createMaterial(0.5f, 0.5f, 0.6f); - physx::PxRigidStatic* pGroundPlane = PxCreatePlane(*m_pPhysics, physx::PxPlane(0, 1, 0, 0), *pMaterial); - m_pScene->addActor(*pGroundPlane); + //physx::PxRigidStatic* pGroundPlane = PxCreatePlane(*m_pPhysics, physx::PxPlane(0, 1, 0, 0), *pMaterial); + //m_pScene->addActor(*pGroundPlane); - { - float halfExtent = .5f; - physx::PxShape* shape = m_pPhysics->createShape(physx::PxSphereGeometry(halfExtent), *pMaterial); - physx::PxU32 size = 30; - physx::PxTransform pxTransform(physx::PxVec3(0)); + //{ + // float halfExtent = .5f; + // physx::PxShape* shape = m_pPhysics->createShape(physx::PxSphereGeometry(halfExtent), *pMaterial); + // physx::PxU32 size = 30; + // physx::PxTransform pxTransform(physx::PxVec3(0)); - for (physx::PxU32 i = 0; i < size; i++) { - for (physx::PxU32 j = 0; j < size - i; j++) { - physx::PxTransform localTm(physx::PxVec3(physx::PxReal(j * 2) - physx::PxReal(size - i) + 100, physx::PxReal(i * 2 + 1), 0) * halfExtent); - physx::PxRigidDynamic* body = m_pPhysics->createRigidDynamic(pxTransform.transform(localTm)); - body->attachShape(*shape); - physx::PxRigidBodyExt::updateMassAndInertia(*body, 10.0f); - m_pScene->addActor(*body); - } - } - } + // for (physx::PxU32 i = 0; i < size; i++) { + // for (physx::PxU32 j = 0; j < size - i; j++) { + // physx::PxTransform localTm(physx::PxVec3(physx::PxReal(j * 2) - physx::PxReal(size - i) + 100, physx::PxReal(i * 2 + 1), 0) * halfExtent); + // physx::PxRigidDynamic* body = m_pPhysics->createRigidDynamic(pxTransform.transform(localTm)); + // body->attachShape(*shape); + // physx::PxRigidBodyExt::updateMassAndInertia(*body, 10.0f); + // m_pScene->addActor(*body); + // } + // } + //} #endif // 기무리 - + pMaterial->release(); return S_OK; @@ -386,6 +466,10 @@ void CPhysX_Manager::Free() if (nullptr != m_pCookingParam) { Safe_Delete(m_pCookingParam); } + if (nullptr != m_pCCTManager) { + m_pCCTManager->release(); + m_pCCTManager = nullptr; + } if (nullptr != m_pScene) { m_pScene->release(); m_pScene = nullptr; @@ -400,6 +484,7 @@ void CPhysX_Manager::Free() } if (nullptr != m_pPvd) { + m_pPvd->disconnect(); m_pPvd->release(); m_pPvd = nullptr; } diff --git a/Jusin154_Team3D/Engine/Private/RigidBody.cpp b/Jusin154_Team3D/Engine/Private/RigidBody.cpp index 2ac92547e..900beff26 100644 --- a/Jusin154_Team3D/Engine/Private/RigidBody.cpp +++ b/Jusin154_Team3D/Engine/Private/RigidBody.cpp @@ -14,7 +14,7 @@ CRigidBody::CRigidBody(const CRigidBody& rhs): m_eActorType(rhs.m_eActorType), m_vhalfGeometryInfo(rhs.m_vhalfGeometryInfo), m_pShape(rhs.m_pShape), - m_pMeshKey(rhs.m_pMeshKey), + m_wstrMeshKey(rhs.m_wstrMeshKey), m_bExclusive(rhs.m_bExclusive), m_bKinematic(rhs.m_bKinematic) { @@ -44,9 +44,8 @@ HRESULT CRigidBody::Initialize_Prototype(RIGIDBODY_PROTOTYPEDESC& Desc) break; case ACTOR::TRIANGLEMESH: { - m_pGameInstance->Create_TriangleMesh(Desc.tRigidStaticDesc.pMeshKey, Desc.tRigidStaticDesc.pMesh); m_pMaterial = m_pGameInstance->Get_Material(Desc.tRigidDynamicDesc.vMatInfo); - m_pMeshKey = Desc.tRigidStaticDesc.pMeshKey; + m_wstrMeshKey = CMyTools::ToWstring(Desc.tRigidStaticDesc.szMeshName); } break; case ACTOR::HEIGHTFIELD: @@ -54,6 +53,7 @@ HRESULT CRigidBody::Initialize_Prototype(RIGIDBODY_PROTOTYPEDESC& Desc) default: break; } + return S_OK; return S_OK; } diff --git a/Jusin154_Team3D/Engine/Public/GameInstance.h b/Jusin154_Team3D/Engine/Public/GameInstance.h index b46b8de2d..d148096df 100644 --- a/Jusin154_Team3D/Engine/Public/GameInstance.h +++ b/Jusin154_Team3D/Engine/Public/GameInstance.h @@ -178,16 +178,20 @@ class ENGINE_DLL CGameInstance final : public CBase #pragma endregion #pragma region PhysX_Manager PSX::PxMaterial* Get_Material(_float3& vMatInfo); - HRESULT Create_TriangleMesh(const _wstring& wstrMeshKey, CMesh* pMesh); + void RegistTriMesh(const _char* pName, PSX::PxTriangleMesh* pPxTriMesh); PSX::PxShape* Create_Shape(ACTOR eType, _float3& vhalfGeometryInfo, PSX::PxMaterial& pxMaterial, _bool bExclusive = false, PSX::PxShapeFlags ePxShapeFlag = PSX::PxShapeFlag::eVISUALIZATION | PSX::PxShapeFlag::eSCENE_QUERY_SHAPE | PSX::PxShapeFlag::eSIMULATION_SHAPE); const PSX::PxRigidDynamic* Add_DynamicActor(CRigidBody& RigidBody); const PSX::PxRigidStatic* Add_StaticActor(CRigidBody& RigidBody); - PSX::PxController* Add_CapsuleController(PSX::PxCapsuleControllerDesc& Desc); - PSX::PxController* Add_BoxController(PSX::PxBoxControllerDesc& Desc); - PSX::PxController* Get_Controller(_uint iControllerIndex); + PSX::PxController* Add_CapsuleController(PSX::PxCapsuleControllerDesc& Desc); + PSX::PxController* Add_BoxController(PSX::PxBoxControllerDesc& Desc); + PSX::PxController* Get_Controller(_uint iControllerIndex); void ReleaseController(_uint iControllerIndex); + + HRESULT ConvertToTriMeshes(vector& Meshes, vector& pxTriMeshes); + _bool SaveTriMeshes(const _char* pPath, vector& TriMeshes); + _bool LoadTriMeshes(const _char* pPath, vector& TriMeshes); #pragma endregion diff --git a/Jusin154_Team3D/Engine/Public/Mesh.h b/Jusin154_Team3D/Engine/Public/Mesh.h index 0f13d50a2..57fba9a7f 100644 --- a/Jusin154_Team3D/Engine/Public/Mesh.h +++ b/Jusin154_Team3D/Engine/Public/Mesh.h @@ -16,6 +16,7 @@ class ENGINE_DLL CMesh final : public CVIBuffer return m_iMaterialIndex; } + const _char* Get_Name() const { return m_szName; } HRESULT Bind_BoneMatrices(const vector& Bones, class CShader* pShader, const _char* pConstantName); HRESULT Bind_BoneMatrices(_float4x4* pCombinedMatrices, class CShader* pShader, const _char* pConstantName); HRESULT Render_Indexed(_uint IndexCount, _uint StartIndexLocation, _uint BaseVertexLocation); @@ -27,7 +28,7 @@ class ENGINE_DLL CMesh final : public CVIBuffer public: static CMesh* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, MODEL eType, vector& Bones, const aiMesh* pAIMesh, _fmatrix& PreTransformMatrix); HRESULT SaveAsBinary(HANDLE hFile, DWORD& dwByte); - PSX::PxTriangleMesh* ConvertToPxMesh(const PSX::PxCookingParams* pParam); + PSX::PxTriangleMesh* ConvertToPxMesh(const PSX::PxCookingParams* pParam, PSX::PxPhysics* pPhysX); #endif // EDITOR_PROJECT public: diff --git a/Jusin154_Team3D/Engine/Public/Model.h b/Jusin154_Team3D/Engine/Public/Model.h index 5e4ac2b94..35b6fd35b 100644 --- a/Jusin154_Team3D/Engine/Public/Model.h +++ b/Jusin154_Team3D/Engine/Public/Model.h @@ -31,6 +31,7 @@ class ENGINE_DLL CModel final : public CComponent _int Get_RootBoneIndex() const { return m_iRootBoneIndex; } const _float4x4* Get_BoneMatrixPtr(const _char* pBoneName) const; _uint Get_NumMeshes() const { return m_iNumMeshes; } + const _char* Get_MeshName(_uint iIndex); MODEL Get_Type() const { return m_eType; } _matrix Get_BoneMatrix(_uint iBoneIndex); @@ -60,12 +61,13 @@ class ENGINE_DLL CModel final : public CComponent static CModel* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, const _char* pModelFilePath, MODEL eType, _fmatrix& PreTransformMatrix, _uint iRootBoneIndex); HRESULT Assimp_Model_Load(const _char* pModelFilePath, MODEL eType, _fmatrix& PreTransformMatrix, _uint iRootBoneIndex); HRESULT Ready_Meshes(MODEL eType, const aiScene* pAIScene, _fmatrix& PreTransformMatrix); + HRESULT Ready_PhysXMeshes(MODEL eType); HRESULT Ready_Materials(const aiScene* pAIScene, const _char* pModelFilePath); HRESULT Ready_Materials_FromFile(const aiScene* pAIScene, const _char* pModelFilePath); HRESULT Ready_Animations(const aiScene* pAIScene); HRESULT Ready_Bones(const aiNode* pAINode, _int iParentIndex); // 바이너리 - bool SaveAssimpModel(const _char* filename); + _bool SaveAssimpModel(const _char* filename); _int SaveNodeRecursive(const aiNode* pAINode, std::vector& outNodes, _int parentIndex); // #endif // EDITOR_PROJECT @@ -83,6 +85,8 @@ class ENGINE_DLL CModel final : public CComponent _uint m_iNumMeshes = {}; // 메쉬의 갯수 vector m_Meshes; // 메쉬의 벡터 + _uint m_iNumPhysXMeshes = {}; // 피직스 메쉬의 갯수 + vector m_TriMeshes = {}; // 피직스 메쉬의 갯수 _uint m_iNumMaterials = {}; // 머테리얼의 갯수 vector m_Materials; // 머테리얼의 벡터 diff --git a/Jusin154_Team3D/Engine/Public/PhysX_Manager.h b/Jusin154_Team3D/Engine/Public/PhysX_Manager.h index 4c9267a15..ae345ebd9 100644 --- a/Jusin154_Team3D/Engine/Public/PhysX_Manager.h +++ b/Jusin154_Team3D/Engine/Public/PhysX_Manager.h @@ -22,11 +22,14 @@ class CPhysX_Manager final : public CBase const PSX::PxRigidDynamic* Add_DynamicActor(CRigidBody& RigidBody); const PSX::PxRigidStatic* Add_StaticActor(CRigidBody& RigidBody); - + + void RegistTriMesh(const _char* pName, PSX::PxTriangleMesh* pPxTriMesh); PSX::PxMaterial* Get_Material(_float3& vMatInfo); PSX::PxShape* Create_Shape(ACTOR eType, _float3& vhalfGeometryInfo, PSX::PxMaterial& pxMaterial, _bool bExclusive, PSX::PxShapeFlags ePxShapeFlag); - HRESULT Create_TriangleMesh(const _wstring& wstrMeshKey, CMesh* pMesh); + HRESULT ConvertToTriMeshes(vector& Meshes, vector& pxTriMeshes); + _bool SaveTriMeshes(const _char* pPath, vector& TriMeshes); + _bool LoadTriMeshes(const _char* pPath, vector& TriMeshes); PSX::PxTriangleMesh* Find_TriangleMesh(const _wstring& wstrMeshKey); void Update(_float fTimeDelta); diff --git a/Jusin154_Team3D/Engine/Public/RigidBody.h b/Jusin154_Team3D/Engine/Public/RigidBody.h index 06178f4b6..ec4ba9b73 100644 --- a/Jusin154_Team3D/Engine/Public/RigidBody.h +++ b/Jusin154_Team3D/Engine/Public/RigidBody.h @@ -16,8 +16,7 @@ class ENGINE_DLL CRigidBody final : public CComponent typedef struct tagRigidStatic_PrototypeDesc { _float3 vMatInfo; - const _tchar* pMeshKey = { nullptr }; - CMesh* pMesh = { nullptr }; + const _char* szMeshName = { } ; }RIGID_STATIC_PROTOTYPEDESC; typedef struct tagRigidDynamic_PrototypeDesc { @@ -37,7 +36,7 @@ class ENGINE_DLL CRigidBody final : public CComponent }; }RIGIDBODY_PROTOTYPEDESC; typedef struct tagRigidStatic_Desc { - const _tchar* pMeshKey = { nullptr }; + const _char* szMeshName = { }; }RIGID_STATIC_DESC; typedef struct tagRigidDynamic_Desc { _float fDensity = { 1000.f }; @@ -68,7 +67,7 @@ class ENGINE_DLL CRigidBody final : public CComponent public: PSX::PxShape* Get_ShapePtr() const { return m_pShape; } CTransform* Get_PxTransformPtr() const { return m_pTransform; } - const _tchar* Get_PxMeshKey() const { return m_pMeshKey; } + const _tchar* Get_PxMeshKey() const { return m_wstrMeshKey.c_str(); } const PSX::PxMaterial* Get_PxMaterial() const { return m_pMaterial; } _float Get_Density() const { return m_fDensity; } @@ -84,7 +83,7 @@ class ENGINE_DLL CRigidBody final : public CComponent _bool m_bKinematic = { false }; _bool m_bExclusive = { false }; _float m_fDensity = { 1000.f }; - const _tchar* m_pMeshKey = { nullptr }; + _wstring m_wstrMeshKey = { }; private: HRESULT Initialize_Prototype(RIGIDBODY_PROTOTYPEDESC& Desc);