mirror of
https://github.com/id-Software/Quake-Tools.git
synced 2026-03-20 00:49:35 +01:00
The source release of the qutils.
This commit is contained in:
222
qutils/TEXMAKE/TEXMAKE.C
Normal file
222
qutils/TEXMAKE/TEXMAKE.C
Normal file
@@ -0,0 +1,222 @@
|
||||
#include "cmdlib.h"
|
||||
#include "mathlib.h"
|
||||
#include "lbmlib.h"
|
||||
#include "trilib.h"
|
||||
|
||||
|
||||
triangle_t *faces;
|
||||
int numfaces;
|
||||
|
||||
byte pic[64000];
|
||||
byte *palette;
|
||||
|
||||
int width, height;
|
||||
int iwidth, iheight;
|
||||
|
||||
float scale;
|
||||
|
||||
char texname[20];
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
BoundFaces
|
||||
================
|
||||
*/
|
||||
vec3_t mins, maxs;
|
||||
|
||||
void BoundFaces (void)
|
||||
{
|
||||
int i,j,k;
|
||||
triangle_t *pol;
|
||||
float v;
|
||||
|
||||
for (i=0 ; i<numfaces ; i++)
|
||||
{
|
||||
pol = &faces[i];
|
||||
for (j=0 ; j<3 ; j++)
|
||||
for (k=0 ; k<3 ; k++)
|
||||
{
|
||||
v = pol->verts[j][k];
|
||||
if (v<mins[k])
|
||||
mins[k] = v;
|
||||
if (v>maxs[k])
|
||||
maxs[k] = v;
|
||||
}
|
||||
}
|
||||
|
||||
for (i=0 ; i<3 ; i++)
|
||||
{
|
||||
mins[i] = floor(mins[i]);
|
||||
maxs[i] = ceil(maxs[i]);
|
||||
}
|
||||
|
||||
width = maxs[0] - mins[0];
|
||||
height = maxs[2] - mins[2];
|
||||
|
||||
printf ("width: %i height: %i\n",width, height);
|
||||
|
||||
scale = 8;
|
||||
if (width*scale >= 150)
|
||||
scale = 150.0 / width;
|
||||
if (height*scale >= 190)
|
||||
scale = 190.0 / height;
|
||||
iwidth = ceil(width*scale) + 4;
|
||||
iheight = ceil(height*scale) + 4;
|
||||
|
||||
printf ("scale: %f\n",scale);
|
||||
printf ("iwidth: %i iheight: %i\n",iwidth, iheight);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
============
|
||||
DrawLine
|
||||
|
||||
Draw a fat line
|
||||
============
|
||||
*/
|
||||
void DrawLine (int x1, int y1, int x2, int y2)
|
||||
{
|
||||
int dx, dy;
|
||||
int adx, ady;
|
||||
int count;
|
||||
float xfrac, yfrac, xstep, ystep;
|
||||
unsigned sx, sy;
|
||||
float u, v;
|
||||
|
||||
dx = x2 - x1;
|
||||
dy = y2 - y1;
|
||||
adx = abs(dx);
|
||||
ady = abs(dy);
|
||||
|
||||
count = adx > ady ? adx : ady;
|
||||
count ++;
|
||||
|
||||
if (count > 300)
|
||||
return; // don't ever hang up on bad data
|
||||
|
||||
xfrac = x1;
|
||||
yfrac = y1;
|
||||
|
||||
xstep = (float)dx / count;
|
||||
ystep = (float)dy / count;
|
||||
|
||||
do
|
||||
{
|
||||
for (u=-0.1 ; u<=0.9 ; u+=0.999)
|
||||
for (v=-0.1 ; v<=0.9 ; v+=0.999)
|
||||
{
|
||||
sx = xfrac+u;
|
||||
sy = yfrac+v;
|
||||
if (sx < 320 && sy < 200)
|
||||
pic[sy*320+sx] = 255;
|
||||
}
|
||||
|
||||
xfrac += xstep;
|
||||
yfrac += ystep;
|
||||
count--;
|
||||
} while (count > 0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
============
|
||||
AddFace
|
||||
============
|
||||
*/
|
||||
void AddFace (triangle_t *f)
|
||||
{
|
||||
vec3_t v1, v2, normal;
|
||||
int basex, basey;
|
||||
int i, j;
|
||||
int coords[3][2];
|
||||
|
||||
//
|
||||
// determine which side to map the teture to
|
||||
//
|
||||
VectorSubtract (f->verts[0], f->verts[1], v1);
|
||||
VectorSubtract (f->verts[2], f->verts[1], v2);
|
||||
CrossProduct (v1, v2, normal);
|
||||
|
||||
if (normal[1] > 0)
|
||||
basex = iwidth + 2;
|
||||
else
|
||||
basex = 2;
|
||||
basey = 2;
|
||||
|
||||
for (i=0 ; i<3 ; i++)
|
||||
{
|
||||
coords[i][0] = Q_rint((f->verts[i][0] - mins[0])*scale + basex);
|
||||
coords[i][1] = Q_rint( (maxs[2] - f->verts[i][2])*scale + basey);
|
||||
}
|
||||
|
||||
//
|
||||
// draw lines
|
||||
//
|
||||
for (i=0 ; i<3 ; i++)
|
||||
{
|
||||
j = (i+1)%3;
|
||||
DrawLine (coords[i][0], coords[i][1],
|
||||
coords[j][0], coords[j][1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
============
|
||||
CalcPalette
|
||||
============
|
||||
*/
|
||||
void CalcPalette (void)
|
||||
{
|
||||
byte *picture;
|
||||
LoadLBM (ExpandPath("id1/gfx/gamepal.lbm"), &picture, &palette);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
============
|
||||
main
|
||||
============
|
||||
*/
|
||||
void main (int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
char filename[1024];
|
||||
|
||||
if (argc == 1)
|
||||
Error ("texmake polfile[.idpol]\nGenerates polfile.lbm and polfile_t.idpol\n");
|
||||
|
||||
//
|
||||
// read the polfile
|
||||
//
|
||||
strcpy (filename, argv[1]);
|
||||
DefaultExtension (filename, ".tri");
|
||||
SetQdirFromPath (filename);
|
||||
LoadTriangleList (filename, &faces, &numfaces);
|
||||
printf ("numfaces: %i\n",numfaces);
|
||||
|
||||
//
|
||||
// generate the texture coordinates
|
||||
//
|
||||
BoundFaces ();
|
||||
|
||||
//
|
||||
// generate the lbm
|
||||
//
|
||||
for (i=0 ; i<numfaces ; i++)
|
||||
AddFace (&faces[i]);
|
||||
|
||||
//
|
||||
// save the lbm
|
||||
//
|
||||
strcpy (filename, argv[1]);
|
||||
StripExtension (filename);
|
||||
strcat (filename, ".lbm");
|
||||
|
||||
printf ("output file: %s\n",filename);
|
||||
CalcPalette ();
|
||||
WriteLBMfile (filename, pic, 320, 200, palette);
|
||||
}
|
||||
269
qutils/TEXMAKE/TEXMAKE.MAK
Normal file
269
qutils/TEXMAKE/TEXMAKE.MAK
Normal file
@@ -0,0 +1,269 @@
|
||||
# Microsoft Developer Studio Generated NMAKE File, Format Version 4.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=texmake - Win32 Debug
|
||||
!MESSAGE No configuration specified. Defaulting to texmake - Win32 Debug.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "texmake - Win32 Release" && "$(CFG)" !=\
|
||||
"texmake - Win32 Debug"
|
||||
!MESSAGE Invalid configuration "$(CFG)" specified.
|
||||
!MESSAGE You can specify a configuration when running NMAKE on this makefile
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "texmake.mak" CFG="texmake - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "texmake - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "texmake - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
!ERROR An invalid configuration is specified.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(OS)" == "Windows_NT"
|
||||
NULL=
|
||||
!ELSE
|
||||
NULL=nul
|
||||
!ENDIF
|
||||
################################################################################
|
||||
# Begin Project
|
||||
# PROP Target_Last_Scanned "texmake - Win32 Debug"
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "texmake - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Target_Dir ""
|
||||
OUTDIR=.\Release
|
||||
INTDIR=.\Release
|
||||
|
||||
ALL : "$(OUTDIR)\texmake.exe"
|
||||
|
||||
CLEAN :
|
||||
-@erase ".\Release\texmake.exe"
|
||||
-@erase ".\Release\mathlib.obj"
|
||||
-@erase ".\Release\cmdlib.obj"
|
||||
-@erase ".\Release\lbmlib.obj"
|
||||
-@erase ".\Release\trilib.obj"
|
||||
-@erase ".\Release\texmake.obj"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c
|
||||
# ADD CPP /nologo /GX /O2 /I "..\common" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c
|
||||
CPP_PROJ=/nologo /ML /GX /O2 /I "..\common" /D "WIN32" /D "NDEBUG" /D\
|
||||
"_CONSOLE" /Fp"$(INTDIR)/texmake.pch" /YX /Fo"$(INTDIR)/" /c
|
||||
CPP_OBJS=.\Release/
|
||||
CPP_SBRS=
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)/texmake.bsc"
|
||||
BSC32_SBRS=
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
|
||||
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
|
||||
odbccp32.lib /nologo /subsystem:console /incremental:no\
|
||||
/pdb:"$(OUTDIR)/texmake.pdb" /machine:I386 /out:"$(OUTDIR)/texmake.exe"
|
||||
LINK32_OBJS= \
|
||||
".\Release\mathlib.obj" \
|
||||
".\Release\cmdlib.obj" \
|
||||
".\Release\lbmlib.obj" \
|
||||
".\Release\trilib.obj" \
|
||||
".\Release\texmake.obj"
|
||||
|
||||
"$(OUTDIR)\texmake.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "texmake - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
OUTDIR=.\Debug
|
||||
INTDIR=.\Debug
|
||||
|
||||
ALL : "$(OUTDIR)\texmake.exe"
|
||||
|
||||
CLEAN :
|
||||
-@erase ".\Debug\vc40.pdb"
|
||||
-@erase ".\Debug\vc40.idb"
|
||||
-@erase ".\Debug\texmake.exe"
|
||||
-@erase ".\Debug\cmdlib.obj"
|
||||
-@erase ".\Debug\lbmlib.obj"
|
||||
-@erase ".\Debug\trilib.obj"
|
||||
-@erase ".\Debug\mathlib.obj"
|
||||
-@erase ".\Debug\texmake.obj"
|
||||
-@erase ".\Debug\texmake.ilk"
|
||||
-@erase ".\Debug\texmake.pdb"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c
|
||||
# ADD CPP /nologo /Gm /GX /Zi /Od /I "..\common" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c
|
||||
CPP_PROJ=/nologo /MLd /Gm /GX /Zi /Od /I "..\common" /D "WIN32" /D "_DEBUG" /D\
|
||||
"_CONSOLE" /Fp"$(INTDIR)/texmake.pch" /YX /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c
|
||||
CPP_OBJS=.\Debug/
|
||||
CPP_SBRS=
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)/texmake.bsc"
|
||||
BSC32_SBRS=
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386
|
||||
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
|
||||
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
|
||||
odbccp32.lib /nologo /subsystem:console /incremental:yes\
|
||||
/pdb:"$(OUTDIR)/texmake.pdb" /debug /machine:I386 /out:"$(OUTDIR)/texmake.exe"
|
||||
LINK32_OBJS= \
|
||||
".\Debug\cmdlib.obj" \
|
||||
".\Debug\lbmlib.obj" \
|
||||
".\Debug\trilib.obj" \
|
||||
".\Debug\mathlib.obj" \
|
||||
".\Debug\texmake.obj"
|
||||
|
||||
"$(OUTDIR)\texmake.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
.c{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cpp{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cxx{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.c{$(CPP_SBRS)}.sbr:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cpp{$(CPP_SBRS)}.sbr:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cxx{$(CPP_SBRS)}.sbr:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
################################################################################
|
||||
# Begin Target
|
||||
|
||||
# Name "texmake - Win32 Release"
|
||||
# Name "texmake - Win32 Debug"
|
||||
|
||||
!IF "$(CFG)" == "texmake - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "texmake - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\texmake.c
|
||||
DEP_CPP_TEXMA=\
|
||||
".\..\common\cmdlib.h"\
|
||||
".\..\common\mathlib.h"\
|
||||
".\..\common\lbmlib.h"\
|
||||
".\..\common\trilib.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\texmake.obj" : $(SOURCE) $(DEP_CPP_TEXMA) "$(INTDIR)"
|
||||
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=\quake\utils2\common\mathlib.c
|
||||
DEP_CPP_MATHL=\
|
||||
".\..\common\cmdlib.h"\
|
||||
".\..\common\mathlib.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\mathlib.obj" : $(SOURCE) $(DEP_CPP_MATHL) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=\quake\utils2\common\lbmlib.c
|
||||
DEP_CPP_LBMLI=\
|
||||
".\..\common\cmdlib.h"\
|
||||
".\..\common\lbmlib.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\lbmlib.obj" : $(SOURCE) $(DEP_CPP_LBMLI) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=\quake\utils2\common\cmdlib.c
|
||||
DEP_CPP_CMDLI=\
|
||||
".\..\common\cmdlib.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
{$(INCLUDE)}"\sys\STAT.H"\
|
||||
|
||||
|
||||
"$(INTDIR)\cmdlib.obj" : $(SOURCE) $(DEP_CPP_CMDLI) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=\quake\utils2\common\trilib.c
|
||||
DEP_CPP_TRILI=\
|
||||
".\..\common\cmdlib.h"\
|
||||
".\..\common\mathlib.h"\
|
||||
".\..\common\trilib.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\trilib.obj" : $(SOURCE) $(DEP_CPP_TRILI) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
################################################################################
|
||||
BIN
qutils/TEXMAKE/TEXMAKE.MDP
Normal file
BIN
qutils/TEXMAKE/TEXMAKE.MDP
Normal file
Binary file not shown.
BIN
qutils/TEXMAKE/TEXMAKE.NCB
Normal file
BIN
qutils/TEXMAKE/TEXMAKE.NCB
Normal file
Binary file not shown.
Reference in New Issue
Block a user