VC and more model stuff

git-svn-id: https://pioneer.svn.sourceforge.net/svnroot/pioneer/trunk@4 e632f14b-6550-0410-b89e-a82653faca30
master
jaj22 2008-06-24 23:32:50 +00:00
parent e47839a6c6
commit e7829cb3ea
9 changed files with 469 additions and 250 deletions

View File

@ -41,6 +41,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\src"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@ -61,6 +62,7 @@
<Tool
Name="VCLinkerTool"
AdditionalDependencies="sdl.lib sdlmain.lib ode.lib sigc-2.0d.lib opengl32.lib glu32.lib SDL_image.lib freetype236MT.lib"
OutputFile="..\data_win32\$(ProjectName)_debug.exe"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="2"
@ -139,6 +141,7 @@
<Tool
Name="VCLinkerTool"
AdditionalDependencies="sdl.lib sdlmain.lib ode.lib sigc-2.0.lib opengl32.lib glu32.lib SDL_image.lib freetype236MT.lib"
OutputFile="..\data_win32\$(ProjectName)_release.exe"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="2"
@ -293,6 +296,10 @@
RelativePath="..\src\ShipCpanel.cpp"
>
</File>
<File
RelativePath="..\src\ShipType.cpp"
>
</File>
<File
RelativePath="..\src\Space.cpp"
>
@ -514,6 +521,58 @@
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
<Filter
Name="sbre"
>
<File
RelativePath="..\src\sbre\brender.cpp"
>
</File>
<File
RelativePath="..\src\sbre\fastmath.h"
>
</File>
<File
RelativePath="..\src\sbre\jjtypes.h"
>
</File>
<File
RelativePath="..\src\sbre\jjvector.cpp"
>
</File>
<File
RelativePath="..\src\sbre\jjvector.h"
>
</File>
<File
RelativePath="..\src\sbre\models.cpp"
>
</File>
<File
RelativePath="..\src\sbre\primfunc.cpp"
>
</File>
<File
RelativePath="..\src\sbre\sbre.h"
>
</File>
<File
RelativePath="..\src\sbre\sbre_anim.h"
>
</File>
<File
RelativePath="..\src\sbre\sbre_int.h"
>
</File>
<File
RelativePath="..\src\sbre\simtriang.cpp"
>
</File>
<File
RelativePath="..\src\sbre\transp.cpp"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>

View File

@ -6,7 +6,7 @@
#include "sbre_int.h"
#include "sbre_anim.h"
float ResolveAnim (ObjParams *pObjParam, Uint16 type)
float ResolveAnim (ObjParams *pObjParam, uint16 type)
{
const AnimFunc *pFunc = pAFunc+type;
float anim = pObjParam->pAnim[pFunc->src];
@ -92,6 +92,7 @@ static void ResolveVertices (Model *pMod, Vector *pRes, ObjParams *pObjParam)
}
static float g_dn, g_df;
static int g_wireframe = 0;
void sbreSetViewport (int w, int h, int d, float zn, float zf, float dn, float df)
{
@ -128,18 +129,28 @@ void sbreSetDirLight (float *pColor, float *pDir)
glLightfv (GL_LIGHT0, GL_SPECULAR, pColor4);
}
void sbreSetWireframe (int val)
{
g_wireframe = val;
}
void SetGeneralState ()
{
float ambient[4] = { SBRE_AMB, SBRE_AMB, SBRE_AMB, 1.0f };
glLightModelfv (GL_LIGHT_MODEL_AMBIENT, ambient);
glDisable (GL_TEXTURE_2D);
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
glFrontFace (GL_CW);
glEnable (GL_CULL_FACE);
glEnable (GL_DEPTH_TEST);
if (g_wireframe) {
glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
glDisable (GL_CULL_FACE);
} else {
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
glEnable (GL_CULL_FACE);
}
glDisableClientState (GL_TEXTURE_COORD_ARRAY);
glDisableClientState (GL_COLOR_ARRAY);
}
@ -201,13 +212,13 @@ void sbreRenderModel (Vector *pPos, Matrix *pOrient, int model, ObjParams *pPara
pModel->pNumVtx = (int *) calloc (pModel->numCache, sizeof(int));
pModel->pNumIdx = (int *) calloc (pModel->numCache, sizeof(int));
pModel->ppVCache = (Vector **) calloc (pModel->numCache, sizeof(Vector *));
pModel->ppICache = (Uint16 **) calloc (pModel->numCache, sizeof(Uint16 *));
pModel->ppICache = (uint16 **) calloc (pModel->numCache, sizeof(uint16 *));
}
SetGeneralState ();
SetOpaqueState ();
Uint16 *pData = pModel->pData;
uint16 *pData = pModel->pData;
while (*pData != PTYPE_END)
{
pData += pPrimFuncTable[*pData & 0xff] (pData, pModel, &rstate);
@ -217,4 +228,6 @@ void sbreRenderModel (Vector *pPos, Matrix *pOrient, int model, ObjParams *pPara
SetTransState ();
RenderTransparencies (&rstate);
}
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
glEnable (GL_CULL_FACE);
}

View File

@ -2,5 +2,9 @@
#define __JJTYPES_H__
#include <SDL_stdinc.h>
typedef Uint32 uint32;
typedef Uint16 uint16;
typedef Uint8 uint8;
#endif

View File

