2006-03-20 16:43:15 +00:00
|
|
|
/*
|
2014-06-01 17:55:23 +00:00
|
|
|
* Portions of this file are copyright Rebirth contributors and licensed as
|
|
|
|
* described in COPYING.txt.
|
|
|
|
* Portions of this file are copyright Parallax Software and licensed
|
|
|
|
* according to the Parallax license below.
|
|
|
|
* See COPYING.txt for license details.
|
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
|
|
|
|
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
|
|
|
|
END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
|
|
|
|
ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
|
|
|
|
IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
|
|
|
|
SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
|
|
|
|
FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
|
|
|
|
CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
|
2013-02-24 02:39:48 +00:00
|
|
|
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
|
2013-03-03 01:03:33 +00:00
|
|
|
COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
2006-03-20 16:43:15 +00:00
|
|
|
*/
|
2008-04-06 20:23:28 +00:00
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
/*
|
|
|
|
*
|
2008-04-06 20:23:28 +00:00
|
|
|
* Header for polyobj.c, the polygon object code
|
2006-03-20 16:43:15 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2015-01-29 04:27:35 +00:00
|
|
|
#pragma once
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
#include "vecmat.h"
|
|
|
|
#include "3d.h"
|
|
|
|
|
2015-01-29 04:27:35 +00:00
|
|
|
struct bitmap_index;
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2013-10-09 03:12:09 +00:00
|
|
|
#ifdef __cplusplus
|
2015-02-14 22:48:28 +00:00
|
|
|
#include <cstddef>
|
2015-04-02 02:36:57 +00:00
|
|
|
#include <memory>
|
|
|
|
#include <physfs.h>
|
2014-07-24 03:25:00 +00:00
|
|
|
#include "pack.h"
|
2013-10-09 03:12:09 +00:00
|
|
|
|
2016-01-09 16:38:15 +00:00
|
|
|
#ifdef dsx
|
2015-12-13 18:00:49 +00:00
|
|
|
namespace dsx {
|
2016-06-25 23:21:36 +00:00
|
|
|
struct robot_info;
|
2015-12-13 18:00:48 +00:00
|
|
|
struct glow_values_t;
|
2013-03-03 01:03:33 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_I)
|
2016-06-25 23:21:36 +00:00
|
|
|
constexpr unsigned MAX_POLYGON_MODELS = 85;
|
2013-03-03 01:03:33 +00:00
|
|
|
#elif defined(DXX_BUILD_DESCENT_II)
|
2016-06-25 23:21:36 +00:00
|
|
|
constexpr unsigned MAX_POLYGON_MODELS = 200;
|
2006-03-20 16:43:15 +00:00
|
|
|
#endif
|
2013-03-24 20:32:01 +00:00
|
|
|
|
|
|
|
// array of names of currently-loaded models
|
2015-08-12 03:11:46 +00:00
|
|
|
extern array<char[13], MAX_POLYGON_MODELS> Pof_names;
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2012-11-11 00:12:17 +00:00
|
|
|
//for each model, a model number for dying & dead variants, or -1 if none
|
2015-04-02 02:36:52 +00:00
|
|
|
extern array<int, MAX_POLYGON_MODELS> Dying_modelnums, Dead_modelnums;
|
2016-06-25 23:21:36 +00:00
|
|
|
}
|
2013-03-24 20:32:01 +00:00
|
|
|
#endif
|
2013-03-03 01:03:33 +00:00
|
|
|
#define MAX_SUBMODELS 10
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2015-12-13 18:00:49 +00:00
|
|
|
namespace dcx {
|
2015-12-13 18:00:48 +00:00
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
//used to describe a polygon model
|
2014-07-24 03:25:00 +00:00
|
|
|
struct polymodel : prohibit_void_ptr<polymodel>
|
2013-12-22 22:03:07 +00:00
|
|
|
{
|
2014-10-26 22:51:27 +00:00
|
|
|
unsigned n_models;
|
2013-02-21 00:20:26 +00:00
|
|
|
int model_data_size;
|
2014-07-24 03:12:57 +00:00
|
|
|
std::unique_ptr<ubyte[]> model_data;
|
2014-07-24 03:25:00 +00:00
|
|
|
array<int, MAX_SUBMODELS> submodel_ptrs;
|
|
|
|
array<vms_vector, MAX_SUBMODELS> submodel_offsets;
|
|
|
|
array<vms_vector, MAX_SUBMODELS> submodel_norms; // norm for sep plane
|
|
|
|
array<vms_vector, MAX_SUBMODELS> submodel_pnts; // point on sep plane
|
|
|
|
array<fix, MAX_SUBMODELS> submodel_rads; // radius for each submodel
|
|
|
|
array<ubyte, MAX_SUBMODELS> submodel_parents; // what is parent for each submodel
|
|
|
|
array<vms_vector, MAX_SUBMODELS> submodel_mins;
|
|
|
|
array<vms_vector, MAX_SUBMODELS> submodel_maxs;
|
2013-02-21 00:20:26 +00:00
|
|
|
vms_vector mins,maxs; // min,max for whole model
|
|
|
|
fix rad;
|
|
|
|
ushort first_texture;
|
2014-10-26 22:51:27 +00:00
|
|
|
ubyte n_textures;
|
2013-02-21 00:20:26 +00:00
|
|
|
ubyte simpler_model; // alternate model with less detail (0 if none, model_num+1 else)
|
|
|
|
//vms_vector min,max;
|
2014-07-24 03:25:00 +00:00
|
|
|
};
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2015-02-14 22:48:28 +00:00
|
|
|
class submodel_angles
|
|
|
|
{
|
|
|
|
typedef const array<vms_angvec, MAX_SUBMODELS> array_type;
|
|
|
|
array_type *p;
|
|
|
|
public:
|
|
|
|
submodel_angles(std::nullptr_t) : p(nullptr) {}
|
|
|
|
submodel_angles(array_type &a) : p(&a) {}
|
|
|
|
explicit operator bool() const { return p != nullptr; }
|
|
|
|
typename array_type::const_reference operator[](std::size_t i) const
|
|
|
|
{
|
|
|
|
array_type &a = *p;
|
|
|
|
return a[i];
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-02-21 00:20:26 +00:00
|
|
|
// how many polygon objects there are
|
2014-02-09 18:09:54 +00:00
|
|
|
extern unsigned N_polygon_models;
|
2016-06-25 23:21:36 +00:00
|
|
|
void init_polygon_models();
|
2015-12-13 18:00:48 +00:00
|
|
|
|
|
|
|
}
|
2016-06-25 23:21:36 +00:00
|
|
|
#ifdef dsx
|
|
|
|
namespace dsx {
|
|
|
|
// array of pointers to polygon objects
|
|
|
|
extern array<polymodel, MAX_POLYGON_MODELS> Polygon_models;
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2008-11-14 16:56:40 +00:00
|
|
|
void free_polygon_models();
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2013-06-08 22:24:17 +00:00
|
|
|
int load_polygon_model(const char *filename,int n_textures,int first_texture,robot_info *r);
|
2016-06-25 23:21:36 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace dcx {
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2015-02-14 22:48:29 +00:00
|
|
|
class alternate_textures
|
|
|
|
{
|
|
|
|
const bitmap_index *p;
|
|
|
|
public:
|
|
|
|
alternate_textures() : p(nullptr) {}
|
|
|
|
alternate_textures(std::nullptr_t) : p(nullptr) {}
|
|
|
|
template <std::size_t N>
|
|
|
|
alternate_textures(const std::array<bitmap_index, N> &a) : p(a.data())
|
|
|
|
{
|
|
|
|
}
|
|
|
|
operator const bitmap_index *() const { return p; }
|
|
|
|
};
|
|
|
|
|
2016-06-25 23:21:36 +00:00
|
|
|
}
|
|
|
|
|
2016-01-09 16:38:15 +00:00
|
|
|
#ifdef dsx
|
2015-12-22 04:18:50 +00:00
|
|
|
namespace dsx {
|
2013-02-21 00:20:26 +00:00
|
|
|
// draw a polygon model
|
2015-02-14 22:48:29 +00:00
|
|
|
void draw_polygon_model(const vms_vector &pos,const vms_matrix *orient,submodel_angles anim_angles,int model_num,int flags,g3s_lrgb lrgb,glow_values_t *glow_values, alternate_textures);
|
2015-12-22 04:18:50 +00:00
|
|
|
}
|
|
|
|
#endif
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2013-02-21 00:20:26 +00:00
|
|
|
// draws the given model in the current canvas. The distance is set to
|
|
|
|
// more-or-less fill the canvas. Note that this routine actually renders
|
|
|
|
// into an off-screen canvas that it creates, then copies to the current
|
|
|
|
// canvas.
|
2014-09-20 23:47:27 +00:00
|
|
|
void draw_model_picture(uint_fast32_t mn,vms_angvec *orient_angles);
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2013-03-24 20:32:01 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_I) || defined(DXX_BUILD_DESCENT_II)
|
2013-03-03 01:03:33 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_I)
|
2006-03-20 16:43:15 +00:00
|
|
|
#define MAX_POLYOBJ_TEXTURES 50
|
2013-03-03 01:03:33 +00:00
|
|
|
#elif defined(DXX_BUILD_DESCENT_II)
|
|
|
|
// free up a model, getting rid of all its memory
|
|
|
|
void free_model(polymodel *po);
|
|
|
|
|
|
|
|
#define MAX_POLYOBJ_TEXTURES 100
|
2016-07-16 16:52:04 +00:00
|
|
|
constexpr unsigned N_D2_POLYGON_MODELS = 166;
|
2013-03-03 01:03:33 +00:00
|
|
|
#endif
|
2014-08-16 22:18:14 +00:00
|
|
|
extern array<grs_bitmap *, MAX_POLYOBJ_TEXTURES> texture_list;
|
2013-03-24 20:32:01 +00:00
|
|
|
#endif
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2015-12-13 18:00:49 +00:00
|
|
|
namespace dcx {
|
2013-03-03 01:03:33 +00:00
|
|
|
/*
|
2016-01-09 16:38:14 +00:00
|
|
|
* reads a polymodel structure from a PHYSFS_File
|
2013-03-03 01:03:33 +00:00
|
|
|
*/
|
2015-04-02 02:36:57 +00:00
|
|
|
extern void polymodel_read(polymodel *pm, PHYSFS_File *fp);
|
2015-12-13 18:00:48 +00:00
|
|
|
}
|
2015-12-04 03:36:31 +00:00
|
|
|
#if 0
|
2015-04-02 02:36:57 +00:00
|
|
|
void polymodel_write(PHYSFS_File *fp, const polymodel &pm);
|
2015-12-04 03:36:31 +00:00
|
|
|
#endif
|
2006-11-22 05:35:10 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* routine which allocates, reads, and inits a polymodel's model_data
|
|
|
|
*/
|
2015-04-02 02:36:57 +00:00
|
|
|
void polygon_model_data_read(polymodel *pm, PHYSFS_File *fp);
|
2011-01-22 17:06:42 +00:00
|
|
|
|
2013-10-09 03:12:09 +00:00
|
|
|
#endif
|