Skip to content

Commit 3d0c40f

Browse files
committed
fixed texture bug holy shit hype
1 parent bbfe3e2 commit 3d0c40f

57 files changed

Lines changed: 3046 additions & 1967 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

changelog.txt

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2,59 +2,4 @@
22
-cleaned up comments
33
-cleaned up some "test" files
44
-updated linux stuff
5-
-rotation texture error (bird's eye):
6-
-1 = top
7-
-2 = bottom
8-
-3 = west
9-
-4 = east
10-
-5 = north
11-
-6 = south
12-
13-
## stole this from sledge. let's have a look at what this means
14-
15-
public void AlignTextureToWorld()
16-
{
17-
// Set the U and V axes to match the X, Y, or Z axes
18-
// How they are calculated depends on which direction the plane is facing
19-
20-
var direction = Plane.GetClosestAxisToNormal();
21-
22-
// VHE behaviour:
23-
// U axis: If the closest axis to the normal is the X axis,
24-
// the U axis is UnitY. Otherwise, the U axis is UnitX.
25-
// V axis: If the closest axis to the normal is the Z axis,
26-
// the V axis is -UnitY. Otherwise, the V axis is -UnitZ.
27-
28-
Texture.UAxis = direction == Coordinate.UnitX ? Coordinate.UnitY : Coordinate.UnitX;
29-
Texture.VAxis = direction == Coordinate.UnitZ ? -Coordinate.UnitY : -Coordinate.UnitZ;
30-
Texture.Rotation = 0;
31-
32-
CalculateTextureCoordinates(true);
33-
}
34-
# what it references
35-
## plane.get
36-
public Coordinate GetClosestAxisToNormal()
37-
{
38-
// VHE prioritises the axes in order of X, Y, Z.
39-
var norm = Normal.Absolute();
40-
41-
if (norm.X >= norm.Y && norm.X >= norm.Z) return Coordinate.UnitX; ##IF DISTANCE FROM X is grequal THAN Y AND Z furthest is X
42-
if (norm.Y >= norm.Z) return Coordinate.UnitY;
43-
return Coordinate.UnitZ;
44-
}
45-
### coordinate.unit x/y/z
46-
public readonly static Coordinate UnitX = new Coordinate(1, 0, 0);
47-
public readonly static Coordinate UnitY = new Coordinate(0, 1, 0);
48-
public readonly static Coordinate UnitZ = new Coordinate(0, 0, 1);
49-
50-
51-
FROM WHAT I GLEAM
52-
53-
the "normal" is the midpoint of a side. so if it's closest to the x axis, the uaxis variable will look like "uaxis" "[0 1 0 1] 0.25".
54-
otherwise, it's "uaxis" "[-1 0 0 1] 0.25"
55-
56-
if the normal is closest to the Z axis, the vaxis variable is "uaxis" "[0 -1 0 1] 0.25". otherwise it's "uaxis" "[0 0 -1 1] 0.25"
57-
58-
what we can do to calculate the norm for each side is go through each variable side (each side is xyz1,xyz2,xyz3 and so on) and get the normal for each, then calculating what uaxis and vaxis should be used. I reckon the tough part might be replacing the u and vaxis variables in the string, but we can probably use a .replace() with a times replaced as 1. Also, that might be a bit tough since we don't know what exactly the uaxis/vaxis values are.
59-
60-
TO FIND THE NORMAL: http://tutorial.math.lamar.edu/Classes/CalcIII/EqnsOfPlanes.aspx
5+
-FIXED TEXTURE BUG!! (praise allah!)

createPrefab.py

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,41 @@ def createTile(posx, posy, id_num, world_id_num, entity_num, placeholder_list, r
253253
"""
254254
values = "".join(lines)#converting list to string
255255
ogvalues = "".join(lines)
256+
257+
normal_list,axislist,negaxislist,vaxis,uaxis=[],['1 0 0 1','0 1 0 1','0 0 1 1'],['-1 0 0 1','0 -1 0 1','0 0 -1 1'],0,0
258+
def evaluate(coords):
259+
dist_x,dist_y,dist_z = abs(coords[0]),abs(coords[1]),abs(coords[2]),
260+
if dist_x >= dist_y and dist_x >= dist_z:
261+
return axislist[0]
262+
if dist_y >= dist_z:
263+
return axislist[1]
264+
return axislist[2]
265+
266+
def get_normal(coord_list):
267+
vector_a = (coord_list[1][0]-coord_list[0][0],coord_list[1][1]-coord_list[0][1],coord_list[1][2]-coord_list[0][2])
268+
vector_b = (coord_list[2][0]-coord_list[0][0],coord_list[2][1]-coord_list[0][1],coord_list[2][2]-coord_list[0][2])
269+
270+
normal = (vector_a[1]*vector_b[2]-vector_a[2]*vector_b[1],vector_a[2]*vector_b[0]-vector_a[0]*vector_b[2],vector_a[0]*vector_b[1]-vector_a[1]*vector_b[0])
271+
return normal
272+
273+
for normal_num in range(1,var_count+1,3):
274+
normal_list=[]
275+
for i in range(3):
276+
normal_list.append([])
277+
for var in ["x", "y", "z"]:
278+
normal_list[i].append(eval(var+str(normal_num+i)))
279+
coords = get_normal(normal_list)
280+
response = evaluate(coords)
281+
if response == axislist[0]:
282+
uaxis = axislist[1]
283+
else:
284+
uaxis = axislist[0]
285+
if response == axislist[2]:
286+
vaxis = negaxislist[1]
287+
else:
288+
vaxis = negaxislist[2]
289+
values = values.replace('AXIS_REPLACE_U',uaxis,1)
290+
values = values.replace('AXIS_REPLACE_V',vaxis,1)
256291
257292
for i in range(ogvalues.count("world_idnum")):
258293
values = values.replace('world_idnum', str(world_id_num), 1)
@@ -522,7 +557,18 @@ def createTile(posx, posy, id_num, world_id_num, entity_num, placeholder_list, r
522557
elif letter == "\"":
523558
eval(which_list).append(letter)
524559

525-
eval(which_list).insert(-2, "[1 0 0 1] 0.25")
560+
eval(which_list).insert(-2, "[AXIS_REPLACE_U] 0.25")
561+
elif "\"vaxis\"" in line:
562+
quote_num = 0
563+
for letter in line:
564+
if letter == "\"":
565+
quote_num += 1
566+
if quote_num != 3:
567+
eval(which_list).append(letter)
568+
elif letter == "\"":
569+
eval(which_list).append(letter)
570+
571+
eval(which_list).insert(-2, "[AXIS_REPLACE_U] 0.25")
526572

527573
else:
528574
eval(which_list).append(line)

prefab_template/add_template.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
normal_list,axislist,negaxislist,vaxis,uaxis=[],['1 0 0 1','0 1 0 1','0 0 1 1'],['-1 0 0 1','0 -1 0 1','0 0 -1 1'],0,0
2+
def evaluate(coords):
3+
dist_x,dist_y,dist_z = abs(coords[0]),abs(coords[1]),abs(coords[2]),
4+
if dist_x >= dist_y and dist_x >= dist_z:
5+
return axislist[0]
6+
if dist_y >= dist_z:
7+
return axislist[1]
8+
return axislist[2]
9+
10+
def get_normal(coord_list):
11+
vector_a = (coord_list[1][0]-coord_list[0][0],coord_list[1][1]-coord_list[0][1],coord_list[1][2]-coord_list[0][2])
12+
vector_b = (coord_list[2][0]-coord_list[0][0],coord_list[2][1]-coord_list[0][1],coord_list[2][2]-coord_list[0][2])
13+
14+
normal = (vector_a[1]*vector_b[2]-vector_a[2]*vector_b[1],vector_a[2]*vector_b[0]-vector_a[0]*vector_b[2],vector_a[0]*vector_b[1]-vector_a[1]*vector_b[0])
15+
return normal
16+
17+
for normal_num in range(1,var_count+1,3):
18+
normal_list=[]
19+
for i in range(3):
20+
normal_list.append([])
21+
for var in ["x", "y", "z"]:
22+
normal_list[i].append(eval(var+str(normal_num+i)))
23+
coords = get_normal(normal_list)
24+
response = evaluate(coords)
25+
if response == axislist[0]:
26+
uaxis = axislist[1]
27+
else:
28+
uaxis = axislist[0]
29+
if response == axislist[2]:
30+
vaxis = negaxislist[1]
31+
else:
32+
vaxis = negaxislist[2]
33+
values = values.replace('AXIS_REPLACE_U',uaxis,1)
34+
values = values.replace('AXIS_REPLACE_V',vaxis,1)

0 commit comments

Comments
 (0)