Skidmarks
-
- Posts: 27
- Joined: Thu Sep 15, 2005 3:22 pm
-
- Posts: 27
- Joined: Thu Sep 15, 2005 3:22 pm
I updated RibbonTrailSceneNode.zip at http://br.geocities.com/paulo_cmv/ with a working example, made over TerrainRendering Irrlicht sample. You can download it again for some testing.
-
- Posts: 27
- Joined: Thu Sep 15, 2005 3:22 pm
I compiled it with VC++ Express, maybe i forget to set something on compiler. I dont noticed, coz i have Net Framework installed
Youre right, file is corrupted. I will post it again tomorrow.
But its code have nothing special. You can get the code inside TerrainRendering.cpp and try to compile it by yourself. I have copied needed media inside dir. Irrlicht version is 1.1 but i think it will work with earlyer versions. Here its worked as expected.
One thing happen is that ribbon wil only be generated while scenenode move in space. If you dont move it, will never get visible. For this example i have set the node as child of camera, just in front. This way, when you move the camera, a ribbon is generated in front of camera, drawing the path you traveled. If you turn on the setShowDebug() or something, then you will see the varios boundingbox being created. Each boundingbox is frustrum-culled, for better FPS if you use large trails.
Youre right, file is corrupted. I will post it again tomorrow.
But its code have nothing special. You can get the code inside TerrainRendering.cpp and try to compile it by yourself. I have copied needed media inside dir. Irrlicht version is 1.1 but i think it will work with earlyer versions. Here its worked as expected.
One thing happen is that ribbon wil only be generated while scenenode move in space. If you dont move it, will never get visible. For this example i have set the node as child of camera, just in front. This way, when you move the camera, a ribbon is generated in front of camera, drawing the path you traveled. If you turn on the setShowDebug() or something, then you will see the varios boundingbox being created. Each boundingbox is frustrum-culled, for better FPS if you use large trails.
-
- Posts: 27
- Joined: Thu Sep 15, 2005 3:22 pm
-
- Posts: 27
- Joined: Thu Sep 15, 2005 3:22 pm
Now I got it to display the skidmarks in the right place but still not quite the way I want. The problem is that the skidmarks get somehow oriented to an axis or something.. anyway driving one way, the skidmarks get displayed correctly but heading 90 degrees from that direction, the marks become 0px wide (the width decreases more and more headed to that direction).
To explain better, here are some images (notice how it is of correct width horisontally and decreases to nothing vertically):
Any thoughts?
To explain better, here are some images (notice how it is of correct width horisontally and decreases to nothing vertically):
Any thoughts?
The way its looking, appears that you are moving the node, but not rotating it with the car. Remember the quads are created aligned btw Point1 and Point2, two vectores RELATIVE to scenenode. In demo i sent, i know this problem occur, probably coz the camera dont pass rotation to its childs ( camera getRotation() returns always 0,0,0 ). Anyway, ill take a closer look in my code...
-
- Posts: 27
- Joined: Thu Sep 15, 2005 3:22 pm
I made the car body node as the parent for testing, so there should be rotation available. Also I tried setting the rotation of the skidmarks node manually on every frame but that didn't change anything either.
This is what I'm using:
This is what I'm using:
Code: Select all
video::ITexture* tex = game->getVDriver()->getTexture("textures/skid.jpg");
skidtrail = new RibbonTrailSceneNode(game->getIDevice(), node, -1);
skidtrail->setPosition(core::vector3df(0.0f, 0.0f, 0.0f));
skidtrail->setMaterialTexture(0, tex);
skidtrail->setPoint1(core::vector3df(0.25f, -0.2f, 0.0f));
skidtrail->setPoint2(core::vector3df(-0.25f, -0.2f, 0.0f));
skidtrail->setMaxDistance(0.5f);
skidtrail->setMaxQuads(10000);
skidtrail->setStartingAlpha(100);
I have made some tests here. The problem you having is more a conceptual problem i will try to solve. As you know, quads are created by a line starting from Point1 to Point2. This line orientation is fixed to scenenode rotation. Then when your car run in right line, node will create correct skidmarks. When your car slide laterally, nodes will show wrong.
I will try to change something in my code. I guess i need a better math to calc vertex positions. If you have a good idea, please tellme
Maybe the simplest way to solve this is store the current position of node, then in the next step, orient node to view in oposite direction from stored position, instead of orienting it with vehicle node.
I will try to change something in my code. I guess i need a better math to calc vertex positions. If you have a good idea, please tellme
Maybe the simplest way to solve this is store the current position of node, then in the next step, orient node to view in oposite direction from stored position, instead of orienting it with vehicle node.
-
- Posts: 27
- Joined: Thu Sep 15, 2005 3:22 pm