Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cracks deform past the edges of some rail objects #1125

Open
alex-wenzel opened this issue Mar 2, 2025 · 1 comment
Open

Cracks deform past the edges of some rail objects #1125

alex-wenzel opened this issue Mar 2, 2025 · 1 comment

Comments

@alex-wenzel
Copy link

I have created some rail objects where cracks don't deform to the nearest edge, as expected, but to some point within the object. After doing a lot of trial and error, I haven't yet been able to isolate why this is happening. Here's some example data and a screenshot:

An example route with rails and cracks in various positions
Route.Comment A test map for road/track cracks. 
Route.Gauge 1435,
Route.Change 1,

Options.BlockLength 10,
Options.ObjectVisibility 1

With Structure,
.Rail(1) sdbve\track\str_ground_grade-crossing_10m.csv
.Rail(2) sdbve\track\road_sw-1-1-sw_14m.csv,

.Ground(1) sdbve\ground\desert_ground.csv,

.CrackL(1) sdbve\platforms\grade_cement_formcl.csv,
.CrackR(1) sdbve\platforms\grade_cement_formcr.csv,

Texture.Background(0) sdbve\sny_sky_2.png,
Texture.Background(0).X 1

With Track,

0,
	.height 2,
	.ground 1,
	.back 0,
	.railtype 0;	1,
	.railstart 1;	-17.00;	0.00;	2,
10,
	.crack 0;	1;	1,
20,
	.crack 1;	0;	1,
30,
	.railend 1,
	.railstart 2;	17.00;	0.00;	2,
40,
	.crack 2;	0;	1,
50,
	.crack 0;	2;	1,
60,
	.railend 2,
70,
	.railstart 3;	-17.00;	0.00;	1,
80,
	.crack 0;	3;	1,
90,
	.crack 3;	0;	1,
100,
	.railend 3
110,
	.railstart 4;	-10.00;	0.00;	2,
	.railstart 5;	-30.00;	0.00;	2,
120,
	.crack 4;	5;	1,
130,
	.crack 5;	4;	1,
140,
	.railend 4,
	.railend 5,
Rail(1) (str_ground_grade-crossing_10m.csv)
;; Left grade surface

CreateMeshBuilder,
AddVertex,	-2.0,	0.101,	0,
AddVertex,	-2.0,	0.101,	10.00,
AddVertex,	-0.82,	0.101,	10.00,
AddVertex,	-0.82,	0.101,	0,
AddFace,	0,	1,	2,	3,
GenerateNormals,

LoadTexture,textures\cement.png,
SetTextureCoordinates,	0,	0,	1,
SetTextureCoordinates,	1,	1,	1,
SetTextureCoordinates,	2,	1,	0,
SetTextureCoordinates,	3,	0,	0,

;; Center grade surface

CreateMeshBuilder,
AddVertex,	-0.62,	0.101,	0,
AddVertex,	-0.62,	0.101,	10.00,
AddVertex,	0.62,	0.101,	10.00,
AddVertex,	0.62,	0.101,	0,
AddFace,	0,	1,	2,	3,
GenerateNormals,

LoadTexture,textures\cement.png,
SetTextureCoordinates,	0,	0,	1,
SetTextureCoordinates,	1,	1,	1,
SetTextureCoordinates,	2,	1,	0,
SetTextureCoordinates,	3,	0,	0,

;; Right grade surface

CreateMeshBuilder,
AddVertex,	0.82,	0.101,	0,
AddVertex,	0.82,	0.101,	10.00,
AddVertex,	2.0,	0.101,	10.00,
AddVertex,	2.0,	0.101,	0,
AddFace,	0,	1,	2,	3,
GenerateNormals,

LoadTexture,textures\cement.png,
SetTextureCoordinates,	0,	0,	1,
SetTextureCoordinates,	1,	1,	1,
SetTextureCoordinates,	2,	1,	0,
SetTextureCoordinates,	3,	0,	0,

;; Left rail top

CreateMeshBuilder,
AddVertex,	-0.82,	0.101,	0,
AddVertex,	-0.82,	0.101,	10.00,
AddVertex,	-0.68,	0.101,	10.00,
AddVertex,	-0.68,	0.101,	0,
AddFace,	0,	1,	2,	3,
GenerateNormals,

LoadTexture,textures\str_ground_rail-top_1m.png,
SetTextureCoordinates,	0,	0,	1,
SetTextureCoordinates,	1,	10,	1,
SetTextureCoordinates,	2,	10,	0,
SetTextureCoordinates,	3,	0,	0,

;; Right rail top

CreateMeshBuilder,
AddVertex,	0.68,	0.101,	0,
AddVertex,	0.68,	0.101,	10.00,
AddVertex,	0.82,	0.101,	10.00,
AddVertex,	0.82,	0.101,	0,
AddFace,	0,	1,	2,	3,
GenerateNormals,

LoadTexture,textures\str_ground_rail-top_1m.png,
SetTextureCoordinates,	0,	0,	1,
SetTextureCoordinates,	1,	10,	1,
SetTextureCoordinates,	2,	10,	0,
SetTextureCoordinates,	3,	0,	0,

;; Black base

CreateMeshBuilder,
AddVertex,	-0.90,	0.09,	0,
AddVertex,	-0.90,	0.09,	10.00,
AddVertex,	0.90,	0.09,	10.00,
AddVertex,	0.90,	0.09,	0,
AddFace,	0,	1,	2,	3,
SetColor,	25,	25,	25,

