Creating Cars - Tutorial

Discussion in 'X-Motor Racing' started by Eugene Cojocar, Aug 5, 2010.

Thread Status:
Not open for further replies.
  1. Eugene Cojocar XMR Developer

    Licensed Member

    A single thread for tutorial of creating cars.
    The same will be done for creating tracks.

    XMR Editor allows prepare tracks and cars and insert into the game.
    You can import any 3d model (whole track/car or single object like tree, house, driver body, tire etc) from 3dmax. You can also create your own track without 3d max.
    Tracks and cars are saved in different ways.
    File types.
    .tdo – single or some objects of track/car/object
    .wld – world project that contains system info about scene.
    .we – world environment that contains all materials, markers, cameras, lines etc
    .trc – texture packet. All textures must be as .tga files.
    .mtl – materials of scene/car that can be imported/exported
    .mss – markers of scene/car that can be imported/exported



    Typical algorithm of creating car:
    1. Creating 3d model with textures in 3d max, but without materials as always
    2. Export car from 3d max as .tdo for XMR Editor
    3. Setup graphics materials for all objects of car
    4. Setup physics properties for all bodies
    5. Preparing suspension and wheels.
    6. Preparing cockpit.
    7. Export to game.

    You can download ready models of R430 and export them to XMR.
    It's better to understand it when you have a sample. Packed with the 7-Zip.

    http://www.mediafire.com/?ocwcmpa7d593bsc
  2. Eugene Cojocar XMR Developer

    Licensed Member

    Open any .tdo file and work with it.

    If we want select and object make sure that these two buttons are pressed to select objects by the mouse.

    [IMG]



    You must apply textures to all objects if you can’t see textured objects.
    XMR Editor can automatically load textures if they in .tga format and located at the same directory where your 3ds file.
    You can add all textures manually also.
    1. Create sub-directory \Textures in your car’s working directory.
    2. Copy all .tga files (sizes must be 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096 pixels) to this directory.
    3. Copy files texPacker.exe and tpack.ini from \\XMREditor\Textures Utility to this directory.
    4. Run texPacker.exe. It creates MyPack.trc or any file .trc that can be loaded into XME Editor. You can define your own name of texture packet in tpack.ini file.
    5. You can see something similar if textures are not applied

    [IMG]

    6. Open Texture Manager from menu.

    [IMG]

    7. Open you texture pack that your just created - MyPack.trc.

    [IMG]

    8. Open you texture pack that your just created - MyPack.trc.

    [IMG]

    9. Select any texture you want to apply to object.

    [IMG]

    10. Then select object you want to apply current texture and open context menu by clicking the right mouse button.

    [IMG]

    11. After that you can see textured object but with ambient lighting only.

    [IMG]


    12. Then turn off Wire Frame and update normals.

    [IMG]

    13. Here's the view when normals are updated.

    [IMG]

    Using these steps you can apply textures to each object you want.
  3. Eugene Cojocar XMR Developer

    Licensed Member

    The next step is adjusting all graphics materials go get a realistic look as possible.

    1. Select any object to assign graphics material. Right click to open context menu and select Properties to open properties dialog.

    [IMG]

    2. Select any material for the selected object from the list Common Material Index on the right side of the dialog. You can assign any materials from this list. XMR supports up to 160 materials. I think it’s quite enough.

    [IMG]

    3. Then we need to adjust materials. At first they have default values but we can adjust them as we want. Open from the menu Materials and Global lighting dialog.

    [IMG]

    4. Select any material you want to adjust.

    [IMG]

    5. Select any component of the material and define its value as you want. You can see the result real-time. Each material has components: Ambient, Diffuse, Specular, Emmision, HDRAmbient, HDRDiffuse, HDRSpecular, HDREmissive, fPower, Reflection Coeff, Refraction Coeff, Fresnel Pow and Fresnel Part.

    [IMG]

    6. You can turn on CarMode to see reflections as they look in the game.

    [IMG]

    You can also import and export materials from the other cars and tracks.
  4. Eugene Cojocar XMR Developer

    Licensed Member

    We need add transparency for the glass objects. If we want transparency we must assign texture with alpha channel (32 bits per pixel).
    1. Select any object to add transparency and open Set Polygons Options dialog from the menu.

    [IMG]

    2. Turn on Change in Graphics material and select FVF_TEXTURE_GLASS_LIGHTYES. This is additional graphics data that define how to render polygons.

    [IMG]

    3. You can see the result here with transparent polygons.

    [IMG]
  5. Eugene Cojocar XMR Developer

    Licensed Member

    Besides standard graphics objects you must create some null textured objects with standard names. XMR uses shadow maps and stencil shadows together.

    These objects are shadow casters of the stencils shadows.
    shadowvolume – shadow caster for the body
    shadowvolume_lf – shadow caster for the left front wheel
    shadowvolume_rf – shadow caster for the right front wheel
    shadowvolume_rr – shadow caster for the right rear wheel
    shadowvolume_lr – shadow caster for the left rear wheel

    [IMG]


    These objects are shadow maps.
    shadowmap_body - shadow map for the body
    shadowmap_lf - shadow map for the left front wheel
    shadowmap_rf - shadow map for the right front wheel
    shadowmap_rr - shadow map for the right rear wheel
    shadowmap_lr - shadow map for the left rear wheel

    [IMG]

    When all graphics objects are ready we must prepare all physics data.
    1. mark all revolving objects, like tires, rims, bolts etc
    2. mark all suspension objects
    3. mark all brake blocks
    4. define centres of wheels
    5. define joint points – where body and wheel are linked
    6. define markers for cockpit objects like steering wheel, tachometer arrow etc
    7. define identifiers for the suspension
  6. Eugene Cojocar XMR Developer

    Licensed Member

    Turn on Draw Centre of Mass from the menu.

    [IMG]

    Select object and right click to open context menu. Select Properties.

    [IMG]

    Select Physic page and turn on Active.
    Select LF_Wheel from the drop-down list and press OK.

    [IMG]

    If the object has something physics flag you can see a blue cross.

    [IMG]

    Hide this object. It’s more comfortable to work when some objects are hidden.

    [IMG]

    Select next object and repeat these steps.

    [IMG]

    You can have a look at the sample \\XMREditor\ Samples\ Cars\HybridCar
    It contains all objects and physics settings.

    You can download ready models of R430 and export them to XMR.
    Or just study them.

    http://www.mediafire.com/?ocwcmpa7d593bsc
  7. Eugene Cojocar XMR Developer

    Licensed Member

    We are going to add some markers. Marker is just a point with string information.

    1. Turn on Marker String from the menu.

    [IMG]

    2. Turn on Vertex mode selection and Wire Frame (it’s more convenient to select vertex).

    [IMG]

    3. Select vertex on the center of the wheel and select Add Marker command from the menu.

    [IMG]

    4. Turn off wire frame and turn on Object mode selection. Then select just created markers on open right-click to open context menu. Select properties.

    [IMG]

    5. Name the marker as “left_front_wheel”. You can define new coordinates here. left_front_wheel is the center of the rotation for the left front wheel.

    [IMG]

    6. Then create new markers and name it as “left_front_wheel_joint”. left_front_wheel_joint is a point where body and wheel are linked.

    [IMG]

    7. Repeat these steps for the other wheels. After finishing you can see something like this.

    [IMG]
  8. Eugene Cojocar XMR Developer

    Licensed Member

    If external model is ready we need to prepare cockpit model.
    They are in different files. It’s more convenient to optimize them.
    1. All object of the steering wheel must have standard name – “steering_wheel”. Have a look at the example and check its names.

    [IMG]
    [IMG]

    2. Tachometer arrow object must have standard name – “tachometer_arrow”.

    [IMG]
    [IMG]

    3. The same for the speedometer arrow object – “speedometer_arrow”.

    [IMG]

    4. When all standard cockpit objects are re-named we need to define vector of the rotation axis for the each object. Vector is just two markers that define start and tip. We can use additional object to locate these markers very correctly.

    [IMG]

    These markers must have standard names.
    “steering_wheel_center” – beginning of the steering wheel axis.
    “steering_wheel_axis” – ending of the steering wheel axis.
    “tachometer_arrow_center” – beginning of the tachometer arrow axis. “tachometer_arrow_axis” – ending of the tachometer arrow axis. “speedometer_arrow_center” – beginning of the speedometer arrow axis. “speedometer_arrow_axis” – ending of the speedometer arrow axis.
    5. After finishing we can see something like this.

    [IMG]
  9. Eugene Cojocar XMR Developer

    Licensed Member

    The last thing we must do is creating camera position for cockpit.
    Create new marker and name it as “driver_head” and place it correctly.

    [IMG]

    When all models are ready we must export them into car’s directory.
    Create car’s directory in \\Data\ Cars\
    Export exterior model as “car.car”.
    Export interior model as “cockpit.car”.
    If we need ghost model we must prepare it and export as “ghost.car”.
    If we need right side driver's position we have to prepare these models and export as “car_right.car” for the exterior model and “cockpit_right.car” for the interior model.
  10. Eugene Cojocar XMR Developer

    Licensed Member

    After 3d models we need to create or copy/edit car.ini file.
    This file contains some additional info about the car.
    Name – defines name of the car.
    Carid – defines an unique id of the car, just unique number.
    Maxtachometerangle – defines max angle of tachometer in cockpit in degrees.
    Maxspeedometerangle – defines max angle of speedometer in cockpit in degrees.
    Maxspeedometervelocity – defines max velocity of speedometer in cockpit in km/h.
    Maxsteeringwheelangle - defines max angle of steering wheel in cockpit. You can also setup global max steering angle in menu.

    The same for the HUD section.

    Then you should define list of colors for the car.
    For example: color Silver 126, 141, 120
    color Red 250, 0, 0

    If you want to use customer skin instead of color then you should create textures.ini file in car’s directory and type the skin texture name for example: body_skin.tga
  11. Eugene Cojocar XMR Developer

    Licensed Member

    New sample is available at first post here.
  12. Eugene Cojocar XMR Developer

    Licensed Member

    The sample is updated. It includes damage model and new physics.
Thread Status:
Not open for further replies.