Skip to content

Commit

Permalink
Merge pull request #1151 from SomaZ/rend2
Browse files Browse the repository at this point in the history
Rend2
  • Loading branch information
Razish authored Oct 3, 2023
2 parents 26b8719 + 3544f14 commit be28b4e
Show file tree
Hide file tree
Showing 111 changed files with 93,833 additions and 557 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ option(BuildMPDed "Whether to create projects for the MP dedicated server (openj
option(BuildMPGame "Whether to create projects for the MP server-side gamecode (jampgamex86.dll)" ON)
option(BuildMPCGame "Whether to create projects for the MP clientside gamecode (cgamex86.dll)" ON)
option(BuildMPUI "Whether to create projects for the MP UI code (uix86.dll)" ON)
option(BuildMPRend2 "Whether to create projects for the EXPERIMENTAL MP rend2 renderer (rd-rend2_x86.dll)" ON)
option(BuildSPEngine "Whether to create projects for the SP engine (openjk_sp.exe)" ON)
option(BuildSPGame "Whether to create projects for the SP gamecode (jagamex86.dll)" ON)
option(BuildSPRdVanilla "Whether to create projects for the SP default renderer (rdsp-vanilla_x86.dll)" ON)
Expand Down Expand Up @@ -157,6 +158,7 @@ set(MPDed "openjkded.${Architecture}")
set(MPGame "jampgame${Architecture}")
set(MPCGame "cgame${Architecture}")
set(MPUI "ui${Architecture}")
set(MPRend2 "rd-rend2_${Architecture}")
set(JK2SPEngine "openjo_sp.${Architecture}")
set(JK2SPGame "jospgame${Architecture}")
set(JK2SPVanillaRenderer "rdjosp-vanilla_${Architecture}")
Expand Down
5 changes: 5 additions & 0 deletions codemp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ if(BuildMPRdVanilla)
add_subdirectory("${MPDir}/rd-vanilla")
endif(BuildMPRdVanilla)

# Add rend2 JKA Renderer Project
if(BuildMPRend2)
add_subdirectory("${MPDir}/rd-rend2")
endif(BuildMPRend2)

# Common things between Engine and Dedicated Server
if(BuildMPEngine OR BuildMPDed)

Expand Down
4 changes: 4 additions & 0 deletions codemp/ghoul2/G2_gore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
#include "G2_gore.h"
#include "../rd-common/tr_common.h"

#ifdef _G2_GORE

GoreTextureCoordinates::GoreTextureCoordinates()
{
Com_Memset (tex, 0, sizeof (tex));
Expand All @@ -39,3 +41,5 @@ GoreTextureCoordinates::~GoreTextureCoordinates()
}
}
}

#endif
56 changes: 26 additions & 30 deletions codemp/ghoul2/ghoul2_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,17 @@ struct surfaceInfo_t
int genPolySurfaceIndex; // used to point back to the original surface and poly if this is a generated surface
int genLod; // used to determine original lod of original surface and poly hit location

surfaceInfo_t():
offFlags(0),
surface(0),
genBarycentricJ(0),
genBarycentricI(0),
genPolySurfaceIndex(0),
genLod(0)
{}

surfaceInfo_t()
: offFlags(0)
, surface(0)
, genBarycentricJ(0)
, genBarycentricI(0)
, genPolySurfaceIndex(0)
, genLod(0)
{
}
};



#define MDXABONEDEF // used in the mdxformat.h file to stop redefinitions of the bone struct.

// we save the whole structure here.
Expand Down Expand Up @@ -153,26 +151,24 @@ struct boneInfo_t
int airTime; //base is in air, be more quick and sensitive about collisions
//rww - RAGDOLL_END

boneInfo_t():
boneNumber(-1),
flags(0),
startFrame(0),
endFrame(0),
startTime(0),
pauseTime(0),
animSpeed(0),
blendFrame(0),
blendLerpFrame(0),
blendTime(0),
blendStart(0),
boneBlendTime(0),
boneBlendStart(0),
lastTime(0),
RagFlags(0)
boneInfo_t()
: boneNumber(-1)
, flags(0)
, startFrame(0)
, endFrame(0)
, startTime(0)
, pauseTime(0)
, animSpeed(0)
, blendFrame(0)
, blendLerpFrame(0)
, blendTime(0)
, blendStart(0)
, boneBlendTime(0)
, boneBlendStart(0)
, lastTime(0)
, RagFlags(0)
{
matrix.matrix[0][0] = matrix.matrix[0][1] = matrix.matrix[0][2] = matrix.matrix[0][3] =
matrix.matrix[1][0] = matrix.matrix[1][1] = matrix.matrix[1][2] = matrix.matrix[1][3] =
matrix.matrix[2][0] = matrix.matrix[2][1] = matrix.matrix[2][2] = matrix.matrix[2][3] = 0.0f;
Com_Memset(&matrix, 0, sizeof(matrix));
}

};
Expand Down
124 changes: 124 additions & 0 deletions codemp/qcommon/qfiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,130 @@ typedef struct md3Header_s {
int ofsEnd; // end of file
} md3Header_t;

