.SHP files by hand?
Moderators: jelco, bert_the_turtle
.SHP files by hand?
Does anybody here know of a guide on creating .SHP files by hand (ie. in Notepad)? I understand the positions, and I think I get the triangles, but how do the vertices work?
If anybody knows of a guide on this, it would be greatly appreciated.
[size=0]I know you lot are gonna try and pimp your favourite text editor now that I've said 'in Notepad'.[/size]
If anybody knows of a guide on this, it would be greatly appreciated.
[size=0]I know you lot are gonna try and pimp your favourite text editor now that I've said 'in Notepad'.[/size]
- trickfred
- level5

- Posts: 1691
- Joined: Sat Jul 24, 2004 5:01 am
- Location: The Great White North, Eh?
- Contact:
There's no guide that specifically refers to making .shp files by hand, but there is nihil's guide on .shp file anatomy.
http://www.nihilesthetics.info/Darwinia ... rwinia.htm
(Click 'Intro' on the left)
Here's one of the first simple shapes I made by hand with graph paper. It's really 2D, as it has no depth (notice the 'z' coordinate column); I was lazy, and it suiteds my purposes at the time.
It's the letter 'a' from one side, and invisible from the other (as the polygons only show on one side, and like I said, it has no depth). As you can see, I just sort of 'faked' the Vertices section, and it turned out okay.
I'm sure xander will chime in on this thread eventually, as he's made some pretty impressive shapes solely by hand.
http://www.nihilesthetics.info/Darwinia ... rwinia.htm
(Click 'Intro' on the left)
Here's one of the first simple shapes I made by hand with graph paper. It's really 2D, as it has no depth (notice the 'z' coordinate column); I was lazy, and it suiteds my purposes at the time.
Code: Select all
Fragment: Box70
ParentName: sceneroot
up: 0.00 1.00 0.00
front: 0.00 0.00 1.00
pos: 0.01 7.11 0.04
Positions: 16
0: 7.500 17.000 0.000
1: 10.500 17.000 0.000
2: 10.500 -5.000 0.000
3: 7.500 -5.000 0.000
4: 7.500 7.500 0.000
5: -10.500 7.500 0.000
6: -10.500 4.500 0.000
7: 7.500 4.500 0.000
8: 7.500 -2.000 0.000
9: -10.500 -2.000 0.000
10: -10.500 -5.000 0.000
11: -7.500 4.500 0.000
12: -7.500 -2.000 0.000
13: -10.500 17.000 0.000
14: -10.500 14.000 0.000
15: 7.500 14.000 0.000
Normals: 0
Colours: 1
0: 95 240 95
Vertices: 16 # Position ID then Colour ID
0: 0 0
1: 1 0
2: 2 0
3: 3 0
4: 4 0
5: 5 0
6: 6 0
7: 7 0
8: 8 0
9: 9 0
10: 10 0
11: 11 0
12: 12 0
13: 13 0
14: 14 0
15: 15 0
Triangles: 10
0,3,1
1,3,2
4,5,6
6,7,4
8,9,10
10,3,8
6,9,12
12,11,6
13,14,15
15,0,13
It's the letter 'a' from one side, and invisible from the other (as the polygons only show on one side, and like I said, it has no depth). As you can see, I just sort of 'faked' the Vertices section, and it turned out okay.
I'm sure xander will chime in on this thread eventually, as he's made some pretty impressive shapes solely by hand.
:)
Thanks for that, trickfred. One thing I don't understand is the colouring - does a triangle average out the colours on the vertices it's connected to?
EDIT: Also, does each fragment have to have a name unique to the whole game? For example, if I was using your shape and I made my own with a fragment named Box70, would Darwinia be OK with that?
EDIT: Also, does each fragment have to have a name unique to the whole game? For example, if I was using your shape and I made my own with a fragment named Box70, would Darwinia be OK with that?
As trickfred said, fragment names only apply to a specific shape, so far as I can tell.
As far as I can tell, the color of a triangle is based upon the color of the last vertex that it hits. Therefore, if you have three colors (say red, green, blue) and three verticies (say 0, 1, and 2), where 0 was red, 1 green, and 2 blue, it would work as below:
A) triangle 0, 1, 2 would be a blue triangle
B) triangle 1, 2, 0 would be a red triangle
C) triangle 2, 1, 0 would be a green triangle
This, at least, is how it works in isolation. I am not sure exactly how triangles are colored in more complicated cases -- I have built shapes where colors seem to mix a bit in the middle. This is why I generally use this strategy: Remember that you can have more verticies than positions. If you have two triangles that share a side (say they use positions 0, 1, 2 and 1, 2, 3), assign vertices as follows:
0: 0 0
1: 1 0
2: 2 0
3: 1 1
4: 2 1
5: 3 1
Notice that vertecies 1 and 3 use the same position, but a different color. The same is true of 2 and 4. Then, triangle 1 is made up of verticies 0, 1, 2 and triangle 2 is made up of verticies 3, 4, 5. I am sure that there is a better way (nihil has probably figured it out), but that works for me -- I am OCD enough to keep making triangles. :)
By the way, trickfred, the scissors now live in desks ;)
xander
As far as I can tell, the color of a triangle is based upon the color of the last vertex that it hits. Therefore, if you have three colors (say red, green, blue) and three verticies (say 0, 1, and 2), where 0 was red, 1 green, and 2 blue, it would work as below:
A) triangle 0, 1, 2 would be a blue triangle
B) triangle 1, 2, 0 would be a red triangle
C) triangle 2, 1, 0 would be a green triangle
This, at least, is how it works in isolation. I am not sure exactly how triangles are colored in more complicated cases -- I have built shapes where colors seem to mix a bit in the middle. This is why I generally use this strategy: Remember that you can have more verticies than positions. If you have two triangles that share a side (say they use positions 0, 1, 2 and 1, 2, 3), assign vertices as follows:
0: 0 0
1: 1 0
2: 2 0
3: 1 1
4: 2 1
5: 3 1
Notice that vertecies 1 and 3 use the same position, but a different color. The same is true of 2 and 4. Then, triangle 1 is made up of verticies 0, 1, 2 and triangle 2 is made up of verticies 3, 4, 5. I am sure that there is a better way (nihil has probably figured it out), but that works for me -- I am OCD enough to keep making triangles. :)
By the way, trickfred, the scissors now live in desks ;)
xander
-
nihilesthetics2
- level2

