added billboards

This commit is contained in:
Sylvain PILLOT 2022-03-12 21:56:55 +01:00
parent 1694aeb3ee
commit 954fa72ed7
16 changed files with 180 additions and 51 deletions

View File

@ -40,6 +40,10 @@ set(ASSETS_cg
assets-cg/clouds/sky3.png
assets-cg/backgrnd/mountain.png
assets-cg/backgrnd/treeline.png
assets-cg/billboard/leftturn.png
assets-cg/billboard/rightturn.png
assets-cg/billboard/uphill.png
assets-cg/billboard/downhill.png
)
fxconv_declare_assets(${ASSETS_cg} WITH_METADATA)

View File

@ -2,24 +2,34 @@
<CodeBlocks_layout_file>
<FileVersion major="1" minor="0" />
<ActiveTarget name="Release" />
<File name="src/include/segment.h" open="0" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/parameters.h" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="574" topLine="11" />
<Cursor1 position="429" topLine="0" />
</Cursor>
</File>
<File name="src/src/camera.cc" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/main.cc" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="1" zoom_2="0">
<Cursor>
<Cursor1 position="370" topLine="0" />
<Cursor1 position="9106" topLine="345" />
</Cursor>
</File>
<File name="src/colors.h" open="0" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="352" topLine="0" />
</Cursor>
</File>
<File name="src/src/cars.cc" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1019" topLine="11" />
</Cursor>
</File>
<File name="src/include/circuit.h" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="645" topLine="30" />
<Cursor1 position="645" topLine="43" />
</Cursor>
</File>
<File name="src/include/camera.h" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/src/clouds.cc" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="221" topLine="0" />
<Cursor1 position="203" topLine="0" />
</Cursor>
</File>
<File name="CMakeLists.txt" open="1" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
@ -37,41 +47,26 @@
<Collapse line="76" />
</Folding>
</File>
<File name="src/parameters.h" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="398" topLine="0" />
</Cursor>
</File>
<File name="src/colors.h" open="0" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="352" topLine="0" />
</Cursor>
</File>
<File name="src/main.cc" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="1" zoom_2="0">
<Cursor>
<Cursor1 position="15894" topLine="490" />
</Cursor>
</File>
<File name="src/include/clouds.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="306" topLine="0" />
</Cursor>
</File>
<File name="src/src/circuit.cc" open="1" top="1" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="16690" topLine="486" />
</Cursor>
</File>
<File name="src/src/clouds.cc" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="203" topLine="0" />
</Cursor>
</File>
<File name="src/include/drawstuff.h" open="0" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="622" topLine="0" />
</Cursor>
</File>
<File name="src/src/camera.cc" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="370" topLine="0" />
</Cursor>
</File>
<File name="src/include/cars.h" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="443" topLine="0" />
</Cursor>
</File>
<File name="src/src/circuit.cc" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="6693" topLine="225" />
</Cursor>
</File>
<File name="src/fixed.h" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="778" topLine="0" />
@ -79,17 +74,22 @@
</File>
<File name="src/src/segment.cc" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="2" zoom_2="0">
<Cursor>
<Cursor1 position="203" topLine="0" />
<Cursor1 position="230" topLine="30" />
</Cursor>
</File>
<File name="src/include/cars.h" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/include/segment.h" open="1" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="443" topLine="0" />
<Cursor1 position="539" topLine="11" />
</Cursor>
</File>
<File name="src/src/cars.cc" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/include/camera.h" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1019" topLine="11" />
<Cursor1 position="221" topLine="0" />
</Cursor>
</File>
<File name="src/include/clouds.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="306" topLine="0" />
</Cursor>
</File>
</CodeBlocks_layout_file>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

@ -0,0 +1,5 @@
*.png:
type: bopti-image
profile: p4
name_regex: (.*)\.png \1

Binary file not shown.

After

Width:  |  Height:  |  Size: 762 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 761 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -47,11 +47,16 @@ enum Decoration
OAKTREE = 2,
CACTUS = 3,
BIGLEAF = 4,
SMALLLEAF = 5
SMALLLEAF = 5,
LEFTTURN = 6,
RIGHTTURN = 7,
UPHILL = 8,
DOWNHILL = 9
};
void initData( void );
void createCircuit( void );
void putBillBoards( void );
void createClouds( void );
void createTraffic( void );
@ -79,6 +84,7 @@ void prepareTraffic( void );
void addStraightLine( Length l, int8_t biome );
void addCurve( Length l, CurveStrength s, CurveType t, int8_t biome );
void addHill( Length l, HillSize s, HillType t, int8_t biome );
void addCurvyHill( Length l, HillSize s, HillType t, CurveStrength cs, CurveType ct, int8_t biome );
fixed_t interpolatePositionX( double currentZ );
fixed_t interpolatePositionY( double currentZ );

View File

@ -26,10 +26,11 @@
extern bopti_image_t car1, car2, car3, car4, car5, car6, car7, car8;
extern bopti_image_t tree1, tree2, tree3, tree4, tree5, tree6;
extern bopti_image_t leftturn, rightturn, uphill, downhill;
extern bopti_image_t player;
extern bopti_image_t sky1, sky2, sky3;
extern bopti_image_t mountain;
extern bopti_image_t treeline;
extern bopti_image_t mountain, treeline;
std::vector<Segment*> circuit;
@ -256,6 +257,9 @@ int main(void)
initData( ); // Positioning of the Camera
createCircuit(); // Creates the circuit
putBillBoards();
createClouds(); // Creates the Sky and Clouds
createTraffic(); // Creates the cas
prepareDecoration(); // Prepares the multiple variations of Decoration (image scaling)

View File

