Skidmarks
-
- Posts: 27
- Joined: Thu Sep 15, 2005 3:22 pm
Skidmarks
I'm trying to implement skidmarks into my little racing-game but I'm having problems. I can determine tire contacts and store them when the currect wheel is skidding but I don't know how to continue. I can also add these point after a relatively similar distance - if the contact is too near to the last one, it wont be added. I have read about decals but haven't had much success implementing them or maby there are some other methods for dealing this.
Some screenshots from the debug display (even Chuck got onto the picture ):
Any help is very welcome
Some screenshots from the debug display (even Chuck got onto the picture ):
Any help is very welcome
wow nice phsics and car model. also store the wheel rotation at that moment of time at every "skid node" then add a rectangular mesh (planar) in that position with that rotaion with the same normal as the ground. if these skid nodes are equidistant as you have already programmed them to be, you wont have to link each skid rectangle(ie join their vertices up)
You have done most of the hard stuff, for aligning to the normal look at the tech demo source, look at how the particle for the impacts is aligned to the normal of the collided triangle.
You have done most of the hard stuff, for aligning to the normal look at the tech demo source, look at how the particle for the impacts is aligned to the normal of the collided triangle.
-
- Posts: 27
- Joined: Thu Sep 15, 2005 3:22 pm
I am having problems with the math. First of all arranging the decals by wheel positions wouldnt work - if your wheels are turned out but the car is going straight, the decals would not be rotated correctly. I'm thinking of calculating the angle by the previous decal position, so they would face each other, but I haven't succeded to do it even in 2d as if the ground was always even. I was thinking something like this:
But this wouldn't apply in 3d anyway. I know I suck with 3d math
Any ideas?
But this wouldn't apply in 3d anyway. I know I suck with 3d math
Any ideas?
-
- Posts: 326
- Joined: Wed Dec 14, 2005 10:08 pm
kallaspriit,
That is my map and that is the vehicle I used in my game. I guess part of the code it's mine too.
I'm intending to make this project ( Supremacy Errands) commercial in the future, so please DO NOT distribute your game with my map.
You can use it for testing purposes though. I just wanted to make these things clear.
Thank you.
That is my map and that is the vehicle I used in my game. I guess part of the code it's mine too.
I'm intending to make this project ( Supremacy Errands) commercial in the future, so please DO NOT distribute your game with my map.
You can use it for testing purposes though. I just wanted to make these things clear.
Thank you.
-
- Posts: 27
- Joined: Thu Sep 15, 2005 3:22 pm
Assuming you can easily get the normal of the terrain and the direction that the tire was sliding, you should be able to easily orient a decal to line up correctly.
For efficiency you will probably want to make one scene node that has a mesh buffer that is used to manage the skid marks. Once the vertices are setup you don't need to touch them. After some time, or maybe after so many decals are laid out, you will need to start recycling vertices in the mesh buffer.
Code: Select all
// parameter is the position of the start of the skid mark
const core::vector3df pos1;
// parameter is the position at the end of the skid mark
const core::vector3df pos2;
// parameter is the normalized normal of the plane the skid mark is on
const core::vector3df normal;
// parameter is the width scale factor to apply to each decal
const f32 width;
// direction of the skid
core::vector3df direction(pos2 - pos1);
direction.normalize();
// vector from pos1 to side of decal
core::vector3df side = normal.crossProduct(direction);
// scale the width vector to make decal wider/narrower
side *= width;
// you could set A and B to be the last to coordinates of the previous skid mark section.
// that would avoid splitting or overlap when a skid section is rotated. it also complicates the code a little.
const core::vector3df A = pos1 - side;
const core::vector3df B = pos1 + side;
const core::vector3df C = pos2 + side;
const core::vector3df D = pos2 - side;
const video::SColor color(255, 255, 255, 255);
Vertices[0] = video::S3DVertex(A.X, A.Y, A.Z, normal.X, normal.Y, normal.Z, color, 0.f, 1.f);
Vertices[1] = video::S3DVertex(B.X, B.Y, B.Z, normal.X, normal.Y, normal.Z, color, 1.f, 1.f);
Vertices[2] = video::S3DVertex(C.X, C.Y, C.Z, normal.X, normal.Y, normal.Z, color, 1.f, 0.f);
Vertices[3] = video::S3DVertex(D.X, D.Y, D.Z, normal.X, normal.Y, normal.Z, color, 0.f, 0.f);
I have made a similar scenenode, but never finished it coz i have a math problem i cannot solve. I need to store a new point only if the angle btw the last two points and the current tire position is greater than, lets say, 5 degrees. This way, stored points become near when turning a curve and far when car dont steer. Currently, stored points is all the same distance. This makes storing a great number of points if you choose a near distance or a poor quality decal if you choose a far distance.
If you interested, i can share my code.
If you interested, i can share my code.
-
- Posts: 27
- Joined: Thu Sep 15, 2005 3:22 pm
I solved all ( known ) problems i got. You can download RibbonTrailSceneNode here
http://br.geocities.com/paulo_cmv/
You can find a lot of info at top of .h file. Feel free to test others scenenodes i have written. CLODSceneNode, CQuadTreeSceneNode, CLensFlareSceneNode.
http://br.geocities.com/paulo_cmv/
You can find a lot of info at top of .h file. Feel free to test others scenenodes i have written. CLODSceneNode, CQuadTreeSceneNode, CLensFlareSceneNode.
-
- Posts: 27
- Joined: Thu Sep 15, 2005 3:22 pm
-
- Posts: 27
- Joined: Thu Sep 15, 2005 3:22 pm
I'm unable to get it to work
I have tried several ways but nothing seems to work. At best I got it to display a debug line between the points added but no textures. This is basicly the demo shown in the header file that does not work for me (skid.jpg is a 64x64 image of skidmark):
I must be missing something
I have tried several ways but nothing seems to work. At best I got it to display a debug line between the points added but no textures. This is basicly the demo shown in the header file that does not work for me (skid.jpg is a 64x64 image of skidmark):
Code: Select all
RibbonTrailSceneNode* skid = new RibbonTrailSceneNode(iDevice, sManager->getRootSceneNode());
skid->setMaterialTexture(0, vDriver->getTexture("textures/skid.jpg"));
skid->setPoint1(core::vector3df(5, 0, 0));
skid->setPoint2(core::vector3df(-5, 0, 0));
skid->setMaxDistance(3);
skid->setStartingAlpha(0);
skid->setShowDebug(true);
skid->setEnabled(true);
-
- Posts: 27
- Joined: Thu Sep 15, 2005 3:22 pm
I'm using the latest version of irrlicht and the textures and everything are very low quality because my pc is a piece of ****
Anyway I posted a working demo of it in NGD forums in this thread
Or if you don't want to register to see it, then it went like this:
During my testing with newton and the vehicle component, I made a small application simulating a vehicle. Basicly you can just drive around a small city . It features a well-tuned car with simulated manual gearbox including torque curve, automatic clutch, optional traction control and so on. It's just 5,52 MB so give it a try and tell me what do you think
The controls are:
ESC - exit
C - toggle follow camera
R - reset car position
P - place car at the start pos
T - toggle traction control
N - make a new vehicle
F1 - toggle show collisions
F2 - toggle show contacts
F3 - toggle show data
F4 - make a pile of boxes
F5 - throw a box
F6 - create a big terrain under the city (take a while)
wheel mouse - change car power (press F3 to see the percent)
arrows - steer and accelerate/brake the car
A - shift up
Z - shift down
ENTER - change drive type (4WD/FWD/RWD) (press F3 to see current)
SPACE - handbrake
Download | 5,52MB
Enjoy
Anyway I posted a working demo of it in NGD forums in this thread
Or if you don't want to register to see it, then it went like this:
During my testing with newton and the vehicle component, I made a small application simulating a vehicle. Basicly you can just drive around a small city . It features a well-tuned car with simulated manual gearbox including torque curve, automatic clutch, optional traction control and so on. It's just 5,52 MB so give it a try and tell me what do you think
The controls are:
ESC - exit
C - toggle follow camera
R - reset car position
P - place car at the start pos
T - toggle traction control
N - make a new vehicle
F1 - toggle show collisions
F2 - toggle show contacts
F3 - toggle show data
F4 - make a pile of boxes
F5 - throw a box
F6 - create a big terrain under the city (take a while)
wheel mouse - change car power (press F3 to see the percent)
arrows - steer and accelerate/brake the car
A - shift up
Z - shift down
ENTER - change drive type (4WD/FWD/RWD) (press F3 to see current)
SPACE - handbrake
Download | 5,52MB
Enjoy
kallaspriit:
means you using our alpha at startup with value 0 ( completely transparent ).
you can use a starting alpha greather then 0, i sugest 100..200
also, i only tested it in DirectX, but i guess it will work well in OpenGL
Code: Select all
skid->setStartingAlpha(0);
you can use a starting alpha greather then 0, i sugest 100..200
also, i only tested it in DirectX, but i guess it will work well in OpenGL