*** empty log message ***

This commit is contained in:
David Rose 2001-06-22 02:39:36 +00:00
parent 3335dae1be
commit fd61ad814a
12 changed files with 125 additions and 46 deletions

View File

@ -15,15 +15,14 @@
#define SOURCES \ #define SOURCES \
xFileFace.cxx xFileFace.h \ xFileFace.cxx xFileFace.h \
xFileMaker.cxx xFileMaker.h \
xFileMaterial.cxx xFileMaterial.h \ xFileMaterial.cxx xFileMaterial.h \
xFileMesh.cxx xFileMesh.h \ xFileMesh.cxx xFileMesh.h \
xFileNormal.cxx xFileNormal.h \ xFileNormal.cxx xFileNormal.h \
xFileTemplates.cxx xFileTemplates.h \
xFileToEggConverter.cxx xFileToEggConverter.h \
xFileVertex.cxx xFileVertex.h xFileVertex.cxx xFileVertex.h
#define SOURCES \
$[SOURCES] \
xFileMaker.cxx xFileMaker.h
#define SOURCES \ #define SOURCES \
$[SOURCES] \ $[SOURCES] \
eggToX.cxx eggToX.h eggToX.cxx eggToX.h
@ -44,15 +43,14 @@
#define SOURCES \ #define SOURCES \
xFileFace.cxx xFileFace.h \ xFileFace.cxx xFileFace.h \
xFileMaker.cxx xFileMaker.h \
xFileMaterial.cxx xFileMaterial.h \ xFileMaterial.cxx xFileMaterial.h \
xFileMesh.cxx xFileMesh.h \ xFileMesh.cxx xFileMesh.h \
xFileNormal.cxx xFileNormal.h \ xFileNormal.cxx xFileNormal.h \
xFileTemplates.cxx xFileTemplates.h \
xFileToEggConverter.cxx xFileToEggConverter.h \
xFileVertex.cxx xFileVertex.h xFileVertex.cxx xFileVertex.h
#define SOURCES \
$[SOURCES] \
xFileToEggConverter.cxx xFileToEggConverter.h
#define SOURCES \ #define SOURCES \
$[SOURCES] \ $[SOURCES] \
xFileToEgg.cxx xFileToEgg.h xFileToEgg.cxx xFileToEgg.h

View File