@ -22,7 +22,7 @@
#define NB_CARS_TRAFFIC 100
#define MAX_SUBIMAGES_TREES 12
#define NB_TREES_TYPES 6
#define NB_TREES_TYPES 10
#define MAX_SUBIMAGES_CARS 12
#define NB_CARS_TYPES 8

View File

@ -30,6 +30,8 @@ extern bopti_image_t tree1, tree2, tree3, tree4, tree5, tree6;
extern bopti_image_t sky1, sky2, sky3;
extern bopti_image_t mountain;
extern bopti_image_t treeline;
extern bopti_image_t leftturn, rightturn, uphill, downhill;
bopti_image_t *scaledTrees[NB_TREES_TYPES][MAX_SUBIMAGES_TREES] = { 0 };
bopti_image_t *scaledCars[NB_CARS_TYPES][MAX_SUBIMAGES_CARS] = { 0 };
@ -147,7 +149,9 @@ void createCircuit( void )
*/
addStraightLine( L_VERYSHORT, PLAINS );
addCurvyHill( L_MEDIUM, H_BIG, UP_HILL, C_HARD, LEFT_CURVE, DESERT );
addStraightLine( L_VERYSHORT, DESERT );
addCurvyHill( L_MEDIUM, H_BIG, DOWN_HILL, C_HARD, RIGHT_CURVE, DESERT );
//addStraightLine( L_VERYSHORT, PLAINS );
//addStraightLine( L_VERYSHORT, DESERT );
addCurve( L_SHORT, C_HARD, LEFT_CURVE, DESERT );
@ -171,6 +175,73 @@ void createCircuit( void )
//addStraightLine( L_VERYLONG, DESERT );
};
void putBillBoards( void )
{
for (int k = 0; k<circuit.size()-3; k++ )
{
int nextcurve = circuit[k+3]->Curve;
int currentcurve = circuit[k]->Curve;
int nextslope = circuit[k+3]->Slope;
int currentslope = circuit[k]->Slope;
if (nextcurve==currentcurve && nextslope==currentslope)
{
// no turn and no hill
}
else if (nextcurve==currentcurve && nextslope!=currentslope)
{
// no turn but hill
if (nextslope>0) //uphill
{
circuit[k]->RDeco=UPHILL;
circuit[k]->LDeco=UPHILL;
}
else if (nextslope<0) //downhill
{
circuit[k]->RDeco=DOWNHILL;
circuit[k]->LDeco=DOWNHILL;
}
}
else if (nextcurve!=currentcurve && nextslope==currentslope)
{
// no turn but hill
if (nextcurve<0) //uphill
{
circuit[k]->RDeco=LEFTTURN;
circuit[k]->LDeco=LEFTTURN;
}
else if (nextcurve>0) //downhill
{
circuit[k]->RDeco=RIGHTTURN;
circuit[k]->LDeco=RIGHTTURN;
}
}
else if (nextcurve!=currentcurve && nextslope!=currentslope)
{
// no turn but hill
if (nextcurve<0) //uphill
{
circuit[k]->RDeco=LEFTTURN;
if (nextslope>0) circuit[k]->LDeco=UPHILL;
else if (nextslope<0) circuit[k]->LDeco=DOWNHILL;
}
else if (nextcurve>0) //downhill
{
circuit[k]->LDeco=RIGHTTURN;
if (nextslope>0) circuit[k]->RDeco=UPHILL;
else if (nextslope<0) circuit[k]->RDeco=DOWNHILL;
}
}
if (nextcurve<0 && currentcurve!=nextcurve) circuit[k]->RDeco=LEFTTURN;
if (nextcurve>0 && currentcurve!=nextcurve) circuit[k]->LDeco=RIGHTTURN;
}
}
void createClouds( void )
{
@ -317,6 +388,40 @@ void addHill( Length l, HillSize s, HillType t, int8_t biome )
}
void addCurvyHill( Length l, HillSize s, HillType t, CurveStrength cs, CurveType ct, int8_t biome )
{
double lastZ=0;
int16_t lastY=0;
uint16_t lastIndex = circuit.size();
if (lastIndex!=0)
{
lastY=circuit[lastIndex-1]->wY;
lastZ=circuit[lastIndex-1]->wZ+SEGMENT_LENGTH;
}
srand( rtc_ticks() );
for( int i=0; i<l; i++)
{
//Segment *s=new Segment( i );
int deco = rand() % 4;
Segment *seg;
if (deco==0) seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, cs*ct, s*t, -1, -1 );
else if (deco==1) seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, cs*ct, s*t, -1, PALMTREE );
else if (deco==2) seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, cs*ct, s*t, OAKTREE, -1 );
else if (deco==3) seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, cs*ct, s*t, OAKTREE, PALMTREE );
if (seg!=nullptr)
{
seg->environment = biome;
circuit.push_back( seg );
}
}
}
void projectCircuitFP( void )
{
for( int i=0; i<circuit.size(); i++)
@ -501,11 +606,16 @@ void prepareDecoration( void )
scale=3.0f/((float) (i+2));
if(k==0) src = &tree1;
else if(k==1) src = &tree2;
else if(k==2) src = &tree3;
else if(k==3) src = &tree4;
else if(k==4) src = &tree5;
else src = &tree6;
else if (k==1) src = &tree2;
else if (k==2) src = &tree3;
else if (k==3) src = &tree4;
else if (k==4) src = &tree5;
else if (k==5) src = &tree6;
else if (k==6) src = &leftturn;
else if (k==7) src = &rightturn;
else if (k==8) src = &uphill;
else src = &downhill;
int width = (int) ((float) src->width * scale);
int height = (int) ((float) src->height * scale);