/*
==============================================================================
MDR file format
==============================================================================
*/

/*
* Here are the definitions for Ravensoft's model format of md4. Raven stores their
* playermodels in .mdr files, in some games, which are pretty much like the md4
* format implemented by ID soft. It seems like ID's original md4 stuff is not used at all.
* MDR is being used in EliteForce, JediKnight2 and Soldiers of Fortune2 (I think).
* So this comes in handy for anyone who wants to make it possible to load player
* models from these games.
* This format has bone tags, which is similar to the thing you have in md3 I suppose.
* Raven has released their version of md3view under GPL enabling me to add support
* to this codebase. Thanks to Steven Howes aka Skinner for helping with example
* source code.
*
* - Thilo Schulz ([email protected])
*/

#define MDR_IDENT (('5'<<24)+('M'<<16)+('D'<<8)+'R')
#define MDR_VERSION 2
#define MDR_MAX_BONES 128

typedef struct {
int boneIndex; // these are indexes into the boneReferences,
float boneWeight; // not the global per-frame bone list
vec3_t offset;
} mdrWeight_t;

typedef struct {
vec3_t normal;
vec2_t texCoords;
int numWeights;
mdrWeight_t weights[1]; // variable sized
} mdrVertex_t;

typedef struct {
int indexes[3];
} mdrTriangle_t;

typedef struct {
int ident;

char name[MAX_QPATH]; // polyset name
char shader[MAX_QPATH];
int shaderIndex; // for in-game use

int ofsHeader; // this will be a negative number

int numVerts;
int ofsVerts;

int numTriangles;
int ofsTriangles;

// Bone references are a set of ints representing all the bones
// present in any vertex weights for this surface. This is
// needed because a model may have surfaces that need to be
// drawn at different sort times, and we don't want to have
// to re-interpolate all the bones for each surface.
int numBoneReferences;
int ofsBoneReferences;

int ofsEnd; // next surface follows
} mdrSurface_t;

typedef struct {
float matrix[3][4];
} mdrBone_t;

typedef struct {
vec3_t bounds[2]; // bounds of all surfaces of all LOD's for this frame
vec3_t localOrigin; // midpoint of bounds, used for sphere cull
float radius; // dist from localOrigin to corner
char name[16];
mdrBone_t bones[1]; // [numBones]
} mdrFrame_t;

typedef struct {
unsigned char Comp[24]; // MC_COMP_BYTES is in MatComp.h, but don't want to couple
} mdrCompBone_t;

typedef struct {
vec3_t bounds[2]; // bounds of all surfaces of all LOD's for this frame
vec3_t localOrigin; // midpoint of bounds, used for sphere cull
float radius; // dist from localOrigin to corner
mdrCompBone_t bones[1]; // [numBones]
} mdrCompFrame_t;

typedef struct {
int numSurfaces;
int ofsSurfaces; // first surface, others follow
int ofsEnd; // next lod follows
} mdrLOD_t;

typedef struct {
int boneIndex;
char name[32];
} mdrTag_t;

typedef struct {
int ident;
int version;

char name[MAX_QPATH]; // model name

// frames and bones are shared by all levels of detail
int numFrames;
int numBones;
int ofsFrames; // mdrFrame_t[numFrames]

// each level of detail has completely separate sets of surfaces
int numLODs;
int ofsLODs;

int numTags;
int ofsTags;

int ofsEnd; // end of file
} mdrHeader_t;

/*
==============================================================================
Expand Down
36 changes: 2 additions & 34 deletions codemp/rd-common/tr_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,39 +296,6 @@ typedef struct skin_s {
/*
Ghoul2 Insert End
*/
typedef enum {
MOD_BAD,
MOD_BRUSH,
MOD_MESH,
/*
Ghoul2 Insert Start
*/
MOD_MDXM,
MOD_MDXA
/*
Ghoul2 Insert End
*/
} modtype_t;

typedef struct model_s {
char name[MAX_QPATH];
modtype_t type;
int index; // model = tr.models[model->index]

int dataSize; // just for listing purposes
struct bmodel_s *bmodel; // only if type == MOD_BRUSH
md3Header_t *md3[MD3_MAX_LODS]; // only if type == MOD_MESH
/*
Ghoul2 Insert Start
*/
mdxmHeader_t *mdxm; // only if type == MOD_GL2M which is a GHOUL II Mesh file NOT a GHOUL II animation file
mdxaHeader_t *mdxa; // only if type == MOD_GL2A which is a GHOUL II Animation file
/*
Ghoul2 Insert End
*/
int numLods;
qboolean bspInstance;
} model_t;

#define MAX_RENDER_STRINGS 8
#define MAX_RENDER_STRING_LENGTH 32
Expand Down Expand Up @@ -372,7 +339,8 @@ typedef int stereoFrame_t;
typedef enum { // r_ext_preferred_tc_method
TC_NONE,
TC_S3TC,
TC_S3TC_DXT
TC_S3TC_DXT,
TC_S3TC_ARB
} textureCompression_t;

typedef struct glconfig_s {
Expand Down
10 changes: 5 additions & 5 deletions codemp/rd-dedicated/G2_API.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2485,6 +2485,11 @@ qboolean G2API_SkinlessModel(CGhoul2Info_v& ghoul2, int modelIndex)
return qtrue;
}

int G2API_Ghoul2Size(CGhoul2Info_v &ghoul2)
{
return ghoul2.size();
}

//#ifdef _SOF2
#ifdef _G2_GORE
void ResetGoreTag(); // put here to reduce coupling
Expand Down Expand Up @@ -2521,11 +2526,6 @@ void G2API_ClearSkinGore ( CGhoul2Info_v &ghoul2 )
}
}

int G2API_Ghoul2Size ( CGhoul2Info_v &ghoul2 )
{
return ghoul2.size();
}

extern int G2_DecideTraceLod(CGhoul2Info &ghoul2, int useLod);
void G2API_AddSkinGore(CGhoul2Info_v &ghoul2,SSkinGoreData &gore)
{
Expand Down
1 change: 1 addition & 0 deletions codemp/rd-dedicated/G2_bolts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.

#include "ghoul2/G2.h"
#include "ghoul2/g2_local.h"
#include "tr_local.h"

//=====================================================================================================================
// Bolt List handling routines - so entities can attach themselves to any part of the model in question
Expand Down
11 changes: 7 additions & 4 deletions codemp/rd-dedicated/G2_misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
#include "server/server.h"
#include "ghoul2/g2_local.h"

#include "tr_local.h"
#ifdef _G2_GORE
#include "ghoul2/G2_gore.h"

#include "tr_local.h"

#define GORE_TAG_UPPER (256)
#define GORE_TAG_MASK (~255)

Expand Down Expand Up @@ -549,6 +548,7 @@ void G2_TransformModel(CGhoul2Info_v &ghoul2, const int frameNum, vec3_t scale,
vec3_t correctScale;
qboolean firstModelOnly = qfalse;

#ifdef _G2_GORE
if ( cg_g2MarksAllModels == NULL )
{
cg_g2MarksAllModels = ri.Cvar_Get( "cg_g2MarksAllModels", "0", 0, "" );
Expand All @@ -559,7 +559,7 @@ void G2_TransformModel(CGhoul2Info_v &ghoul2, const int frameNum, vec3_t scale,
{
firstModelOnly = qtrue;
}

#endif

VectorCopy(scale, correctScale);
// check for scales of 0 - that's the default I believe
Expand Down Expand Up @@ -1497,6 +1497,7 @@ void G2_TraceModels(CGhoul2Info_v &ghoul2, vec3_t rayStart, vec3_t rayEnd, Colli
shader_t *cust_shader;
qboolean firstModelOnly = qfalse;

#ifdef _G2_GORE
if ( cg_g2MarksAllModels == NULL )
{
cg_g2MarksAllModels = ri.Cvar_Get( "cg_g2MarksAllModels", "0", 0, "" );
Expand All @@ -1507,6 +1508,7 @@ void G2_TraceModels(CGhoul2Info_v &ghoul2, vec3_t rayStart, vec3_t rayEnd, Colli
{
firstModelOnly = qtrue;
}
#endif

// walk each possible model for this entity and try tracing against it
for (i=0; i<ghoul2.size(); i++)
Expand Down Expand Up @@ -1552,14 +1554,15 @@ void G2_TraceModels(CGhoul2Info_v &ghoul2, vec3_t rayStart, vec3_t rayEnd, Colli
}

lod = G2_DecideTraceLod(ghoul2[i],useLod);
#ifdef _G2_GORE
if ( skipIfLODNotMatch )
{//we only want to hit this SPECIFIC LOD...
if ( lod != useLod )
{//doesn't match, skip this model
continue;
}
}

#endif
//reset the quick surface override lookup
G2_FindOverrideSurface(-1, ghoul2[i].mSlist);

Expand Down
Loading

0 comments on commit be28b4e

Please sign in to comment.