- Posts: 101
- Joined: Mon Dec 12, 2005 11:18 pm
xander wrote:the color of a triangle is based upon the color of the last vertex that it hits.
Yes you are quite correct my friend.
xander wrote: I have built shapes where colors seem to mix a bit in the middle.
Thats odd. Actually you can get a shading effect by turning on smooth shading in the game, and its amazingly easy. What you do is unpack using upx, open in a hex editor, and change all hex references of '68001D00' to '68011D00'. That means that whenever you find a reference to GL_FLAT, you change it to GL_SMOOTH. For some reason it doesnt seem to working on shapes, although it used to as shown here. Maybe there was something else you had to do that Ive forgotten.
N2
nihilesthetics2 wrote:xander wrote:the color of a triangle is based upon the color of the last vertex that it hits.
Yes you are quite correct my friend.xander wrote: I have built shapes where colors seem to mix a bit in the middle.
Thats odd. Actually you can get a shading effect by turning on smooth shading in the game, and its amazingly easy. What you do is unpack using upx, open in a hex editor, and change all hex references of '68001D00' to '68011D00'. That means that whenever you find a reference to GL_FLAT, you change it to GL_SMOOTH. For some reason it doesnt seem to working on shapes, although it used to as shown here. Maybe there was something else you had to do that Ive forgotten.
N2
Perhaps there are a few special cases where smooth shading was used? I am fairly certain that I had solar panels that looked like your box at one point. However, as I don't really remember which verticies I changed, I am not sure that I can go back and make it look like that again.
xander
Broken!
What's going on here?
Only one triangle on each face shows up. It inverts on the inside.
Do the triangle vertices have to be in a particular order?
Code: Select all
Fragment: Box01
ParentName: sceneroot
up: 0.00 1.00 0.00
front: 0.00 0.00 1.00
pos: 0.00 10.00 0.00
Positions: 8 # x y z
0: 10.00 10.00 10.00
1: 10.00 10.00 -10.00
2: -10.00 10.00 10.00
3: -10.00 10.00 -10.00
4: 10.00 -10.00 10.00
5: 10.00 -10.00 -10.00
6: -10.00 -10.00 10.00
7: -10.00 -10.00 -10.00
Normals: 0
Colours: 1 # r g b
0: 190 190 190
Vertices: 8 # pos col
0: 0 0
1: 1 0
2: 2 0
3: 3 0
4: 4 0
5: 5 0
6: 6 0
7: 7 0
Triangles: 12
0,1,3
0,2,3
0,1,5
0,4,5
1,3,5
7,3,5
3,7,6
3,2,6
0,2,6
0,4,6
7,6,4
7,5,4
Only one triangle on each face shows up. It inverts on the inside.
Do the triangle vertices have to be in a particular order?
Yeah, real helpful.
What order? Do they need to be clockwise, anti-clockwise, or something else?
Re: Yeah, real helpful.
AzraelUK wrote:What order? Do they need to be clockwise, anti-clockwise, or something else?
Yes. I haven't actually bothered to figure out which direction it should go. I generally just double them up. For instance, these two triangles are the same, only facing different directions:
0,1,2
0,2,1
Use them both. By the way (done by hand):
Code: Select all
Fragment: crane
ParentName: sceneroot
up: 0.00 1.00 0.00
front: 0.00 0.00 1.00
pos: 0.00 1.00 0.00
Positions: 49
0: 0 0 0
1: 10 0 1.1111111111
2: 10 0 -1.1111111111
3: -10 0 1.1111111111
4: -10 0 -1.1111111111
5: 0 10 0
6: 8.8888888889 -2.2222222222 0.66666666667
7: 6.6666666667 12.222222222 0
8: 10 13.333333333 1.1111111111
9: 10 13.333333333 -1.1111111111
10: 14.444444444 6.6666666667 0
11: -8.8888888889 -2.2222222222 0.66666666667
12: -12.222222222 20 0
13: 0 4.4444444444 2.2222222222
14: 0 7.7777777778 3.3333333333
15: 0 11.111111111 6.6666666667
16: 0 12.222222222 11.111111111
17: 0 11.111111111 15.555555556
18: 0 7.7777777778 18.888888889
19: 8.8888888889 4.4444444444 2.2222222222
20: 8.2222222222 7.7777777778 3.3333333333
21: 6.4444444444 11.111111111 6.6666666667
22: 4.2222222222 12.222222222 11.111111111
23: 1.7777777778 11.111111111 15.555555556
24: -8.8888888889 4.4444444444 2.2222222222
25: -8.2222222222 7.7777777778 3.3333333333
26: -6.4444444444 11.111111111 6.6666666667
27: -4.2222222222 12.222222222 11.111111111
28: -1.7777777778 11.111111111 15.555555556
29: 0 4.4444444444 -2.2222222222
30: 0 7.7777777778 -3.3333333333
31: 0 11.111111111 -6.6666666667
32: 0 12.222222222 -11.111111111
33: 0 11.111111111 -15.555555556
34: 0 7.7777777778 -18.888888889
35: 8.8888888889 4.4444444444 -2.2222222222
36: 8.2222222222 7.7777777778 -3.3333333333
37: 6.4444444444 11.111111111 -6.6666666667
38: 4.2222222222 12.222222222 -11.111111111
39: 1.7777777778 11.111111111 -15.555555556
40: -8.8888888889 4.4444444444 -2.2222222222
41: -8.2222222222 7.7777777778 -3.3333333333
42: -6.4444444444 11.111111111 -6.6666666667
43: -4.2222222222 12.222222222 -11.111111111
44: -1.7777777778 11.111111111 -15.555555556
45: 8.8888888889 -2.2222222222 -0.66666666667
46: -8.8888888889 -2.2222222222 -0.66666666667
47: 0 0 1.1111111111
48: 0 0 -1.1111111111
Normals: 0
Colours: 1
0: 255 255 255
Vertices: 49
0: 0 0
1: 1 0
2: 2 0
3: 3 0
4: 4 0
5: 5 0
6: 6 0
7: 7 0
8: 8 0
9: 9 0
10: 10 0
11: 11 0
12: 12 0
13: 13 0
14: 14 0
15: 15 0
16: 16 0
17: 17 0
18: 18 0
19: 19 0
20: 20 0
21: 21 0
22: 22 0
23: 23 0
24: 24 0
25: 25 0
26: 26 0
27: 27 0
28: 28 0
29: 29 0
30: 30 0
31: 31 0
32: 32 0
33: 33 0
34: 34 0
35: 35 0
36: 36 0
37: 37 0
38: 38 0
39: 39 0
40: 40 0
41: 41 0
42: 42 0
43: 43 0
44: 44 0
45: 45 0
46: 46 0
47: 47 0
48: 48 0
Triangles: 124
0,1,5
0,5,1
0,2,5
0,5,2
0,3,5 # 5
0,5,3
0,4,5
0,5,4
0,1,6
0,6,1 # 10
0,2,45
0,45,2
0,3,11
0,11,3
0,4,46 #15
0,46,4
1,3,5
1,5,3
2,4,5
2,5,4 # 20
0,7,8
0,8,7
0,7,9
0,9,7
0,6,8 #25
0,8,6
0,45,9
0,9,45
7,8,10
7,10,8 # 30
7,9,10
7,10,9
0,11,12
0,12,11
0,46,12 # 35
0,12,46
47,13,19
47,19,13
13,14,20
13,20,14 # 40
14,15,21
14,21,15
15,16,22
15,22,16
16,17,23 # 45
16,23,17
1,19,47
1,47,19
19,20,13
19,13,20 # 50
20,21,14
20,14,21
21,22,15
21,15,22
22,23,16 # 55
22,16,23
17,18,23
17,23,18
47,13,24
47,24,13 # 60
13,14,25
13,25,14
14,15,26
14,26,15
15,16,27 # 65
15,27,16
16,17,28
16,28,17
17,18,28
17,28,18 # 70
3,24,47
3,47,24
24,25,13
24,13,25
25,26,14 # 75
25,14,26
26,27,15
26,15,27
27,28,16
27,16,28 # 80
48,29,35
48,35,29
29,30,36
29,36,30
30,31,37 # 85
30,37,31
31,32,38
31,38,32
32,33,39
32,39,33 # 90
2,35,48
2,48,35
35,36,29
35,29,36
36,37,30 # 95
36,30,37
37,38,31
37,31,38
38,39,32
38,32,39 # 100
33,34,39
33,39,34
48,29,40
48,40,29
29,30,41 # 105
29,41,30
30,31,42
30,42,31
31,32,43
31,43,32 # 110
32,33,44
32,44,33
4,40,48
4,48,40
40,41,29 # 115
40,29,41
41,42,30
41,30,42
42,43,31
42,31,43 # 120
43,44,32
43,32,44
33,34,44
33,44,34
xander
-
nihilesthetics2
- level2

