Terrain dependent friction

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Hixxy
Posts: 3
Joined: Fri Jun 16, 2006 10:27 pm

Terrain dependent friction

Post by Hixxy »

For my university project we're creating a bike simulator which is a cross between an arcade game and an exercise bike where you can steer through a 3d course but have to pedal to provide your speed along the way (uphill being harder and downhill freewheeling etc).

Having figured out the whole blender-Irrlicht .x export problems it's all going well except for one feature:

Terrain dependent friction.

Instead of using a TerrainSceneNode we're creating a mesh of a terrain in Blender and texturing different uv faces differently (ie road and grass). We're using a triangle selector to determine the angle of the ground the bike is on and hence the force (and acceleration) this creates. I was then hoping to use "GetMaterial" to determine the texture of the triangle and hence use it to alter our value for friction if it's on road or grass but it seems I misunderstood the function completely.

Having searched the forums I found a post from december:

(http://irrlicht.sourceforge.net/phpBB2/ ... ap+texture)

This asks about getting the texture of a whole terrainSceneNode but no answer was found and our problem is even more specific in needing to know which texture covers which triangle.

I can use

slope_node->getMaterial(1).Texture1 = driver->getTexture("../media/test2.bmp");
slope_node->getMaterial(2).Texture1 = driver->getTexture("../media/test3.bmp");

to change all the two individual textures so was wondering if it's in any way posible to determine which ones apply to which triangles? filenames aren't a problem, all we need is simply some kind of flag (number etc) to tell the difference between the two?

Thanks in advance,

Hixxy.
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

unfortunatley, vertex and texture coordinate information is not stored within the triangles returned by a triangle selector.
I think your best option is to copy the code to the (oct-tree?) triangle selector and make a new one that stores a reference to the mesh buffer (sub-mesh) number, and the position (index of the vertex in the array) for each point added.
You can then use the mesh buffer number to check the material (and therefore texture layers), and the indices to get the texture coordinates, colour and alpha channel of each selected vertex. I would add this as an extra function rather than break the interface (for example an extra member function called getLastSelectedTriangleDetails which populates 4 integers)

I think a lot of people would find this very useful for games (different surfaces make different footstep sounds, different types of decals for bullet holes and scratches etc), so we'd be very grateful if you shared the source to such a handy new selector. :)
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
TheGameMaker
Posts: 275
Joined: Fri May 12, 2006 6:37 pm
Location: Germany

Post by TheGameMaker »

maybe, if your terrain is a recagel, you can do a second image, whith different colors, get the relatif position on the terrain and projekt it onto the images and then read the next Pixel....

Code: Select all

^ Y
|*************   lets say this ist the terrain and the 8 is the bike.
|*************   then lets say the top left pos of the terrain lays at 0;0;0
|*************   ever dot is a step of 1
|********8****   that means the bike is at position 4;9 realativ to the 
|*************   terrain. The terrain is 5; 13 big. the relativ pos of the 
|------------------>X
bike is 4/5;9/13   the result is a nummer between 0 and 1 for X and Y.
now lets say our grafik is 400*900 pixel big, then multiply the Xvalue with the pixel hight of the img and the Y value with the widht of the img. The int of this numbers are the pixelcoordinates of the bike.. 
I think the rest is easy,
TGM
Hixxy
Posts: 3
Joined: Fri Jun 16, 2006 10:27 pm

Post by Hixxy »

I've only got til wednesday to finish the code so I think using a seperate image to look up friction values will be the best solution for now unless I can get anywhere with Bitplane's suggestion in the next day or so.

I hadn't considered that the same method could be used for sounds / decals so if I have time after it's due in I might try and implement it just for personal satisfaction and if I'm succesful the I'll post the code.

Any extra pointers on how to implement the modified triangle selector would be grately appreciated.

Cheers,

Hixxy.
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

I've had a look at this and cant think of a clean way to do it without adapting the collision manager and triangle selectors, or introducing interface breaking changes. :?
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post by sudi »

Use newton it already has a material system pluged in.
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
Shakira22

Post by Shakira22 »

really ? :) :)
Post Reply