[phpBB Debug] PHP Notice: in file /viewtopic.php on line 969: Use of undefined constant gu - assumed 'gu' (this will throw an Error in a future version of PHP)
[phpBB Debug] PHP Notice: in file /viewtopic.php on line 969: Use of undefined constant personal_album_id - assumed 'personal_album_id' (this will throw an Error in a future version of PHP)
[phpBB Debug] PHP Notice: in file /viewtopic.php on line 969: Use of undefined constant gu - assumed 'gu' (this will throw an Error in a future version of PHP)
[phpBB Debug] PHP Notice: in file /viewtopic.php on line 969: Use of undefined constant user_images - assumed 'user_images' (this will throw an Error in a future version of PHP)
Speed Dreams Community • View topic - Start from pit lane

Start from pit lane

Information about the inner-side magic

Moderator: kilo

Start from pit lane

Postby c00ler » Thu Apr 25, 2013 11:42 am

Hi guys
First of all thank you to all of you for this nice simulator. Great work !

Now my question:
I want to implement feature "Start from pit lane", i found that cars placed on tracks in initStartingGrid (raceinit.cpp)
so what i have done:
1 swapped calls initStartingGrid and initPits in ReInitCars
2 replace this code in initStartingGrid

startpos = ReInfo->track->length - (d1 + (i / rows) * d2 + (i % rows) * d3);
tr = a + b * ((i % rows) + 1) / (rows + 1);
curseg = ReInfo->track->seg; /* last segment */
while (startpos < curseg->lgfromstart) {
curseg = curseg->prev;
}

ts = startpos - curseg->lgfromstart;
car->_trkPos.seg = curseg;
car->_trkPos.toRight = tr;
with

//later in will be a key in xml file
if (1 == 1) {
ts = car->_pit->pos.seg->lgfromstart;

car->_trkPos.seg = car->_pit->pos.seg;
car->_trkPos.toLeft = car->_pit->pos.toLeft;
car->_trkPos.toRight = car->_pit->pos.toRight;

} else {
startpos = ReInfo->track->length - (d1 + (i / rows) * d2 + (i % rows) * d3);
tr = a + b * ((i % rows) + 1) / (rows + 1);
curseg = ReInfo->track->seg; /* last segment */
while (startpos < curseg->lgfromstart) {
curseg = curseg->prev;
}

ts = startpos - curseg->lgfromstart;
car->_trkPos.seg = curseg;
car->_trkPos.toRight = tr;
}

and after that in aalborg my car (driver simplix) start from
468.442780:472.048004:10.401583 (s->cars[i]->pub.DynGCg.pos.x : s->cars[i]->pub.DynGCg.pos.y : s->cars[i]->pub.DynGCg.pos.z)
segment.id = 9
segment.name = 10 (segment name from aalborg.xml)

but when a car goes to pit it stop at
271.957123:472.596558:3.761633
segment.id = 357
segment.name = 403 (segment name from aalborg.xml)

Its seems that i have miss something but cant understand what is it

Yes i understand that answer can be found in simplix driver code
But if someone what to help me to explain why its different (i mean the meaning of that) i will be very happy :)

Thank you
c00ler
 
Posts: 2
Joined: Thu Apr 25, 2013 11:29 am

Re: Start from pit lane

Postby c00ler » Sat Apr 27, 2013 4:55 pm

I found were i was wrong, this is a correct code:

--------------------------
//later it will be a key in xml file
if (1 == 1) {
ts = car->_pit->pos.toStart;

car->_trkPos.seg = car->_pit->pos.seg;
car->_trkPos.toLeft = car->_pit->pos.toLeft;
car->_trkPos.toRight = car->_pit->pos.toRight;
curseg = car->_pit->pos.seg;
} else {
startpos = ReInfo->track->length - (d1 + (i / rows) * d2 + (i % rows) * d3);
tr = a + b * ((i % rows) + 1) / (rows + 1);
curseg = ReInfo->track->seg; /* last segment */
while (startpos < curseg->lgfromstart) {
curseg = curseg->prev;
}

ts = startpos - curseg->lgfromstart;
car->_trkPos.seg = curseg;
car->_trkPos.toRight = tr;
}
--------------------------

and now start position is (global x: global y:global z):
318.136261:472.038452:7.029230

when car stopped in pit at (global x:global y:global z):
325.228394:473.698608:7.753133
c00ler
 
Posts: 2
Joined: Thu Apr 25, 2013 11:29 am

Re: Start from pit lane

Postby roosttylor » Tue Mar 31, 2015 4:43 am

I've often seen video of two players racing, side by side with the full pedals and racing seat etc., but there's usually two computers providing the experience as far as I know. Would be a bit of good publicity to demonstrate such a feature. Maybe in 3.0?
ahsan
roosttylor
 
Posts: 1
Joined: Tue Mar 31, 2015 4:16 am


Return to SD Physics & Internals

Who is online

Users browsing this forum: No registered users and 14 guests