- Posts: 101
- Joined: Mon Dec 12, 2005 11:18 pm
Re: Broken!
AzraelUK wrote:Do the triangle vertices have to be in a particular order?
Its to do with the winding and normals. Each triangle has a normal, that points out from the face of the triangle at 90 degrees in one direction only. Light only reflects in the direction of the normal. So a triangle is always visible from one side and invisible from the other. Considering the viewers position, if the triangle is wound counter-clockwise, i.e if v0, v1 and v2 turn widdershins ( I cant believe Ive actually found a valid place to use that word - that alone is worth the post, surely ), then the normal points towards the viewer and the triangle is visible. If the triangle is wound clockwise, i.e. if v0, v1 and v2 turn clockwise, then the normal points away from the viewer and the triangle is invisible. This is slightly complicated by the fact that you can flip the normals in the code that renders the image - but you have no control over that. So you cant tell, without looking at the code, whether counterclockwise or clockwise winding is visible to the viewer.
If you think about this at all, you will probably find it is too complex to figure out the winding in your head such that every non-occluded triangle is visible from any angle for all but the most simple of shapes. What Xanders trick does is to always have two triangles back-to-back, so there is always a visible triangle ( and by inference always an invisible triangle ) from the viewers position.
When you make a shape in a modelling package, the program will automatically wind the triangles correctly so that the shape is visible.
N2
- trickfred
- level5

- Posts: 1691
- Joined: Sat Jul 24, 2004 5:01 am
- Location: The Great White North, Eh?
- Contact:
Re: Broken!
nihilesthetics2 wrote:When you make a shape in a modelling package, the program will automatically wind the triangles correctly so that the shape is visible.
I've had to manually 'flip' a few pieces of objects made in 3DS Max 5, but it's quite possible I bunged something up being such a greenhorn with the software.
Plus, making manual shapes is, as has been said before, trial and error.
Who is online
Users browsing this forum: No registered users and 3 guests



