more edge cases handled, one more left
This commit is contained in:
@@ -4,17 +4,49 @@
|
||||
{
|
||||
"classname" "worldspawn"
|
||||
"_tb_textures" "textures/common;textures/dev"
|
||||
"_tb_def" "builtin:goake.ent"
|
||||
// brush 0
|
||||
{
|
||||
( 0 576 -32 ) ( 0 577 -32 ) ( 0 576 -31 ) common/slick 0 0 0 4 4 0 0 0
|
||||
( 224 0 -32 ) ( 224 0 -31 ) ( 225 0 -32 ) common/slick 0 0 0 4 4 0 0 0
|
||||
( 224 576 -512 ) ( 225 576 -512 ) ( 224 577 -512 ) common/slick 0 0 0 4 4 0 0 0
|
||||
( 256 608 0 ) ( 256 609 0 ) ( 257 608 0 ) common/slick 0 0 0 4 4 0 0 0
|
||||
( 256 512 -16 ) ( 257 512 -16 ) ( 256 512 -15 ) common/slick 0 0 0 4 4 0 0 0
|
||||
( 512 608 -16 ) ( 512 608 -15 ) ( 512 609 -16 ) common/slick 0 0 0 4 4 0 0 0
|
||||
( -32 176 112 ) ( -32 176 176 ) ( 0 144 144 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 0 144 144 ) ( 32 176 112 ) ( -32 176 112 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 0 144 144 ) ( -32 176 176 ) ( 32 176 176 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 32 176 176 ) ( -32 176 176 ) ( -32 176 112 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 0 144 144 ) ( 32 176 176 ) ( 32 176 112 ) common/slick 0 0 0 1 1 0 0 0
|
||||
}
|
||||
// brush 1
|
||||
{
|
||||
( 0 144 144 ) ( -32 112 176 ) ( -32 112 112 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( -32 112 176 ) ( 32 112 176 ) ( 32 112 112 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 0 144 144 ) ( -32 112 112 ) ( 32 112 112 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 0 144 144 ) ( 32 112 176 ) ( -32 112 176 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 32 112 112 ) ( 32 112 176 ) ( 0 144 144 ) common/slick 0 0 0 1 1 0 0 0
|
||||
}
|
||||
// brush 2
|
||||
{
|
||||
( 0 0 144 ) ( -32 32 176 ) ( -32 -32 176 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 0 0 144 ) ( -32 -32 176 ) ( 32 -32 176 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( -32 32 176 ) ( 32 32 176 ) ( 32 -32 176 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 0 0 144 ) ( 32 32 176 ) ( -32 32 176 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 32 -32 176 ) ( 32 32 176 ) ( 0 0 144 ) common/slick 0 0 0 1 1 0 0 0
|
||||
}
|
||||
// brush 3
|
||||
{
|
||||
( -32 -32 48 ) ( -32 32 48 ) ( 0 0 80 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 0 0 80 ) ( 32 -32 48 ) ( -32 -32 48 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 32 32 48 ) ( -32 32 48 ) ( -32 -32 48 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 0 0 80 ) ( -32 32 48 ) ( 32 32 48 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 0 0 80 ) ( 32 32 48 ) ( 32 -32 48 ) common/slick 0 0 0 1 1 0 0 0
|
||||
}
|
||||
// brush 4
|
||||
{
|
||||
( -32 -32 112 ) ( -32 32 112 ) ( 0 0 144 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 0 0 144 ) ( 32 -32 112 ) ( -32 -32 112 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 32 32 112 ) ( -32 32 112 ) ( -32 -32 112 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 0 0 144 ) ( -32 32 112 ) ( 32 32 112 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 0 0 144 ) ( 32 32 112 ) ( 32 -32 112 ) common/slick 0 0 0 1 1 0 0 0
|
||||
}
|
||||
// brush 5
|
||||
{
|
||||
( -64 -64 16 ) ( -64 -63 16 ) ( -64 -64 17 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( -64 -64 16 ) ( -64 -64 17 ) ( -63 -64 16 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( -64 -64 16 ) ( -63 -64 16 ) ( -64 -63 16 ) common/slick 0 0 0 1 1 0 0 0
|
||||
@@ -22,45 +54,14 @@
|
||||
( 64 64 48 ) ( 65 64 48 ) ( 64 64 49 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 64 64 48 ) ( 64 64 49 ) ( 64 65 48 ) common/slick 0 0 0 1 1 0 0 0
|
||||
}
|
||||
// brush 2
|
||||
{
|
||||
( -32 -32 112 ) ( -32 32 112 ) ( 0 0 144 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 0 0 144 ) ( 32 -32 112 ) ( -32 -32 112 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 32 32 112 ) ( -32 32 112 ) ( -32 -32 112 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 0 0 144 ) ( -32 32 112 ) ( 32 32 112 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 0 0 144 ) ( 32 32 112 ) ( 32 -32 112 ) common/slick 0 0 0 1 1 0 0 0
|
||||
}
|
||||
// brush 3
|
||||
{
|
||||
( 0 0 144 ) ( -32 32 176 ) ( -32 -32 176 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 0 0 144 ) ( -32 -32 176 ) ( 32 -32 176 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( -32 32 176 ) ( 32 32 176 ) ( 32 -32 176 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 0 0 144 ) ( 32 32 176 ) ( -32 32 176 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 32 -32 176 ) ( 32 32 176 ) ( 0 0 144 ) common/slick 0 0 0 1 1 0 0 0
|
||||
}
|
||||
// brush 4
|
||||
{
|
||||
( -32 176 112 ) ( -32 176 176 ) ( 0 144 144 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 0 144 144 ) ( 32 176 112 ) ( -32 176 112 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 0 144 144 ) ( -32 176 176 ) ( 32 176 176 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 32 176 176 ) ( -32 176 176 ) ( -32 176 112 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 0 144 144 ) ( 32 176 176 ) ( 32 176 112 ) common/slick 0 0 0 1 1 0 0 0
|
||||
}
|
||||
// brush 5
|
||||
{
|
||||
( 0 144 144 ) ( -32 112 176 ) ( -32 112 112 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( -32 112 176 ) ( 32 112 176 ) ( 32 112 112 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 0 144 144 ) ( -32 112 112 ) ( 32 112 112 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 0 144 144 ) ( 32 112 176 ) ( -32 112 176 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 32 112 112 ) ( 32 112 176 ) ( 0 144 144 ) common/slick 0 0 0 1 1 0 0 0
|
||||
}
|
||||
// brush 6
|
||||
{
|
||||
( -32 -32 48 ) ( -32 32 48 ) ( 0 0 80 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 0 0 80 ) ( 32 -32 48 ) ( -32 -32 48 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 32 32 48 ) ( -32 32 48 ) ( -32 -32 48 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 0 0 80 ) ( -32 32 48 ) ( 32 32 48 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 0 0 80 ) ( 32 32 48 ) ( 32 -32 48 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 256 352 256 ) ( 256 353 256 ) ( 256 352 257 ) common/slick 16 16 30 -1 1 0 0 0
|
||||
( 240 352 256 ) ( 240 352 257 ) ( 241 352 256 ) common/slick 16 16 30 1 1 0 0 0
|
||||
( 240 352 256 ) ( 241 352 256 ) ( 240 353 256 ) common/slick 16 16 30 -1 1 0 0 0
|
||||
( 320 432 320 ) ( 320 433 320 ) ( 321 432 320 ) common/slick 16 16 30 1 1 0 0 0
|
||||
( 320 416 264 ) ( 321 416 264 ) ( 320 416 265 ) common/slick 16 16 30 -1 1 0 0 0
|
||||
( 320 432 264 ) ( 320 432 265 ) ( 320 433 264 ) common/slick 16 16 30 1 1 0 0 0
|
||||
}
|
||||
// brush 7
|
||||
{
|
||||
@@ -80,4 +81,58 @@
|
||||
( 320 416 136 ) ( 321 416 136 ) ( 320 416 137 ) common/slick 0 0 0 -1 1 0 0 0
|
||||
( 320 432 136 ) ( 320 432 137 ) ( 320 433 136 ) common/slick 32 0 0 1 1 0 0 0
|
||||
}
|
||||
// brush 9
|
||||
{
|
||||
( 0 576 -32 ) ( 0 577 -32 ) ( 0 576 -31 ) common/slick 0 0 0 4 4 0 0 0
|
||||
( 224 0 -32 ) ( 224 0 -31 ) ( 225 0 -32 ) common/slick 0 0 0 4 4 0 0 0
|
||||
( 224 576 -512 ) ( 225 576 -512 ) ( 224 577 -512 ) common/slick 0 0 0 4 4 0 0 0
|
||||
( 256 608 0 ) ( 256 609 0 ) ( 257 608 0 ) common/slick 0 0 0 4 4 0 0 0
|
||||
( 256 512 -16 ) ( 257 512 -16 ) ( 256 512 -15 ) common/slick 0 0 0 4 4 0 0 0
|
||||
( 512 608 -16 ) ( 512 608 -15 ) ( 512 609 -16 ) common/slick 0 0 0 4 4 0 0 0
|
||||
}
|
||||
// brush 10
|
||||
{
|
||||
( 416 429.25483399593895 136 ) ( 416.70710678118661 429.96194077712562 136 ) ( 416 429.25483399593895 137 ) common/slick 28 0 0 -1 1 0 0 0
|
||||
( 416 338.74516600406093 128 ) ( 415.29289321881345 339.45227278524749 128 ) ( 416 338.74516600406093 129 ) common/slick 0 0 0 -1 1 0 0 0
|
||||
( 404.68629150101526 327.4314575050762 128 ) ( 405.39339828220182 328.13856428626275 128 ) ( 403.97918471982871 328.13856428626269 128 ) common/slick 0 32 0 -1 1 0 0 0
|
||||
( 404.68629150101532 440.5685424949238 192 ) ( 403.97918471982877 441.27564927611036 192 ) ( 405.39339828220187 441.27564927611036 192 ) common/slick 0 32 0 1 1 0 0 0
|
||||
( 404.68629150101526 327.4314575050762 128 ) ( 404.68629150101526 327.4314575050762 129 ) ( 405.39339828220182 328.13856428626275 128 ) common/slick 28 0 0 1 1 0 0 0
|
||||
( 404.68629150101532 440.5685424949238 136 ) ( 404.68629150101532 440.5685424949238 137 ) ( 403.97918471982877 441.27564927611036 136 ) common/slick 0 0 0 1 1 0 0 0
|
||||
}
|
||||
// brush 11
|
||||
{
|
||||
( 512 384 114.74516600406099 ) ( 512 384.70710678118655 115.45227278524749 ) ( 512 383.29289321881345 115.45227278524754 ) common/slick -32 0 0 -1 1 0 0 0
|
||||
( 496 384 114.74516600406099 ) ( 496 383.29289321881345 115.45227278524754 ) ( 497 384 114.74516600406099 ) common/slick 0 8 180 1 1 0 0 0
|
||||
( 576 395.31370849898474 216.56854249492386 ) ( 576 396.02081528017129 217.27564927611041 ) ( 577 395.31370849898474 216.56854249492386 ) common/slick 0 8 0 1 1 0 0 0
|
||||
( 496 384 114.74516600406099 ) ( 497 384 114.74516600406099 ) ( 496 384.70710678118655 115.45227278524749 ) common/slick 0 8 180 1 1 0 0 0
|
||||
( 576 423.59797974644664 165.65685424949243 ) ( 577 423.59797974644664 165.65685424949243 ) ( 576 422.89087296526009 166.36396103067898 ) common/slick 0 8 180 1 1 0 0 0
|
||||
( 576 434.91168824543138 176.97056274847722 ) ( 576 434.20458146424482 177.67766952966372 ) ( 576 435.61879502661793 177.67766952966377 ) common/slick -32 0 0 1 1 0 0 0
|
||||
}
|
||||
// brush 12
|
||||
{
|
||||
( 641.37258300203052 327.4314575050762 137.3725830020303 ) ( 641.87258300203052 328.13856428626286 136.87258300203041 ) ( 640.87258300203052 328.13856428626275 137.8725830020303 ) common/slick 0 0 180 1 1 0 0 0
|
||||
( 649.37258300203052 338.74516600406105 129.37258300203041 ) ( 648.87258300203052 339.45227278524749 129.8725830020303 ) ( 650.07968978321708 338.74516600406105 130.07968978321691 ) common/slick 16 8 1.77636e-15 1 1 0 0 0
|
||||
( 655.02943725152284 429.25483399593918 135.02943725152275 ) ( 655.52943725152284 429.96194077712562 134.52943725152275 ) ( 655.73654403270939 429.25483399593918 135.7365440327093 ) common/slick -16 8 0 -1 1 0 0 0
|
||||
( 647.02943725152284 440.5685424949238 143.02943725152275 ) ( 647.73654403270939 440.5685424949238 143.7365440327093 ) ( 646.52943725152284 441.27564927611047 143.52943725152275 ) common/slick 0 0 180 1 1 0 0 0
|
||||
( 641.37258300203052 327.4314575050762 137.3725830020303 ) ( 642.07968978321708 327.4314575050762 138.07968978321679 ) ( 641.87258300203052 328.13856428626286 136.87258300203041 ) common/slick 0 0 180 1 1 0 0 0
|
||||
( 686.62741699796948 440.5685424949238 182.62741699796945 ) ( 686.12741699796948 441.27564927611047 183.12741699796945 ) ( 687.12741699796948 441.27564927611047 182.12741699796945 ) common/slick -32 -24 90 1 1 0 0 0
|
||||
}
|
||||
// brush 13
|
||||
{
|
||||
( 416 429.25483399593895 200 ) ( 416.70710678118661 429.96194077712562 200 ) ( 416 429.25483399593895 201 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 416 338.74516600406093 192 ) ( 415.29289321881345 339.45227278524749 192 ) ( 416 338.74516600406093 193 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 404.68629150101526 327.4314575050762 192 ) ( 405.39339828220182 328.13856428626275 192 ) ( 403.97918471982871 328.13856428626269 192 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 404.68629150101532 440.5685424949238 256 ) ( 403.97918471982877 441.27564927611036 256 ) ( 405.39339828220187 441.27564927611036 256 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 404.68629150101526 327.4314575050762 192 ) ( 404.68629150101526 327.4314575050762 193 ) ( 405.39339828220182 328.13856428626275 192 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 404.68629150101532 440.5685424949238 200 ) ( 404.68629150101532 440.5685424949238 201 ) ( 403.97918471982877 441.27564927611036 200 ) common/slick 0 0 0 1 1 0 0 0
|
||||
}
|
||||
// brush 14
|
||||
{
|
||||
( 512 384 206.74516600406099 ) ( 512 384.70710678118655 207.45227278524749 ) ( 512 383.29289321881345 207.45227278524754 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 496 384 206.74516600406099 ) ( 496 383.29289321881345 207.45227278524754 ) ( 497 384 206.74516600406099 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 576 395.31370849898474 308.56854249492386 ) ( 576 396.02081528017129 309.27564927611041 ) ( 577 395.31370849898474 308.56854249492386 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 496 384 206.74516600406099 ) ( 497 384 206.74516600406099 ) ( 496 384.70710678118655 207.45227278524749 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 576 423.59797974644664 257.65685424949243 ) ( 577 423.59797974644664 257.65685424949243 ) ( 576 422.89087296526009 258.36396103067898 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 576 434.91168824543138 268.97056274847722 ) ( 576 434.20458146424482 269.67766952966372 ) ( 576 435.61879502661793 269.67766952966377 ) common/slick 0 0 0 1 1 0 0 0
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
BIN
Content/Materials/dev/slick.flax
Normal file
BIN
Content/Materials/dev/slick.flax
Normal file
Binary file not shown.
@@ -22,7 +22,7 @@
|
||||
"TypeName": "Game.Q3MapImporter",
|
||||
"ParentID": "194e05f445ece24ec5448d886e1334df",
|
||||
"V": {
|
||||
"material": "076df2f449a475bd96087ebb03e0cfc6"
|
||||
"material": "a1ac1cf4484f3bf8e07c2ea4fddaa74f"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -176,13 +176,13 @@
|
||||
"Transform": {
|
||||
"Translation": {
|
||||
"X": 0.0,
|
||||
"Y": 484.0,
|
||||
"Y": 735.0,
|
||||
"Z": 0.0
|
||||
}
|
||||
},
|
||||
"Control": "FlaxEngine.GUI.Label",
|
||||
"Data": {
|
||||
"Text": "eFPS: 121\nuFPS: -2147483648\nrFPS: -2147483648\npFPS: -2147483648\nCon: 0ms\nDirectX11\nGC memory: 9.544752MB",
|
||||
"Text": "eFPS: 344\nuFPS: 346\nrFPS: 346\npFPS: 30\nCon: NaNms\nDirectX11\nGC memory: 62.44806MB",
|
||||
"TextColor": {
|
||||
"R": 1.0,
|
||||
"G": 1.0,
|
||||
@@ -268,8 +268,8 @@
|
||||
"Name": "ContainerControl 0",
|
||||
"Transform": {
|
||||
"Translation": {
|
||||
"X": 44635.0,
|
||||
"Y": -124.0,
|
||||
"X": 44550.0,
|
||||
"Y": 1.5,
|
||||
"Z": 0.0
|
||||
}
|
||||
},
|
||||
@@ -364,30 +364,6 @@
|
||||
},
|
||||
"PostFxMaterials": {}
|
||||
}
|
||||
},
|
||||
{
|
||||
"ID": "d5ffa50f41e7f68e73b8c98bb98c84e6",
|
||||
"TypeName": "FlaxEngine.StaticModel",
|
||||
"ParentID": "194e05f445ece24ec5448d886e1334df",
|
||||
"Name": "Capsule",
|
||||
"Transform": {
|
||||
"Translation": {
|
||||
"X": -42.142974853515628,
|
||||
"Y": 1.731597900390625,
|
||||
"Z": 261.0594482421875
|
||||
}
|
||||
},
|
||||
"Model": "3f82e57744f57c28285150b646ad2198",
|
||||
"Buffer": {
|
||||
"Entries": [
|
||||
{
|
||||
"Material": "076df2f449a475bd96087ebb03e0cfc6",
|
||||
"ShadowsMode": 3,
|
||||
"Visible": true,
|
||||
"ReceiveDecals": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1736,57 +1736,78 @@ namespace Game
|
||||
Vector3 v3 = brushVertices[i+2];
|
||||
|
||||
Vector3 normal = -Vector3.Cross(v3 - v1, v2 - v1).Normalized;
|
||||
Vector3 normal2 = new Vector3(-normal.X, -normal.Y, -normal.Z);
|
||||
|
||||
// texture is projected to the surface from the closest axis
|
||||
|
||||
var dotX = Mathf.Abs(Vector3.Dot(normal2, Vector3.Right));
|
||||
var dotY = Mathf.Abs(Vector3.Dot(normal2, Vector3.Up));
|
||||
var dotZ = Mathf.Abs(Vector3.Dot(normal2, Vector3.Forward));
|
||||
Vector3 theUp;
|
||||
if (dotX > dotY && dotX > dotZ)
|
||||
theUp = Vector3.Right;
|
||||
else if (dotZ > dotX && dotZ > dotY)
|
||||
theUp = -Vector3.Forward;
|
||||
else if (dotY > dotX && dotY > dotZ)
|
||||
theUp = -Vector3.Up;
|
||||
else
|
||||
theUp = -Vector3.Up;
|
||||
|
||||
var up1 = Vector3.Up;
|
||||
var up2 = -Vector3.Forward;
|
||||
|
||||
Vector2 uvScale = new Vector2(0f);
|
||||
float uvRotation = 0f;
|
||||
Vector2 uvOffset = new Vector2(0f);
|
||||
bool found = false;
|
||||
Vector2 textureSize = new Vector2(64f); // TODO: figure out the correct size for the material
|
||||
foreach (var brushPlane in brush.planes)
|
||||
{
|
||||
Plane plane = brushPlane.plane;
|
||||
if ((plane.Normal - normal).Length < 0.01f)
|
||||
{
|
||||
uvScale = 1f / brushPlane.scale / 64f; // texture size?
|
||||
normal = plane.Normal; // for consistency
|
||||
uvScale = 1f / brushPlane.scale / textureSize; // texture size?
|
||||
uvRotation = brushPlane.rotation;
|
||||
uvOffset = brushPlane.offset;
|
||||
uvOffset = brushPlane.offset * brushPlane.scale;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
Console.Print("no found, hidden surface?");
|
||||
Console.Print("no found, bad geometry?");
|
||||
|
||||
// texture is projected to the surface from the closest axis
|
||||
|
||||
Vector3 normal2 = normal;
|
||||
List<Tuple<float, Vector3>> dots = new List<Tuple<float, Vector3>>(new []
|
||||
{
|
||||
new Tuple<float, Vector3>(Mathf.Abs(Vector3.Dot(normal2, Vector3.Right)), Vector3.Right),
|
||||
new Tuple<float, Vector3>(Mathf.Abs(Vector3.Dot(normal2, Vector3.Forward)), -Vector3.Forward),
|
||||
|
||||
new Tuple<float, Vector3>(Mathf.Abs(Vector3.Dot(normal2, Vector3.Up)), -Vector3.Up),
|
||||
|
||||
});
|
||||
dots.Sort((l, r) => l.Item1.CompareTo(r.Item1));
|
||||
Vector3 theUp = dots.Last().Item2;
|
||||
|
||||
/*var dotX = Mathf.Abs(Vector3.Dot(normal2, Vector3.Right));
|
||||
var dotY = Mathf.Abs(Vector3.Dot(normal2, Vector3.Up));
|
||||
var dotZ = Mathf.Abs(Vector3.Dot(normal2, Vector3.Forward));
|
||||
Vector3 theUp;
|
||||
if (false)
|
||||
{}
|
||||
else if (dotY > dotX && dotY > dotZ)
|
||||
theUp = -Vector3.Up;
|
||||
else if (dotX > dotY && dotX > dotZ)
|
||||
theUp = Vector3.Right;
|
||||
else if (dotZ > dotX && dotZ > dotY)
|
||||
theUp = -Vector3.Forward;
|
||||
else
|
||||
theUp = Vector3.Right;*/
|
||||
|
||||
var up1 = Vector3.Up;
|
||||
var up2 = -Vector3.Forward;
|
||||
|
||||
var finalUp = Mathf.Abs(Vector3.Dot(theUp, up1)) > 0.01f ? up2 : up1;
|
||||
var finalUp2 = Mathf.Abs(Vector3.Dot(theUp, up1)) > 0.01f ? up1 : up2;
|
||||
var theRight = Vector3.Right;
|
||||
Quaternion rot = Quaternion.Identity;
|
||||
rot = rot * Quaternion.LookRotation(theUp, finalUp);
|
||||
rot = rot * Quaternion.RotationAxis(Vector3.Forward, 180f * Mathf.DegreesToRadians);
|
||||
rot = rot * Quaternion.RotationAxis(theUp, uvRotation * Mathf.DegreesToRadians);
|
||||
rot = rot * Quaternion.RotationAxis(up2, 180f * Mathf.DegreesToRadians);
|
||||
rot = rot * Quaternion.RotationAxis(Mathf.Abs(Vector3.Dot(theUp, theRight)) > 0.01f ? theRight : finalUp2, uvRotation * Mathf.DegreesToRadians);
|
||||
|
||||
//if (Mathf.Abs(Vector3.Dot(theUp, theRight)) <= 0.01f)
|
||||
// uvOffset *= 2;
|
||||
|
||||
|
||||
|
||||
brushUvs[i + 0] = ((Vector2)(v1 * rot) * uvScale) + uvOffset / 64f;
|
||||
brushUvs[i + 1] = ((Vector2)(v2 * rot) * uvScale) + uvOffset / 64f;
|
||||
brushUvs[i + 2] = ((Vector2)(v3 * rot) * uvScale) + uvOffset / 64f;
|
||||
brushUvs[i + 0] = ((Vector2)(v1 * rot) + (uvOffset)) * uvScale;
|
||||
brushUvs[i + 1] = ((Vector2)(v2 * rot) + (uvOffset)) * uvScale;
|
||||
brushUvs[i + 2] = ((Vector2)(v3 * rot) + (uvOffset)) * uvScale;
|
||||
|
||||
brushNormals[i + 0] = normal;
|
||||
brushNormals[i + 1] = normal;
|
||||
|
||||
Reference in New Issue
Block a user