*** 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 \
xFileFace.cxx xFileFace.h \
xFileMaker.cxx xFileMaker.h \
xFileMaterial.cxx xFileMaterial.h \
xFileMesh.cxx xFileMesh.h \
xFileNormal.cxx xFileNormal.h \
xFileTemplates.cxx xFileTemplates.h \
xFileToEggConverter.cxx xFileToEggConverter.h \
xFileVertex.cxx xFileVertex.h
#define SOURCES \
$[SOURCES] \
xFileMaker.cxx xFileMaker.h
#define SOURCES \
$[SOURCES] \
eggToX.cxx eggToX.h
@ -44,15 +43,14 @@
#define SOURCES \
xFileFace.cxx xFileFace.h \
xFileMaker.cxx xFileMaker.h \
xFileMaterial.cxx xFileMaterial.h \
xFileMesh.cxx xFileMesh.h \
xFileNormal.cxx xFileNormal.h \
xFileTemplates.cxx xFileTemplates.h \
xFileToEggConverter.cxx xFileToEggConverter.h \
xFileVertex.cxx xFileVertex.h
#define SOURCES \
$[SOURCES] \
xFileToEggConverter.cxx xFileToEggConverter.h
#define SOURCES \
$[SOURCES] \
xFileToEgg.cxx xFileToEgg.h

View File

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

View File

@ -19,6 +19,7 @@
#include "xFileMaker.h"
#include "xFileMesh.h"
#include "xFileMaterial.h"
#include "xFileTemplates.h"
#include "notify.h"
#include "eggGroupNode.h"
@ -34,10 +35,6 @@
#include "string_utils.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
// Access: Public
@ -79,7 +76,7 @@ open(const Filename &filename) {
}
// 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) {
nout << "Unable to register templates.\n";
return false;
@ -152,7 +149,7 @@ add_tree(EggData &egg_data) {
int num_bins = pmaker.make_bins(&egg_data);
// 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 "xFileToEggConverter.h"
#include "eggMaterial.h"
#include "eggTexture.h"
#include "eggMaterialCollection.h"
#include "eggTextureCollection.h"
#include "eggPrimitive.h"
#include "datagram.h"
@ -101,14 +100,12 @@ set_from_egg(EggPrimitive *egg_prim) {
// indicated egg primitive.
////////////////////////////////////////////////////////////////////
void XFileMaterial::
apply_to_egg(EggPrimitive *egg_prim,
EggTextureCollection &textures,
EggMaterialCollection &materials) {
apply_to_egg(EggPrimitive *egg_prim, XFileToEggConverter *converter) {
// Is there a texture?
if (_has_texture) {
EggTexture temp("", _texture);
EggTexture *egg_tex =
textures.create_unique_texture(temp, ~EggTexture::E_tref_name);
Filename texture = converter->convert_texture_path(_texture);
EggTexture temp("", texture);
EggTexture *egg_tex = converter->create_unique_texture(temp);
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],
_emissive_color[2], 1.0));
}
EggMaterial *egg_mat =
materials.create_unique_material(temp, ~EggMaterial::E_mref_name);
EggMaterial *egg_mat = converter->create_unique_material(temp);
egg_prim->set_material(egg_mat);
}

View File

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

View File

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

View File

@ -30,12 +30,11 @@ class XFileVertex;
class XFileNormal;
class XFileMaterial;
class XFileFace;
class XFileToEggConverter;
class EggGroupNode;
class EggVertex;
class EggPolygon;
class EggPrimitive;
class EggTextureCollection;
class EggMaterialCollection;
class Datagram;
////////////////////////////////////////////////////////////////////
@ -59,8 +58,7 @@ public:
int add_material(XFileMaterial *material);
bool create_polygons(EggGroupNode *egg_parent,
EggTextureCollection &textures,
EggMaterialCollection &materials);
XFileToEggConverter *converter);
bool has_normals() 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_texture_path_options();
add_rel_dir_options();
add_search_path_options(false);
add_search_path_options(true);
set_program_description
("This program converts DirectX retained-mode (.x) files to egg. This "

View File

@ -19,13 +19,13 @@
#include "xFileToEggConverter.h"
#include "xFileMesh.h"
#include "xFileMaterial.h"
#include "xFileTemplates.h"
#include "eggData.h"
#include "eggGroup.h"
#include "datagram.h"
// This must be included only in exactly one .cxx file, since
// including defines the structure!
#include <rmxftmpl.h>
#include "eggMaterialCollection.h"
#include "eggTextureCollection.h"
////////////////////////////////////////////////////////////////////
@ -119,7 +119,7 @@ convert_file(const Filename &filename) {
}
// 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) {
nout << "Unable to register templates.\n";
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
// Access: Private
@ -312,7 +336,7 @@ convert_mesh(LPDIRECTXFILEDATA obj, EggGroupNode *egg_parent) {
return false;
}
if (!mesh.create_polygons(egg_parent, _textures, _materials)) {
if (!mesh.create_polygons(egg_parent, this)) {
return false;
}

View File

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