*** empty log message ***

This commit is contained in:
David Rose 2001-04-30 16:49:58 +00:00
parent 68fc0979ff
commit c4a8d6e24b
13 changed files with 185 additions and 40 deletions

View File

@ -1117,7 +1117,7 @@ translate_mat(FLOATTYPE tx, FLOATTYPE ty, FLOATTYPE tz) {
// degrees counterclockwise about the indicated vector. // degrees counterclockwise about the indicated vector.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE_LINMATH FLOATNAME(LMatrix4) FLOATNAME(LMatrix4):: INLINE_LINMATH FLOATNAME(LMatrix4) FLOATNAME(LMatrix4)::
rotate_mat(FLOATTYPE angle, FLOATNAME(LVecBase3) &axis, rotate_mat(FLOATTYPE angle, FLOATNAME(LVecBase3) axis,
CoordinateSystem cs) { CoordinateSystem cs) {
if (cs == CS_default) { if (cs == CS_default) {

View File

@ -106,7 +106,7 @@ PUBLISHED:
INLINE_LINMATH static FLOATNAME(LMatrix4) translate_mat(const FLOATNAME(LVecBase3) &trans); INLINE_LINMATH static FLOATNAME(LMatrix4) translate_mat(const FLOATNAME(LVecBase3) &trans);
INLINE_LINMATH static FLOATNAME(LMatrix4) translate_mat(FLOATTYPE tx, FLOATTYPE ty, FLOATTYPE tz); INLINE_LINMATH static FLOATNAME(LMatrix4) translate_mat(FLOATTYPE tx, FLOATTYPE ty, FLOATTYPE tz);
INLINE_LINMATH static FLOATNAME(LMatrix4) rotate_mat(FLOATTYPE angle, INLINE_LINMATH static FLOATNAME(LMatrix4) rotate_mat(FLOATTYPE angle,
FLOATNAME(LVecBase3) &axis, FLOATNAME(LVecBase3) axis,
CoordinateSystem cs = CS_default); CoordinateSystem cs = CS_default);
INLINE_LINMATH static FLOATNAME(LMatrix4) scale_mat(const FLOATNAME(LVecBase3) &scale); INLINE_LINMATH static FLOATNAME(LMatrix4) scale_mat(const FLOATNAME(LVecBase3) &scale);
INLINE_LINMATH static FLOATNAME(LMatrix4) scale_mat(FLOATTYPE sx, FLOATTYPE sy, FLOATTYPE sz); INLINE_LINMATH static FLOATNAME(LMatrix4) scale_mat(FLOATTYPE sx, FLOATTYPE sy, FLOATTYPE sz);

View File

@ -3,7 +3,7 @@
#define LOCAL_LIBS \ #define LOCAL_LIBS \
progbase progbase
#define OTHER_LIBS \ #define OTHER_LIBS \
egg:c panda:m egg:c linmath:c panda:m
#define SOURCES \ #define SOURCES \
eggBase.cxx eggBase.h \ eggBase.cxx eggBase.h \

View File

@ -29,18 +29,3 @@
eggTopstrip.cxx eggTopstrip.h eggTopstrip.cxx eggTopstrip.h
#end bin_target #end bin_target
#begin bin_target
#define TARGET lwo2egg
#define LOCAL_LIBS lwo lwoegg eggbase progbase
#define OTHER_LIBS \
egg:c pandaegg:m \
linmath:c panda:m \
express:c pandaexpress:m \
dtoolutil:c dconfig:c dtoolconfig:m dtool:m pystub
#define SOURCES \
lwoToEgg.cxx lwoToEgg.h
#end bin_target

View File

@ -83,13 +83,3 @@
lwoVertexMap.h lwoVertexMap.h
#end ss_lib_target #end ss_lib_target
#begin test_bin_target
#define TARGET test_lwo
#define LOCAL_LIBS lwo $[LOCAL_LIBS]
#define OTHER_LIBS $[OTHER_LIBS] pystub:c
#define SOURCES \
test_lwo.cxx
#end test_bin_target

View File

@ -15,9 +15,6 @@
// Description : The tMap chunk within a LwoSurfaceBlock chunk. // Description : The tMap chunk within a LwoSurfaceBlock chunk.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
class LwoSurfaceBlockTMap : public LwoGroupChunk { class LwoSurfaceBlockTMap : public LwoGroupChunk {
public:
string _ordinal;
public: public:
virtual bool read_iff(IffInputFile *in, size_t stop_at); virtual bool read_iff(IffInputFile *in, size_t stop_at);
virtual void write(ostream &out, int indent_level = 0) const; virtual void write(ostream &out, int indent_level = 0) const;

View File

@ -31,6 +31,7 @@ CLwoSurface(LwoToEggConverter *converter, const LwoSurface *surface) :
_flags = 0; _flags = 0;
_checked_texture = false; _checked_texture = false;
_has_uvs = false; _has_uvs = false;
_map_uvs = NULL;
_block = (CLwoSurfaceBlock *)NULL; _block = (CLwoSurfaceBlock *)NULL;
// Walk through the chunk list, looking for some basic properties. // Walk through the chunk list, looking for some basic properties.
@ -207,6 +208,8 @@ check_texture() {
} }
_checked_texture = true; _checked_texture = true;
_egg_texture = (EggTexture *)NULL; _egg_texture = (EggTexture *)NULL;
_has_uvs = false;
_map_uvs = NULL;
if (_block == (CLwoSurfaceBlock *)NULL) { if (_block == (CLwoSurfaceBlock *)NULL) {
// No texture. Not even a shader block. // No texture. Not even a shader block.
@ -233,7 +236,41 @@ check_texture() {
Filename pathname = _converter->convert_texture_path(clip->_filename); Filename pathname = _converter->convert_texture_path(clip->_filename);
_egg_texture = new EggTexture("clip" + format_string(clip_index), pathname); _egg_texture = new EggTexture("clip" + format_string(clip_index), pathname);
_has_uvs = true;
// Do we need to generate UV's?
switch (_block->_projection_mode) {
case LwoSurfaceBlockProjection::M_planar:
_has_uvs = true;
_map_uvs = &CLwoSurface::map_planar;
break;
case LwoSurfaceBlockProjection::M_cylindrical:
_has_uvs = true;
_map_uvs = &CLwoSurface::map_cylindrical;
break;
case LwoSurfaceBlockProjection::M_spherical:
_has_uvs = true;
_map_uvs = &CLwoSurface::map_spherical;
break;
case LwoSurfaceBlockProjection::M_cubic:
_has_uvs = true;
_map_uvs = &CLwoSurface::map_cubic;
break;
case LwoSurfaceBlockProjection::M_front:
// Cannot generate "front" UV's, since this depends on a camera.
// Is it supposed to be updated in real time, like a projected
// texture?
break;
case LwoSurfaceBlockProjection::M_uv:
// "uv" projection means to use the existing UV's already defined
// for the vertex. This case was already handled in the code that
// created the EggVertex pointers.
break;
};
return true; return true;
} }
@ -247,6 +284,8 @@ check_texture() {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void CLwoSurface:: void CLwoSurface::
generate_uvs(vector_PT_EggVertex &egg_vertices) { generate_uvs(vector_PT_EggVertex &egg_vertices) {
nassertv(_map_uvs != NULL);
// To do this properly near seams and singularities (for instance, // To do this properly near seams and singularities (for instance,
// the back seam and the poles of the spherical map), we will need // the back seam and the poles of the spherical map), we will need
// to know the polygon's centroid. // to know the polygon's centroid.
@ -264,10 +303,10 @@ generate_uvs(vector_PT_EggVertex &egg_vertices) {
for (vi = egg_vertices.begin(); vi != egg_vertices.end(); ++vi) { for (vi = egg_vertices.begin(); vi != egg_vertices.end(); ++vi) {
EggVertex *egg_vertex = (*vi); EggVertex *egg_vertex = (*vi);
LPoint3d pos = egg_vertex->get_pos3(); LPoint3d pos = egg_vertex->get_pos3();
egg_vertex->set_uv(map_spherical(pos, centroid)); LPoint2d uv = (this->*_map_uvs)(pos, centroid);
egg_vertex->set_uv(uv);
} }
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: CLwoSurface::map_planar // Function: CLwoSurface::map_planar
@ -379,13 +418,14 @@ map_cylindrical(const LPoint3d &pos, const LPoint3d &centroid) const {
// using a cubic projection. // using a cubic projection.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
LPoint2d CLwoSurface:: LPoint2d CLwoSurface::
map_cubic(const LPoint3d &pos, const LPoint3d &) const { map_cubic(const LPoint3d &pos, const LPoint3d &centroid) const {
// A cubic projection is a planar projection, but we eliminate the // A cubic projection is a planar projection, but we eliminate the
// dominant axis instead of arbitrarily eliminating Y. // dominant axis (based on the polygon's centroid) instead of
// arbitrarily eliminating Y.
double x = fabs(pos[0]); double x = fabs(centroid[0]);
double y = fabs(pos[1]); double y = fabs(centroid[1]);
double z = fabs(pos[2]); double z = fabs(centroid[2]);
double u, v; double u, v;

View File

@ -81,7 +81,7 @@ private:
LPoint2d map_cubic(const LPoint3d &pos, const LPoint3d &centroid) const; LPoint2d map_cubic(const LPoint3d &pos, const LPoint3d &centroid) const;
// Define a pointer to one of the above member functions. // Define a pointer to one of the above member functions.
LPoint2d (CLwoSurface::*_map_uv)(const LPoint3d &pos, const LPoint3d &centroid) const; LPoint2d (CLwoSurface::*_map_uvs)(const LPoint3d &pos, const LPoint3d &centroid) const;
}; };
#include "cLwoSurface.I" #include "cLwoSurface.I"

View File

@ -0,0 +1,23 @@
#begin bin_target
#define TARGET lwo2egg
#define LOCAL_LIBS lwo lwoegg eggbase progbase
#define OTHER_LIBS \
egg:c pandaegg:m \
linmath:c panda:m \
express:c pandaexpress:m \
dtoolutil:c dconfig:c dtoolconfig:m dtool:m pystub
#define SOURCES \
lwoToEgg.cxx lwoToEgg.h
#end bin_target
#begin bin_target
#define TARGET lwo-scan
#define LOCAL_LIBS lwo progbase
#define SOURCES \
lwoScan.cxx lwoScan.h
#end bin_target

View File

@ -0,0 +1,80 @@
// Filename: test_lwo.cxx
// Created by: drose (24Apr01)
//
////////////////////////////////////////////////////////////////////
#include "lwoScan.h"
#include <lwoInputFile.h>
#include <lwoChunk.h>
#include <config_lwo.h>
////////////////////////////////////////////////////////////////////
// Function: LwoScan::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
LwoScan::
LwoScan() {
clear_runlines();
add_runline("[opts] input.lwo");
set_program_description
("This program simply reads a Lightwave object file and dumps its "
"contents to standard output. It's mainly useful for debugging "
"problems with lwo2egg.");
}
////////////////////////////////////////////////////////////////////
// Function: LwoScan::run
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
void LwoScan::
run() {
LwoInputFile in;
if (!in.open_read(_input_filename)) {
nout << "Unable to open " << _input_filename << "\n";
exit(1);
}
PT(IffChunk) chunk = in.get_chunk();
if (chunk == (IffChunk *)NULL) {
nout << "Unable to read file.\n";
} else {
while (chunk != (IffChunk *)NULL) {
chunk->write(cout, 0);
chunk = in.get_chunk();
}
}
}
////////////////////////////////////////////////////////////////////
// Function: LwoScan::handle_args
// Access: Protected, Virtual
// Description:
////////////////////////////////////////////////////////////////////
bool LwoScan::
handle_args(ProgramBase::Args &args) {
if (args.empty()) {
nout << "You must specify the Lightwave object file to read on the command line.\n";
return false;
}
if (args.size() != 1) {
nout << "You may specify only one Lightwave object file to read on the command line.\n";
return false;
}
_input_filename = args[0];
return true;
}
int
main(int argc, char *argv[]) {
LwoScan prog;
prog.parse_command_line(argc, argv);
prog.run();
return 0;
}

View File

@ -0,0 +1,30 @@
// Filename: lwoScan.h
// Created by: drose (30Apr01)
//
////////////////////////////////////////////////////////////////////
#ifndef LWOSCAN_H
#define LWOSCAN_H
#include <programBase.h>
#include <filename.h>
////////////////////////////////////////////////////////////////////
// Class : LwoScan
// Description : A program to read a Lightwave file and report its
// structure and contents.
////////////////////////////////////////////////////////////////////
class LwoScan : public ProgramBase {
public:
LwoScan();
void run();
protected:
virtual bool handle_args(Args &args);
Filename _input_filename;
};
#endif