CreateMeshBuilder,	
AddVertex,	-0.90,	0.09,	0,
AddVertex,	0.90,	0.09,	0,
AddVertex,	0.90,	-0.14,	0,
AddVertex,	-0.90,	-0.14,	0,
AddFace,	0,	1,	2,	3,
SetColor,	25,	25,	25,
Rail(2) (road_sw-1-1-sw_14m.csv)
; left sidewalk

CreateMeshBuilder,
AddVertex,	-7.00,	0.101,	10.00,
AddVertex,	-5.50,	0.101,	10.00,
AddVertex,	-5.50,	0.101,	0.00,
AddVertex,	-7.00,	0.101,	0.00,
AddFace,	0,	1,	2,	3,
LoadTexture,	..\shared_textures\sidewalk_1.png
SetTextureCoordinates,	0,	0,	0,
SetTextureCoordinates,	1,	1,	0,
SetTextureCoordinates,	2,	1,	5,
SetTextureCoordinates,	3,	0,	5,

; asphalt

CreateMeshBuilder,
AddVertex,	-5.50,	0.101,	10.00,
AddVertex,	5.50,	0.101,	10.00,
AddVertex,	5.50,	0.101,	0.00,
AddVertex,	-5.50,	0.101,	0.00,
AddFace,	0,	1,	2,	3,
LoadTexture,	textures\asphalt_only.png
SetTextureCoordinates,	0,	0,	0,
SetTextureCoordinates,	1,	1,	0,
SetTextureCoordinates,	2,	1,	1,
SetTextureCoordinates,	3,	0,	1,

; right sidwalk

CreateMeshBuilder,
AddVertex,	5.50,	0.101,	10.00,
AddVertex,	7.00,	0.101,	10.00,
AddVertex,	7.00,	0.101,	0.00,
AddVertex,	5.50,	0.101,	0.00,
AddFace,	0,	1,	2,	3,
LoadTexture,	..\shared_textures\sidewalk_1.png
SetTextureCoordinates,	0,	0,	0,
SetTextureCoordinates,	1,	1,	0,
SetTextureCoordinates,	2,	1,	5,
SetTextureCoordinates,	3,	0,	5,

; right sidewalk edge

CreateMeshBuilder,
AddVertex,	7.00,	0.101,	0.00,
AddVertex,	7.00,	0.101,	10.00,
AddVertex,	7.00,	-0.18,	10.00,
AddVertex,	7.00,	-0.18,	0.00,
AddFace,	0,	1,	2,	3,
LoadTexture,	..\shared_textures\sidewalk_1.png
SetTextureCoordinates,	0,	0,	0,
SetTextureCoordinates,	1,	5,	0,
SetTextureCoordinates,	2,	5,	1,
SetTextureCoordinates,	3,	0,	1,
CrackL(1) (grade_cement_formcl.csv)
CreateMeshBuilder,
AddVertex,	-3.55,	0.101,	0,
AddVertex,	-3.55,	0.101,	10.1,
AddVertex,	-2.00,	0.101,	10.1,
AddVertex,	-2.00,	0.101,	0,

;AddFace,	0,	1,	2,	3,
AddFace,	2,	3,	0,	1,	

LoadTexture,..\track\textures\cement.png,
SetTextureCoordinates,	0,	0,	2,
SetTextureCoordinates,	1,	1,	2,
SetTextureCoordinates,	2,	1,	0,
SetTextureCoordinates,	3,	0,	0,
CrackR(1) (grade_cement_formcr.csv)
CreateMeshBuilder,
AddVertex,	3.55,	0.101,	0,
AddVertex,	3.55,	0.101,	10.1,
AddVertex,	2.00,	0.101,	10.1,
AddVertex,	2.00,	0.101,	0,

AddFace,	3,	2,	1,	0,

LoadTexture,..\track\textures\cement.png,
SetTextureCoordinates,	0,	0,	2,
SetTextureCoordinates,	1,	1,	2,
SetTextureCoordinates,	2,	1,	0,
SetTextureCoordinates,	3,	0,	0,
Screenshot of the route Image

As you can see, cracks applied to any combination containing Rail(2) don't align as expected to the outer edge of Rail(2). I haven't been able to figure out what makes Rail(1) work as expected and Rail(2) behave so differently. I thought the issue might be that Rail(1) and Rail(2) are different widths, but you can see the same behavior happening with cracks between two rails with the Rail(2) type.

This may or may not be related, but I also had some difficulty parsing the documentation for cracks, specifically the sentence "top refers to the furthest distance in the Z-axis, and left refers to the furthest distance in the X-axis.". The top/bottom makes sense, but I wasn't sure if "furthest distance in the X-axis" meant largest absolute distance from x = 0 or largest positive x-value, and how that interacts with whether rail index 1 in the Track.Crack command is to the left or right of rail index 2. Experimenting with this is why there are some commented AddFace commands above.

If you want to render these exact objects, these are the textures:

@leezer3
Copy link
Owner

leezer3 commented Mar 5, 2025

Cracks are a slightly complicated mess I'm afraid.....

What you're seeing with the alignment is normal- They'll align with the center point of the rail (minus / plus any offsets in the object).
They don't know anything about the actual width of any other rail (object), just the points in space which define it.

Left means the smallest absolute number in the X-axis.
e.g.
If you've got three points at -2, 0 and 2, this would be -2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants