Train-Sim.Com
BVE

Handcoding objects

Notice to all visitors and members of the Train-Sim.Com message forums:
If you plan on using a signature banner in your posts, we would like to remind you that there is a maximum size for banners. That maximum is 450 pixels wide by 120 pixels high, and not to exceed 25k. Your compliance is appreciated. FORUM RULES Problems? There are two common reasons for problems with logging in and posting messages. The first is that you are running a firewall that prevents your messages from being sent to the server. The other is that you have cookies disabled; the DCForum software requires cookies to work properly.

Previous Topic | Next Topic

Printer-friendly copy Email this topic to a friend

Reading Topic #106

Member since Apr-14-03 · 7 posts

Hi,though i am a newbie,i want to learn how to handcode objects can someone tell me how to do it and now to create tracks,tunnels and placing objects?

Alert | IP

Printer-friendly page | Edit | Reply | Reply With Quote | Top

RE: handcoding objects, Zazzy_Bob, Apr-20-03, 00:37 AM, (1) RE: handcoding objects, davereage, Apr-20-03, 00:41 AM, (2) RE: handcoding objects, Technical Numpty, Apr-28-03, 08:57 AM, (9) RE: handcoding objects, davereage, Apr-28-03, 03:15 PM, (12) RE: handcoding objects, Technical Numpty, Apr-29-03, 09:53 AM, (13) RE: handcoding objects, Stooopid_person, Apr-29-03, 10:57 AM, (14) RE: handcoding objects, davereage, Apr-29-03, 11:01 AM, (15) RE: handcoding objects, Technical Numpty, Apr-29-03, 11:47 AM, (16) RE: handcoding objects, Stooopid_person, Apr-30-03, 06:22 AM, (18) RE: handcoding objects, Technical Numpty, Apr-30-03, 07:20 AM, (19) RE: handcoding objects, Stooopid_person, Apr-30-03, 07:33 AM, (20) RE: handcoding objects, Technical Numpty, Apr-30-03, 08:27 AM, (21) RE: handcoding objects, Stooopid_person, Apr-30-03, 08:33 AM, (22) RE: handcoding objects, Technical Numpty, Apr-30-03, 08:51 AM, (23) RE: handcoding objects, b3mb3e0r4v2, Apr-20-03, 06:11 AM, (3) RE: handcoding objects, jsdickinson, Apr-20-03, 06:15 AM, (4) RE: handcoding objects, OliverMat, Apr-20-03, 07:00 AM, (5) RE: handcoding objects, D2UK JLE Line, Apr-20-03, 12:34 PM, (6) RE: handcoding objects, mjspeed, Apr-20-03, 01:56 PM, (7) RE: handcoding objects, Stooopid_person, Apr-21-03, 10:12 AM, (8) RE: handcoding objects, smikes, Apr-28-03, 10:45 AM, (10) RE: handcoding objects, Psy, May-02-03, 11:41 PM, (24) RE: handcoding objects, etjason, Apr-28-03, 02:58 PM, (11) RE: handcoding objects, Routemaster J, Apr-29-03, 12:39 PM, (17) RE: handcoding objects, leezer3, May-03-03, 07:48 AM, (25)

Conferences | Topics | Previous Topic | Next Topic

Member since Apr-17-03 · 38 posts

RE: handcoding objects

Handcoding objects – image 1

Hello there,Up until about 24 hours ago, I had never even looked at the code contained within the route and object files. Now I am really starting to get to grips with it all.I started by downloading Structure Viewer and Track Viewer from Mackoys website. Then it was just a case of literally toying with the code, and seeing how each change made a difference to the structure and the trackbed itself. Firstly, I created a long, straight track, and then tried out the different commands on that.It took a couple of hours of mindless manipulation, but then it clicked, and now it's getting easier by the minute. Even so, I am only just starting out and there is TONS more to learn.....It seems daunting at first, but once you start, it becomes (at risk of sounding lame) really exciting when it all starts coming together.Spend a day with Notepad and Structure/Track Viewer open, fiddling around, and once you get it, you'll be amazed at the results.As for the objects, once you've got the co-ordinate system sussed, it becomes easier as you create more and more objects.Cliche: "Practice makes perfect" true though Good luck!Peace,
ZB

http://www.zazzybob.com
Home of the ZBRail Network

Alert | IP

Printer-friendly page | Edit | Reply | Reply With Quote | Top

Charter Member · 674 posts

RE: handcoding objects

I find the most helpfull thing to do when coding objects is to sketch it out in 3D. Then I write in the coordinates for most of the vertices so I can easily code them.As Zazzy_Bob said though, it does take a lot of practice and fiddling to get it right.Good luck

Dave Reage
www.geocities.com/d_reage

Alert | IP

Printer-friendly page | Edit | Reply | Reply With Quote | Top

Member since Apr-16-03 · 9 posts

RE: handcoding objects

Hi Gang!!I'm also looking at this whole 3D object thing and, as the name suggests, I haven't a clue where to start. I've looked all round the web (including the BVE Helper site) but am getting no satisfaction at all.Where do the textures come from? Are they hand produced in Paint (or similar) or do people use photos converted to 256 colour bitmaps?What does the CSV code for an object mean? How do I replicate this?Where do the relevant vertices go?In short, HELP!!!!!!Technical Numpty

Alert | IP

Printer-friendly page | Edit | Reply | Reply With Quote | Top

Charter Member · 674 posts

RE: handcoding objects

LAST EDITED ON Apr-28-03 AT 03:15 PM (EDT)

>Where do the textures come from? Are they hand produced in
>Paint (or similar) or do people use photos converted to 256
>colour bitmaps? The textures are .bmp files, whether you draw them yourself or use photos is totally up to you. There is no need to change them to 256 colour bitmaps, however this greatly reduces the file size, so it is good to do it whenever you can.If you use bitmaps that are larger than 256 x 256 pixels some people may have problems running your route depending on their video card.>Where do the relevant vertices go? not sure what you mean by "relevant" vertices, but vertices are just the corners of the object that you are coding. These vertices are based on an XYZ axis system (x being horizontal, y being vertical and z being depth away from you).In order to create a face that you can apply a texture to, you must define the vertices that make up the face.In a simple example, a 1m by 1m square that is two dimensional (ie no depth) would have the following vertices:vertex 0,0,0
vertex 0,1,0
vertex 1,1,0
vertex 1,0,0This defines the four corners that make up the box. Then, to create a square face that can be textured or coloured,face 0,1,2,3This tells BVE to create a face using vertices 0,1,2,3 above (these numkbers are automatic based on the order of the vertices above).Hope this helps a little.

Dave Reage
www.geocities.com/d_reage

Alert | IP

Printer-friendly page | Edit | Reply | Reply With Quote | Top

Member since Apr-16-03 · 9 posts

RE: handcoding objects

>In a simple example, a 1m by 1m square that is two
>dimensional (ie no depth) would have the following vertices:
>
>vertex 0,0,0
>vertex 0,1,0
>vertex 1,1,0
>vertex 1,0,0
>
>This defines the four corners that make up the box.So, if I wanted to make this into a 3D object, a signal box say, that can be viewed from both directions (i.e. a face and two ends), the vertices would look something like this.vertex 0,0,0
vertex 0,1,0
vertex 1,1,0
vertex 1,0,0
vertex 0,0,1
vertex 0,1,1
vertex 1,0,1
vertex 1,1,1>Then, to create a square face that can be textured or coloured,
>
>face 0,1,2,3
>
>This tells BVE to create a face using vertices 0,1,2,3 above
>(these numkbers are automatic based on the order of the
>vertices above).OK, so now I've go three faces.face 0,1,2,3
face 0,2,4,5
face 1,3,6,7(I think this is right.)As a leap of intellect, I am guessing that these are now known to BVE as face 0, face 1 and face 2, and each can be allocated it's own texture accordingly.This is all well and good for simple objects. I presume that more complex objects are simply made up using a "grid" of vertices joined together dot-to-dot fashion. If I really wanted to go to town and stick big turrets onto station buildings, would I try to render this as one object or as two with one placed on top of the other?>Hope this helps a little.Most certainly does!!! I think I'm beginning to understand...!!Technical Numpty (although, getting more adept all the time)

Alert | IP

Printer-friendly page | Edit | Reply | Reply With Quote | Top

Charter Member · 2158 posts

RE: handcoding objects

Here's another big hint to save space.
If the .bmp doesn't need to be duplicated in the SetTextureCooridinates section, the .bmp need not be in 2* size. There are examples of this in the Victoria Line V2 and HK MTR lines.

------My favourite LUL train------
Handcoding objects – image 2
HAPPY NOW? It's not moving anymore.
It's still the same train but in another livery, that's all.

Alert | IP

Printer-friendly page | Edit | Reply | Reply With Quote | Top

Charter Member · 674 posts

RE: handcoding objects

LAST EDITED ON Apr-29-03 AT 11:03 AM (EDT)

>So, if I wanted to make this into a 3D object, a signal box
>say, that can be viewed from both directions (i.e. a face
>and two ends), the vertices would look something like this.
>
>vertex 0,0,0
>vertex 0,1,0
>vertex 1,1,0
>vertex 1,0,0
>vertex 0,0,1
>vertex 0,1,1
>vertex 1,0,1
>vertex 1,1,1 Not exactly. For each face you want to create, you must separate your vertices and have a separate face command.Here's an example from one of my objects (a simple station information sign with two beams to hang it from the ceiling):(meshbuilder)
vertex 0,.65,0
vertex 3,.65,0
vertex 3,-.1,0
vertex 0,-.1,0
face2 0,1,2,3(texture)
load collegesign.bmp
coordinates 0,0,0
coordinates 1,1,0
coordinates 2,1,1
coordinates 3,0,1(meshbuilder)
vertex 0,-.1,0
vertex 0,-.1,.1
vertex 3,-.1,.1
vertex 3,-.1,0
face2 0,1,2,3
color 33,39,55(meshbuilder)
vertex 0,-.1,0
vertex 0,.65,0
vertex 0,.65,.1
vertex 0,-.1,.1
face2 0,1,2,3
color 33,39,55(meshbuilder)
vertex 3,-.1,0
vertex 3,.65,0
vertex 3,.65,.1
vertex 3,-.1,.1
face2 0,1,2,3
color 33,39,55(meshbuilder)
vertex 0,0,0
vertex .1,0,0
vertex .1,7,0
vertex 0,7,0
face2 0,1,2,3
color 1,1,1(meshbuilder)
vertex 0,0,0
vertex 0,7,0
vertex 0,7,.1
vertex 0,0,.1
face2 0,1,2,3
color 1,1,1(meshbuilder)
vertex 2.9,0,0
vertex 3,0,0
vertex 3,7,0
vertex 2.9,7,0
face2 0,1,2,3
color 1,1,1(meshbuilder)
vertex 2.9,0,0
vertex 2.9,7,0
vertex 2.9,7,.1
vertex 2.9,0,.1
face2 0,1,2,3
color 1,1,1Please not that the brackets should actually be square brackets, but if I use square brackets the forum will think I'm trying to use html.As you can see, each face is coded in the meshbuilder section, then a face is created, and then one of two things happens: it is assigned a colour (color 1,1,1) or a texture is applied to it (load collegesign.bmp)When applying a texture, it is best to leave out the color command.The face2 command works like the face command, except that it creates a double-sided face.I wouldn't recommend using the face2 command unless you have to (I'm not sure why I used it here, I coded this a long time ago) as it is innefficient and can lead to slower running in extreme cases. >This is all well and good for simple objects. I presume that
>more complex objects are simply made up using a "grid" of
>vertices joined together dot-to-dot fashion. If I really
>wanted to go to town and stick big turrets onto station
>buildings, would I try to render this as one object or as
>two with one placed on top of the other? Essentially yes. I'm not sure what you mean by a turret (is that like a pillar?). If you look at how most "round" objects are created, you will see that they are created by placing many vertices very close to each other, so the illusion of roundness is accomplished.Cheers

Dave Reage
www.geocities.com/d_reage

Alert | IP

Printer-friendly page | Edit | Reply | Reply With Quote | Top

Member since Apr-16-03 · 9 posts

RE: handcoding objects

Ah, OK.I am guessing that each object file uses the same grid, so that all the vertix co-ordinates are related to each other. So, for example, if the front face of an object had the Z co-ordinate 0, to put a back face on one metre behind it, it's face co-ordinates would have the Z co-ordinate 1. A bit like this;Front Face
vertex 0,0,0
vertex 1,0,0
vertex 0,1,0
vertex 1,1,0
face 0,1,2,3Back Face
vertex 0,0,1
vertex 1,0,1
vertex 0,1,1
vertex 1,1,1
face 0,1,2,3Then, to add sides to make this a cube, I would need to replicate each
vertex separately to join the corners like this;Left Side
vertex 0,0,0
vertex 0,1,0
vertex 0,0,1
vertex 0,1,1
face 0,1,2,3Right Side
vertex 1,0,0
vertex 1,1,0
vertex 1,0,1
vertex 1,1,1
face 0,1,2,3Repeat the steps again to give the cube a top and bottom, apply texture and I'd have a lovely 1 metre cubed object.Voila (I hope)!!I presume that the main use of the face2 command would be to create things like double-sided trees for routes that be driven in either direction...?Technical NumptyP.S. Perhaps I'll make an object to illustrate the gradient of this learning curve I'm on!!

Alert | IP

Printer-friendly page | Edit | Reply | Reply With Quote | Top

Charter Member · 2158 posts

RE: handcoding objects

>Repeat the steps again to give the cube a top and bottom,
>apply texture and I'd have a lovely 1 metre cubed object. You don't have to do that for a cube! There is a special command, like making cylinders but I forgot what it was.But, if you don't want to use that special command, Richard Gellman made this cube object for me to play with long time ago, as I was fooling around to see what happens if I change this number, etc{Meshbuilder}
Vertex 1,1,-1
Vertex 1,-1,-1
Vertex -1,-1,-1
Vertex -1,1,-1
Vertex 1,1,1
Vertex 1,-1,1
Vertex -1,-1,1
Vertex -1,1,1 Face 0,1,2,3
Face 4,0,3,7
Face 4,5,1,0
Face 3,2,6,7
Face 1,5,6,2
Face 7,6,5,4 Color 255,0,0So, in other words, a complex object can be made in one Meshbuilder.

------My favourite LUL train------
Handcoding objects – image 3
HAPPY NOW? It's not moving anymore.
It's still the same train but in another livery, that's all.

Alert | IP

Printer-friendly page | Edit | Reply | Reply With Quote | Top

Member since Apr-16-03 · 9 posts

RE: handcoding objects

Hi Stooopid!! (Man, I feel bad calling you that when you're helping me.)I think it's beginning to click.If I have an object that whose faces are all one colour (or texture?), I'm guessing that I can code all the vertices and faces together and apply the colour at the end. If the faces are different, would they have to be coded separately so that the relevant colour/texture can be applied to each one in turn?And now for an advanced question (eek)!! I am presuming that curved surfaces are made up of lots of flat ones carefully arranged (a bit like a glitter ball made up of lots of flat mirror tiles). Is this right, or is there some handy command that would do this for me?I notice from the "Disappearing Objects" thread that there is something called an Axis Point, and a recommendation that large objects are built from the farthest point back rather than the nearest point forward. Could someone please explain what this means?I think that the best thing for me to do now is to go away and put some of this into practice. Before I do, is there anything else that I should know?Thanks to everyone for the excellent help that you've given. This really is very helpful indeed.Technical Numpty

Alert | IP

Printer-friendly page | Edit | Reply | Reply With Quote | Top

Charter Member · 2158 posts

RE: handcoding objects

>If I have an object that whose faces are all one colour (or
>texture?), I'm guessing that I can code all the vertices and
>faces together and apply the colour at the end. If the faces
>are different, would they have to be coded separately so
>that the relevant colour/texture can be applied to each one
>in turn? If every side of the cube is different colour, you can code the faces seperately OR apply a texture to it, which has all the colours.>And now for an advanced question (eek)!! I am presuming that
>curved surfaces are made up of lots of flat ones carefully
>arranged (a bit like a glitter ball made up of lots of flat
>mirror tiles). Is this right, or is there some handy command
>that would do this for me? You can use the cylinder command. A hint, if you are coding in .csv, don't put Generate Normals, to make the curves look smoother.>I notice from the "Disappearing Objects" thread that there
>is something called an Axis Point, and a recommendation that
>large objects are built from the farthest point back rather
>than the nearest point forward. Could someone please explain
>what this means? If the object is longer than 25m, after you pass that 25m, it will dissappear. An example is on the UBahn demo route, at the last signal, when you apprach it, it suddenly turns to green. BVE unloads the red light and reveals a green light behind it.

------My favourite LUL train------
Handcoding objects – image 4
HAPPY NOW? It's not moving anymore.
It's still the same train but in another livery, that's all.

Alert | IP

Printer-friendly page | Edit | Reply | Reply With Quote | Top

Member since Apr-16-03 · 9 posts

RE: handcoding objects

>>I notice from the "Disappearing Objects" thread that there
>>is something called an Axis Point, and a recommendation that
>>large objects are built from the farthest point back rather
>>than the nearest point forward. Could someone please explain
>>what this means?
>
>If the object is longer than 25m, after you pass that 25m,
>it will dissappear. An example is on the UBahn demo route,
>at the last signal, when you apprach it, it suddenly turns
>to green. BVE unloads the red light and reveals a green
>light behind it.
Er, still not sure I understand this. I understand that this can be used for good effect, but I really don't want things like station buildings disappearing!!Let's say I code an object 50 metres long and insert it at 1000 metres into the route. Are you saying that, once I get half way along it, it will disappear?If I've understood this correctly, to prevent this from happening, I'd need to build the object from the farthest point back (the front of this theoretical object having a vertex X value of -50 and the back having a vertex X value of 0?). To make it appear where I want it, would I also need to change the insertion point from 1000 to 1050 metres?I'm sorry for all these questions. It's just that, when I start coding, I want to make sure that it's as right as it can be first time so that I don't get discouraged having to do a major de-bugging afterwards.Thanks again!!Technical Numpty

Alert | IP

Printer-friendly page | Edit | Reply | Reply With Quote | Top

Charter Member · 2158 posts

RE: handcoding objects

>Er, still not sure I understand this. I understand that this
>can be used for good effect, but I really don't want things
>like station buildings disappearing!!
>
>Let's say I code an object 50 metres long and insert it at
>1000 metres into the route. Are you saying that, once I get
>half way along it, it will disappear? Yes, so, the maximum length of the z axis must be 25m. So you object can be from -25m to 25m. Try not to make it more than -100 as it can create sudden appearance if the drawing distance is 200m.
>If I've understood this correctly, to prevent this from
>happening, I'd need to build the object from the farthest
>point back (the front of this theoretical object having a
>vertex X value of -50 and the back having a vertex X value
>of 0?). To make it appear where I want it, would I also need
>to change the insertion point from 1000 to 1050 metres? It depends on whether you choose -25m to 25m or -50m to 0m.

------My favourite LUL train------
Handcoding objects – image 5
HAPPY NOW? It's not moving anymore.
It's still the same train but in another livery, that's all.

Alert | IP

Printer-friendly page | Edit | Reply | Reply With Quote | Top

Member since Apr-16-03 · 9 posts

RE: handcoding objects

OK, cool. I'll leave you alone now and go away and actually do some coding now. (Well, not actually now as work takes precedence. Bummer.)The info you've given is really helpful and has given me a real confidence boost. Very many thanks for all the help and assistance you have all afforded me.Technical Numpty

Alert | IP

Printer-friendly page | Edit | Reply | Reply With Quote | Top

Member since Apr-9-03 · 22 posts

RE: handcoding objects

I suggest the BVE Helper site for learning the basics of route coding and using Tim Corbett's CSV Commands sheet that you can fully code a BVE route.For object building I think the only site is Al Bartens Works Object tutorial.I can't remember the URLs but I think someone else can help.
====================
James Dickinson
www.brc.rr.nuHandcoding objects – image 6

Alert | IP

Printer-friendly page | Edit | Reply | Reply With Quote | Top

Member since Apr-5-03 · 42 posts

RE: handcoding objects

Handcoding objects – image 7

I'll never learn to code, i'm waiting for rb.
I'm not trying to be lazy but it's all numbers and commas for me

Alert | IP

Printer-friendly page | Edit | Reply | Reply With Quote | Top

Member since Apr-8-03 · 13 posts

RE: handcoding objects

Click to send message via ICQ

Handcoding objects – image 8

LAST EDITED ON Apr-20-03 AT 02:05 PM (EDT)

Same for me - I tried the tutorial, but it wasn't sinking in for me, I'm happy being a driver!
With Routebuilder out soon, I'll have a crack at it, and see how stuff turns out. When I get time, I'll look into making objects - it looks a little simpler than route coding, because theres not as many commands to worry about I could be wrong of course (hence the underline), but I hope I'm not!

Alert | IP

Printer-friendly page | Edit | Reply | Reply With Quote | Top

Charter Member · 2158 posts

RE: handcoding objects

>I'll never learn to code, i'm waiting for rb.
>I'm not trying to be lazy but it's all numbers and commas
>for me RB can only code routes, not objects.

------My favourite LUL train------
Handcoding objects – image 9
HAPPY NOW? It's not moving anymore.
It's still the same train but in another livery, that's all.

Alert | IP

Printer-friendly page | Edit | Reply | Reply With Quote | Top

Member since Apr-7-03 · 21 posts

RE: handcoding objects

The tutorial at BVE Helper site doesn't get to building objects,but,as previously said,Al Bartens does and he also has an article on creating people objects,which also helps understanding other objects,in Woodbridges Train Sim magazine at trainsimmodeler.com.Click on BVE to see article.

Alert | IP

Printer-friendly page | Edit | Reply | Reply With Quote | Top

Member since Apr-14-03 · 89 posts

RE: handcoding objects

I am an experienced route and object builder but, I think there should be a wal to make smooth tube tunnels usings the Cylinder command. If you use a minus for the raius you get an open ended cylinder, but if you try to move through it is disappears, cant we get the inner face to show up as well? (or instead of the outer face)This way we would get smooth tube tunnels and other tunnels for that matter!

Joshim,
currently constructing the DLR Route for BVE check out MY NEW WEBSITE http://joshimsbveroutes.gamehorizons.net/

Alert | IP

Printer-friendly page | Edit | Reply | Reply With Quote | Top

Restored from the Train-Sim.Com archive, captured May 7, 2003. About this archive.