@ -24,7 +24,7 @@
// Description: // Description:
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
EggToX:: EggToX::
EggToX() : EggToSomething("DirectX", "x") { EggToX() : EggToSomething("DirectX", ".x") {
set_program_description set_program_description
("This program reads an Egg file and outputs an equivalent, " ("This program reads an Egg file and outputs an equivalent, "
"or nearly equivalent, DirectX-style .x file. Only simple " "or nearly equivalent, DirectX-style .x file. Only simple "

View File

@ -19,6 +19,7 @@
#include "xFileMaker.h" #include "xFileMaker.h"
#include "xFileMesh.h" #include "xFileMesh.h"
#include "xFileMaterial.h" #include "xFileMaterial.h"
#include "xFileTemplates.h"
#include "notify.h" #include "notify.h"
#include "eggGroupNode.h" #include "eggGroupNode.h"
@ -34,10 +35,6 @@
#include "string_utils.h" #include "string_utils.h"
#include "datagram.h" #include "datagram.h"
// This must be included only in exactly one .cxx file, since
// including defines the structure!
#include <rmxftmpl.h>
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: XFileMaker::Constructor // Function: XFileMaker::Constructor
// Access: Public // Access: Public
@ -79,7 +76,7 @@ open(const Filename &filename) {
} }
// Register our templates. // Register our templates.
hr = _dx_file->RegisterTemplates(D3DRM_XTEMPLATES, D3DRM_XTEMPLATE_BYTES); hr = _dx_file->RegisterTemplates(D3DRM_XTEMPLATES, d3drm_xtemplates_length);
if (hr != DXFILE_OK) { if (hr != DXFILE_OK) {
nout << "Unable to register templates.\n"; nout << "Unable to register templates.\n";
return false; return false;
@ -152,7 +149,7 @@ add_tree(EggData &egg_data) {
int num_bins = pmaker.make_bins(&egg_data); int num_bins = pmaker.make_bins(&egg_data);
// And now we're ready to traverse the egg hierarchy. // And now we're ready to traverse the egg hierarchy.
return add_node(&egg_data, NULL); return recurse_nodes(&egg_data, NULL);
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////

View File

@ -17,11 +17,10 @@
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
#include "xFileMaterial.h" #include "xFileMaterial.h"
#include "xFileToEggConverter.h"
#include "eggMaterial.h" #include "eggMaterial.h"
#include "eggTexture.h" #include "eggTexture.h"
#include "eggMaterialCollection.h"
#include "eggTextureCollection.h"
#include "eggPrimitive.h" #include "eggPrimitive.h"
#include "datagram.h" #include "datagram.h"
@ -101,14 +100,12 @@ set_from_egg(EggPrimitive *egg_prim) {
// indicated egg primitive. // indicated egg primitive.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void XFileMaterial:: void XFileMaterial::
apply_to_egg(EggPrimitive *egg_prim, apply_to_egg(EggPrimitive *egg_prim, XFileToEggConverter *converter) {
EggTextureCollection &textures,
EggMaterialCollection &materials) {
// Is there a texture? // Is there a texture?
if (_has_texture) { if (_has_texture) {
EggTexture temp("", _texture); Filename texture = converter->convert_texture_path(_texture);
EggTexture *egg_tex = EggTexture temp("", texture);
textures.create_unique_texture(temp, ~EggTexture::E_tref_name); EggTexture *egg_tex = converter->create_unique_texture(temp);
egg_prim->set_texture(egg_tex); egg_prim->set_texture(egg_tex);
} }
@ -127,8 +124,7 @@ apply_to_egg(EggPrimitive *egg_prim,
temp.set_emit(Colorf(_emissive_color[0], _emissive_color[1], temp.set_emit(Colorf(_emissive_color[0], _emissive_color[1],
_emissive_color[2], 1.0)); _emissive_color[2], 1.0));
} }
EggMaterial *egg_mat = EggMaterial *egg_mat = converter->create_unique_material(temp);
materials.create_unique_material(temp, ~EggMaterial::E_mref_name);
egg_prim->set_material(egg_mat); egg_prim->set_material(egg_mat);
} }

View File

@ -24,9 +24,8 @@
#include "filename.h" #include "filename.h"
class EggPrimitive; class EggPrimitive;
class EggTextureCollection;
class EggMaterialCollection;
class Datagram; class Datagram;
class XFileToEggConverter;
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Class : XFileMaterial // Class : XFileMaterial
@ -39,9 +38,7 @@ public:
~XFileMaterial(); ~XFileMaterial();
void set_from_egg(EggPrimitive *egg_prim); void set_from_egg(EggPrimitive *egg_prim);
void apply_to_egg(EggPrimitive *egg_prim, void apply_to_egg(EggPrimitive *egg_prim, XFileToEggConverter *converter);
EggTextureCollection &textures,
EggMaterialCollection &materials);
int compare_to(const XFileMaterial &other) const; int compare_to(const XFileMaterial &other) const;

View File

@ -254,9 +254,7 @@ add_material(XFileMaterial *material) {
// node. // node.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
bool XFileMesh:: bool XFileMesh::
create_polygons(EggGroupNode *egg_parent, create_polygons(EggGroupNode *egg_parent, XFileToEggConverter *converter) {
EggTextureCollection &textures,
EggMaterialCollection &materials) {
EggVertexPool *vpool = new EggVertexPool(get_name()); EggVertexPool *vpool = new EggVertexPool(get_name());
egg_parent->add_child(vpool); egg_parent->add_child(vpool);
Faces::const_iterator fi; Faces::const_iterator fi;
@ -308,9 +306,8 @@ create_polygons(EggGroupNode *egg_parent,
int material_index = face->_material_index; int material_index = face->_material_index;
if (material_index >= 0 && material_index < (int)_materials.size()) { if (material_index >= 0 && material_index < (int)_materials.size()) {
XFileMaterial *material = _materials[material_index]; XFileMaterial *material = _materials[material_index];
material->apply_to_egg(egg_poly, textures, materials); material->apply_to_egg(egg_poly, converter);
} }
} }
return true; return true;

View File

@ -30,12 +30,11 @@ class XFileVertex;
class XFileNormal; class XFileNormal;
class XFileMaterial; class XFileMaterial;
class XFileFace; class XFileFace;
class XFileToEggConverter;
class EggGroupNode; class EggGroupNode;
class EggVertex; class EggVertex;
class EggPolygon; class EggPolygon;
class EggPrimitive; class EggPrimitive;
class EggTextureCollection;
class EggMaterialCollection;
class Datagram; class Datagram;
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -59,8 +58,7 @@ public:
int add_material(XFileMaterial *material); int add_material(XFileMaterial *material);
bool create_polygons(EggGroupNode *egg_parent, bool create_polygons(EggGroupNode *egg_parent,
EggTextureCollection &textures, XFileToEggConverter *converter);
EggMaterialCollection &materials);
bool has_normals() const; bool has_normals() const;
bool has_colors() const; bool has_colors() const;

View File

@ -0,0 +1,27 @@
// Filename: xFileTemplates.cxx
// Created by: drose (21Jun01)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://www.panda3d.org/license.txt .
//
// To contact the maintainers of this program write to
// panda3d@yahoogroups.com .
//
////////////////////////////////////////////////////////////////////
#include "xFileTemplates.h"
// This must be included only in exactly one .cxx file, since
// including defines the structure!
#include <rmxftmpl.h>
const int d3drm_xtemplates_length = D3DRM_XTEMPLATE_BYTES;

View File

@ -0,0 +1,40 @@
// Filename: xFileTemplates.h
// Created by: drose (21Jun01)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://www.panda3d.org/license.txt .
//
// To contact the maintainers of this program write to
// panda3d@yahoogroups.com .
//
////////////////////////////////////////////////////////////////////
#ifndef XFILETEMPLATES_H
#define XFILETEMPLATES_H
////////////////////////////////////////////////////////////////////
//
// This file exists to get an external handle to the table defined in
// the Windows header file rmxftmpl.h. Since the table is actually
// defined in the Windows header file, we can't include that header
// file in multiple .cxx files, or we'll define the table multiple
// times.
//
// Unfortunately, the length of the table is defined within that
// header file with a #define, so there's no way to extern *that*.
// Instead, we define our own variable that references the length.
//
////////////////////////////////////////////////////////////////////
extern unsigned char D3DRM_XTEMPLATES[];
extern const int d3drm_xtemplates_length;
#endif

View File

@ -32,7 +32,7 @@ XFileToEgg() :
add_transform_options(); add_transform_options();
add_texture_path_options(); add_texture_path_options();
add_rel_dir_options(); add_rel_dir_options();
add_search_path_options(false); add_search_path_options(true);
set_program_description set_program_description
("This program converts DirectX retained-mode (.x) files to egg. This " ("This program converts DirectX retained-mode (.x) files to egg. This "

View File

@ -19,13 +19,13 @@
#include "xFileToEggConverter.h" #include "xFileToEggConverter.h"
#include "xFileMesh.h" #include "xFileMesh.h"
#include "xFileMaterial.h" #include "xFileMaterial.h"
#include "xFileTemplates.h"
#include "eggData.h" #include "eggData.h"
#include "eggGroup.h" #include "eggGroup.h"
#include "datagram.h" #include "datagram.h"
#include "eggMaterialCollection.h"
// This must be included only in exactly one .cxx file, since #include "eggTextureCollection.h"
// including defines the structure!
#include <rmxftmpl.h>
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -119,7 +119,7 @@ convert_file(const Filename &filename) {
} }
// Register our templates. // Register our templates.
hr = _dx_file->RegisterTemplates(D3DRM_XTEMPLATES, D3DRM_XTEMPLATE_BYTES); hr = _dx_file->RegisterTemplates(D3DRM_XTEMPLATES, d3drm_xtemplates_length);
if (hr != DXFILE_OK) { if (hr != DXFILE_OK) {
nout << "Unable to register templates.\n"; nout << "Unable to register templates.\n";
return false; return false;
@ -154,6 +154,30 @@ close() {
} }
} }
////////////////////////////////////////////////////////////////////
// Function: XFileToEggConverter::create_unique_texture
// Access: Public
// Description: Returns an EggTexture pointer whose properties match
// that of the the given EggTexture, except for the tref
// name.
////////////////////////////////////////////////////////////////////
EggTexture *XFileToEggConverter::
create_unique_texture(const EggTexture &copy) {
return _textures.create_unique_texture(copy, ~EggTexture::E_tref_name);
}
////////////////////////////////////////////////////////////////////
// Function: XFileToEggConverter::create_unique_material
// Access: Public
// Description: Returns an EggMaterial pointer whose properties match
// that of the the given EggMaterial, except for the mref
// name.
////////////////////////////////////////////////////////////////////
EggMaterial *XFileToEggConverter::
create_unique_material(const EggMaterial &copy) {
return _materials.create_unique_material(copy, ~EggMaterial::E_mref_name);
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: XFileToEggConverter::get_toplevel // Function: XFileToEggConverter::get_toplevel
// Access: Private // Access: Private
@ -312,7 +336,7 @@ convert_mesh(LPDIRECTXFILEDATA obj, EggGroupNode *egg_parent) {
return false; return false;
} }
if (!mesh.create_polygons(egg_parent, _textures, _materials)) { if (!mesh.create_polygons(egg_parent, this)) {
return false; return false;
} }

View File

@ -35,6 +35,8 @@ class EggGroupNode;
class Datagram; class Datagram;
class XFileMesh; class XFileMesh;
class XFileMaterial; class XFileMaterial;
class EggTexture;
class EggMaterial;
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Class : XFileToEggConverter // Class : XFileToEggConverter
@ -54,6 +56,9 @@ public:
virtual bool convert_file(const Filename &filename); virtual bool convert_file(const Filename &filename);
void close(); void close();
EggTexture *create_unique_texture(const EggTexture &copy);
EggMaterial *create_unique_material(const EggMaterial &copy);
private: private:
bool get_toplevel(); bool get_toplevel();
bool convert_object(LPDIRECTXFILEOBJECT obj, EggGroupNode *egg_parent); bool convert_object(LPDIRECTXFILEOBJECT obj, EggGroupNode *egg_parent);