@ -1,6 +1,7 @@
#include "sbre_int.h"
#include "sbre_anim.h"
const int SUB_DISH = 2;
const int SUB_NOSEWHEEL = 3;
const int SUB_WING = 4;
const int SUB_NACELLE = 5;
@ -23,7 +24,7 @@ static PlainVertex tetravtx1[] = {
static CompoundVertex tetravtx2[] = {
{ VTYPE_CROSS, { 0, 1, 2, -1, -1 } }, // dummy
};
static Uint16 tetradata[] = {
static uint16 tetradata[] = {
PTYPE_MATFIXED, 100, 0, 100, 0, 0, 0, 100, 0, 0, 0,
PTYPE_TRIFLAT, 6, 7, 8,
PTYPE_TRIFLAT, 6, 8, 9,
@ -42,7 +43,7 @@ static PlainVertex circlevtx1[] = {
static CompoundVertex circlevtx2[] = {
{ VTYPE_NORM, { 6, 7, 8, -1, -1 } }, // dummy
};
static Uint16 circledata[] = {
static uint16 circledata[] = {
PTYPE_MATANIM, AFUNC_THRUSTPULSE,
0, 0, 0, 0, 0, 0, 100, 50, 50, 100,
0, 0, 0, 0, 0, 0, 100, 0, 0, 50,
@ -61,7 +62,7 @@ static PlainVertex cylvtx1[] = {
static CompoundVertex cylvtx2[] = {
{ VTYPE_NORM, { 6, 7, 8, -1, -1 } },
};
static Uint16 cyldata[] = {
static uint16 cyldata[] = {
PTYPE_MATFIXED, 100, 0, 100, 0, 0, 0, 100, 0, 0, 0,
// PTYPE_CYLINDER, 0, 8, 6, 7, 20, 2000,
PTYPE_TUBE, 0, 8, 6, 7, 20, 2000, 1000,
@ -89,7 +90,7 @@ static CompoundVertex nwunitvtx2[] = {
{ VTYPE_ANIMHERM, { 9, 11, 12, 13, AFUNC_GFLAP } }, //
{ VTYPE_ANIMLIN, { 2, 1, -1, -1, AFUNC_GEAR } }, // gear y axis
};
static Uint16 nwunitdata[] = {
static uint16 nwunitdata[] = {
PTYPE_MATFIXED, 20, 20, 20, 0, 0, 0, 100, 0, 0, 0,
PTYPE_QUADFLAT | RFLAG_XREF, 8, 6, 7, 9, // flap internal
@ -117,7 +118,7 @@ static PlainVertex nosewheelvtx1[] = {
static CompoundVertex nosewheelvtx2[] = {
{ VTYPE_CROSS, { 0, 1, 2, -1, -1 } }, // dummy
};
static Uint16 nosewheeldata[] = {
static uint16 nosewheeldata[] = {
PTYPE_MATFIXED, 50, 50, 50, 100, 100, 100, 200, 0, 0, 0,
PTYPE_CYLINDER, 0, 8, 6, 8, 2, 40,
PTYPE_CYLINDER, 1, 8, 7, 8, 2, 50,
@ -147,7 +148,7 @@ static CompoundVertex mwunitvtx2[] = {
{ VTYPE_ANIMHERM, { 9, 11, 12, 13, AFUNC_GFLAP } }, //
{ VTYPE_ANIMLIN, { 2, 1, -1, -1, AFUNC_GEAR } }, // gear y axis
};
static Uint16 mwunitdata[] = {
static uint16 mwunitdata[] = {
PTYPE_MATFIXED, 20, 20, 20, 0, 0, 0, 100, 0, 0, 0,
PTYPE_QUADFLAT | RFLAG_XREF, 8, 6, 7, 9, // flap internal
@ -179,7 +180,7 @@ static PlainVertex mainwheelvtx1[] = {
static CompoundVertex mainwheelvtx2[] = {
{ VTYPE_CROSS, { 0, 1, 2, -1, -1 } }, // dummy
};
static Uint16 mainwheeldata[] = {
static uint16 mainwheeldata[] = {
PTYPE_MATFIXED, 50, 50, 50, 100, 100, 100, 200, 0, 0, 0,
PTYPE_CYLINDER, 0, 8, 6, 8, 2, 40,
@ -210,7 +211,7 @@ static PlainVertex nacellevtx1[] = {
static CompoundVertex nacellevtx2[] = {
{ VTYPE_CROSS, { 0, 1, 2, -1, -1 } }, // dummy
};
static Uint16 nacelledata[] = {
static uint16 nacelledata[] = {
PTYPE_MATFIXED, 100, 0, 100, 0, 0, 0, 100, 0, 0, 0,
PTYPE_COMPSMOOTH | RFLAG_XREF, 0, 5, 6, 2, 8, 1,
COMP_HERMITE, 11, 3, 13, 15,
@ -290,7 +291,7 @@ static CompoundVertex shipvtx2[] = {
{ VTYPE_NORM, { 12, 8, 6, -1, -1 } }, // 55, right text normal
};
static Uint16 shipdata[] = {
static uint16 shipdata[] = {
PTYPE_MATFIXED, 100, 0, 100, 0, 0, 0, 100, 0, 0, 0,
PTYPE_QUADFLAT, 7, 6, 8, 9, // top
PTYPE_QUADFLAT, 13, 11, 15, 17, // bottom
@ -366,7 +367,7 @@ static CompoundVertex wingvtx2[] = {
{ VTYPE_CROSS, { 16, 17, -1, -1, -1 } }, // norm 3
{ VTYPE_CROSS, { 18, 19, -1, -1, -1 } }, // norm 2
};
static Uint16 wingdata[] = {
static uint16 wingdata[] = {
PTYPE_MATFIXED, 100, 0, 100, 0, 0, 0, 100, 0, 0, 0,
PTYPE_COMPSMOOTH | RFLAG_XREF, 0, 5, 10, 12, 6, 30, // side
COMP_HERMITE, 7, 31, 14, 15,
@ -510,7 +511,7 @@ static PlainVertex ship2vtx1[] = {
static CompoundVertex ship2vtx2[] = {
{ VTYPE_NORM, { 77, 78, 80, -1, -1 } }, // 120, retro norm
};
static Uint16 ship2data[] = {
static uint16 ship2data[] = {
PTYPE_MATFIXED, 100, 0, 100, 0, 0, 0, 100, 0, 0, 0,
PTYPE_COMPSMOOTH | RFLAG_XREF, 0, 5, 26, 27, 6, 7, // front edge
COMP_HERM_NOTAN, 8, 9,
@ -720,7 +721,7 @@ static PlainVertex station1vtx1[] = {
static CompoundVertex station1vtx2[] = {
{ VTYPE_CROSS, { 0, 1, 2, -1, -1 } }, // dummy
};
static Uint16 station1data[] = {
static uint16 station1data[] = {
PTYPE_MATFIXED, 100, 0, 100, 0, 0, 0, 100, 0, 0, 0,
PTYPE_QUADFLAT, 7, 6, 18, 19, // front face
PTYPE_QUADFLAT | RFLAG_XREF, 9, 8, 7, 19,
@ -768,8 +769,11 @@ static PlainVertex ship3vtx1[] = {
{ VTYPE_PLAIN, { 10.0f, 5.0f, -10.0f } }, // back mid
{ VTYPE_PLAIN, { 30.0f, -5.0f, -10.0f } }, // back end
{ VTYPE_PLAIN, { 20.0f, 1.0f, 0.0f } }, // 13, curve midpoint
{ VTYPE_DIR, { 2.0f, 2.0f, 1.0f } }, // norm
// { VTYPE_PLAIN, { 20.0f, 1.0f, 0.0f } }, // 13, curve midpoint
// { VTYPE_DIR, { 2.0f, 2.0f, 1.0f } }, // norm
{ VTYPE_PLAIN, { 18.75f, 1.25f, -2.1875f } }, // 13, curve midpoint
{ VTYPE_DIR, { 0.707f, 1.0f, 0.707f } }, // norm
{ VTYPE_PLAIN, { 15.0f, 0.0f, -10.0f } }, // 15, back midpoint
{ VTYPE_PLAIN, { 30.0f, -5.0f, -10.0f } }, // underside midpoint
@ -820,7 +824,7 @@ static CompoundVertex ship3vtx2[] = {
{ VTYPE_NORM, { 15, 8, 10, -1, -1 } }, // 100, mid curve norm
{ VTYPE_NORM, { 9, 8, 11, -1, -1 } }, // 101, top curve norm
};
static Uint16 ship3data[] = {
static uint16 ship3data[] = {
PTYPE_MATFIXED, 100, 0, 100, 0, 0, 0, 100, 0, 0, 0,
PTYPE_QUADFLAT, 6, 8, 9, 7,
PTYPE_QUADFLAT, 9, 8, 11, 29,
@ -897,65 +901,49 @@ static PlainVertex ship4vtx1[] = {
{ VTYPE_PLAIN, { -1.0f, -7.0f, 32.0f } },
{ VTYPE_PLAIN, { -6.0f, 8.0f, 20.0f } }, // 10, nose section back
{ VTYPE_PLAIN, { 6.0f, 8.0f, 20.0f } },
{ VTYPE_PLAIN, { 6.0f, 8.0f, 20.0f } }, // and extrusion area
{ VTYPE_PLAIN, { 10.0f, 4.0f, 20.0f } },
{ VTYPE_PLAIN, { 10.0f, -6.0f, 20.0f } },
{ VTYPE_PLAIN, { 8.0f, -8.0f, 20.0f } },
{ VTYPE_PLAIN, { -8.0f, -8.0f, 20.0f } },
{ VTYPE_PLAIN, { 10.0f, -4.0f, 20.0f } },
{ VTYPE_PLAIN, { 6.0f, -8.0f, 20.0f } },
{ VTYPE_PLAIN, { -6.0f, -8.0f, 20.0f } },
{ VTYPE_PLAIN, { -10.0f, -4.0f, 20.0f } },
{ VTYPE_PLAIN, { -10.0f, 4.0f, 20.0f } },
{ VTYPE_PLAIN, { -7.5f, 6.0f, 20.0f } }, // 16,
{ VTYPE_PLAIN, { 7.5f, 6.0f, 20.0f } },
{ VTYPE_PLAIN, { 8.0f, -7.0f, 20.0f } },
{ VTYPE_PLAIN, { -8.0f, -7.0f, 20.0f } },
//midpoints
{ VTYPE_PLAIN, { 0.0f, 0.0f, 20.0f } }, // 18
{ VTYPE_PLAIN, { 0.0f, 0.0f, 16.0f } }, //
{ VTYPE_PLAIN, { 0.0f, 0.0f, -4.0f } }, //
{ VTYPE_PLAIN, { 0.0f, 0.0f, -8.0f } }, //
{ VTYPE_PLAIN, { 0.0f, 0.0f, -26.0f } }, //
{ VTYPE_PLAIN, { -7.5f, 6.0f, 16.0f } },
{ VTYPE_PLAIN, { 7.5f, 6.0f, 16.0f } },
{ VTYPE_PLAIN, { 8.0f, -7.0f, 16.0f } },
{ VTYPE_PLAIN, { -8.0f, -7.0f, 16.0f } },
{ VTYPE_PLAIN, { 0.3826834f, 0.9238795f, 0.0f } }, // 23, tube norm
{ VTYPE_PLAIN, { -6.0f, 8.0f, 16.0f } }, // 24, mid section front
{ VTYPE_PLAIN, { 6.0f, 8.0f, 16.0f } },
{ VTYPE_PLAIN, { 10.0f, 4.0f, 16.0f } },
{ VTYPE_PLAIN, { 10.0f, -6.0f, 16.0f } },
{ VTYPE_PLAIN, { 8.0f, -8.0f, 16.0f } },
{ VTYPE_PLAIN, { -8.0f, -8.0f, 16.0f } },
{ VTYPE_PLAIN, { 12.5f, 2.0f, -10.0f } }, // 24, top engine
{ VTYPE_PLAIN, { 12.5f, 2.0f, -30.0f } },
{ VTYPE_PLAIN, { 12.5f, 2.0f, -13.0f } },
{ VTYPE_PLAIN, { 12.5f, 2.0f, -27.0f } },
{ VTYPE_PLAIN, { -6.0f, 8.0f, -4.0f } }, // 30, mid section back
{ VTYPE_PLAIN, { 6.0f, 8.0f, -4.0f } },
{ VTYPE_PLAIN, { 10.0f, 4.0f, -4.0f } },
{ VTYPE_PLAIN, { 10.0f, -6.0f, -4.0f } },
{ VTYPE_PLAIN, { 8.0f, -8.0f, -4.0f } },
{ VTYPE_PLAIN, { -8.0f, -8.0f, -4.0f } },
{ VTYPE_PLAIN, { 11.5f, -6.0f, -10.0f } }, // 28, bottom engine
{ VTYPE_PLAIN, { 11.5f, -6.0f, -30.0f } },
{ VTYPE_PLAIN, { 11.5f, -6.0f, -13.0f } },
{ VTYPE_PLAIN, { 11.5f, -6.0f, -27.0f } },
{ VTYPE_PLAIN, { -7.5f, 6.0f, -4.0f } }, // 36,
{ VTYPE_PLAIN, { 7.5f, 6.0f, -4.0f } },
{ VTYPE_PLAIN, { 8.0f, -7.0f, -4.0f } },
{ VTYPE_PLAIN, { -8.0f, -7.0f, -4.0f } },
{ VTYPE_PLAIN, { 10.0f, -4.0f, -4.0f } }, // 32, right text pos
{ VTYPE_PLAIN, { -10.0f, -4.0f, 16.0f } }, // left text pos
{ VTYPE_PLAIN, { -7.5f, 6.0f, -8.0f } },
{ VTYPE_PLAIN, { 7.5f, 6.0f, -8.0f } },
{ VTYPE_PLAIN, { 8.0f, -7.0f, -8.0f } },
{ VTYPE_PLAIN, { -8.0f, -7.0f, -8.0f } },
{ VTYPE_PLAIN, { -6.0f, 8.0f, -8.0f } }, // 44, mid section front
{ VTYPE_PLAIN, { 6.0f, 8.0f, -8.0f } },
{ VTYPE_PLAIN, { 10.0f, 4.0f, -8.0f } },
{ VTYPE_PLAIN, { 10.0f, -6.0f, -8.0f } },
{ VTYPE_PLAIN, { 8.0f, -8.0f, -8.0f } },
{ VTYPE_PLAIN, { -8.0f, -8.0f, -8.0f } },
{ VTYPE_PLAIN, { -6.0f, 8.0f, -26.0f } }, // 50, mid section back
{ VTYPE_PLAIN, { 6.0f, 8.0f, -26.0f } },
{ VTYPE_PLAIN, { 10.0f, 4.0f, -26.0f } },
{ VTYPE_PLAIN, { 10.0f, -6.0f, -26.0f } },
{ VTYPE_PLAIN, { 8.0f, -8.0f, -26.0f } },
{ VTYPE_PLAIN, { -8.0f, -8.0f, -26.0f } },
{ VTYPE_PLAIN, { 5.0f, -8.0f, 13.0f } }, // 34, gear pos
{ VTYPE_PLAIN, { -5.0f, -8.0f, 13.0f } },
{ VTYPE_PLAIN, { 11.5f, -8.309f, -25.0f } }, // 36, gear pos
{ VTYPE_PLAIN, { -11.5f, -8.309f, -25.0f } },
{ VTYPE_PLAIN, { 11.5f, -8.309f, -13.0f } }, // 38, gear pos
{ VTYPE_PLAIN, { -11.5f, -8.309f, -13.0f } },
{ VTYPE_PLAIN, { 0.05f, 8.0f, -15.0f } }, // 40, dish pos
};
static CompoundVertex ship4vtx2[] = {
{ VTYPE_CROSS, { 0, 1, 2, -1, -1 } }, // dummy
};
static Uint16 ship4data[] = {
static uint16 ship4data[] = {
PTYPE_MATFIXED, 100, 0, 100, 0, 0, 0, 100, 0, 0, 0,
PTYPE_QUADFLAT, 6, 7, 11, 10, // front section
@ -969,52 +957,109 @@ static Uint16 ship4data[] = {
PTYPE_QUADFLAT, 10, 11, 14, 15,
PTYPE_QUADFLAT | RFLAG_XREF, 11, 12, 13, 14,
PTYPE_QUADFLAT, 29, 28, 25, 24, // mid section
PTYPE_QUADFLAT | RFLAG_XREF, 28, 27, 26, 25,
PTYPE_EXTRUSION, 0, 8, 19, 20, 1, 100, 10,
PTYPE_EXTRUSION, 1, 8, 21, 22, 1, 100, 10,
PTYPE_QUADFLAT, 24, 25, 31, 30,
PTYPE_QUADFLAT | RFLAG_XREF, 25, 26, 32, 31,
PTYPE_QUADFLAT | RFLAG_XREF, 26, 27, 33, 32,
PTYPE_QUADFLAT | RFLAG_XREF, 27, 28, 34, 33,
PTYPE_QUADFLAT, 28, 29, 35, 34,
PTYPE_TUBE | RFLAG_XREF, 2, 8, 24, 25, 23, 250, 200,
PTYPE_TUBE | RFLAG_XREF, 3, 8, 28, 29, 23, 250, 200,
PTYPE_QUADFLAT, 30, 31, 34, 35,
PTYPE_QUADFLAT | RFLAG_XREF, 31, 32, 33, 34,
PTYPE_QUADFLAT, 49, 48, 45, 44, // rear section
PTYPE_QUADFLAT | RFLAG_XREF, 48, 47, 46, 45,
PTYPE_QUADFLAT, 44, 45, 51, 50,
PTYPE_QUADFLAT | RFLAG_XREF, 45, 46, 52, 51,
PTYPE_QUADFLAT | RFLAG_XREF, 46, 47, 53, 52,
PTYPE_QUADFLAT | RFLAG_XREF, 47, 48, 54, 53,
PTYPE_QUADFLAT, 48, 49, 55, 54,
PTYPE_QUADFLAT, 50, 51, 54, 55,
PTYPE_QUADFLAT | RFLAG_XREF, 51, 52, 53, 54,
PTYPE_MATANIM, AFUNC_THRUSTPULSE,
0, 0, 0, 0, 0, 0, 100, 50, 50, 100,
0, 0, 0, 0, 0, 0, 100, 0, 0, 50,
PTYPE_CIRCLE | RFLAG_XREF, 4, 8, 26, 2, 23, 200,
PTYPE_CIRCLE | RFLAG_XREF, 5, 8, 27, 5, 23, 200,
PTYPE_CIRCLE | RFLAG_XREF, 6, 8, 30, 2, 23, 200,
PTYPE_CIRCLE | RFLAG_XREF, 7, 8, 31, 5, 23, 200,
PTYPE_MATFIXED, 30, 30, 30, 10, 10, 10, 100, 0, 0, 0,
PTYPE_EXTRUSION, 8, 8, 18, 19, 1, 85, 10,
PTYPE_EXTRUSION, 9, 8, 20, 21, 1, 85, 10,
PTYPE_QUADFLAT, 16, 17, 21, 20, // front join
PTYPE_QUADFLAT | RFLAG_XREF, 17, 18, 22, 21,
PTYPE_QUADFLAT, 18, 19, 23, 22,
PTYPE_MATFIXED, 20, 20, 20, 0, 0, 0, 100, 0, 0, 0,
PTYPE_ZBIAS, 0, 5,
PTYPE_TEXT, 0, 0x8000, 32, 0, 2, 300, 250, 400,
PTYPE_ZBIAS, 3, 5,
PTYPE_TEXT, 0, 0x8000, 33, 3, 5, 300, 250, 400,
PTYPE_QUADFLAT, 36, 37, 41, 40, // rear join
PTYPE_QUADFLAT | RFLAG_XREF, 37, 38, 42, 41,
PTYPE_QUADFLAT, 38, 39, 43, 42,
PTYPE_ZBIAS, 4, 5,
PTYPE_SUBOBJECT, 0, SUB_MWUNIT, 34, 0, 4, 60,
PTYPE_SUBOBJECT, 0, SUB_MWUNIT, 35, 0, 4, 60,
PTYPE_SUBOBJECT, 0, SUB_MWUNIT, 36, 0, 4, 50,
PTYPE_SUBOBJECT, 0, SUB_MWUNIT, 37, 0, 4, 50,
PTYPE_SUBOBJECT, 0, SUB_MWUNIT, 38, 0, 4, 50,
PTYPE_SUBOBJECT, 0, SUB_MWUNIT, 39, 0, 4, 50,
PTYPE_ZBIAS, 1, 5,
PTYPE_SUBOBJECT, 0x8000, SUB_DISH, 40, 0, 1, 200,
// PTYPE_SUBOBJECT, 0x8000, SUB_NOSEWHEEL, 10, 0, 4, 100,
PTYPE_END,
};
static Model ship4model = { 1.0f, 56, ship4vtx1, 100, 0, ship4vtx2,
0, 0, 0, 0, ship4data, 0 };
static Thruster ship4thruster[] = {
{ 25, 5 | THRUST_NOANG | THRUST_XREF, 30.0f },
{ 29, 5 | THRUST_NOANG | THRUST_XREF, 30.0f },
{ 24, 2 | THRUST_NOANG | THRUST_XREF, 20.0f },
{ 28, 2 | THRUST_NOANG | THRUST_XREF, 20.0f },
// { 40, 0 | THRUST_XREF, 15.0f },
// { 41, 4 | THRUST_XREF, 15.0f },
// { 42, 1 | THRUST_XREF, 15.0f },
// { 43, 0 | THRUST_XREF, 15.0f },
};
static Model ship4model = { 1.0f, 41, ship4vtx1, 100, 0, ship4vtx2,
0, 0, 4, ship4thruster, ship4data, 10 };
static PlainVertex dishvtx1[] = {
{ VTYPE_PLAIN, { 0.0f, 3.0f, 1.2f } }, // 6, dish
{ VTYPE_PLAIN, { 1.0f, 2.0f, 1.2f } },
{ VTYPE_PLAIN, { 0.0f, 1.0f, 1.2f } },
{ VTYPE_PLAIN, { -1.0f, 2.0f, 1.2f } },
{ VTYPE_PLAIN, { 0.0f, 2.0f, 0.2f } },
{ VTYPE_PLAIN, { 0.0f, 2.2f, 0.0f } }, // 11, stand
{ VTYPE_PLAIN, { 0.0f, 0.6f, 0.0f } },
{ VTYPE_PLAIN, { 0.0f, 0.0f, 0.0f } },
{ VTYPE_PLAIN, { 0.0f, 2.0f, 1.7f } }, // 14, antenna
{ VTYPE_PLAIN, { 1.5f, 0.0f, 0.0f } }, // 15, tangents
{ VTYPE_PLAIN, { -1.5f, 0.0f, 0.0f } },
{ VTYPE_PLAIN, { 0.0f, 1.5f, 0.0f } },
{ VTYPE_PLAIN, { 0.0f, -1.5f, 0.0f } },
};
static CompoundVertex dishvtx2[] = {
{ VTYPE_CROSS, { 0, 1, 2, -1, -1 } }, // dummy
};
static uint16 dishdata[] = {
PTYPE_MATFIXED, 50, 50, 50, 100, 100, 100, 200, 0, 0, 0,
PTYPE_COMPSMOOTH, 0, 5, 10, 5, 6, 1,
COMP_HERMITE, 7, 0, 15, 18,
COMP_HERMITE, 8, 4, 18, 16,
COMP_HERMITE, 9, 3, 16, 17,
COMP_HERMITE, 6, 1, 17, 15,
COMP_END,
PTYPE_COMPSMOOTH, 1, 5, 10, 2, 6, 4,
COMP_HERMITE, 9, 0, 16, 18,
COMP_HERMITE, 8, 1, 18, 15,
COMP_HERMITE, 7, 3, 15, 17,
COMP_HERMITE, 6, 4, 17, 16,
COMP_END,
PTYPE_CYLINDER, 4, 6, 10, 14, 0, 10,
PTYPE_MATFIXED, 100, 0, 100, 0, 0, 0, 100, 0, 0, 0,
PTYPE_CYLINDER, 2, 6, 11, 12, 0, 20,
PTYPE_CYLINDER, 3, 6, 12, 13, 0, 70,
PTYPE_END,
};
static Model dishmodel = { 1.0f, 19, dishvtx1, 40, 0, dishvtx2,
0, 0, 0, 0, dishdata, 5 };
Model *ppModel[] = {
&ship4model,
&tetramodel,
&circlemodel,
&dishmodel,
&nosewheelmodel,
&wingmodel,
&nacellemodel,

View File

@ -3,17 +3,17 @@
#include "sbre_int.h"
#include "sbre_anim.h"
#include "sbre.h" // for subobject
#include "../glfreetype.h"
#include "glfreetype.h"
/*
Uint16 PFUNC_MATANIM
Uint16 animfunc
Uint16 dr1, dg1, db1, sr1, sg1, sb1, sh1, er1, eg1, eb1
Uint16 dr2, dg2, db2, sr2, sg2, sb2, sh2, er2, eg2, eb2
uint16 PFUNC_MATANIM
uint16 animfunc
uint16 dr1, dg1, db1, sr1, sg1, sb1, sh1, er1, eg1, eb1
uint16 dr2, dg2, db2, sr2, sg2, sb2, sh2, er2, eg2, eb2
*/
static int PrimFuncMatAnim (Uint16 *pData, Model *pMod, RState *pState)
static int PrimFuncMatAnim (uint16 *pData, Model *pMod, RState *pState)
{
float anim = 0.01f * ResolveAnim (pState->pObjParam, pData[1]);
float ianim = 0.01f - anim;
@ -36,14 +36,14 @@ static int PrimFuncMatAnim (Uint16 *pData, Model *pMod, RState *pState)
}
/*
Uint16 PFUNC_MATFIXED
Uint16 dr, dg, db
Uint16 sr, sg, sb
Uint16 shiny
Uint16 er, eg, eb
uint16 PFUNC_MATFIXED
uint16 dr, dg, db
uint16 sr, sg, sb
uint16 shiny
uint16 er, eg, eb
*/
static int PrimFuncMatFixed (Uint16 *pData, Model *pMod, RState *pState)
static int PrimFuncMatFixed (uint16 *pData, Model *pMod, RState *pState)
{
int i;
float pDiff[4] = { 0, 0, 0, 1.0f }, shiny;
@ -63,11 +63,11 @@ static int PrimFuncMatFixed (Uint16 *pData, Model *pMod, RState *pState)
}
/*
Uint16 PFUNC_MATVAR
Uint16 index
uint16 PFUNC_MATVAR
uint16 index
*/
static int PrimFuncMatVar (Uint16 *pData, Model *pMod, RState *pState)
static int PrimFuncMatVar (uint16 *pData, Model *pMod, RState *pState)
{
int i;
float pDiff[4] = { 0, 0, 0, 1.0f }, shiny;
@ -88,12 +88,12 @@ static int PrimFuncMatVar (Uint16 *pData, Model *pMod, RState *pState)
}
/*
Uint16 PFUNC_ZBIAS
Uint16 offset // to test if nearer - 0x8000 = reset
Uint16 units // integer units. not used
uint16 PFUNC_ZBIAS
uint16 offset // to test if nearer - 0x8000 = reset
uint16 units // integer units. not used
*/
static int PrimFuncZBias (Uint16 *pData, Model *pMod, RState *pState)
static int PrimFuncZBias (uint16 *pData, Model *pMod, RState *pState)
{
if (pData[1] & 0x8000) glDepthRange (pState->dn+SBRE_ZBIAS, pState->df);
else if (VecDot (pState->pVtx+pData[1], &pState->campos) > 0.0f)
@ -101,7 +101,7 @@ static int PrimFuncZBias (Uint16 *pData, Model *pMod, RState *pState)
return 3;
}
static int PrimFuncTriFlat (Uint16 *pData, Model *pMod, RState *pState)
static int PrimFuncTriFlat (uint16 *pData, Model *pMod, RState *pState)
{
Vector *pVtx = pState->pVtx;
Vector *pVec;
@ -133,7 +133,7 @@ static int PrimFuncTriFlat (Uint16 *pData, Model *pMod, RState *pState)
return 4;
}
static int PrimFuncQuadFlat (Uint16 *pData, Model *pMod, RState *pState)
static int PrimFuncQuadFlat (uint16 *pData, Model *pMod, RState *pState)
{
Vector *pVtx = pState->pVtx;
Vector *pVec;
@ -172,7 +172,7 @@ static int PrimFuncQuadFlat (Uint16 *pData, Model *pMod, RState *pState)
}
void RenderArray (int nv, int ni, Vector *pVertex, Uint16 *pIndex, Uint16 flags)
void RenderArray (int nv, int ni, Vector *pVertex, uint16 *pIndex, uint16 flags)
{
glNormalPointer (GL_FLOAT, 2*sizeof(Vector), pVertex+1);
glVertexPointer (3, GL_FLOAT, 2*sizeof(Vector), pVertex);
@ -190,43 +190,43 @@ void RenderArray (int nv, int ni, Vector *pVertex, Uint16 *pIndex, Uint16 flags)
}
}
void CopyArrayToCache (int nv, int ni, Vector *pVertex, Uint16 *pIndex, int ci, Model *pModel)
void CopyArrayToCache (int nv, int ni, Vector *pVertex, uint16 *pIndex, int ci, Model *pModel)
{
pModel->pNumIdx[ci] = ni;
pModel->pNumVtx[ci] = nv;
pModel->ppICache[ci] = (Uint16 *) malloc (ni*sizeof(Uint16));
memcpy (pModel->ppICache[ci], pIndex, ni*sizeof(Uint16));
pModel->ppICache[ci] = (uint16 *) malloc (ni*sizeof(uint16));
memcpy (pModel->ppICache[ci], pIndex, ni*sizeof(uint16));
pModel->ppVCache[ci] = (Vector *) malloc (2*nv*sizeof(Vector));
memcpy (pModel->ppVCache[ci], pVertex, 2*nv*sizeof(Vector));
}
/*
Uint16 PFUNC_COMPSMOOTH
Uint16 cacheidx
Uint16 steps
Uint16 centpos
Uint16 centnorm
Uint16 startpos
Uint16 startnorm
Uint16 COMP_END
Uint16 COMP_LINE
Uint16 pos
Uint16 norm
Uint16 COMP_HERMITE
Uint16 pos
Uint16 norm
Uint16 tan0
Uint16 tan1
uint16 PFUNC_COMPSMOOTH
uint16 cacheidx
uint16 steps
uint16 centpos
uint16 centnorm
uint16 startpos
uint16 startnorm
uint16 COMP_END
uint16 COMP_LINE
uint16 pos
uint16 norm
uint16 COMP_HERMITE
uint16 pos
uint16 norm
uint16 tan0
uint16 tan1
// tangents should be prescaled
*/
int PrimFuncCompoundSmooth (Uint16 *pData, Model *pMod, RState *pState)
int PrimFuncCompoundSmooth (uint16 *pData, Model *pMod, RState *pState)
{
Vector *pVtx = pState->pVtx;
Model *pModel = pState->pModel;
Uint16 ci = pData[1];
uint16 ci = pData[1];
if (ci != 0x8000 && pModel->pNumIdx[ci])
{
RenderArray (pModel->pNumVtx[ci], pModel->pNumIdx[ci],
@ -244,30 +244,35 @@ int PrimFuncCompoundSmooth (Uint16 *pData, Model *pMod, RState *pState)
while (pData[c] != COMP_END)
{
switch (pData[c])
if (pData[c] == COMP_STEPS) steps = pData[c+1];
else if (pData[c] == COMP_LINE)
{
case COMP_STEPS:
steps = pData[c+1];
c += 2; break;
case COMP_LINE:
pLPos = pVtx+pData[c+1], pLNorm = pVtx+pData[c+2];
TriangAddPoint (pLPos, pLNorm);
c += 3; break;
case COMP_HERMITE:
case COMP_HERM_NOTAN:
}
else
{
Vector t0, t1;
if (pData[c] == COMP_HERMITE)
{ t0 = pVtx[pData[c+3]]; t1 = pVtx[pData[c+4]]; }
else if (pData[c] == COMP_HERM_NOTAN)
{ VecSub (pVtx+pData[c+1], pLPos, &t0); t1 = t0; }
else if (pData[c] == COMP_HERM_AUTOTAN)
{
Vector tv; VecSub (pVtx+pData[c+1], pLPos, &tv);
VecMul (pLNorm, VecDot (&tv, pLNorm), &t0);
VecSub (&tv, &t0, &t0);
VecMul (pVtx+pData[c+2], VecDot (&tv, pVtx+pData[c+2]), &t1);
VecSub (&tv, &t1, &t1);
}
// else { //crash? };
// Now add points along spline
float t, incstep = 1.0f / (steps+1);
int i; for (i=0, t=incstep; i<steps; i++, t+=incstep)
{
Vector pos, norm;
if (pData[c] == COMP_HERM_NOTAN) {
Vector tan; VecSub (pVtx+pData[c+1], pLPos, &tan);
ResolveHermiteSpline (pLPos, pVtx+pData[c+1], &tan, &tan, t, &pos);
}
else ResolveHermiteSpline (pLPos, pVtx+pData[c+1],
pVtx+pData[c+3], pVtx+pData[c+4], t, &pos);
ResolveHermiteSpline (pLPos, pVtx+pData[c+1], &t0, &t1, t, &pos);
ResolveLinearInterp (pLNorm, pVtx+pData[c+2], t, &norm);
VecNorm (&norm, &norm);
TriangAddPoint (&pos, &norm);
@ -275,13 +280,13 @@ int PrimFuncCompoundSmooth (Uint16 *pData, Model *pMod, RState *pState)
// add end point
pLPos = pVtx+pData[c+1], pLNorm = pVtx+pData[c+2];
TriangAddPoint (pLPos, pLNorm);
c += pCompSize[pData[c]]; break;
}
c += pCompSize[pData[c]];
}
int ni, nv;
Vector *pVertex;
Uint16 *pIndex;
uint16 *pIndex;
if ((pData[0]&0xff) == PTYPE_COMPFLAT) steps = 0;
Triangulate (pCPos, pCNorm, steps, &pVertex, &nv, &pIndex, &ni);
@ -291,21 +296,21 @@ int PrimFuncCompoundSmooth (Uint16 *pData, Model *pMod, RState *pState)
}
/*
Uint16 PFUNC_CYLINDER
Uint16 cacheidx -1 => uncacheable
Uint16 steps 8 => octagonal
Uint16 startvtx
Uint16 endvtx
Uint16 updir
Uint16 rad
uint16 PFUNC_CYLINDER
uint16 cacheidx -1 => uncacheable
uint16 steps 8 => octagonal
uint16 startvtx
uint16 endvtx
uint16 updir
uint16 rad
*/
static int PrimFuncCylinder (Uint16 *pData, Model *pMod, RState *pState)
static int PrimFuncCylinder (uint16 *pData, Model *pMod, RState *pState)
{
Vector *pVtx = pState->pVtx;
Model *pModel = pState->pModel;
Uint16 ci = pData[1];
uint16 ci = pData[1];
if (ci != 0x8000 && pModel->pNumIdx[ci])
{
RenderArray (pModel->pNumVtx[ci], pModel->pNumIdx[ci],
@ -316,7 +321,7 @@ static int PrimFuncCylinder (Uint16 *pData, Model *pMod, RState *pState)
int steps = pData[2];
float rad = pData[6] * 0.01f;
Vector *pVertex = (Vector *) alloca (8*steps*sizeof(Vector));
Uint16 *pIndex = (Uint16 *) alloca (12*steps*sizeof(Vector));
uint16 *pIndex = (uint16 *) alloca (12*steps*sizeof(Vector));
int ni = 0;
// generate cylinder axes
@ -370,21 +375,21 @@ static int PrimFuncCylinder (Uint16 *pData, Model *pMod, RState *pState)
}
/*
Uint16 PFUNC_CIRCLE
Uint16 cacheidx -1 => uncacheable
Uint16 steps 8 => octagonal
Uint16 vtx
Uint16 norm
Uint16 updir
Uint16 rad
uint16 PFUNC_CIRCLE
uint16 cacheidx -1 => uncacheable
uint16 steps 8 => octagonal
uint16 vtx
uint16 norm
uint16 updir
uint16 rad
*/
static int PrimFuncCircle (Uint16 *pData, Model *pMod, RState *pState)
static int PrimFuncCircle (uint16 *pData, Model *pMod, RState *pState)
{
Vector *pVtx = pState->pVtx;
Model *pModel = pState->pModel;
Uint16 ci = pData[1];
uint16 ci = pData[1];
if (ci != 0x8000 && pModel->pNumIdx[ci])
{
RenderArray (pModel->pNumVtx[ci], pModel->pNumIdx[ci],
@ -395,7 +400,7 @@ static int PrimFuncCircle (Uint16 *pData, Model *pMod, RState *pState)
int steps = pData[2];
float rad = pData[6] * 0.01f;
Vector *pVertex = (Vector *) alloca (2*steps*sizeof(Vector));
Uint16 *pIndex = (Uint16 *) alloca (3*steps*sizeof(Vector));
uint16 *pIndex = (uint16 *) alloca (3*steps*sizeof(Vector));
int ni = 0;
// generate axes
@ -428,22 +433,22 @@ static int PrimFuncCircle (Uint16 *pData, Model *pMod, RState *pState)
/*
Uint16 PFUNC_TUBE
Uint16 cacheidx -1 => uncacheable
Uint16 steps 8 => octagonal
Uint16 startvtx
Uint16 endvtx
Uint16 updir
Uint16 outerrad
Uint16 innerrad
uint16 PFUNC_TUBE
uint16 cacheidx -1 => uncacheable
uint16 steps 8 => octagonal
uint16 startvtx
uint16 endvtx
uint16 updir
uint16 outerrad
uint16 innerrad
*/
static int PrimFuncTube (Uint16 *pData, Model *pMod, RState *pState)
static int PrimFuncTube (uint16 *pData, Model *pMod, RState *pState)
{
Vector *pVtx = pState->pVtx;
Model *pModel = pState->pModel;
Uint16 ci = pData[1];
uint16 ci = pData[1];
if (ci != 0x8000 && pModel->pNumIdx[ci])
{
RenderArray (pModel->pNumVtx[ci], pModel->pNumIdx[ci],
@ -453,7 +458,7 @@ static int PrimFuncTube (Uint16 *pData, Model *pMod, RState *pState)
int steps = pData[2];
Vector *pVertex = (Vector *) alloca (16*steps*sizeof(Vector));
Uint16 *pIndex = (Uint16 *) alloca (24*steps*sizeof(Vector));
uint16 *pIndex = (uint16 *) alloca (24*steps*sizeof(Vector));
int ni = 0;
// generate cylinder axes
@ -525,16 +530,16 @@ steps*7: end, inner, axial
/*
Uint16 PFUNC_SUBOBJECT
Uint16 anim
Uint16 modelnum
Uint16 offset
Uint16 xaxis
Uint16 yaxis
Uint16 scale
uint16 PFUNC_SUBOBJECT
uint16 anim
uint16 modelnum
uint16 offset
uint16 xaxis
uint16 yaxis
uint16 scale
*/
static int PrimFuncSubObject (Uint16 *pData, Model *pMod, RState *pState)
static int PrimFuncSubObject (uint16 *pData, Model *pMod, RState *pState)
{
// return immediately if object is not present
if (pData[1] != 0x8000 && !pState->pObjParam->pFlag[pData[1]]) return 7;
@ -567,22 +572,22 @@ static int glfinit = 0;
static FontFace *pFace = 0;
/*
Uint16 PFUNC_TEXT
Uint16 anim
Uint16 textnum
Uint16 pos
Uint16 norm
Uint16 xaxis
Uint16 xoff
Uint16 yoff
Uint16 scale
uint16 PFUNC_TEXT
uint16 anim
uint16 textnum
uint16 pos
uint16 norm
uint16 xaxis
uint16 xoff
uint16 yoff
uint16 scale
*/
static int PrimFuncText (Uint16 *pData, Model *pMod, RState *pState)
static int PrimFuncText (uint16 *pData, Model *pMod, RState *pState)
{
if (!glfinit) {
GLFTInit ();
pFace = new FontFace ("font.ttf");
pFace = new FontFace ("arial.ttf");
glfinit = 1;
}
@ -630,21 +635,105 @@ static int PrimFuncText (Uint16 *pData, Model *pMod, RState *pState)
return 9;
}
/*
uint16 PFUNC_EXTRUSION
uint16 cacheidx -1 => uncacheable
uint16 count
uint16 startvtx
uint16 endvtx
uint16 updir
uint16 rad
uint16 firstvtx
*/
static int PrimFuncExtrusion (uint16 *pData, Model *pMod, RState *pState)
{
Vector *pVtx = pState->pVtx;
Model *pModel = pState->pModel;
uint16 ci = pData[1];
if (ci != 0x8000 && pModel->pNumIdx[ci])
{
glShadeModel (GL_FLAT);
RenderArray (pModel->pNumVtx[ci], pModel->pNumIdx[ci],
pModel->ppVCache[ci], pModel->ppICache[ci], pData[0]);
glShadeModel (GL_SMOOTH);
return 8;
}
int steps = pData[2];
float rad = pData[6] * 0.01f;
Vector *pVertex = (Vector *) alloca (8*steps*sizeof(Vector));
uint16 *pIndex = (uint16 *) alloca (12*steps*sizeof(Vector));
int ni = 0;
// generate cylinder axes
Vector yax = pVtx[pData[5]], xax, zax;
VecSub (pVtx+pData[4], pVtx+pData[3], &zax); // dir = end-start
VecNorm (&zax, &zax);
VecCross (&yax, &zax, &xax);
int i; for (i=0; i<steps; i++)
{
Vector tv, norm;
VecMul (&xax, pVtx[pData[7]+i].x, &tv);
VecMul (&yax, pVtx[pData[7]+i].y, &norm);
VecAdd (&tv, &norm, &norm);
pVertex[1+(i+steps*3)*2] = zax; VecInv (&zax, &tv); // endcap
pVertex[1+(i+steps*2)*2] = tv; // startcap
VecMul (&norm, rad, &tv);
VecAdd (pVtx+pData[3], &tv, pVertex+i*2); // start
VecAdd (pVtx+pData[4], &tv, pVertex+(i+steps)*2); // end
pVertex[(i+steps*2)*2] = pVertex[i*2]; // startcap
pVertex[(i+steps*3)*2] = pVertex[(i+steps)*2]; // endcap
}
// render sides
for (i=0; i<steps; i++)
{
int i1 = i+1==steps?0:i+1;
FindNormal (pVertex+i*2, pVertex+(i+steps)*2, pVertex+i1*2, pVertex+i*2+1);
pVertex[(i+steps)*2+1] = pVertex[i*2+1];
pIndex[ni++] = i; pIndex[ni++] = i+steps; pIndex[ni++] = i1;
pIndex[ni++] = i+steps; pIndex[ni++] = i1+steps; pIndex[ni++] = i1;
}
// render ends
for (i=1; i<steps-1; i++) {
pIndex[ni++] = steps*2;
pIndex[ni++] = i+steps*2;
pIndex[ni++] = i+1+steps*2;
}
for (i=steps-1; i>1; i--) {
pIndex[ni++] = steps*3;
pIndex[ni++] = i+steps*3;
pIndex[ni++] = i-1+steps*3;
}
RenderArray (4*steps, ni, pVertex, pIndex, pData[0]);
if (ci != 0x8000) CopyArrayToCache (4*steps, ni, pVertex, pIndex, ci, pModel);
return 8;
}
/*
Uint16 PFUNC_WINDOWS
Uint16
Uint16 textnum
Uint16 pos
Uint16 norm
Uint16 xaxis
Uint16 xoff
Uint16 yoff
Uint16 scale
uint16 PFUNC_WINDOWS
uint16
uint16 textnum
uint16 pos
uint16 norm
uint16 xaxis
uint16 xoff
uint16 yoff
uint16 scale
*/
int (*pPrimFuncTable[])(Uint16 *, Model *, RState *) = {
int (*pPrimFuncTable[])(uint16 *, Model *, RState *) = {
0, // end
PrimFuncMatAnim,
PrimFuncMatFixed,
@ -659,6 +748,7 @@ int (*pPrimFuncTable[])(Uint16 *, Model *, RState *) = {
PrimFuncTube,
PrimFuncSubObject,
PrimFuncText,
PrimFuncExtrusion,
};

View File

@ -21,7 +21,7 @@ enum animflag
struct ObjParams
{
float pAnim[10];
Uint8 pFlag[10];
uint8 pFlag[10];
float linthrust[3]; // 1.0 to -1.0
float angthrust[3]; // 1.0 to -1.0
@ -39,6 +39,7 @@ struct ObjParams
void sbreSetViewport (int w, int h, int d, float zn, float zf, float dn, float df);
void sbreSetDirLight (float *pColor, float *pDir);
void sbreSetWireframe (int val);
void sbreRenderModel (Vector *pPos, Matrix *pOrient, int model, ObjParams *pParam, float s=1.0f);
#endif /* __SBRE_H__ */
#endif /* __SBRE_H__ */

View File

@ -20,30 +20,30 @@ enum vtxtype
struct PlainVertex
{
Uint32 type;
uint32 type;
Vector pos;
};
struct CompoundVertex
{
Uint16 type;
Uint16 pParam[5];
uint16 type;
uint16 pParam[5];
};
//**************************************************************************
struct Thruster
{
Uint16 pos; // index into vertices
Uint16 dir;
uint16 pos; // index into vertices
uint16 dir;
float power;
};
struct Light
{
Uint8 animcolor;
Uint8 animpower;
Uint16 vtx;
uint8 animcolor;
uint8 animpower;
uint16 vtx;
float power;
float pColor[3];
};
@ -65,12 +65,12 @@ struct Model
int numThrusters;
Thruster *pThruster;
Uint16 *pData;
uint16 *pData;
int numCache; // number of cached primitives
int *pNumVtx, *pNumIdx;
Vector **ppVCache;
Uint16 **ppICache;
uint16 **ppICache;
};
extern Model *ppModel[];
@ -88,7 +88,7 @@ void ResolveHermiteNormal (Vector *p0, Vector *p1, Vector *n0, Vector *n1, float
void TriangAddPoint (Vector *pPos, Vector *pNorm);
void Triangulate (Vector *pCPos, Vector *pCNorm, int steps,
Vector **ppVtx, int *pNV, Uint16 **ppIndex, int *pNI);
Vector **ppVtx, int *pNV, uint16 **ppIndex, int *pNI);
//******************************************************************************
@ -120,9 +120,10 @@ enum primtype
PTYPE_TUBE,
PTYPE_SUBOBJECT,
PTYPE_TEXT,
PTYPE_EXTRUSION,
};
extern int (*pPrimFuncTable[])(Uint16 *, Model *, RState *);
extern int (*pPrimFuncTable[])(uint16 *, Model *, RState *);
static const int RFLAG_XREF = 0x8000;
@ -138,16 +139,17 @@ enum comptype
COMP_LINE,
COMP_HERMITE,
COMP_HERM_NOTAN,
COMP_HERM_AUTOTAN,
COMP_STEPS,
};
const int pCompSize[] = { 1, 3, 5, 3, 2 };
const int pCompSize[] = { 1, 3, 5, 3, 3, 2 };
const char pModelString[1][256] = {
"Bollocks",
};
void RenderTransparencies (RState *pState);
float ResolveAnim (ObjParams *pObjParam, Uint16 type);
float ResolveAnim (ObjParams *pObjParam, uint16 type);
#endif /* __SBRE_INT_H__ */
#endif /* __SBRE_INT_H__ */

View File

@ -48,7 +48,7 @@ void ResolveHermiteSpline (Vector *p0, Vector *p1, Vector *n0, Vector *n1, float
VecAdd (&tv1, &tv2, pRes);
}
void ResolveHermiteNormal (Vector *p0, Vector *p1, Vector *n0, Vector *n1, float t, Vector *pRes)
void ResolveHermiteTangent (Vector *p0, Vector *p1, Vector *n0, Vector *n1, float t, Vector *pRes)
{
float t2 = t*t;
Vector tv1, tv2, tv;
@ -68,10 +68,10 @@ struct TriangPoint
Vector pos; // base pos, norm
Vector norm;
int num; // count of valid vertices
Uint16 pIndex[TRIANG_MAXSTEPS+1]; // index of each vertex, inside to outside
uint16 pIndex[TRIANG_MAXSTEPS+1]; // index of each vertex, inside to outside
};
static Uint16 pIndex[6*TRIANG_MAXPOINTS*(TRIANG_MAXSTEPS+1)];
static uint16 pIndex[6*TRIANG_MAXPOINTS*(TRIANG_MAXSTEPS+1)];
static Vector pVertex[2*TRIANG_MAXPOINTS*(TRIANG_MAXSTEPS+1)];
static TriangPoint pPoint[TRIANG_MAXPOINTS];
@ -86,7 +86,7 @@ void TriangAddPoint (Vector *pPos, Vector *pNorm)
}
void Triangulate (Vector *pCPos, Vector *pCNorm, int steps,
Vector **ppVtx, int *pNV, Uint16 **ppIndex, int *pNI)
Vector **ppVtx, int *pNV, uint16 **ppIndex, int *pNI)
{
// Ok. For each point, find number of increments
// and generate intermediate values
@ -94,11 +94,14 @@ void Triangulate (Vector *pCPos, Vector *pCNorm, int steps,
int nv = 0, ni = 0;
int i; for (int i=0; i<numPoints; i++)
{
Vector tv;
Vector tv; //, tnorm, tnorm2;
TriangPoint *pCur = pPoint+i;
VecSub (pCPos, &pCur->pos, &tv);
float len = sqrt (VecDot (&tv, &tv));
// float len = sqrt (VecDot (&tv, &tv));
// VecCross (&pCur->norm, pCNorm, &tnorm);
// VecCross (pCNorm, &tv, &tnorm2);
// if (VecDot (&tnorm, &tnorm2) < 0.0f) VecInv (&tnorm, &tnorm);
pVertex[nv] = pCur->pos; // add first vertex to array
pVertex[nv+1] = pCur->norm;
pCur->pIndex[0] = nv>>1; nv+=2;
@ -118,6 +121,8 @@ void Triangulate (Vector *pCPos, Vector *pCNorm, int steps,
int j; for (t=inc, j=1; j<=pCur->num; j++, t+=inc)
{
ResolveHermiteSpline (&pCur->pos, pCPos, &t0, &t1, t, pVertex+nv);
// ResolveHermiteTangent (&pCur->pos, pCPos, &t0, &t1, t, &tv);
// VecCross (&tv, &tnorm, pVertex+nv+1);
ResolveLinearInterp (&pCur->norm, pCNorm, t, pVertex+nv+1);
pCur->pIndex[j] = nv>>1; nv+=2;
}

View File

@ -10,14 +10,14 @@ static Vector pTVertex4pt[2*4+2];
static Vector pTVertex8pt[6*8+2];
static Vector pTVertex16pt[14*16+2];
static Uint16 pTIndex4pt[(2*4+1*8)*3];
static Uint16 pTIndex8pt[(2*8+5*16)*3];
static Uint16 pTIndex16pt[(2*16+13*32)*3];
static uint16 pTIndex4pt[(2*4+1*8)*3];
static uint16 pTIndex8pt[(2*8+5*16)*3];
static uint16 pTIndex16pt[(2*16+13*32)*3];
static Vector *ppTVertex[3] =
{ pTVertex4pt, pTVertex8pt, pTVertex16pt };
static Uint16 *ppTIndex[3] =
static uint16 *ppTIndex[3] =
{ pTIndex4pt, pTIndex8pt, pTIndex16pt };
@ -72,7 +72,7 @@ static void GenerateThrusters ()
*pCur = pos1; pCur++;
int ni=0, k;
Uint16 *pIndex = ppTIndex[j];
uint16 *pIndex = ppTIndex[j];
for (k=0; k<n; k++) {
int k1 = k+1==n ? 0 : k+1;