diff --git a/.idea/EG.iml b/.idea/EG.iml
index c1574376..ba1e88cf 100644
--- a/.idea/EG.iml
+++ b/.idea/EG.iml
@@ -3,8 +3,9 @@
+
-
+
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 51b9fc17..b4e62875 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -3,5 +3,5 @@
-
+
\ No newline at end of file
diff --git a/RenderPipelineFile/config/daytime.yaml b/RenderPipelineFile/config/daytime.yaml
index 54447c55..84b58692 100644
--- a/RenderPipelineFile/config/daytime.yaml
+++ b/RenderPipelineFile/config/daytime.yaml
@@ -17,7 +17,7 @@ control_points:
scattering:
sun_intensity: [[[0.0000000000,0.0000000000],[0.0041666667,0.0000000000],[0.0083333333,0.0000000000],[0.0125000000,0.0000000000],[0.0166666667,0.0000000000],[0.0208333333,0.0000000000],[0.0250000000,0.0000000000],[0.0291666667,0.0000000000],[0.0333333333,0.0000000000],[0.0375000000,0.0000000000],[0.0416666667,0.0000000000],[0.0458333333,0.0000000000],[0.0500000000,0.0000000000],[0.0541666667,0.0000000000],[0.0583333333,0.0000000000],[0.0625000000,0.0000000000],[0.0666666667,0.0000000000],[0.0708333333,0.0000000000],[0.0750000000,0.0000000000],[0.0791666667,0.0000000000],[0.0833333333,0.0000000000],[0.0875000000,0.0000000000],[0.0916666667,0.0000000000],[0.0958333333,0.0000000000],[0.1000000000,0.0000000000],[0.1041666667,0.0000000000],[0.1083333333,0.0000000000],[0.1125000000,0.0000000000],[0.1166666667,0.0000000000],[0.1208333333,0.0000000000],[0.1250000000,0.0000000000],[0.1291666667,0.0000000000],[0.1333333333,0.0000000000],[0.1375000000,0.0000000000],[0.1416666667,0.0000000000],[0.1458333333,0.0000000000],[0.1500000000,0.0000000000],[0.1541666667,0.0000000000],[0.1583333333,0.0000028805],[0.1625000000,0.0003577724],[0.1666666667,0.0013331400],[0.1708333333,0.0029671803],[0.1750000000,0.0052963381],[0.1791666667,0.0083550556],[0.1833333333,0.0121755589],[0.1875000000,0.0167876159],[0.1916666667,0.0222183530],[0.1958333333,0.0284919947],[0.2000000000,0.0356297193],[0.2041666667,0.0436494349],[0.2083333333,0.0525656099],[0.2125000000,0.0623891610],[0.2166666667,0.0731272461],[0.2208333333,0.0847831708],[0.2250000000,0.0973563167],[0.2291666667,0.1108419698],[0.2333333333,0.1252313631],[0.2375000000,0.1405115250],[0.2416666667,0.1566653434],[0.2458333333,0.1736715009],[0.2500000000,0.1915046014],[0.2541666667,0.2101350464],[0.2583333333,0.2295292930],[0.2625000000,0.2496498145],[0.2666666667,0.2704552670],[0.2708333333,0.2919006662],[0.2750000000,0.3139375192],[0.2791666667,0.3365139497],[0.2833333333,0.3595750662],[0.2875000000,0.3830630359],[0.2916666667,0.4069173972],[0.2958333333,0.4310753462],[0.3000000000,0.4554720417],[0.3041666667,0.4800408236],[0.3083333333,0.5047136020],[0.3125000000,0.5294212108],[0.3166666667,0.5540936424],[0.3208333333,0.5786605298],[0.3250000000,0.6030514553],[0.3291666667,0.6271963182],[0.3333333333,0.6510256858],[0.3375000000,0.6744711982],[0.3416666667,0.6974659988],[0.3458333333,0.7199450163],[0.3500000000,0.7418453485],[0.3541666667,0.7631067095],[0.3583333333,0.7836717291],[0.3625000000,0.8034862953],[0.3666666667,0.8224999302],[0.3708333333,0.8406661079],[0.3750000000,0.8579425235],[0.3791666667,0.8742914270],[0.3833333333,0.8896799131],[0.3875000000,0.9040801386],[0.3916666667,0.9174695289],[0.3958333333,0.9298310650],[0.4000000000,0.9411533765],[0.4041666667,0.9514309312],[0.4083333333,0.9606641691],[0.4125000000,0.9688595571],[0.4166666667,0.9760296330],[0.4208333333,0.9821930708],[0.4250000000,0.9873746114],[0.4291666667,0.9916050060],[0.4333333333,0.9949209310],[0.4375000000,0.9973647924],[0.4416666667,0.9989845508],[0.4458333333,0.9998334497],[0.4500000000,0.9999696949],[0.4541666667,0.9994560801],[0.4583333333,0.9983595429],[0.4625000000,0.9967506613],[0.4666666667,0.9947030614],[0.4708333333,0.9922927758],[0.4750000000,0.9895975125],[0.4791666667,0.9866958610],[0.4833333333,0.9836664262],[0.4875000000,0.9805868867],[0.4916666667,0.9775330316],[0.4958333333,0.9745777179],[0.5000000000,0.9717898417],[0.5041666667,0.9692332877],[0.5083333333,0.9669658924],[0.5125000000,0.9650384806],[0.5089595376,0.9690650222],[0.5208333333,0.9623666659],[0.5250000000,0.9616814371],[0.5291666667,0.9614534423],[0.5333333333,0.9616877089],[0.5375000000,0.9623790807],[0.5416666667,0.9635123329],[0.5458333333,0.9650624244],[0.5500000000,0.9669949804],[0.5541666667,0.9692669864],[0.5583333333,0.9718275065],[0.5625000000,0.9746185969],[0.5666666667,0.9775762863],[0.5708333333,0.9806315864],[0.5750000000,0.9837115661],[0.5791666667,0.9867403433],[0.5833333333,0.9896401655],[0.5875000000,0.9923323562],[0.5916666667,0.9947382579],[0.5958333333,0.9967800977],[0.6000000000,0.9983817820],[0.6041666667,0.9994696263],[0.6083333333,0.9999730028],[0.6125000000,0.9998249266],[0.6166666667,0.9989625601],[0.6208333333,0.9973276624],[0.6250000000,0.9948669567],[0.6291666667,0.9915324664],[0.6333333333,0.9872817545],[0.6375000000,0.9820781426],[0.6416666667,0.9758908775],[0.6458333333,0.9686952146],[0.6500000000,0.9604725211],[0.6541666667,0.9512102537],[0.6583333333,0.9409019858],[0.6625000000,0.9295473441],[0.6666666667,0.9171518878],[0.6708333333,0.9037270619],[0.6750000000,0.8892899902],[0.6791666667,0.8738633008],[0.6833333333,0.8574749656],[0.6875000000,0.8401579787],[0.6916666667,0.8219502453],[0.6958333333,0.8028941798],[0.7000000000,0.7830364456],[0.7041666667,0.7624277344],[0.7083333333,0.7411222520],[0.7125000000,0.7191776044],[0.7166666667,0.6966542563],[0.7208333333,0.6736152714],[0.7250000000,0.6501259629],[0.7291666667,0.6262533880],[0.7333333333,0.6020661121],[0.7375000000,0.5776338043],[0.7416666667,0.5530267796],[0.7458333333,0.5283156992],[0.7500000000,0.5035711751],[0.7541666667,0.4788634341],[0.7583333333,0.4542618347],[0.7625000000,0.4298347613],[0.7666666667,0.4056490351],[0.7708333333,0.3817697830],[0.7750000000,0.3582600107],[0.7791666667,0.3351803495],[0.7833333333,0.3125888445],[0.7875000000,0.2905406366],[0.7916666667,0.2690876955],[0.7958333333,0.2482787388],[0.8000000000,0.2281588906],[0.8041666667,0.2087696425],[0.8083333333,0.1901486315],[0.8125000000,0.1723295359],[0.8166666667,0.1553419918],[0.8208333333,0.1392115328],[0.8250000000,0.1239595144],[0.8291666667,0.1096030703],[0.8333333333,0.0961551918],[0.8375000000,0.0836246599],[0.8416666667,0.0720161369],[0.8458333333,0.0613302273],[0.8500000000,0.0515635598],[0.8541666667,0.0427088803],[0.8583333333,0.0347551990],[0.8625000000,0.0276878920],[0.8666666667,0.0214889271],[0.8708333333,0.0161369711],[0.8750000000,0.0116076130],[0.8791666667,0.0078735477],[0.8833333333,0.0049047927],[0.8875000000,0.0026688977],[0.8916666667,0.0011311782],[0.8958333333,0.0002549473],[0.9000000000,0.0000000000],[0.9041666667,0.0000000000],[0.9083333333,0.0000000000],[0.9125000000,0.0000000000],[0.9166666667,0.0000000000],[0.9208333333,0.0000000000],[0.9250000000,0.0000000000],[0.9291666667,0.0000000000],[0.9333333333,0.0000000000],[0.9375000000,0.0000000000],[0.9416666667,0.0000000000],[0.9458333333,0.0000000000],[0.9500000000,0.0000000000],[0.9541666667,0.0000000000],[0.9583333333,0.0000000000],[0.9625000000,0.0000000000],[0.9666666667,0.0000000000],[0.9708333333,0.0000000000],[0.9750000000,0.0000000000],[0.9791666667,0.0000000000],[0.9833333333,0.0000000000],[0.9875000000,0.0000000000],[0.9916666667,0.0000000000],[0.9958333333,0.0000000000]]]
sun_color: [[[0.5010435645,0.5818710306],[0.0433100000,0.8999700000],[0.8635787716,0.9130000000],[0.1785000000,0.8973600000],[0.8099800000,0.8651100000],[0.2360800000,0.7712700000],[0.6583432177,0.8485126184],[0.1266806142,0.9648102053],[0.9558541267,0.9090909091],[0.5568400771,0.7353760446]],[[0.5001318426,0.5160300000],[0.0572700000,0.6541600000],[0.2395000000,0.5976800000],[0.8104600000,0.6009000000],[0.6967400000,0.5483900000]],[[0.0862400000,0.4257800000],[0.4955600000,0.4033000000],[0.8234200000,0.4340200000]]]
- sun_azimuth: [[[0.5000000000,0.6250000000]]]
+ sun_azimuth: [[[0.5000000000,0.4916666667]]]
sun_altitude: [[[0.5000000000,0.9555555556]]]
extinction: [[[0.4913294798,0.6378830084]]]
volumetrics:
diff --git a/pandatool/CMakeLists.txt b/pandatool/CMakeLists.txt
deleted file mode 100644
index 8db045f4..00000000
--- a/pandatool/CMakeLists.txt
+++ /dev/null
@@ -1,53 +0,0 @@
-if(NOT BUILD_PANDA)
- message(FATAL_ERROR "Cannot build pandatool without panda! Please enable the BUILD_PANDA option.")
-endif()
-
-# Include pandatool source directories
-add_subdirectory(src/assimp)
-add_subdirectory(src/bam)
-add_subdirectory(src/converter)
-add_subdirectory(src/daeegg)
-add_subdirectory(src/daeprogs)
-add_subdirectory(src/deploy-stub)
-add_subdirectory(src/dxf)
-add_subdirectory(src/dxfegg)
-add_subdirectory(src/dxfprogs)
-add_subdirectory(src/eggbase)
-add_subdirectory(src/eggcharbase)
-add_subdirectory(src/eggprogs)
-add_subdirectory(src/egg-mkfont)
-add_subdirectory(src/egg-optchar)
-add_subdirectory(src/egg-palettize)
-add_subdirectory(src/egg-qtess)
-add_subdirectory(src/flt)
-add_subdirectory(src/fltegg)
-add_subdirectory(src/fltprogs)
-add_subdirectory(src/gtk-stats)
-add_subdirectory(src/imagebase)
-add_subdirectory(src/imageprogs)
-add_subdirectory(src/lwo)
-add_subdirectory(src/lwoegg)
-add_subdirectory(src/lwoprogs)
-add_subdirectory(src/mac-stats)
-add_subdirectory(src/miscprogs)
-add_subdirectory(src/objegg)
-add_subdirectory(src/objprogs)
-add_subdirectory(src/palettizer)
-add_subdirectory(src/pandatoolbase)
-add_subdirectory(src/pfmprogs)
-add_subdirectory(src/progbase)
-add_subdirectory(src/pstatserver)
-add_subdirectory(src/ptloader)
-add_subdirectory(src/text-stats)
-add_subdirectory(src/vrml)
-add_subdirectory(src/vrmlegg)
-add_subdirectory(src/vrmlprogs)
-add_subdirectory(src/win-stats)
-add_subdirectory(src/xfile)
-add_subdirectory(src/xfileegg)
-add_subdirectory(src/xfileprogs)
-
-if(BUILD_TOOLS)
- export_targets(Tools)
-endif()
-export_targets(ToolsDevel NAMESPACE "Panda3D::Tools::" COMPONENT ToolsDevel)
diff --git a/pandatool/src/assimp/CMakeLists.txt b/pandatool/src/assimp/CMakeLists.txt
deleted file mode 100644
index 5b88e0ef..00000000
--- a/pandatool/src/assimp/CMakeLists.txt
+++ /dev/null
@@ -1,39 +0,0 @@
-if(NOT HAVE_ASSIMP)
- return()
-endif()
-
-set(P3ASSIMP_HEADERS
- assimpLoader.h assimpLoader.I
- config_assimp.h
- loaderFileTypeAssimp.h
- pandaIOStream.h
- pandaIOSystem.h
- pandaLogger.h
-)
-
-set(P3ASSIMP_SOURCES
- assimpLoader.cxx
- config_assimp.cxx
- loaderFileTypeAssimp.cxx
- pandaIOStream.cxx
- pandaIOSystem.cxx
- pandaLogger.cxx
-)
-
-composite_sources(p3assimp P3ASSIMP_SOURCES)
-add_library(p3assimp ${MODULE_TYPE} ${P3ASSIMP_HEADERS} ${P3ASSIMP_SOURCES})
-set_target_properties(p3assimp PROPERTIES DEFINE_SYMBOL BUILDING_ASSIMP)
-target_link_libraries(p3assimp PRIVATE p3pandatoolbase)
-target_link_libraries(p3assimp PUBLIC PKG::ASSIMP)
-
-if(CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|Clang)$")
- # Do not re-export symbols from these libraries.
- target_link_options(p3assimp PRIVATE "LINKER:--exclude-libs,libassimp.a")
- target_link_options(p3assimp PRIVATE "LINKER:--exclude-libs,libIrrXML.a")
-endif()
-
-if(BUILD_SHARED_LIBS)
- # We can't install this if we're doing a static build, because it depends on
- # a static library that isn't installed.
- install(TARGETS p3assimp EXPORT Assimp COMPONENT Assimp DESTINATION ${MODULE_DESTINATION})
-endif()
diff --git a/pandatool/src/assimp/assimpLoader.I b/pandatool/src/assimp/assimpLoader.I
deleted file mode 100644
index 5ce6c3bf..00000000
--- a/pandatool/src/assimp/assimpLoader.I
+++ /dev/null
@@ -1,12 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file assimpLoader.I
- * @author rdb
- * @date 2011-03-29
- */
diff --git a/pandatool/src/assimp/assimpLoader.cxx b/pandatool/src/assimp/assimpLoader.cxx
deleted file mode 100644
index 80b94a7c..00000000
--- a/pandatool/src/assimp/assimpLoader.cxx
+++ /dev/null
@@ -1,1326 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file assimpLoader.cxx
- * @author rdb
- * @date 2011-03-29
- */
-
-#include "assimpLoader.h"
-
-#include "geomNode.h"
-#include "luse.h"
-#include "geomVertexWriter.h"
-#include "geomPoints.h"
-#include "geomLines.h"
-#include "geomTriangles.h"
-#include "pnmFileTypeRegistry.h"
-#include "pnmImage.h"
-#include "alphaTestAttrib.h"
-#include "materialAttrib.h"
-#include "textureAttrib.h"
-#include "cullFaceAttrib.h"
-#include "transparencyAttrib.h"
-#include "ambientLight.h"
-#include "directionalLight.h"
-#include "spotlight.h"
-#include "pointLight.h"
-#include "look_at.h"
-#include "texturePool.h"
-#include "character.h"
-#include "animBundle.h"
-#include "animBundleNode.h"
-#include "animChannelMatrixXfmTable.h"
-#include "pvector.h"
-#include "cmath.h"
-#include "deg_2_rad.h"
-#include "string_utils.h"
-
-#include "pandaIOSystem.h"
-#include "pandaLogger.h"
-
-#include
-
-#ifndef AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_BASE_COLOR_FACTOR
-#define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_BASE_COLOR_FACTOR "$mat.gltf.pbrMetallicRoughness.baseColorFactor", 0, 0
-#endif
-
-#ifndef AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_METALLIC_FACTOR
-#define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_METALLIC_FACTOR "$mat.gltf.pbrMetallicRoughness.metallicFactor", 0, 0
-#endif
-
-#ifndef AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_ROUGHNESS_FACTOR
-#define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_ROUGHNESS_FACTOR "$mat.gltf.pbrMetallicRoughness.roughnessFactor", 0, 0
-#endif
-
-#ifndef AI_MATKEY_GLTF_ALPHAMODE
-#define AI_MATKEY_GLTF_ALPHAMODE "$mat.gltf.alphaMode", 0, 0
-#endif
-
-#ifndef AI_MATKEY_GLTF_ALPHACUTOFF
-#define AI_MATKEY_GLTF_ALPHACUTOFF "$mat.gltf.alphaCutoff", 0, 0
-#endif
-
-// Older versions of Assimp used these glTF-specific keys instead.
-#ifndef AI_MATKEY_BASE_COLOR
-#define AI_MATKEY_BASE_COLOR AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_BASE_COLOR_FACTOR
-#endif
-
-#ifndef AI_MATKEY_METALLIC_FACTOR
-#define AI_MATKEY_METALLIC_FACTOR AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_METALLIC_FACTOR
-#endif
-
-#ifndef AI_MATKEY_ROUGHNESS_FACTOR
-#define AI_MATKEY_ROUGHNESS_FACTOR AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_ROUGHNESS_FACTOR
-#endif
-
-using std::ostringstream;
-using std::stringstream;
-using std::string;
-
-struct BoneWeight {
- CPT(JointVertexTransform) joint_vertex_xform;
- float weight;
-
- BoneWeight(CPT(JointVertexTransform) joint_vertex_xform, float weight)
- : joint_vertex_xform(joint_vertex_xform), weight(weight)
- {}
-};
-typedef pvector BoneWeightList;
-
-/**
- *
- */
-AssimpLoader::
-AssimpLoader() :
- _error (false),
- _geoms (nullptr) {
-
- PandaLogger::set_default();
- _importer.SetIOHandler(new PandaIOSystem);
-}
-
-/**
- *
- */
-AssimpLoader::
-~AssimpLoader() {
- _importer.FreeScene();
-}
-
-/**
- * Returns a space-separated list of extensions that Assimp can load, without
- * the leading dots.
- */
-void AssimpLoader::
-get_extensions(string &ext) const {
- aiString aexts;
- _importer.GetExtensionList(aexts);
-
- // The format is like: *.mdc;*.mdl;*.mesh.xml;*.mot
- char *sub = strtok(aexts.data, ";");
- while (sub != nullptr) {
- ext += sub + 2;
- sub = strtok(nullptr, ";");
-
- if (sub != nullptr) {
- ext += ' ';
- }
- }
-}
-
-/**
- * Reads from the indicated file.
- */
-bool AssimpLoader::
-read(const Filename &filename) {
- _filename = filename;
-
- unsigned int flags = aiProcess_Triangulate | aiProcess_GenUVCoords;
-
- if (assimp_calc_tangent_space) {
- flags |= aiProcess_CalcTangentSpace;
- }
- if (assimp_join_identical_vertices) {
- flags |= aiProcess_JoinIdenticalVertices;
- }
- if (assimp_improve_cache_locality) {
- flags |= aiProcess_ImproveCacheLocality;
- }
- if (assimp_remove_redundant_materials) {
- flags |= aiProcess_RemoveRedundantMaterials;
- }
- if (assimp_fix_infacing_normals) {
- flags |= aiProcess_FixInfacingNormals;
- }
- if (assimp_optimize_meshes) {
- flags |= aiProcess_OptimizeMeshes;
- }
- if (assimp_optimize_graph) {
- flags |= aiProcess_OptimizeGraph;
- }
- if (assimp_flip_winding_order) {
- flags |= aiProcess_FlipWindingOrder;
- }
- if (assimp_gen_normals) {
- if (assimp_smooth_normal_angle == 0.0) {
- flags |= aiProcess_GenNormals;
- }
- else {
- flags |= aiProcess_GenSmoothNormals;
- _importer.SetPropertyFloat(AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE,
- assimp_smooth_normal_angle);
- }
- }
-
- _scene = _importer.ReadFile(_filename.c_str(), flags);
- if (_scene == nullptr) {
- _error = true;
- return false;
- }
-
- _error = false;
- return true;
-}
-
-/**
- * Converts scene graph structures into a Panda3D scene graph, with _root
- * being the root node.
- */
-void AssimpLoader::
-build_graph() {
- nassertv(_scene != nullptr); // read() must be called first
- nassertv(!_error); // and have succeeded
-
- // Protect the import process
- MutexHolder holder(_lock);
-
- _root = new ModelRoot(_filename.get_basename());
-
- // Import all of the embedded textures first.
- _textures = new PT(Texture)[_scene->mNumTextures];
- for (size_t i = 0; i < _scene->mNumTextures; ++i) {
- load_texture(i);
- }
-
- // Then the materials.
- _mat_states = new CPT(RenderState)[_scene->mNumMaterials];
- for (size_t i = 0; i < _scene->mNumMaterials; ++i) {
- load_material(i);
- }
-
- // And then the meshes.
- _geoms = new Geoms[_scene->mNumMeshes];
- for (size_t i = 0; i < _scene->mNumMeshes; ++i) {
- load_mesh(i);
- }
-
- // And now the node structure.
- if (_scene->mRootNode != nullptr) {
- load_node(*_scene->mRootNode, _root);
- }
-
- // And lastly, the lights.
- for (size_t i = 0; i < _scene->mNumLights; ++i) {
- load_light(*_scene->mLights[i]);
- }
-
- delete[] _textures;
- delete[] _mat_states;
- delete[] _geoms;
-}
-
-/**
- * Finds a node by name.
- */
-const aiNode *AssimpLoader::
-find_node(const aiNode &root, const aiString &name) {
- const aiNode *node;
-
- if (root.mName == name) {
- return &root;
- } else {
- for (size_t i = 0; i < root.mNumChildren; ++i) {
- node = find_node(*root.mChildren[i], name);
- if (node) {
- return node;
- }
- }
- }
-
- return nullptr;
-}
-
-/**
- * Converts an aiTexture into a Texture.
- */
-void AssimpLoader::
-load_texture(size_t index) {
- const aiTexture &tex = *_scene->mTextures[index];
-
- PT(Texture) ptex = new Texture;
-
- if (tex.mHeight == 0) {
- // Compressed texture.
- if (assimp_cat.is_debug()) {
- assimp_cat.debug()
- << "Reading embedded compressed texture with format "
- << tex.achFormatHint << " and size " << tex.mWidth << "\n";
- }
- stringstream str;
- str.write((char*) tex.pcData, tex.mWidth);
-
- if (strncmp(tex.achFormatHint, "dds", 3) == 0) {
- ptex->read_dds(str);
-
- } else {
- const PNMFileTypeRegistry *reg = PNMFileTypeRegistry::get_global_ptr();
- PNMFileType *ftype;
- PNMImage img;
-
- // Work around a bug in Assimp, it sometimes writes jp instead of jpg
- if (strncmp(tex.achFormatHint, "jp\0", 3) == 0) {
- ftype = reg->get_type_from_extension("jpg");
- } else {
- ftype = reg->get_type_from_extension(tex.achFormatHint);
- }
-
- if (img.read(str, "", ftype)) {
- ptex->load(img);
- } else {
- ptex = nullptr;
- }
- }
- } else {
- if (assimp_cat.is_debug()) {
- assimp_cat.debug()
- << "Reading embedded raw texture with size "
- << tex.mWidth << "x" << tex.mHeight << "\n";
- }
-
- ptex->setup_2d_texture(tex.mWidth, tex.mHeight, Texture::T_unsigned_byte, Texture::F_rgba);
- PTA_uchar data = ptex->modify_ram_image();
-
- size_t p = 0;
- for (size_t i = 0; i < tex.mWidth * tex.mHeight; ++i) {
- const aiTexel &texel = tex.pcData[i];
- data[p++] = texel.b;
- data[p++] = texel.g;
- data[p++] = texel.r;
- data[p++] = texel.a;
- }
- }
-
- // ostringstream path; path << "tmp" << index << ".png";
- // ptex->write(path.str());
-
- _textures[index] = ptex;
-
-}
-
-/**
- * Converts an aiMaterial into a RenderState.
- */
-void AssimpLoader::
-load_texture_stage(const aiMaterial &mat, const aiTextureType &ttype,
- TextureStage::Mode mode, CPT(TextureAttrib) &tattr,
- CPT(TexMatrixAttrib) &tmattr) {
- aiString path;
- aiTextureMapping mapping;
- unsigned int uvindex;
- float blend;
- aiTextureOp op;
- aiTextureMapMode mapmode[3];
-
- for (size_t i = 0; i < mat.GetTextureCount(ttype); ++i) {
- mat.GetTexture(ttype, i, &path, &mapping, nullptr, &blend, &op, mapmode);
-
- if (AI_SUCCESS != mat.Get(AI_MATKEY_UVWSRC(ttype, i), uvindex)) {
- // If there's no texture coordinate set for this texture, assume that
- // it's the same as the index on the stack. TODO: if there's only one
- // set on the mesh, force everything to use just the first stage.
- uvindex = i;
- }
-
- if (ttype == aiTextureType_DIFFUSE && i == 1) {
- // The glTF 2 importer duplicates this slot in older versions of Assimp.
- // Since glTF doesn't support multiple diffuse textures anyway, we check
- // for this old glTF-specific key, and if present, ignore this texture.
- aiColor4D col;
- if (AI_SUCCESS == mat.Get(AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_BASE_COLOR_FACTOR, col)) {
- return;
- }
- }
-
- std::string uvindex_str = format_string(uvindex);
- PT(TextureStage) stage = new TextureStage(uvindex_str);
- stage->set_mode(mode);
- if (uvindex > 0) {
- stage->set_texcoord_name(InternalName::get_texcoord_name(uvindex_str));
- }
- PT(Texture) ptex;
-
- // I'm not sure if this is the right way to handle it, as I couldn't find
- // much information on embedded textures.
- if (path.data[0] == '*') {
- long num = strtol(path.data + 1, nullptr, 10);
- ptex = _textures[num];
-
- } else if (path.length > 0) {
- Filename fn = Filename::from_os_specific(string(path.data, path.length));
-
- // Try to find the file by moving up twice in the hierarchy.
- VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr();
- Filename dir (_filename);
- _filename.make_canonical();
- dir = _filename.get_dirname();
-
- // Quake 3 BSP doesn't specify an extension for textures.
- if (vfs->is_regular_file(Filename(dir, fn))) {
- fn = Filename(dir, fn);
- } else if (vfs->is_regular_file(Filename(dir, fn + ".tga"))) {
- fn = Filename(dir, fn + ".tga");
- } else if (vfs->is_regular_file(Filename(dir, fn + ".jpg"))) {
- fn = Filename(dir, fn + ".jpg");
- } else {
- dir = _filename.get_dirname();
- if (vfs->is_regular_file(Filename(dir, fn))) {
- fn = Filename(dir, fn);
- } else if (vfs->is_regular_file(Filename(dir, fn + ".tga"))) {
- fn = Filename(dir, fn + ".tga");
- } else if (vfs->is_regular_file(Filename(dir, fn + ".jpg"))) {
- fn = Filename(dir, fn + ".jpg");
- }
- }
-
- ptex = TexturePool::load_texture(fn);
- }
-
- if (ptex != nullptr) {
- // Apply the mapping modes.
- switch (mapmode[0]) {
- case aiTextureMapMode_Wrap:
- ptex->set_wrap_u(SamplerState::WM_repeat);
- break;
- case aiTextureMapMode_Clamp:
- ptex->set_wrap_u(SamplerState::WM_clamp);
- break;
- case aiTextureMapMode_Decal:
- ptex->set_wrap_u(SamplerState::WM_border_color);
- ptex->set_border_color(LColor(0, 0, 0, 0));
- break;
- case aiTextureMapMode_Mirror:
- ptex->set_wrap_u(SamplerState::WM_mirror);
- break;
- default:
- break;
- }
- switch (mapmode[1]) {
- case aiTextureMapMode_Wrap:
- ptex->set_wrap_v(SamplerState::WM_repeat);
- break;
- case aiTextureMapMode_Clamp:
- ptex->set_wrap_v(SamplerState::WM_clamp);
- break;
- case aiTextureMapMode_Decal:
- ptex->set_wrap_v(SamplerState::WM_border_color);
- ptex->set_border_color(LColor(0, 0, 0, 0));
- break;
- case aiTextureMapMode_Mirror:
- ptex->set_wrap_v(SamplerState::WM_mirror);
- break;
- default:
- break;
- }
- switch (mapmode[2]) {
- case aiTextureMapMode_Wrap:
- ptex->set_wrap_w(SamplerState::WM_repeat);
- break;
- case aiTextureMapMode_Clamp:
- ptex->set_wrap_w(SamplerState::WM_clamp);
- break;
- case aiTextureMapMode_Decal:
- ptex->set_wrap_w(SamplerState::WM_border_color);
- ptex->set_border_color(LColor(0, 0, 0, 0));
- break;
- case aiTextureMapMode_Mirror:
- ptex->set_wrap_w(SamplerState::WM_mirror);
- break;
- default:
- break;
- }
-
- tattr = DCAST(TextureAttrib, tattr->add_on_stage(stage, ptex));
-
- // Is there a texture transform?
- aiUVTransform transform;
- if (AI_SUCCESS == mat.Get(AI_MATKEY_UVTRANSFORM(ttype, i), transform)) {
- // Reconstruct the original origin from the glTF file.
- PN_stdfloat rcos, rsin;
- csincos(-transform.mRotation, &rsin, &rcos);
- transform.mTranslation.x -= (0.5 * transform.mScaling.x) * (-rcos + rsin + 1);
- transform.mTranslation.y -= ((0.5 * transform.mScaling.y) * (rsin + rcos - 1)) + 1 - transform.mScaling.y;
-
- LMatrix3 matrix =
- LMatrix3::translate_mat(0, -1) *
- LMatrix3::scale_mat(transform.mScaling.x, transform.mScaling.y) *
- LMatrix3::rotate_mat(rad_2_deg(-transform.mRotation)) *
- LMatrix3::translate_mat(transform.mTranslation.x, 1 + transform.mTranslation.y);
-
- CPT(TransformState) cstate =
- TransformState::make_mat3(matrix);
-
- CPT(RenderAttrib) new_attr = (tmattr == nullptr)
- ? TexMatrixAttrib::make(stage, std::move(cstate))
- : tmattr->add_stage(stage, std::move(cstate));
- tmattr = DCAST(TexMatrixAttrib, std::move(new_attr));
- }
- }
- }
-}
-
-/**
- * Converts an aiMaterial into a RenderState.
- */
-void AssimpLoader::
-load_material(size_t index) {
- const aiMaterial &mat = *_scene->mMaterials[index];
-
- CPT(RenderState) state = RenderState::make_empty();
-
- aiColor4D col;
- bool have;
- int ival;
- PN_stdfloat fval;
-
- // XXX a lot of this is untested.
-
- // First do the material attribute.
- PT(Material) pmat = new Material;
- have = false;
- if (AI_SUCCESS == mat.Get(AI_MATKEY_BASE_COLOR, col)) {
- pmat->set_base_color(LColor(col.r, col.g, col.b, col.a));
- have = true;
- }
- else if (AI_SUCCESS == mat.Get(AI_MATKEY_COLOR_DIFFUSE, col)) {
- pmat->set_diffuse(LColor(col.r, col.g, col.b, 1));
- have = true;
- }
- if (AI_SUCCESS == mat.Get(AI_MATKEY_COLOR_SPECULAR, col)) {
- if (AI_SUCCESS == mat.Get(AI_MATKEY_SHININESS_STRENGTH, fval)) {
- pmat->set_specular(LColor(col.r * fval, col.g * fval, col.b * fval, 1));
- } else {
- pmat->set_specular(LColor(col.r, col.g, col.b, 1));
- }
- have = true;
- }
- //else {
- // if (AI_SUCCESS == mat.Get(AI_MATKEY_SHININESS_STRENGTH, fval)) {
- // pmat->set_specular(LColor(fval, fval, fval, 1));
- // } else {
- // pmat->set_specular(LColor(1, 1, 1, 1));
- // }
- //}
- if (AI_SUCCESS == mat.Get(AI_MATKEY_COLOR_AMBIENT, col)) {
- pmat->set_specular(LColor(col.r, col.g, col.b, 1));
- have = true;
- }
- if (AI_SUCCESS == mat.Get(AI_MATKEY_COLOR_EMISSIVE, col)) {
- pmat->set_emission(LColor(col.r, col.g, col.b, 1));
- have = true;
- }
- if (AI_SUCCESS == mat.Get(AI_MATKEY_COLOR_TRANSPARENT, col)) {
- // FIXME: ???
- }
- if (AI_SUCCESS == mat.Get(AI_MATKEY_SHININESS, fval)) {
- pmat->set_shininess(fval);
- have = true;
- }
- if (AI_SUCCESS == mat.Get(AI_MATKEY_METALLIC_FACTOR, fval)) {
- pmat->set_metallic(fval);
- have = true;
- }
- if (AI_SUCCESS == mat.Get(AI_MATKEY_ROUGHNESS_FACTOR, fval)) {
- pmat->set_roughness(fval);
- have = true;
- }
- if (AI_SUCCESS == mat.Get(AI_MATKEY_REFRACTI, fval)) {
- pmat->set_refractive_index(fval);
- have = true;
- }
- else if (pmat->has_metallic()) {
- // Default refractive index to 1.5 for PBR models
- pmat->set_refractive_index(1.5);
- }
- if (have) {
- state = state->add_attrib(MaterialAttrib::make(pmat));
- }
-
- // Wireframe.
- if (AI_SUCCESS == mat.Get(AI_MATKEY_ENABLE_WIREFRAME, ival)) {
- if (ival) {
- state = state->add_attrib(RenderModeAttrib::make(RenderModeAttrib::M_wireframe));
- } else {
- state = state->add_attrib(RenderModeAttrib::make(RenderModeAttrib::M_filled));
- }
- }
-
- // Backface culling. Not sure if this is also supposed to set the twoside
- // flag in the material, I'm guessing not.
- if (AI_SUCCESS == mat.Get(AI_MATKEY_TWOSIDED, ival)) {
- if (ival) {
- state = state->add_attrib(CullFaceAttrib::make(CullFaceAttrib::M_cull_none));
- } else {
- state = state->add_attrib(CullFaceAttrib::make_default());
- }
- }
-
- // Alpha mode.
- aiString alpha_mode;
- if (AI_SUCCESS == mat.Get(AI_MATKEY_GLTF_ALPHAMODE, alpha_mode)) {
- if (strcmp(alpha_mode.C_Str(), "MASK") == 0) {
- PN_stdfloat cutoff = 0.5;
- mat.Get(AI_MATKEY_GLTF_ALPHACUTOFF, cutoff);
- state = state->add_attrib(AlphaTestAttrib::make(AlphaTestAttrib::M_greater_equal, cutoff));
- }
- else if (strcmp(alpha_mode.C_Str(), "BLEND") == 0) {
- state = state->add_attrib(TransparencyAttrib::make(TransparencyAttrib::M_alpha));
- }
- }
-
- // And let's not forget the textures!
- CPT(TextureAttrib) tattr = DCAST(TextureAttrib, TextureAttrib::make());
- CPT(TexMatrixAttrib) tmattr;
- load_texture_stage(mat, aiTextureType_DIFFUSE, TextureStage::M_modulate, tattr, tmattr);
-
- // Check for an ORM map, from the glTF/OBJ importer. glTF also puts it in the
- // LIGHTMAP slot, despite only having the lightmap in the red channel, so we
- // have to ignore it.
- if (mat.GetTextureCount(aiTextureType_UNKNOWN) > 0) {
- load_texture_stage(mat, aiTextureType_UNKNOWN, TextureStage::M_selector, tattr, tmattr);
- } else {
- load_texture_stage(mat, aiTextureType_LIGHTMAP, TextureStage::M_modulate, tattr, tmattr);
- }
-
- load_texture_stage(mat, aiTextureType_NORMALS, TextureStage::M_normal, tattr, tmattr);
- load_texture_stage(mat, aiTextureType_EMISSIVE, TextureStage::M_emission, tattr, tmattr);
- load_texture_stage(mat, aiTextureType_HEIGHT, TextureStage::M_height, tattr, tmattr);
- if (tattr->get_num_on_stages() > 0) {
- state = state->add_attrib(tattr);
- }
- if (tmattr != nullptr) {
- state = state->add_attrib(tmattr);
- }
-
- _mat_states[index] = std::move(state);
-}
-
-/**
- * Creates a CharacterJoint from an aiNode
- */
-void AssimpLoader::
-create_joint(Character *character, CharacterJointBundle *bundle, PartGroup *parent, const aiNode &node) {
- const aiMatrix4x4 &t = node.mTransformation;
- LMatrix4 mat(t.a1, t.b1, t.c1, t.d1,
- t.a2, t.b2, t.c2, t.d2,
- t.a3, t.b3, t.c3, t.d3,
- t.a4, t.b4, t.c4, t.d4);
- PT(CharacterJoint) joint = new CharacterJoint(character, bundle, parent, node.mName.C_Str(), mat);
-
- if (assimp_cat.is_debug()) {
- assimp_cat.debug()
- << "Creating joint for: " << node.mName.C_Str() << "\n";
- }
-
- for (size_t i = 0; i < node.mNumChildren; ++i) {
- if (_bonemap.find(node.mChildren[i]->mName.C_Str()) != _bonemap.end()) {
- create_joint(character, bundle, joint, *node.mChildren[i]);
- }
- }
-}
-
-/**
- * Creates a AnimChannelMatrixXfmTable from an aiNodeAnim
- */
-void AssimpLoader::
-create_anim_channel(const aiAnimation &anim, AnimBundle *bundle, AnimGroup *parent, const aiNode &node) {
- PT(AnimChannelMatrixXfmTable) group = new AnimChannelMatrixXfmTable(parent, node.mName.C_Str());
-
- // See if there is a channel for this node
- aiNodeAnim *node_anim = nullptr;
- for (size_t i = 0; i < anim.mNumChannels; ++i) {
- if (anim.mChannels[i]->mNodeName == node.mName) {
- node_anim = anim.mChannels[i];
- }
- }
-
- if (node_anim) {
- if (assimp_cat.is_debug()) {
- assimp_cat.debug()
- << "Found channel for node: " << node.mName.C_Str() << "\n";
- }
- // assimp_cat.debug() << "Num Position Keys " <<
- // node_anim->mNumPositionKeys << "\n"; assimp_cat.debug() << "Num
- // Rotation Keys " << node_anim->mNumRotationKeys << "\n";
- // assimp_cat.debug() << "Num Scaling Keys " << node_anim->mNumScalingKeys
- // << "\n";
-
- // Convert positions
- PTA_stdfloat tablex = PTA_stdfloat::empty_array(node_anim->mNumPositionKeys);
- PTA_stdfloat tabley = PTA_stdfloat::empty_array(node_anim->mNumPositionKeys);
- PTA_stdfloat tablez = PTA_stdfloat::empty_array(node_anim->mNumPositionKeys);
- for (size_t i = 0; i < node_anim->mNumPositionKeys; ++i) {
- tablex[i] = node_anim->mPositionKeys[i].mValue.x;
- tabley[i] = node_anim->mPositionKeys[i].mValue.y;
- tablez[i] = node_anim->mPositionKeys[i].mValue.z;
- }
- group->set_table('x', tablex);
- group->set_table('y', tabley);
- group->set_table('z', tablez);
-
- // Convert rotations
- PTA_stdfloat tableh = PTA_stdfloat::empty_array(node_anim->mNumRotationKeys);
- PTA_stdfloat tablep = PTA_stdfloat::empty_array(node_anim->mNumRotationKeys);
- PTA_stdfloat tabler = PTA_stdfloat::empty_array(node_anim->mNumRotationKeys);
- for (size_t i = 0; i < node_anim->mNumRotationKeys; ++i) {
- aiQuaternion ai_quat = node_anim->mRotationKeys[i].mValue;
- LVecBase3 hpr = LQuaternion(ai_quat.w, ai_quat.x, ai_quat.y, ai_quat.z).get_hpr();
- tableh[i] = hpr.get_x();
- tablep[i] = hpr.get_y();
- tabler[i] = hpr.get_z();
- }
- group->set_table('h', tableh);
- group->set_table('p', tablep);
- group->set_table('r', tabler);
-
- // Convert scales
- PTA_stdfloat tablei = PTA_stdfloat::empty_array(node_anim->mNumScalingKeys);
- PTA_stdfloat tablej = PTA_stdfloat::empty_array(node_anim->mNumScalingKeys);
- PTA_stdfloat tablek = PTA_stdfloat::empty_array(node_anim->mNumScalingKeys);
- for (size_t i = 0; i < node_anim->mNumScalingKeys; ++i) {
- tablei[i] = node_anim->mScalingKeys[i].mValue.x;
- tablej[i] = node_anim->mScalingKeys[i].mValue.y;
- tablek[i] = node_anim->mScalingKeys[i].mValue.z;
- }
- group->set_table('i', tablei);
- group->set_table('j', tablej);
- group->set_table('k', tablek);
- }
- else if (assimp_cat.is_debug()) {
- assimp_cat.debug()
- << "No channel found for node: " << node.mName.C_Str() << "\n";
- }
-
-
- for (size_t i = 0; i < node.mNumChildren; ++i) {
- if (_bonemap.find(node.mChildren[i]->mName.C_Str()) != _bonemap.end()) {
- create_anim_channel(anim, bundle, group, *node.mChildren[i]);
- }
- }
-}
-
-/**
- * Converts an aiMesh into a Geom.
- */
-void AssimpLoader::
-load_mesh(size_t index) {
- const aiMesh &mesh = *_scene->mMeshes[index];
-
- // Check if we need to make a Character
- PT(Character) character = nullptr;
- if (mesh.HasBones()) {
- if (assimp_cat.is_debug()) {
- assimp_cat.debug()
- << "Creating character for mesh '" << mesh.mName.C_Str() << "' with "
- << mesh.mNumBones << " bones\n";
- }
-
- // Find and add all bone nodes to the bone map
- for (size_t i = 0; i < mesh.mNumBones; ++i) {
- const aiBone &bone = *mesh.mBones[i];
- const aiNode *node = find_node(*_scene->mRootNode, bone.mName);
- _bonemap[bone.mName.C_Str()] = node;
- }
-
- // Now create a character from the bones
- character = new Character(mesh.mName.C_Str());
- PT(CharacterJointBundle) bundle = character->get_bundle(0);
- PT(PartGroup) skeleton = new PartGroup(bundle, "");
-
- for (size_t i = 0; i < mesh.mNumBones; ++i) {
- const aiBone &bone = *mesh.mBones[i];
-
- // Find the root bone node
- const aiNode *root = _bonemap[bone.mName.C_Str()];
- while (root->mParent && _bonemap.find(root->mParent->mName.C_Str()) != _bonemap.end()) {
- root = root->mParent;
- }
-
- // Don't process this root if we already have a joint for it
- if (character->find_joint(root->mName.C_Str())) {
- continue;
- }
-
- create_joint(character, bundle, skeleton, *root);
- }
- }
-
- // Create transform blend table
- PT(TransformBlendTable) tbtable = new TransformBlendTable;
- pvector bone_weights(mesh.mNumVertices);
- if (character) {
- for (size_t i = 0; i < mesh.mNumBones; ++i) {
- const aiBone &bone = *mesh.mBones[i];
- CharacterJoint *joint = character->find_joint(bone.mName.C_Str());
- if (joint == nullptr) {
- if (assimp_cat.is_debug()) {
- assimp_cat.debug()
- << "Could not find joint for bone: " << bone.mName.C_Str() << "\n";
- }
- continue;
- }
-
- CPT(JointVertexTransform) jvt = new JointVertexTransform(joint);
-
- for (size_t j = 0; j < bone.mNumWeights; ++j) {
- const aiVertexWeight &weight = bone.mWeights[j];
-
- bone_weights[weight.mVertexId].push_back(BoneWeight(jvt, weight.mWeight));
- }
- }
- }
-
- // Create the vertex format.
- PT(GeomVertexArrayFormat) aformat = new GeomVertexArrayFormat;
- aformat->add_column(InternalName::get_vertex(), 3, Geom::NT_stdfloat, Geom::C_point);
- if (mesh.HasNormals()) {
- aformat->add_column(InternalName::get_normal(), 3, Geom::NT_stdfloat, Geom::C_normal);
- }
- if (mesh.HasVertexColors(0)) {
- aformat->add_column(InternalName::get_color(), 4, Geom::NT_stdfloat, Geom::C_color);
- }
- unsigned int num_uvs = mesh.GetNumUVChannels();
- if (num_uvs > 0) {
- // UV sets are named texcoord, texcoord.1, texcoord.2...
- aformat->add_column(InternalName::get_texcoord(), 3, Geom::NT_stdfloat, Geom::C_texcoord);
- for (unsigned int u = 1; u < num_uvs; ++u) {
- ostringstream out;
- out << u;
- aformat->add_column(InternalName::get_texcoord_name(out.str()), 3, Geom::NT_stdfloat, Geom::C_texcoord);
- }
- }
- if (mesh.HasTangentsAndBitangents()) {
- aformat->add_column(InternalName::get_tangent(), 3, Geom::NT_stdfloat, Geom::C_vector);
- aformat->add_column(InternalName::get_binormal(), 3, Geom::NT_stdfloat, Geom::C_vector);
- }
-
- PT(GeomVertexArrayFormat) tb_aformat = new GeomVertexArrayFormat;
- tb_aformat->add_column(InternalName::make("transform_blend"), 1, Geom::NT_uint16, Geom::C_index);
-
- // Check to see if we need to convert any animations
- for (size_t i = 0; i < _scene->mNumAnimations; ++i) {
- aiAnimation &ai_anim = *_scene->mAnimations[i];
- bool convert_anim = false;
-
- if (assimp_cat.is_debug()) {
- assimp_cat.debug()
- << "Checking to see if anim (" << ai_anim.mName.C_Str()
- << ") matches character (" << mesh.mName.C_Str() << ")\n";
- }
- for (size_t j = 0; j < ai_anim.mNumChannels; ++j) {
- if (assimp_cat.is_spam()) {
- assimp_cat.spam()
- << "Searching for " << ai_anim.mChannels[j]->mNodeName.C_Str()
- << " in bone map" << "\n";
- }
- if (_bonemap.find(ai_anim.mChannels[j]->mNodeName.C_Str()) != _bonemap.end()) {
- convert_anim = true;
- break;
- }
- }
-
- if (convert_anim) {
- if (assimp_cat.is_debug()) {
- assimp_cat.debug()
- << "Found animation (" << ai_anim.mName.C_Str()
- << ") for character (" << mesh.mName.C_Str() << ")\n";
- }
-
- // Now create the animation
- unsigned int frames = 0;
- for (size_t j = 0; j < ai_anim.mNumChannels; ++j) {
- if (ai_anim.mChannels[j]->mNumPositionKeys > frames) {
- frames = ai_anim.mChannels[j]->mNumPositionKeys;
- }
- if (ai_anim.mChannels[j]->mNumRotationKeys > frames) {
- frames = ai_anim.mChannels[j]->mNumRotationKeys;
- }
- if (ai_anim.mChannels[j]->mNumScalingKeys > frames) {
- frames = ai_anim.mChannels[j]->mNumScalingKeys;
- }
- }
- PN_stdfloat fps = frames / (ai_anim.mTicksPerSecond * ai_anim.mDuration);
- if (assimp_cat.is_debug()) {
- assimp_cat.debug()
- << "FPS " << fps << "\n";
- assimp_cat.debug()
- << "Frames " << frames << "\n";
- }
-
- PT(AnimBundle) bundle = new AnimBundle(mesh.mName.C_Str(), fps, frames);
- PT(AnimGroup) skeleton = new AnimGroup(bundle, "");
-
- for (size_t i = 0; i < mesh.mNumBones; ++i) {
- const aiBone &bone = *mesh.mBones[i];
-
- // Find the root bone node
- const aiNode *root = _bonemap[bone.mName.C_Str()];
- while (root->mParent && _bonemap.find(root->mParent->mName.C_Str()) != _bonemap.end()) {
- root = root->mParent;
- }
-
- // Only convert root nodes
- if (root->mName == bone.mName) {
- create_anim_channel(ai_anim, bundle, skeleton, *root);
-
- // Attach the animation to the character node
- PT(AnimBundleNode) bundle_node = new AnimBundleNode(bone.mName.C_Str(), bundle);
- character->add_child(bundle_node);
- }
- }
- }
- }
-
- // TODO: if there is only one UV set, hackily iterate over the texture
- // stages and clear the texcoord name things
-
- PT(GeomVertexFormat) format = new GeomVertexFormat;
- format->add_array(aformat);
- if (character) {
- format->add_array(tb_aformat);
-
- GeomVertexAnimationSpec aspec;
- aspec.set_panda();
- format->set_animation(aspec);
- }
-
- // Create the GeomVertexData.
- string name (mesh.mName.data, mesh.mName.length);
- PT(GeomVertexData) vdata = new GeomVertexData(name, GeomVertexFormat::register_format(format), Geom::UH_static);
- if (character) {
- vdata->set_transform_blend_table(tbtable);
- }
- vdata->unclean_set_num_rows(mesh.mNumVertices);
-
- // Read out the vertices.
- GeomVertexWriter vertex (vdata, InternalName::get_vertex());
- for (size_t i = 0; i < mesh.mNumVertices; ++i) {
- const aiVector3D &vec = mesh.mVertices[i];
- vertex.set_data3(vec.x, vec.y, vec.z);
- }
-
- // Now the normals, if any.
- if (mesh.HasNormals()) {
- GeomVertexWriter normal (vdata, InternalName::get_normal());
- for (size_t i = 0; i < mesh.mNumVertices; ++i) {
- const aiVector3D &vec = mesh.mNormals[i];
- normal.set_data3(vec.x, vec.y, vec.z);
- }
- }
-
- // Vertex colors, if any. We only import the first set.
- if (mesh.HasVertexColors(0)) {
- GeomVertexWriter color (vdata, InternalName::get_color());
- for (size_t i = 0; i < mesh.mNumVertices; ++i) {
- const aiColor4D &col = mesh.mColors[0][i];
- color.set_data4(col.r, col.g, col.b, col.a);
- }
- }
-
- // Now the texture coordinates.
- if (num_uvs > 0) {
- // UV sets are named texcoord, texcoord.1, texcoord.2...
- GeomVertexWriter texcoord0 (vdata, InternalName::get_texcoord());
- for (size_t i = 0; i < mesh.mNumVertices; ++i) {
- const aiVector3D &vec = mesh.mTextureCoords[0][i];
- texcoord0.set_data3(vec.x, vec.y, vec.z);
- }
- for (unsigned int u = 1; u < num_uvs; ++u) {
- ostringstream out;
- out << u;
- GeomVertexWriter texcoord (vdata, InternalName::get_texcoord_name(out.str()));
- for (size_t i = 0; i < mesh.mNumVertices; ++i) {
- const aiVector3D &vec = mesh.mTextureCoords[u][i];
- texcoord.set_data3(vec.x, vec.y, vec.z);
- }
- }
- }
-
- // Now the tangents and bitangents, if any.
- if (mesh.HasTangentsAndBitangents()) {
- GeomVertexWriter tangent (vdata, InternalName::get_tangent());
- GeomVertexWriter binormal (vdata, InternalName::get_binormal());
- for (size_t i = 0; i < mesh.mNumVertices; ++i) {
- const aiVector3D &tvec = mesh.mTangents[i];
- const aiVector3D &bvec = mesh.mBitangents[i];
- tangent.set_data3(tvec.x, tvec.y, tvec.z);
- binormal.set_data3(bvec.x, bvec.y, bvec.z);
- }
- }
-
- // Now the transform blend table
- if (character) {
- GeomVertexWriter transform_blend (vdata, InternalName::get_transform_blend());
-
- for (size_t i = 0; i < mesh.mNumVertices; ++i) {
- TransformBlend tblend;
-
- for (size_t j = 0; j < bone_weights[i].size(); ++j) {
- tblend.add_transform(bone_weights[i][j].joint_vertex_xform, bone_weights[i][j].weight);
- }
- transform_blend.set_data1i(tbtable->add_blend(tblend));
- }
-
- tbtable->set_rows(SparseArray::lower_on(vdata->get_num_rows()));
- }
-
- // Now read out the primitives. Keep in mind that we called ReadFile with
- // the aiProcess_Triangulate flag earlier, so we don't have to worry about
- // polygons.
- PT(GeomPoints) points = new GeomPoints(Geom::UH_static);
- PT(GeomLines) lines = new GeomLines(Geom::UH_static);
- PT(GeomTriangles) triangles = new GeomTriangles(Geom::UH_static);
-
- // Now add the vertex indices.
- for (size_t i = 0; i < mesh.mNumFaces; ++i) {
- const aiFace &face = mesh.mFaces[i];
-
- if (face.mNumIndices == 0) {
- // It happens, strangely enough.
- continue;
- } else if (face.mNumIndices == 1) {
- points->add_vertex(face.mIndices[0]);
- points->close_primitive();
- } else if (face.mNumIndices == 2) {
- lines->add_vertices(face.mIndices[0], face.mIndices[1]);
- lines->close_primitive();
- } else if (face.mNumIndices == 3) {
- triangles->add_vertices(face.mIndices[0], face.mIndices[1], face.mIndices[2]);
- triangles->close_primitive();
- } else {
- nassertd(false) continue;
- }
- }
-
- // Create a geom and add the primitives to it.
- Geoms &geoms = _geoms[index];
- geoms._mat_index = mesh.mMaterialIndex;
-
- if (points->get_num_primitives() > 0) {
- geoms._points = new Geom(vdata);
- geoms._points->add_primitive(points);
- }
- if (lines->get_num_primitives() > 0) {
- geoms._lines = new Geom(vdata);
- geoms._lines->add_primitive(lines);
- }
- if (triangles->get_num_primitives() > 0) {
- geoms._triangles = new Geom(vdata);
- geoms._triangles->add_primitive(triangles);
- }
-
- if (character) {
- geoms._character = character;
-
- PT(GeomNode) gnode = new GeomNode("");
- if (geoms._points != nullptr) {
- gnode->add_geom(geoms._points);
- }
- if (geoms._lines != nullptr) {
- gnode->add_geom(geoms._lines);
- }
- if (geoms._triangles != nullptr) {
- gnode->add_geom(geoms._triangles);
- }
- gnode->set_state(_mat_states[mesh.mMaterialIndex]);
- character->add_child(gnode);
- }
-}
-
-/**
- * Converts an aiNode into a PandaNode. Returns true if the node had anything
- * of interest under it, false otherwise.
- */
-bool AssimpLoader::
-load_node(const aiNode &node, PandaNode *parent, bool under_joint) {
- PT(PandaNode) pnode;
- string name (node.mName.data, node.mName.length);
-
- if (assimp_cat.is_debug()) {
- assimp_cat.debug()
- << "Converting node '" << name << "' with " << node.mNumMeshes
- << " meshes and " << node.mNumChildren << " children\n";
- }
-
- if (!under_joint) {
- under_joint = (_bonemap.find(node.mName.C_Str()) != _bonemap.end());
- }
-
- bool prune = false;
-
- if (node.mNumMeshes == 0) {
- if (parent == _root && assimp_collapse_dummy_root_node && !under_joint &&
- (name.empty() || name[0] == '$' || name == "RootNode" || name == "ROOT" || name == "Root" || (name.size() > 2 && name[0] == '<' && name[name.size() - 1] == '>') || name == _root->get_name())) {
- // Collapse root node.
- pnode = _root;
- } else {
- pnode = new PandaNode(name);
-
- // Possibly prune this if this is a joint or under a joint.
- prune = under_joint;
- }
- }
- else if (node.mNumMeshes == 1) {
- size_t meshIndex = node.mMeshes[0];
- const Geoms &geoms = _geoms[meshIndex];
-
- if (geoms._character != nullptr) {
- pnode = new PandaNode(name);
- pnode->add_child(geoms._character);
- }
- else {
- PT(GeomNode) gnode = new GeomNode(name);
- const RenderState *state = _mat_states[geoms._mat_index];
- if (geoms._points != nullptr) {
- gnode->add_geom(geoms._points);
- }
- if (geoms._lines != nullptr) {
- gnode->add_geom(geoms._lines);
- }
- if (geoms._triangles != nullptr) {
- gnode->add_geom(geoms._triangles);
- }
- if (state != nullptr) {
- // Only set the state on the GeomNode if there are no child nodes.
- if (node.mNumChildren == 0) {
- gnode->set_state(state);
- } else {
- for (int i = 0; i < gnode->get_num_geoms(); ++i) {
- gnode->set_geom_state(i, state);
- }
- }
- }
- pnode = gnode;
- }
- }
- else {
- // Do we have regular meshes or just animated meshes?
- bool character_only = true;
-
- // First add all the regular meshes.
- for (size_t i = 0; i < node.mNumMeshes; ++i) {
- size_t meshIndex = node.mMeshes[i];
-
- if (_geoms[meshIndex]._character == nullptr) {
- character_only = false;
- break;
- }
- }
-
- PT(GeomNode) gnode;
- if (character_only) {
- pnode = new PandaNode(name);
- } else {
- gnode = new GeomNode(name);
- pnode = gnode;
- }
-
- for (size_t i = 0; i < node.mNumMeshes; ++i) {
- size_t meshIndex = node.mMeshes[i];
- const Geoms &geoms = _geoms[meshIndex];
-
- if (geoms._character != nullptr) {
- // An animated mesh, which already is converted as Character with an
- // attached GeomNode.
- pnode->add_child(geoms._character);
- }
- else {
- // A non-animated mesh.
- const RenderState *state = _mat_states[geoms._mat_index];
- if (geoms._points != nullptr) {
- gnode->add_geom(geoms._points, state);
- }
- if (geoms._lines != nullptr) {
- gnode->add_geom(geoms._lines, state);
- }
- if (geoms._triangles != nullptr) {
- gnode->add_geom(geoms._triangles, state);
- }
- }
- }
- }
-
- if (parent != pnode) {
- parent->add_child(pnode);
- }
-
- if (node.mMetaData != nullptr) {
- for (unsigned i = 0; i < node.mMetaData->mNumProperties; ++i) {
- const aiMetadataEntry &entry = node.mMetaData->mValues[i];
- std::string value;
- switch (entry.mType) {
- //case AI_BOOL:
- // value = (*static_cast(entry.mData)) ? "1" : "";
- // break;
- case AI_INT32:
- value = format_string(*static_cast(entry.mData));
- break;
- case AI_UINT64:
- value = format_string(*static_cast(entry.mData));
- break;
- case AI_FLOAT:
- value = format_string(*static_cast(entry.mData));
- break;
- case AI_DOUBLE:
- value = format_string(*static_cast(entry.mData));
- break;
- case AI_AISTRING:
- {
- const aiString *str = static_cast(entry.mData);
- value = std::string(str->data, str->length);
- }
- break;
- default:
- continue;
- }
- const aiString &key = node.mMetaData->mKeys[i];
- pnode->set_tag(std::string(key.data, key.length), std::move(value));
- }
- }
-
- // Load in the transformation matrix.
- const aiMatrix4x4 &t = node.mTransformation;
- if (!t.IsIdentity()) {
- LMatrix4 mat(t.a1, t.b1, t.c1, t.d1,
- t.a2, t.b2, t.c2, t.d2,
- t.a3, t.b3, t.c3, t.d3,
- t.a4, t.b4, t.c4, t.d4);
- pnode->set_transform(TransformState::make_mat(mat));
- }
-
- for (size_t i = 0; i < node.mNumChildren; ++i) {
- if (load_node(*node.mChildren[i], pnode, under_joint)) {
- prune = false;
- }
- }
-
- if (prune) {
- // This is an empty node in a hierarchy of joints, prune it.
- parent->remove_child(pnode);
- if (assimp_cat.is_debug()) {
- assimp_cat.debug()
- << "Pruning node '" << name << "'\n";
- }
- return false;
- } else {
- return true;
- }
-}
-
-/**
- * Converts an aiLight into a LightNode.
- */
-void AssimpLoader::
-load_light(const aiLight &light) {
- string name (light.mName.data, light.mName.length);
- if (assimp_cat.is_debug()) {
- assimp_cat.debug() << "Found light '" << name << "'\n";
- }
-
- aiColor3D col;
- aiVector3D vec;
-
- switch (light.mType) {
- case aiLightSource_DIRECTIONAL: {
- PT(DirectionalLight) dlight = new DirectionalLight(name);
- _root->add_child(dlight);
-
- col = light.mColorDiffuse;
- dlight->set_color(LColor(col.r, col.g, col.b, 1));
-
- col = light.mColorSpecular;
- dlight->set_specular_color(LColor(col.r, col.g, col.b, 1));
-
- vec = light.mPosition;
- dlight->set_point(LPoint3(vec.x, vec.y, vec.z));
-
- vec = light.mDirection;
- dlight->set_direction(LVector3(vec.x, vec.y, vec.z));
- break; }
-
- case aiLightSource_POINT: {
- PT(PointLight) plight = new PointLight(name);
- _root->add_child(plight);
-
- col = light.mColorDiffuse;
- plight->set_color(LColor(col.r, col.g, col.b, 1));
-
- col = light.mColorSpecular;
- plight->set_specular_color(LColor(col.r, col.g, col.b, 1));
-
- vec = light.mPosition;
- plight->set_point(LPoint3(vec.x, vec.y, vec.z));
-
- plight->set_attenuation(LVecBase3(light.mAttenuationConstant,
- light.mAttenuationLinear,
- light.mAttenuationQuadratic));
- break; }
-
- case aiLightSource_SPOT: {
- PT(Spotlight) plight = new Spotlight(name);
- _root->add_child(plight);
-
- col = light.mColorDiffuse;
- plight->set_color(LColor(col.r, col.g, col.b, 1));
-
- col = light.mColorSpecular;
- plight->set_specular_color(LColor(col.r, col.g, col.b, 1));
-
- plight->set_attenuation(LVecBase3(light.mAttenuationConstant,
- light.mAttenuationLinear,
- light.mAttenuationQuadratic));
-
- plight->get_lens()->set_fov(light.mAngleOuterCone);
- // TODO: translate mAngleInnerCone to an exponent, somehow
-
- // This *should* be about right.
- vec = light.mDirection;
- LPoint3 pos (light.mPosition.x, light.mPosition.y, light.mPosition.z);
- LQuaternion quat;
- ::look_at(quat, LPoint3(vec.x, vec.y, vec.z), LVector3::up());
- plight->set_transform(TransformState::make_pos_quat(pos, quat));
- break; }
-
- case aiLightSource_AMBIENT:
- // This is handled below.
- break;
-
- default:
- assimp_cat.warning() << "Light '" << name << "' has an unknown type!\n";
- return;
- }
-
- // If there's an ambient color, add it as ambient light.
- col = light.mColorAmbient;
- LVecBase4 ambient (col.r, col.g, col.b, 0);
- if (ambient != LVecBase4::zero()) {
- PT(AmbientLight) alight = new AmbientLight(name);
- alight->set_color(ambient);
- _root->add_child(alight);
- }
-}
diff --git a/pandatool/src/assimp/assimpLoader.h b/pandatool/src/assimp/assimpLoader.h
deleted file mode 100644
index e323cb1e..00000000
--- a/pandatool/src/assimp/assimpLoader.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file assimpLoader.h
- * @author rdb
- * @date 2011-03-29
- */
-
-#ifndef ASSIMPLOADER_H
-#define ASSIMPLOADER_H
-
-#include "config_assimp.h"
-#include "filename.h"
-#include "modelRoot.h"
-#include "texture.h"
-#include "textureStage.h"
-#include "pmap.h"
-
-#include
-#include
-
-class Character;
-class CharacterJointBundle;
-class PartGroup;
-class AnimBundle;
-class AnimGroup;
-
-struct char_cmp {
- bool operator () (const char *a, const char *b) const {
- return strcmp(a,b) < 0;
- }
-};
-typedef pmap BoneMap;
-
-/**
- * Class that interfaces with Assimp and builds Panda nodes to represent the
- * Assimp structures. The loader should be reusable.
- */
-class AssimpLoader : public TypedReferenceCount {
-public:
- AssimpLoader();
- virtual ~AssimpLoader();
-
- void get_extensions(std::string &ext) const;
-
- bool read(const Filename &filename);
- void build_graph();
-
-public:
- bool _error;
- PT(ModelRoot) _root;
- Filename _filename;
- Mutex _lock;
-
-private:
- Assimp::Importer _importer;
- const aiScene *_scene;
-
- struct Geoms {
- PT(Geom) _points;
- PT(Geom) _lines;
- PT(Geom) _triangles;
- PT(Character) _character;
- unsigned int _mat_index = 0;
- };
-
- // These arrays are temporarily used during the build_graph run.
- PT(Texture) *_textures;
- CPT(RenderState) *_mat_states;
- Geoms *_geoms;
- BoneMap _bonemap;
-
- const aiNode *find_node(const aiNode &root, const aiString &name);
-
- void load_texture(size_t index);
- void load_texture_stage(const aiMaterial &mat, const aiTextureType &ttype,
- TextureStage::Mode mode, CPT(TextureAttrib) &tattr,
- CPT(TexMatrixAttrib) &tmattr);
- void load_material(size_t index);
- void create_joint(Character *character, CharacterJointBundle *bundle, PartGroup *parent, const aiNode &node);
- void create_anim_channel(const aiAnimation &anim, AnimBundle *bundle, AnimGroup *parent, const aiNode &node);
- void load_mesh(size_t index);
- bool load_node(const aiNode &node, PandaNode *parent, bool under_joint = false);
- void load_light(const aiLight &light);
-};
-
-#include "assimpLoader.I"
-
-#endif
diff --git a/pandatool/src/assimp/config_assimp.cxx b/pandatool/src/assimp/config_assimp.cxx
deleted file mode 100644
index 42446e2b..00000000
--- a/pandatool/src/assimp/config_assimp.cxx
+++ /dev/null
@@ -1,114 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file config_assimp.cxx
- * @author rdb
- * @date 2011-03-29
- */
-
-#include "config_assimp.h"
-
-#include "loaderFileTypeAssimp.h"
-
-#include "dconfig.h"
-#include "loaderFileTypeRegistry.h"
-
-ConfigureDef(config_assimp);
-NotifyCategoryDef(assimp, "");
-
-ConfigureFn(config_assimp) {
- init_libassimp();
-}
-
-ConfigVariableBool assimp_calc_tangent_space
-("assimp-calc-tangent-space", false,
- PRC_DESC("Calculates tangents and binormals for meshes imported via Assimp."));
-
-ConfigVariableBool assimp_join_identical_vertices
-("assimp-join-identical-vertices", true,
- PRC_DESC("Merges duplicate vertices. Set this to false if you want each "
- "vertex to only be in use on one triangle."));
-
-ConfigVariableBool assimp_improve_cache_locality
-("assimp-improve-cache-locality", true,
- PRC_DESC("Improves rendering performance of the loaded meshes by reordering "
- "triangles for better vertex cache locality. Set this to false if "
- "you need geometry to be loaded in the exact order that it was "
- "specified in the file, or to improve load performance."));
-
-ConfigVariableBool assimp_remove_redundant_materials
-("assimp-remove-redundant-materials", true,
- PRC_DESC("Removes redundant/unreferenced materials from assets."));
-
-ConfigVariableBool assimp_fix_infacing_normals
-("assimp-fix-infacing-normals", false,
- PRC_DESC("Determines which normal vectors are facing inward and inverts them "
- "so that they are facing outward."));
-
-ConfigVariableBool assimp_optimize_meshes
-("assimp-optimize-meshes", true,
- PRC_DESC("Reduces the number of draw calls by unifying geometry with the same "
- "materials. Especially effective in conjunction with "
- "assimp-optimize-graph and assimp-remove-redundant-materials."));
-
-ConfigVariableBool assimp_optimize_graph
-("assimp-optimize-graph", false,
- PRC_DESC("Optimizes the scene geometry by flattening the scene hierarchy. "
- "This is very efficient (combined with assimp-optimize-meshes), but "
- "it may result the hierarchy to become lost, so it is disabled by "
- "default."));
-
-ConfigVariableBool assimp_flip_winding_order
-("assimp-flip-winding-order", false,
- PRC_DESC("Set this true to flip the winding order of all models loaded via "
- "the Assimp loader. Note that you may need to clear the model-cache "
- "after changing this."));
-
-ConfigVariableBool assimp_gen_normals
-("assimp-gen-normals", false,
- PRC_DESC("Set this true to generate normals (if absent from file) on import. "
- "See assimp-smooth-normal-angle for more information. "
- "Note that you may need to clear the model-cache after "
- "changing this."));
-
-ConfigVariableDouble assimp_smooth_normal_angle
-("assimp-smooth-normal-angle", 0.0,
- PRC_DESC("Set this to anything other than 0.0 in degrees (so 180.0 is PI) to "
- "specify the maximum angle that may be between two face normals at "
- "the same vertex position that are smoothed together. Sometimes "
- "referred to as 'crease angle'. Only has effect if "
- "assimp-gen-normals is set to true and the file does not contain "
- "normals. Note that you may need to clear the model-cache after "
- "changing this."));
-
-ConfigVariableBool assimp_collapse_dummy_root_node
-("assimp-collapse-dummy-root-node", true,
- PRC_DESC("If set to true, collapses the root node that Assimp creates, if it "
- "appears to be a synthetic dummy root node and contains no meshes. "
- "This variable is new as of Panda3D 1.10.13 and will become true by "
- "default as of Panda3D 1.11.0."));
-
-/**
- * Initializes the library. This must be called at least once before any of
- * the functions or classes in this library can be used. Normally it will be
- * called by the static initializers and need not be called explicitly, but
- * special cases exist.
- */
-void
-init_libassimp() {
- static bool initialized = false;
- if (initialized) {
- return;
- }
- initialized = true;
-
- LoaderFileTypeAssimp::init_type();
-
- LoaderFileTypeRegistry *reg = LoaderFileTypeRegistry::get_global_ptr();
- reg->register_type(new LoaderFileTypeAssimp);
-}
diff --git a/pandatool/src/assimp/config_assimp.h b/pandatool/src/assimp/config_assimp.h
deleted file mode 100644
index f999a600..00000000
--- a/pandatool/src/assimp/config_assimp.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file config_assimp.h
- * @author rdb
- * @date 2011-03-29
- */
-
-#ifndef CONFIG_ASSIMP_H
-#define CONFIG_ASSIMP_H
-
-#include "pandatoolbase.h"
-#include "notifyCategoryProxy.h"
-#include "configVariableBool.h"
-#include "configVariableDouble.h"
-#include "dconfig.h"
-
-ConfigureDecl(config_assimp, EXPCL_ASSIMP, EXPTP_ASSIMP);
-NotifyCategoryDecl(assimp, EXPCL_ASSIMP, EXPTP_ASSIMP);
-
-extern ConfigVariableBool assimp_calc_tangent_space;
-extern ConfigVariableBool assimp_join_identical_vertices;
-extern ConfigVariableBool assimp_improve_cache_locality;
-extern ConfigVariableBool assimp_remove_redundant_materials;
-extern ConfigVariableBool assimp_fix_infacing_normals;
-extern ConfigVariableBool assimp_optimize_meshes;
-extern ConfigVariableBool assimp_optimize_graph;
-extern ConfigVariableBool assimp_flip_winding_order;
-extern ConfigVariableBool assimp_gen_normals;
-extern ConfigVariableDouble assimp_smooth_normal_angle;
-extern ConfigVariableBool assimp_collapse_dummy_root_node;
-
-extern EXPCL_ASSIMP void init_libassimp();
-
-#endif
diff --git a/pandatool/src/assimp/loaderFileTypeAssimp.cxx b/pandatool/src/assimp/loaderFileTypeAssimp.cxx
deleted file mode 100644
index bd3061f2..00000000
--- a/pandatool/src/assimp/loaderFileTypeAssimp.cxx
+++ /dev/null
@@ -1,133 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file loaderFileTypeAssimp.cxx
- * @author rdb
- * @date 2011-03-29
- */
-
-#include "loaderFileTypeAssimp.h"
-#include "config_assimp.h"
-#include "assimpLoader.h"
-
-#include
-
-using std::string;
-
-TypeHandle LoaderFileTypeAssimp::_type_handle;
-
-/**
- *
- */
-LoaderFileTypeAssimp::
-LoaderFileTypeAssimp() {
-}
-
-/**
- *
- */
-LoaderFileTypeAssimp::
-~LoaderFileTypeAssimp() {
-}
-
-/**
- *
- */
-string LoaderFileTypeAssimp::
-get_name() const {
- return "Assimp Importer";
-}
-
-/**
- *
- */
-string LoaderFileTypeAssimp::
-get_extension() const {
- return "";
-}
-
-/**
- * Returns a space-separated list of extension, in addition to the one
- * returned by get_extension(), that are recognized by this converter.
- */
-string LoaderFileTypeAssimp::
-get_additional_extensions() const {
- // This may be called at static init time, so ensure it is constructed now.
- static ConfigVariableString assimp_disable_extensions
- ("assimp-disable-extensions", "gltf glb",
- PRC_DESC("A list of extensions (without preceding dot) that should not be "
- "loaded via the Assimp loader, even if Assimp supports these "
- "formats. It is useful to set this for eg. gltf and glb files "
- "to prevent them from being accidentally loaded via the Assimp "
- "plug-in instead of via a superior plug-in like panda3d-gltf."));
-
- bool has_disabled_exts = !assimp_disable_extensions.empty();
-
- aiString aexts;
- aiGetExtensionList(&aexts);
-
- char *buffer = (char *)alloca(aexts.length + 2);
- char *p = buffer;
-
- // The format is like: *.mdc;*.mdl;*.mesh.xml;*.mot
- char *sub = strtok(aexts.data, ";");
- while (sub != nullptr) {
- bool enabled = true;
- if (has_disabled_exts) {
- for (size_t i = 0; i < assimp_disable_extensions.get_num_words(); ++i) {
- std::string disabled_ext = assimp_disable_extensions.get_word(i);
- if (strcmp(sub + 2, disabled_ext.c_str()) == 0) {
- enabled = false;
- break;
- }
- }
- }
- if (enabled) {
- *(p++) = ' ';
- size_t len = strlen(sub + 2);
- memcpy(p, sub + 2, len);
- p += len;
- }
-
- sub = strtok(nullptr, ";");
- }
-
- // Strip first space
- ++buffer;
- return std::string(buffer, p - buffer);
-}
-
-/**
- * Returns true if this file type can transparently load compressed files
- * (with a .pz or .gz extension), false otherwise.
- */
-bool LoaderFileTypeAssimp::
-supports_compressed() const {
- return true;
-}
-
-/**
- *
- */
-PT(PandaNode) LoaderFileTypeAssimp::
-load_file(const Filename &path, const LoaderOptions &options,
- BamCacheRecord *record) const {
-
- assimp_cat.info()
- << "Reading " << path << "\n";
-
- AssimpLoader loader;
- loader.local_object();
-
- if (!loader.read(path)) {
- return nullptr;
- }
-
- loader.build_graph();
- return DCAST(PandaNode, loader._root);
-}
diff --git a/pandatool/src/assimp/loaderFileTypeAssimp.h b/pandatool/src/assimp/loaderFileTypeAssimp.h
deleted file mode 100644
index 033ab9af..00000000
--- a/pandatool/src/assimp/loaderFileTypeAssimp.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file loaderFileTypeAssimp.h
- * @author rdb
- * @date 2011-03-29
- */
-
-#ifndef LOADERFILETYPEASSIMP_H
-#define LOADERFILETYPEASSIMP_H
-
-#include "config_assimp.h"
-#include "loaderFileType.h"
-
-class AssimpLoader;
-
-/**
- * This defines the Loader interface that uses the Assimp library to load
- * various model formats.
- */
-class EXPCL_ASSIMP LoaderFileTypeAssimp : public LoaderFileType {
-public:
- LoaderFileTypeAssimp();
- virtual ~LoaderFileTypeAssimp();
-
- virtual std::string get_name() const;
- virtual std::string get_extension() const;
- virtual std::string get_additional_extensions() const;
- virtual bool supports_compressed() const;
-
- virtual PT(PandaNode) load_file(const Filename &path, const LoaderOptions &options,
- BamCacheRecord *record) const;
-
-public:
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- LoaderFileType::init_type();
- register_type(_type_handle, "LoaderFileTypeAssimp",
- LoaderFileType::get_class_type());
- }
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
-
-private:
- static TypeHandle _type_handle;
-};
-
-#endif
diff --git a/pandatool/src/assimp/p3assimp_composite1.cxx b/pandatool/src/assimp/p3assimp_composite1.cxx
deleted file mode 100644
index bc813b11..00000000
--- a/pandatool/src/assimp/p3assimp_composite1.cxx
+++ /dev/null
@@ -1,7 +0,0 @@
-
-#include "config_assimp.cxx"
-#include "assimpLoader.cxx"
-#include "loaderFileTypeAssimp.cxx"
-#include "pandaIOStream.cxx"
-#include "pandaIOSystem.cxx"
-#include "pandaLogger.cxx"
diff --git a/pandatool/src/assimp/pandaIOStream.cxx b/pandatool/src/assimp/pandaIOStream.cxx
deleted file mode 100644
index e8d4dc86..00000000
--- a/pandatool/src/assimp/pandaIOStream.cxx
+++ /dev/null
@@ -1,107 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file pandaIOStream.cxx
- * @author rdb
- * @date 2011-03-29
- */
-
-#include "pandaIOStream.h"
-
-using std::ios;
-
-/**
- *
- */
-PandaIOStream::
-PandaIOStream(std::istream &stream) : _istream(stream) {
-}
-
-/**
- * Returns the size of this file.
- */
-size_t PandaIOStream::
-FileSize() const {
- _istream.clear();
- std::streampos cur = _istream.tellg();
- _istream.seekg(0, ios::end);
- std::streampos end = _istream.tellg();
- _istream.seekg(cur);
- return end;
-}
-
-/**
- * See fflush.
- */
-void PandaIOStream::
-Flush() {
- nassertv(false);
-}
-
-/**
- * See fread.
- */
-size_t PandaIOStream::
-Read(void *buffer, size_t size, size_t count) {
- _istream.read((char *)buffer, size * count);
-
- if (_istream.eof()) {
- // Gracefully handle EOF.
- _istream.clear(ios::eofbit);
- }
-
- return _istream.gcount() / size;
-}
-
-/**
- * See fseek.
- */
-aiReturn PandaIOStream::
-Seek(size_t offset, aiOrigin origin) {
- switch (origin) {
- case aiOrigin_SET:
- _istream.seekg(offset, ios::beg);
- break;
-
- case aiOrigin_CUR:
- _istream.seekg(offset, ios::cur);
- break;
-
- case aiOrigin_END:
- _istream.seekg(offset, ios::end);
- break;
-
- default:
- // Keep compiler happy
- nassertr(false, AI_FAILURE);
- break;
- }
-
- if (_istream.good()) {
- return AI_SUCCESS;
- } else {
- return AI_FAILURE;
- }
-}
-
-/**
- * See ftell.
- */
-size_t PandaIOStream::
-Tell() const {
- return _istream.tellg();
-}
-
-/**
- * See fwrite.
- */
-size_t PandaIOStream::
-Write(const void *buffer, size_t size, size_t count) {
- nassertr(false, 0);
- return 0;
-}
diff --git a/pandatool/src/assimp/pandaIOStream.h b/pandatool/src/assimp/pandaIOStream.h
deleted file mode 100644
index 18c24b14..00000000
--- a/pandatool/src/assimp/pandaIOStream.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file pandaIOStream.h
- * @author rdb
- * @date 2011-03-29
- */
-
-#ifndef PANDAIOSTREAM_H
-#define PANDAIOSTREAM_H
-
-#include "config_assimp.h"
-
-#include
-
-class PandaIOSystem;
-
-/**
- * Custom implementation of Assimp::IOStream. It simply wraps around an
- * istream object, and is unable to write.
- */
-class PandaIOStream : public Assimp::IOStream {
-public:
- PandaIOStream(std::istream &stream);
- virtual ~PandaIOStream() {};
-
- size_t FileSize() const;
- void Flush();
- size_t Read(void *pvBuffer, size_t pSize, size_t pCount);
- aiReturn Seek(size_t pOffset, aiOrigin pOrigin);
- size_t Tell() const;
- size_t Write(const void *buffer, size_t size, size_t count);
-
-private:
- std::istream &_istream;
-
- friend class PandaIOSystem;
-};
-
-#endif
diff --git a/pandatool/src/assimp/pandaIOSystem.cxx b/pandatool/src/assimp/pandaIOSystem.cxx
deleted file mode 100644
index 241790f6..00000000
--- a/pandatool/src/assimp/pandaIOSystem.cxx
+++ /dev/null
@@ -1,85 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file pandaIOSystem.cxx
- * @author rdb
- * @date 2011-03-29
- */
-
-#include "pandaIOSystem.h"
-#include "pandaIOStream.h"
-
-/**
- * Initializes the object with the given VFS, or the global one if none was
- * specified.
- */
-PandaIOSystem::
-PandaIOSystem(VirtualFileSystem *vfs) : _vfs(vfs) {
-}
-
-/**
- * Returns true if the file exists, duh.
- */
-bool PandaIOSystem::
-Exists(const char *file) const {
- Filename fn = Filename::from_os_specific(file);
- return _vfs->exists(fn);
-}
-
-/**
- * Closes the indicated file stream.
- */
-void PandaIOSystem::
-Close(Assimp::IOStream *file) {
- PandaIOStream *pstr = (PandaIOStream*) file;
- _vfs->close_read_file(&pstr->_istream);
-}
-
-/**
- * Returns true if the two paths point to the same file, false if not.
- */
-bool PandaIOSystem::
-ComparePaths(const char *p1, const char *p2) const {
- Filename fn1 = Filename::from_os_specific(p1);
- Filename fn2 = Filename::from_os_specific(p2);
- fn1.make_canonical();
- fn2.make_canonical();
- return fn1 == fn2;
-}
-
-/**
- * Returns the path separator for this operating system.
- */
-char PandaIOSystem::
-getOsSeparator() const {
-#ifdef _WIN32
- return '\\';
-#else
- return '/';
-#endif
-}
-
-/**
- * Opens the indicated file.
- */
-Assimp::IOStream *PandaIOSystem::
-Open(const char *file, const char *mode) {
- Filename fn = Filename::from_os_specific(file);
-
- if (mode[0] == 'r') {
- std::istream *stream = _vfs->open_read_file(file, true);
- if (stream == nullptr) {
- return nullptr;
- }
- return new PandaIOStream(*stream);
-
- } else {
- nassert_raise("write mode not implemented");
- return nullptr;
- }
-}
diff --git a/pandatool/src/assimp/pandaIOSystem.h b/pandatool/src/assimp/pandaIOSystem.h
deleted file mode 100644
index be8ad2dd..00000000
--- a/pandatool/src/assimp/pandaIOSystem.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file pandaIOSystem.h
- * @author rdb
- * @date 2011-03-29
- */
-
-#ifndef PANDAIOSYSTEM_H
-#define PANDAIOSYSTEM_H
-
-#include "config_assimp.h"
-#include "virtualFileSystem.h"
-
-#include
-
-/**
- * Custom implementation of Assimp::IOSystem.
- */
-class PandaIOSystem : public Assimp::IOSystem {
-public:
- PandaIOSystem(VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr());
- virtual ~PandaIOSystem() {};
-
- void Close(Assimp::IOStream *file);
- bool ComparePaths(const char *p1, const char *p2) const;
- bool Exists(const char *file) const;
- char getOsSeparator() const;
- Assimp::IOStream *Open(const char *file, const char *mode);
-
-private:
- VirtualFileSystem *_vfs;
-};
-
-#endif
diff --git a/pandatool/src/assimp/pandaLogger.cxx b/pandatool/src/assimp/pandaLogger.cxx
deleted file mode 100644
index ee0a4132..00000000
--- a/pandatool/src/assimp/pandaLogger.cxx
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file pandaLogger.cxx
- * @author rdb
- * @date 2011-05-05
- */
-
-#include "pandaLogger.h"
-
-#include
-
-PandaLogger *PandaLogger::_ptr = nullptr;
-
-/**
- * Makes sure there's a global PandaLogger object and makes sure that it is
- * Assimp's default logger.
- */
-void PandaLogger::
-set_default() {
- if (_ptr == nullptr) {
- _ptr = new PandaLogger;
- }
- if (_ptr != Assimp::DefaultLogger::get()) {
- Assimp::DefaultLogger::set(_ptr);
- }
-}
-
-/**
- *
- */
-void PandaLogger::OnDebug(const char *message) {
- if (assimp_cat.is_debug()) {
- assimp_cat.debug() << message << "\n";
- }
-}
-
-/**
- *
- */
-void PandaLogger::OnVerboseDebug(const char *message) {
- if (assimp_cat.is_spam()) {
- assimp_cat.spam() << message << "\n";
- }
-}
-
-/**
- *
- */
-void PandaLogger::OnError(const char *message) {
- assimp_cat.error() << message << "\n";
-}
-
-/**
- *
- */
-void PandaLogger::OnInfo(const char *message) {
- assimp_cat.info() << message << "\n";
-}
-
-/**
- *
- */
-void PandaLogger::OnWarn(const char *message) {
- assimp_cat.warning() << message << "\n";
-}
diff --git a/pandatool/src/assimp/pandaLogger.h b/pandatool/src/assimp/pandaLogger.h
deleted file mode 100644
index 2fdbd446..00000000
--- a/pandatool/src/assimp/pandaLogger.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file pandaLogger.h
- * @author rdb
- * @date 2011-05-05
- */
-
-#ifndef PANDALOGGER_H
-#define PANDALOGGER_H
-
-#include "config_assimp.h"
-
-#include
-
-/**
- * Custom implementation of Assimp::Logger. It simply wraps around the
- * assimp_cat methods.
- */
-class PandaLogger : public Assimp::Logger {
-public:
- static void set_default();
-
-protected:
- INLINE bool attachStream(Assimp::LogStream*, unsigned int) {
- return false;
- };
- INLINE bool detachStream(Assimp::LogStream*, unsigned int) {
- return false;
- };
-
- // Kept for compatibility with Assimp 4.x
- INLINE bool detatchStream(Assimp::LogStream*, unsigned int) {
- return false;
- };
-
- void OnDebug(const char *message);
- void OnVerboseDebug(const char *message);
- void OnError(const char *message);
- void OnInfo(const char *message);
- void OnWarn(const char *message);
-
-private:
- static PandaLogger *_ptr;
-};
-
-#endif
diff --git a/pandatool/src/bam/CMakeLists.txt b/pandatool/src/bam/CMakeLists.txt
deleted file mode 100644
index 32f5a6f5..00000000
--- a/pandatool/src/bam/CMakeLists.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-if(NOT BUILD_TOOLS)
- return()
-endif()
-
-add_executable(bam-info bamInfo.cxx bamInfo.h)
-target_link_libraries(bam-info p3progbase panda)
-install(TARGETS bam-info EXPORT Tools COMPONENT Tools DESTINATION ${CMAKE_INSTALL_BINDIR})
-
-if(HAVE_EGG)
-
- add_executable(egg2bam eggToBam.cxx eggToBam.h)
- target_link_libraries(egg2bam p3eggbase p3progbase panda)
- install(TARGETS egg2bam EXPORT Tools COMPONENT Tools DESTINATION ${CMAKE_INSTALL_BINDIR})
-
- if(HAVE_SQUISH)
- target_compile_definitions(egg2bam PRIVATE HAVE_SQUISH)
- endif()
-
- add_executable(bam2egg bamToEgg.cxx bamToEgg.h)
- target_link_libraries(bam2egg p3converter p3eggbase p3progbase panda)
- install(TARGETS bam2egg EXPORT Tools COMPONENT Tools DESTINATION ${CMAKE_INSTALL_BINDIR})
-
- add_executable(pts2bam ptsToBam.cxx ptsToBam.h)
- target_link_libraries(pts2bam p3progbase pandaegg panda)
- install(TARGETS pts2bam EXPORT Tools COMPONENT Tools DESTINATION ${CMAKE_INSTALL_BINDIR})
-
-endif()
diff --git a/pandatool/src/bam/bamInfo.cxx b/pandatool/src/bam/bamInfo.cxx
deleted file mode 100644
index 291d3379..00000000
--- a/pandatool/src/bam/bamInfo.cxx
+++ /dev/null
@@ -1,328 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file bamInfo.cxx
- * @author drose
- * @date 2000-07-02
- */
-
-#include "bamInfo.h"
-
-#include "bamFile.h"
-#include "pandaNode.h"
-#include "geomNode.h"
-#include "texture.h"
-#include "recorderHeader.h"
-#include "recorderFrame.h"
-#include "recorderTable.h"
-#include "dcast.h"
-#include "pvector.h"
-#include "bamCacheRecord.h"
-#include "bamCacheIndex.h"
-
-/**
- *
- */
-BamInfo::
-BamInfo() {
- set_program_brief("describe the contents of .bam files");
- set_program_description
- ("This program scans one or more Bam files--Panda's Binary Animation "
- "and Models native binary format--and describes their contents.");
-
- clear_runlines();
- add_runline("[opts] input.bam [input.bam ... ]");
-
- add_option
- ("ls", "", 0,
- "List the scene graph hierarchy in the bam file.",
- &BamInfo::dispatch_none, &_ls);
-
- add_option
- ("t", "", 0,
- "List explicitly each transition in the hierarchy.",
- &BamInfo::dispatch_none, &_verbose_transitions);
-
- add_option
- ("g", "", 0,
- "Output verbose information about each Geom in the Bam file.",
- &BamInfo::dispatch_none, &_verbose_geoms);
-
- _num_scene_graphs = 0;
-}
-
-
-/**
- *
- */
-void BamInfo::
-run() {
- bool okflag = true;
-
- Filenames::const_iterator fi;
- for (fi = _filenames.begin(); fi != _filenames.end(); ++fi) {
- if (!get_info(*fi)) {
- okflag = false;
- }
- }
-
- if (_num_scene_graphs > 0) {
- nout << "\nScene graph statistics:\n";
- _analyzer.write(nout, 2);
- }
- nout << "\n";
-
- if (!okflag) {
- // Exit with an error if any of the files was unreadable.
- exit(1);
- }
-}
-
-
-/**
- *
- */
-bool BamInfo::
-handle_args(ProgramBase::Args &args) {
- if (args.empty()) {
- nout << "You must specify the Bam file(s) to read on the command line.\n";
- return false;
- }
-
- ProgramBase::Args::const_iterator ai;
- for (ai = args.begin(); ai != args.end(); ++ai) {
- _filenames.push_back(*ai);
- }
-
- return true;
-}
-
-
-/**
- * Reads a single Bam file and displays its contents. Returns true if
- * successful, false on error.
- */
-bool BamInfo::
-get_info(const Filename &filename) {
- BamFile bam_file;
-
- if (!bam_file.open_read(filename)) {
- nout << "Unable to read.\n";
- return false;
- }
-
- const char *endian = "little-endian";
- if (bam_file.get_file_endian() == BamEnums::BE_bigendian) {
- endian = "big-endian";
- }
- int float_width = 32;
- if (bam_file.get_file_stdfloat_double()) {
- float_width = 64;
- }
-
- nout << filename << " : Bam version " << bam_file.get_file_major_ver()
- << "." << bam_file.get_file_minor_ver()
- << ", " << endian << ", " << float_width << "-bit floats.\n";
-
- Objects objects;
- TypedWritable *object = bam_file.read_object();
-
- if (object != nullptr &&
- object->is_exact_type(BamCacheRecord::get_class_type())) {
- // Here's a special case: if the first object in the file is a
- // BamCacheRecord, it's a cache data file; in this case, we output the
- // cache record, and then pretend it doesn't exist.
- DCAST(BamCacheRecord, object)->write(nout, 2);
- nout << "\n";
- object = bam_file.read_object();
- }
-
- while (object != nullptr || !bam_file.is_eof()) {
- if (object != nullptr) {
- objects.push_back(object);
- }
- object = bam_file.read_object();
- }
- if (!bam_file.resolve()) {
- nout << "Unable to fully resolve file.\n";
- return false;
- }
-
- // We can't close the bam file until we have examined the objects, since
- // closing it will decrement reference counts.
-
- if (objects.size() == 1 &&
- objects[0]->is_of_type(PandaNode::get_class_type())) {
- describe_scene_graph(DCAST(PandaNode, objects[0]));
-
- } else if (objects.size() == 1 &&
- objects[0]->is_of_type(Texture::get_class_type())) {
- describe_texture(DCAST(Texture, objects[0]));
-
- } else if (objects.size() == 1 &&
- objects[0]->is_of_type(BamCacheIndex::get_class_type())) {
- describe_cache_index(DCAST(BamCacheIndex, objects[0]));
-
- } else if (!objects.empty() && objects[0]->is_of_type(RecorderHeader::get_class_type())) {
- describe_session(DCAST(RecorderHeader, objects[0]), objects);
-
- } else {
- nout << "file contains " << objects.size() << " objects:\n";
- for (int i = 0; i < (int)objects.size(); i++) {
- describe_general_object(objects[i]);
- }
- }
-
- return true;
-}
-
-
-/**
- * Called for Bam files that contain a single scene graph and no other
- * objects. This should describe that scene graph in some meaningful way.
- */
-void BamInfo::
-describe_scene_graph(PandaNode *node) {
- // Parent the node to our own scene graph root, so we can (a) guarantee it
- // won't accidentally be deleted before we're done, (b) easily determine the
- // bounding volume of the scene, and (c) report statistics on all the bam
- // file's scene graphs together when we've finished.
-
- PT(PandaNode) root = new PandaNode("root");
- root->add_child(node);
- _num_scene_graphs++;
-
- int num_nodes = _analyzer.get_num_nodes();
- _analyzer.add_node(node);
- num_nodes = _analyzer.get_num_nodes() - num_nodes;
-
- nout << " " << num_nodes << " nodes, bounding volume is "
- << *root->get_bounds() << "\n";
-
- if (_ls || _verbose_geoms || _verbose_transitions) {
- list_hierarchy(node, 0);
- }
-}
-
-/**
- * Called for Bam files that contain a Texture object.
- */
-void BamInfo::
-describe_texture(Texture *tex) {
- tex->write(nout, 2);
-}
-
-/**
- * Called for Bam files that contain a BamCacheIndex object.
- */
-void BamInfo::
-describe_cache_index(BamCacheIndex *index) {
- index->write(nout, 2);
-}
-
-/**
- * Called for Bam files that contain a recorded session table.
- */
-void BamInfo::
-describe_session(RecorderHeader *header, const BamInfo::Objects &objects) {
- char time_buffer[1024];
- strftime(time_buffer, 1024, "%c",
- localtime(&header->_start_time));
-
- pset recorders;
- double last_timestamp = 0.0;
-
- for (size_t i = 1; i < objects.size(); i++) {
- if (objects[i]->is_of_type(RecorderFrame::get_class_type())) {
- RecorderFrame *frame = DCAST(RecorderFrame, objects[i]);
- if (frame->_table_changed) {
- RecorderTable::Recorders::const_iterator ri;
- for (ri = frame->_table->_recorders.begin();
- ri != frame->_table->_recorders.end();
- ++ri) {
- recorders.insert((*ri).first);
- }
- }
- last_timestamp = frame->_timestamp;
- }
- }
-
- nout << "Session, " << last_timestamp
- << " secs, " << objects.size() - 1 << " frames, "
- << time_buffer << ".\n"
- << "Recorders:";
- for (pset::iterator ni = recorders.begin();
- ni != recorders.end();
- ++ni) {
- nout << " " << (*ni);
- }
- nout << "\n";
-}
-
-/**
- * Called for Bam files that contain multiple objects which may or may not be
- * scene graph nodes. This should describe each object in some meaningful
- * way.
- */
-void BamInfo::
-describe_general_object(TypedWritable *object) {
- nassertv(object != nullptr);
- nout << " " << object->get_type() << "\n";
-}
-
-/**
- * Outputs the hierarchy and all of the verbose GeomNode information.
- */
-void BamInfo::
-list_hierarchy(PandaNode *node, int indent_level) {
- indent(nout, indent_level) << *node;
-
- if (_verbose_transitions) {
- nout << "\n";
- if (!node->get_transform()->is_identity()) {
- node->get_transform()->write(nout, indent_level);
- }
- if (!node->get_state()->is_empty()) {
- node->get_state()->write(nout, indent_level);
- }
- if (!node->get_effects()->is_empty()) {
- node->get_effects()->write(nout, indent_level);
- }
-
- } else {
- if (!node->get_transform()->is_identity()) {
- nout << " " << *node->get_transform();
- }
- if (!node->get_state()->is_empty()) {
- nout << " " << *node->get_state();
- }
- if (!node->get_effects()->is_empty()) {
- nout << " " << *node->get_effects();
- }
- nout << "\n";
- }
-
- if (_verbose_geoms && node->is_geom_node()) {
- GeomNode *geom_node;
- DCAST_INTO_V(geom_node, node);
- geom_node->write_verbose(nout, indent_level);
- }
-
- int num_children = node->get_num_children();
- for (int i = 0; i < num_children; i++) {
- PandaNode *child = node->get_child(i);
- list_hierarchy(child, indent_level + 2);
- }
-}
-
-int main(int argc, char *argv[]) {
- BamInfo prog;
- prog.parse_command_line(argc, argv);
- prog.run();
- return 0;
-}
diff --git a/pandatool/src/bam/bamInfo.h b/pandatool/src/bam/bamInfo.h
deleted file mode 100644
index 766c6986..00000000
--- a/pandatool/src/bam/bamInfo.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file bamInfo.h
- * @author drose
- * @date 2000-07-02
- */
-
-#ifndef BAMINFO_H
-#define BAMINFO_H
-
-#include "pandatoolbase.h"
-
-#include "programBase.h"
-#include "filename.h"
-#include "sceneGraphAnalyzer.h"
-
-#include "pvector.h"
-
-class TypedWritable;
-class PandaNode;
-class Texture;
-class BamCacheIndex;
-class RecorderHeader;
-
-/**
- *
- */
-class BamInfo : public ProgramBase {
-public:
- BamInfo();
-
- void run();
-
-protected:
- virtual bool handle_args(Args &args);
-
-private:
- typedef pvector Objects;
-
- bool get_info(const Filename &filename);
- void describe_scene_graph(PandaNode *node);
- void describe_texture(Texture *tex);
- void describe_cache_index(BamCacheIndex *index);
- void describe_session(RecorderHeader *header, const Objects &objects);
- void describe_general_object(TypedWritable *object);
- void list_hierarchy(PandaNode *node, int indent_level);
-
- typedef pvector Filenames;
- Filenames _filenames;
-
- bool _ls;
- bool _verbose_transitions;
- bool _verbose_geoms;
-
- int _num_scene_graphs;
- SceneGraphAnalyzer _analyzer;
-};
-
-#endif
diff --git a/pandatool/src/bam/bamToEgg.cxx b/pandatool/src/bam/bamToEgg.cxx
deleted file mode 100644
index 96aa14e4..00000000
--- a/pandatool/src/bam/bamToEgg.cxx
+++ /dev/null
@@ -1,104 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file bamToEgg.cxx
- * @author drose
- * @date 2001-06-25
- */
-
-#include "bamToEgg.h"
-#include "save_egg_file.h"
-#include "string_utils.h"
-#include "bamFile.h"
-#include "bamCacheRecord.h"
-
-/**
- *
- */
-BamToEgg::
-BamToEgg() :
- SomethingToEgg("bam", ".bam")
-{
- set_program_brief("convert a native Panda .bam file to an .egg file");
- set_program_description
- ("This program converts native Panda bam files to egg. The conversion "
- "is somewhat incomplete; running egg2bam followed by bam2egg should not "
- "be expected to yield the same egg file you started with.");
-
- redescribe_option
- ("cs",
- "Specify the coordinate system of the input " + _format_name +
- " file. By default, this is taken from the Config.prc file, which "
- "is currently " + format_string(get_default_coordinate_system()) + ".");
-
- _coordinate_system = get_default_coordinate_system();
-}
-
-/**
- *
- */
-void BamToEgg::
-run() {
- BamFile bam_file;
-
- if (!bam_file.open_read(_input_filename)) {
- nout << "Unable to read " << _input_filename << "\n";
- exit(1);
- }
-
- nout << _input_filename << " : Bam version "
- << bam_file.get_file_major_ver() << "."
- << bam_file.get_file_minor_ver() << "\n";
-
- typedef pvector Objects;
- Objects objects;
- TypedWritable *object = bam_file.read_object();
-
- if (object != nullptr &&
- object->is_exact_type(BamCacheRecord::get_class_type())) {
- // Here's a special case: if the first object in the file is a
- // BamCacheRecord, it's really a cache data file and not a true bam file;
- // but skip over the cache data record and let the user treat it like an
- // ordinary bam file.
- object = bam_file.read_object();
- }
-
- while (object != nullptr || !bam_file.is_eof()) {
- if (object != nullptr) {
- ReferenceCount *ref_ptr = object->as_reference_count();
- if (ref_ptr != nullptr) {
- ref_ptr->ref();
- }
- objects.push_back(object);
- }
- object = bam_file.read_object();
- }
- bam_file.resolve();
- bam_file.close();
-
- _data->set_coordinate_system(_coordinate_system);
-
- if (objects.size() == 1 &&
- objects[0]->is_of_type(PandaNode::get_class_type())) {
- PandaNode *node = DCAST(PandaNode, objects[0]);
- save_egg_data(_data, node);
-
- } else {
- nout << "File does not contain a scene graph.\n";
- exit(1);
- }
-
- write_egg_file();
-}
-
-int main(int argc, char *argv[]) {
- BamToEgg prog;
- prog.parse_command_line(argc, argv);
- prog.run();
- return 0;
-}
diff --git a/pandatool/src/bam/bamToEgg.h b/pandatool/src/bam/bamToEgg.h
deleted file mode 100644
index f5a29c3f..00000000
--- a/pandatool/src/bam/bamToEgg.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file bamToEgg.h
- * @author drose
- * @date 2001-06-25
- */
-
-#ifndef BAMTOEGG_H
-#define BAMTOEGG_H
-
-#include "pandatoolbase.h"
-
-#include "somethingToEgg.h"
-
-/**
- * This program reads a bam file, for instance as written out from a real-time
- * interaction session, and generates a corresponding egg file.
- */
-class BamToEgg : public SomethingToEgg {
-public:
- BamToEgg();
-
- void run();
-
-private:
-};
-
-#endif
diff --git a/pandatool/src/bam/eggToBam.cxx b/pandatool/src/bam/eggToBam.cxx
deleted file mode 100644
index a7e760d2..00000000
--- a/pandatool/src/bam/eggToBam.cxx
+++ /dev/null
@@ -1,491 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggToBam.cxx
- * @author drose
- * @date 2000-06-28
- */
-
-#include "eggToBam.h"
-
-#include "config_putil.h"
-#include "bamFile.h"
-#include "load_egg_file.h"
-#include "config_egg2pg.h"
-#include "config_gobj.h"
-#include "config_chan.h"
-#include "pandaNode.h"
-#include "geomNode.h"
-#include "renderState.h"
-#include "textureAttrib.h"
-#include "dcast.h"
-#include "graphicsPipeSelection.h"
-#include "graphicsEngine.h"
-#include "graphicsBuffer.h"
-#include "graphicsStateGuardian.h"
-#include "load_prc_file.h"
-#include "windowProperties.h"
-#include "frameBufferProperties.h"
-
-/**
- *
- */
-EggToBam::
-EggToBam() :
- EggToSomething("Bam", ".bam", true, false)
-{
- set_program_brief("convert .egg files to .bam files");
- set_program_description
- ("This program reads Egg files and outputs Bam files, the binary format "
- "suitable for direct loading of animation and models into Panda. Bam "
- "files are tied to a particular version of Panda, so should not be "
- "considered replacements for egg files, but they tend to be smaller and "
- "load much faster than the equivalent egg files.");
-
- // -f is always in effect for egg2bam. It doesn't make sense to provide it
- // as an option to the user.
- remove_option("f");
-
- add_path_replace_options();
- add_path_store_options();
-
- add_option
- ("flatten", "flag", 0,
- "Specifies whether to flatten the egg hierarchy after it is loaded. "
- "If flag is zero, the egg hierarchy will not be flattened, but will "
- "instead be written to the bam file exactly as it is. If flag is "
- "non-zero, the hierarchy will be flattened so that unnecessary nodes "
- "(usually group nodes with only one child) are eliminated. The default "
- "if this is not specified is taken from the egg-flatten Config.prc "
- "variable.",
- &EggToBam::dispatch_int, &_has_egg_flatten, &_egg_flatten);
-
- add_option
- ("combine-geoms", "flag", 0,
- "Specifies whether to combine sibling GeomNodes into a common GeomNode "
- "when possible. This flag is only respected if flatten, above, is also "
- "enabled (or implicitly true from the Config.prc file). The default if "
- "this is not specified is taken from the egg-combine-geoms Config.prc "
- "variable.",
- &EggToBam::dispatch_int, &_has_egg_combine_geoms, &_egg_combine_geoms);
-
- add_option
- ("suppress-hidden", "flag", 0,
- "Specifies whether to suppress hidden geometry. If this is nonzero, "
- "egg geometry tagged as \"hidden\" will be removed from the final "
- "scene graph; otherwise, it will be preserved (but stashed). The "
- "default is nonzero, to remove it.",
- &EggToBam::dispatch_int, nullptr, &_egg_suppress_hidden);
-
- add_option
- ("ls", "", 0,
- "Writes a scene graph listing to standard output after the egg "
- "file has been loaded, showing the nodes that will be written out.",
- &EggToBam::dispatch_none, &_ls);
-
- add_option
- ("C", "quality", 0,
- "Specify the quality level for lossy channel compression. If this "
- "is specified, the animation channels will be compressed at this "
- "quality level, which is normally an integer value between 0 and 100, "
- "inclusive, where higher numbers produce larger files with greater "
- "quality. Generally, 95 is the highest useful quality level. Use "
- "-NC (described below) to disable channel compression. If neither "
- "option is specified, the default comes from the Config.prc file.",
- &EggToBam::dispatch_int, &_has_compression_quality, &_compression_quality);
-
- add_option
- ("NC", "", 0,
- "Turn off lossy compression of animation channels. Channels will be "
- "written exactly as they are, losslessly.",
- &EggToBam::dispatch_none, &_compression_off);
-
- add_option
- ("rawtex", "", 0,
- "Record texture data directly in the bam file, instead of storing "
- "a reference to the texture elsewhere on disk. The textures are "
- "stored uncompressed, unless -ctex is also specified. "
- "A particular texture that is encoded into "
- "multiple different bam files in this way cannot be unified into "
- "the same part of texture memory if the different bam files are loaded "
- "together. That being said, this can sometimes be a convenient "
- "way to ensure the bam file is completely self-contained.",
- &EggToBam::dispatch_none, &_tex_rawdata);
-
- add_option
- ("txo", "", 0,
- "Rather than writing texture data directly into the bam file, as in "
- "-rawtex, create a texture object for each referenced texture. A "
- "texture object is a kind of mini-bam file, with a .txo extension, "
- "that contains all of the data needed to recreate a texture, including "
- "its image contents, filter and wrap settings, and so on. 3-D textures "
- "and cube maps can also be represented in a single .txo file. Texture "
- "object files, like bam files, are tied to a particular version of "
- "Panda.",
- &EggToBam::dispatch_none, &_tex_txo);
-
-#ifdef HAVE_ZLIB
- add_option
- ("txopz", "", 0,
- "In addition to writing texture object files as above, compress each "
- "one using pzip to a .txo.pz file. In many cases, this will yield a "
- "disk file size comparable to that achieved by png compression. This "
- "is an on-disk compression only, and does not affect the amount of "
- "RAM or texture memory consumed by the texture when it is loaded.",
- &EggToBam::dispatch_none, &_tex_txopz);
-#endif // HAVE_ZLIB
-
- add_option
- ("ctex", "", 0,
-#ifdef HAVE_SQUISH
- "Pre-compress the texture images using the libsquish library, when "
- "using -rawtex or -txo. "
-#else
- "Asks the graphics card to pre-compress the texture images when using "
- "-rawtex or -txo. "
-#endif // HAVE_SQUISH
-#ifdef HAVE_ZLIB
- "This is unrelated to the on-disk compression achieved "
- "via -txopz (and it may be used in conjunction with that parameter). "
-#endif // HAVE_ZLIB
- "This will result in a smaller RAM and texture memory footprint for "
- "the texture images. The same "
- "effect can be achieved at load time by setting compressed-textures in "
- "your Config.prc file; but -ctex pre-compresses the "
- "textures so that they do not need to be compressed at load time. "
-#ifndef HAVE_SQUISH
- "Note that, since your Panda is not compiled with the libsquish "
- "library, using -ctex will make .txo files that are only guaranteed "
- "to load on the particular graphics card that was used to "
- "generate them."
-#endif // HAVE_SQUISH
- ,
- &EggToBam::dispatch_none, &_tex_ctex);
-
- add_option
- ("mipmap", "", 0,
- "Records the pre-generated mipmap levels in the texture object file "
- "when using -rawtex or -txo, regardless of the texture filter mode. This "
- "will increase the size of the texture object file by about 33%, but "
- "it prevents the need to compute the mipmaps at runtime. The default "
- "is to record mipmap levels only when the texture uses a mipmap "
- "filter mode.",
- &EggToBam::dispatch_none, &_tex_mipmap);
-
- add_option
- ("ctexq", "quality", 0,
- "Specifies the compression quality to use when performing the "
- "texture compression requested by -ctex. This may be one of "
- "'default', 'fastest', 'normal', or 'best'. The default is 'best'. "
- "Set it to 'default' to use whatever is specified by the Config.prc "
- "file. This is a global setting only; individual texture quality "
- "settings appearing within the egg file will override this.",
- &EggToBam::dispatch_string, nullptr, &_ctex_quality);
-
- add_option
- ("load-display", "display name", 0,
- "Specifies the particular display module to load to perform the texture "
- "compression requested by -ctex. If this is omitted, the default is "
- "taken from the Config.prc file."
-#ifdef HAVE_SQUISH
- " Since your Panda has libsquish compiled in, this is not necessary; "
- "Panda can compress textures without loading a display module."
-#endif // HAVE_SQUISH
- ,
- &EggToBam::dispatch_string, nullptr, &_load_display);
-
- redescribe_option
- ("cs",
- "Specify the coordinate system of the resulting " + _format_name +
- " file. This may be "
- "one of 'y-up', 'z-up', 'y-up-left', or 'z-up-left'. The default "
- "is z-up.");
-
- _force_complete = true;
- _egg_flatten = 0;
- _egg_combine_geoms = 0;
- _egg_suppress_hidden = 1;
- _tex_txopz = false;
- _ctex_quality = "best";
-}
-
-/**
- *
- */
-void EggToBam::
-run() {
- if (_has_egg_flatten) {
- // If the user specified some -flatten, we need to set the corresponding
- // Config.prc variable.
- egg_flatten = (_egg_flatten != 0);
- }
- if (_has_egg_combine_geoms) {
- // Ditto with -combine_geoms.
- egg_combine_geoms = (_egg_combine_geoms != 0);
- }
-
- // We always set egg_suppress_hidden.
- egg_suppress_hidden = _egg_suppress_hidden;
-
- if (_compression_off) {
- // If the user specified -NC, turn off channel compression.
- compress_channels = false;
-
- } else if (_has_compression_quality) {
- // Otherwise, if the user specified a compression quality with -C, use
- // that quality level.
- compress_channels = true;
- compress_chan_quality = _compression_quality;
- }
-
- if (_ctex_quality != "default") {
- // Override the user's config file with the command-line parameter for
- // texture compression.
- std::string prc = "texture-quality-level " + _ctex_quality;
- load_prc_file_data("prc", prc);
- }
-
- if (!_got_coordinate_system) {
- // If the user didn't specify otherwise, ensure the coordinate system is
- // Z-up.
- _data->set_coordinate_system(CS_zup_right);
- }
-
- PT(PandaNode) root = load_egg_data(_data);
- if (root == nullptr) {
- nout << "Unable to build scene graph from egg file.\n";
- exit(1);
- }
-
- if (_tex_ctex) {
-#ifndef HAVE_SQUISH
- if (!make_buffer()) {
- nout << "Unable to initialize graphics context; cannot compress textures.\n";
- exit(1);
- }
-#endif // HAVE_SQUISH
- }
-
- if (_tex_txo || _tex_txopz || (_tex_ctex && _tex_rawdata)) {
- collect_textures(root);
- Textures::iterator ti;
- for (ti = _textures.begin(); ti != _textures.end(); ++ti) {
- Texture *tex = (*ti);
- tex->get_ram_image();
- bool want_mipmaps = (_tex_mipmap || tex->uses_mipmaps());
- if (want_mipmaps) {
- // Generate mipmap levels.
- tex->generate_ram_mipmap_images();
- }
-
- if (_tex_ctex) {
-#ifdef HAVE_SQUISH
- if (!tex->compress_ram_image()) {
- nout << " couldn't compress " << tex->get_name() << "\n";
- }
- tex->set_compression(Texture::CM_on);
-#else // HAVE_SQUISH
- tex->set_keep_ram_image(true);
- bool has_mipmap_levels = (tex->get_num_ram_mipmap_images() > 1);
- if (!_engine->extract_texture_data(tex, _gsg)) {
- nout << " couldn't compress " << tex->get_name() << "\n";
- }
- if (!has_mipmap_levels && !want_mipmaps) {
- // Make sure we didn't accidentally introduce mipmap levels by
- // rendezvousing through the graphics card.
- tex->clear_ram_mipmap_images();
- }
- tex->set_keep_ram_image(false);
-#endif // HAVE_SQUISH
- }
-
- if (_tex_txo || _tex_txopz) {
- convert_txo(tex);
- }
- }
- }
-
- if (_ls) {
- root->ls(nout, 0);
- }
-
- // This should be guaranteed because we pass false to the constructor,
- // above.
- nassertv(has_output_filename());
-
- Filename filename = get_output_filename();
- filename.make_dir();
- nout << "Writing " << filename << "\n";
- BamFile bam_file;
- if (!bam_file.open_write(filename)) {
- nout << "Error in writing.\n";
- exit(1);
- }
-
- if (!bam_file.write_object(root)) {
- nout << "Error in writing.\n";
- exit(1);
- }
-}
-
-/**
- * Does something with the additional arguments on the command line (after all
- * the -options have been parsed). Returns true if the arguments are good,
- * false otherwise.
- */
-bool EggToBam::
-handle_args(ProgramBase::Args &args) {
- // If the user specified a path store option, we need to set the bam-
- // texture-mode Config.prc variable directly to support this (otherwise the
- // bam code will do what it wants to do anyway).
- if (_tex_rawdata) {
- bam_texture_mode = BamFile::BTM_rawdata;
-
- } else if (_got_path_store) {
- bam_texture_mode = BamFile::BTM_unchanged;
-
- } else {
- // Otherwise, the default path store is absolute; then the bam-texture-
- // mode can do the appropriate thing to it.
- _path_replace->_path_store = PS_absolute;
- }
-
- return EggToSomething::handle_args(args);
-}
-
-/**
- * Recursively walks the scene graph, looking for Texture references.
- */
-void EggToBam::
-collect_textures(PandaNode *node) {
- collect_textures(node->get_state());
- if (node->is_geom_node()) {
- GeomNode *geom_node = DCAST(GeomNode, node);
- int num_geoms = geom_node->get_num_geoms();
- for (int i = 0; i < num_geoms; ++i) {
- collect_textures(geom_node->get_geom_state(i));
- }
- }
-
- PandaNode::Children children = node->get_children();
- int num_children = children.get_num_children();
- for (int i = 0; i < num_children; ++i) {
- collect_textures(children.get_child(i));
- }
-}
-
-/**
- * Recursively walks the scene graph, looking for Texture references.
- */
-void EggToBam::
-collect_textures(const RenderState *state) {
- const TextureAttrib *tex_attrib = DCAST(TextureAttrib, state->get_attrib(TextureAttrib::get_class_type()));
- if (tex_attrib != nullptr) {
- int num_on_stages = tex_attrib->get_num_on_stages();
- for (int i = 0; i < num_on_stages; ++i) {
- _textures.insert(tex_attrib->get_on_texture(tex_attrib->get_on_stage(i)));
- }
- }
-}
-
-/**
- * If the indicated Texture was not already loaded from a txo file, writes it
- * to a txo file and updates the Texture object to reference the new file.
- */
-void EggToBam::
-convert_txo(Texture *tex) {
- if (!tex->get_loaded_from_txo()) {
- Filename fullpath = tex->get_fullpath().get_filename_index(0);
- if (_tex_txopz) {
- fullpath.set_extension("txo.pz");
- // We use this clumsy syntax so that the new extension appears to be two
- // separate extensions, .txo followed by .pz, which is what
- // Texture::write() expects to find.
- fullpath = Filename(fullpath.get_fullpath());
- } else {
- fullpath.set_extension("txo");
- }
-
- if (tex->write(fullpath)) {
- nout << " Writing " << fullpath;
- if (tex->get_ram_image_compression() != Texture::CM_off) {
- nout << " (compressed " << tex->get_ram_image_compression() << ")";
- }
- nout << "\n";
- tex->set_loaded_from_txo();
- tex->set_fullpath(fullpath);
- tex->clear_alpha_fullpath();
-
- Filename filename = tex->get_filename().get_filename_index(0);
- if (_tex_txopz) {
- filename.set_extension("txo.pz");
- filename = Filename(filename.get_fullpath());
- } else {
- filename.set_extension("txo");
- }
-
- tex->set_filename(filename);
- tex->clear_alpha_filename();
- }
- }
-}
-
-/**
- * Creates a GraphicsBuffer for communicating with the graphics card.
- */
-bool EggToBam::
-make_buffer() {
- if (!_load_display.empty()) {
- // Override the user's config file with the command-line parameter.
- std::string prc = "load-display " + _load_display;
- load_prc_file_data("prc", prc);
- }
-
- GraphicsPipeSelection *selection = GraphicsPipeSelection::get_global_ptr();
- _pipe = selection->make_default_pipe();
- if (_pipe == nullptr) {
- nout << "Unable to create graphics pipe.\n";
- return false;
- }
-
- _engine = new GraphicsEngine;
-
- FrameBufferProperties fbprops = FrameBufferProperties::get_default();
-
- // Some graphics drivers can only create single-buffered offscreen buffers.
- // So request that.
- fbprops.set_back_buffers(0);
-
- WindowProperties winprops;
- winprops.set_size(1, 1);
- winprops.set_origin(0, 0);
- winprops.set_undecorated(true);
- winprops.set_open(true);
- winprops.set_z_order(WindowProperties::Z_bottom);
-
- // We don't care how big the buffer is; we just need it to manifest the GSG.
- _buffer = _engine->make_output(_pipe, "buffer", 0,
- fbprops, winprops,
- GraphicsPipe::BF_fb_props_optional);
- _engine->open_windows();
- if (_buffer == nullptr || !_buffer->is_valid()) {
- nout << "Unable to create graphics window.\n";
- return false;
- }
- _gsg = _buffer->get_gsg();
-
- return true;
-}
-
-
-int main(int argc, char *argv[]) {
- EggToBam prog;
- prog.parse_command_line(argc, argv);
- prog.run();
- return 0;
-}
diff --git a/pandatool/src/bam/eggToBam.h b/pandatool/src/bam/eggToBam.h
deleted file mode 100644
index 1ab262a5..00000000
--- a/pandatool/src/bam/eggToBam.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggToBam.h
- * @author drose
- * @date 2000-06-28
- */
-
-#ifndef EGGTOBAM_H
-#define EGGTOBAM_H
-
-#include "pandatoolbase.h"
-
-#include "eggToSomething.h"
-#include "pset.h"
-#include "graphicsPipe.h"
-
-class PandaNode;
-class RenderState;
-class Texture;
-class GraphicsEngine;
-class GraphicsStateGuardian;
-class GraphicsOutput;
-
-/**
- *
- */
-class EggToBam : public EggToSomething {
-public:
- EggToBam();
-
- void run();
-
-protected:
- virtual bool handle_args(Args &args);
-
-private:
- void collect_textures(PandaNode *node);
- void collect_textures(const RenderState *state);
- void convert_txo(Texture *tex);
-
- bool make_buffer();
-
-private:
- typedef pset Textures;
- Textures _textures;
-
- bool _has_egg_flatten;
- int _egg_flatten;
- bool _has_egg_combine_geoms;
- int _egg_combine_geoms;
- bool _egg_suppress_hidden;
- bool _ls;
- bool _has_compression_quality;
- int _compression_quality;
- bool _compression_off;
- bool _tex_rawdata;
- bool _tex_txo;
- bool _tex_txopz;
- bool _tex_ctex;
- bool _tex_mipmap;
- std::string _ctex_quality;
- std::string _load_display;
-
- // The rest of this is required to support -ctex.
- PT(GraphicsPipe) _pipe;
- GraphicsStateGuardian *_gsg;
- GraphicsEngine *_engine;
- GraphicsOutput *_buffer;
-};
-
-#endif
diff --git a/pandatool/src/bam/ptsToBam.cxx b/pandatool/src/bam/ptsToBam.cxx
deleted file mode 100644
index 0059df86..00000000
--- a/pandatool/src/bam/ptsToBam.cxx
+++ /dev/null
@@ -1,238 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file ptsToBam.cxx
- * @author drose
- * @date 2000-06-28
- */
-
-#include "ptsToBam.h"
-
-#include "config_putil.h"
-#include "geomPoints.h"
-#include "bamFile.h"
-#include "pandaNode.h"
-#include "geomNode.h"
-#include "dcast.h"
-#include "string_utils.h"
-#include "config_egg2pg.h"
-
-using std::string;
-
-/**
- *
- */
-PtsToBam::
-PtsToBam() : WithOutputFile(true, false, true)
-{
- set_program_brief("convert point cloud data into a .bam file");
- set_program_description
- ("This program reads a point clound in a pts file and outputs a bam files, "
- "suitable for viewing in Panda.");
-
- clear_runlines();
- add_runline("[opts] input.pts output.bam");
- add_runline("[opts] -o output.bam input.pts");
-
- add_option
- ("o", "filename", 0,
- "Specify the filename to which the resulting .bam file will be written. "
- "If this option is omitted, the last parameter name is taken to be the "
- "name of the output file.",
- &PtsToBam::dispatch_filename, &_got_output_filename, &_output_filename);
-
- add_option
- ("d", "divisor", 0,
- "Decimates the point cloud by the indicated divisor. The number of points\n"
- "added is 1/divisor; numbers larger than 1.0 mean correspondingly fewer\n"
- "points.",
- &PtsToBam::dispatch_double, nullptr, &_decimate_divisor);
-
- _decimate_divisor = 1.0;
-}
-
-/**
- *
- */
-void PtsToBam::
-run() {
- pifstream pts;
- _pts_filename.set_text();
- if (!_pts_filename.open_read(pts)) {
- nout << "Cannot open " << _pts_filename << "\n";
- exit(1);
- }
-
- _gnode = new GeomNode(_pts_filename.get_basename());
-
- _num_points_expected = 0;
- _num_points_found = 0;
- _num_points_added = 0;
- _decimate_factor = 1.0 / std::max(1.0, _decimate_divisor);
- _line_number = 0;
- _point_number = 0;
- _decimated_point_number = 0.0;
- _num_vdatas = 0;
- string line;
- while (std::getline(pts, line)) {
- process_line(line);
- }
- close_vertex_data();
-
- nout << "\nFound " << _num_points_found << " points of " << _num_points_expected << " expected.\n";
- nout << "Generated " << _num_points_added << " points to bam file.\n";
-
- // This should be guaranteed because we pass false to the constructor,
- // above.
- nassertv(has_output_filename());
-
- Filename filename = get_output_filename();
- filename.make_dir();
- nout << "Writing " << filename << "\n";
- BamFile bam_file;
- if (!bam_file.open_write(filename)) {
- nout << "Error in writing.\n";
- exit(1);
- }
-
- if (!bam_file.write_object(_gnode.p())) {
- nout << "Error in writing.\n";
- exit(1);
- }
-}
-
-/**
- *
- */
-bool PtsToBam::
-handle_args(ProgramBase::Args &args) {
- if (args.empty()) {
- nout << "You must specify the pts file to read on the command line.\n";
- return false;
- }
-
- if (args.size() > 1) {
- nout << "Specify only one pts on the command line.\n";
- return false;
- }
-
- _pts_filename = Filename::from_os_specific(args[0]);
-
- return true;
-}
-
-/**
- * Reads a single line from the pts file.
- */
-void PtsToBam::
-process_line(const string &line) {
- _line_number++;
-
- if (_line_number % 1000000 == 0) {
- std::cerr << "." << std::flush;
- }
-
- if (line.empty() || !isdigit(line[0])) {
- return;
- }
-
- if (_line_number == 1) {
- // The first line might be just the number of points.
- vector_string words;
- tokenize(trim(line), words, " \t", true);
- if (words.size() == 1) {
- string tail;
- _num_points_expected = string_to_int(words[0], tail);
- nout << "Expecting " << _num_points_expected << " points, will generate "
- << (int)(_num_points_expected * _decimate_factor) << "\n";
- return;
- }
- }
-
- // Here we might have a point.
- _num_points_found++;
- _decimated_point_number += _decimate_factor;
- int point_number = int(_decimated_point_number);
- if (point_number > _point_number) {
- _point_number = point_number;
-
- vector_string words;
- tokenize(trim(line), words, " \t", true);
- if (words.size() >= 3) {
- add_point(words);
- }
- }
-}
-
-/**
- * Adds a point from the pts file.
- */
-void PtsToBam::
-add_point(const vector_string &words) {
- if (_data == nullptr || _data->get_num_rows() >= egg_max_vertices) {
- open_vertex_data();
- }
-
- string tail;
- double x, y, z;
- x = string_to_double(words[0], tail);
- y = string_to_double(words[1], tail);
- z = string_to_double(words[2], tail);
- _vertex.add_data3d(x, y, z);
- _num_points_added++;
-}
-
-/**
- * Creates a new GeomVertexData.
- */
-void PtsToBam::
-open_vertex_data() {
- if (_data != nullptr) {
- close_vertex_data();
- }
- CPT(GeomVertexFormat) format = GeomVertexFormat::get_v3();
- _data = new GeomVertexData("pts", format, GeomEnums::UH_static);
- _vertex = GeomVertexWriter(_data, "vertex");
-}
-
-/**
- * Closes a previous GeomVertexData and adds it to the scene graph.
- */
-void PtsToBam::
-close_vertex_data() {
- if (_data == nullptr) {
- return;
- }
-
- _num_vdatas++;
- nout << "\nGenerating " << _num_points_added << " points in " << _num_vdatas << " GeomVertexDatas\n";
-
- PT(Geom) geom = new Geom(_data);
-
- int num_vertices = _data->get_num_rows();
- int vertices_so_far = 0;
- while (num_vertices > 0) {
- int this_num_vertices = std::min(num_vertices, (int)egg_max_indices);
- PT(GeomPrimitive) points = new GeomPoints(GeomEnums::UH_static);
- points->add_consecutive_vertices(vertices_so_far, this_num_vertices);
- geom->add_primitive(points);
- vertices_so_far += this_num_vertices;
- num_vertices -= this_num_vertices;
- }
-
- _gnode->add_geom(geom);
-
- _data = nullptr;
-}
-
-int main(int argc, char *argv[]) {
- PtsToBam prog;
- prog.parse_command_line(argc, argv);
- prog.run();
- return 0;
-}
diff --git a/pandatool/src/bam/ptsToBam.h b/pandatool/src/bam/ptsToBam.h
deleted file mode 100644
index 20fa76e7..00000000
--- a/pandatool/src/bam/ptsToBam.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file ptsToBam.h
- * @author drose
- * @date 2000-06-28
- */
-
-#ifndef PTSTOBAM_H
-#define PTSTOBAM_H
-
-#include "pandatoolbase.h"
-
-#include "programBase.h"
-#include "withOutputFile.h"
-#include "filename.h"
-#include "vector_string.h"
-#include "geomVertexData.h"
-#include "geomVertexWriter.h"
-#include "geomNode.h"
-
-/**
- *
- */
-class PtsToBam : public ProgramBase, public WithOutputFile {
-public:
- PtsToBam();
-
- void run();
-
-protected:
- virtual bool handle_args(Args &args);
-
-private:
- void process_line(const std::string &line);
- void add_point(const vector_string &words);
-
- void open_vertex_data();
- void close_vertex_data();
-
-private:
- Filename _pts_filename;
- double _decimate_divisor;
- double _decimate_factor;
-
- int _line_number;
- int _point_number;
- int _num_points_expected;
- int _num_points_found;
- int _num_points_added;
- int _num_vdatas;
-
- double _decimated_point_number;
- PT(GeomNode) _gnode;
- PT(GeomVertexData) _data;
- GeomVertexWriter _vertex;
-};
-
-#endif
diff --git a/pandatool/src/converter/CMakeLists.txt b/pandatool/src/converter/CMakeLists.txt
deleted file mode 100644
index a793b718..00000000
--- a/pandatool/src/converter/CMakeLists.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-if(NOT HAVE_EGG)
- return()
-endif()
-
-set(P3CONVERTER_HEADERS
- somethingToEggConverter.h somethingToEggConverter.I
- eggToSomethingConverter.h eggToSomethingConverter.I
-)
-
-set(P3CONVERTER_SOURCES
- somethingToEggConverter.cxx eggToSomethingConverter.cxx
-)
-
-add_library(p3converter STATIC ${P3CONVERTER_HEADERS} ${P3CONVERTER_SOURCES})
-target_link_libraries(p3converter p3pandatoolbase pandaegg)
-
-install(TARGETS p3converter
- EXPORT ToolsDevel COMPONENT ToolsDevel
- DESTINATION ${CMAKE_INSTALL_LIBDIR}
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
- INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/panda3d
- ARCHIVE COMPONENT ToolsDevel)
-install(FILES ${P3CONVERTER_HEADERS} COMPONENT ToolsDevel DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/panda3d)
diff --git a/pandatool/src/converter/eggToSomethingConverter.I b/pandatool/src/converter/eggToSomethingConverter.I
deleted file mode 100644
index 54320824..00000000
--- a/pandatool/src/converter/eggToSomethingConverter.I
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggToSomethingConverter.I
- * @author drose
- * @date 2012-09-26
- */
-
-/**
- * Resets the error flag to the no-error state. had_error() will return false
- * until a new error is generated.
- */
-INLINE void EggToSomethingConverter::
-clear_error() {
- _error = false;
-}
-
-/**
- * Returns true if an error was detected during the conversion process, false
- * otherwise.
- */
-INLINE bool EggToSomethingConverter::
-had_error() const {
- return _error;
-}
-
-/**
- * Sets the EggData to NULL and makes the converter invalid.
- */
-INLINE void EggToSomethingConverter::
-clear_egg_data() {
- set_egg_data(nullptr);
-}
-
-/**
- * Returns the EggData structure.
- */
-INLINE EggData *EggToSomethingConverter::
-get_egg_data() {
- return _egg_data;
-}
-
-/**
- * Specifies the units that the EggData has already been scaled to. This is
- * informational only; if the target file format supports it, this information
- * will be written to the header.
- */
-void EggToSomethingConverter::
-set_output_units(DistanceUnit output_units) {
- _output_units = output_units;
-}
-
-/**
- * Returns the value supplied to set_output_units().
- */
-DistanceUnit EggToSomethingConverter::
-get_output_units() const {
- return _output_units;
-}
diff --git a/pandatool/src/converter/eggToSomethingConverter.cxx b/pandatool/src/converter/eggToSomethingConverter.cxx
deleted file mode 100644
index 0f357883..00000000
--- a/pandatool/src/converter/eggToSomethingConverter.cxx
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggToSomethingConverter.cxx
- * @author drose
- * @date 2001-04-26
- */
-
-#include "eggToSomethingConverter.h"
-
-#include "eggData.h"
-
-/**
- *
- */
-EggToSomethingConverter::
-EggToSomethingConverter() {
- _egg_data = nullptr;
- _error = false;
-}
-
-/**
- *
- */
-EggToSomethingConverter::
-EggToSomethingConverter(const EggToSomethingConverter ©) {
- _egg_data = nullptr;
- _error = false;
-}
-
-/**
- *
- */
-EggToSomethingConverter::
-~EggToSomethingConverter() {
- clear_egg_data();
-}
-
-/**
- * Sets the egg data that will be filled in when convert_file() is called.
- * This must be called before convert_file().
- */
-void EggToSomethingConverter::
-set_egg_data(EggData *egg_data) {
- _egg_data = egg_data;
-}
-
-/**
- * Returns a space-separated list of extension, in addition to the one
- * returned by get_extension(), that are recognized by this converter.
- */
-std::string EggToSomethingConverter::
-get_additional_extensions() const {
- return std::string();
-}
-
-/**
- * Returns true if this file type can transparently save compressed files
- * (with a .pz extension), false otherwise.
- */
-bool EggToSomethingConverter::
-supports_compressed() const {
- return false;
-}
diff --git a/pandatool/src/converter/eggToSomethingConverter.h b/pandatool/src/converter/eggToSomethingConverter.h
deleted file mode 100644
index 0e95958c..00000000
--- a/pandatool/src/converter/eggToSomethingConverter.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggToSomethingConverter.h
- * @author drose
- * @date 2012-09-26
- */
-
-#ifndef EGGTOSOMETHINGCONVERTER_H
-#define EGGTOSOMETHINGCONVERTER_H
-
-#include "pandatoolbase.h"
-
-#include "filename.h"
-#include "pointerTo.h"
-#include "distanceUnit.h"
-#include "coordinateSystem.h"
-
-class EggData;
-class EggGroupNode;
-
-/**
- * This is a base class for a family of converter classes that manage a
- * conversion from egg format to some other file type.
- *
- * Classes of this type can be used to implement egg2xxx converter programs,
- * as well as LoaderFileTypeXXX run-time savers.
- */
-class EggToSomethingConverter {
-public:
- EggToSomethingConverter();
- EggToSomethingConverter(const EggToSomethingConverter ©);
- virtual ~EggToSomethingConverter();
-
- virtual EggToSomethingConverter *make_copy()=0;
-
- INLINE void clear_error();
- INLINE bool had_error() const;
-
- void set_egg_data(EggData *egg_data);
- INLINE void clear_egg_data();
- INLINE EggData *get_egg_data();
-
- INLINE void set_output_units(DistanceUnit output_units);
- INLINE DistanceUnit get_output_units() const;
- INLINE void set_output_coordinate_system(CoordinateSystem output_coordinate_system) const;
- INLINE CoordinateSystem get_output_coordinate_system() const;
-
- virtual std::string get_name() const=0;
- virtual std::string get_extension() const=0;
- virtual std::string get_additional_extensions() const;
- virtual bool supports_compressed() const;
-
- virtual bool write_file(const Filename &filename)=0;
-
-protected:
- PT(EggData) _egg_data;
- DistanceUnit _output_units;
- CoordinateSystem _output_coordinate_system;
-
- bool _error;
-};
-
-#include "eggToSomethingConverter.I"
-
-#endif
diff --git a/pandatool/src/converter/somethingToEggConverter.I b/pandatool/src/converter/somethingToEggConverter.I
deleted file mode 100644
index b3fed0cb..00000000
--- a/pandatool/src/converter/somethingToEggConverter.I
+++ /dev/null
@@ -1,391 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file somethingToEggConverter.I
- * @author drose
- * @date 2001-04-26
- */
-
-/**
- * Resets the error flag to the no-error state. had_error() will return false
- * until a new error is generated.
- */
-INLINE void SomethingToEggConverter::
-clear_error() {
- _error = false;
-}
-
-/**
- * Returns true if an error was detected during the conversion process (unless
- * _allow_errors is true), false otherwise.
- */
-INLINE bool SomethingToEggConverter::
-had_error() const {
- return !_allow_errors && (_error || _path_replace->had_error());
-}
-
-/**
- * Replaces the PathReplace object (which specifies how to mangle paths from
- * the source to the destination egg file) with a new one.
- */
-INLINE void SomethingToEggConverter::
-set_path_replace(PathReplace *path_replace) {
- _path_replace = path_replace;
-}
-
-/**
- * Returns a pointer to the PathReplace object associated with this converter.
- * If the converter is non-const, this returns a non-const pointer, which can
- * be adjusted.
- */
-INLINE PathReplace *SomethingToEggConverter::
-get_path_replace() {
- return _path_replace;
-}
-
-/**
- * Returns a pointer to the PathReplace object associated with this converter.
- * If the converter is non-const, this returns a non-const pointer, which can
- * be adjusted.
- */
-INLINE const PathReplace *SomethingToEggConverter::
-get_path_replace() const {
- return _path_replace;
-}
-
-/**
- * Specifies how source animation will be converted into egg structures. The
- * default is AC_none, which means animation tables will be ignored. This is
- * only meaningful for converters that understand animation.
- */
-INLINE void SomethingToEggConverter::
-set_animation_convert(AnimationConvert animation_convert) {
- _animation_convert = animation_convert;
-}
-
-/**
- * Returns how source animation will be converted into egg structures.
- */
-INLINE AnimationConvert SomethingToEggConverter::
-get_animation_convert() const {
- return _animation_convert;
-}
-
-/**
- * Specifies the name of the character generated. This name should match
- * between all the model and channel egg files for a particular character and
- * its associated animations.
- */
-INLINE void SomethingToEggConverter::
-set_character_name(const std::string &character_name) {
- _character_name = character_name;
-}
-
-/**
- * Returns the name of the character generated. See set_character_name().
- */
-INLINE const std::string &SomethingToEggConverter::
-get_character_name() const {
- return _character_name;
-}
-
-/**
- * Specifies the starting frame of the animation to convert, in the units
- * specified by set_input_frame_rate(). If this is unspecified, the starting
- * frame is taken from the source, for instance from the first frame of the
- * animation slider.
- */
-INLINE void SomethingToEggConverter::
-set_start_frame(double start_frame) {
- _start_frame = start_frame;
- _control_flags |= CF_start_frame;
-}
-
-/**
- * Returns true if the starting frame has been explicitly specified via
- * set_start_frame(), or false if the starting frame should be implicit based
- * on the source.
- */
-INLINE bool SomethingToEggConverter::
-has_start_frame() const {
- return (_control_flags & CF_start_frame) != 0;
-}
-
-/**
- * Returns the value set by a previous call to set_start_frame(). It is an
- * error to call this if has_start_frame() returns false.
- */
-INLINE double SomethingToEggConverter::
-get_start_frame() const {
- nassertr(has_start_frame(), 0.0);
- return _start_frame;
-}
-
-/**
- * Removes the value previously set by set_start_frame().
- */
-INLINE void SomethingToEggConverter::
-clear_start_frame() {
- _start_frame = 0.0;
- _control_flags &= ~CF_start_frame;
-}
-
-/**
- * Specifies the ending frame of the animation to convert, in the units
- * specified by set_input_frame_rate(). If this is unspecified, the ending
- * frame is taken from the source, for instance from the last frame of the
- * animation slider.
- */
-INLINE void SomethingToEggConverter::
-set_end_frame(double end_frame) {
- _end_frame = end_frame;
- _control_flags |= CF_end_frame;
-}
-
-/**
- * Returns true if the ending frame has been explicitly specified via
- * set_end_frame(), or false if the ending frame should be implicit based on
- * the source.
- */
-INLINE bool SomethingToEggConverter::
-has_end_frame() const {
- return (_control_flags & CF_end_frame) != 0;
-}
-
-/**
- * Returns the value set by a previous call to set_end_frame(). It is an
- * error to call this if has_end_frame() returns false.
- */
-INLINE double SomethingToEggConverter::
-get_end_frame() const {
- nassertr(has_end_frame(), 0.0);
- return _end_frame;
-}
-
-/**
- * Removes the value previously set by set_end_frame().
- */
-INLINE void SomethingToEggConverter::
-clear_end_frame() {
- _end_frame = 0.0;
- _control_flags &= ~CF_end_frame;
-}
-
-/**
- * Specifies the increment between frames to extract. This is the amount to
- * increment the time slider (in units of internal_frame_rate) between
- * extracting each frame. If this is not specified, the default is taken from
- * the animation package, or 1.0 if the animation package does not specified a
- * frame increment.
- */
-INLINE void SomethingToEggConverter::
-set_frame_inc(double frame_inc) {
- _frame_inc = frame_inc;
- _control_flags |= CF_frame_inc;
-}
-
-/**
- * Returns true if the frame increment has been explicitly specified via
- * set_frame_inc(), or false if the ending frame should be implicit based on
- * the source.
- */
-INLINE bool SomethingToEggConverter::
-has_frame_inc() const {
- return (_control_flags & CF_frame_inc) != 0;
-}
-
-/**
- * Returns the value set by a previous call to set_frame_inc(). It is an
- * error to call this if has_frame_inc() returns false.
- */
-INLINE double SomethingToEggConverter::
-get_frame_inc() const {
- nassertr(has_frame_inc(), 0.0);
- return _frame_inc;
-}
-
-/**
- * Removes the value previously set by set_frame_inc().
- */
-INLINE void SomethingToEggConverter::
-clear_frame_inc() {
- _frame_inc = 0.0;
- _control_flags &= ~CF_frame_inc;
-}
-
-/**
- * Specifies the frame of animation to represent the neutral pose of the
- * model.
- */
-INLINE void SomethingToEggConverter::
-set_neutral_frame(double neutral_frame) {
- _neutral_frame = neutral_frame;
- _control_flags |= CF_neutral_frame;
-}
-
-/**
- * Returns true if the neutral frame has been explicitly specified via
- * set_neutral_frame(), or false otherwise.
- */
-INLINE bool SomethingToEggConverter::
-has_neutral_frame() const {
- return (_control_flags & CF_neutral_frame) != 0;
-}
-
-/**
- * Returns the value set by a previous call to set_neutral_frame(). It is an
- * error to call this if has_neutral_frame() returns false.
- */
-INLINE double SomethingToEggConverter::
-get_neutral_frame() const {
- nassertr(has_neutral_frame(), 0.0);
- return _neutral_frame;
-}
-
-/**
- * Removes the value previously set by set_neutral_frame().
- */
-INLINE void SomethingToEggConverter::
-clear_neutral_frame() {
- _neutral_frame = 0.0;
- _control_flags &= ~CF_neutral_frame;
-}
-
-/**
- * Specifies the number of frames per second that is represented by the
- * "frame" unit in the animation package. If this is omitted, it is taken
- * from whatever the file header indicates. Some animation packages do not
- * encode a frame rate, in which case the default if this is omitted is the
- * same as the output frame rate.
- */
-INLINE void SomethingToEggConverter::
-set_input_frame_rate(double input_frame_rate) {
- _input_frame_rate = input_frame_rate;
- _control_flags |= CF_input_frame_rate;
-}
-
-/**
- * Returns true if the frame rate has been explicitly specified via
- * set_input_frame_rate(), or false otherwise.
- */
-INLINE bool SomethingToEggConverter::
-has_input_frame_rate() const {
- return (_control_flags & CF_input_frame_rate) != 0;
-}
-
-/**
- * Returns the value set by a previous call to set_input_frame_rate(). It is
- * an error to call this if has_input_frame_rate() returns false.
- */
-INLINE double SomethingToEggConverter::
-get_input_frame_rate() const {
- nassertr(has_input_frame_rate(), 0.0);
- return _input_frame_rate;
-}
-
-/**
- * Removes the value previously set by set_input_frame_rate().
- */
-INLINE void SomethingToEggConverter::
-clear_input_frame_rate() {
- _input_frame_rate = 0.0;
- _control_flags &= ~CF_input_frame_rate;
-}
-
-/**
- * Specifies the number of frames per second that the resulting animation
- * should be played at. If this is omitted, it is taken to be the same as the
- * input frame rate.
- */
-INLINE void SomethingToEggConverter::
-set_output_frame_rate(double output_frame_rate) {
- _output_frame_rate = output_frame_rate;
- _control_flags |= CF_output_frame_rate;
-}
-
-/**
- * Returns true if the frame rate has been explicitly specified via
- * set_output_frame_rate(), or false otherwise.
- */
-INLINE bool SomethingToEggConverter::
-has_output_frame_rate() const {
- return (_control_flags & CF_output_frame_rate) != 0;
-}
-
-/**
- * Returns the value set by a previous call to set_output_frame_rate(). It is
- * an error to call this if has_output_frame_rate() returns false.
- */
-INLINE double SomethingToEggConverter::
-get_output_frame_rate() const {
- nassertr(has_output_frame_rate(), 0.0);
- return _output_frame_rate;
-}
-
-/**
- * Removes the value previously set by set_output_frame_rate().
- */
-INLINE void SomethingToEggConverter::
-clear_output_frame_rate() {
- _output_frame_rate = 0.0;
- _control_flags &= ~CF_output_frame_rate;
-}
-
-/**
- * Returns the default frame rate if nothing is specified for input_frame_rate
- * or output_frame_rate, and the animation package does not have an implicit
- * frame rate.
- */
-INLINE double SomethingToEggConverter::
-get_default_frame_rate() {
- return 24.0;
-}
-
-/**
- * Sets the merge_externals flag. When this is true, external references
- * within the source file are read in and merged directly; otherwise, only a
- * reference to a similarly-named egg file is inserted.
- */
-INLINE void SomethingToEggConverter::
-set_merge_externals(bool merge_externals) {
- _merge_externals = merge_externals;
-}
-
-/**
- * Returns the current state of the merge_externals flag. See
- * set_merge_externals().
- */
-INLINE bool SomethingToEggConverter::
-get_merge_externals() const {
- return _merge_externals;
-}
-
-/**
- * Sets the EggData to NULL and makes the converter invalid.
- */
-INLINE void SomethingToEggConverter::
-clear_egg_data() {
- set_egg_data(nullptr);
-}
-
-/**
- * Returns the EggData structure.
- */
-INLINE EggData *SomethingToEggConverter::
-get_egg_data() {
- return _egg_data;
-}
-
-/**
- * Converts the indicated model filename to a relative or absolute or whatever
- * filename, according to _path_replace.
- */
-INLINE Filename SomethingToEggConverter::
-convert_model_path(const Filename &orig_filename) {
- return _path_replace->convert_path(orig_filename);
-}
diff --git a/pandatool/src/converter/somethingToEggConverter.cxx b/pandatool/src/converter/somethingToEggConverter.cxx
deleted file mode 100644
index 8911021a..00000000
--- a/pandatool/src/converter/somethingToEggConverter.cxx
+++ /dev/null
@@ -1,165 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file somethingToEggConverter.cxx
- * @author drose
- * @date 2001-04-26
- */
-
-#include "somethingToEggConverter.h"
-
-#include "eggData.h"
-#include "eggExternalReference.h"
-
-/**
- *
- */
-SomethingToEggConverter::
-SomethingToEggConverter() {
- _allow_errors = false;
- _path_replace = new PathReplace;
- _path_replace->_path_store = PS_absolute;
- _animation_convert = AC_none;
- _start_frame = 0.0;
- _end_frame = 0.0;
- _frame_inc = 0.0;
- _neutral_frame = 0.0;
- _input_frame_rate = 0.0;
- _output_frame_rate = 0.0;
- _control_flags = 0;
- _merge_externals = false;
- _egg_data = nullptr;
- _error = false;
-}
-
-/**
- *
- */
-SomethingToEggConverter::
-SomethingToEggConverter(const SomethingToEggConverter ©) :
- _allow_errors(copy._allow_errors),
- _path_replace(copy._path_replace),
- _merge_externals(copy._merge_externals)
-{
- _egg_data = nullptr;
- _error = false;
-}
-
-/**
- *
- */
-SomethingToEggConverter::
-~SomethingToEggConverter() {
- clear_egg_data();
-}
-
-/**
- * Sets the egg data that will be filled in when convert_file() is called.
- * This must be called before convert_file().
- */
-void SomethingToEggConverter::
-set_egg_data(EggData *egg_data) {
- _egg_data = egg_data;
-}
-
-/**
- * Returns a space-separated list of extension, in addition to the one
- * returned by get_extension(), that are recognized by this converter.
- */
-std::string SomethingToEggConverter::
-get_additional_extensions() const {
- return std::string();
-}
-
-/**
- * Returns true if this file type can transparently load compressed files
- * (with a .pz extension), false otherwise.
- */
-bool SomethingToEggConverter::
-supports_compressed() const {
- return false;
-}
-
-/**
- * Returns true if this converter can directly convert the model type to
- * internal Panda memory structures, given the indicated options, or false
- * otherwise. If this returns true, then convert_to_node() may be called to
- * perform the conversion, which may be faster than calling convert_file() if
- * the ultimate goal is a PandaNode anyway.
- */
-bool SomethingToEggConverter::
-supports_convert_to_node(const LoaderOptions &options) const {
- return false;
-}
-
-/**
- * This may be called after convert_file() has been called and returned true,
- * indicating a successful conversion. It will return the distance units
- * represented by the converted egg file, if known, or DU_invalid if not
- * known.
- */
-DistanceUnit SomethingToEggConverter::
-get_input_units() {
- return DU_invalid;
-}
-
-/**
- * Reads the input file and directly produces a ready-to-render model file as
- * a PandaNode. Returns NULL on failure, or if it is not supported. (This
- * functionality is not supported by all converter types; see
- * supports_convert_to_node()).
- */
-PT(PandaNode) SomethingToEggConverter::
-convert_to_node(const LoaderOptions &options, const Filename &filename) {
- return nullptr;
-}
-
-/**
- * Handles an external reference in the source file. If the merge_externals
- * flag is true (see set_merge_externals()), this causes the named file to be
- * read in and converted, and the converted egg geometry is parented to
- * egg_parent. Otherwise, only a reference to a similarly named egg file is
- * parented to egg_parent.
- *
- * The parameters orig_filename and searchpath are as those passed to
- * convert_model_path().
- *
- * Returns true on success, false on failure.
- */
-bool SomethingToEggConverter::
-handle_external_reference(EggGroupNode *egg_parent,
- const Filename &ref_filename) {
- if (_merge_externals) {
- SomethingToEggConverter *ext = make_copy();
- PT(EggData) egg_data = new EggData;
- egg_data->set_coordinate_system(get_egg_data()->get_coordinate_system());
- ext->set_egg_data(egg_data);
-
- if (!ext->convert_file(ref_filename)) {
- delete ext;
- nout << "Unable to read external reference: " << ref_filename << "\n";
- _error = true;
- return false;
- }
-
- egg_parent->steal_children(*egg_data);
- delete ext;
- return true;
-
- } else {
- // If we're installing external references instead of reading them, we
- // should make it into an egg filename.
- Filename filename = ref_filename;
- filename.set_extension("egg");
-
- EggExternalReference *egg_ref = new EggExternalReference("", filename);
- egg_parent->add_child(egg_ref);
- }
-
- return true;
-}
diff --git a/pandatool/src/converter/somethingToEggConverter.h b/pandatool/src/converter/somethingToEggConverter.h
deleted file mode 100644
index 16d16df5..00000000
--- a/pandatool/src/converter/somethingToEggConverter.h
+++ /dev/null
@@ -1,148 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file somethingToEggConverter.h
- * @author drose
- * @date 2001-04-17
- */
-
-#ifndef SOMETHINGTOEGGCONVERTER_H
-#define SOMETHINGTOEGGCONVERTER_H
-
-#include "pandatoolbase.h"
-
-#include "filename.h"
-#include "config_putil.h" // for get_model_path()
-#include "animationConvert.h"
-#include "pathReplace.h"
-#include "pointerTo.h"
-#include "distanceUnit.h"
-#include "pandaNode.h"
-
-class EggData;
-class EggGroupNode;
-class LoaderOptions;
-
-/**
- * This is a base class for a family of converter classes that manage a
- * conversion from some file type to egg format.
- *
- * Classes of this type can be used to implement xxx2egg converter programs,
- * as well as LoaderFileTypeXXX run-time loaders.
- */
-class SomethingToEggConverter {
-public:
- SomethingToEggConverter();
- SomethingToEggConverter(const SomethingToEggConverter ©);
- virtual ~SomethingToEggConverter();
-
- virtual SomethingToEggConverter *make_copy()=0;
-
- INLINE void clear_error();
- INLINE bool had_error() const;
-
- INLINE void set_path_replace(PathReplace *path_replace);
- INLINE PathReplace *get_path_replace();
- INLINE const PathReplace *get_path_replace() const;
-
- // These methods dealing with animation and frame rate are only relevant to
- // converter types that understand animation.
- INLINE void set_animation_convert(AnimationConvert animation_convert);
- INLINE AnimationConvert get_animation_convert() const;
-
- INLINE void set_character_name(const std::string &character_name);
- INLINE const std::string &get_character_name() const;
-
- INLINE void set_start_frame(double start_frame);
- INLINE bool has_start_frame() const;
- INLINE double get_start_frame() const;
- INLINE void clear_start_frame();
-
- INLINE void set_end_frame(double end_frame);
- INLINE bool has_end_frame() const;
- INLINE double get_end_frame() const;
- INLINE void clear_end_frame();
-
- INLINE void set_frame_inc(double frame_inc);
- INLINE bool has_frame_inc() const;
- INLINE double get_frame_inc() const;
- INLINE void clear_frame_inc();
-
- INLINE void set_neutral_frame(double neutral_frame);
- INLINE bool has_neutral_frame() const;
- INLINE double get_neutral_frame() const;
- INLINE void clear_neutral_frame();
-
- INLINE void set_input_frame_rate(double input_frame_rate);
- INLINE bool has_input_frame_rate() const;
- INLINE double get_input_frame_rate() const;
- INLINE void clear_input_frame_rate();
-
- INLINE void set_output_frame_rate(double output_frame_rate);
- INLINE bool has_output_frame_rate() const;
- INLINE double get_output_frame_rate() const;
- INLINE void clear_output_frame_rate();
-
- INLINE static double get_default_frame_rate();
-
- INLINE void set_merge_externals(bool merge_externals);
- INLINE bool get_merge_externals() const;
-
- void set_egg_data(EggData *egg_data);
- INLINE void clear_egg_data();
- INLINE EggData *get_egg_data();
-
- virtual std::string get_name() const=0;
- virtual std::string get_extension() const=0;
- virtual std::string get_additional_extensions() const;
- virtual bool supports_compressed() const;
- virtual bool supports_convert_to_node(const LoaderOptions &options) const;
-
- virtual bool convert_file(const Filename &filename)=0;
- virtual PT(PandaNode) convert_to_node(const LoaderOptions &options, const Filename &filename);
- virtual DistanceUnit get_input_units();
-
- bool handle_external_reference(EggGroupNode *egg_parent,
- const Filename &ref_filename);
-
- INLINE Filename convert_model_path(const Filename &orig_filename);
-
- // Set this true to treat errors as warnings and generate output anyway.
- bool _allow_errors;
-
-protected:
- PT(PathReplace) _path_replace;
-
- AnimationConvert _animation_convert;
- std::string _character_name;
- double _start_frame;
- double _end_frame;
- double _frame_inc;
- double _neutral_frame;
- double _input_frame_rate; // frames per second
- double _output_frame_rate; // frames per second
- enum ControlFlags {
- CF_start_frame = 0x0001,
- CF_end_frame = 0x0002,
- CF_frame_inc = 0x0004,
- CF_neutral_frame = 0x0008,
- CF_input_frame_rate = 0x0010,
- CF_output_frame_rate = 0x0020,
- };
- int _control_flags;
-
- bool _merge_externals;
-
- PT(EggData) _egg_data;
-
- bool _error;
-};
-
-#include "somethingToEggConverter.I"
-
-#endif
diff --git a/pandatool/src/daeegg/CMakeLists.txt b/pandatool/src/daeegg/CMakeLists.txt
deleted file mode 100644
index 07b6320d..00000000
--- a/pandatool/src/daeegg/CMakeLists.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-if(NOT HAVE_EGG OR NOT HAVE_FCOLLADA)
- return()
-endif()
-
-set(P3DAEEGG_HEADERS
- config_daeegg.h
- daeCharacter.h
- daeMaterials.h
- daeToEggConverter.h
- fcollada_utils.h
- pre_fcollada_include.h
-)
-
-set(P3DAEEGG_SOURCES
- config_daeegg.cxx
- daeCharacter.cxx
- daeMaterials.cxx
- daeToEggConverter.cxx
-)
-
-add_library(p3daeegg STATIC ${P3DAEEGG_HEADERS} ${P3DAEEGG_SOURCES})
-target_link_libraries(p3daeegg p3eggbase
- PKG::FCOLLADA)
-
-# This is only needed for binaries in the pandatool package. It is not useful
-# for user applications, so it is not installed.
diff --git a/pandatool/src/daeegg/config_daeegg.cxx b/pandatool/src/daeegg/config_daeegg.cxx
deleted file mode 100644
index 2b363155..00000000
--- a/pandatool/src/daeegg/config_daeegg.cxx
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file config_daeegg.cxx
- * @author rdb
- * @date 2008-10-30
- */
-
-#include "config_daeegg.h"
-#include "daeCharacter.h"
-#include "daeMaterials.h"
-
-#include "dconfig.h"
-
-Configure(config_daeegg);
-NotifyCategoryDef(daeegg, "");
-
-ConfigureFn(config_daeegg) {
- init_libdaeegg();
-}
-
-/**
- * Initializes the library. This must be called at least once before any of
- * the functions or classes in this library can be used. Normally it will be
- * called by the static initializers and need not be called explicitly, but
- * special cases exist.
- */
-void
-init_libdaeegg() {
- static bool initialized = false;
- if (initialized) {
- return;
- }
- initialized = true;
-
- DaeCharacter::init_type();
- DaeMaterials::init_type();
-}
diff --git a/pandatool/src/daeegg/config_daeegg.h b/pandatool/src/daeegg/config_daeegg.h
deleted file mode 100644
index 8f60ed73..00000000
--- a/pandatool/src/daeegg/config_daeegg.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file config_daeegg.h
- * @author rdb
- * @date 2008-10-30
- */
-
-#ifndef CONFIG_DAEEGG_H
-#define CONFIG_DAEEGG_H
-
-#include "pandatoolbase.h"
-#include "notifyCategoryProxy.h"
-
-NotifyCategoryDeclNoExport(daeegg);
-
-extern void init_libdaeegg();
-
-#endif
diff --git a/pandatool/src/daeegg/daeCharacter.cxx b/pandatool/src/daeegg/daeCharacter.cxx
deleted file mode 100644
index 57c048fc..00000000
--- a/pandatool/src/daeegg/daeCharacter.cxx
+++ /dev/null
@@ -1,312 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file daeCharacter.cxx
- * @author rdb
- * @date 2008-11-24
- */
-
-#include "daeCharacter.h"
-#include "config_daeegg.h"
-#include "fcollada_utils.h"
-#include "pt_EggVertex.h"
-#include "eggXfmSAnim.h"
-#include "daeToEggConverter.h"
-#include "daeMaterials.h"
-
-#include "eggExternalReference.h"
-
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-
-TypeHandle DaeCharacter::_type_handle;
-
-/**
- *
- */
-DaeCharacter::
-DaeCharacter(EggGroup *node_group, const FCDControllerInstance *instance) :
- _node_group(node_group),
- _skin_mesh(nullptr),
- _instance(instance),
- _bind_shape_mat(LMatrix4d::ident_mat()),
- _name(node_group->get_name()),
- _skin_controller(nullptr) {
-
- // If it's a skin controller, add the controller joints.
- const FCDController *controller = (const FCDController *)instance->GetEntity();
- if (controller == nullptr) {
- return;
- }
- _skin_mesh = controller->GetBaseGeometry()->GetMesh();
-
- if (controller->IsSkin()) {
- _skin_controller = controller->GetSkinController();
- _bind_shape_mat = DAEToEggConverter::convert_matrix(_skin_controller->GetBindShapeTransform());
- }
-}
-
-/**
- * Binds the joints to the character. This means changing them to the bind
- * pose. It is necessary to call this before process_skin_geometry.
- *
- * Returns the root group.
- */
-void DaeCharacter::
-bind_joints(JointMap &joint_map) {
- _joints.clear();
-
- size_t num_joints = _skin_controller->GetJointCount();
- _joints.reserve(num_joints);
-
- // Record the bind pose for each joint.
- for (size_t j = 0; j < num_joints; ++j) {
- const FCDSkinControllerJoint *skin_joint = _skin_controller->GetJoint(j);
- std::string sid = FROM_FSTRING(skin_joint->GetId());
- LMatrix4d bind_pose;
- bind_pose.invert_from(DAEToEggConverter::convert_matrix(
- skin_joint->GetBindPoseInverse()));
-
- // Check that we already encountered this joint during traversal.
- JointMap::iterator ji = joint_map.find(sid);
- if (ji != joint_map.end()) {
- Joint &joint = ji->second;
-
- if (joint._character != nullptr) {
- // In some cases, though, multiple controllers share the same joints.
- // We can't support this without duplicating the joint structure, so
- // we check if the bind poses are the same.
- if (!joint._bind_pose.almost_equal(bind_pose, 0.0001)) {
- // Ugh. What else could we do?
- daeegg_cat.error()
- << "Multiple controllers share joint with sid " << sid
- << ", with different bind poses.\n";
- }
- } else {
- // Mark the joint as being controlled by this character.
- joint._bind_pose = bind_pose;
- joint._character = this;
- }
-
- _joints.push_back(joint);
- } else {
- daeegg_cat.warning()
- << "Unknown joint sid being referenced: '" << sid << "'\n";
-
- // We still have to add a dummy joint or the index will be off.
- _joints.push_back(Joint(nullptr, nullptr));
- }
- }
-}
-
-/**
- * Traverses through the character hierarchy in order to bind the mesh to the
- * character. This involves reorienting the joints to match the bind pose.
- *
- * It is important that this is called only once.
- */
-void DaeCharacter::
-adjust_joints(FCDSceneNode *node, const JointMap &joint_map,
- const LMatrix4d &transform) {
-
- LMatrix4d this_transform = transform;
-
- if (node->IsJoint()) {
- std::string sid = FROM_FSTRING(node->GetSubId());
-
- JointMap::const_iterator ji = joint_map.find(sid);
- if (ji != joint_map.end()) {
- const Joint &joint = ji->second;
-
- // Panda needs the joints to be in bind pose. Not fun! We copy the
- // joint transform to the default pose, though, so that Panda will
- // restore the joint transformation after binding.
-
- if (joint._character == this) {
- LMatrix4d bind_pose = joint._bind_pose * _bind_shape_mat *
- invert(transform);
- // LMatrix4d bind_pose = joint._bind_pose * _bind_shape_mat *
- // joint._group->get_parent()->get_node_frame_inv();
-
- this_transform = bind_pose * this_transform;
- joint._group->set_default_pose(*joint._group);
- joint._group->set_transform3d(bind_pose);
-
- /*
- PT(EggGroup) sphere = new EggGroup;
- sphere->add_uniform_scale(0.1);
- sphere->set_group_type(EggGroup::GT_instance);
- sphere->add_child(new EggExternalReference("", "jack.egg"));
- joint._group->add_child(sphere);
- */
- }
- }
- } else {
- // this_transform = DAEToEggConverter::convert_matrix(node->ToMatrix());
- }
-
- // Loop through the children joints
- for (size_t ch = 0; ch < node->GetChildrenCount(); ++ch) {
- // if (node->GetChild(ch)->IsJoint()) {
- adjust_joints(node->GetChild(ch), joint_map, this_transform);
- // }
- }
-}
-
-/**
- * Adds the influences for the given vertex.
- */
-void DaeCharacter::
-influence_vertex(int index, EggVertex *vertex) {
- const FCDSkinControllerVertex *influence = _skin_controller->GetVertexInfluence(index);
-
- for (size_t pa = 0; pa < influence->GetPairCount(); ++pa) {
- const FCDJointWeightPair* jwpair = influence->GetPair(pa);
-
- if (jwpair->jointIndex >= 0 && jwpair->jointIndex < (int)_joints.size()) {
- EggGroup *joint = _joints[jwpair->jointIndex]._group.p();
- if (joint != nullptr) {
- joint->ref_vertex(vertex, jwpair->weight);
- }
- } else {
- daeegg_cat.error()
- << "Invalid joint index: " << jwpair->jointIndex << "\n";
- }
- }
-}
-
-/**
- * Collects all animation keys of animations applied to this character.
- */
-void DaeCharacter::
-collect_keys(pset &keys) {
-#if FCOLLADA_VERSION < 0x00030005
- FCDSceneNodeList roots = _instance->FindSkeletonNodes();
-#else
- FCDSceneNodeList roots;
- _instance->FindSkeletonNodes(roots);
-#endif
-
- for (FCDSceneNodeList::iterator it = roots.begin(); it != roots.end(); ++it) {
- r_collect_keys(*it, keys);
- }
-}
-
-/**
- * Collects all animation keys found for the given node tree.
- */
-void DaeCharacter::
-r_collect_keys(FCDSceneNode* node, pset &keys) {
- FCDAnimatedList animateds;
-
- // Collect all the animation curves
- for (size_t t = 0; t < node->GetTransformCount(); ++t) {
- FCDTransform *transform = node->GetTransform(t);
- FCDAnimated *animated = transform->GetAnimated();
-
- if (animated != nullptr) {
- const FCDAnimationCurveListList &all_curves = animated->GetCurves();
-
- for (size_t ci = 0; ci < all_curves.size(); ++ci) {
- const FCDAnimationCurveTrackList &curves = all_curves[ci];
- if (curves.empty()) {
- continue;
- }
-
- size_t num_keys = curves.front()->GetKeyCount();
- const FCDAnimationKey **curve_keys = curves.front()->GetKeys();
-
- for (size_t c = 0; c < num_keys; ++c) {
- keys.insert(curve_keys[c]->input);
- }
- }
- }
- }
-}
-
-/**
- * Processes a joint node and its transforms.
- */
-void DaeCharacter::
-build_table(EggTable *parent, FCDSceneNode* node, const pset &keys) {
- nassertv(node != nullptr);
-
- if (!node->IsJoint()) {
- for (size_t ch = 0; ch < node->GetChildrenCount(); ++ch) {
- build_table(parent, node->GetChild(ch), keys);
- }
- return;
- }
-
- std::string node_id = FROM_FSTRING(node->GetDaeId());
- PT(EggTable) table = new EggTable(node_id);
- table->set_table_type(EggTable::TT_table);
- parent->add_child(table);
-
- PT(EggXfmSAnim) xform = new EggXfmSAnim("xform");
- table->add_child(xform);
-
- // Generate the sampled animation and loop through the matrices
- FCDAnimatedList animateds;
-
- // Collect all the animation curves
- for (size_t t = 0; t < node->GetTransformCount(); ++t) {
- FCDTransform *transform = node->GetTransform(t);
- FCDAnimated *animated = transform->GetAnimated();
- if (animated != nullptr) {
- if (animated->HasCurve()) {
- animateds.push_back(animated);
- }
- }
- }
-
- // Sample the scene node transform
- float last_key;
- float timing_total = 0;
- pset::const_iterator ki;
- for (ki = keys.begin(); ki != keys.end(); ++ki) {
- for (FCDAnimatedList::iterator it = animateds.begin(); it != animateds.end(); ++it) {
- // Sample each animated, which changes the transform values directly
- (*it)->Evaluate(*ki);
- }
-
- if (ki != keys.begin()) {
- timing_total += (*ki - last_key);
- }
- last_key = *ki;
-
- // Retrieve the new transform matrix for the COLLADA scene node
- FMMatrix44 fmat = node->ToMatrix();
-
- // Work around issue in buggy exporters (like ColladaMax)
- if (IS_NEARLY_ZERO(fmat[3][3])) {
- fmat[3][3] = 1;
- }
-
- xform->add_data(DAEToEggConverter::convert_matrix(fmat));
- }
-
- // Quantize the FPS, otherwise Panda complains about FPS mismatches.
- float fps = cfloor(((keys.size() - 1) / timing_total) * 100 + 0.5f) * 0.01f;
- xform->set_fps(fps);
-
- // Loop through the children joints
- for (size_t ch = 0; ch < node->GetChildrenCount(); ++ch) {
- // if (node->GetChild(ch)->IsJoint()) {
- build_table(table, node->GetChild(ch), keys);
- // }
- }
-}
diff --git a/pandatool/src/daeegg/daeCharacter.h b/pandatool/src/daeegg/daeCharacter.h
deleted file mode 100644
index e384c221..00000000
--- a/pandatool/src/daeegg/daeCharacter.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file daeCharacter.h
- * @author rdb
- * @date 2008-11-24
- */
-
-#ifndef DAECHARACTER_H
-#define DAECHARACTER_H
-
-#include "pandatoolbase.h"
-#include "typedReferenceCount.h"
-#include "typeHandle.h"
-#include "eggTable.h"
-#include "epvector.h"
-
-#include "pre_fcollada_include.h"
-#include
-#include
-#include
-#include
-#include
-
-class DAEToEggConverter;
-
-/**
- * Class representing an animated character.
- */
-class DaeCharacter : public TypedReferenceCount {
-public:
- DaeCharacter(EggGroup *node_group, const FCDControllerInstance* controller_instance);
-
- struct Joint {
- INLINE Joint(EggGroup *group, const FCDSceneNode *scene_node) :
- _bind_pose(LMatrix4d::ident_mat()),
- _group(group),
- _scene_node(scene_node),
- _character(nullptr) {}
-
- LMatrix4d _bind_pose;
- PT(EggGroup) _group;
- const FCDSceneNode *_scene_node;
- DaeCharacter *_character;
- };
- typedef epvector Joints;
- typedef pmap JointMap;
-
- void bind_joints(JointMap &joint_map);
- void adjust_joints(FCDSceneNode *node, const JointMap &joint_map,
- const LMatrix4d &transform = LMatrix4d::ident_mat());
-
- void influence_vertex(int index, EggVertex *vertex);
-
- void collect_keys(pset &keys);
- void r_collect_keys(FCDSceneNode *node, pset &keys);
-
- void build_table(EggTable *parent, FCDSceneNode* node, const pset &keys);
-
-public:
- PT(EggGroup) _node_group;
- const FCDGeometryMesh *_skin_mesh;
- const FCDControllerInstance *_instance;
- LMatrix4d _bind_shape_mat;
-
-private:
- std::string _name;
- const FCDSkinController *_skin_controller;
- Joints _joints;
- JointMap _bound_joints;
-
-public:
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- TypedReferenceCount::init_type();
- register_type(_type_handle, "DaeCharacter",
- TypedReferenceCount::get_class_type());
- }
-
-private:
- static TypeHandle _type_handle;
-};
-
-#endif
diff --git a/pandatool/src/daeegg/daeMaterials.cxx b/pandatool/src/daeegg/daeMaterials.cxx
deleted file mode 100644
index ac221344..00000000
--- a/pandatool/src/daeegg/daeMaterials.cxx
+++ /dev/null
@@ -1,451 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file daeMaterials.cxx
- * @author rdb
- * @date 2008-10-03
- */
-
-#include "daeMaterials.h"
-#include "config_daeegg.h"
-#include "fcollada_utils.h"
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "filename.h"
-#include "string_utils.h"
-
-using std::endl;
-using std::string;
-
-TypeHandle DaeMaterials::_type_handle;
-
-// luminance function, based on the ISOCIE color standards see ITU-R
-// Recommendation BT.709-4
-#define luminance(c) ((c[0] * 0.212671 + c[1] * 0.715160 + c[2] * 0.072169))
-
-/**
- *
- */
-DaeMaterials::
-DaeMaterials(const FCDGeometryInstance* geometry_instance) {
- for (size_t mi = 0; mi < geometry_instance->GetMaterialInstanceCount(); ++mi) {
- add_material_instance(geometry_instance->GetMaterialInstance(mi));
- }
-}
-
-/**
- * Adds a material instance. Normally automatically done by constructor.
- */
-void DaeMaterials::add_material_instance(const FCDMaterialInstance* instance) {
- nassertv(instance != nullptr);
- const string semantic (FROM_FSTRING(instance->GetSemantic()));
- if (_materials.count(semantic) > 0) {
- daeegg_cat.warning() << "Ignoring duplicate material with semantic " << semantic << endl;
- return;
- }
- _materials[semantic] = new DaeMaterial();
-
- // Load in the uvsets
- for (size_t vib = 0; vib < instance->GetVertexInputBindingCount(); ++vib) {
- const FCDMaterialInstanceBindVertexInput* mivib = instance->GetVertexInputBinding(vib);
- assert(mivib != nullptr);
- PT(DaeVertexInputBinding) bvi = new DaeVertexInputBinding();
- bvi->_input_set = mivib->inputSet;
-#if FCOLLADA_VERSION >= 0x00030005
- bvi->_input_semantic = mivib->GetInputSemantic();
- bvi->_semantic = *mivib->semantic;
-#else
- bvi->_input_semantic = mivib->inputSemantic;
- bvi->_semantic = FROM_FSTRING(mivib->semantic);
-#endif
- _materials[semantic]->_uvsets.push_back(bvi);
- }
-
- // Handle the material stuff
- if (daeegg_cat.is_spam()) {
- daeegg_cat.spam() << "Trying to process material with semantic " << semantic << endl;
- }
- PT_EggMaterial egg_material = new EggMaterial(semantic);
- pvector egg_textures;
- const FCDEffect* effect = instance->GetMaterial()->GetEffect();
- if (effect == nullptr) {
- if (daeegg_cat.is_debug()) {
- daeegg_cat.debug() << "Ignoring material (semantic: " << semantic << ") without assigned effect" << endl;
- }
- } else {
- // Grab the common profile effect
- const FCDEffectStandard* effect_common = (FCDEffectStandard *)effect->FindProfile(FUDaeProfileType::COMMON);
- if (effect_common == nullptr) {
- daeegg_cat.info() << "Ignoring effect referenced by material with semantic " << semantic
- << " because it has no common profile" << endl;
- } else {
- if (daeegg_cat.is_spam()) {
- daeegg_cat.spam() << "Processing effect, material semantic is " << semantic << endl;
- }
- // Set the material parameters
- egg_material->set_amb(TO_COLOR(effect_common->GetAmbientColor()));
- // We already process transparency using blend modes LVecBase4 diffuse =
- // TO_COLOR(effect_common->GetDiffuseColor());
- // diffuse.set_w(diffuse.get_w() * (1.0f -
- // effect_common->GetOpacity())); egg_material->set_diff(diffuse);
- egg_material->set_diff(TO_COLOR(effect_common->GetDiffuseColor()));
- egg_material->set_emit(TO_COLOR(effect_common->GetEmissionColor()) * effect_common->GetEmissionFactor());
- egg_material->set_shininess(effect_common->GetShininess());
- egg_material->set_spec(TO_COLOR(effect_common->GetSpecularColor()));
- // Now try to load in the textures
- process_texture_bucket(semantic, effect_common, FUDaeTextureChannel::DIFFUSE, EggTexture::ET_modulate);
- process_texture_bucket(semantic, effect_common, FUDaeTextureChannel::BUMP, EggTexture::ET_normal);
- process_texture_bucket(semantic, effect_common, FUDaeTextureChannel::SPECULAR, EggTexture::ET_modulate_gloss);
- process_texture_bucket(semantic, effect_common, FUDaeTextureChannel::SPECULAR_LEVEL, EggTexture::ET_gloss);
- process_texture_bucket(semantic, effect_common, FUDaeTextureChannel::TRANSPARENT, EggTexture::ET_unspecified, EggTexture::F_alpha);
- process_texture_bucket(semantic, effect_common, FUDaeTextureChannel::EMISSION, EggTexture::ET_add);
-#if FCOLLADA_VERSION < 0x00030005
- process_texture_bucket(semantic, effect_common, FUDaeTextureChannel::OPACITY, EggTexture::ET_unspecified, EggTexture::F_alpha);
-#endif
- // Now, calculate the color blend stuff.
- _materials[semantic]->_blend = convert_blend(effect_common->GetTransparencyMode(),
- TO_COLOR(effect_common->GetTranslucencyColor()),
- effect_common->GetTranslucencyFactor());
- }
- // Find an tag to support some extra stuff from extensions
- process_extra(semantic, effect->GetExtra());
- }
- if (daeegg_cat.is_spam()) {
- daeegg_cat.spam() << "Found " << egg_textures.size() << " textures in material" << endl;
- }
- _materials[semantic]->_egg_material = egg_material;
-}
-
-/**
- * Processes the given texture bucket and gives the textures in it the given
- * envtype and format.
- */
-void DaeMaterials::
-process_texture_bucket(const string semantic, const FCDEffectStandard* effect_common, FUDaeTextureChannel::Channel bucket, EggTexture::EnvType envtype, EggTexture::Format format) {
- for (size_t tx = 0; tx < effect_common->GetTextureCount(bucket); ++tx) {
- const FCDImage* image = effect_common->GetTexture(bucket, tx)->GetImage();
- if (image == nullptr) {
- daeegg_cat.warning() << "Texture references a nonexisting image!" << endl;
- } else {
- const FCDEffectParameterSampler* sampler = effect_common->GetTexture(bucket, tx)->GetSampler();
- // FCollada only supplies absolute paths. We need to grab the document
- // location ourselves and make the image path absolute.
- Filename texpath;
- if (image->GetDocument()) {
- Filename docpath = Filename::from_os_specific(FROM_FSTRING(image->GetDocument()->GetFileUrl()));
- docpath.make_canonical();
- texpath = Filename::from_os_specific(FROM_FSTRING(image->GetFilename()));
- texpath.make_canonical();
- texpath.make_relative_to(docpath.get_dirname(), true);
- if (daeegg_cat.is_debug()) {
- daeegg_cat.debug() << "Found texture with path " << texpath << endl;
- }
- } else {
- // Never mind.
- texpath = Filename::from_os_specific(FROM_FSTRING(image->GetFilename()));
- }
- PT_EggTexture egg_texture = new EggTexture(FROM_FSTRING(image->GetDaeId()), texpath.to_os_generic());
- // Find a set of UV coordinates
- const FCDEffectParameterInt* uvset = effect_common->GetTexture(bucket, tx)->GetSet();
- if (uvset != nullptr) {
- if (daeegg_cat.is_debug()) {
- daeegg_cat.debug() << "Texture has uv name '" << FROM_FSTRING(uvset->GetSemantic()) << "'\n";
- }
- string uvset_semantic (FROM_FSTRING(uvset->GetSemantic()));
-
- // Only set the UV name if this UV set actually exists.
- for (size_t i = 0; i < _materials[semantic]->_uvsets.size(); ++i) {
- if (_materials[semantic]->_uvsets[i]->_semantic == uvset_semantic) {
- egg_texture->set_uv_name(uvset_semantic);
- break;
- }
- }
- }
- // Apply sampler stuff
- if (sampler != nullptr) {
- egg_texture->set_texture_type(convert_texture_type(sampler->GetSamplerType()));
- egg_texture->set_wrap_u(convert_wrap_mode(sampler->GetWrapS()));
- if (sampler->GetSamplerType() != FCDEffectParameterSampler::SAMPLER1D) {
- egg_texture->set_wrap_v(convert_wrap_mode(sampler->GetWrapT()));
- }
- if (sampler->GetSamplerType() == FCDEffectParameterSampler::SAMPLER3D) {
- egg_texture->set_wrap_w(convert_wrap_mode(sampler->GetWrapP()));
- }
- egg_texture->set_minfilter(convert_filter_type(sampler->GetMinFilter()));
- egg_texture->set_magfilter(convert_filter_type(sampler->GetMagFilter()));
- if (envtype != EggTexture::ET_unspecified) {
- egg_texture->set_env_type(envtype);
- }
- if (format != EggTexture::F_unspecified) {
- egg_texture->set_format(format);
- }
- }
- _materials[semantic]->_egg_textures.push_back(egg_texture);
- }
- }
-}
-
-/**
- * Processes the extra data in the given tag. If the given element is
- * NULL, it just silently returns.
- */
-void DaeMaterials::
-process_extra(const string semantic, const FCDExtra* extra) {
- if (extra == nullptr) return;
- const FCDEType* etype = extra->GetDefaultType();
- if (etype == nullptr) return;
- for (size_t et = 0; et < etype->GetTechniqueCount(); ++et) {
- const FCDENode* enode = ((const FCDENode*)(etype->GetTechnique(et)))->FindChildNode("double_sided");
- if (enode != nullptr) {
- string content = trim(enode->GetContent());
- if (content == "1" || content == "true") {
- _materials[semantic]->_double_sided = true;
- } else if (content == "0" || content == "false") {
- _materials[semantic]->_double_sided = false;
- } else {
- daeegg_cat.warning() << "Expected tag to be either 1 or 0, found '" << content << "' instead" << endl;
- }
- }
- }
-}
-
-/**
- * Applies the stuff to the given EggPrimitive.
- */
-void DaeMaterials::
-apply_to_primitive(const string semantic, const PT(EggPrimitive) to) {
- if (_materials.count(semantic) > 0) {
- to->set_material(_materials[semantic]->_egg_material);
- for (pvector::iterator it = _materials[semantic]->_egg_textures.begin(); it != _materials[semantic]->_egg_textures.end(); ++it) {
- if (daeegg_cat.is_spam()) {
- daeegg_cat.spam() << "Applying texture " << (*it)->get_name() << " from material with semantic " << semantic << endl;
- }
- to->add_texture(*it);
- }
- to->set_bface_flag(_materials[semantic]->_double_sided);
- }
-}
-
-/**
- * Applies the colorblend stuff to the given EggGroup.
- */
-void DaeMaterials::
-apply_to_group(const string semantic, const PT(EggGroup) to, bool invert_transparency) {
- if (_materials.count(semantic) > 0) {
- PT(DaeBlendSettings) blend = _materials[semantic]->_blend;
- if (blend && blend->_enabled) {
- to->set_blend_mode(EggGroup::BM_add);
- to->set_blend_color(blend->_color);
- if (invert_transparency) {
- to->set_blend_operand_a(blend->_operand_b);
- to->set_blend_operand_b(blend->_operand_a);
- } else {
- to->set_blend_operand_a(blend->_operand_a);
- to->set_blend_operand_b(blend->_operand_b);
- }
- } else if (blend && invert_transparency) {
- to->set_blend_mode(EggGroup::BM_add);
- to->set_blend_color(blend->_color);
- to->set_blend_operand_a(blend->_operand_b);
- to->set_blend_operand_b(blend->_operand_a);
- }
- }
-}
-
-/**
- * Returns the semantic of the uvset with the specified input set, or an empty
- * string if the given material has no input set.
- */
-const string DaeMaterials::
-get_uvset_name(const string semantic, FUDaeGeometryInput::Semantic input_semantic, int32 input_set) {
- if (_materials.count(semantic) > 0) {
- if (input_set == -1 && _materials[semantic]->_uvsets.size() == 1) {
- return _materials[semantic]->_uvsets[0]->_semantic;
- } else {
- for (size_t i = 0; i < _materials[semantic]->_uvsets.size(); ++i) {
- if (_materials[semantic]->_uvsets[i]->_input_set == input_set &&
- _materials[semantic]->_uvsets[i]->_input_semantic == input_semantic) {
- return _materials[semantic]->_uvsets[i]->_semantic;
- }
- }
- // If we can't find it, let's look again, but don't care for the
- // input_semantic this time. The reason for this is that some tools
- // export textangents and texbinormals bound to a uvset with input
- // semantic TEXCOORD.
- for (size_t i = 0; i < _materials[semantic]->_uvsets.size(); ++i) {
- if (_materials[semantic]->_uvsets[i]->_input_set == input_set) {
- if (daeegg_cat.is_debug()) {
- daeegg_cat.debug() << "Using uv set with non-matching input semantic " << _materials[semantic]->_uvsets[i]->_semantic << "\n";
- }
- return _materials[semantic]->_uvsets[i]->_semantic;
- }
- }
- if (daeegg_cat.is_debug()) {
- daeegg_cat.debug() << "No uv set binding found for input set " << input_set << "\n";
- }
- }
- }
- return "";
-}
-
-/**
- * Converts an FCollada sampler type to the EggTexture texture type
- * equivalent.
- */
-EggTexture::TextureType DaeMaterials::
-convert_texture_type(const FCDEffectParameterSampler::SamplerType orig_type) {
- switch (orig_type) {
- case FCDEffectParameterSampler::SAMPLER1D:
- return EggTexture::TT_1d_texture;
- case FCDEffectParameterSampler::SAMPLER2D:
- return EggTexture::TT_2d_texture;
- case FCDEffectParameterSampler::SAMPLER3D:
- return EggTexture::TT_3d_texture;
- case FCDEffectParameterSampler::SAMPLERCUBE:
- return EggTexture::TT_cube_map;
- default:
- daeegg_cat.warning() << "Invalid sampler type found" << endl;
- }
- return EggTexture::TT_unspecified;
-}
-
-/**
- * Converts an FCollada wrap mode to the EggTexture wrap mode equivalent.
- */
-EggTexture::WrapMode DaeMaterials::
-convert_wrap_mode(const FUDaeTextureWrapMode::WrapMode orig_mode) {
- switch (orig_mode) {
- case FUDaeTextureWrapMode::NONE:
- // FIXME: this shouldnt be unspecified
- return EggTexture::WM_unspecified;
- case FUDaeTextureWrapMode::WRAP:
- return EggTexture::WM_repeat;
- case FUDaeTextureWrapMode::MIRROR:
- return EggTexture::WM_mirror;
- case FUDaeTextureWrapMode::CLAMP:
- return EggTexture::WM_clamp;
- case FUDaeTextureWrapMode::BORDER:
- return EggTexture::WM_border_color;
- case FUDaeTextureWrapMode::UNKNOWN:
- return EggTexture::WM_unspecified;
- default:
- daeegg_cat.warning() << "Invalid wrap mode found: " << FUDaeTextureWrapMode::ToString(orig_mode) << endl;
- }
- return EggTexture::WM_unspecified;
-}
-
-/**
- * Converts an FCollada filter function to the EggTexture wrap type
- * equivalent.
- */
-EggTexture::FilterType DaeMaterials::
-convert_filter_type(const FUDaeTextureFilterFunction::FilterFunction orig_type) {
- switch (orig_type) {
- case FUDaeTextureFilterFunction::NONE:
- // FIXME: this shouldnt be unspecified
- return EggTexture::FT_unspecified;
- case FUDaeTextureFilterFunction::NEAREST:
- return EggTexture::FT_nearest;
- case FUDaeTextureFilterFunction::LINEAR:
- return EggTexture::FT_linear;
- case FUDaeTextureFilterFunction::NEAREST_MIPMAP_NEAREST:
- return EggTexture::FT_nearest_mipmap_nearest;
- case FUDaeTextureFilterFunction::LINEAR_MIPMAP_NEAREST:
- return EggTexture::FT_linear_mipmap_nearest;
- case FUDaeTextureFilterFunction::NEAREST_MIPMAP_LINEAR:
- return EggTexture::FT_nearest_mipmap_linear;
- case FUDaeTextureFilterFunction::LINEAR_MIPMAP_LINEAR:
- return EggTexture::FT_linear_mipmap_linear;
- case FUDaeTextureFilterFunction::UNKNOWN:
- return EggTexture::FT_unspecified;
- default:
- daeegg_cat.warning() << "Unknown filter type found: " << FUDaeTextureFilterFunction::ToString(orig_type) << endl;
- }
- return EggTexture::FT_unspecified;
-}
-
-/**
- * Converts collada blend attribs to Panda's equivalents.
- */
-PT(DaeMaterials::DaeBlendSettings) DaeMaterials::
-convert_blend(FCDEffectStandard::TransparencyMode mode, const LColor &transparent, double transparency) {
- // Create the DaeBlendSettings and fill it with some defaults.
- PT(DaeBlendSettings) blend = new DaeBlendSettings();
- blend->_enabled = true;
- blend->_color = LColor::zero();
- blend->_operand_a = EggGroup::BO_unspecified;
- blend->_operand_b = EggGroup::BO_unspecified;
-
- // First fill in the color value.
- if (mode == FCDEffectStandard::A_ONE) {// || mode == FCDEffectStandard::A_ZERO) {
- double value = transparent[3] * transparency;
- blend->_color = LColor(value, value, value, value);
- } else if (mode == FCDEffectStandard::RGB_ZERO) {//|| mode == FCDEffectStandard::RGB_ONE) {
- blend->_color = transparent * transparency;
- blend->_color[3] = luminance(blend->_color);
- } else {
- daeegg_cat.error() << "Unknown opaque type found!" << endl;
- blend->_enabled = false;
- return blend;
- }
-
- // Now figure out the operands.
- if (mode == FCDEffectStandard::RGB_ZERO) {// || mode == FCDEffectStandard::A_ZERO) {
- blend->_operand_a = EggGroup::BO_one_minus_constant_color;
- blend->_operand_b = EggGroup::BO_constant_color;
- } else if (mode == FCDEffectStandard::A_ONE) {// || mode == FCDEffectStandard::RGB_ONE) {
- blend->_operand_a = EggGroup::BO_constant_color;
- blend->_operand_b = EggGroup::BO_one_minus_constant_color;
- } else {
- daeegg_cat.error() << "Unknown opaque type found!" << endl;
- blend->_enabled = false;
- return blend;
- }
-
- // See if we can optimize out the color.
- if (blend->_operand_a == EggGroup::BO_constant_color) {
- if (blend->_color == LColor::zero()) {
- blend->_operand_a = EggGroup::BO_zero;
- } else if (blend->_color == LColor(1, 1, 1, 1)) {
- blend->_operand_a = EggGroup::BO_one;
- }
- }
- if (blend->_operand_b == EggGroup::BO_constant_color) {
- if (blend->_color == LColor::zero()) {
- blend->_operand_b = EggGroup::BO_zero;
- } else if (blend->_color == LColor(1, 1, 1, 1)) {
- blend->_operand_b = EggGroup::BO_one;
- }
- }
- if (blend->_operand_a == EggGroup::BO_one_minus_constant_color) {
- if (blend->_color == LColor::zero()) {
- blend->_operand_a = EggGroup::BO_one;
- } else if (blend->_color == LColor(1, 1, 1, 1)) {
- blend->_operand_a = EggGroup::BO_zero;
- }
- }
- if (blend->_operand_b == EggGroup::BO_one_minus_constant_color) {
- if (blend->_color == LColor::zero()) {
- blend->_operand_b = EggGroup::BO_one;
- } else if (blend->_color == LColor(1, 1, 1, 1)) {
- blend->_operand_b = EggGroup::BO_zero;
- }
- }
-
- // See if we can entirely disable the blend.
- if (blend->_operand_a == EggGroup::BO_one && blend->_operand_b == EggGroup::BO_zero) {
- blend->_enabled = false;
- }
- return blend;
-}
diff --git a/pandatool/src/daeegg/daeMaterials.h b/pandatool/src/daeegg/daeMaterials.h
deleted file mode 100644
index 08cfed03..00000000
--- a/pandatool/src/daeegg/daeMaterials.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file daeMaterials.h
- * @author rdb
- * @date 2008-10-03
- */
-
-#ifndef DAEMATERIALS_H
-#define DAEMATERIALS_H
-
-#include "pandatoolbase.h"
-#include "eggMaterial.h"
-#include "eggTexture.h"
-#include "eggPrimitive.h"
-#include "eggGroup.h"
-#include "pointerTo.h"
-#include "pt_EggTexture.h"
-#include "pt_EggMaterial.h"
-
-#include "pre_fcollada_include.h"
-#include
-#include
-#include
-#include
-#include
-#include
-
-/**
- * This class is seperated from the converter file because otherwise it would
- * get too big and needlessly complicated.
- */
-class DaeMaterials : public TypedReferenceCount {
-public:
- DaeMaterials(const FCDGeometryInstance* geometry_instance);
- virtual ~DaeMaterials() {};
-
- void add_material_instance(const FCDMaterialInstance* instance);
- void apply_to_primitive(const std::string semantic, const PT(EggPrimitive) to);
- void apply_to_group(const std::string semantic, const PT(EggGroup) to, bool invert_transparency=false);
- const std::string get_uvset_name(const std::string semantic, FUDaeGeometryInput::Semantic input_semantic, int32 input_set);
-
- static EggTexture::TextureType convert_texture_type(const FCDEffectParameterSampler::SamplerType orig_type);
- static EggTexture::WrapMode convert_wrap_mode(const FUDaeTextureWrapMode::WrapMode orig_mode);
- static EggTexture::FilterType convert_filter_type(const FUDaeTextureFilterFunction::FilterFunction orig_type);
-
-private:
- // Holds stuff for color blend attribs.
- struct DaeBlendSettings : public ReferenceCount {
- bool _enabled;
- LColor _color;
- EggGroup::BlendOperand _operand_a;
- EggGroup::BlendOperand _operand_b;
- };
-
- // Holds information to bind texcoord inputs to textures.
- struct DaeVertexInputBinding : public ReferenceCount {
- int32 _input_set;
- FUDaeGeometryInput::Semantic _input_semantic;
- std::string _semantic;
- };
-
- // Holds stuff for an individual material.
- struct DaeMaterial : public ReferenceCount {
- pvector _egg_textures;
- PT_EggMaterial _egg_material;
- bool _double_sided;
- pvector _uvsets;
- PT(DaeBlendSettings) _blend;
- };
-
- void process_texture_bucket(const std::string semantic, const FCDEffectStandard* effect_common, FUDaeTextureChannel::Channel bucket, EggTexture::EnvType envtype = EggTexture::ET_unspecified, EggTexture::Format format = EggTexture::F_unspecified);
- void process_extra(const std::string semantic, const FCDExtra* extra);
- static PT(DaeBlendSettings) convert_blend(FCDEffectStandard::TransparencyMode mode, const LColor &transparent, double transparency);
-
- pmap _materials;
-
-public:
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- TypedReferenceCount::init_type();
- register_type(_type_handle, "DaeMaterials",
- TypedReferenceCount::get_class_type());
- }
-
-private:
- static TypeHandle _type_handle;
-};
-
-#endif
diff --git a/pandatool/src/daeegg/daeToEggConverter.cxx b/pandatool/src/daeegg/daeToEggConverter.cxx
deleted file mode 100644
index 95b146de..00000000
--- a/pandatool/src/daeegg/daeToEggConverter.cxx
+++ /dev/null
@@ -1,851 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file daeToEggConverter.cxx
- * @author rdb
- * @date 2008-05-08
- */
-
-#include "daeToEggConverter.h"
-#include "fcollada_utils.h"
-#include "config_daeegg.h"
-#include "daeCharacter.h"
-#include "dcast.h"
-#include "string_utils.h"
-#include "eggData.h"
-#include "eggPrimitive.h"
-#include "eggLine.h"
-#include "eggPolygon.h"
-#include "eggTriangleFan.h"
-#include "eggTriangleStrip.h"
-#include "eggPoint.h"
-#include "eggXfmSAnim.h"
-#include "eggSAnimData.h"
-#include "pt_EggVertex.h"
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#if FCOLLADA_VERSION >= 0x00030005
- #include
-#endif
-
-using std::endl;
-using std::string;
-
-/**
- *
- */
-DAEToEggConverter::
-DAEToEggConverter() {
- _unit_name = "meter";
- _unit_meters = 1.0;
- _document = nullptr;
- _table = nullptr;
- _error_handler = nullptr;
- _invert_transparency = false;
-}
-
-/**
- *
- */
-DAEToEggConverter::
-DAEToEggConverter(const DAEToEggConverter ©) :
- SomethingToEggConverter(copy)
-{
-}
-
-/**
- *
- */
-DAEToEggConverter::
-~DAEToEggConverter() {
- delete _error_handler;
-}
-
-/**
- * Allocates and returns a new copy of the converter.
- */
-SomethingToEggConverter *DAEToEggConverter::
-make_copy() {
- return new DAEToEggConverter(*this);
-}
-
-
-/**
- * Returns the English name of the file type this converter supports.
- */
-string DAEToEggConverter::
-get_name() const {
- return "COLLADA";
-}
-
-/**
- * Returns the common extension of the file type this converter supports.
- */
-string DAEToEggConverter::
-get_extension() const {
- return "dae";
-}
-
-/**
- * Handles the reading of the input file and converting it to egg. Returns
- * true if successful, false otherwise.
- */
-bool DAEToEggConverter::
-convert_file(const Filename &filename) {
- // Reset stuff
- clear_error();
- _joints.clear();
- if (_error_handler == nullptr) {
- _error_handler = new FUErrorSimpleHandler;
- }
-
- // The default coordinate system is Y-up
- if (_egg_data->get_coordinate_system() == CS_default) {
- _egg_data->set_coordinate_system(CS_yup_right);
- }
-
- // Read the file
- FCollada::Initialize();
- _document = FCollada::LoadDocument(filename.to_os_specific().c_str());
- if (_document == nullptr) {
- daeegg_cat.error() << "Failed to load document: " << _error_handler->GetErrorString() << endl;
- FCollada::Release();
- return false;
- }
- // Make sure the file uses consistent coordinate system and length
- if (_document->GetAsset() != nullptr) {
- FCDocumentTools::StandardizeUpAxisAndLength(_document);
- }
-
- // Process the scene
- process_asset();
- PT(EggGroup) scene_group;
- string model_name = _character_name;
-
- FCDSceneNode* visual_scene = _document->GetVisualSceneInstance();
- if (visual_scene != nullptr) {
- if (model_name.empty()) {
- // By lack of anything better...
- model_name = FROM_FSTRING(visual_scene->GetName());
- }
- scene_group = new EggGroup(model_name);
- _egg_data->add_child(scene_group);
-
- for (size_t ch = 0; ch < visual_scene->GetChildrenCount(); ++ch) {
- process_node(scene_group, visual_scene->GetChild(ch));
- }
- } else {
- daeegg_cat.warning()
- << "No visual scene instance found in COLLADA document.\n";
- }
-
- // Now process the characters. This depends on information from collected
- // joints, which is why it's done in a second step.
- if (get_animation_convert() != AC_none) {
- Characters::iterator it;
- DaeCharacter *character;
- for (it = _characters.begin(); it != _characters.end(); ++it) {
- character = *it;
- if (get_animation_convert() != AC_chan) {
- character->bind_joints(_joints);
-
- const FCDGeometryMesh *mesh = character->_skin_mesh;
-
- if (mesh != nullptr) {
- PT(DaeMaterials) materials = new DaeMaterials(character->_instance);
- if (daeegg_cat.is_spam()) {
- daeegg_cat.spam() << "Processing mesh for controller\n";
- }
- process_mesh(character->_node_group, mesh, materials, character);
- }
- }
- }
-
- // Put the joints in bind pose.
- for (size_t ch = 0; ch < visual_scene->GetChildrenCount(); ++ch) {
- character->adjust_joints(visual_scene->GetChild(ch), _joints, LMatrix4d::ident_mat());
- }
-
- if (scene_group != nullptr) {
- // Mark the scene as character.
- if (get_animation_convert() == AC_chan) {
- _egg_data->remove_child(scene_group);
- } else {
- scene_group->set_dart_type(EggGroup::DT_default);
- }
- }
-
- if (get_animation_convert() != AC_model) {
- _table = new EggTable();
- _table->set_table_type(EggTable::TT_table);
- _egg_data->add_child(_table);
-
- PT(EggTable) bundle = new EggTable(model_name);
- bundle->set_table_type(EggTable::TT_bundle);
- _table->add_child(bundle);
-
- PT(EggTable) skeleton = new EggTable("");
- skeleton->set_table_type(EggTable::TT_table);
- bundle->add_child(skeleton);
-
- pset keys;
-
- Characters::iterator it;
- DaeCharacter *character;
- for (it = _characters.begin(); it != _characters.end(); ++it) {
- character = *it;
-
- // Collect key frame timings.
- if (get_animation_convert() == AC_both ||
- get_animation_convert() == AC_chan) {
- character->collect_keys(keys);
- }
- }
-
- if (_frame_inc != 0.0) {
- // A frame increment was given, this means that we have to sample the
- // animation.
- float start, end;
- if (_end_frame != _start_frame) {
- start = _start_frame;
- end = _end_frame;
- } else {
- // No range was given. Infer the frame range from the keys.
- start = *keys.begin();
- end = *keys.rbegin();
- }
- keys.clear();
-
- for (float t = start; t <= end; t += _frame_inc) {
- keys.insert(t);
- }
- } else {
- // No sampling parameters given; not necessarily a failure, since the
- // animation may already be sampled. We use the key frames as
- // animation frames.
- if (_end_frame != 0.0) {
- // An end frame was given, chop off all keys after that.
- float end = _end_frame;
- pset::iterator ki;
- for (ki = keys.begin(); ki != keys.end(); ++ki) {
- if (*ki > end && !IS_THRESHOLD_EQUAL(*ki, end, 0.001)) {
- keys.erase(ki, keys.end());
- break;
- }
- }
- }
- if (_start_frame != 0.0) {
- // A start frame was given, chop off all keys before that.
- float start = _start_frame;
- pset::iterator ki;
- for (ki = keys.begin(); ki != keys.end(); ++ki) {
- if (*ki > start && !IS_THRESHOLD_EQUAL(*ki, start, 0.001)) {
- keys.erase(keys.begin(), ki);
- break;
- }
- }
- }
-
- // Check that this does indeed look like a sampled animation; if not,
- // issue an appropriate warning.
- pset::const_iterator ki = keys.begin();
- if (ki != keys.end()) {
- float last = *ki;
- float diff = 0;
-
- for (++ki; ki != keys.end(); ++ki) {
- if (diff != 0 && !IS_THRESHOLD_EQUAL((*ki - last), diff, 0.001)) {
- daeegg_cat.error()
- << "This does not appear to be a sampled animation.\n"
- << "Specify the -sf, -ef and -if options to indicate how the "
- << "animations should be sampled.\n";
- break;
- }
- diff = (*ki - last);
- last = *ki;
- }
- }
- }
-
- // It doesn't really matter which character we grab for this as it'll
- // iterate over the whole graph right now anyway.
- for (size_t ch = 0; ch < visual_scene->GetChildrenCount(); ++ch) {
- character->build_table(skeleton, visual_scene->GetChild(ch), keys);
- }
- }
- }
-
- // Clean up and return
- SAFE_DELETE(visual_scene);
- SAFE_DELETE(_document);
- FCollada::Release();
- return true;
-}
-
-/**
- * This may be called after convert_file() has been called and returned true,
- * indicating a successful conversion. It will return the distance units
- * represented by the converted egg file, if known, or DU_invalid if not
- * known.
- */
-DistanceUnit DAEToEggConverter::
-get_input_units() {
- if (IS_NEARLY_EQUAL(_unit_meters, 0.001)) {
- return DU_millimeters;
- }
- if (IS_NEARLY_EQUAL(_unit_meters, 0.01)) {
- return DU_centimeters;
- }
- if (IS_NEARLY_EQUAL(_unit_meters, 1.0)) {
- return DU_meters;
- }
- if (IS_NEARLY_EQUAL(_unit_meters, 1000.0)) {
- return DU_kilometers;
- }
- if (IS_NEARLY_EQUAL(_unit_meters, 3.0 * 12.0 * 0.0254)) {
- return DU_yards;
- }
- if (IS_NEARLY_EQUAL(_unit_meters, 12.0 * 0.0254)) {
- return DU_feet;
- }
- if (IS_NEARLY_EQUAL(_unit_meters, 0.0254)) {
- return DU_inches;
- }
- if (IS_NEARLY_EQUAL(_unit_meters, 1852.0)) {
- return DU_nautical_miles;
- }
- if (IS_NEARLY_EQUAL(_unit_meters, 5280.0 * 12.0 * 0.0254)) {
- return DU_statute_miles;
- }
-
- // Whatever.
- return DU_invalid;
-}
-
-void DAEToEggConverter::
-process_asset() {
- const FCDAsset *asset = _document->GetAsset();
- if (_document->GetAsset() == nullptr) {
- return;
- }
-
- _unit_name = FROM_FSTRING(asset->GetUnitName());
- _unit_meters = asset->GetUnitConversionFactor();
-
- // Read out the coordinate system
- FMVector3 up_axis = asset->GetUpAxis();
-
- if (up_axis == FMVector3(0, 1, 0)) {
- _egg_data->set_coordinate_system(CS_yup_right);
-
- } else if (up_axis == FMVector3(0, 0, 1)) {
- _egg_data->set_coordinate_system(CS_zup_right);
-
- } else {
- _egg_data->set_coordinate_system(CS_invalid);
- daeegg_cat.warning() << "Unrecognized coordinate system!\n";
- }
-}
-
-// Process the node. If forced is true, it will even process it if its known
-// to be a skeleton root.
-void DAEToEggConverter::
-process_node(EggGroupNode *parent, const FCDSceneNode* node, bool forced) {
- nassertv(node != nullptr);
- string node_id = FROM_FSTRING(node->GetDaeId());
- if (daeegg_cat.is_spam()) {
- daeegg_cat.spam() << "Processing node with ID '" << node_id << "'" << endl;
- }
-
- // Create an egg group for this node
- PT(EggGroup) node_group = new EggGroup(FROM_FSTRING(node->GetDaeId()));
- process_extra(node_group, node->GetExtra());
- parent->add_child(node_group);
-
- // Check if its a joint
- if (node->IsJoint()) {
- string sid = FROM_FSTRING(node->GetSubId());
- node_group->set_group_type(EggGroup::GT_joint);
-
- if (!_joints.insert(DaeCharacter::JointMap::value_type(sid,
- DaeCharacter::Joint(node_group, node))).second) {
- daeegg_cat.error()
- << "Joint with sid " << sid << " occurs more than once!\n";
- }
- }
-
- // Loop through the transforms and apply them (in reverse order)
- for (size_t tr = node->GetTransformCount(); tr > 0; --tr) {
- apply_transform(node_group, node->GetTransform(tr - 1));
- }
- // node_group->set_transform3d(convert_matrix(node->ToMatrix()));
-
- // Loop through the instances and process them
- for (size_t in = 0; in < node->GetInstanceCount(); ++in) {
- process_instance(node_group, node->GetInstance(in));
- }
-
- // Loop through the children and recursively process them
- for (size_t ch = 0; ch < node->GetChildrenCount(); ++ch) {
- process_node(DCAST(EggGroupNode, node_group), node->GetChild(ch));
- }
-
- // Loop through any possible scene node instances and process those, too.
- for (size_t in = 0; in < node->GetInstanceCount(); ++in) {
- const FCDEntity *entity = node->GetInstance(in)->GetEntity();
- if (entity && entity->GetType() == FCDEntity::SCENE_NODE) {
- process_node(node_group, (const FCDSceneNode*) entity);
- }
- }
-}
-
-void DAEToEggConverter::
-process_instance(EggGroup *parent, const FCDEntityInstance* instance) {
- nassertv(instance != nullptr);
- nassertv(instance->GetEntity() != nullptr);
- // Check what kind of instance this is
- switch (instance->GetType()) {
- case FCDEntityInstance::GEOMETRY:
- {
- if (get_animation_convert() != AC_chan) {
- const FCDGeometry* geometry = (const FCDGeometry*) instance->GetEntity();
- assert(geometry != nullptr);
- if (geometry->IsMesh()) {
- // Now, handle the mesh.
- process_mesh(parent, geometry->GetMesh(), new DaeMaterials((const FCDGeometryInstance*) instance));
- }
- if (geometry->IsSpline()) {
- process_spline(parent, FROM_FSTRING(geometry->GetName()), const_cast (geometry->GetSpline()));
- }
- }
- }
- break;
-
- case FCDEntityInstance::CONTROLLER:
- // Add the dart tag and process the controller instance
- // parent->set_dart_type(EggGroup::DT_default);
- process_controller(parent, (const FCDControllerInstance*) instance);
- break;
-
- case FCDEntityInstance::MATERIAL:
- // We don't process this directly, handled per-geometry instead.
- break;
-
- case FCDEntityInstance::SIMPLE:
- {
- // Grab the entity and check its type.
- const FCDEntity* entity = instance->GetEntity();
- if (entity->GetType() != FCDEntity::SCENE_NODE) {
- daeegg_cat.warning() << "Unsupported entity type found" << endl;
- }
- }
- break;
-
- default:
- daeegg_cat.warning() << "Unsupported instance type found" << endl;
- }
-}
-
-// Processes the given mesh.
-void DAEToEggConverter::
-process_mesh(EggGroup *parent, const FCDGeometryMesh* mesh,
- DaeMaterials *materials, DaeCharacter *character) {
-
- nassertv(mesh != nullptr);
- if (daeegg_cat.is_debug()) {
- daeegg_cat.debug() << "Processing mesh with id " << FROM_FSTRING(mesh->GetDaeId()) << endl;
- }
-
- // Create the egg stuff to hold this mesh
- PT(EggGroup) mesh_group = new EggGroup(FROM_FSTRING(mesh->GetDaeId()));
- parent->add_child(mesh_group);
- PT(EggVertexPool) mesh_pool = new EggVertexPool(FROM_FSTRING(mesh->GetDaeId()));
- mesh_group->add_child(mesh_pool);
-
- // First retrieve the vertex source
- if (mesh->GetSourceCount() == 0) {
- if (daeegg_cat.is_debug()) {
- daeegg_cat.debug() << "Mesh with id " << FROM_FSTRING(mesh->GetDaeId()) << " has no sources" << endl;
- }
- return;
- }
- const FCDGeometrySource* vsource = mesh->FindSourceByType(FUDaeGeometryInput::POSITION);
- if (vsource == nullptr) {
- if (daeegg_cat.is_debug()) {
- daeegg_cat.debug() << "Mesh with id " << FROM_FSTRING(mesh->GetDaeId()) << " has no source for POSITION data" << endl;
- }
- return;
- }
-
- // Loop through the polygon groups and add them
- if (daeegg_cat.is_spam()) {
- daeegg_cat.spam() << "Mesh with id " << FROM_FSTRING(mesh->GetDaeId()) << " has " << mesh->GetPolygonsCount() << " polygon groups" << endl;
- }
- if (mesh->GetPolygonsCount() == 0) return;
-
- // This is an array of pointers, I know. But since they are refcounted, I
- // don't have a better idea.
- PT(EggGroup) *primitive_holders = new PT(EggGroup) [mesh->GetPolygonsCount()];
- for (size_t gr = 0; gr < mesh->GetPolygonsCount(); ++gr) {
- const FCDGeometryPolygons* polygons = mesh->GetPolygons(gr);
- string material_semantic = FROM_FSTRING(polygons->GetMaterialSemantic());
-
- // Stores which group holds the primitives.
- PT(EggGroup) primitiveholder;
- // If we have materials, make a group for each material. Then, apply the
- // material's per-group stuff.
- if (materials != nullptr && (!polygons->GetMaterialSemantic().empty()) && mesh->GetPolygonsCount() > 1) {
- // primitiveholder = new EggGroup(FROM_FSTRING(mesh->GetDaeId()) + "." +
- // material_semantic);
- primitiveholder = new EggGroup;
- mesh_group->add_child(primitiveholder);
- } else {
- primitiveholder = mesh_group;
- }
- primitive_holders[gr] = primitiveholder;
- // Apply the per-group data of the materials, if we have it.
- if (materials != nullptr) {
- materials->apply_to_group(material_semantic, primitiveholder, _invert_transparency);
- }
- // Find the position sources
- const FCDGeometryPolygonsInput* pinput = polygons->FindInput(FUDaeGeometryInput::POSITION);
- assert(pinput != nullptr);
- const uint32* indices = pinput->GetIndices();
- // Find the normal sources
- const FCDGeometrySource* nsource = mesh->FindSourceByType(FUDaeGeometryInput::NORMAL);
- const FCDGeometryPolygonsInput* ninput = polygons->FindInput(FUDaeGeometryInput::NORMAL);
- const uint32* nindices;
- if (ninput != nullptr) nindices = ninput->GetIndices();
- // Find texcoord sources
- const FCDGeometrySource* tcsource = mesh->FindSourceByType(FUDaeGeometryInput::TEXCOORD);
- const FCDGeometryPolygonsInput* tcinput = polygons->FindInput(FUDaeGeometryInput::TEXCOORD);
- const uint32* tcindices;
- if (tcinput != nullptr) tcindices = tcinput->GetIndices();
- // Find vcolor sources
- const FCDGeometrySource* csource = mesh->FindSourceByType(FUDaeGeometryInput::COLOR);
- const FCDGeometryPolygonsInput* cinput = polygons->FindInput(FUDaeGeometryInput::COLOR);
- const uint32* cindices;
- if (cinput != nullptr) cindices = cinput->GetIndices();
- // Find binormal sources
- const FCDGeometrySource* bsource = mesh->FindSourceByType(FUDaeGeometryInput::TEXBINORMAL);
- const FCDGeometryPolygonsInput* binput = polygons->FindInput(FUDaeGeometryInput::TEXBINORMAL);
- const uint32* bindices;
- if (binput != nullptr) bindices = binput->GetIndices();
- // Find tangent sources
- const FCDGeometrySource* tsource = mesh->FindSourceByType(FUDaeGeometryInput::TEXTANGENT);
- const FCDGeometryPolygonsInput* tinput = polygons->FindInput(FUDaeGeometryInput::TEXTANGENT);
- const uint32* tindices;
- if (tinput != nullptr) tindices = tinput->GetIndices();
- // Get a name for potential coordinate sets
- string tcsetname;
- if (materials != nullptr && tcinput != nullptr) {
- if (daeegg_cat.is_debug()) {
- daeegg_cat.debug()
- << "Assigning texcoord set " << tcinput->GetSet()
- << " to semantic '" << material_semantic << "'\n";
- }
- tcsetname = materials->get_uvset_name(material_semantic,
- FUDaeGeometryInput::TEXCOORD, tcinput->GetSet());
- }
- string tbsetname;
- if (materials != nullptr && binput != nullptr) {
- if (daeegg_cat.is_debug()) {
- daeegg_cat.debug()
- << "Assigning texbinormal set " << binput->GetSet()
- << " to semantic '" << material_semantic << "'\n";
- }
- tbsetname = materials->get_uvset_name(material_semantic,
- FUDaeGeometryInput::TEXBINORMAL, binput->GetSet());
- }
- string ttsetname;
- if (materials != nullptr && tinput != nullptr) {
- if (daeegg_cat.is_debug()) {
- daeegg_cat.debug()
- << "Assigning textangent set " << tinput->GetSet()
- << " to semantic '" << material_semantic << "'\n";
- }
- ttsetname = materials->get_uvset_name(material_semantic,
- FUDaeGeometryInput::TEXTANGENT, tinput->GetSet());
- }
- // Loop through the indices and add the vertices.
- for (size_t ix = 0; ix < pinput->GetIndexCount(); ++ix) {
- PT_EggVertex vertex = mesh_pool->make_new_vertex();
- const float* data = &vsource->GetData()[indices[ix]*3];
- vertex->set_pos(LPoint3d(data[0], data[1], data[2]));
-
- if (character != nullptr) {
- // If this is skinned geometry, add the vertex influences.
- character->influence_vertex(indices[ix], vertex);
- }
-
- // Process the normal
- if (nsource != nullptr && ninput != nullptr) {
- assert(nsource->GetStride() == 3);
- data = &nsource->GetData()[nindices[ix]*3];
- vertex->set_normal(LVecBase3d(data[0], data[1], data[2]));
- }
- // Process the texcoords
- if (tcsource != nullptr && tcinput != nullptr) {
- assert(tcsource->GetStride() == 2 || tcsource->GetStride() == 3);
- data = &tcsource->GetData()[tcindices[ix]*tcsource->GetStride()];
- if (tcsource->GetStride() == 2) {
- vertex->set_uv(tcsetname, LPoint2d(data[0], data[1]));
- } else {
- vertex->set_uvw(tcsetname, LPoint3d(data[0], data[1], data[2]));
- }
- }
- // Process the color
- if (csource != nullptr && cinput != nullptr) {
- assert(csource->GetStride() == 3 || csource->GetStride() == 4);
- if (csource->GetStride() == 3) {
- data = &csource->GetData()[cindices[ix]*3];
- vertex->set_color(LColor(data[0], data[1], data[2], 1.0f));
- } else {
- data = &csource->GetData()[cindices[ix]*4];
- vertex->set_color(LColor(data[0], data[1], data[2], data[3]));
- }
- }
- // Possibly add a UV object
- if ((bsource != nullptr && binput != nullptr) || (tsource != nullptr && tinput != nullptr)) {
- if (bsource != nullptr && binput != nullptr) {
- assert(bsource->GetStride() == 3);
- data = &bsource->GetData()[bindices[ix]*3];
- PT(EggVertexUV) uv_obj = vertex->modify_uv_obj(tbsetname);
- if (uv_obj == nullptr) {
- uv_obj = new EggVertexUV(tbsetname, LTexCoordd());
- }
- uv_obj->set_binormal(LVecBase3d(data[0], data[1], data[2]));
- }
- if (tsource != nullptr && tinput != nullptr) {
- assert(tsource->GetStride() == 3);
- data = &tsource->GetData()[tindices[ix]*3];
- PT(EggVertexUV) uv_obj = vertex->modify_uv_obj(ttsetname);
- if (uv_obj == nullptr) {
- uv_obj = new EggVertexUV(ttsetname, LTexCoordd());
- }
- uv_obj->set_tangent(LVecBase3d(data[0], data[1], data[2]));
- }
- }
- vertex->transform(parent->get_node_to_vertex());
- }
- }
- // Loop again for the polygons
- for (size_t gr = 0; gr < mesh->GetPolygonsCount(); ++gr) {
- const FCDGeometryPolygons* polygons = mesh->GetPolygons(gr);
- // Now loop through the faces
- uint32 offset = 0;
- for (size_t fa = 0; fa < polygons->GetFaceVertexCountCount(); ++fa) {
- PT(EggPrimitive) primitive = nullptr;
- // Create a primitive that matches the fcollada type
- switch (polygons->GetPrimitiveType()) {
- case FCDGeometryPolygons::LINES:
- primitive = new EggLine();
- break;
- case FCDGeometryPolygons::POLYGONS:
- primitive = new EggPolygon();
- break;
- case FCDGeometryPolygons::TRIANGLE_FANS:
- primitive = new EggTriangleFan();
- break;
- case FCDGeometryPolygons::TRIANGLE_STRIPS:
- primitive = new EggTriangleStrip();
- break;
- case FCDGeometryPolygons::POINTS:
- primitive = new EggPoint();
- break;
- case FCDGeometryPolygons::LINE_STRIPS:
- daeegg_cat.warning() << "Linestrips not yet supported!" << endl;
- break;
- default:
- daeegg_cat.warning() << "Unsupported primitive type found!" << endl;
- }
- if (primitive != nullptr) {
- primitive_holders[gr]->add_child(primitive);
- if (materials != nullptr) {
- materials->apply_to_primitive(FROM_FSTRING(polygons->GetMaterialSemantic()), primitive);
- }
- for (size_t ve = 0; ve < polygons->GetFaceVertexCount(fa); ++ve) {
- assert(mesh_pool->has_vertex(ve + polygons->GetFaceVertexOffset() + offset));
- primitive->add_vertex(mesh_pool->get_vertex(ve + polygons->GetFaceVertexOffset() + offset));
- }
- }
- offset += polygons->GetFaceVertexCount(fa);
- }
- }
- delete[] primitive_holders;
-}
-
-void DAEToEggConverter::
-process_spline(EggGroup *parent, const string group_name, FCDGeometrySpline* geometry_spline) {
- assert(geometry_spline != nullptr);
- PT(EggGroup) result = new EggGroup(group_name);
- parent->add_child(result);
- // TODO: if its not a nurbs, make it convert between the types
- if (geometry_spline->GetType() != FUDaeSplineType::NURBS) {
- daeegg_cat.warning() << "Only NURBS curves are supported (yet)!" << endl;
- } else {
- // Loop through the splines
- for (size_t sp = 0; sp < geometry_spline->GetSplineCount(); ++sp) {
- process_spline(result, geometry_spline->GetSpline(sp));
- }
- }
-}
-
-void DAEToEggConverter::
-process_spline(EggGroup *parent, const FCDSpline* spline) {
- assert(spline != nullptr);
- nassertv(spline->GetSplineType() == FUDaeSplineType::NURBS);
- // Now load in the nurbs curve to the egg library
- PT(EggNurbsCurve) nurbs_curve = new EggNurbsCurve(FROM_FSTRING(spline->GetName()));
- parent->add_child(nurbs_curve);
- // TODO: what value is this?
- nurbs_curve->setup(0, ((const FCDNURBSSpline*) spline)->GetKnotCount());
- for (size_t kn = 0; kn < ((const FCDNURBSSpline*) spline)->GetKnotCount(); ++kn) {
- const float* knot = ((const FCDNURBSSpline*) spline)->GetKnot(kn);
- assert(knot != nullptr);
- nurbs_curve->set_knot(kn, *knot);
- }
- for (size_t cv = 0; cv < spline->GetCVCount(); ++cv) {
- PT_EggVertex c_vtx = new EggVertex();
- c_vtx->set_pos(TO_VEC3(*spline->GetCV(cv)));
- c_vtx->transform(parent->get_node_to_vertex());
- nurbs_curve->add_vertex(c_vtx);
- }
-}
-
-void DAEToEggConverter::
-process_controller(EggGroup *parent, const FCDControllerInstance *instance) {
- assert(instance != nullptr);
- const FCDController* controller = (const FCDController *)instance->GetEntity();
- assert(controller != nullptr);
-
- if (get_animation_convert() == AC_none) {
- // If we're exporting a static mesh, export the base geometry as-is.
- const FCDGeometryMesh *mesh = controller->GetBaseGeometry()->GetMesh();
- if (mesh != nullptr) {
- PT(DaeMaterials) materials = new DaeMaterials(instance);
- if (daeegg_cat.is_spam()) {
- daeegg_cat.spam() << "Processing mesh for controller\n";
- }
- process_mesh(parent, mesh, materials);
- }
- } else {
- // Add a character for this to the table, the mesh is processed later
- PT(DaeCharacter) character = new DaeCharacter(parent, instance);
- _characters.push_back(character);
- }
-
- if (controller->IsMorph()) {
- assert(controller != nullptr);
- const FCDMorphController* morph_controller = controller->GetMorphController();
- assert(morph_controller != nullptr);
- PT(EggTable) bundle = new EggTable(parent->get_name());
- bundle->set_table_type(EggTable::TT_bundle);
- PT(EggTable) morph = new EggTable("morph");
- morph->set_table_type(EggTable::TT_table);
- bundle->add_child(morph);
- // Loop through the morph targets.
- for (size_t mt = 0; mt < morph_controller->GetTargetCount(); ++mt) {
- const FCDMorphTarget* morph_target = morph_controller->GetTarget(mt);
- assert(morph_target != nullptr);
- PT(EggSAnimData) target = new EggSAnimData(FROM_FSTRING(morph_target->GetGeometry()->GetName()));
- if (morph_target->IsAnimated()) {
- // TODO
- } else {
- target->add_data(morph_target->GetWeight());
- }
- morph->add_child(target);
- }
- }
-}
-
-void DAEToEggConverter::
-process_extra(EggGroup *group, const FCDExtra* extra) {
- if (extra == nullptr) {
- return;
- }
- nassertv(group != nullptr);
-
- const FCDEType* etype = extra->GetDefaultType();
- if (etype == nullptr) {
- return;
- }
-
- const FCDENode* enode = (const FCDENode*) etype->FindTechnique("PANDA3D");
- if (enode == nullptr) {
- return;
- }
-
- FCDENodeList tags;
- enode->FindChildrenNodes("param", tags);
- for (FCDENodeList::iterator it = tags.begin(); it != tags.end(); ++it) {
- const FCDEAttribute* attr = (*it)->FindAttribute("sid");
- if (attr) {
- group->set_tag(FROM_FSTRING(attr->GetValue()), (*it)->GetContent());
- }
- }
-}
-
-LMatrix4d DAEToEggConverter::
-convert_matrix(const FMMatrix44 &matrix) {
- return LMatrix4d(
- matrix[0][0], matrix[0][1], matrix[0][2], matrix[0][3],
- matrix[1][0], matrix[1][1], matrix[1][2], matrix[1][3],
- matrix[2][0], matrix[2][1], matrix[2][2], matrix[2][3],
- matrix[3][0], matrix[3][1], matrix[3][2], matrix[3][3]);
-}
-
-void DAEToEggConverter::
-apply_transform(EggGroup *to, const FCDTransform* from) {
- assert(from != nullptr);
- assert(to != nullptr);
- // to->set_transform3d(convert_matrix(from->ToMatrix()) *
- // to->get_transform3d());
- switch (from->GetType()) {
- case FCDTransform::TRANSLATION:
- {
- const FCDTTranslation *trans = (const FCDTTranslation *)from;
- to->add_translate3d(TO_VEC3(trans->GetTranslation()));
- }
- break;
-
- case FCDTransform::ROTATION:
- {
- const FCDTRotation *rot = (const FCDTRotation *)from;
- to->add_rotate3d(rot->GetAngle(), TO_VEC3(rot->GetAxis()));
- }
- break;
-
- case FCDTransform::SCALE:
- {
- const FCDTScale *scale = (const FCDTScale *)from;
- to->add_scale3d(TO_VEC3(scale->GetScale()));
- }
- break;
-
- default:
- // Either a matrix, or something we can't handle.
- to->add_matrix4(convert_matrix(from->ToMatrix()));
- break;
- }
-}
diff --git a/pandatool/src/daeegg/daeToEggConverter.h b/pandatool/src/daeegg/daeToEggConverter.h
deleted file mode 100644
index bb3b6f55..00000000
--- a/pandatool/src/daeegg/daeToEggConverter.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file daeToEggConverter.h
- * @author rdb
- * @date 2008-05-08
- */
-
-#ifndef DAETOEGGCONVERTER_H
-#define DAETOEGGCONVERTER_H
-
-#include "pandatoolbase.h"
-#include "somethingToEggConverter.h"
-#include "eggGroup.h"
-#include "eggMaterial.h"
-#include "eggTexture.h"
-#include "eggTable.h"
-#include "eggNurbsCurve.h"
-
-#include "pre_fcollada_include.h"
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "daeMaterials.h"
-#include "daeCharacter.h"
-#include "pvector.h" // Include last
-
-/**
- * This class supervises the construction of an EggData structure from a DAE
- * file.
- */
-class DAEToEggConverter : public SomethingToEggConverter {
-public:
- DAEToEggConverter();
- DAEToEggConverter(const DAEToEggConverter ©);
- ~DAEToEggConverter();
-
- virtual SomethingToEggConverter *make_copy();
-
- virtual std::string get_name() const;
- virtual std::string get_extension() const;
-
- virtual bool convert_file(const Filename &filename);
- virtual DistanceUnit get_input_units();
-
- bool _invert_transparency;
-
-private:
- std::string _unit_name;
- double _unit_meters;
- PT(EggTable) _table;
- FCDocument* _document;
- FUErrorSimpleHandler* _error_handler;
- DaeCharacter::JointMap _joints;
-
- typedef pvector Characters;
- Characters _characters;
-
- void process_asset();
- void process_node(EggGroupNode *parent, const FCDSceneNode* node, bool forced = false);
- void process_instance(EggGroup *parent, const FCDEntityInstance* instance);
- void process_mesh(EggGroup *parent, const FCDGeometryMesh* mesh,
- DaeMaterials *materials, DaeCharacter *character = nullptr);
- void process_spline(EggGroup *parent, const std::string group_name, FCDGeometrySpline* geometry_spline);
- void process_spline(EggGroup *parent, const FCDSpline* spline);
- void process_controller(EggGroup *parent, const FCDControllerInstance* instance);
- void process_extra(EggGroup *group, const FCDExtra* extra);
-
- static LMatrix4d convert_matrix(const FMMatrix44& matrix);
- void apply_transform(EggGroup *to, const FCDTransform* from);
-
- friend class DaeCharacter;
-};
-
-#endif
diff --git a/pandatool/src/daeegg/fcollada_utils.h b/pandatool/src/daeegg/fcollada_utils.h
deleted file mode 100644
index 3a8ae692..00000000
--- a/pandatool/src/daeegg/fcollada_utils.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fcollada_utils.h
- * @author rdb
- * @date 2008-12-22
- */
-
-// This file defines some conversion tools for conversion between FCollada and
-// Panda3D
-
-#ifndef FCOLLADA_UTILS_H
-#define FCOLLADA_UTILS_H
-
-#include "pre_fcollada_include.h"
-#include
-
-// Useful conversion stuff
-inline LVecBase3d TO_VEC3(FMVector3 v) {
- return LVecBase3d(v.x, v.y, v.z);
-}
-inline LVecBase4d TO_VEC4(FMVector4 v) {
- return LVecBase4d(v.x, v.y, v.z, v.w);
-}
-inline LColor TO_COLOR(FMVector4 v) {
- return LColor(v.x, v.y, v.z, v.w);
-}
-#define FROM_VEC3(v) (FMVector3(v[0], v[1], v[2]))
-#define FROM_VEC4(v) (FMVector4(v[0], v[1], v[2], v[3]))
-#define FROM_MAT4(v) (FMMatrix44(v.getData()))
-#define FROM_FSTRING(fs) (std::string(fs.c_str()))
-
-#endif
diff --git a/pandatool/src/daeegg/p3daeegg_composite1.cxx b/pandatool/src/daeegg/p3daeegg_composite1.cxx
deleted file mode 100644
index be3f927d..00000000
--- a/pandatool/src/daeegg/p3daeegg_composite1.cxx
+++ /dev/null
@@ -1,5 +0,0 @@
-
-#include "config_daeegg.cxx"
-#include "daeCharacter.cxx"
-#include "daeMaterials.cxx"
-#include "daeToEggConverter.cxx"
diff --git a/pandatool/src/daeegg/pre_fcollada_include.h b/pandatool/src/daeegg/pre_fcollada_include.h
deleted file mode 100644
index 59ad054c..00000000
--- a/pandatool/src/daeegg/pre_fcollada_include.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file pre_fcollada_include.h
- * @author rdb
- * @date 2008-10-04
- */
-
-// This file defines some stuff that need to be defined before one includes
-// FCollada.h
-
-#ifndef PRE_FCOLLADA_INCLUDE_H
-#define PRE_FCOLLADA_INCLUDE_H
-
-#ifdef FCOLLADA_VERSION
- #error You must include pre_fcollada_include.h before including FCollada.h!
-#endif
-
-#ifdef _WIN32
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN 1
-#endif
-#include
-#endif
-
-// FCollada expects LINUX to be defined on linux
-#ifdef IS_LINUX
- #ifndef LINUX
- #define LINUX
- #endif
-#endif
-
-#define NO_LIBXML
-#define FCOLLADA_NOMINMAX
-
-// FCollada does use global min/max.
-using std::min;
-using std::max;
-
-#endif
diff --git a/pandatool/src/daeprogs/CMakeLists.txt b/pandatool/src/daeprogs/CMakeLists.txt
deleted file mode 100644
index 42cd2f48..00000000
--- a/pandatool/src/daeprogs/CMakeLists.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-if(NOT BUILD_TOOLS)
- return()
-endif()
-
-if(HAVE_EGG AND HAVE_FCOLLADA)
-
- add_executable(dae2egg daeToEgg.cxx daeToEgg.h)
- target_link_libraries(dae2egg p3daeegg p3eggbase p3progbase)
- install(TARGETS dae2egg EXPORT Tools COMPONENT Tools DESTINATION ${CMAKE_INSTALL_BINDIR})
-
-endif()
diff --git a/pandatool/src/daeprogs/daeToEgg.cxx b/pandatool/src/daeprogs/daeToEgg.cxx
deleted file mode 100644
index e0074734..00000000
--- a/pandatool/src/daeprogs/daeToEgg.cxx
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file daeToEgg.cxx
- * @author rdb
- * @date 2008-05-08
- */
-
-#include "daeToEgg.h"
-
-#include "daeToEggConverter.h"
-
-/**
- *
- */
-DAEToEgg::
-DAEToEgg():
- SomethingToEgg("COLLADA", ".dae")
-{
- add_animation_options();
- add_units_options();
- add_normals_options();
- add_transform_options();
-
- add_option
- ("invtrans", "", false,
- "Import the .dae file using inverted transparency. "
- "This is useful when importing COLLADA files from some authoring tools "
- "that export models with inverted transparency, such as Google SketchUp.",
- &SomethingToEgg::dispatch_none, &_invert_transparency);
-
- set_program_brief("convert COLLADA assets into .egg files");
- set_program_description
- ("This program converts .dae files (COLLADA Digital Asset Exchange) to .egg.");
-
- _coordinate_system = CS_yup_right;
- _animation_convert = AC_both;
-}
-
-/**
- *
- */
-void DAEToEgg::
-run() {
- if (_animation_convert != AC_both && _animation_convert != AC_none &&
- _animation_convert != AC_chan && _animation_convert != AC_model) {
- std::cerr << "Unsupported animation convert option.\n";
- exit(1);
- }
-
- nout << "Reading " << _input_filename << "\n";
-
- _data->set_coordinate_system(_coordinate_system);
-
- DAEToEggConverter converter;
- converter.set_egg_data(_data);
- converter._allow_errors = _allow_errors;
- converter._invert_transparency = _invert_transparency;
-
- apply_parameters(converter);
-
- if (!converter.convert_file(_input_filename)) {
- nout << "Errors in conversion.\n";
- exit(1);
- }
-
- write_egg_file();
- nout << "\n";
-}
-
-
-int main(int argc, char *argv[]) {
- DAEToEgg prog;
- prog.parse_command_line(argc, argv);
- prog.run();
- return 0;
-}
diff --git a/pandatool/src/daeprogs/daeToEgg.h b/pandatool/src/daeprogs/daeToEgg.h
deleted file mode 100644
index 7b7eb3aa..00000000
--- a/pandatool/src/daeprogs/daeToEgg.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file daeToEgg.h
- * @author rdb
- * @date 2008-05-08
- */
-
-#ifndef DAETOEGG_H
-#define DAETOEGG_H
-
-#include "pandatoolbase.h"
-
-#include "somethingToEgg.h"
-#include "daeToEggConverter.h"
-
-/**
- * A program to read a DAE file and generate an egg file.
- */
-class DAEToEgg : public SomethingToEgg {
-public:
- DAEToEgg();
-
- void run();
-
-private:
- bool _invert_transparency;
-};
-
-#endif
diff --git a/pandatool/src/daeprogs/eggToDAE.cxx b/pandatool/src/daeprogs/eggToDAE.cxx
deleted file mode 100644
index d3c616c3..00000000
--- a/pandatool/src/daeprogs/eggToDAE.cxx
+++ /dev/null
@@ -1,173 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggToDAE.cxx
- * @author rdb
- * @date 2008-10-04
- */
-
-#include "eggToDAE.h"
-#include "dcast.h"
-#include "pandaVersion.h"
-
-#include
-#include
-#include
-
-// Useful conversion stuff
-#define TO_VEC3(v) (LVecBase3d(v[0], v[1], v[2]))
-#define TO_VEC4(v) (LVecBase4d(v[0], v[1], v[2], v[3]))
-#define TO_COLOR(v) (LColor(v[0], v[1], v[2], v[3]))
-#define FROM_VEC3(v) (FMVector3(v[0], v[1], v[2]))
-#define FROM_VEC4(v) (FMVector4(v[0], v[1], v[2], v[3]))
-#define FROM_MAT4(v) (FMMatrix44(v.get_data()))
-#define FROM_FSTRING(fs) (fs.c_str())
-
-using std::cerr;
-
-/**
- *
- */
-EggToDAE::
-EggToDAE() :
- EggToSomething("COLLADA", ".dae", true, false)
-{
- set_binary_output(false);
- set_program_brief("convert .egg files into COLLADA asset files");
- set_program_description
- ("This program converts files from the egg format to the COLLADA "
- ".dae (Digital Asset Exchange) format.");
-
- _document = nullptr;
-}
-
-/**
- *
- */
-void EggToDAE::
-run() {
- nassertv(has_output_filename());
- nassertv(_data != nullptr);
-
- FCollada::Initialize();
- _document = FCollada::NewTopDocument();
-
- // Add the contributor part to the asset
- FCDAssetContributor* contributor = _document->GetAsset()->AddContributor();
- const char* user_name = getenv("USER");
- if (user_name == nullptr) user_name = getenv("USERNAME");
- if (user_name != nullptr) contributor->SetAuthor(TO_FSTRING(user_name));
- // contributor->SetSourceData();
- char authoring_tool[1024];
- snprintf(authoring_tool, 1024, "Panda3D %s eggToDAE converter | FCollada v%d.%02d", PANDA_VERSION_STR, FCOLLADA_VERSION >> 16, FCOLLADA_VERSION & 0xFFFF);
- authoring_tool[1023] = 0;
- contributor->SetAuthoringTool(TO_FSTRING(authoring_tool));
-
- // Set coordinate system
- switch (_data->get_coordinate_system()) {
- case CS_zup_right:
- _document->GetAsset()->SetUpAxis(FMVector3::ZAxis);
- break;
- case CS_yup_right:
- _document->GetAsset()->SetUpAxis(FMVector3::YAxis);
- break;
- }
-
- // Now actually start processing the data.
- FCDSceneNode* visual_scene = _document->AddVisualScene();
- for (EggGroupNode::iterator it = _data->begin(); it != _data->end(); ++it) {
- if ((*it)->is_of_type(EggGroup::get_class_type())) {
- process_node(visual_scene, DCAST(EggGroup, *it));
- }
- }
-
- // We're done here.
- FCollada::SaveDocument(_document, get_output_filename().to_os_specific().c_str());
- SAFE_DELETE(_document);
- FCollada::Release();
-
- // if (!out) { nout << "An error occurred while writing.\n"; exit(1); }
-}
-
-void EggToDAE::process_node(FCDSceneNode* parent, const PT(EggGroup) node) {
- assert(node != nullptr);
- FCDSceneNode* scene_node = parent->AddChildNode();
- // Set the parameters
- scene_node->SetDaeId(node->get_name().c_str());
- scene_node->SetJointFlag(node->is_joint());
- // Apply the transforms
- apply_transform(scene_node, node);
- // Recursively process sub-nodes
- for (EggGroupNode::iterator it = node->begin(); it != node->end(); ++it) {
- if ((*it)->is_of_type(EggGroup::get_class_type())) {
- process_node(scene_node, DCAST(EggGroup, *it));
- }
- }
-}
-
-void EggToDAE::apply_transform(FCDSceneNode* to, const PT(EggGroup) from) {
- assert(to != nullptr);
- assert(from != nullptr);
- for (int co = 0; co < from->get_num_components(); ++co) {
- switch (from->get_component_type(co)) {
- case EggTransform::CT_translate2d:
- cerr << "Warning: ignoring non-supported 2d translation\n";
- break;
- case EggTransform::CT_rotate2d:
- cerr << "Warning: ignoring non-supported 2d rotation\n";
- break;
- case EggTransform::CT_scale2d:
- cerr << "Warning: ignoring non-supported 2d scaling\n";
- break;
- case EggTransform::CT_matrix3:
- cerr << "Warning: ignoring non-supported 2d matrix\n";
- break;
- case EggTransform::CT_translate3d: {
- FCDTTranslation* new_transform = (FCDTTranslation*) to->AddTransform(FCDTransform::TRANSLATION);
- new_transform->SetTranslation(FROM_VEC3(from->get_component_vec3(co)));
- break; }
- case EggTransform::CT_rotate3d: {
- FCDTRotation* new_transform = (FCDTRotation*) to->AddTransform(FCDTransform::ROTATION);
- new_transform->SetRotation(FROM_VEC3(from->get_component_vec3(co)), from->get_component_number(co));
- break; }
- case EggTransform::CT_scale3d: {
- FCDTScale* new_transform = (FCDTScale*) to->AddTransform(FCDTransform::SCALE);
- new_transform->SetScale(FROM_VEC3(from->get_component_vec3(co)));
- break; }
- case EggTransform::CT_matrix4: {
- FCDTMatrix* new_transform = (FCDTMatrix*) to->AddTransform(FCDTransform::MATRIX);
- new_transform->SetTransform(FROM_MAT4(from->get_component_mat4(co)));
- break; }
- case EggTransform::CT_rotx: {
- FCDTRotation* new_transform = (FCDTRotation*) to->AddTransform(FCDTransform::ROTATION);
- new_transform->SetRotation(FMVector3::XAxis, from->get_component_number(co));
- break; }
- case EggTransform::CT_roty: {
- FCDTRotation* new_transform = (FCDTRotation*) to->AddTransform(FCDTransform::ROTATION);
- new_transform->SetRotation(FMVector3::YAxis, from->get_component_number(co));
- break; }
- case EggTransform::CT_rotz: {
- FCDTRotation* new_transform = (FCDTRotation*) to->AddTransform(FCDTransform::ROTATION);
- new_transform->SetRotation(FMVector3::ZAxis, from->get_component_number(co));
- break; }
- case EggTransform::CT_uniform_scale: {
- FCDTScale* new_transform = (FCDTScale*) to->AddTransform(FCDTransform::SCALE);
- new_transform->SetScale(from->get_component_number(co), from->get_component_number(co), from->get_component_number(co));
- break; }
- default:
- cerr << "Warning: ignoring invalid transform\n";
- }
- }
-}
-
-int main(int argc, char *argv[]) {
- EggToDAE prog;
- prog.parse_command_line(argc, argv);
- prog.run();
- return 0;
-}
diff --git a/pandatool/src/daeprogs/eggToDAE.h b/pandatool/src/daeprogs/eggToDAE.h
deleted file mode 100644
index c7782a42..00000000
--- a/pandatool/src/daeprogs/eggToDAE.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggToDAE.h
- * @author rdb
- * @date 2008-10-04
- */
-
-#ifndef EGGTODAE_H
-#define EGGTODAE_H
-
-#include "pandatoolbase.h"
-#include "eggToSomething.h"
-#include "eggGroup.h"
-#include "eggTransform.h"
-
-#include "pre_fcollada_include.h"
-#include
-#include
-
-/**
- * A program to read an egg file and write a DAE file.
- */
-class EggToDAE : public EggToSomething {
-public:
- EggToDAE();
-
- void run();
-
-private:
- FCDocument* _document;
-
- void process_node(FCDSceneNode* parent, const PT(EggGroup) node);
- void apply_transform(FCDSceneNode* to, const PT(EggGroup) from);
-
-};
-
-#endif
diff --git a/pandatool/src/deploy-stub/CMakeLists.txt b/pandatool/src/deploy-stub/CMakeLists.txt
deleted file mode 100644
index 066d2925..00000000
--- a/pandatool/src/deploy-stub/CMakeLists.txt
+++ /dev/null
@@ -1,42 +0,0 @@
-if(NOT HAVE_PYTHON)
- return()
-endif()
-
-add_executable(deploy-stub deploy-stub.c)
-
-if(IS_OSX)
- target_link_options(deploy-stub PRIVATE -sectcreate __PANDA __panda /dev/null)
- set_target_properties(deploy-stub PROPERTIES
- INSTALL_RPATH "@executable_path"
- BUILD_WITH_INSTALL_RPATH ON)
-
-elseif(WIN32)
- target_sources(deploy-stub PRIVATE frozen_dllmain.c)
-
-elseif(IS_LINUX OR IS_FREEBSD)
- set_target_properties(deploy-stub PROPERTIES
- INSTALL_RPATH "$ORIGIN"
- BUILD_WITH_INSTALL_RPATH ON)
- target_link_options(deploy-stub PRIVATE -Wl,--disable-new-dtags -Wl,-z,origin -rdynamic)
- target_link_libraries(deploy-stub m)
-endif()
-
-target_link_libraries(deploy-stub Python::Python)
-install(TARGETS deploy-stub)
-
-if(WIN32 OR IS_OSX)
- add_executable(deploy-stubw WIN32 deploy-stub.c)
-
- if(IS_OSX)
- target_link_options(deploy-stubw PRIVATE -sectcreate __PANDA __panda /dev/null)
- set_target_properties(deploy-stubw PROPERTIES
- INSTALL_RPATH "@executable_path/../Frameworks"
- BUILD_WITH_INSTALL_RPATH ON)
- target_compile_definitions(deploy-stubw PRIVATE MACOS_APP_BUNDLE=1)
- elseif(WIN32)
- target_sources(deploy-stubw PRIVATE frozen_dllmain.c)
- endif()
-
- target_link_libraries(deploy-stubw Python::Python)
- install(TARGETS deploy-stubw)
-endif()
diff --git a/pandatool/src/deploy-stub/NativeInvocationHandler.java b/pandatool/src/deploy-stub/NativeInvocationHandler.java
deleted file mode 100644
index 2a108373..00000000
--- a/pandatool/src/deploy-stub/NativeInvocationHandler.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.jnius;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-
-/**
- * Special support for pyjnius.
- */
-public class NativeInvocationHandler implements InvocationHandler {
- private long _ptr;
-
- public NativeInvocationHandler(long ptr) {
- _ptr = ptr;
- }
-
- public long getPythonObjectPointer() {
- return _ptr;
- }
-
- public Object invoke(Object proxy, Method method, Object[] args) {
- return invoke0(proxy, method, args);
- }
-
- native Object invoke0(Object proxy, Method method, Object[] args);
-}
diff --git a/pandatool/src/deploy-stub/android_log.c b/pandatool/src/deploy-stub/android_log.c
deleted file mode 100644
index 83b60901..00000000
--- a/pandatool/src/deploy-stub/android_log.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file android_log.c
- * @author rdb
- * @date 2021-12-10
- */
-
-#undef _POSIX_C_SOURCE
-#undef _XOPEN_SOURCE
-#define PY_SSIZE_T_CLEAN 1
-
-#include "Python.h"
-#include
-
-/**
- * Writes a message to the Android log.
- */
-static PyObject *
-_py_write(PyObject *self, PyObject *args) {
- int prio;
- char *tag;
- char *text;
- if (PyArg_ParseTuple(args, "iss", &prio, &tag, &text)) {
- __android_log_write(prio, tag, text);
- Py_RETURN_NONE;
- }
- return NULL;
-}
-
-static PyMethodDef python_simple_funcs[] = {
- { "write", &_py_write, METH_VARARGS },
- { NULL, NULL }
-};
-
-static struct PyModuleDef android_log_module = {
- PyModuleDef_HEAD_INIT,
- "android_log",
- NULL,
- -1,
- python_simple_funcs,
- NULL, NULL, NULL, NULL
-};
-
-__attribute__((visibility("default")))
-PyObject *PyInit_android_log() {
- return PyModule_Create(&android_log_module);
-}
diff --git a/pandatool/src/deploy-stub/android_main.cxx b/pandatool/src/deploy-stub/android_main.cxx
deleted file mode 100644
index d1e140c5..00000000
--- a/pandatool/src/deploy-stub/android_main.cxx
+++ /dev/null
@@ -1,337 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file android_main.cxx
- * @author rdb
- * @date 2021-12-06
- */
-
-#include "config_android.h"
-#include "config_putil.h"
-#include "virtualFileMountAndroidAsset.h"
-#include "virtualFileSystem.h"
-#include "filename.h"
-#include "thread.h"
-#include "urlSpec.h"
-
-#include "android_native_app_glue.h"
-
-#include "Python.h"
-#include "structmember.h"
-
-#include
-#include
-
-#include
-
-// Leave room for future expansion.
-#define MAX_NUM_POINTERS 24
-
-// Define an exposed symbol where we store the offset to the module data.
-extern "C" {
- __attribute__((__visibility__("default"), used))
- volatile struct {
- uint64_t blob_offset;
- uint64_t blob_size;
- uint16_t version;
- uint16_t num_pointers;
- uint16_t codepage;
- uint16_t flags;
- uint64_t reserved;
- void *pointers[MAX_NUM_POINTERS];
-
- // The reason we initialize it to -1 is because otherwise, smart linkers may
- // end up putting it in the .bss section for zero-initialized data.
- } blobinfo = {(uint64_t)-1};
-}
-
-// Defined in android_log.c
-extern "C" PyObject *PyInit_android_log();
-
-/**
- * Maps the binary blob at the given memory address to memory, and returns the
- * pointer to the beginning of it.
- */
-static void *map_blob(const char *path, off_t offset, size_t size) {
- FILE *runtime = fopen(path, "rb");
- assert(runtime != NULL);
-
- void *blob = (void *)mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fileno(runtime), offset);
- assert(blob != MAP_FAILED);
-
- fclose(runtime);
- return blob;
-}
-
-/**
- * The inverse of map_blob.
- */
-static void unmap_blob(void *blob) {
- if (blob) {
- munmap(blob, blobinfo.blob_size);
- }
-}
-
-/**
- * This function is called by native_app_glue to initialize the program.
- *
- * Note that this does not run in the main thread, but in a thread created
- * specifically for this activity by android_native_app_glue.
- *
- * Unlike the regular deploy-stub, we need to interface directly with the
- * Panda3D libraries here, since we can't pass the pointers from Java to Panda
- * through the Python interpreter easily.
- */
-void android_main(struct android_app *app) {
- panda_android_app = app;
-
- // Attach the app thread to the Java VM.
- JNIEnv *env;
- ANativeActivity *activity = app->activity;
- int attach_status = activity->vm->AttachCurrentThread(&env, nullptr);
- if (attach_status < 0 || env == nullptr) {
- android_cat.error() << "Failed to attach thread to JVM!\n";
- return;
- }
-
- jclass activity_class = env->GetObjectClass(activity->clazz);
-
- // Get the current Java thread name. This just helps with debugging.
- jmethodID methodID = env->GetStaticMethodID(activity_class, "getCurrentThreadName", "()Ljava/lang/String;");
- jstring jthread_name = (jstring) env->CallStaticObjectMethod(activity_class, methodID);
-
- std::string thread_name;
- if (jthread_name != nullptr) {
- const char *c_str = env->GetStringUTFChars(jthread_name, nullptr);
- thread_name.assign(c_str);
- env->ReleaseStringUTFChars(jthread_name, c_str);
- }
-
- // Before we make any Panda calls, we must make the thread known to Panda.
- // This will also cause the JNIEnv pointer to be stored on the thread.
- // Note that we must keep a reference to this thread around.
- PT(Thread) current_thread = Thread::bind_thread(thread_name, "android_app");
-
- android_cat.info()
- << "New native activity started on " << *current_thread << "\n";
-
- // Fetch the data directory.
- jmethodID get_appinfo = env->GetMethodID(activity_class, "getApplicationInfo", "()Landroid/content/pm/ApplicationInfo;");
-
- jobject appinfo = env->CallObjectMethod(activity->clazz, get_appinfo);
- jclass appinfo_class = env->GetObjectClass(appinfo);
-
- // Fetch the path to the data directory.
- jfieldID datadir_field = env->GetFieldID(appinfo_class, "dataDir", "Ljava/lang/String;");
- jstring datadir = (jstring) env->GetObjectField(appinfo, datadir_field);
- const char *data_path = env->GetStringUTFChars(datadir, nullptr);
-
- if (data_path != nullptr) {
- Filename::_internal_data_dir = data_path;
- android_cat.info() << "Path to data: " << data_path << "\n";
-
- env->ReleaseStringUTFChars(datadir, data_path);
- }
-
- // Get the cache directory. Set the model-path to this location.
- methodID = env->GetMethodID(activity_class, "getCacheDirString", "()Ljava/lang/String;");
- jstring jcache_dir = (jstring) env->CallObjectMethod(activity->clazz, methodID);
-
- if (jcache_dir != nullptr) {
- const char *cache_dir;
- cache_dir = env->GetStringUTFChars(jcache_dir, nullptr);
- android_cat.info() << "Path to cache: " << cache_dir << "\n";
-
- ConfigVariableFilename model_cache_dir("model-cache-dir", Filename());
- model_cache_dir.set_value(cache_dir);
- env->ReleaseStringUTFChars(jcache_dir, cache_dir);
- }
-
- // Fetch the path to the library directory.
- jfieldID libdir_field = env->GetFieldID(appinfo_class, "nativeLibraryDir", "Ljava/lang/String;");
- jstring libdir_jstr = (jstring) env->GetObjectField(appinfo, libdir_field);
- const char *libdir = env->GetStringUTFChars(libdir_jstr, nullptr);
-
- if (libdir != nullptr) {
- std::string dtool_name = std::string(libdir) + "/libp3dtool.so";
- ExecutionEnvironment::set_dtool_name(dtool_name);
- android_cat.info() << "Path to dtool: " << dtool_name << "\n";
- }
-
- // Get the path to the APK.
- methodID = env->GetMethodID(activity_class, "getPackageCodePath", "()Ljava/lang/String;");
- jstring code_path = (jstring) env->CallObjectMethod(activity->clazz, methodID);
-
- const char *apk_path;
- apk_path = env->GetStringUTFChars(code_path, nullptr);
- android_cat.info() << "Path to APK: " << apk_path << "\n";
-
- // Get the path to the native library.
- methodID = env->GetMethodID(activity_class, "getNativeLibraryPath", "()Ljava/lang/String;");
- jstring lib_path_jstr = (jstring) env->CallObjectMethod(activity->clazz, methodID);
-
- const char *lib_path;
- lib_path = env->GetStringUTFChars(lib_path_jstr, nullptr);
- android_cat.info() << "Path to native library: " << lib_path << "\n";
- ExecutionEnvironment::set_binary_name(lib_path);
-
- // Map the blob to memory
- void *blob = map_blob(lib_path, (off_t)blobinfo.blob_offset, (size_t)blobinfo.blob_size);
- env->ReleaseStringUTFChars(lib_path_jstr, lib_path);
- assert(blob != NULL);
-
- assert(blobinfo.num_pointers <= MAX_NUM_POINTERS);
- for (uint32_t i = 0; i < blobinfo.num_pointers; ++i) {
- // Only offset if the pointer is non-NULL. Except for the first
- // pointer, which may never be NULL and usually (but not always)
- // points to the beginning of the blob.
- if (i == 0 || blobinfo.pointers[i] != nullptr) {
- blobinfo.pointers[i] = (void *)((uintptr_t)blobinfo.pointers[i] + (uintptr_t)blob);
- }
- }
-
- // Now load the configuration files.
- ConfigPage *page = nullptr;
- ConfigPageManager *cp_mgr;
- const char *prc_data = (char *)blobinfo.pointers[1];
- if (prc_data != nullptr) {
- cp_mgr = ConfigPageManager::get_global_ptr();
- std::istringstream in(prc_data);
- page = cp_mgr->make_explicit_page("builtin");
- page->read_prc(in);
- }
-
- // Mount the assets directory.
- Filename apk_fn(apk_path);
- PT(VirtualFileMountAndroidAsset) asset_mount;
- asset_mount = new VirtualFileMountAndroidAsset(app->activity->assetManager, apk_fn);
- VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr();
-
- //Filename asset_dir(apk_fn.get_dirname(), "assets");
- Filename asset_dir("/android_asset");
- vfs->mount(asset_mount, asset_dir, 0);
-
- // Release the apk_path.
- env->ReleaseStringUTFChars(code_path, apk_path);
-
- // Now add the asset directory to the model-path.
- //TODO: prevent it from adding the directory multiple times.
- get_model_path().append_directory(asset_dir);
-
- // Offset the pointers in the module table using the base mmap address.
- struct _frozen *moddef = (struct _frozen *)blobinfo.pointers[0];
- while (moddef->name) {
- moddef->name = (char *)((uintptr_t)moddef->name + (uintptr_t)blob);
- if (moddef->code != nullptr) {
- moddef->code = (unsigned char *)((uintptr_t)moddef->code + (uintptr_t)blob);
- }
- //__android_log_print(ANDROID_LOG_DEBUG, "Panda3D", "MOD: %s %p %d\n", moddef->name, (void*)moddef->code, moddef->size);
- moddef++;
- }
-
- PyImport_FrozenModules = (struct _frozen *)blobinfo.pointers[0];
-
- PyPreConfig preconfig;
- PyPreConfig_InitIsolatedConfig(&preconfig);
- preconfig.utf8_mode = 1;
- PyStatus status = Py_PreInitialize(&preconfig);
- if (PyStatus_Exception(status)) {
- env->ReleaseStringUTFChars(libdir_jstr, libdir);
- Py_ExitStatusException(status);
- return;
- }
-
- // Register the android_log module.
- if (PyImport_AppendInittab("android_log", &PyInit_android_log) < 0) {
- android_cat.error()
- << "Failed to register android_log module.\n";
- env->ReleaseStringUTFChars(libdir_jstr, libdir);
- return;
- }
-
- PyConfig config;
- PyConfig_InitIsolatedConfig(&config);
- config.pathconfig_warnings = 0; /* Suppress errors from getpath.c */
- config.buffered_stdio = 0;
- config.configure_c_stdio = 0;
- config.write_bytecode = 0;
- PyConfig_SetBytesString(&config, &config.platlibdir, libdir);
- env->ReleaseStringUTFChars(libdir_jstr, libdir);
-
- status = Py_InitializeFromConfig(&config);
- PyConfig_Clear(&config);
- if (PyStatus_Exception(status)) {
- Py_ExitStatusException(status);
- return;
- }
-
- while (!app->destroyRequested) {
- // Call the main module. This will not return until the app is done.
- android_cat.info() << "Importing __main__\n";
-
- int n = PyImport_ImportFrozenModule("__main__");
- if (n == 0) {
- Py_FatalError("__main__ not frozen");
- break;
- }
- if (n < 0) {
- if (!PyErr_ExceptionMatches(PyExc_SystemExit)) {
- PyErr_Print();
- } else {
- PyErr_Clear();
- }
- }
-
- if (app->destroyRequested) {
- // The app closed responding to a destroy request.
- break;
- }
-
- // Ask Android to clean up the activity.
- android_cat.info() << "Exited from __main__, finishing activity\n";
- ANativeActivity_finish(activity);
-
- // We still need to keep an event loop going until Android gives us leave
- // to end the process.
- while (!app->destroyRequested) {
- int looper_id;
- struct android_poll_source *source;
- auto result = ALooper_pollOnce(-1, &looper_id, nullptr, (void **)&source);
- if (looper_id == LOOPER_ID_MAIN) {
- int8_t cmd = android_app_read_cmd(app);
- android_app_pre_exec_cmd(app, cmd);
- android_app_post_exec_cmd(app, cmd);
-
- // I don't think we can get a resume command after we call finish(),
- // but let's handle it just in case.
- if (cmd == APP_CMD_RESUME || cmd == APP_CMD_DESTROY) {
- break;
- }
- } else if (source != nullptr) {
- source->process(app, source);
- }
- }
- }
-
- Py_Finalize();
-
- android_cat.info() << "Destroy requested, exiting from android_main\n";
-
- vfs->unmount(asset_mount);
-
- if (page != nullptr) {
- cp_mgr->delete_explicit_page(page);
- }
-
- unmap_blob(blob);
-
- // Detach the thread before exiting.
- activity->vm->DetachCurrentThread();
-
- _exit(0);
-}
diff --git a/pandatool/src/deploy-stub/deploy-stub.c b/pandatool/src/deploy-stub/deploy-stub.c
deleted file mode 100644
index 6cd2c280..00000000
--- a/pandatool/src/deploy-stub/deploy-stub.c
+++ /dev/null
@@ -1,767 +0,0 @@
-/* Python interpreter main program for frozen scripts */
-
-#include "Python.h"
-#ifdef _WIN32
-# include "malloc.h"
-# include
-#else
-# include
-# include
-#endif
-
-#ifdef __FreeBSD__
-# include
-#endif
-
-#ifdef __APPLE__
-# include
-# include
-#endif
-
-#include
-#include
-#include
-
-#include
-
-#include "structmember.h"
-
-/* Leave room for future expansion. We only read pointer 0, but there are
- other pointers that are being read by configPageManager.cxx. */
-#define MAX_NUM_POINTERS 24
-
-/* Stored in the flags field of the blobinfo structure below. */
-enum Flags {
- F_log_append = 1,
- F_log_filename_strftime = 2,
- F_keep_docstrings = 4,
-};
-
-/* Define an exposed symbol where we store the offset to the module data. */
-#ifdef _MSC_VER
-__declspec(dllexport)
-#else
-__attribute__((__visibility__("default"), used))
-#endif
-volatile struct {
- uint64_t blob_offset;
- uint64_t blob_size;
- uint16_t version;
- uint16_t num_pointers;
- uint16_t codepage;
- uint16_t flags;
- uint64_t reserved;
- void *pointers[MAX_NUM_POINTERS];
-
- // The reason we initialize it to -1 is because otherwise, smart linkers may
- // end up putting it in the .bss section for zero-initialized data.
-} blobinfo = {(uint64_t)-1};
-
-
-#ifdef _WIN32
-// These placeholders can have their names changed by deploy-stub.
-__declspec(dllexport) DWORD SymbolPlaceholder___________________ = 0x00000001;
-__declspec(dllexport) DWORD SymbolPlaceholder__ = 0x00000001;
-#endif
-
-#ifdef MS_WINDOWS
-# define WIN32_LEAN_AND_MEAN
-# include
-
-extern void PyWinFreeze_ExeInit(void);
-extern void PyWinFreeze_ExeTerm(void);
-
-static struct _inittab extensions[] = {
- {0, 0},
-};
-
-# define WIN_UNICODE
-#endif
-
-#ifdef _WIN32
-static wchar_t *log_pathw = NULL;
-#endif
-
-#if PY_VERSION_HEX >= 0x030b0000
-typedef struct {
- const char *name;
- const unsigned char *code;
- int size;
-} ModuleDef;
-#else
-typedef struct _frozen ModuleDef;
-#endif
-
-/**
- * Sets the main_dir field of the blobinfo structure, but only if it wasn't
- * already set.
- */
-static void set_main_dir(char *main_dir) {
- if (blobinfo.num_pointers >= 10) {
- if (blobinfo.num_pointers == 10) {
- ++blobinfo.num_pointers;
- blobinfo.pointers[10] = NULL;
- }
- if (blobinfo.pointers[10] == NULL) {
- blobinfo.pointers[10] = main_dir;
- }
- }
-}
-
-/**
- * Creates the parent directories of the given path. Returns 1 on success.
- */
-#ifdef _WIN32
-static int mkdir_parent(const wchar_t *path) {
- // Copy the path to a temporary buffer.
- wchar_t buffer[4096];
- size_t buflen = wcslen(path);
- if (buflen + 1 >= _countof(buffer)) {
- return 0;
- }
- wcscpy_s(buffer, _countof(buffer), path);
-
- // Seek back to find the last path separator.
- while (buflen-- > 0) {
- if (buffer[buflen] == '/' || buffer[buflen] == '\\') {
- buffer[buflen] = 0;
- break;
- }
- }
- if (buflen == (size_t)-1 || buflen == 0) {
- // There was no path separator, or this was the root directory.
- return 0;
- }
-
- if (CreateDirectoryW(buffer, NULL) != 0) {
- // Success!
- return 1;
- }
-
- // Failed.
- DWORD last_error = GetLastError();
- if (last_error == ERROR_ALREADY_EXISTS) {
- // Not really an error: the directory is already there.
- return 1;
- }
-
- if (last_error == ERROR_PATH_NOT_FOUND) {
- // We need to make the parent directory first.
- if (mkdir_parent(buffer)) {
- // Parent successfully created. Try again to make the child.
- if (CreateDirectoryW(buffer, NULL) != 0) {
- // Got it!
- return 1;
- }
- }
- }
- return 0;
-}
-#else
-static int mkdir_parent(const char *path) {
- // Copy the path to a temporary buffer.
- char buffer[4096];
- size_t buflen = strlen(path);
- if (buflen + 1 >= sizeof(buffer)) {
- return 0;
- }
- strcpy(buffer, path);
-
- // Seek back to find the last path separator.
- while (buflen-- > 0) {
- if (buffer[buflen] == '/') {
- buffer[buflen] = 0;
- break;
- }
- }
- if (buflen == (size_t)-1 || buflen == 0) {
- // There was no path separator, or this was the root directory.
- return 0;
- }
- if (mkdir(buffer, 0755) == 0) {
- // Success!
- return 1;
- }
-
- // Failed.
- if (errno == EEXIST) {
- // Not really an error: the directory is already there.
- return 1;
- }
-
- if (errno == ENOENT || errno == EACCES) {
- // We need to make the parent directory first.
- if (mkdir_parent(buffer)) {
- // Parent successfully created. Try again to make the child.
- if (mkdir(buffer, 0755) == 0) {
- // Got it!
- return 1;
- }
- }
- }
- return 0;
-}
-#endif
-
-/**
- * Redirects the output streams to point to the log file with the given path.
- *
- * @param path specifies the location of log file, may start with ~
- * @param append should be nonzero if it should not truncate the log file.
- */
-static int setup_logging(const char *path, int append) {
-#ifdef _WIN32
- // Does it start with a tilde? Perform tilde expansion if so.
- wchar_t *pathw = (wchar_t *)malloc(sizeof(wchar_t) * MAX_PATH);
- pathw[0] = 0;
- size_t offset = 0;
- if (path[0] == '~' && (path[1] == 0 || path[1] == '/' || path[1] == '\\')) {
- // Strip off the tilde.
- ++path;
-
- // Get the home directory path for the current user.
- if (!SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_PROFILE, NULL, 0, pathw))) {
- free(pathw);
- return 0;
- }
- offset = wcslen(pathw);
- }
-
- // We need to convert the rest of the path from UTF-8 to UTF-16.
- if (MultiByteToWideChar(CP_UTF8, 0, path, -1, pathw + offset,
- (int)(MAX_PATH - offset)) == 0) {
- free(pathw);
- return 0;
- }
-
- DWORD access = append ? FILE_APPEND_DATA : (GENERIC_READ | GENERIC_WRITE);
- int creation = append ? OPEN_ALWAYS : CREATE_ALWAYS;
- HANDLE handle = CreateFileW(pathw, access, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE,
- NULL, creation, FILE_ATTRIBUTE_NORMAL, NULL);
-
- if (handle == INVALID_HANDLE_VALUE) {
- // Make the parent directories first.
- mkdir_parent(pathw);
- handle = CreateFileW(pathw, access, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE,
- NULL, creation, FILE_ATTRIBUTE_NORMAL, NULL);
- }
-
- if (handle == INVALID_HANDLE_VALUE) {
- free(pathw);
- return 0;
- }
-
- log_pathw = pathw;
-
- if (append) {
- SetFilePointer(handle, 0, NULL, FILE_END);
- }
-
- SetStdHandle(STD_OUTPUT_HANDLE, handle);
- SetStdHandle(STD_ERROR_HANDLE, handle);
-
- // If we are running under the UCRT in a GUI application, we can't be sure
- // that we have valid fds for stdout and stderr, so we have to set them up.
- // One way to do this is to reopen them to something silly (like NUL).
- if (_fileno(stdout) < 0) {
- _close(1);
- _wfreopen(L"\\\\.\\NUL", L"w", stdout);
- }
-
- if (_fileno(stderr) < 0) {
- _close(2);
- _wfreopen(L"\\\\.\\NUL", L"w", stderr);
- }
-
- // Now replace the stdout and stderr file descriptors with one pointing to
- // our desired handle.
- int fd = _open_osfhandle((intptr_t)handle, _O_WRONLY | _O_TEXT | _O_APPEND);
- _dup2(fd, _fileno(stdout));
- _dup2(fd, _fileno(stderr));
- _close(fd);
-
- return 1;
-#else
- // Does it start with a tilde? Perform tilde expansion if so.
- char buffer[PATH_MAX * 2];
- size_t offset = 0;
- if (path[0] == '~' && (path[1] == 0 || path[1] == '/')) {
- // Strip off the tilde.
- ++path;
-
- // Get the home directory path for the current user.
- const char *home_dir = getenv("HOME");
- if (home_dir == NULL) {
- home_dir = getpwuid(getuid())->pw_dir;
- }
- offset = strlen(home_dir);
- assert(offset < sizeof(buffer));
- strncpy(buffer, home_dir, sizeof(buffer));
- }
-
- // Copy over the rest of the path.
- strcpy(buffer + offset, path);
-
- mode_t mode = O_CREAT | O_WRONLY | (append ? O_APPEND : O_TRUNC);
- int fd = open(buffer, mode, 0644);
- if (fd == -1) {
- // Make the parent directories first.
- mkdir_parent(buffer);
- fd = open(buffer, mode, 0644);
- }
-
- if (fd == -1) {
- perror(buffer);
- return 0;
- }
-
- fflush(stdout);
- fflush(stderr);
-
- dup2(fd, 1);
- dup2(fd, 2);
-
- if (close(fd) < 0) {
- perror("setup_logging: close");
- }
- return 1;
-#endif
-}
-
-/**
- * Sets the line_buffering property on a TextIOWrapper object.
- */
-static int enable_line_buffering(PyObject *file) {
-#if PY_VERSION_HEX >= 0x03070000
- /* Python 3.7 has a useful reconfigure() method. */
- PyObject *kwargs = _PyDict_NewPresized(1);
- PyDict_SetItemString(kwargs, "line_buffering", Py_True);
- PyObject *args = PyTuple_New(0);
-
- PyObject *method = PyObject_GetAttrString(file, "reconfigure");
- if (method != NULL) {
- PyObject *result = PyObject_Call(method, args, kwargs);
- Py_DECREF(method);
- Py_DECREF(kwargs);
- Py_DECREF(args);
- if (result != NULL) {
- Py_DECREF(result);
- } else {
- PyErr_Clear();
- return 0;
- }
- } else {
- Py_DECREF(kwargs);
- Py_DECREF(args);
- PyErr_Clear();
- return 0;
- }
-#else
- /* Older versions just don't expose a way to reconfigure(), but it's still
- safe to override the property; we just have to use a hack to do it,
- because it's officially marked "readonly". */
-
- PyTypeObject *type = Py_TYPE(file);
- PyMemberDef *member = type->tp_members;
-
- while (member != NULL && member->name != NULL) {
- if (strcmp(member->name, "line_buffering") == 0) {
- *((char *)file + member->offset) = 1;
- return 1;
- }
- ++member;
- }
- fflush(stdout);
-#endif
- return 1;
-}
-
-/* Main program */
-
-#ifdef WIN_UNICODE
-int Py_FrozenMain(int argc, wchar_t **argv)
-#else
-int Py_FrozenMain(int argc, char **argv)
-#endif
-{
- char *p;
- int n, sts = 1;
- int unbuffered = 0;
-#ifndef NDEBUG
- int inspect = 0;
-#endif
-
-#ifndef WIN_UNICODE
- int i;
- char *oldloc;
- wchar_t **argv_copy = NULL;
- /* We need a second copies, as Python might modify the first one. */
- wchar_t **argv_copy2 = NULL;
-
- if (argc > 0) {
- argv_copy = (wchar_t **)alloca(sizeof(wchar_t *) * argc);
- argv_copy2 = (wchar_t **)alloca(sizeof(wchar_t *) * argc);
- }
-#endif
-
- Py_FrozenFlag = 1; /* Suppress errors from getpath.c */
- Py_NoSiteFlag = 0;
- Py_NoUserSiteDirectory = 1;
-
-#if PY_VERSION_HEX >= 0x03020000
- if (blobinfo.flags & F_keep_docstrings) {
- Py_OptimizeFlag = 1;
- } else {
- Py_OptimizeFlag = 2;
- }
-#endif
-
-#ifndef NDEBUG
- if ((p = Py_GETENV("PYTHONINSPECT")) && *p != '\0')
- inspect = 1;
-#endif
- if ((p = Py_GETENV("PYTHONUNBUFFERED")) && *p != '\0')
- unbuffered = 1;
-
- if (unbuffered) {
- setbuf(stdin, (char *)NULL);
- setbuf(stdout, (char *)NULL);
- setbuf(stderr, (char *)NULL);
- }
-
-#ifndef WIN_UNICODE
- oldloc = setlocale(LC_ALL, NULL);
- setlocale(LC_ALL, "");
- for (i = 0; i < argc; i++) {
- argv_copy[i] = Py_DecodeLocale(argv[i], NULL);
- argv_copy2[i] = argv_copy[i];
- if (!argv_copy[i]) {
- fprintf(stderr, "Unable to decode the command line argument #%i\n",
- i + 1);
- argc = i;
- goto error;
- }
- }
- setlocale(LC_ALL, oldloc);
-#endif
-
-#ifdef MS_WINDOWS
- PyImport_ExtendInittab(extensions);
-#endif /* MS_WINDOWS */
-
- if (argc >= 1) {
-#ifndef WIN_UNICODE
- Py_SetProgramName(argv_copy[0]);
-#else
- Py_SetProgramName(argv[0]);
-#endif
- }
-
- Py_Initialize();
-#ifdef MS_WINDOWS
- PyWinFreeze_ExeInit();
-#endif
-
-#ifdef MS_WINDOWS
- /* Ensure that line buffering is enabled on the output streams. */
- if (!unbuffered) {
- PyObject *sys_stream;
- sys_stream = PySys_GetObject("__stdout__");
- if (sys_stream && !enable_line_buffering(sys_stream)) {
- fprintf(stderr, "Failed to enable line buffering on sys.stdout\n");
- fflush(stderr);
- }
- sys_stream = PySys_GetObject("__stderr__");
- if (sys_stream && !enable_line_buffering(sys_stream)) {
- fprintf(stderr, "Failed to enable line buffering on sys.stderr\n");
- fflush(stderr);
- }
- }
-#endif
-
- if (Py_VerboseFlag)
- fprintf(stderr, "Python %s\n%s\n",
- Py_GetVersion(), Py_GetCopyright());
-
-#ifndef WIN_UNICODE
- PySys_SetArgv(argc, argv_copy);
-#else
- PySys_SetArgv(argc, argv);
-#endif
-
-#ifdef MACOS_APP_BUNDLE
- // Add the Frameworks directory to sys.path.
- char buffer[PATH_MAX];
- uint32_t bufsize = sizeof(buffer);
- if (_NSGetExecutablePath(buffer, &bufsize) != 0) {
- assert(false);
- return 1;
- }
- char resolved[PATH_MAX];
- if (!realpath(buffer, resolved)) {
- perror("realpath");
- return 1;
- }
- const char *dir = dirname(resolved);
- sprintf(buffer, "%s/../Frameworks", dir);
-
- PyObject *sys_path = PyList_New(1);
- PyList_SET_ITEM(sys_path, 0, PyUnicode_FromString(buffer));
- PySys_SetObject("path", sys_path);
- Py_DECREF(sys_path);
-
- // Now, store a path to the Resources directory into the main_dir pointer,
- // for ConfigPageManager to read out and assign to MAIN_DIR.
- sprintf(buffer, "%s/../Resources", dir);
- set_main_dir(buffer);
-
- // Finally, chdir to it, so that regular Python files are read from the
- // right location.
- chdir(buffer);
-#endif
-
- n = PyImport_ImportFrozenModule("__main__");
- if (n == 0)
- Py_FatalError("__main__ not frozen");
- if (n < 0) {
- PyErr_Print();
- sts = 1;
- }
- else
- sts = 0;
-
-#ifndef NDEBUG
- if (inspect && isatty((int)fileno(stdin)))
- sts = PyRun_AnyFile(stdin, "") != 0;
-#endif
-
-#ifdef MS_WINDOWS
- PyWinFreeze_ExeTerm();
-#endif
- Py_Finalize();
-
-#ifndef WIN_UNICODE
-error:
- if (argv_copy2) {
- for (i = 0; i < argc; i++) {
- PyMem_RawFree(argv_copy2[i]);
- }
- }
-#endif
- return sts;
-}
-
-/**
- * Maps the binary blob at the given memory address to memory, and returns the
- * pointer to the beginning of it.
- */
-static void *map_blob(off_t offset, size_t size) {
- void *blob;
- FILE *runtime;
-
-#ifdef _WIN32
- wchar_t buffer[2048];
- GetModuleFileNameW(NULL, buffer, 2048);
- runtime = _wfopen(buffer, L"rb");
-#elif defined(__FreeBSD__)
- size_t bufsize = 4096;
- char buffer[4096];
- int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1};
- mib[3] = getpid();
- if (sysctl(mib, 4, (void *)buffer, &bufsize, NULL, 0) == -1) {
- perror("sysctl");
- return NULL;
- }
- runtime = fopen(buffer, "rb");
-#elif defined(__APPLE__)
- char buffer[4096];
- uint32_t bufsize = sizeof(buffer);
- if (_NSGetExecutablePath(buffer, &bufsize) != 0) {
- return NULL;
- }
- runtime = fopen(buffer, "rb");
-#else
- char buffer[4096];
- ssize_t pathlen = readlink("/proc/self/exe", buffer, sizeof(buffer) - 1);
- if (pathlen <= 0) {
- perror("readlink(/proc/self/exe)");
- return NULL;
- }
- buffer[pathlen] = '\0';
- runtime = fopen(buffer, "rb");
-#endif
-
- // Get offsets. In version 0, we read it from the end of the file.
- if (blobinfo.version == 0) {
- uint64_t end, begin;
- fseek(runtime, -8, SEEK_END);
- end = ftell(runtime);
- fread(&begin, 8, 1, runtime);
-
- offset = (off_t)begin;
- size = (size_t)(end - begin);
- }
-
- // mmap the section indicated by the offset (or malloc/fread on windows)
-#ifdef _WIN32
- blob = (void *)malloc(size);
- assert(blob != NULL);
- fseek(runtime, (long)offset, SEEK_SET);
- fread(blob, size, 1, runtime);
-#else
- blob = (void *)mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fileno(runtime), offset);
- assert(blob != MAP_FAILED);
-#endif
-
- fclose(runtime);
- return blob;
-}
-
-/**
- * The inverse of map_blob.
- */
-static void unmap_blob(void *blob) {
- if (blob) {
-#ifdef _WIN32
- free(blob);
-#else
- munmap(blob, blobinfo.blob_size);
-#endif
- }
-}
-
-/**
- * Main entry point to deploy-stub.
- */
-#ifdef _WIN32
-int wmain(int argc, wchar_t *argv[]) {
-#else
-int main(int argc, char *argv[]) {
-#endif
- int retval;
- ModuleDef *moddef;
- const char *log_filename;
- void *blob = NULL;
- log_filename = NULL;
-
-#ifdef __APPLE__
- // Strip a -psn_xxx argument passed in by macOS when run from an .app bundle.
- if (argc > 1 && strncmp(argv[1], "-psn_", 5) == 0) {
- argv[1] = argv[0];
- ++argv;
- --argc;
- }
-#endif
-
- /*
- printf("blob_offset: %d\n", (int)blobinfo.blob_offset);
- printf("blob_size: %d\n", (int)blobinfo.blob_size);
- printf("version: %d\n", (int)blobinfo.version);
- printf("num_pointers: %d\n", (int)blobinfo.num_pointers);
- printf("codepage: %d\n", (int)blobinfo.codepage);
- printf("flags: %d\n", (int)blobinfo.flags);
- printf("reserved: %d\n", (int)blobinfo.reserved);
- */
-
- // If we have a blob offset, we have to map the blob to memory.
- if (blobinfo.version == 0 || blobinfo.blob_offset != 0) {
- void *blob = map_blob((off_t)blobinfo.blob_offset, (size_t)blobinfo.blob_size);
- assert(blob != NULL);
-
- // Offset the pointers in the header using the base mmap address.
- if (blobinfo.version > 0 && blobinfo.num_pointers > 0) {
- uint32_t i;
- assert(blobinfo.num_pointers <= MAX_NUM_POINTERS);
- for (i = 0; i < blobinfo.num_pointers; ++i) {
- // Only offset if the pointer is non-NULL. Except for the first
- // pointer, which may never be NULL and usually (but not always)
- // points to the beginning of the blob.
- if (i == 0 || blobinfo.pointers[i] != 0) {
- blobinfo.pointers[i] = (void *)((uintptr_t)blobinfo.pointers[i] + (uintptr_t)blob);
- }
- }
- if (blobinfo.num_pointers >= 12) {
- log_filename = blobinfo.pointers[11];
- }
- } else {
- blobinfo.pointers[0] = blob;
- }
-
- // Offset the pointers in the module table using the base mmap address.
- moddef = blobinfo.pointers[0];
-#if PY_VERSION_HEX < 0x030b0000
- PyImport_FrozenModules = moddef;
-#endif
- while (moddef->name) {
- moddef->name = (char *)((uintptr_t)moddef->name + (uintptr_t)blob);
- if (moddef->code != 0) {
- moddef->code = (unsigned char *)((uintptr_t)moddef->code + (uintptr_t)blob);
- }
- //printf("MOD: %s %p %d\n", moddef->name, (void*)moddef->code, moddef->size);
- moddef++;
- }
-
- // In Python 3.11, we need to convert this to the new structure format.
-#if PY_VERSION_HEX >= 0x030b0000
- ModuleDef *moddef_end = moddef;
- ptrdiff_t num_modules = moddef - (ModuleDef *)blobinfo.pointers[0];
- struct _frozen *new_moddef = (struct _frozen *)calloc(num_modules + 1, sizeof(struct _frozen));
- PyImport_FrozenModules = new_moddef;
- for (moddef = blobinfo.pointers[0]; moddef < moddef_end; ++moddef) {
- new_moddef->name = moddef->name;
- new_moddef->code = moddef->code;
- new_moddef->size = moddef->size < 0 ? -(moddef->size) : moddef->size;
- new_moddef->is_package = moddef->size < 0;
-#if PY_VERSION_HEX < 0x030d0000 // 3.13
- new_moddef->get_code = NULL;
-#endif
- new_moddef++;
- }
-#endif
- } else {
- PyImport_FrozenModules = blobinfo.pointers[0];
- }
-
- if (log_filename != NULL) {
- char log_filename_buf[4096];
- if (blobinfo.flags & F_log_filename_strftime) {
- log_filename_buf[0] = 0;
- time_t now = time(NULL);
- if (strftime(log_filename_buf, sizeof(log_filename_buf), log_filename, localtime(&now)) > 0) {
- log_filename = log_filename_buf;
- }
- }
- setup_logging(log_filename, (blobinfo.flags & F_log_append) != 0);
- }
-
-#ifdef _WIN32
- if (blobinfo.codepage != 0) {
- SetConsoleCP(blobinfo.codepage);
- SetConsoleOutputCP(blobinfo.codepage);
- }
-#endif
-
- // Run frozen application
- retval = Py_FrozenMain(argc, argv);
-
- fflush(stdout);
- fflush(stderr);
-
-#if PY_VERSION_HEX >= 0x030b0000
- free((void *)PyImport_FrozenModules);
- PyImport_FrozenModules = NULL;
-#endif
-
- unmap_blob(blob);
- return retval;
-}
-
-#ifdef WIN_UNICODE
-int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, wchar_t *lpCmdLine, int nCmdShow) {
- return wmain(__argc, __wargv);
-}
-#elif defined(_WIN32)
-int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, char *lpCmdLine, int nCmdShow) {
- return main(__argc, __argv);
-}
-#endif
diff --git a/pandatool/src/deploy-stub/frozen_dllmain.c b/pandatool/src/deploy-stub/frozen_dllmain.c
deleted file mode 100644
index 3e374cf5..00000000
--- a/pandatool/src/deploy-stub/frozen_dllmain.c
+++ /dev/null
@@ -1,134 +0,0 @@
-/* FreezeDLLMain.cpp
-
-This is a DLLMain suitable for frozen applications/DLLs on
-a Windows platform.
-
-The general problem is that many Python extension modules may define
-DLL main functions, but when statically linked together to form
-a frozen application, this DLLMain symbol exists multiple times.
-
-The solution is:
-* Each module checks for a frozen build, and if so, defines its DLLMain
- function as "__declspec(dllexport) DllMain%module%"
- (eg, DllMainpythoncom, or DllMainpywintypes)
-
-* The frozen .EXE/.DLL links against this module, which provides
- the single DllMain.
-
-* This DllMain attempts to locate and call the DllMain for each
- of the extension modules.
-
-* This code also has hooks to "simulate" DllMain when used from
- a frozen .EXE.
-
-At this stage, there is a static table of "possibly embedded modules".
-This should change to something better, but it will work OK for now.
-
-Note that this scheme does not handle dependencies in the order
-of DllMain calls - except it does call pywintypes first :-)
-
-As an example of how an extension module with a DllMain should be
-changed, here is a snippet from the pythoncom extension module.
-
- // end of example code from pythoncom's DllMain.cpp
- #ifndef BUILD_FREEZE
- #define DLLMAIN DllMain
- #define DLLMAIN_DECL
- #else
- #define DLLMAIN DllMainpythoncom
- #define DLLMAIN_DECL __declspec(dllexport)
- #endif
-
- extern "C" DLLMAIN_DECL
- BOOL WINAPI DLLMAIN(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
- // end of example code from pythoncom's DllMain.cpp
-
-***************************************************************************/
-#include "windows.h"
-
-static char *possibleModules[] = {
- "pywintypes",
- "pythoncom",
- "win32ui",
- NULL,
-};
-
-BOOL CallModuleDllMain(char *modName, DWORD dwReason);
-
-
-/*
- Called by a frozen .EXE only, so that built-in extension
- modules are initialized correctly
-*/
-void PyWinFreeze_ExeInit(void)
-{
- char **modName;
- for (modName = possibleModules;*modName;*modName++) {
-/* printf("Initialising '%s'\n", *modName); */
- CallModuleDllMain(*modName, DLL_PROCESS_ATTACH);
- }
-}
-
-/*
- Called by a frozen .EXE only, so that built-in extension
- modules are cleaned up
-*/
-void PyWinFreeze_ExeTerm(void)
-{
- // Must go backwards
- char **modName;
- for (modName = possibleModules+(sizeof(possibleModules) / sizeof(char *))-2;
- modName >= possibleModules;
- *modName--) {
-/* printf("Terminating '%s'\n", *modName);*/
- CallModuleDllMain(*modName, DLL_PROCESS_DETACH);
- }
-}
-
-BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
-{
- BOOL ret = TRUE;
- switch (dwReason) {
- case DLL_PROCESS_ATTACH:
- {
- char **modName;
- for (modName = possibleModules;*modName;*modName++) {
- BOOL ok = CallModuleDllMain(*modName, dwReason);
- if (!ok)
- ret = FALSE;
- }
- break;
- }
- case DLL_PROCESS_DETACH:
- {
- // Must go backwards
- char **modName;
- for (modName = possibleModules+(sizeof(possibleModules) / sizeof(char *))-2;
- modName >= possibleModules;
- *modName--)
- CallModuleDllMain(*modName, DLL_PROCESS_DETACH);
- break;
- }
- }
- return ret;
-}
-
-BOOL CallModuleDllMain(char *modName, DWORD dwReason)
-{
- BOOL (WINAPI * pfndllmain)(HINSTANCE, DWORD, LPVOID);
-
- char funcName[255];
- HMODULE hmod = GetModuleHandleW(NULL);
- strcpy(funcName, "_DllMain");
- strcat(funcName, modName);
- strcat(funcName, "@12"); // stdcall convention.
- pfndllmain = (BOOL (WINAPI *)(HINSTANCE, DWORD, LPVOID))GetProcAddress(hmod, funcName);
- if (pfndllmain==NULL) {
- /* No function by that name exported - then that module does
- not appear in our frozen program - return OK
- */
- return TRUE;
- }
- return (*pfndllmain)(hmod, dwReason, NULL);
-}
-
diff --git a/pandatool/src/dxf/CMakeLists.txt b/pandatool/src/dxf/CMakeLists.txt
deleted file mode 100644
index c8095a32..00000000
--- a/pandatool/src/dxf/CMakeLists.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-set(P3DXF_HEADERS
- dxfFile.h
- dxfLayer.h
- dxfLayerMap.h
- dxfVertex.h
-)
-
-set(P3DXF_SOURCES
- dxfFile.cxx
- dxfLayer.cxx
- dxfLayerMap.cxx
- dxfVertex.cxx
-)
-
-composite_sources(p3dxf P3DXF_SOURCES)
-add_library(p3dxf STATIC ${P3DXF_HEADERS} ${P3DXF_SOURCES})
-target_link_libraries(p3dxf p3pandatoolbase)
-
-# This is only needed for binaries in the pandatool package. It is not useful
-# for user applications, so it is not installed.
diff --git a/pandatool/src/dxf/dxfFile.cxx b/pandatool/src/dxf/dxfFile.cxx
deleted file mode 100644
index f5bb6e09..00000000
--- a/pandatool/src/dxf/dxfFile.cxx
+++ /dev/null
@@ -1,937 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file dxfFile.cxx
- * @author drose
- * @date 2004-05-04
- */
-
-#include "dxfFile.h"
-#include "string_utils.h"
-#include "virtualFileSystem.h"
-
-using std::istream;
-using std::ostream;
-using std::string;
-
-DXFFile::Color DXFFile::_colors[DXF_num_colors] = {
- { 1, 1, 1 }, // Color 0 is not used.
- { 1, 0, 0 }, // Color 1 = Red
- { 1, 1, 0 }, // Color 2 = Yellow
- { 0, 1, 0 }, // Color 3 = Green
- { 0, 1, 1 }, // Color 4 = Cyan
- { 0, 0, 1 }, // Color 5 = Blue
- { 1, 0, 1 }, // Color 6 = Magenta
- { 1, 1, 1 }, // Color 7 = Black/White
- { 0.3, 0.3, 0.3 }, // Color 8 = Gray
- { 0.7, 0.7, 0.7 }, // Color 9 = Gray
- { 1, 0, 0 }, // Remaining colors are from the fancy palette.
- { 1, 0.5, 0.5 },
- { 0.65, 0, 0 },
- { 0.65, 0.325, 0.325 },
- { 0.5, 0, 0 },
- { 0.5, 0.25, 0.25 },
- { 0.3, 0, 0 },
- { 0.3, 0.15, 0.15 },
- { 0.15, 0, 0 },
- { 0.15, 0.075, 0.075 },
- { 1, 0.25, 0 },
- { 1, 0.625, 0.5 },
- { 0.65, 0.1625, 0 },
- { 0.65, 0.4063, 0.325 },
- { 0.5, 0.125, 0 },
- { 0.5, 0.3125, 0.25 },
- { 0.3, 0.075, 0 },
- { 0.3, 0.1875, 0.15 },
- { 0.15, 0.0375, 0 },
- { 0.15, 0.0938, 0.075 },
- { 1, 0.5, 0 },
- { 1, 0.75, 0.5 },
- { 0.65, 0.325, 0 },
- { 0.65, 0.4875, 0.325 },
- { 0.5, 0.25, 0 },
- { 0.5, 0.375, 0.25 },
- { 0.3, 0.15, 0 },
- { 0.3, 0.225, 0.15 },
- { 0.15, 0.075, 0 },
- { 0.15, 0.1125, 0.075 },
- { 1, 0.75, 0 },
- { 1, 0.875, 0.5 },
- { 0.65, 0.4875, 0 },
- { 0.65, 0.5688, 0.325 },
- { 0.5, 0.375, 0 },
- { 0.5, 0.4375, 0.25 },
- { 0.3, 0.225, 0 },
- { 0.3, 0.2625, 0.15 },
- { 0.15, 0.1125, 0 },
- { 0.15, 0.1313, 0.075 },
- { 1, 1, 0 },
- { 1, 1, 0.5 },
- { 0.65, 0.65, 0 },
- { 0.65, 0.65, 0.325 },
- { 0.5, 0.5, 0 },
- { 0.5, 0.5, 0.25 },
- { 0.3, 0.3, 0 },
- { 0.3, 0.3, 0.15 },
- { 0.15, 0.15, 0 },
- { 0.15, 0.15, 0.075 },
- { 0.75, 1, 0 },
- { 0.875, 1, 0.5 },
- { 0.4875, 0.65, 0 },
- { 0.5688, 0.65, 0.325 },
- { 0.375, 0.5, 0 },
- { 0.4375, 0.5, 0.25 },
- { 0.225, 0.3, 0 },
- { 0.2625, 0.3, 0.15 },
- { 0.1125, 0.15, 0 },
- { 0.1313, 0.15, 0.075 },
- { 0.5, 1, 0 },
- { 0.75, 1, 0.5 },
- { 0.325, 0.65, 0 },
- { 0.4875, 0.65, 0.325 },
- { 0.25, 0.5, 0 },
- { 0.375, 0.5, 0.25 },
- { 0.15, 0.3, 0 },
- { 0.225, 0.3, 0.15 },
- { 0.075, 0.15, 0 },
- { 0.1125, 0.15, 0.075 },
- { 0.25, 1, 0 },
- { 0.625, 1, 0.5 },
- { 0.1625, 0.65, 0 },
- { 0.4063, 0.65, 0.325 },
- { 0.125, 0.5, 0 },
- { 0.3125, 0.5, 0.25 },
- { 0.075, 0.3, 0 },
- { 0.1875, 0.3, 0.15 },
- { 0.0375, 0.15, 0 },
- { 0.0938, 0.15, 0.075 },
- { 0, 1, 0 },
- { 0.5, 1, 0.5 },
- { 0, 0.65, 0 },
- { 0.325, 0.65, 0.325 },
- { 0, 0.5, 0 },
- { 0.25, 0.5, 0.25 },
- { 0, 0.3, 0 },
- { 0.15, 0.3, 0.15 },
- { 0, 0.15, 0 },
- { 0.075, 0.15, 0.075 },
- { 0, 1, 0.25 },
- { 0.5, 1, 0.625 },
- { 0, 0.65, 0.1625 },
- { 0.325, 0.65, 0.4063 },
- { 0, 0.5, 0.125 },
- { 0.25, 0.5, 0.3125 },
- { 0, 0.3, 0.075 },
- { 0.15, 0.3, 0.1875 },
- { 0, 0.15, 0.0375 },
- { 0.075, 0.15, 0.0938 },
- { 0, 1, 0.5 },
- { 0.5, 1, 0.75 },
- { 0, 0.65, 0.325 },
- { 0.325, 0.65, 0.4875 },
- { 0, 0.5, 0.25 },
- { 0.25, 0.5, 0.375 },
- { 0, 0.3, 0.15 },
- { 0.15, 0.3, 0.225 },
- { 0, 0.15, 0.075 },
- { 0.075, 0.15, 0.1125 },
- { 0, 1, 0.75 },
- { 0.5, 1, 0.875 },
- { 0, 0.65, 0.4875 },
- { 0.325, 0.65, 0.5688 },
- { 0, 0.5, 0.375 },
- { 0.25, 0.5, 0.4375 },
- { 0, 0.3, 0.225 },
- { 0.15, 0.3, 0.2625 },
- { 0, 0.15, 0.1125 },
- { 0.075, 0.15, 0.1313 },
- { 0, 1, 1 },
- { 0.5, 1, 1 },
- { 0, 0.65, 0.65 },
- { 0.325, 0.65, 0.65 },
- { 0, 0.5, 0.5 },
- { 0.25, 0.5, 0.5 },
- { 0, 0.3, 0.3 },
- { 0.15, 0.3, 0.3 },
- { 0, 0.15, 0.15 },
- { 0.075, 0.15, 0.15 },
- { 0, 0.75, 1 },
- { 0.5, 0.875, 1 },
- { 0, 0.4875, 0.65 },
- { 0.325, 0.5688, 0.65 },
- { 0, 0.375, 0.5 },
- { 0.25, 0.4375, 0.5 },
- { 0, 0.225, 0.3 },
- { 0.15, 0.2625, 0.3 },
- { 0, 0.1125, 0.15 },
- { 0.075, 0.1313, 0.15 },
- { 0, 0.5, 1 },
- { 0.5, 0.75, 1 },
- { 0, 0.325, 0.65 },
- { 0.325, 0.4875, 0.65 },
- { 0, 0.25, 0.5 },
- { 0.25, 0.375, 0.5 },
- { 0, 0.15, 0.3 },
- { 0.15, 0.225, 0.3 },
- { 0, 0.075, 0.15 },
- { 0.075, 0.1125, 0.15 },
- { 0, 0.25, 1 },
- { 0.5, 0.625, 1 },
- { 0, 0.1625, 0.65 },
- { 0.325, 0.4063, 0.65 },
- { 0, 0.125, 0.5 },
- { 0.25, 0.3125, 0.5 },
- { 0, 0.075, 0.3 },
- { 0.15, 0.1875, 0.3 },
- { 0, 0.0375, 0.15 },
- { 0.075, 0.0938, 0.15 },
- { 0, 0, 1 },
- { 0.5, 0.5, 1 },
- { 0, 0, 0.65 },
- { 0.325, 0.325, 0.65 },
- { 0, 0, 0.5 },
- { 0.25, 0.25, 0.5 },
- { 0, 0, 0.3 },
- { 0.15, 0.15, 0.3 },
- { 0, 0, 0.15 },
- { 0.075, 0.075, 0.15 },
- { 0.25, 0, 1 },
- { 0.625, 0.5, 1 },
- { 0.1625, 0, 0.65 },
- { 0.4063, 0.325, 0.65 },
- { 0.125, 0, 0.5 },
- { 0.3125, 0.25, 0.5 },
- { 0.075, 0, 0.3 },
- { 0.1875, 0.15, 0.3 },
- { 0.0375, 0, 0.15 },
- { 0.0938, 0.075, 0.15 },
- { 0.5, 0, 1 },
- { 0.75, 0.5, 1 },
- { 0.325, 0, 0.65 },
- { 0.4875, 0.325, 0.65 },
- { 0.25, 0, 0.5 },
- { 0.375, 0.25, 0.5 },
- { 0.15, 0, 0.3 },
- { 0.225, 0.15, 0.3 },
- { 0.075, 0, 0.15 },
- { 0.1125, 0.075, 0.15 },
- { 0.75, 0, 1 },
- { 0.875, 0.5, 1 },
- { 0.4875, 0, 0.65 },
- { 0.5688, 0.325, 0.65 },
- { 0.375, 0, 0.5 },
- { 0.4375, 0.25, 0.5 },
- { 0.225, 0, 0.3 },
- { 0.2625, 0.15, 0.3 },
- { 0.1125, 0, 0.15 },
- { 0.1313, 0.075, 0.15 },
- { 1, 0, 1 },
- { 1, 0.5, 1 },
- { 0.65, 0, 0.65 },
- { 0.65, 0.325, 0.65 },
- { 0.5, 0, 0.5 },
- { 0.5, 0.25, 0.5 },
- { 0.3, 0, 0.3 },
- { 0.3, 0.15, 0.3 },
- { 0.15, 0, 0.15 },
- { 0.15, 0.075, 0.15 },
- { 1, 0, 0.75 },
- { 1, 0.5, 0.875 },
- { 0.65, 0, 0.4875 },
- { 0.65, 0.325, 0.5688 },
- { 0.5, 0, 0.375 },
- { 0.5, 0.25, 0.4375 },
- { 0.3, 0, 0.225 },
- { 0.3, 0.15, 0.2625 },
- { 0.15, 0, 0.1125 },
- { 0.15, 0.075, 0.1313 },
- { 1, 0, 0.5 },
- { 1, 0.5, 0.75 },
- { 0.65, 0, 0.325 },
- { 0.65, 0.325, 0.4875 },
- { 0.5, 0, 0.25 },
- { 0.5, 0.25, 0.375 },
- { 0.3, 0, 0.15 },
- { 0.3, 0.15, 0.225 },
- { 0.15, 0, 0.075 },
- { 0.15, 0.075, 0.1125 },
- { 1, 0, 0.25 },
- { 1, 0.5, 0.625 },
- { 0.65, 0, 0.1625 },
- { 0.65, 0.325, 0.4063 },
- { 0.5, 0, 0.125 },
- { 0.5, 0.25, 0.3125 },
- { 0.3, 0, 0.075 },
- { 0.3, 0.15, 0.1875 },
- { 0.15, 0, 0.0375 },
- { 0.15, 0.075, 0.0938 },
- { 0.33, 0.33, 0.33 },
- { 0.464, 0.464, 0.464 },
- { 0.598, 0.598, 0.598 },
- { 0.732, 0.732, 0.732 },
- { 0.866, 0.866, 0.866 },
- { 1, 1, 1 },
-};
-
-
-/**
- *
- */
-DXFFile::
-DXFFile() {
- _in = nullptr;
- _owns_in = false;
- _layer = nullptr;
- reset_entity();
- _color_index = -1;
-}
-
-/**
- *
- */
-DXFFile::
-~DXFFile() {
- if (_owns_in) {
- VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr();
- vfs->close_read_file(_in);
- }
-}
-
-
-/**
- * Opens the indicated filename and reads it as a DXF file.
- */
-void DXFFile::
-process(Filename filename) {
- filename.set_text();
-
- VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr();
- istream *in = vfs->open_read_file(filename, true);
- if (in == nullptr) {
- return;
- }
- process(in, true);
-}
-
-
-/**
- * Reads the indicated stream as a DXF file. If owns_in is true, then the
- * istream will be deleted via vfs->close_read_file() when the DXFFile object
- * destructs.
- */
-void DXFFile::
-process(istream *in, bool owns_in) {
- if (_owns_in) {
- VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr();
- vfs->close_read_file(_in);
- }
- _in = in;
- _owns_in = owns_in;
- _state = ST_top;
-
- begin_file();
- while (_state != ST_done && _state != ST_error) {
- if (get_group()) {
- switch (_state) {
- case ST_top:
- state_top();
- break;
-
- case ST_section:
- state_section();
- break;
-
- case ST_entity:
- state_entity();
- break;
-
- case ST_verts:
- state_verts();
- break;
-
- default:
- break;
- }
- }
- }
-}
-
-
-
-/**
- * A hook for user code, if desired. This function is called whenever
- * processing begins on the DXF file.
- */
-void DXFFile::
-begin_file() {
-}
-
-
-/**
- * A hook for user code, if desired. This function is called whenever a new
- * section in the DXF file is encountered.
- */
-void DXFFile::
-begin_section() {
-}
-
-
-/**
- * A hook for user code, if desired. This function is called whenever a
- * vertex is read from the DXF file. This function has the default behavior
- * of adding the vertex to the _verts list, so that when done_entity() is
- * called later, it will have the complete list of vertices available to it.
- */
-void DXFFile::
-done_vertex() {
- DXFVertex v;
- v._p = _p;
- _verts.push_back(v);
-}
-
-
-/**
- * This is the primary hook for user code. This function is called when an
- * entity is read from the DXF file. This may be something like a polygon,
- * point, or a polygon mesh: any geometry. It is up to the user code to
- * override this function and do something interesting with each piece of
- * geometry that is read.
- */
-void DXFFile::
-done_entity() {
-}
-
-
-/**
- * A hook for user code, if desired. This function is called as each section
- * in the DXF file is finished.
- */
-void DXFFile::
-end_section() {
-}
-
-
-/**
- * A hook for user code, if desired. This function is called when the DXF
- * processing is complete.
- */
-void DXFFile::
-end_file() {
-}
-
-
-/**
- * A hook for user code, if desired. This function is called when some
- * unexpected error occurs while reading the DXF file.
- */
-void DXFFile::
-error() {
- nout << "Error!\n";
-}
-
-
-
-/**
- * Returns the index of the closest matching AutoCAD color to the indicated r,
- * g, b.
- */
-int DXFFile::
-find_color(double r, double g, double b) {
- double best_diff = 4.0; // 4 is greater than our expected max, 3.
- int best_index = 7;
-
- for (int i = 0; i < 255; i++) {
- double diff = ((r - _colors[i].r) * (r - _colors[i].r) +
- (g - _colors[i].g) * (g - _colors[i].g) +
- (b - _colors[i].b) * (b - _colors[i].b));
- if (diff < best_diff) {
- best_diff = diff;
- best_index = i;
- }
- }
-
- return best_index;
-}
-
-/**
- * This is a convenience function to return the r,g,b color of the current
- * entity (at the time of done_entity()). It's based on the _color_index
- * value that was read from the DXF file.
- */
-const DXFFile::Color &DXFFile::
-get_color() const {
- if (_color_index >= 0 && _color_index <= 255) {
- return _colors[_color_index];
- }
- return _colors[0];
-}
-
-
-/**
- * Assuming the current entity is a planar-based entity, for instance, a 2-d
- * polygon (as opposed to a 3-d polygon), this converts the coordinates from
- * the funny planar coordinate system to the world coordinates. It converts
- * the _p value of the entity, as well as all vertices in the _verts list.
- */
-void DXFFile::
-ocs_2_wcs() {
- compute_ocs();
-
- // Convert the entity's position.
- _p = _p * _ocs2wcs;
-
- // Maybe we have these coordinates too.
- _q = _q * _ocs2wcs;
- _r = _r * _ocs2wcs;
- _s = _s * _ocs2wcs;
-
- // If there are any vertices, convert them too.
- DXFVertices::iterator vi;
- for (vi = _verts.begin(); vi != _verts.end(); ++vi) {
- (*vi)._p = (*vi)._p * _ocs2wcs;
- }
-}
-
-
-/**
- * Computes the matrix used to convert from the planar coordinate system to
- * world coordinates.
- */
-void DXFFile::
-compute_ocs() {
- // A 2-d entity's vertices might be defined in an "Object Coordinate System"
- // which has a funny definition. Its Z axis is defined by _z, and its X and
- // Y axes are inferred from that. The origin is the same as the world
- // coordinate system's origin.
-
- // The Z axis is _z. Determine the x and y axes.
- LVector3d x, y;
-
- if (fabs(_z[0]) < 1.0/64.0 && fabs(_z[1]) < 1.0/64.0) {
- x = cross(LVector3d(0.0, 1.0, 0.0), _z);
- } else {
- x = cross(LVector3d(0.0, 0.0, 1.0), _z);
- }
- x.normalize();
- y = cross(x, _z);
- y.normalize();
-
- // Now build a rotate matrix from these vectors.
- LMatrix4d
- ocs( x[0], x[1], x[2], 0,
- y[0], y[1], y[2], 0,
- _z[0], _z[1], _z[2], 0,
- 0, 0, 0, 1);
-
- _ocs2wcs.invert_from(ocs);
-}
-
-
-/**
- * Reads the next code, string pair from the DXF file. This is the basic unit
- * of data in a DXF file.
- */
-bool DXFFile::
-get_group() {
- istream &in = *_in;
- do {
- in >> _code;
- if (!in) {
- change_state(ST_error);
- return false;
- }
-
- // Now skip past exactly one newline character and any number of other
- // whitespace characters.
- while (in && in.peek() != '\n') {
- in.get();
- }
- in.get();
- while (in && isspace(in.peek()) && in.peek() != '\n') {
- in.get();
- }
-
- std::getline(in, _string);
- _string = trim_right(_string);
-
- if (!in) {
- change_state(ST_error);
- return false;
- }
-
- // If we just read a comment, go back and get another one.
- } while (_code == 999);
-
- return true;
-}
-
-
-/**
- * Called as new nodes are read to update the internal state correctly.
- */
-void DXFFile::
-change_state(State new_state) {
- if (_state == ST_verts) {
- done_vertex();
- _p.set(0.0, 0.0, 0.0);
- _q.set(0.0, 0.0, 0.0);
- _r.set(0.0, 0.0, 0.0);
- _s.set(0.0, 0.0, 0.0);
- }
- if ((_state == ST_entity || _state == ST_verts) &&
- new_state != ST_verts) {
- // We finish an entity when we read a new entity, or when we've read the
- // last vertex (if we were scanning the vertices after an entity).
- done_entity();
- reset_entity();
- }
- switch (new_state) {
- case ST_top:
- end_section();
- break;
-
- case ST_done:
- end_file();
- break;
-
- default:
- break;
- }
- _state = new_state;
-}
-
-
-/**
- *
- */
-void DXFFile::
-change_section(Section new_section) {
- change_state(ST_section);
- _section = new_section;
- begin_section();
-}
-
-
-/**
- * Given a newly read layer name, sets the _layer pointer to point to the
- * associate layer. If the layer name has not been encountered before,
- * creates a new layer definition.
- */
-void DXFFile::
-change_layer(const string &layer_name) {
- if (_layer == nullptr || _layer->get_name() != layer_name) {
- _layer = _layers.get_layer(layer_name, this);
- }
-}
-
-
-/**
- *
- */
-void DXFFile::
-change_entity(Entity new_entity) {
- if (new_entity == EN_vertex && _vertices_follow) {
- // If we read a new vertex and we're still scanning the vertices that
- // follow an entity, keep scanning it--we haven't finished the entity yet.
- change_state(ST_verts);
-
- } else {
- // Otherwise, begin a new entity.
- change_state(ST_entity);
- _entity = new_entity;
- }
-}
-
-
-/**
- * Resets the current entity to its initial, default state prior to reading a
- * new entity.
- */
-void DXFFile::
-reset_entity() {
- _p.set(0.0, 0.0, 0.0);
- _q.set(0.0, 0.0, 0.0);
- _r.set(0.0, 0.0, 0.0);
- _s.set(0.0, 0.0, 0.0);
- _z.set(0.0, 0.0, 1.0);
- _vertices_follow = false;
- // _color_index = -1;
-
- _verts.erase(_verts.begin(), _verts.end());
-}
-
-
-/**
- * Does the DXF processing when we are at the top of the file, outside of any
- * section.
- */
-void DXFFile::
-state_top() {
- if (_code != 0) {
- nout << "Group code 0 not found at top level; found code " << _code
- << " instead.\n";
- change_state(ST_error);
- } else {
- if (_string == "SECTION") {
- if (get_group()) {
- if (_code != 2) {
- nout << "Group code 0 not immediately followed by code 2; found code "
- << _code << " instead.\n";
- } else {
- if (_string == "HEADER") {
- change_section(SE_header);
- } else if (_string == "TABLES") {
- change_section(SE_tables);
- } else if (_string == "BLOCKS") {
- change_section(SE_blocks);
- } else if (_string == "ENTITIES") {
- change_section(SE_entities);
- } else if (_string == "OBJECTS") {
- change_section(SE_objects);
- } else {
- change_section(SE_unknown);
- }
- }
- }
- } else if (_string == "EOF") {
- change_state(ST_done);
- } else {
- nout << "Unexpected section at top level: '" << _string << "'\n";
- change_state(ST_error);
- }
- }
-}
-
-
-
-/**
- * Does the DXF processing when we are within some section.
- */
-void DXFFile::
-state_section() {
- string tail;
-
- switch (_code) {
- case 0:
- if (_string == "ENDSEC") {
- change_state(ST_top);
- } else {
- if (_section == SE_entities) {
- if (_string == "3DFACE") {
- change_entity(EN_3dface);
- } else if (_string == "POINT") {
- change_entity(EN_point);
- } else if (_string == "INSERT") {
- change_entity(EN_insert);
- } else if (_string == "VERTEX") {
- change_entity(EN_vertex);
- } else if (_string == "POLYLINE") {
- change_entity(EN_polyline);
- } else {
- change_entity(EN_unknown);
- }
- }
- }
- break;
-
- case 8:
- change_layer(_string);
- break;
-
- case 62: // Color.
- _color_index = string_to_int(_string, tail);
- break;
-
- default:
- break;
- }
-}
-
-
-/**
- * Does the DXF processing when we are reading an entity.
- */
-void DXFFile::
-state_entity() {
- string tail;
-
- switch (_code) {
- case 0:
- state_section();
- break;
-
- case 8:
- change_layer(_string);
- break;
-
- case 10:
- _p[0] = string_to_double(_string, tail);
- break;
-
- case 11:
- _q[0] = string_to_double(_string, tail);
- break;
-
- case 12:
- _r[0] = string_to_double(_string, tail);
- break;
-
- case 13:
- _s[0] = string_to_double(_string, tail);
- break;
-
- case 20:
- _p[1] = string_to_double(_string, tail);
- break;
-
- case 21:
- _q[1] = string_to_double(_string, tail);
- break;
-
- case 22:
- _r[1] = string_to_double(_string, tail);
- break;
-
- case 23:
- _s[1] = string_to_double(_string, tail);
- break;
-
- case 30:
- _p[2] = string_to_double(_string, tail);
- break;
-
- case 31:
- _q[2] = string_to_double(_string, tail);
- break;
-
- case 32:
- _r[2] = string_to_double(_string, tail);
- break;
-
- case 33:
- _s[2] = string_to_double(_string, tail);
- break;
-
- case 62: // Color.
- _color_index = string_to_int(_string, tail);
- break;
-
- case 66: // Vertices-follow.
- _vertices_follow = (string_to_int(_string, tail) != 0);
- break;
-
- case 70: // Polyline flags.
- _flags = string_to_int(_string, tail);
- break;
-
- case 210:
- _z[0] = string_to_double(_string, tail);
- break;
-
- case 220:
- _z[1] = string_to_double(_string, tail);
- break;
-
- case 230:
- _z[2] = string_to_double(_string, tail);
- break;
-
- default:
- break;
- }
-}
-
-
-/**
- * Does the DXF processing when we are reading the list of vertices that might
- * follow an entity.
- */
-void DXFFile::
-state_verts() {
- string tail;
-
- switch (_code) {
- case 0:
- state_section();
- break;
-
- case 8:
- change_layer(_string);
- break;
-
- case 10:
- _p[0] = string_to_double(_string, tail);
- break;
-
- case 20:
- _p[1] = string_to_double(_string, tail);
- break;
-
- case 30:
- _p[2] = string_to_double(_string, tail);
- break;
-
- default:
- break;
- }
-}
-
-
-ostream &operator << (ostream &out, const DXFFile::State &state) {
- switch (state) {
- case DXFFile::ST_top:
- return out << "ST_top";
- case DXFFile::ST_section:
- return out << "ST_section";
- case DXFFile::ST_entity:
- return out << "ST_entity";
- case DXFFile::ST_verts:
- return out << "ST_verts";
- case DXFFile::ST_error:
- return out << "ST_error";
- case DXFFile::ST_done:
- return out << "ST_done";
- }
- return out << "Unknown state";
-}
-
-ostream &operator << (ostream &out, const DXFFile::Section §ion) {
- switch (section) {
- case DXFFile::SE_unknown:
- return out << "SE_unknown";
- case DXFFile::SE_header:
- return out << "SE_header";
- case DXFFile::SE_tables:
- return out << "SE_tables";
- case DXFFile::SE_blocks:
- return out << "SE_blocks";
- case DXFFile::SE_entities:
- return out << "SE_entities";
- case DXFFile::SE_objects:
- return out << "SE_objects";
- }
- return out << "Unknown section";
-}
-
-ostream &operator << (ostream &out, const DXFFile::Entity &entity) {
- switch (entity) {
- case DXFFile::EN_unknown:
- return out << "EN_unknown";
- case DXFFile::EN_3dface:
- return out << "EN_3dface";
- case DXFFile::EN_point:
- return out << "EN_point";
- case DXFFile::EN_insert:
- return out << "EN_insert";
- case DXFFile::EN_vertex:
- return out << "EN_vertex";
- case DXFFile::EN_polyline:
- return out << "EN_polyline";
- }
- return out << "Unknown entity";
-}
diff --git a/pandatool/src/dxf/dxfFile.h b/pandatool/src/dxf/dxfFile.h
deleted file mode 100644
index e555960e..00000000
--- a/pandatool/src/dxf/dxfFile.h
+++ /dev/null
@@ -1,168 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file dxfFile.h
- * @author drose
- * @date 2004-05-04
- */
-
-#ifndef DXFFILE_H
-#define DXFFILE_H
-
-#include "pandatoolbase.h"
-
-#include "dxfLayer.h"
-#include "dxfLayerMap.h"
-#include "dxfVertex.h"
-
-#include "luse.h"
-#include "filename.h"
-
-
-static const int DXF_max_line = 256;
-static const int DXF_num_colors = 256;
-
-/**
- * A generic DXF-reading class. This class can read a DXF file but doesn't
- * actually do anything with the data; it's intended to be inherited from and
- * the appropriate functions overridden (particularly DoneEntity()).
- */
-class DXFFile : public MemoryBase {
-public:
- DXFFile();
- virtual ~DXFFile();
-
- void process(Filename filename);
- void process(std::istream *in, bool owns_in);
-
- // These functions are called as the file is processed. These are the main
- // hooks for redefining how the class should dispense its data. As each
- // function is called, the state stored in the DXFFile class reflects the
- // data that was most recently read.
-
- virtual void begin_file();
- virtual void begin_section();
- virtual void done_vertex();
- virtual void done_entity();
- virtual void end_section();
- virtual void end_file();
- virtual void error();
-
- // new_layer() is called whenever the DXFFile class encounters a new Layer
- // definition, and must allocate a DXFLayer instance. This function is
- // provided so that user code may force allocate of a specialized DXFLayer
- // instance instead.
- virtual DXFLayer *new_layer(const std::string &name) {
- return new DXFLayer(name);
- }
-
- enum State {
- ST_top,
- ST_section,
- ST_entity,
- ST_verts,
- ST_error,
- ST_done,
- };
- enum Section {
- SE_unknown,
- SE_header,
- SE_tables,
- SE_blocks,
- SE_entities,
- SE_objects,
- };
- enum Entity {
- EN_unknown,
- EN_3dface,
- EN_point,
- EN_insert,
- EN_vertex,
- EN_polyline,
- };
- enum PolylineFlags {
- PF_closed = 0x01,
- PF_curve_fit = 0x02,
- PF_spline_fit = 0x04,
- PF_3d = 0x08,
- PF_3d_mesh = 0x10,
- PF_closed_n = 0x20,
- PF_polyface = 0x40,
- PF_continuous_linetype = 0x80,
- };
-
- // This is a table of standard Autocad colors. DXF files can store only a
- // limited range of colors; specifically, the 255 colors defined by Autocad.
- struct Color {
- double r, g, b;
- };
- static Color _colors[DXF_num_colors];
-
- // find_color() returns the index of the closest matching AutoCAD color to
- // the indicated r, g, b.
- static int find_color(double r, double g, double b);
-
- // get_color() returns the r,g,b of the current entity. It is valid at the
- // time done_entity() is called.
- const Color &get_color() const;
-
- // Some entities are defined in world coordinates, in 3-d space; other
- // entities are inherently 2-d in nature and are defined in planar
- // coordinates and must be converted to 3-d space. Call this function from
- // done_entity() to convert a 2-d entity to 3-d world coordinates.
- void ocs_2_wcs();
-
- // These members indicate the current state and describe properties of the
- // current thing being processed. They are valid at done_entity(), and at
- // other times.
- int _flags;
- Section _section;
- Entity _entity;
- LPoint3d _p, _q, _r, _s;
- LVector3d _z;
- int _color_index;
- DXFLayer *_layer;
-
- // _verts is the list of vertices associated with the current entity. It is
- // valid at the time done_entity() is called.
- DXFVertices _verts;
-
- // This is the set of layers encountered within the DXF file.
- DXFLayerMap _layers;
-
-protected:
- State _state;
- bool _vertices_follow;
- LMatrix4d _ocs2wcs;
-
- std::istream *_in;
- bool _owns_in;
-
- int _code;
- std::string _string;
-
- void compute_ocs();
-
- bool get_group();
- void change_state(State new_state);
- void change_section(Section new_section);
- void change_layer(const std::string &layer_name);
- void change_entity(Entity new_entity);
- void reset_entity();
-
- void state_top();
- void state_section();
- void state_entity();
- void state_verts();
-};
-
-std::ostream &operator << (std::ostream &out, const DXFFile::State &state);
-std::ostream &operator << (std::ostream &out, const DXFFile::Section §ion);
-std::ostream &operator << (std::ostream &out, const DXFFile::Entity &entity);
-
-#endif
diff --git a/pandatool/src/dxf/dxfLayer.cxx b/pandatool/src/dxf/dxfLayer.cxx
deleted file mode 100644
index 6803cc17..00000000
--- a/pandatool/src/dxf/dxfLayer.cxx
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file dxfLayer.cxx
- * @author drose
- * @date 2004-05-04
- */
-
-#include "dxfLayer.h"
-
-
-/**
- *
- */
-DXFLayer::
-DXFLayer(const std::string &name) : Namable(name) {
-}
-
-/**
- *
- */
-DXFLayer::
-~DXFLayer() {
-}
diff --git a/pandatool/src/dxf/dxfLayer.h b/pandatool/src/dxf/dxfLayer.h
deleted file mode 100644
index 74519728..00000000
--- a/pandatool/src/dxf/dxfLayer.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file dxfLayer.h
- * @author drose
- * @date 2004-05-04
- */
-
-#ifndef DXFLAYER_H
-#define DXFLAYER_H
-
-#include "pandatoolbase.h"
-#include "namable.h"
-
-/**
- * This represents a "layer" as read from the DXF file. A layer may be
- * defined by reading the header part of the file, or it may be implicitly
- * defined by an entity's having referenced it.
- *
- * User code may derive from DXFLayer to associate private data with each
- * layer, if desired.
- */
-class DXFLayer : public Namable {
-public:
- DXFLayer(const std::string &name);
- virtual ~DXFLayer();
-};
-
-#endif
diff --git a/pandatool/src/dxf/dxfLayerMap.cxx b/pandatool/src/dxf/dxfLayerMap.cxx
deleted file mode 100644
index d2049c81..00000000
--- a/pandatool/src/dxf/dxfLayerMap.cxx
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file dxfLayerMap.cxx
- * @author drose
- * @date 2004-05-04
- */
-
-#include "dxfLayerMap.h"
-#include "dxfFile.h"
-
-/**
- * Looks up the layer name in the map, and returns a pointer to the associated
- * DXFLayer. If this is the first time this layer name has been used, creates
- * a new DXFLayer by the given name. In this case, it calls
- * dxffile->new_layer() to create the layer, allowing user code to override
- * this function to create a specialized time, if desired.
- */
-DXFLayer *DXFLayerMap::
-get_layer(const std::string &name, DXFFile *dxffile) {
- iterator lmi;
- lmi = find(name);
- if (lmi != end()) {
- // The layer was already here.
- return (*lmi).second;
- }
-
- // Need a new layer.
- DXFLayer *layer = dxffile->new_layer(name);
- (*this)[name] = layer;
-
- return layer;
-}
diff --git a/pandatool/src/dxf/dxfLayerMap.h b/pandatool/src/dxf/dxfLayerMap.h
deleted file mode 100644
index f2fabe53..00000000
--- a/pandatool/src/dxf/dxfLayerMap.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file dxfLayerMap.h
- * @author drose
- * @date 2004-05-04
- */
-
-#ifndef DXFLAYERMAP_H
-#define DXFLAYERMAP_H
-
-#include "pandatoolbase.h"
-#include "pmap.h"
-
-class DXFLayer;
-class DXFFile;
-
-/**
- * A map of string (layer name) to DXFLayer: that is, the layers of a file
- * ordered by name. This is used as a lookup within DXFFile to locate the
- * layer associated with a particular entity.
- */
-class DXFLayerMap : public pmap {
-public:
- DXFLayer *get_layer(const std::string &name, DXFFile *dxffile);
-};
-
-#endif
diff --git a/pandatool/src/dxf/dxfVertex.cxx b/pandatool/src/dxf/dxfVertex.cxx
deleted file mode 100644
index 3802802f..00000000
--- a/pandatool/src/dxf/dxfVertex.cxx
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file dxfVertex.cxx
- * @author drose
- * @date 2004-05-04
- */
-
-#include "dxfVertex.h"
-
-/**
- * This defines a unique ordering for vertices so that the DXFVertexMap can
- * group identical vertices together.
- */
-int DXFVertex::
-operator < (const DXFVertex &other) const {
- if (fabs(_p[0] - other._p[0]) > 0.0001) {
- return _p[0] < other._p[0];
- } else if (fabs(_p[1] - other._p[1]) > 0.0001) {
- return _p[1] < other._p[1];
- } else if (fabs(_p[2] - other._p[2]) > 0.0001) {
- return _p[2] < other._p[2];
- }
-
- return false;
-}
diff --git a/pandatool/src/dxf/dxfVertex.h b/pandatool/src/dxf/dxfVertex.h
deleted file mode 100644
index 32494509..00000000
--- a/pandatool/src/dxf/dxfVertex.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file dxfVertex.h
- * @author drose
- * @date 2004-05-04
- */
-
-#ifndef DXFVERTEX_H
-#define DXFVERTEX_H
-
-#include "pandatoolbase.h"
-#include "pvector.h"
-#include "luse.h"
-
-/**
- * Stored within DXFFile, this is the basic Vertex data of a DXF file. When
- * DXFFile::DoneEntity() is called, if the entity is a type to have vertices,
- * then DXFFile::_verts contains a list of all the vertices that belong to the
- * entity.
- */
-class DXFVertex {
-public:
- DXFVertex() { }
- DXFVertex(const LPoint3d &p) : _p(p) { }
- int operator < (const DXFVertex &other) const;
-
- LPoint3d _p;
-};
-
-typedef pvector DXFVertices;
-
-#endif
diff --git a/pandatool/src/dxf/p3dxf_composite1.cxx b/pandatool/src/dxf/p3dxf_composite1.cxx
deleted file mode 100644
index 6d62c98c..00000000
--- a/pandatool/src/dxf/p3dxf_composite1.cxx
+++ /dev/null
@@ -1,4 +0,0 @@
-#include "dxfFile.cxx"
-#include "dxfLayer.cxx"
-#include "dxfLayerMap.cxx"
-#include "dxfVertex.cxx"
diff --git a/pandatool/src/dxfegg/CMakeLists.txt b/pandatool/src/dxfegg/CMakeLists.txt
deleted file mode 100644
index 74684b1c..00000000
--- a/pandatool/src/dxfegg/CMakeLists.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-if(NOT HAVE_EGG)
- return()
-endif()
-
-set(P3DXFEGG_HEADERS
- dxfToEggConverter.h
- dxfToEggLayer.h
-)
-
-set(P3DXFEGG_SOURCES
- dxfToEggConverter.cxx
- dxfToEggLayer.cxx
-)
-
-add_library(p3dxfegg STATIC ${P3DXFEGG_HEADERS} ${P3DXFEGG_SOURCES})
-target_link_libraries(p3dxfegg p3dxf p3eggbase)
-
-# This is only needed for binaries in the pandatool package. It is not useful
-# for user applications, so it is not installed.
diff --git a/pandatool/src/dxfegg/dxfToEggConverter.cxx b/pandatool/src/dxfegg/dxfToEggConverter.cxx
deleted file mode 100644
index 6ba64119..00000000
--- a/pandatool/src/dxfegg/dxfToEggConverter.cxx
+++ /dev/null
@@ -1,145 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file dxfToEggConverter.cxx
- * @author drose
- * @date 2004-05-04
- */
-
-#include "dxfToEggConverter.h"
-#include "dxfToEggLayer.h"
-#include "eggData.h"
-
-/**
- *
- */
-DXFToEggConverter::
-DXFToEggConverter() {
-}
-
-/**
- *
- */
-DXFToEggConverter::
-DXFToEggConverter(const DXFToEggConverter ©) :
- SomethingToEggConverter(copy)
-{
-}
-
-/**
- *
- */
-DXFToEggConverter::
-~DXFToEggConverter() {
-}
-
-/**
- * Allocates and returns a new copy of the converter.
- */
-SomethingToEggConverter *DXFToEggConverter::
-make_copy() {
- return new DXFToEggConverter(*this);
-}
-
-
-/**
- * Returns the English name of the file type this converter supports.
- */
-std::string DXFToEggConverter::
-get_name() const {
- return "DXF";
-}
-
-/**
- * Returns the common extension of the file type this converter supports.
- */
-std::string DXFToEggConverter::
-get_extension() const {
- return "dxf";
-}
-
-/**
- * Returns true if this file type can transparently load compressed files
- * (with a .pz extension), false otherwise.
- */
-bool DXFToEggConverter::
-supports_compressed() const {
- return true;
-}
-
-/**
- * Handles the reading of the input file and converting it to egg. Returns
- * true if successful, false otherwise.
- */
-bool DXFToEggConverter::
-convert_file(const Filename &filename) {
- clear_error();
-
- if (_egg_data->get_coordinate_system() == CS_default) {
- _egg_data->set_coordinate_system(CS_zup_right);
- }
-
- process(filename);
- return !had_error();
-}
-
-/**
- *
- */
-DXFLayer *DXFToEggConverter::
-new_layer(const std::string &name) {
- return new DXFToEggLayer(name, get_egg_data());
-}
-
-/**
- * If the entity is a polygon, creates the corresponding egg polygon.
- */
-void DXFToEggConverter::
-done_entity() {
- if (_entity == EN_polyline) {
- // A Polyline is either an unclosed series of connected line segments, or
- // a closed polygon of arbitrary complexity.
-
- if ((_flags & PF_3d) == 0) {
- // it's a 2-d polygon; convert it to 3-d coordinates.
- ocs_2_wcs();
- }
-
- if (_flags & PF_closed) {
- // it's closed; create a polygon.
- nassertv(_layer!=nullptr);
- ((DXFToEggLayer *)_layer)->add_polygon(this);
- } else {
- // It's open; create a series of line segments.
- nassertv(_layer!=nullptr);
- ((DXFToEggLayer *)_layer)->add_line(this);
- }
-
- } else if (_entity == EN_3dface) {
- // DXF can also represent a polygon as a 3DFace. This might be either a
- // quad or a triangle (if two of the vertices are the same). We'll add
- // the vertices to our list of vertices and then define the polygon.
- _verts.clear();
- _verts.push_back(DXFVertex(_s));
- _verts.push_back(DXFVertex(_r));
- _verts.push_back(DXFVertex(_q));
- _verts.push_back(DXFVertex(_p));
-
- nassertv(_layer!=nullptr);
- ((DXFToEggLayer *)_layer)->add_polygon(this);
- }
-}
-
-/**
- * A hook for user code, if desired. This function is called when some
- * unexpected error occurs while reading the DXF file.
- */
-void DXFToEggConverter::
-error() {
- _error = true;
-}
diff --git a/pandatool/src/dxfegg/dxfToEggConverter.h b/pandatool/src/dxfegg/dxfToEggConverter.h
deleted file mode 100644
index 56969e74..00000000
--- a/pandatool/src/dxfegg/dxfToEggConverter.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file dxfToEggConverter.h
- * @author drose
- * @date 2004-05-04
- */
-
-#ifndef DXFTOEGGCONVERTER_H
-#define DXFTOEGGCONVERTER_H
-
-#include "pandatoolbase.h"
-
-#include "somethingToEggConverter.h"
-#include "dxfFile.h"
-
-/**
- * This class supervises the construction of an EggData structure from a DXF
- * file.
- */
-class DXFToEggConverter : public SomethingToEggConverter, public DXFFile {
-public:
- DXFToEggConverter();
- DXFToEggConverter(const DXFToEggConverter ©);
- ~DXFToEggConverter();
-
- virtual SomethingToEggConverter *make_copy();
-
- virtual std::string get_name() const;
- virtual std::string get_extension() const;
- virtual bool supports_compressed() const;
-
- virtual bool convert_file(const Filename &filename);
-
-protected:
- virtual DXFLayer *new_layer(const std::string &name);
- virtual void done_entity();
- virtual void error();
-
- bool _error;
-};
-
-#endif
diff --git a/pandatool/src/dxfegg/dxfToEggLayer.cxx b/pandatool/src/dxfegg/dxfToEggLayer.cxx
deleted file mode 100644
index 3ecb915e..00000000
--- a/pandatool/src/dxfegg/dxfToEggLayer.cxx
+++ /dev/null
@@ -1,99 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file dxfToEggLayer.cxx
- * @author drose
- * @date 2004-05-04
- */
-
-#include "dxfToEggLayer.h"
-#include "dxfToEggConverter.h"
-
-#include "dxfFile.h"
-#include "eggGroup.h"
-#include "eggPolygon.h"
-#include "eggLine.h"
-#include "eggVertex.h"
-#include "eggVertexPool.h"
-
-
-/**
- *
- */
-DXFToEggLayer::
-DXFToEggLayer(const std::string &name, EggGroupNode *parent) : DXFLayer(name) {
- _group = new EggGroup(name);
- parent->add_child(_group);
- _vpool = new EggVertexPool(name);
- _group->add_child(_vpool);
-}
-
-
-/**
- * Given that done_entity() has just been called and that the current entity
- * represents a polygon, adds the corresponding polygon to the layer's
- * EggGroup and vertex pool.
- */
-void DXFToEggLayer::
-add_polygon(const DXFToEggConverter *entity) {
- EggPolygon *poly = new EggPolygon;
- _group->add_child(poly);
-
- const DXFFile::Color &color = entity->get_color();
- poly->set_color(LColor(color.r, color.g, color.b, 1.0));
-
- // A polyline's vertices are stored in the attached vector by dxf.cxx. They
- // were defined in the DXF file using a series of "VERTEX" entries.
-
- // For a 3dface, the vertices are defined explicitly as part of the entity;
- // but in this case, they were added to the vector before add_polygon() was
- // called.
-
- DXFVertices::const_iterator vi;
- for (vi = entity->_verts.begin();
- vi != entity->_verts.end();
- ++vi) {
- poly->add_vertex(add_vertex(*vi));
- }
-
- poly->cleanup();
-}
-
-
-/**
- * Similar to add_polygon(), but adds a set of point lights instead.
- */
-void DXFToEggLayer::
-add_line(const DXFToEggConverter *entity) {
- EggLine *line = new EggLine;
- _group->add_child(line);
-
- const DXFFile::Color &color = entity->get_color();
- line->set_color(LColor(color.r, color.g, color.b, 1.0));
-
- DXFVertices::const_iterator vi;
- for (vi = entity->_verts.begin();
- vi != entity->_verts.end();
- ++vi) {
- line->add_vertex(add_vertex(*vi));
- }
-}
-
-
-/**
- * Adds a unique vertex to the layer's vertex pool and returns it. If the
- * vertex was already defined previously, returns the original definition.
- * This is designed to share the common vertices within a layer.
- */
-EggVertex *DXFToEggLayer::
-add_vertex(const DXFVertex &vert) {
- EggVertex egg_vert;
- egg_vert.set_pos(vert._p);
-
- return _vpool->create_unique_vertex(egg_vert);
-}
diff --git a/pandatool/src/dxfegg/dxfToEggLayer.h b/pandatool/src/dxfegg/dxfToEggLayer.h
deleted file mode 100644
index 9067cc70..00000000
--- a/pandatool/src/dxfegg/dxfToEggLayer.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file dxfToEggLayer.h
- * @author drose
- * @date 2004-05-04
- */
-
-#ifndef DXFTOEGGLAYER_H
-#define DXFTOEGGLAYER_H
-
-#include "pandatoolbase.h"
-
-#include "dxfLayer.h"
-#include "eggVertexPool.h"
-#include "eggGroup.h"
-#include "pointerTo.h"
-
-class EggGroupNode;
-class EggVertex;
-class DXFVertex;
-class DXFToEggConverter;
-
-/**
- * The specialization of DXFLayer used by DXFToEggConverter. It contains a
- * pointer to an EggGroup and a vertex pool; these are used to build up
- * polygons grouped by layer in the egg file as each polygon is read from the
- * DXF file.
- */
-class DXFToEggLayer : public DXFLayer {
-public:
- DXFToEggLayer(const std::string &name, EggGroupNode *parent);
-
- void add_polygon(const DXFToEggConverter *entity);
- void add_line(const DXFToEggConverter *entity);
- EggVertex *add_vertex(const DXFVertex &vertex);
-
- PT(EggVertexPool) _vpool;
- PT(EggGroup) _group;
-};
-
-
-#endif
diff --git a/pandatool/src/dxfprogs/CMakeLists.txt b/pandatool/src/dxfprogs/CMakeLists.txt
deleted file mode 100644
index 0a2033d1..00000000
--- a/pandatool/src/dxfprogs/CMakeLists.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-if(NOT BUILD_TOOLS)
- return()
-endif()
-
-add_executable(dxf-points dxfPoints.cxx dxfPoints.h)
-target_link_libraries(dxf-points p3progbase p3dxf)
-install(TARGETS dxf-points EXPORT Tools COMPONENT Tools DESTINATION ${CMAKE_INSTALL_BINDIR})
-
-if(HAVE_EGG)
-
- add_executable(egg2dxf eggToDXF.cxx eggToDXF.h eggToDXFLayer.cxx eggToDXFLayer.h)
- target_link_libraries(egg2dxf p3dxfegg p3eggbase p3progbase)
- install(TARGETS egg2dxf EXPORT Tools COMPONENT Tools DESTINATION ${CMAKE_INSTALL_BINDIR})
-
- add_executable(dxf2egg dxfToEgg.cxx dxfToEgg.h)
- target_link_libraries(dxf2egg p3dxfegg p3eggbase p3progbase)
- install(TARGETS dxf2egg EXPORT Tools COMPONENT Tools DESTINATION ${CMAKE_INSTALL_BINDIR})
-
-endif()
diff --git a/pandatool/src/dxfprogs/dxfPoints.cxx b/pandatool/src/dxfprogs/dxfPoints.cxx
deleted file mode 100644
index c0002b28..00000000
--- a/pandatool/src/dxfprogs/dxfPoints.cxx
+++ /dev/null
@@ -1,89 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file dxfPoints.cxx
- * @author drose
- * @date 2004-05-04
- */
-
-#include "dxfPoints.h"
-
-/**
- *
- */
-DXFPoints::
-DXFPoints() :
- WithOutputFile(true, true, false)
-{
- // Indicate the extension name we expect the user to supply for output
- // files.
- _preferred_extension = ".txt";
-
- set_program_brief("extract points from AutoCAD .dxf files");
- set_program_description
- ("This program reads an AutoCAD .dxf file and generates a simple "
- "list of all the points contained within it, one per line, to a "
- "text file, or to standard output.");
-
- clear_runlines();
- add_runline("[opts] input.dxf > output.txt");
- add_runline("[opts] -o output.txt input.dxf");
- add_runline("[opts] input.dxf output.txt");
-}
-
-
-/**
- *
- */
-void DXFPoints::
-run() {
- // Invoke the DXFFile base class to process the input file.
- process(_input_filename);
-}
-
-/**
- * This is inherited from DXFFile, and gets called as each entity (face, line,
- * whatever) has finished processing.
- */
-void DXFPoints::
-done_entity() {
- if (_entity == EN_point) {
- get_output() << _p << "\n";
-
- } else if (_entity == EN_insert) {
- ocs_2_wcs();
- get_output() << _p << "\n";
- }
-}
-
-/**
- *
- */
-bool DXFPoints::
-handle_args(ProgramBase::Args &args) {
- if (args.empty()) {
- nout << "You must specify the .dxf file to read on the command line.\n";
- return false;
-
- } else if (args.size() != 1) {
- nout << "You must specify only one .dxf file to read on the command line.\n";
- return false;
- }
-
- _input_filename = args[0];
-
- return true;
-}
-
-
-int main(int argc, char *argv[]) {
- DXFPoints prog;
- prog.parse_command_line(argc, argv);
- prog.run();
- return 0;
-}
diff --git a/pandatool/src/dxfprogs/dxfPoints.h b/pandatool/src/dxfprogs/dxfPoints.h
deleted file mode 100644
index 9715b5d6..00000000
--- a/pandatool/src/dxfprogs/dxfPoints.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file dxfPoints.h
- * @author drose
- * @date 2004-05-04
- */
-
-#ifndef DXFPOINTS_H
-#define DXFPOINTS_H
-
-#include "pandatoolbase.h"
-#include "programBase.h"
-#include "withOutputFile.h"
-
-#include "dxfFile.h"
-
-/**
- * A simple program to read a dxf file and list the points contained within it
- * to a text file.
- */
-class DXFPoints : public ProgramBase, public WithOutputFile, public DXFFile {
-public:
- DXFPoints();
-
- void run();
-
- virtual void done_entity();
-
-protected:
- virtual bool handle_args(Args &args);
-
- Filename _input_filename;
-};
-
-#endif
diff --git a/pandatool/src/dxfprogs/dxfToEgg.cxx b/pandatool/src/dxfprogs/dxfToEgg.cxx
deleted file mode 100644
index 4ca66f0a..00000000
--- a/pandatool/src/dxfprogs/dxfToEgg.cxx
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file dxfToEgg.cxx
- * @author drose
- * @date 2004-05-04
- */
-
-#include "dxfToEgg.h"
-
-#include "dxfToEggConverter.h"
-
-/**
- *
- */
-DXFToEgg::
-DXFToEgg() :
- SomethingToEgg("DXF", ".dxf")
-{
- add_units_options();
- add_normals_options();
- add_transform_options();
-
- set_program_brief("convert AutoCAD .dxf files to .egg files");
- set_program_description
- ("This program converts DXF (AutoCAD interchange format) to egg. It "
- "only converts polygon data, with no fancy tricks. DXF does not support "
- "hierarchical databases, so dxf2egg creates a single group at the root "
- "level for each layer in the DXF file.");
-
- redescribe_option
- ("cs",
- "Specify the coordinate system of the input " + _format_name +
- " file. Normally, this is z-up.");
-
- _coordinate_system = CS_zup_right;
-}
-
-/**
- *
- */
-void DXFToEgg::
-run() {
- nout << "Reading " << _input_filename << "\n";
-
- _data->set_coordinate_system(_coordinate_system);
-
- DXFToEggConverter converter;
- converter.set_egg_data(_data);
- converter._allow_errors = _allow_errors;
-
- apply_parameters(converter);
-
- if (!converter.convert_file(_input_filename)) {
- nout << "Errors in conversion.\n";
- exit(1);
- }
-
- write_egg_file();
- nout << "\n";
-}
-
-
-int main(int argc, char *argv[]) {
- DXFToEgg prog;
- prog.parse_command_line(argc, argv);
- prog.run();
- return 0;
-}
diff --git a/pandatool/src/dxfprogs/dxfToEgg.h b/pandatool/src/dxfprogs/dxfToEgg.h
deleted file mode 100644
index cb8b5b6b..00000000
--- a/pandatool/src/dxfprogs/dxfToEgg.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file dxfToEgg.h
- * @author drose
- * @date 2004-05-04
- */
-
-#ifndef DXFTOEGG_H
-#define DXFTOEGG_H
-
-#include "pandatoolbase.h"
-
-#include "somethingToEgg.h"
-#include "dxfToEggConverter.h"
-
-/**
- * A program to read a DXF file and generate an egg file.
- */
-class DXFToEgg : public SomethingToEgg {
-public:
- DXFToEgg();
-
- void run();
-};
-
-#endif
diff --git a/pandatool/src/dxfprogs/eggToDXF.cxx b/pandatool/src/dxfprogs/eggToDXF.cxx
deleted file mode 100644
index 412b8156..00000000
--- a/pandatool/src/dxfprogs/eggToDXF.cxx
+++ /dev/null
@@ -1,149 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggToDXF.cxx
- * @author drose
- * @date 2004-05-04
- */
-
-#include "eggToDXF.h"
-#include "eggPolygon.h"
-#include "dcast.h"
-
-/**
- *
- */
-EggToDXF::
-EggToDXF() :
- EggToSomething("DXF", ".dxf", true, false)
-{
- set_binary_output(true);
- set_program_brief("convert .egg files to AutoCAD .dxf files");
- set_program_description
- ("This program converts files from egg format to AutoCAD DXF format. "
- "Since DXF does not support nested hierarchies, vertex normals, or any "
- "fancy stuff you are probably used to, there is some information lost "
- "in the conversion");
-
- add_option
- ("p", "", 0,
- "Use POLYLINE to represent polygons instead of the default, 3DFACE.",
- &EggToDXF::dispatch_none, &_use_polyline);
-
- _coordinate_system = CS_zup_right;
- _got_coordinate_system = true;
-}
-
-/**
- *
- */
-void EggToDXF::
-run() {
- get_layers(_data);
- if (_layers.empty()) {
- nout << "Egg file contains no polygons. Output file not written.\n";
- exit(1);
- }
-
- // uniquify_names("layer", _layers.begin(), _layers.end());
-
- std::ostream &out = get_output();
-
- // Autodesk says we don't need the header, but some DXF-reading programs
- // might get confused if it's missing. We'll write an empty header.
- out << "0\nSECTION\n"
- << "2\nHEADER\n"
- << "0\nENDSEC\n";
-
- write_tables(out);
- write_entities(out);
- out << "0\nEOF\n"; // Mark end of file.
-
- if (!out) {
- nout << "An error occurred while writing.\n";
- exit(1);
- }
-}
-
-/**
- * Traverses the hierarchy, looking for groups that contain polygons. Any
- * such groups are deemed to be layers, and are added to the layers set.
- */
-void EggToDXF::
-get_layers(EggGroupNode *group) {
- bool has_polys = false;
-
- EggToDXFLayer layer(this, group);
-
- EggGroupNode::iterator ci;
- for (ci = group->begin(); ci != group->end(); ++ci) {
- EggNode *child = (*ci);
- if (child->is_of_type(EggPolygon::get_class_type())) {
- EggPolygon *poly = DCAST(EggPolygon, child);
- has_polys = true;
-
- layer.add_color(poly->get_color());
-
- } else if (child->is_of_type(EggGroupNode::get_class_type())) {
- get_layers(DCAST(EggGroupNode, child));
- }
- }
-
- if (has_polys) {
- layer.choose_overall_color();
- _layers.push_back(layer);
- }
-}
-
-
-/**
- * Writes out the "layers", e.g. groups. This is just the layers definition
- * in the tables section at the beginning of the file; the actual geometry
- * gets written later, in write_entities().
- */
-void EggToDXF::
-write_tables(std::ostream &out) {
- out << "0\nSECTION\n"
- << "2\nTABLES\n" // Begin TABLES section.
- << "0\nTABLE\n"
- << "2\nLAYER\n" // Define LAYERS.
- << "70\n" << _layers.size() << "\n";
-
- EggToDXFLayers::iterator li;
- for (li = _layers.begin(); li != _layers.end(); ++li) {
- (*li).write_layer(out);
- }
-
- out << "0\nENDTAB\n" // End LAYERS definition.
- << "0\nENDSEC\n"; // End TABLES section.
-}
-
-/**
- * Writes out the "entities", e.g. polygons, defined for all layers.
- */
-void EggToDXF::
-write_entities(std::ostream &out) {
- out << "0\nSECTION\n"
- << "2\nENTITIES\n"; // Begin ENTITIES section.
-
- EggToDXFLayers::iterator li;
- for (li = _layers.begin(); li != _layers.end(); ++li) {
- (*li).write_entities(out);
- }
-
- out << "0\nENDSEC\n"; // End ENTITIES section.
-}
-
-
-
-int main(int argc, char *argv[]) {
- EggToDXF prog;
- prog.parse_command_line(argc, argv);
- prog.run();
- return 0;
-}
diff --git a/pandatool/src/dxfprogs/eggToDXF.h b/pandatool/src/dxfprogs/eggToDXF.h
deleted file mode 100644
index da7764fb..00000000
--- a/pandatool/src/dxfprogs/eggToDXF.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggToDXF.h
- * @author drose
- * @date 2004-05-04
- */
-
-#ifndef EGGTODXF_H
-#define EGGTODXF_H
-
-#include "pandatoolbase.h"
-
-#include "eggToSomething.h"
-#include "eggToDXFLayer.h"
-
-class EggGroupNode;
-
-/**
- * A program to read an egg file and write a DXF file.
- */
-class EggToDXF : public EggToSomething {
-public:
- EggToDXF();
-
- void run();
-
- bool _use_polyline;
-
-private:
- void get_layers(EggGroupNode *group);
- void write_tables(std::ostream &out);
- void write_entities(std::ostream &out);
-
- EggToDXFLayers _layers;
-};
-
-#endif
diff --git a/pandatool/src/dxfprogs/eggToDXFLayer.cxx b/pandatool/src/dxfprogs/eggToDXFLayer.cxx
deleted file mode 100644
index 6922f0b8..00000000
--- a/pandatool/src/dxfprogs/eggToDXFLayer.cxx
+++ /dev/null
@@ -1,219 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggToDXFLayer.cxx
- * @author drose
- * @date 2004-05-04
- */
-
-#include "eggToDXFLayer.h"
-#include "eggToDXF.h"
-#include "dxfFile.h"
-#include "eggGroup.h"
-#include "eggGroupNode.h"
-#include "eggPolygon.h"
-#include "dcast.h"
-
-using std::ostream;
-
-/**
- *
- */
-EggToDXFLayer::
-EggToDXFLayer(EggToDXF *egg2dxf, EggGroupNode *group) :
- _egg2dxf(egg2dxf), _group(group)
-{
- _layer_color = -1;
-}
-
-/**
- *
- */
-EggToDXFLayer::
-EggToDXFLayer(const EggToDXFLayer ©) :
- _egg2dxf(copy._egg2dxf),
- _group(copy._group),
- _layer_color(copy._layer_color)
-{
- // The copy constructor doesn't bother with the ColorCounts.
-}
-
-/**
- *
- */
-void EggToDXFLayer::
-operator = (const EggToDXFLayer ©) {
- _egg2dxf = copy._egg2dxf;
- _group = copy._group;
- _layer_color = copy._layer_color;
-
- // The copy constructor doesn't bother with the ColorCounts.
-}
-
-/**
- * Records that one polygon is defined using the indicated color. This will
- * get accumulated; the color used by the majority of polygons will become the
- * layer color.
- */
-void EggToDXFLayer::
-add_color(const LColor &color) {
- int autocad_color = get_autocad_color(color);
-
- ColorCounts::iterator cci;
- cci = _color_counts.find(autocad_color);
- if (cci == _color_counts.end()) {
- // The first time a particular color was used. Count it once.
- _color_counts[autocad_color] = 1;
- } else {
- // This color has been used before. Count it again.
- (*cci).second++;
- }
-}
-
-
-/**
- * After all polygons have been accounted for, chooses the polygon color that
- * occurred most often as the layer color.
- */
-void EggToDXFLayer::
-choose_overall_color() {
- int max_count = 0;
-
- ColorCounts::iterator cci;
- for (cci = _color_counts.begin(); cci != _color_counts.end(); ++cci) {
- int count = (*cci).second;
- if (count > max_count) {
- _layer_color = (*cci).first;
- max_count = count;
- }
- }
-}
-
-
-/**
- * Writes the layer definition into the table at the beginning of the DXF
- * file. This does not write the actual geometry; that gets done later by
- * write_entities().
- */
-void EggToDXFLayer::
-write_layer(ostream &out) {
- out << "0\nLAYER\n"
- << "2\n" << _group->get_name() << "\n"
- << "70\n0\n"
- << "62\n" << _layer_color << "\n"
- << "6\nCONTINUOUS\n";
-}
-
-/**
- * Writes a polygon as a POLYLINE entity.
- */
-void EggToDXFLayer::
-write_polyline(EggPolygon *poly, ostream &out) {
- out << "0\nPOLYLINE\n"
- << "8\n" << _group->get_name() << "\n"
- << "66\n1\n"
- << "70\n1\n"
- << "62\n" << get_autocad_color(poly->get_color()) << "\n";
-
- // Since DXF uses a clockwise ordering convention, we must reverse the order
- // in which we write out the vertices.
- EggPolygon::reverse_iterator vi;
- for (vi = poly->rbegin(); vi != poly->rend(); ++vi) {
- EggVertex *vtx = (*vi);
- LVecBase3d pos = vtx->get_pos3() * _group->get_vertex_frame();
- out << "0\nVERTEX\n"
- << "10\n" << pos[0] << "\n"
- << "20\n" << pos[1] << "\n"
- << "30\n" << pos[2] << "\n";
- }
- out << "0\nSEQEND\n";
-}
-
-/**
- * Writes a polygon as a 3DFACE entity.
- */
-void EggToDXFLayer::
-write_3d_face(EggPolygon *poly, ostream &out) {
- if (poly->size() > 4) {
- // If we have a big polygon, we have to triangulate it, since 3DFaces can
- // only be tris and quads.
- PT(EggGroup) group = new EggGroup;
- poly->triangulate_into(group, true);
-
- EggGroupNode::iterator ci;
- for (ci = group->begin(); ci != group->end(); ++ci) {
- EggNode *child = (*ci);
- if (child->is_of_type(EggPolygon::get_class_type())) {
- write_3d_face(DCAST(EggPolygon, child), out);
- }
- }
-
- } else if (poly->size() > 2) {
- // Otherwise, if we have a tri or a quad, just write it out.
- out << "0\n3DFACE\n"
- << "8\n" << _group->get_name() << "\n";
-
- // Since DXF uses a clockwise ordering convention, we must reverse the
- // order in which we write out the vertices.
- int i;
- EggPolygon::reverse_iterator vi;
- for (i = 0, vi = poly->rbegin(); vi != poly->rend(); ++i, ++vi) {
- EggVertex *vtx = (*vi);
- LVecBase3d pos = vtx->get_pos3() * _group->get_vertex_frame();
- out << 10 + i << "\n" << pos[0] << "\n"
- << 20 + i << "\n" << pos[1] << "\n"
- << 30 + i << "\n" << pos[2] << "\n";
- if (i == 2 && poly->size() == 3) {
- // A special case for triangles: repeat the last vertex.
- out << 11 + i << "\n" << pos[0] << "\n"
- << 21 + i << "\n" << pos[1] << "\n"
- << 31 + i << "\n" << pos[2] << "\n";
- }
- }
- }
-}
-
-
-/**
- * Writes out the "entities", e.g. polygons, defined for the current layer.
- */
-void EggToDXFLayer::
-write_entities(ostream &out) {
- EggGroupNode::iterator ci;
- for (ci = _group->begin(); ci != _group->end(); ++ci) {
- EggNode *child = (*ci);
- if (child->is_of_type(EggPolygon::get_class_type())) {
- EggPolygon *poly = DCAST(EggPolygon, child);
- if (_egg2dxf->_use_polyline) {
- write_polyline(poly, out);
- } else {
- write_3d_face(poly, out);
- }
- }
- }
-}
-
-/**
- * Returns the AutoCAD color index that most closely matches the indicated
- * EggColor.
- */
-int EggToDXFLayer::
-get_autocad_color(const LColor &color) {
- typedef pmap ColorMap;
- static ColorMap _map;
-
- ColorMap::iterator cmi;
- cmi = _map.find(color);
- if (cmi != _map.end()) {
- return (*cmi).second;
- }
-
- int result = DXFFile::find_color(color[0], color[1], color[2]);
- _map[color] = result;
- return result;
-}
diff --git a/pandatool/src/dxfprogs/eggToDXFLayer.h b/pandatool/src/dxfprogs/eggToDXFLayer.h
deleted file mode 100644
index a5fe7b75..00000000
--- a/pandatool/src/dxfprogs/eggToDXFLayer.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggToDXFLayer.h
- * @author drose
- * @date 2004-05-04
- */
-
-#ifndef EGGTODXFLAYER_H
-#define EGGTODXFLAYER_H
-
-#include "pandatoolbase.h"
-#include "pmap.h"
-#include "pvector.h"
-#include "luse.h"
-
-class EggToDXF;
-class EggPolygon;
-class EggGroupNode;
-
-/**
- * A single layer in the DXF file to be written by EggToDXF.
- */
-class EggToDXFLayer {
-public:
- EggToDXFLayer(EggToDXF *egg2dxf, EggGroupNode *group);
- EggToDXFLayer(const EggToDXFLayer ©);
- void operator = (const EggToDXFLayer ©);
-
- void add_color(const LColor &color);
- void choose_overall_color();
-
- void write_layer(std::ostream &out);
- void write_polyline(EggPolygon *poly, std::ostream &out);
- void write_3d_face(EggPolygon *poly, std::ostream &out);
- void write_entities(std::ostream &out);
-
-private:
- int get_autocad_color(const LColor &color);
-
- typedef pmap ColorCounts;
- ColorCounts _color_counts;
-
- EggToDXF *_egg2dxf;
- EggGroupNode *_group;
- int _layer_color;
-};
-
-typedef pvector EggToDXFLayers;
-
-#endif
diff --git a/pandatool/src/egg-mkfont/CMakeLists.txt b/pandatool/src/egg-mkfont/CMakeLists.txt
deleted file mode 100644
index 60f0331e..00000000
--- a/pandatool/src/egg-mkfont/CMakeLists.txt
+++ /dev/null
@@ -1,25 +0,0 @@
-if(NOT BUILD_TOOLS)
- return()
-endif()
-
-if(NOT HAVE_EGG OR NOT HAVE_FREETYPE)
- return()
-endif()
-
-set(P3EGG_MKFONT_HEADERS
- eggMakeFont.h
- rangeDescription.h rangeDescription.I
- rangeIterator.h rangeIterator.I
-)
-
-set(P3EGG_MKFONT_SOURCES
- eggMakeFont.cxx
- rangeDescription.cxx
- rangeIterator.cxx
-)
-
-composite_sources(egg-mkfont P3EGG_MKFONT_SOURCES)
-add_executable(egg-mkfont ${P3EGG_MKFONT_HEADERS} ${P3EGG_MKFONT_SOURCES})
-target_link_libraries(egg-mkfont p3palettizer p3eggbase p3pandatoolbase)
-
-install(TARGETS egg-mkfont EXPORT Tools COMPONENT Tools DESTINATION ${CMAKE_INSTALL_BINDIR})
diff --git a/pandatool/src/egg-mkfont/egg-mkfont_composite1.cxx b/pandatool/src/egg-mkfont/egg-mkfont_composite1.cxx
deleted file mode 100644
index aa44d511..00000000
--- a/pandatool/src/egg-mkfont/egg-mkfont_composite1.cxx
+++ /dev/null
@@ -1,5 +0,0 @@
-
-#include "eggMakeFont.cxx"
-#include "rangeDescription.cxx"
-#include "rangeIterator.cxx"
-
diff --git a/pandatool/src/egg-mkfont/eggMakeFont.cxx b/pandatool/src/egg-mkfont/eggMakeFont.cxx
deleted file mode 100644
index 4efa4a5a..00000000
--- a/pandatool/src/egg-mkfont/eggMakeFont.cxx
+++ /dev/null
@@ -1,745 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggMakeFont.cxx
- * @author drose
- * @date 2001-02-16
- */
-
-#include "eggMakeFont.h"
-#include "rangeIterator.h"
-#include "palettizer.h"
-#include "filenameUnifier.h"
-#include "eggFile.h"
-#include "textureImage.h"
-#include "sourceTextureImage.h"
-#include "pnmTextMaker.h"
-#include "pnmTextGlyph.h"
-#include "eggData.h"
-#include "eggGroup.h"
-#include "eggPoint.h"
-#include "eggPolygon.h"
-#include "eggTexture.h"
-#include "eggVertexPool.h"
-#include "eggVertex.h"
-#include "string_utils.h"
-#include "dcast.h"
-
-#include
-
-using std::string;
-
-/**
- *
- */
-EggMakeFont::
-EggMakeFont() : EggWriter(true, false) {
- set_program_brief("generates .egg files with rasterized font glyphs");
- set_program_description
- ("egg-mkfont uses the FreeType library to generate an egg file "
- "and a series of texture images from a font file "
- "input, such as a TTF file. The resulting egg file "
- "can be loaded in Panda as a font for rendering text, even "
- "if FreeType is not compiled into the executing Panda.\n\n"
-
- "egg-mkfont will normally run the generated egg file through "
- "egg-palettize automatically as part of the generation process. "
- "This collects the individual glyph textures into a small number "
- "of texture maps. If you intend to run the font through egg-palettize "
- "yourself later, you may choose to omit this step.");
-
- clear_runlines();
- add_runline("[opts] -o output.egg font");
- add_runline("[opts] font output.egg");
-
- add_option
- ("fg", "r,g,b[,a]", 0,
- "Specifies the foreground color of the generated texture map. The "
- "default is white: 1,1,1,1, which leads to the most flexibility "
- "as the color can be modulated at runtime to any suitable color.",
- &EggMakeFont::dispatch_color, nullptr, &_fg[0]);
-
- add_option
- ("bg", "r,g,b[,a]", 0,
- "Specifies the background color of the generated texture map. The "
- "default is transparent: 1,1,1,0, which allows the text to be "
- "visible against any color background by placing a polygon of a "
- "suitable color behind it. If the alpha component of either -fg "
- "or -bg is not 1, the generated texture images will include an "
- "alpha component; if both colors specify an alpha component of 1 "
- "(or do not specify an alpha compenent), then the generated images "
- "will not include an alpha component.",
- &EggMakeFont::dispatch_color, nullptr, &_bg[0]);
-
- add_option
- ("interior", "r,g,b[,a]", 0,
- "Specifies the color to render the interior part of a hollow font. "
- "This is a special effect that involves analysis of the bitmap after "
- "the font has been rendered, and so is more effective when the pixel "
- "size is large. It also implies -noaa (but you can use a scale "
- "factor with -sf to achieve antialiasing).",
- &EggMakeFont::dispatch_color, &_got_interior, &_interior[0]);
-
- add_option
- ("chars", "range", 0,
- "Specifies the characters of the font that are used. The range "
- "specification may include combinations of decimal or hex unicode "
- "values (where hex values are identified with a leading 0x), separated "
- "by commas and hyphens to indicate ranges, e.g. '32-126,0xfa0-0xfff'. "
- "It also may specify ranges of ASCII characters by enclosing them "
- "within square brackets, e.g. '[A-Za-z0-9]'. If this is not specified, "
- "the default set has all ASCII characters and an assorted set of "
- "latin-1 characters, diacritics and punctuation marks.",
- &EggMakeFont::dispatch_range, nullptr, &_range);
-
- add_option
- ("extra", "file.egg", 0,
- "Specifies additional externally-painted glyphs to mix into the "
- "generated egg file. The named egg file is expected to contain one "
- "or more groups, each of which is named with the decimal unicode "
- "number of a character and should contain one polygon. These groups "
- "are simply copied into the output egg file as if they were generated "
- "locally. This option may be repeated.",
- &EggMakeFont::dispatch_vector_string, nullptr, &_extra_filenames);
-
- add_option
- ("ppu", "pixels", 0,
- "Specify the pixels per unit. This is the number of pixels in the "
- "generated texture map that are used for each onscreen unit (or each "
- "10 points of font; see -ps). Setting this number larger results in "
- "an easier-to-read font, but at the cost of more texture memory. "
- "The default is 40.",
- &EggMakeFont::dispatch_double, nullptr, &_pixels_per_unit);
-
- add_option
- ("ps", "size", 0,
- "Specify the point size of the resulting font. This controls the "
- "apparent size of the font when it is rendered onscreen. By convention, "
- "a 10 point font is 1 screen unit high, so the default is 10.",
- &EggMakeFont::dispatch_double, nullptr, &_point_size);
-
- add_option
- ("sdf", "", 0,
- "If this is set, a signed distance field will be generated, which "
- "results in crisp text even when the text is enlarged or zoomed in.",
- &EggMakeFont::dispatch_true, nullptr, &_generate_distance_field);
-
- add_option
- ("pm", "n", 0,
- "The number of extra pixels around a single character in the "
- "generated polygon. This may be a floating-point number. The "
- "default is 1.",
- &EggMakeFont::dispatch_double, nullptr, &_poly_margin);
-
- add_option
- ("tm", "n", 0,
- "The number of extra pixels around each character in the texture map. "
- "This may only be an integer. The default is 2. This is meaningful "
- "when -nopal is also used; in the normal case, use -pm to control "
- "both the polygon size and the texture map spacing.",
- &EggMakeFont::dispatch_int, nullptr, &_tex_margin);
-
- add_option
- ("rm", "n", 0,
- "The amount of padding in screen units to place around the glyph when "
- "rendered. This differs from -pm in that it has no effect on the "
- "generated texture map, only on the generated egg. Use this in order to "
- "space the characters out in case they appear to be too close together "
- "when rendered. The default is 0.",
- &EggMakeFont::dispatch_double, nullptr, &_render_margin);
-
- add_option
- ("sf", "factor", 0,
- "The scale factor of the generated image. This is the factor by which "
- "the font image is generated oversized, then reduced to its final size, "
- "to improve antialiasing. If the specified font contains one "
- "or more fixed-size fonts instead of a scalable font, the scale factor "
- "may be automatically adjusted as necessary to scale the closest-"
- "matching font to the desired pixel size. The default is 2.",
- &EggMakeFont::dispatch_double, &_got_scale_factor, &_scale_factor);
-
- add_option
- ("noaa", "", 0,
- "Disable low-level antialiasing by the Freetype library. "
- "This is unrelated to the antialiasing that is applied due to the "
- "scale factor specified by -sf; you may have either one, neither, or "
- "both kinds of antialiasing enabled.",
- &EggMakeFont::dispatch_none, &_no_native_aa);
-
- add_option
- ("nopal", "", 0,
- "Don't run egg-palettize automatically on the output file, but "
- "just output the raw egg file and all of its individual texture "
- "images, one for each glyph.",
- &EggMakeFont::dispatch_none, &_no_palettize);
-
- add_option
- ("nr", "", 0,
- "Don't actually reduce the images after applying the scale factor, but "
- "leave them at their inflated sizes. Presumably you will reduce "
- "them later, for instance with egg-palettize.",
- &EggMakeFont::dispatch_none, &_no_reduce);
-
- add_option
- ("gp", "pattern", 0,
- "The pattern to be used to generate the glyph texture images. This "
- "string will be passed to sprintf to generate the actual file name; it "
- "should contain the string %d or %x (or some variant such as %03d) "
- "which will be filled in with the Unicode number of each symbol. "
- "If it is omitted, the default is based on the name of the egg file. "
- "This is used only if -nopal is specified; in the normal case, "
- "without -nopal, use -pp instead.",
- &EggMakeFont::dispatch_string, nullptr, &_output_glyph_pattern);
-
- add_option
- ("pp", "pattern", 0,
- "The pattern to be used to generate the palette texture images. This "
- "string is effectively passed to egg-palettize as the -tn option, and "
- "thus should contain %i for the palette index number. This is used "
- "if -nopal is not specified.",
- &EggMakeFont::dispatch_string, nullptr, &_output_palette_pattern);
-
- add_option
- ("palsize", "xsize,ysize", 0,
- "Specify the size of the palette texture images. This is used if "
- "-nopal is not specified.",
- &EggMakeFont::dispatch_int_pair, nullptr, _palette_size);
-
- add_option
- ("face", "index", 0,
- "Specify the face index of the particular face within the font file "
- "to use. Some font files contain multiple faces, indexed beginning "
- "at 0. The default is face 0.",
- &EggMakeFont::dispatch_int, nullptr, &_face_index);
-
- _fg.set(1.0, 1.0, 1.0, 1.0);
- _bg.set(1.0, 1.0, 1.0, 0.0);
- _interior.set(1.0, 1.0, 1.0, 1.0);
- _pixels_per_unit = 40.0;
- _point_size = 10.0;
- _poly_margin = 1.0;
- _tex_margin = 2;
- _render_margin = 0.0;
- _palette_size[0] = _palette_size[1] = 512;
- _face_index = 0;
- _generate_distance_field = false;
-
- _text_maker = nullptr;
- _vpool = nullptr;
- _group = nullptr;
-}
-
-
-/**
- * Does something with the additional arguments on the command line (after all
- * the -options have been parsed). Returns true if the arguments are good,
- * false otherwise.
- */
-bool EggMakeFont::
-handle_args(ProgramBase::Args &args) {
- if (args.empty()) {
- nout << "Must specify name of font file on command line.\n";
- return false;
- }
-
- _input_font_filename = args[0];
- args.pop_front();
- return EggWriter::handle_args(args);
-}
-
-/**
- *
- */
-void EggMakeFont::
-run() {
- if (has_output_filename() && !get_output_filename().get_dirname().empty()) {
- FilenameUnifier::set_rel_dirname(get_output_filename().get_dirname());
- } else {
- FilenameUnifier::set_rel_dirname(".");
- }
-
- _text_maker = new PNMTextMaker(_input_font_filename, _face_index);
- if (!_text_maker->is_valid()) {
- exit(1);
- }
-
- if (_got_interior) {
- _no_native_aa = true;
- }
-
- if (!_got_scale_factor) {
- // The default scale factor is 4 if we are not using FreeType's antialias,
- // or 2 if we are.
- if (_generate_distance_field) {
- _scale_factor = 1.0;
- } else if (_no_native_aa) {
- _scale_factor = 4.0;
- } else {
- _scale_factor = 2.0;
- }
- }
-
- _text_maker->set_point_size(_point_size);
- _text_maker->set_native_antialias(!_no_native_aa);
- _text_maker->set_interior_flag(_got_interior);
- _text_maker->set_pixels_per_unit(_pixels_per_unit);
- _text_maker->set_scale_factor(_scale_factor);
-
- // The text_maker may have had to adjust the pixels per unit and the scale
- // factor according to what the font supports.
- _pixels_per_unit = _text_maker->get_pixels_per_unit();
- _scale_factor = _text_maker->get_scale_factor();
-
- if (_text_maker->get_font_pixel_size() != 0) {
- nout << "Using " << _text_maker->get_font_pixel_size() << "-pixel font.\n";
- }
-
- // Now we may want to tweak the scale factor so that fonts will actually be
- // generated big. We have to do this after we have already send the current
- // _scale_factor through the _text_maker for validation.
- _palettize_scale_factor = _scale_factor;
- if (_scale_factor != 1.0 && (_no_reduce || !_no_palettize)) {
- // If _no_reduce is true (-nr was specified), we want to keep the glyph
- // textures full-sized, because the user asked for that.
-
- // If _no_palettize is false (-nopal was not specified), we still want to
- // keep the glyph textures full-sized, because the palettizer will reduce
- // them later.
-
- _tex_margin = (int)(_tex_margin * _scale_factor);
- _poly_margin *= _scale_factor;
- _pixels_per_unit *= _scale_factor;
- _scale_factor = 1.0;
- _text_maker->set_pixels_per_unit(_pixels_per_unit);
- _text_maker->set_scale_factor(1.0);
- }
-
- if (_no_reduce) {
- // If -nr was specified, but we're still palettizing, we don't even want
- // to reduce the palette images. Instead, we'll generate extra-large
- // palette images.
- _palette_size[0] = (int)(_palette_size[0] * _palettize_scale_factor);
- _palette_size[1] = (int)(_palette_size[1] * _palettize_scale_factor);
- _palettize_scale_factor = 1.0;
- }
-
- if (_range.is_empty()) {
- // If there's no specified range, the default is the entire ASCII set.
- _range.add_range(0x20, 0x7e);
-
- _range.add_singleton(0xa1); // Upside down exclamation mark
- _range.add_singleton(0xa9); // Copyright sign
- _range.add_singleton(0xab); // Left double angle quote
- // _range.add_singleton(0xae); Registered sign
- _range.add_singleton(0xb0); // Degree symbol
- _range.add_singleton(0xb5); // Mu/micro
- _range.add_singleton(0xb8); // Cedilla
- _range.add_singleton(0xbb); // Right double angle quote
- _range.add_singleton(0xbf); // Upside down question mark
-
- _range.add_singleton(0xc6); // AE ligature
- _range.add_singleton(0xc7); // C cedilla
- // _range.add_singleton(0xd0); Upper-case Eth _range.add_singleton(0xd8);
- // Upper-case O with line _range.add_singleton(0xde); Upper-case Thorn
- _range.add_singleton(0xdf); // German Eszet
- _range.add_singleton(0xe6); // ae ligature
- _range.add_singleton(0xe7); // c cedilla
- _range.add_singleton(0xf0); // Lower-case Eth
- _range.add_singleton(0xf8); // Lower-case O with line
- _range.add_singleton(0xfe); // Lower-case Thorn
-
- // _range.add_singleton(0x03c0); pi
-
- // Dotless i and j, for combining purposes.
- _range.add_singleton(0x0131);
- _range.add_singleton(0x0237);
-
- // And general punctuation. These don't take up much space anyway.
- _range.add_range(0x2018, 0x201f);
-
- _range.add_singleton(0x2026); // Ellipses
-
- // Also add all the combining diacritic marks.
- _range.add_range(0x0300, 0x030f);
- }
- if (_output_glyph_pattern.empty()) {
- // Create a default texture filename pattern.
- _output_glyph_pattern = get_output_filename().get_fullpath_wo_extension() + "%03d.png";
- }
- if (_output_palette_pattern.empty()) {
- // Create a default texture filename pattern.
- _output_palette_pattern = get_output_filename().get_fullpath_wo_extension() + "_%i";
- }
-
- // Figure out how many channels we need based on the foreground and
- // background colors.
- bool needs_alpha = (_fg[3] != 1.0 || _bg[3] != 1.0 || _interior[3] != 1.0);
- bool needs_color = (_fg[0] != _fg[1] || _fg[1] != _fg[2] ||
- _bg[0] != _bg[1] || _bg[1] != _bg[2] ||
- _interior[0] != _interior[1] || _interior[1] != _interior[2]);
-
- if (needs_alpha) {
- if (needs_color) {
- _num_channels = 4;
- _format = EggTexture::F_rgba;
- } else {
- if (_fg[0] == 1.0 && _bg[0] == 1.0 && _interior[0] == 1.0) {
- // A special case: we only need an alpha channel. Copy the alpha data
- // into the color channels so we can write out a one-channel image.
- _fg[0] = _fg[1] = _fg[2] = _fg[3];
- _bg[0] = _bg[1] = _bg[2] = _bg[3];
- _interior[0] = _interior[1] = _interior[2] = _interior[3];
- _num_channels = 1;
- _format = EggTexture::F_alpha;
- } else {
- _num_channels = 2;
- _format = EggTexture::F_luminance_alpha;
- }
- }
- } else {
- if (needs_color) {
- _num_channels = 3;
- _format = EggTexture::F_rgb;
- } else {
- _num_channels = 1;
- _format = EggTexture::F_luminance;
- }
- }
-
- // Create a global Palettizer object. We'll use this even if the user
- // specified -nopal, if nothing else just to hold all of the TextureImage
- // pointers.
- pal = new Palettizer;
- pal->_generated_image_pattern = _output_palette_pattern;
- pal->_omit_solitary = false;
- pal->_round_uvs = false;
-
- // Generate a txa script for the palettizer. We have the palettizer reduce
- // all of the texture images by the inverse of our scale factor.
- char buffer[1024];
- sprintf(buffer, ":margin 0;:coverage 1000;:background %f %f %f %f;:palette %d %d;*: %f%% keep-format",
- _bg[0], _bg[1], _bg[2], _bg[3],
- _palette_size[0], _palette_size[1],
- 100.0 / _palettize_scale_factor);
- std::istringstream txa_script(buffer);
- pal->read_txa_file(txa_script, "default script");
-
- pal->all_params_set();
-
- // Now create all the egg structures. We can't use _data, since we want to
- // pass this object to the palettizer, which will try to up its reference
- // count.
- PT(EggData) egg_data = new EggData;
- _group = new EggGroup();
- egg_data->add_child(_group);
- append_command_comment(egg_data);
-
- _vpool = new EggVertexPool("vpool");
- _group->add_child(_vpool);
-
- // Make the group a sequence, as a convenience. If we view the egg file
- // directly we can see all the characters one at a time.
- _group->set_switch_flag(true);
- _group->set_switch_fps(2.0);
-
- double margin = _poly_margin;
- if (_generate_distance_field) {
- // Distance fields are always rendered with binary alpha.
- _group->set_alpha_mode(EggRenderMode::AM_binary);
-
- // Fudged to make most fonts fit on 512x256.
- if (_poly_margin >= 1) {
- margin += 3.5;
- _poly_margin -= 0.5;
- }
-
- _text_maker->set_distance_field_radius(4);
- }
-
- // Also create an egg group indicating the font's design size and poly
- // margin.
- EggGroup *ds_group = new EggGroup("ds");
- _group->add_child(ds_group);
- EggVertex *vtx = make_vertex(LPoint2d(margin / _pixels_per_unit, _text_maker->get_line_height()));
- EggPoint *point = new EggPoint;
- ds_group->add_child(point);
- point->add_vertex(vtx);
-
- // Finally, add the characters, one at a time.
- RangeIterator ri(_range);
- do {
- add_character(ri.get_code());
- } while (ri.next());
-
- // If there are extra glyphs, pick them up.
- if (!_extra_filenames.empty()) {
- vector_string::const_iterator si;
- for (si = _extra_filenames.begin(); si != _extra_filenames.end(); ++si) {
- add_extra_glyphs(*si);
- }
- }
-
- if (_no_palettize) {
- // Ok, no palettize step; just write out the egg file and all of the
- // textures.
- Textures::iterator ti;
- for (ti = _textures.begin(); ti != _textures.end(); ++ti) {
- TextureImage *texture = (*ti);
- texture->write(texture->read_source_image());
- }
-
- egg_data->write_egg(get_output());
-
- } else {
- // Pass the generated egg structure through egg-palettize, without writing
- // it to disk first.
- string name = get_output_filename().get_basename();
- EggFile *egg_file = pal->get_egg_file(name);
- egg_file->from_command_line(egg_data, "", get_output_filename(),
- get_exec_command());
-
- pal->add_command_line_egg(egg_file);
- pal->process_all(true, "");
- pal->optimal_resize();
- pal->generate_images(true);
- if (!pal->write_eggs()) {
- exit(1);
- }
- // pal->report_pi();
- }
-}
-
-/**
- *
- */
-bool EggMakeFont::
-dispatch_range(const string &, const string &arg, void *var) {
- RangeDescription *ip = (RangeDescription *)var;
- return ip->parse_parameter(arg);
-}
-
-/**
- * Allocates and returns a new vertex from the vertex pool representing the
- * indicated 2-d coordinates.
- */
-EggVertex *EggMakeFont::
-make_vertex(const LPoint2d &xy) {
- return
- _vpool->make_new_vertex(LPoint3d::origin(_coordinate_system) +
- LVector3d::rfu(xy[0], 0.0, xy[1], _coordinate_system));
-}
-
-/**
- * Generates the indicated character and adds it to the font description.
- */
-void EggMakeFont::
-add_character(int code) {
- PNMTextGlyph *glyph = _text_maker->get_glyph(code);
- if (glyph == nullptr) {
- nout << "No definition in font for character " << code << ".\n";
- return;
- }
-
- make_geom(glyph, code);
-}
-
-
-/**
- * Creates the actual geometry for the glyph.
- */
-void EggMakeFont::
-make_geom(PNMTextGlyph *glyph, int character) {
- // Create an egg group to hold the polygon.
- string group_name = format_string(character);
- EggGroup *group = new EggGroup(group_name);
- _group->add_child(group);
-
- if (glyph->get_width() != 0 && glyph->get_height() != 0) {
- int bitmap_top = glyph->get_top();
- int bitmap_left = glyph->get_left();
- double tex_x_size = glyph->get_width();
- double tex_y_size = glyph->get_height();
-
- double poly_margin = _poly_margin;
- double x_origin = _tex_margin;
- double y_origin = _tex_margin;
- double page_y_size = tex_y_size + _tex_margin * 2;
- double page_x_size = tex_x_size + _tex_margin * 2;
-
- // Determine the corners of the rectangle in geometric units.
- double tex_poly_margin = poly_margin / _pixels_per_unit;
- double origin_y = bitmap_top / _pixels_per_unit;
- double origin_x = bitmap_left / _pixels_per_unit;
- double top = origin_y + tex_poly_margin;
- double left = origin_x - tex_poly_margin;
- double bottom = origin_y - tex_y_size / _pixels_per_unit - tex_poly_margin;
- double right = origin_x + tex_x_size / _pixels_per_unit + tex_poly_margin;
-
- // And the corresponding corners in UV units.
- double uv_top = 1.0f - (double)(y_origin - poly_margin) / page_y_size;
- double uv_left = (double)(x_origin - poly_margin) / page_x_size;
- double uv_bottom = 1.0f - (double)(y_origin + poly_margin + tex_y_size) / page_y_size;
- double uv_right = (double)(x_origin + poly_margin + tex_x_size) / page_x_size;
-
- // Create the vertices for the polygon.
- EggVertex *v1 = make_vertex(LPoint2d(left, bottom));
- EggVertex *v2 = make_vertex(LPoint2d(right, bottom));
- EggVertex *v3 = make_vertex(LPoint2d(right, top));
- EggVertex *v4 = make_vertex(LPoint2d(left, top));
-
- v1->set_uv(LTexCoordd(uv_left, uv_bottom));
- v2->set_uv(LTexCoordd(uv_right, uv_bottom));
- v3->set_uv(LTexCoordd(uv_right, uv_top));
- v4->set_uv(LTexCoordd(uv_left, uv_top));
-
- EggPolygon *poly = new EggPolygon();
- group->add_child(poly);
- poly->set_texture(get_tref(glyph, character));
-
- poly->add_vertex(v1);
- poly->add_vertex(v2);
- poly->add_vertex(v3);
- poly->add_vertex(v4);
- }
-
- // Now create a single point where the origin of the next character will be.
-
- EggVertex *v0 = make_vertex(LPoint2d(glyph->get_advance() / _pixels_per_unit + _render_margin, 0.0));
- EggPoint *point = new EggPoint;
- group->add_child(point);
- point->add_vertex(v0);
-}
-
-/**
- * Returns the egg texture reference for a particular glyph, creating it if it
- * has not already been created.
- */
-EggTexture *EggMakeFont::
-get_tref(PNMTextGlyph *glyph, int character) {
- TRefs::iterator ti = _trefs.find(glyph);
- if (ti != _trefs.end()) {
- return (*ti).second;
- }
-
- EggTexture *tref = make_tref(glyph, character);
- _trefs[glyph] = tref;
- return tref;
-}
-
-/**
- * Generates a texture image for the indicated glyph, and returns its egg
- * reference.
- */
-EggTexture *EggMakeFont::
-make_tref(PNMTextGlyph *glyph, int character) {
- char buffer[1024];
- sprintf(buffer, _output_glyph_pattern.c_str(), character);
-
- Filename texture_filename = buffer;
- PNMImage image(glyph->get_width() + _tex_margin * 2,
- glyph->get_height() + _tex_margin * 2, _num_channels);
- image.fill(_bg[0], _bg[1], _bg[2]);
- if (image.has_alpha()) {
- image.alpha_fill(_bg[3]);
- }
- if (_got_interior) {
- glyph->place(image, -glyph->get_left() + _tex_margin,
- glyph->get_top() + _tex_margin, _fg, _interior);
- } else {
- glyph->place(image, -glyph->get_left() + _tex_margin,
- glyph->get_top() + _tex_margin, _fg);
- }
-
- // We don't write the image to disk immediately, since it might just get
- // palettized. But we do record it in a TextureImage object within the
- // global Palettizer, so that it may be written out later.
-
- string name = texture_filename.get_basename_wo_extension();
- TextureImage *texture = pal->get_texture(name);
- _textures.push_back(texture);
- texture->set_filename("", texture_filename);
- SourceTextureImage *source = texture->get_source(texture_filename, "", 0);
- texture->set_source_image(image);
- source->set_header(image);
-
- EggTexture *tref = new EggTexture(name, texture_filename);
- tref->set_format(_format);
- tref->set_wrap_mode(EggTexture::WM_clamp);
- tref->set_minfilter(EggTexture::FT_linear_mipmap_linear);
- tref->set_magfilter(EggTexture::FT_linear);
- tref->set_quality_level(EggTexture::QL_best);
-
- return tref;
-}
-
-/**
- * Reads the indicated filename and adds any numbered groups into the current
- * egg file.
- */
-void EggMakeFont::
-add_extra_glyphs(const Filename &extra_filename) {
- PT(EggData) extra_data = new EggData;
-
- if (!extra_data->read(extra_filename)) {
- return;
- }
-
- _group->steal_children(*extra_data);
-}
-
-/**
- * Recursively searches for numbered groups in the indicated egg file, and
- * copies them to the current egg file.
- */
-void EggMakeFont::
-r_add_extra_glyphs(EggGroupNode *egg_group) {
- if (egg_group->is_of_type(EggGroup::get_class_type())) {
- EggGroup *group = DCAST(EggGroup, egg_group);
- if (is_numeric(group->get_name())) {
- EggGroup *new_group = new EggGroup(group->get_name());
- _group->add_child(new_group);
- new_group->steal_children(*group);
- return;
- }
- }
-
- EggGroupNode::iterator ci;
- for (ci = egg_group->begin(); ci != egg_group->end(); ++ci) {
- EggNode *child = (*ci);
- if (child->is_of_type(EggGroupNode::get_class_type())) {
- r_add_extra_glyphs(DCAST(EggGroupNode, child));
- }
- }
-}
-
-/**
- * Returns true if the indicated string is all numeric digits, false
- * otherwise.
- */
-bool EggMakeFont::
-is_numeric(const string &str) {
- if (str.empty()) {
- return false;
- }
-
- string::const_iterator si;
- for (si = str.begin(); si != str.end(); ++si) {
- if (!isdigit(*si)) {
- return false;
- }
- }
-
- return true;
-}
-
-int main(int argc, char *argv[]) {
- EggMakeFont prog;
- prog.parse_command_line(argc, argv);
- prog.run();
- return 0;
-}
diff --git a/pandatool/src/egg-mkfont/eggMakeFont.h b/pandatool/src/egg-mkfont/eggMakeFont.h
deleted file mode 100644
index 3df12af6..00000000
--- a/pandatool/src/egg-mkfont/eggMakeFont.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggMakeFont.h
- * @author drose
- * @date 2001-02-16
- */
-
-#ifndef EGGMAKEFONT_H
-#define EGGMAKEFONT_H
-
-#include "pandatoolbase.h"
-#include "rangeDescription.h"
-
-#include "eggWriter.h"
-#include "eggTexture.h"
-#include "pmap.h"
-#include "pvector.h"
-#include "vector_string.h"
-
-class PNMTextMaker;
-class PNMTextGlyph;
-class EggVertexPool;
-class EggGroup;
-class TextureImage;
-
-/**
- * This program uses FreeType to generate an egg file and a series of texture
- * images from a font file input, such as a TTF file. The resulting egg file
- * can be loaded in Panda as a StaticTextFont object for rendering text, even
- * if FreeType is not compiled into the executing Panda.
- */
-class EggMakeFont : public EggWriter {
-public:
- EggMakeFont();
-
-protected:
- virtual bool handle_args(Args &args);
-
-public:
- void run();
-
-private:
- static bool dispatch_range(const std::string &, const std::string &arg, void *var);
- EggVertex *make_vertex(const LPoint2d &xy);
-
- void add_character(int code);
- void make_geom(PNMTextGlyph *glyph, int character);
- EggTexture *get_tref(PNMTextGlyph *glyph, int character);
- EggTexture *make_tref(PNMTextGlyph *glyph, int character);
- void add_extra_glyphs(const Filename &extra_filename);
- void r_add_extra_glyphs(EggGroupNode *egg_group);
- static bool is_numeric(const std::string &str);
-
-
-private:
- LColor _fg, _bg, _interior;
- bool _got_interior;
- RangeDescription _range;
- vector_string _extra_filenames;
- double _pixels_per_unit;
- double _point_size;
- double _poly_margin;
- int _tex_margin;
- double _render_margin;
- bool _got_scale_factor;
- double _scale_factor;
- bool _no_reduce;
- bool _no_native_aa;
- bool _no_palettize;
- int _palette_size[2];
- bool _generate_distance_field;
-
- double _palettize_scale_factor;
- Filename _input_font_filename;
- int _face_index;
- std::string _output_glyph_pattern;
- std::string _output_palette_pattern;
-
- PNMTextMaker *_text_maker;
-
- EggTexture::Format _format;
- int _num_channels;
- EggVertexPool *_vpool;
- EggGroup *_group;
-
- typedef pmap TRefs;
- TRefs _trefs;
-
- typedef pvector Textures;
- Textures _textures;
-};
-
-
-#endif
diff --git a/pandatool/src/egg-mkfont/rangeDescription.I b/pandatool/src/egg-mkfont/rangeDescription.I
deleted file mode 100644
index 39a20162..00000000
--- a/pandatool/src/egg-mkfont/rangeDescription.I
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file rangeDescription.I
- * @author drose
- * @date 2003-09-07
- */
-
-/**
- *
- */
-INLINE void RangeDescription::
-add_singleton(int code) {
- _range_list.push_back(Range(code));
-}
-
-/**
- *
- */
-INLINE void RangeDescription::
-add_range(int from_code, int to_code) {
- _range_list.push_back(Range(from_code, to_code));
-}
-
-/**
- * Returns true if there are no codes described in the range.
- */
-INLINE bool RangeDescription::
-is_empty() const {
- return _range_list.empty();
-}
-
-/**
- *
- */
-INLINE RangeDescription::Range::
-Range(int code) :
- _from_code(code),
- _to_code(code)
-{
-}
-
-/**
- *
- */
-INLINE RangeDescription::Range::
-Range(int from_code, int to_code) :
- _from_code(from_code),
- _to_code(to_code)
-{
-}
-
-INLINE std::ostream &operator << (std::ostream &out, const RangeDescription &range) {
- range.output(out);
- return out;
-}
diff --git a/pandatool/src/egg-mkfont/rangeDescription.cxx b/pandatool/src/egg-mkfont/rangeDescription.cxx
deleted file mode 100644
index 2833f533..00000000
--- a/pandatool/src/egg-mkfont/rangeDescription.cxx
+++ /dev/null
@@ -1,175 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file rangeDescription.cxx
- * @author drose
- * @date 2003-09-07
- */
-
-#include "rangeDescription.h"
-#include "string_utils.h"
-#include "pnotify.h"
-
-using std::string;
-
-/**
- *
- */
-RangeDescription::
-RangeDescription() {
-}
-
-/**
- * Parses a string of comma- and hyphen-delimited unicode values, in decimal
- * and/or hex, including possible bracket-delimited ASCII characters, as may
- * have been passed on a command line. Returns true if the parameter is
- * parsed correctly, false otherwise.
- */
-bool RangeDescription::
-parse_parameter(const string ¶m) {
- // First, go through and separate the string by commas. We have to do this
- // by hand instead of calling tokenize(), because we also have to scan for
- // square brackets, which may contain nested commas.
- size_t p = 0;
- while (p < param.length()) {
- size_t q = param.find_first_of("[,", p);
- if (q == string::npos) {
- return parse_word(trim(param.substr(p)));
- }
- if (!parse_word(trim(param.substr(p, q - p)))) {
- return false;
- }
-
- if (param[q] == '[') {
- // A square bracket means we must search for the matching square
- // bracket. However, a right bracket immediately after the left bracket
- // doesn't count; we start the scan after that.
- p = param.find("]", q + 2);
- if ( p == string::npos) {
- nout << "Unclosed open bracket.\n";
- return false;
- }
- if (!parse_bracket(param.substr(q + 1, p - q - 1))) {
- return false;
- }
- p = p + 1;
-
- } else {
- // Otherwise, if the separator was just a comma, the next character
- // begins the next word.
- p = q + 1;
- }
- }
-
- return true;
-}
-
-/**
- *
- */
-void RangeDescription::
-output(std::ostream &out) const {
- bool first_time = true;
- RangeList::const_iterator ri;
- for (ri = _range_list.begin(); ri != _range_list.end(); ++ri) {
- const Range &range = (*ri);
- if (!first_time) {
- out << ",";
- }
- first_time = false;
- if (range._from_code == range._to_code) {
- out << range._from_code;
- } else {
- out << range._from_code << "-" << range._to_code;
- }
- }
-}
-
-/**
- * Parses a single "word", i.e. the text delimited by commas, that might be
- * listed on the command line. This is generally either the empty string, a
- * single number, or a pair of numbers separated by a hyphen.
- */
-bool RangeDescription::
-parse_word(const string &word) {
- if (word.empty()) {
- return true;
- }
-
- // It's not empty, so see if it includes a hyphen.
- size_t hyphen = word.find('-');
- if (hyphen == string::npos) {
- // Nope, just one number.
- int code;
- if (!parse_code(word, code)) {
- return false;
- }
- add_singleton(code);
-
- } else {
- // Two numbers separated by a hyphen.
- int from_code, to_code;
- if (!parse_code(word.substr(0, hyphen), from_code)) {
- return false;
- }
- if (!parse_code(word.substr(hyphen + 1), to_code)) {
- return false;
- }
- add_range(from_code, to_code);
- }
-
- return true;
-}
-
-/**
- * Parses a single numeric value, either decimal or hexadecimal, and stores it
- * in the indicated parameter. Returns true if successful, false otherwise.
- */
-bool RangeDescription::
-parse_code(const string &word, int &code) {
- string str = trim(word);
- const char *nptr = str.c_str();
- char *endptr;
- code = strtol(nptr, &endptr, 0);
- if (*endptr == '\0') {
- return true;
- }
-
- nout << "Invalid Unicode value: " << word << "\n";
- return false;
-}
-
-/**
- * Parses the text listed between square brackets on the command line.
- */
-bool RangeDescription::
-parse_bracket(const string &str) {
- string::const_iterator si;
- si = str.begin();
- while (si != str.end()) {
- int ch = (*si);
- ++si;
- if (si != str.end() && (*si) == '-') {
- // A hyphen indicates a range.
- ++si;
- if (si == str.end()) {
- // Unless the hyphen is the last character.
- add_singleton(ch);
- add_singleton('-');
- } else {
- add_range(ch, (*si));
- ++si;
- }
- } else {
- // Anything other than a hyphen indicates a singleton.
- add_singleton(ch);
- }
- }
-
- return true;
-}
diff --git a/pandatool/src/egg-mkfont/rangeDescription.h b/pandatool/src/egg-mkfont/rangeDescription.h
deleted file mode 100644
index 25119cb1..00000000
--- a/pandatool/src/egg-mkfont/rangeDescription.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file rangeDescription.h
- * @author drose
- * @date 2003-09-07
- */
-
-#ifndef RANGEDESCRIPTION_H
-#define RANGEDESCRIPTION_H
-
-#include "pandatoolbase.h"
-#include "pvector.h"
-
-/**
- * This describes a sparse range of Unicode character codes for conversion
- * that may be specified on the command line.
- */
-class RangeDescription {
-public:
- RangeDescription();
-
- bool parse_parameter(const std::string ¶m);
- INLINE void add_singleton(int code);
- INLINE void add_range(int from_code, int to_code);
- INLINE bool is_empty() const;
-
- void output(std::ostream &out) const;
-
-private:
- bool parse_word(const std::string &word);
- bool parse_code(const std::string &word, int &code);
- bool parse_bracket(const std::string &str);
-
-private:
- class Range {
- public:
- INLINE Range(int code);
- INLINE Range(int from_code, int to_code);
-
- int _from_code;
- int _to_code;
- };
-
- typedef pvector RangeList;
- RangeList _range_list;
-
- friend class RangeIterator;
-};
-
-INLINE std::ostream &operator << (std::ostream &out, const RangeDescription &range);
-
-#include "rangeDescription.I"
-
-#endif
diff --git a/pandatool/src/egg-mkfont/rangeIterator.I b/pandatool/src/egg-mkfont/rangeIterator.I
deleted file mode 100644
index 5d34d4ec..00000000
--- a/pandatool/src/egg-mkfont/rangeIterator.I
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file rangeIterator.I
- * @author drose
- * @date 2003-09-07
- */
-
-/**
- * Returns the current Unicode value represented by the iterator, or -1 if the
- * iterator has reached the end.
- */
-INLINE int RangeIterator::
-get_code() const {
- return _code;
-}
-
-/**
- * Returns true if all the code have been retrieved, false otherwise.
- */
-INLINE bool RangeIterator::
-eof() const {
- return (_it == _desc._range_list.end());
-}
diff --git a/pandatool/src/egg-mkfont/rangeIterator.cxx b/pandatool/src/egg-mkfont/rangeIterator.cxx
deleted file mode 100644
index 0050c80b..00000000
--- a/pandatool/src/egg-mkfont/rangeIterator.cxx
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file rangeIterator.cxx
- * @author drose
- * @date 2003-09-07
- */
-
-#include "rangeIterator.h"
-
-/**
- * Constructs an iterator to walk through the codes on the descriptor. It is
- * important not to modify the RangeDescription object during the lifetime of
- * the iterator.
- */
-RangeIterator::
-RangeIterator(const RangeDescription &desc) :
- _desc(desc)
-{
- _it = _desc._range_list.begin();
- if (_it == _desc._range_list.end()) {
- _code = -1;
- } else {
- _code = (*_it)._from_code;
- _codes_generated.insert(_code);
- }
-}
-
-/**
- * Advances the iterator to the next code. Returns true if there is a next
- * code, or false if there are no mode codes.
- */
-bool RangeIterator::
-next() {
- do {
- if (_it == _desc._range_list.end()) {
- return false;
- }
-
- if (_code < (*_it)._to_code) {
- _code++;
-
- } else {
- _it++;
- if (_it == _desc._range_list.end()) {
- _code = -1;
- return false;
- }
-
- _code = (*_it)._from_code;
- }
-
- // If this code has already been generated, repeat and skip to the next
- // one.
- } while (!_codes_generated.insert(_code).second);
-
- return true;
-}
diff --git a/pandatool/src/egg-mkfont/rangeIterator.h b/pandatool/src/egg-mkfont/rangeIterator.h
deleted file mode 100644
index 5a9630d7..00000000
--- a/pandatool/src/egg-mkfont/rangeIterator.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file rangeIterator.h
- * @author drose
- * @date 2003-09-07
- */
-
-#ifndef RANGEITERATOR_H
-#define RANGEITERATOR_H
-
-#include "pandatoolbase.h"
-#include "rangeDescription.h"
-
-#include "pset.h"
-
-/**
- * Walks through all the Unicode characters described by a RangeDescription
- * class.
- */
-class RangeIterator {
-public:
- RangeIterator(const RangeDescription &desc);
-
- INLINE int get_code() const;
- bool next();
- INLINE bool eof() const;
-
-private:
- const RangeDescription &_desc;
- RangeDescription::RangeList::const_iterator _it;
- int _code;
-
- typedef pset Codes;
- Codes _codes_generated;
-};
-
-#include "rangeIterator.I"
-
-#endif
diff --git a/pandatool/src/egg-optchar/CMakeLists.txt b/pandatool/src/egg-optchar/CMakeLists.txt
deleted file mode 100644
index 379fc301..00000000
--- a/pandatool/src/egg-optchar/CMakeLists.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-if(NOT BUILD_TOOLS)
- return()
-endif()
-
-if(NOT HAVE_EGG)
- return()
-endif()
-
-set(P3EGG_OPTCHAR_HEADERS
- config_egg_optchar.h
- eggOptchar.h
- eggOptcharUserData.h eggOptcharUserData.I
- vertexMembership.h vertexMembership.I
-)
-
-set(P3EGG_OPTCHAR_SOURCES
- config_egg_optchar.cxx
- eggOptchar.cxx
- eggOptcharUserData.cxx
- vertexMembership.cxx
-)
-
-composite_sources(egg-optchar P3EGG_OPTCHAR_SOURCES)
-add_executable(egg-optchar ${P3EGG_OPTCHAR_HEADERS} ${P3EGG_OPTCHAR_SOURCES})
-target_link_libraries(egg-optchar p3eggcharbase)
-
-install(TARGETS egg-optchar EXPORT Tools COMPONENT Tools DESTINATION ${CMAKE_INSTALL_BINDIR})
diff --git a/pandatool/src/egg-optchar/config_egg_optchar.cxx b/pandatool/src/egg-optchar/config_egg_optchar.cxx
deleted file mode 100644
index ef835f1f..00000000
--- a/pandatool/src/egg-optchar/config_egg_optchar.cxx
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file config_egg_optchar.cxx
- * @author drose
- * @date 2003-07-18
- */
-
-#include "config_egg_optchar.h"
-#include "eggOptcharUserData.h"
-
-#include "dconfig.h"
-
-
-Configure(config_egg_optchar);
-
-ConfigureFn(config_egg_optchar) {
- init_egg_optchar();
-}
-
-/**
- * Initializes the library. This must be called at least once before any of
- * the functions or classes in this library can be used. Normally it will be
- * called by the static initializers and need not be called explicitly, but
- * special cases exist.
- */
-void
-init_egg_optchar() {
- static bool initialized = false;
- if (initialized) {
- return;
- }
- initialized = true;
-
- EggOptcharUserData::init_type();
-}
diff --git a/pandatool/src/egg-optchar/config_egg_optchar.h b/pandatool/src/egg-optchar/config_egg_optchar.h
deleted file mode 100644
index 9d01b7fe..00000000
--- a/pandatool/src/egg-optchar/config_egg_optchar.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file config_egg_optchar.h
- * @author drose
- * @date 2003-07-18
- */
-
-#ifndef CONFIG_EGG_OPTCHAR_H
-#define CONFIG_EGG_OPTCHAR_H
-
-#include "pandatoolbase.h"
-
-void init_egg_optchar();
-
-#endif /* CONFIG_EGG_OPTCHAR_H */
diff --git a/pandatool/src/egg-optchar/eggOptchar.cxx b/pandatool/src/egg-optchar/eggOptchar.cxx
deleted file mode 100644
index 182b6579..00000000
--- a/pandatool/src/egg-optchar/eggOptchar.cxx
+++ /dev/null
@@ -1,1522 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggOptchar.cxx
- * @author drose
- * @date 2003-07-18
- */
-
-#include "eggOptchar.h"
-#include "eggOptcharUserData.h"
-#include "vertexMembership.h"
-
-#include "eggJointData.h"
-#include "eggSliderData.h"
-#include "eggCharacterCollection.h"
-#include "eggCharacterData.h"
-#include "eggBackPointer.h"
-#include "eggGroupNode.h"
-#include "eggPrimitive.h"
-#include "eggVertexPool.h"
-#include "eggTable.h"
-#include "eggGroup.h"
-#include "eggAnimPreload.h"
-#include "string_utils.h"
-#include "dcast.h"
-#include "pset.h"
-#include "compose_matrix.h"
-#include "fftCompressor.h"
-
-#include
-
-using std::cout;
-using std::setw;
-using std::string;
-
-/**
- *
- */
-EggOptchar::
-EggOptchar() {
- add_path_replace_options();
- add_path_store_options();
- add_normals_options();
- add_transform_options();
- add_fixrest_option();
-
- set_program_brief("optimizes character models and animations in .egg files");
- set_program_description
- ("egg-optchar performs basic optimizations of a character model "
- "and its associated animations, primarily by analyzing the "
- "animation tables and removing unneeded joints and/or morphs. "
- "It can also perform basic restructuring operations on the "
- "character hierarchy.");
-
- add_option
- ("ls", "", 0,
- "List the joint hierarchy instead of performing any operations.",
- &EggOptchar::dispatch_none, &_list_hierarchy);
-
- add_option
- ("lsv", "", 0,
- "List the joint hierarchy along with an indication of the properties "
- "each joint.",
- &EggOptchar::dispatch_none, &_list_hierarchy_v);
-
- add_option
- ("lsp", "", 0,
- "List the existing joint hierarchy as a series of -p joint,parent "
- "commands, suitable for pasting into an egg-optchar command line.",
- &EggOptchar::dispatch_none, &_list_hierarchy_p);
-
- add_option
- ("keep", "joint[,joint...]", 0,
- "Keep the named joints (or sliders) in the character, even if they do "
- "not appear to be needed by the animation.",
- &EggOptchar::dispatch_vector_string_comma, nullptr, &_keep_components);
-
- add_option
- ("drop", "joint[,joint...]", 0,
- "Removes the named joints or sliders, even if they appear to be needed.",
- &EggOptchar::dispatch_vector_string_comma, nullptr, &_drop_components);
-
- add_option
- ("expose", "joint[,joint...]", 0,
- "Expose the named joints by flagging them with a DCS attribute, so "
- "each one can be found in the scene graph when the character is loaded, "
- "and objects can be parented to it. This implies -keep.",
- &EggOptchar::dispatch_vector_string_comma, nullptr, &_expose_components);
-
- add_option
- ("suppress", "joint[,joint...]", 0,
- "The opposite of suppress, this prevents the named joints from "
- "being created with an implicit DCS attribute, even if they contain "
- "rigid geometry. The default is to create an implicit node for any "
- "joint that contains rigid geometry, to take advantage of display "
- "list and/or vertex buffer caching. This does not imply -keep.",
- &EggOptchar::dispatch_vector_string_comma, nullptr, &_suppress_components);
-
- add_option
- ("flag", "node[,node...][=name]", 0,
- "Assign the indicated name to the geometry within the given nodes. "
- "This will make the geometry visible as a node in the resulting "
- "character model when it is loaded in the scene graph (normally, "
- "the node hierarchy is suppressed when loading characters). This "
- "is different from -expose in that it reveals geometry rather than "
- "joints; the revealed node can be hidden or its attributes changed "
- "at runtime, but it will be animated by its vertices, not the node, so "
- "objects parented to this node will not inherit its animation.",
- &EggOptchar::dispatch_flag_groups, nullptr, &_flag_groups);
-
- add_option
- ("defpose", "anim.egg,frame", 0,
- "Specify the model's default pose. The pose is taken "
- "from the indicated frame of the named animation file (which must "
- "also be named separately on the command line). The "
- "pose will be held by the model in "
- "the absence of any animation, and need not be the same "
- "pose in which the model was originally skinned.",
- &EggOptchar::dispatch_string, nullptr, &_defpose);
-
- add_option
- ("preload", "", 0,
- "Add an entry for each animation to the model file(s). "
- "This can be used at runtime to support asynchronous "
- "loading and binding of animation channels.",
- &EggOptchar::dispatch_none, &_preload);
-
- add_option
- ("zero", "joint[,hprxyzijkabc]", 0,
- "Zeroes out the animation channels for the named joint. If "
- "a subset of the component letters hprxyzijkabc is included, the "
- "operation is restricted to just those components; otherwise the "
- "entire transform is cleared.",
- &EggOptchar::dispatch_name_components, nullptr, &_zero_channels);
-
- add_option
- ("keepall", "", 0,
- "Keep all joints and sliders in the character, except those named "
- "explicitly by -drop.",
- &EggOptchar::dispatch_none, &_keep_all);
-
- add_option
- ("p", "joint,parent", 0,
- "Moves the named joint under the named parent joint. Use "
- "\"-p joint,\" to reparent a joint to the root. The joint transform "
- "is recomputed appropriately under its new parent so that the animation "
- "is not affected (the effect is similar to NodePath::wrt_reparent_to).",
- &EggOptchar::dispatch_vector_string_pair, nullptr, &_reparent_joints);
-
- add_option
- ("new", "joint,source", 0,
- "Creates a new joint under the named parent joint. The new "
- "joint will inherit the same net transform as its parent.",
- &EggOptchar::dispatch_vector_string_pair, nullptr, &_new_joints);
-
- add_option
- ("rename", "joint,newjoint", 0,
- "Renames the indicated joint, if present, to the given name.",
- &EggOptchar::dispatch_vector_string_pair, nullptr, &_rename_joints);
-
- if (FFTCompressor::is_compression_available()) {
- add_option
- ("optimal", "", 0,
- "Computes the optimal joint hierarchy for the character by analyzing "
- "all of the joint animation and reparenting joints to minimize "
- "transformations. This can repair skeletons that have been flattened "
- "or whose hierarchy was otherwise damaged in conversion; it can also "
- "detect joints that are constrained to follow other joints and should "
- "therefore be parented to the master joints. The result is a file "
- "from which more joints may be successfully removed, that generally "
- "compresses better and with fewer artifacts. However, this is a "
- "fairly expensive operation.",
- &EggOptchar::dispatch_none, &_optimal_hierarchy);
- }
-
- add_option
- ("q", "quantum", 0,
- "Quantize joint membership values to the given unit. This is "
- "the smallest significant change in joint membership. There can "
- "be a significant performance (and memory utilization) runtime "
- "benefit for eliminating small differences in joint memberships "
- "between neighboring vertices. The default is 0.01; specifying "
- "0 means to preserve the original values.",
- &EggOptchar::dispatch_double, nullptr, &_vref_quantum);
-
- add_option
- ("qa", "quantum[,hprxyzijkabc]", 0,
- "Quantizes animation channels to the given unit. This rounds each "
- "of the named components of all joints to the nearest multiple of unit. "
- "There is no performance benefit, and little compression benefit, "
- "for doing this; and this may introduce visible artifacts to the "
- "animation. However, sometimes it is a useful tool for animation "
- "analysis and comparison. This option may be repeated several times "
- "to quantize different channels by a different amount.",
- &EggOptchar::dispatch_double_components, nullptr, &_quantize_anims);
-
- add_option
- ("dart", "[default, sync, nosync, or structured]", 0,
- "change the dart value in the given eggs",
- &EggOptchar::dispatch_string, nullptr, &_dart_type);
-
-
- _optimal_hierarchy = false;
- _vref_quantum = 0.01;
-}
-
-/**
- *
- */
-void EggOptchar::
-run() {
- // We have to apply the user-specified reparent requests first, before we
- // even analyze the joints. This is because reparenting the joints may
- // change their properties.
- if (apply_user_reparents()) {
- nout << "Reparenting hierarchy.\n";
- // So we'll have to call do_reparent() twice. It seems wasteful, but it
- // really is necessary, and it's not that bad.
- do_reparent();
- }
-
- if (!_zero_channels.empty()) {
- zero_channels();
- }
-
- int num_characters = _collection->get_num_characters();
- int ci;
-
- // Now we can analyze the joints for their properties.
- for (ci = 0; ci < num_characters; ci++) {
- EggCharacterData *char_data = _collection->get_character(ci);
- analyze_joints(char_data->get_root_joint(), 0);
- analyze_sliders(char_data);
- }
-
- if (_list_hierarchy || _list_hierarchy_v) {
- for (ci = 0; ci < num_characters; ci++) {
- EggCharacterData *char_data = _collection->get_character(ci);
- nout << "Character: " << char_data->get_name() << "\n";
- list_joints(char_data->get_root_joint(), 0, _list_hierarchy_v);
- list_scalars(char_data, _list_hierarchy_v);
- nout << char_data->get_num_joints() << " joints.\n";
- }
-
- } else if (_list_hierarchy_p) {
- for (ci = 0; ci < num_characters; ci++) {
- EggCharacterData *char_data = _collection->get_character(ci);
- nout << "Character: " << char_data->get_name() << "\n";
- int col = 0;
- list_joints_p(char_data->get_root_joint(), col);
- // A newline to cout is needed after the above call.
- cout << "\n";
- nout << char_data->get_num_joints() << " joints.\n";
- }
-
- } else {
- // The meat of the program: determine which joints are to be removed, and
- // then actually remove them.
- determine_removed_components();
- move_vertices();
- if (process_joints()) {
- do_reparent();
- }
-
- // We currently do not implement optimizing morph sliders. Need to add
- // this at some point; it's quite easy. Identity and empty morph sliders
- // can simply be removed, while static sliders need to be applied to the
- // vertices and then removed.
-
- rename_joints();
-
- // Quantize the vertex memberships. We call this even if _vref_quantum is
- // 0, because this also normalizes the vertex memberships.
- quantize_vertices();
-
- // Also quantize the animation channels, if the user so requested.
- quantize_channels();
-
- // flag all the groups as the user requested.
- if (!_flag_groups.empty()) {
- Eggs::iterator ei;
- for (ei = _eggs.begin(); ei != _eggs.end(); ++ei) {
- do_flag_groups(*ei);
- }
- }
-
- // Add the AnimPreload entries.
- if (_preload) {
- do_preload();
- }
-
-
- // Finally, set the default poses. It's important not to do this until
- // after we have adjusted all of the transforms for the various joints.
- if (!_defpose.empty()) {
- do_defpose();
- }
-
- if (!_dart_type.empty()) {
- Eggs::iterator ei;
- for (ei = _eggs.begin(); ei != _eggs.end(); ++ei) {
- change_dart_type(*ei, _dart_type);
- }
- }
-
- write_eggs();
- }
-}
-
-/**
- * Does something with the additional arguments on the command line (after all
- * the -options have been parsed). Returns true if the arguments are good,
- * false otherwise.
- */
-bool EggOptchar::
-handle_args(ProgramBase::Args &args) {
- if (_list_hierarchy || _list_hierarchy_v || _list_hierarchy_p) {
- _read_only = true;
- }
-
- return EggCharacterFilter::handle_args(args);
-}
-
-/**
- * Standard dispatch function for an option that takes a pair of string
- * parameters. The data pointer is to StringPairs vector; the pair will be
- * pushed onto the end of the vector.
- */
-bool EggOptchar::
-dispatch_vector_string_pair(const string &opt, const string &arg, void *var) {
- StringPairs *ip = (StringPairs *)var;
-
- vector_string words;
- tokenize(arg, words, ",");
-
- if (words.size() == 2) {
- StringPair sp;
- sp._a = words[0];
- sp._b = words[1];
- ip->push_back(sp);
-
- } else {
- nout << "-" << opt
- << " requires a pair of strings separated by a comma.\n";
- return false;
- }
-
- return true;
-}
-
-/**
- * Accepts a name optionally followed by a comma and some of the nine standard
- * component letters,
- *
- * The data pointer is to StringPairs vector; the pair will be pushed onto the
- * end of the vector.
- */
-bool EggOptchar::
-dispatch_name_components(const string &opt, const string &arg, void *var) {
- StringPairs *ip = (StringPairs *)var;
-
- vector_string words;
- tokenize(arg, words, ",");
-
- StringPair sp;
- if (words.size() == 1) {
- sp._a = words[0];
-
- } else if (words.size() == 2) {
- sp._a = words[0];
- sp._b = words[1];
-
- } else {
- nout << "-" << opt
- << " requires a pair of strings separated by a comma.\n";
- return false;
- }
-
- if (sp._b.empty()) {
- sp._b = matrix_component_letters;
- } else {
- for (string::const_iterator si = sp._b.begin(); si != sp._b.end(); ++si) {
- if (strchr(matrix_component_letters, *si) == nullptr) {
- nout << "Not a standard matrix component: \"" << *si << "\"\n"
- << "-" << opt << " requires a joint name followed by a set "
- << "of component names. The standard component names are \""
- << matrix_component_letters << "\".\n";
- return false;
- }
- }
- }
-
- ip->push_back(sp);
-
- return true;
-}
-
-/**
- * Accepts a double value optionally followed by a comma and some of the nine
- * standard component letters,
- *
- * The data pointer is to a DoubleStrings vector; the pair will be pushed onto
- * the end of the vector.
- */
-bool EggOptchar::
-dispatch_double_components(const string &opt, const string &arg, void *var) {
- DoubleStrings *ip = (DoubleStrings *)var;
-
- vector_string words;
- tokenize(arg, words, ",");
-
- bool valid_double = false;
-
- DoubleString sp;
- if (words.size() == 1) {
- valid_double = string_to_double(words[0], sp._a);
-
- } else if (words.size() == 2) {
- valid_double = string_to_double(words[0], sp._a);
- sp._b = words[1];
-
- } else {
- nout << "-" << opt
- << " requires a numeric value followed by a string.\n";
- return false;
- }
-
- if (!valid_double) {
- nout << "-" << opt
- << " requires a numeric value followed by a string.\n";
- return false;
- }
-
- if (sp._b.empty()) {
- sp._b = matrix_component_letters;
- } else {
- for (string::const_iterator si = sp._b.begin(); si != sp._b.end(); ++si) {
- if (strchr(matrix_component_letters, *si) == nullptr) {
- nout << "Not a standard matrix component: \"" << *si << "\"\n"
- << "-" << opt << " requires a joint name followed by a set "
- << "of component names. The standard component names are \""
- << matrix_component_letters << "\".\n";
- return false;
- }
- }
- }
-
- ip->push_back(sp);
-
- return true;
-}
-
-/**
- * Accepts a set of comma-delimited group names followed by an optional name
- * separated with an equal sign.
- *
- * The data pointer is to a FlagGroups object.
- */
-bool EggOptchar::
-dispatch_flag_groups(const string &opt, const string &arg, void *var) {
- FlagGroups *ip = (FlagGroups *)var;
-
- vector_string words;
-
- tokenize(arg, words, ",");
-
- if (words.empty()) {
- nout << "-" << opt
- << " requires a series of words separated by a comma.\n";
- return false;
- }
-
- FlagGroupsEntry entry;
-
- // Check for an equal sign in the last word. This marks the name to assign.
- string &last_word = words.back();
- size_t equals = last_word.rfind('=');
- if (equals != string::npos) {
- entry._name = last_word.substr(equals + 1);
- last_word = last_word.substr(0, equals);
-
- } else {
- // If there's no equal sign, the default is to name all groups after the
- // group itself. We leave the name empty to indicate that.
- }
-
- // Convert the words to GlobPatterns.
- vector_string::const_iterator si;
- for (si = words.begin(); si != words.end(); ++si) {
- const string &word = (*si);
- entry._groups.push_back(GlobPattern(word));
- }
-
- ip->push_back(entry);
-
- return true;
-}
-
-/**
- * Flag all joints and sliders that should be removed for optimization
- * purposes.
- */
-void EggOptchar::
-determine_removed_components() {
- typedef pset Names;
- Names keep_names;
- Names drop_names;
- Names expose_names;
- Names suppress_names;
- Names names_used;
-
- vector_string::const_iterator si;
- for (si = _keep_components.begin(); si != _keep_components.end(); ++si) {
- keep_names.insert(*si);
- }
- for (si = _drop_components.begin(); si != _drop_components.end(); ++si) {
- drop_names.insert(*si);
- }
- for (si = _expose_components.begin(); si != _expose_components.end(); ++si) {
- keep_names.insert(*si);
- expose_names.insert(*si);
- }
- for (si = _suppress_components.begin(); si != _suppress_components.end(); ++si) {
- suppress_names.insert(*si);
- }
-
- // We always keep the root joint, which has no name.
- keep_names.insert("");
-
- int num_characters = _collection->get_num_characters();
- for (int ci = 0; ci < num_characters; ci++) {
- EggCharacterData *char_data = _collection->get_character(ci);
- int num_components = char_data->get_num_components();
- nout << char_data->get_name() << " has " << num_components << " components.\n";
- for (int i = 0; i < num_components; i++) {
- EggComponentData *comp_data = char_data->get_component(i);
- nassertv(comp_data != nullptr);
-
- EggOptcharUserData *user_data =
- DCAST(EggOptcharUserData, comp_data->get_user_data());
- nassertv(user_data != nullptr);
-
- const string &name = comp_data->get_name();
- if (suppress_names.find(name) != suppress_names.end()) {
- // If this component is not dropped, it will not be implicitly
- // exposed.
- names_used.insert(name);
- user_data->_flags |= EggOptcharUserData::F_suppress;
- }
-
- if (drop_names.find(name) != drop_names.end()) {
- // Remove this component by user request.
- names_used.insert(name);
- user_data->_flags |= EggOptcharUserData::F_remove;
-
- } else if (_keep_all || keep_names.find(name) != keep_names.end()) {
- // Keep this component.
- names_used.insert(name);
-
- if (expose_names.find(name) != expose_names.end()) {
- // In fact, expose it.
- user_data->_flags |= EggOptcharUserData::F_expose;
- }
-
- } else {
- // Remove this component if it's unanimated or empty.
- if ((user_data->_flags & (EggOptcharUserData::F_static | EggOptcharUserData::F_empty)) != 0) {
- if ((user_data->_flags & (EggOptcharUserData::F_top | EggOptcharUserData::F_empty)) == EggOptcharUserData::F_top) {
- // Actually, we can't remove it if it's a top joint, unless it's
- // also empty. That's because vertices that are partially
- // assigned to this joint would then have no joint to represent
- // the same partial assignment, and they would then appear to be
- // wholly assigned to their other joint, which would be incorrect.
-
- } else {
- // But joints that aren't top joints (or that are empty) are o.k.
- // to remove.
- user_data->_flags |= EggOptcharUserData::F_remove;
- }
- }
- }
- }
- }
-
- // Go back and tell the user about component names we didn't use, just to be
- // helpful.
- for (si = _keep_components.begin(); si != _keep_components.end(); ++si) {
- const string &name = (*si);
- if (names_used.find(name) == names_used.end()) {
- nout << "No such component: " << name << "\n";
- }
- }
- for (si = _drop_components.begin(); si != _drop_components.end(); ++si) {
- const string &name = (*si);
- if (names_used.find(name) == names_used.end()) {
- nout << "No such component: " << name << "\n";
- }
- }
- for (si = _expose_components.begin(); si != _expose_components.end(); ++si) {
- const string &name = (*si);
- if (names_used.find(name) == names_used.end()) {
- nout << "No such component: " << name << "\n";
- }
- }
- for (si = _suppress_components.begin(); si != _suppress_components.end(); ++si) {
- const string &name = (*si);
- if (names_used.find(name) == names_used.end()) {
- nout << "No such component: " << name << "\n";
- }
- }
-}
-
-/**
- * Moves the vertices from joints that are about to be removed into the first
- * suitable parent. This might result in fewer joints being removed (because
- * the parent might suddenly no longer be empty).
- */
-void EggOptchar::
-move_vertices() {
- int num_characters = _collection->get_num_characters();
- for (int ci = 0; ci < num_characters; ci++) {
- EggCharacterData *char_data = _collection->get_character(ci);
- int num_joints = char_data->get_num_joints();
-
- for (int i = 0; i < num_joints; i++) {
- EggJointData *joint_data = char_data->get_joint(i);
- EggOptcharUserData *user_data =
- DCAST(EggOptcharUserData, joint_data->get_user_data());
-
- if ((user_data->_flags & EggOptcharUserData::F_empty) == 0 &&
- (user_data->_flags & EggOptcharUserData::F_remove) != 0) {
- // This joint has vertices, but is scheduled to be removed; find a
- // suitable home for its vertices.
- EggJointData *best_joint = find_best_vertex_joint(joint_data->get_parent());
- joint_data->move_vertices_to(best_joint);
-
- // Now we can't remove the joint.
- if (best_joint != nullptr) {
- EggOptcharUserData *best_user_data =
- DCAST(EggOptcharUserData, best_joint->get_user_data());
- best_user_data->_flags &= ~(EggOptcharUserData::F_empty | EggOptcharUserData::F_remove);
- }
- }
- }
- }
-}
-
-
-/**
- * Effects the actual removal of joints flagged for removal by reparenting the
- * hierarchy appropriately. Returns true if any joints are removed, false
- * otherwise.
- */
-bool EggOptchar::
-process_joints() {
- bool removed_any = false;
- int num_characters = _collection->get_num_characters();
- for (int ci = 0; ci < num_characters; ci++) {
- EggCharacterData *char_data = _collection->get_character(ci);
- int num_joints = char_data->get_num_joints();
-
- int num_static = 0;
- int num_empty = 0;
- int num_identity = 0;
- int num_other = 0;
- int num_kept = 0;
-
- for (int i = 0; i < num_joints; i++) {
- EggJointData *joint_data = char_data->get_joint(i);
- EggOptcharUserData *user_data =
- DCAST(EggOptcharUserData, joint_data->get_user_data());
-
- if ((user_data->_flags & EggOptcharUserData::F_remove) != 0) {
- // This joint will be removed, so reparent it to nothing.
- joint_data->reparent_to(nullptr);
-
- // Determine what kind of node it is we're removing, for the user's
- // information.
- if ((user_data->_flags & EggOptcharUserData::F_identity) != 0) {
- num_identity++;
- } else if ((user_data->_flags & EggOptcharUserData::F_static) != 0) {
- num_static++;
- } else if ((user_data->_flags & EggOptcharUserData::F_empty) != 0) {
- num_empty++;
- } else {
- num_other++;
- }
- removed_any = true;
-
- } else {
- // This joint will be preserved, but maybe its parent will change.
- EggJointData *best_parent = find_best_parent(joint_data->get_parent());
- joint_data->reparent_to(best_parent);
- if ((user_data->_flags & EggOptcharUserData::F_expose) != 0) {
- joint_data->expose();
- } else if ((user_data->_flags & EggOptcharUserData::F_suppress) != 0) {
- joint_data->expose(EggGroup::DC_none);
- }
- num_kept++;
- }
- }
-
- if (num_joints == num_kept) {
- nout << char_data->get_name() << ": keeping " << num_joints
- << " joints.\n";
- } else {
- nout << setw(5) << num_joints
- << " original joints in " << char_data->get_name()
- << "\n";
- if (num_identity != 0) {
- nout << setw(5) << num_identity << " identity joints\n";
- }
- if (num_static != 0) {
- nout << setw(5) << num_static << " unanimated joints\n";
- }
- if (num_empty != 0) {
- nout << setw(5) << num_empty << " empty joints\n";
- }
- if (num_other != 0) {
- nout << setw(5) << num_other << " other joints\n";
- }
- nout << " ----\n"
- << setw(5) << num_kept << " joints remaining\n\n";
- }
- }
-
- return removed_any;
-}
-
-/**
- * Searches for the first joint at this level or above that is not scheduled
- * to be removed. This is the joint that the first child of this joint should
- * be reparented to.
- */
-EggJointData *EggOptchar::
-find_best_parent(EggJointData *joint_data) const {
- EggOptcharUserData *user_data =
- DCAST(EggOptcharUserData, joint_data->get_user_data());
-
- if ((user_data->_flags & EggOptcharUserData::F_remove) != 0) {
- // Keep going.
- if (joint_data->get_parent() != nullptr) {
- return find_best_parent(joint_data->get_parent());
- }
- }
-
- // This is the one!
- return joint_data;
-}
-
-/**
- * Searches for the first joint at this level or above that is not static.
- * This is the joint that the vertices of this joint should be moved into.
- */
-EggJointData *EggOptchar::
-find_best_vertex_joint(EggJointData *joint_data) const {
- if (joint_data == nullptr) {
- return nullptr;
- }
-
- EggOptcharUserData *user_data =
- DCAST(EggOptcharUserData, joint_data->get_user_data());
-
- if ((user_data->_flags & EggOptcharUserData::F_static) != 0) {
- // Keep going.
- return find_best_vertex_joint(joint_data->get_parent());
- }
-
- // This is the one!
- return joint_data;
-}
-
-/**
- * Reparents all the joints that the user suggested on the command line.
- * Returns true if any operations were performed, false otherwise.
- */
-bool EggOptchar::
-apply_user_reparents() {
- bool did_anything = false;
-
- int num_characters = _collection->get_num_characters();
-
- // First, get the new joints.
- StringPairs::const_iterator spi;
- for (spi = _new_joints.begin(); spi != _new_joints.end(); ++spi) {
- const StringPair &p = (*spi);
-
- for (int ci = 0; ci < num_characters; ci++) {
- EggCharacterData *char_data = _collection->get_character(ci);
- EggJointData *node_a = char_data->find_joint(p._a);
- EggJointData *node_b = char_data->get_root_joint();
- if (!p._b.empty()) {
- node_b = char_data->find_joint(p._b);
- }
-
- if (node_b == nullptr) {
- nout << "No joint named " << p._b << " in " << char_data->get_name()
- << ".\n";
-
- } else if (node_a != nullptr) {
- nout << "Joint " << p._a << " already exists in "
- << char_data->get_name() << ".\n";
-
- } else {
- nout << "Creating new joint " << p._a << " in "
- << char_data->get_name() << ".\n";
- node_a = char_data->make_new_joint(p._a, node_b);
- did_anything = true;
- }
- }
- }
-
- // Now get the user reparents.
- for (spi = _reparent_joints.begin(); spi != _reparent_joints.end(); ++spi) {
- const StringPair &p = (*spi);
-
- for (int ci = 0; ci < num_characters; ci++) {
- EggCharacterData *char_data = _collection->get_character(ci);
- EggJointData *node_a = char_data->find_joint(p._a);
- EggJointData *node_b = char_data->get_root_joint();
- if (!p._b.empty()) {
- node_b = char_data->find_joint(p._b);
- }
-
- if (node_b == nullptr) {
- nout << "No joint named " << p._b << " in " << char_data->get_name()
- << ".\n";
- } else if (node_a == nullptr) {
- nout << "No joint named " << p._a << " in " << char_data->get_name()
- << ".\n";
- } else {
- node_a->reparent_to(node_b);
- did_anything = true;
- }
- }
- }
-
- if (_optimal_hierarchy) {
- did_anything = true;
- for (int ci = 0; ci < num_characters; ci++) {
- EggCharacterData *char_data = _collection->get_character(ci);
- nout << "Computing optimal hierarchy for "
- << char_data->get_name() << ".\n";
- char_data->choose_optimal_hierarchy();
- nout << "Done computing optimal hierarchy for "
- << char_data->get_name() << ".\n";
- }
- }
-
- return did_anything;
-}
-
-/**
- * Zeroes out the channels specified by the user on the command line.
- *
- * Returns true if any operation was performed, false otherwise.
- */
-bool EggOptchar::
-zero_channels() {
- bool did_anything = false;
- int num_characters = _collection->get_num_characters();
-
- StringPairs::const_iterator spi;
- for (spi = _zero_channels.begin(); spi != _zero_channels.end(); ++spi) {
- const StringPair &p = (*spi);
-
- for (int ci = 0; ci < num_characters; ci++) {
- EggCharacterData *char_data = _collection->get_character(ci);
- EggJointData *joint_data = char_data->find_joint(p._a);
-
- if (joint_data == nullptr) {
- nout << "No joint named " << p._a << " in " << char_data->get_name()
- << ".\n";
- } else {
- joint_data->zero_channels(p._b);
- did_anything = true;
- }
- }
- }
-
- return did_anything;
-}
-
-/**
- * Quantizes the channels specified by the user on the command line.
- *
- * Returns true if any operation was performed, false otherwise.
- */
-bool EggOptchar::
-quantize_channels() {
- bool did_anything = false;
- int num_characters = _collection->get_num_characters();
-
- DoubleStrings::const_iterator spi;
- for (spi = _quantize_anims.begin(); spi != _quantize_anims.end(); ++spi) {
- const DoubleString &p = (*spi);
-
- for (int ci = 0; ci < num_characters; ci++) {
- EggCharacterData *char_data = _collection->get_character(ci);
- EggJointData *joint_data = char_data->get_root_joint();
-
- if (joint_data != nullptr) {
- joint_data->quantize_channels(p._b, p._a);
- did_anything = true;
- }
- }
- }
-
- return did_anything;
-}
-
-/**
- * Recursively walks the joint hierarchy for a particular character,
- * indentifying properties of each joint.
- */
-void EggOptchar::
-analyze_joints(EggJointData *joint_data, int level) {
- PT(EggOptcharUserData) user_data = new EggOptcharUserData;
- joint_data->set_user_data(user_data);
-
- if (level == 1) {
- // The child joints of the root joint are deemed "top" joints. These may
- // not be removed unless they are empty (because their vertices have no
- // joint to be moved into).
- user_data->_flags |= EggOptcharUserData::F_top;
- }
-
- // Analyze the table of matrices for this joint, checking to see if they're
- // all the same across all frames, or if any of them are different; also
- // look for empty joints (that control no vertices).
- int num_mats = 0;
- bool different_mat = false;
- bool has_vertices = false;
-
- int num_models = joint_data->get_num_models();
- int i;
- for (i = 0; i < num_models; i++) {
- if (joint_data->has_model(i)) {
- EggBackPointer *model = joint_data->get_model(i);
- if (model->has_vertices()) {
- has_vertices = true;
- }
-
- int num_frames = joint_data->get_num_frames(i);
-
- int f;
- for (f = 0; f < num_frames && !different_mat; f++) {
- LMatrix4d mat = joint_data->get_frame(i, f);
- num_mats++;
- if (num_mats == 1) {
- // This is the first matrix.
- user_data->_static_mat = mat;
-
- } else {
- // This is a second or later matrix.
- if (!mat.almost_equal(user_data->_static_mat, 0.0001)) {
- // It's different than the first one.
- different_mat = true;
- }
- }
- }
- }
- }
-
- if (!different_mat) {
- // All the mats are the same for this joint.
- user_data->_flags |= EggOptcharUserData::F_static;
-
- if (num_mats == 0 ||
- user_data->_static_mat.almost_equal(LMatrix4d::ident_mat(), 0.0001)) {
- // It's not only static, but it's the identity matrix.
- user_data->_flags |= EggOptcharUserData::F_identity;
- }
- }
-
- if (!has_vertices) {
- // There are no vertices in this joint.
- user_data->_flags |= EggOptcharUserData::F_empty;
- }
-
- int num_children = joint_data->get_num_children();
- for (i = 0; i < num_children; i++) {
- analyze_joints(joint_data->get_child(i), level + 1);
- }
-}
-
-/**
- * Linearly walks the slider list for a particular character, indentifying
- * properties of each slider.
- */
-void EggOptchar::
-analyze_sliders(EggCharacterData *char_data) {
- int num_sliders = char_data->get_num_sliders();
- for (int si = 0; si < num_sliders; si++) {
- EggSliderData *slider_data = char_data->get_slider(si);
-
- PT(EggOptcharUserData) user_data = new EggOptcharUserData;
- slider_data->set_user_data(user_data);
-
- // Analyze the table of values for this slider, checking to see if they're
- // all the same across all frames, or if any of them are different; also
- // look for empty sliders (that control no vertices).
- int num_values = 0;
- bool different_value = false;
- bool has_vertices = false;
-
- int num_models = slider_data->get_num_models();
- for (int i = 0; i < num_models; i++) {
- if (slider_data->has_model(i)) {
- EggBackPointer *model = slider_data->get_model(i);
- if (model->has_vertices()) {
- has_vertices = true;
- }
-
- int num_frames = slider_data->get_num_frames(i);
-
- int f;
- for (f = 0; f < num_frames && !different_value; f++) {
- double value = slider_data->get_frame(i, f);
- num_values++;
- if (num_values == 1) {
- // This is the first value.
- user_data->_static_value = value;
-
- } else {
- // This is a second or later value.
- if (!IS_THRESHOLD_EQUAL(value, user_data->_static_value, 0.0001)) {
- // It's different than the first one.
- different_value = true;
- }
- }
- }
- }
- }
-
- if (!different_value) {
- // All the values are the same for this slider.
- user_data->_flags |= EggOptcharUserData::F_static;
-
- if (num_values == 0 || IS_THRESHOLD_ZERO(user_data->_static_value, 0.0001)) {
- // It's not only static, but it's the identity value.
- user_data->_flags |= EggOptcharUserData::F_identity;
- }
- }
-
- if (!has_vertices) {
- // There are no vertices in this slider.
- user_data->_flags |= EggOptcharUserData::F_empty;
- }
- }
-}
-
-/**
- * Outputs a list of the joint hierarchy.
- */
-void EggOptchar::
-list_joints(EggJointData *joint_data, int indent_level, bool verbose) {
- // Don't list the root joint, which is artificially created when the
- // character is loaded. Instead, list each child as it is encountered.
-
- int num_children = joint_data->get_num_children();
- for (int i = 0; i < num_children; i++) {
- EggJointData *child_data = joint_data->get_child(i);
- describe_component(child_data, indent_level, verbose);
-
- list_joints(child_data, indent_level + 2, verbose);
- }
-}
-
-/**
- * Outputs a list of the joint hierarchy as a series of -p joint,parent
- * commands.
- */
-void EggOptchar::
-list_joints_p(EggJointData *joint_data, int &col) {
- // As above, don't list the root joint.
-
- int num_children = joint_data->get_num_children();
- static const int max_col = 72;
-
- for (int i = 0; i < num_children; i++) {
- EggJointData *child_data = joint_data->get_child(i);
- // We send output to cout instead of nout to avoid the word-wrapping, and
- // also to allow the user to redirect this easily to a file.
-
- string text = string(" -p ") + child_data->get_name() +
- string(",") + joint_data->get_name();
- if (col == 0) {
- cout << " " << text;
- col = 4 + text.length();
- } else {
- col += text.length();
- if (col >= max_col) {
- cout << " \\\n " << text;
- col = 4 + text.length();
- } else {
- cout << text;
- }
- }
-
- list_joints_p(child_data, col);
- }
-}
-
-/**
- * Outputs a list of the scalars.
- */
-void EggOptchar::
-list_scalars(EggCharacterData *char_data, bool verbose) {
- int num_sliders = char_data->get_num_sliders();
- for (int si = 0; si < num_sliders; si++) {
- EggSliderData *slider_data = char_data->get_slider(si);
- describe_component(slider_data, 0, verbose);
- }
-}
-
-/**
- * Describes one particular slider or joint.
- */
-void EggOptchar::
-describe_component(EggComponentData *comp_data, int indent_level,
- bool verbose) {
- // We use cout instead of nout so the user can easily redirect this to a
- // file.
- indent(cout, indent_level)
- << comp_data->get_name();
-
- if (verbose) {
- EggOptcharUserData *user_data =
- DCAST(EggOptcharUserData, comp_data->get_user_data());
- if (user_data->is_identity()) {
- cout << " (identity)";
- } else if (user_data->is_static()) {
- cout << " (static)";
- }
- if (user_data->is_empty()) {
- cout << " (empty)";
- }
- if (user_data->is_top()) {
- cout << " (top)";
- }
- }
- cout << "\n";
-}
-
-/**
- * Performs all of the queued up reparenting operations.
- */
-void EggOptchar::
-do_reparent() {
- bool all_ok = true;
-
- int num_characters = _collection->get_num_characters();
- for (int ci = 0; ci < num_characters; ci++) {
- EggCharacterData *char_data = _collection->get_character(ci);
- if (!char_data->do_reparent()) {
- all_ok = false;
- }
- }
-
- if (!all_ok) {
- exit(1);
- }
-}
-
-/**
- * Walks through all of the loaded egg files, looking for vertices whose joint
- * memberships are then quantized according to _vref_quantum.
- */
-void EggOptchar::
-quantize_vertices() {
- Eggs::iterator ei;
- for (ei = _eggs.begin(); ei != _eggs.end(); ++ei) {
- quantize_vertices(*ei);
- }
-}
-
-/**
- * Recursively walks through the indicated egg hierarchy, looking for vertices
- * whose joint memberships are then quantized according to _vref_quantum.
- */
-void EggOptchar::
-quantize_vertices(EggNode *egg_node) {
- if (egg_node->is_of_type(EggVertexPool::get_class_type())) {
- EggVertexPool *vpool = DCAST(EggVertexPool, egg_node);
- EggVertexPool::iterator vi;
- for (vi = vpool->begin(); vi != vpool->end(); ++vi) {
- quantize_vertex(*vi);
- }
-
- } else if (egg_node->is_of_type(EggGroupNode::get_class_type())) {
- EggGroupNode *group = DCAST(EggGroupNode, egg_node);
- EggGroupNode::iterator ci;
- for (ci = group->begin(); ci != group->end(); ++ci) {
- quantize_vertices(*ci);
- }
- }
-}
-
-/**
- * Quantizes the indicated vertex's joint membership.
- */
-void EggOptchar::
-quantize_vertex(EggVertex *egg_vertex) {
- if (egg_vertex->gref_size() == 0) {
- // Never mind on this vertex.
- return;
- }
-
- // First, get a copy of the existing membership.
- VertexMemberships memberships;
- EggVertex::GroupRef::const_iterator gi;
- double net_membership = 0.0;
- for (gi = egg_vertex->gref_begin(); gi != egg_vertex->gref_end(); ++gi) {
- EggGroup *group = (*gi);
- double membership = group->get_vertex_membership(egg_vertex);
- memberships.push_back(VertexMembership(group, membership));
- net_membership += membership;
- }
- nassertv(net_membership != 0.0);
-
- // Now normalize all the memberships so the net membership is 1.0, and then
- // quantize the result (if the user so requested).
- double factor = 1.0 / net_membership;
- net_membership = 0.0;
- VertexMemberships::iterator mi;
- VertexMemberships::iterator largest = memberships.begin();
-
- for (mi = memberships.begin(); mi != memberships.end(); ++mi) {
- if ((*largest) < (*mi)) {
- // Remember the largest membership value, so we can readjust it at the
- // end.
- largest = mi;
- }
-
- double value = (*mi)._membership * factor;
- if (_vref_quantum != 0.0) {
- value = floor(value / _vref_quantum + 0.5) * _vref_quantum;
- }
- (*mi)._membership = value;
-
- net_membership += value;
- }
-
- // The the largest membership value gets corrected again by the roundoff
- // error.
- (*largest)._membership += 1.0 - net_membership;
-
- // Finally, walk back through and apply these computed values to the vertex.
- for (mi = memberships.begin(); mi != memberships.end(); ++mi) {
- (*mi)._group->set_vertex_membership(egg_vertex, (*mi)._membership);
- }
-}
-
-/**
- * Recursively walks the indicated egg hierarchy, looking for groups that
- * match one of the group names in _flag_groups, and renaming geometry
- * appropriately.
- */
-void EggOptchar::
-do_flag_groups(EggGroupNode *egg_group) {
- bool matched = false;
- string name;
- FlagGroups::const_iterator fi;
- for (fi = _flag_groups.begin();
- fi != _flag_groups.end() && !matched;
- ++fi) {
- const FlagGroupsEntry &entry = (*fi);
- Globs::const_iterator si;
- for (si = entry._groups.begin();
- si != entry._groups.end() && !matched;
- ++si) {
- if ((*si).matches(egg_group->get_name())) {
- matched = true;
- if (!entry._name.empty()) {
- name = entry._name;
- } else {
- name = egg_group->get_name();
- }
- }
- }
- }
-
- if (matched) {
- // Ok, this group matched one of the user's command-line renames. Rename
- // all the primitives in this group and below to the indicated name; this
- // will expose the primitives through the character loader.
- rename_primitives(egg_group, name);
- }
-
- // Now recurse on children.
- EggGroupNode::iterator gi;
- for (gi = egg_group->begin(); gi != egg_group->end(); ++gi) {
- EggNode *child = (*gi);
- if (child->is_of_type(EggGroupNode::get_class_type())) {
- EggGroupNode *group = DCAST(EggGroupNode, child);
- do_flag_groups(group);
- }
- }
-}
-
-/**
- * Rename all the joints named with the -rename command-line option.
- */
-void EggOptchar::
-rename_joints() {
- for (StringPairs::iterator spi = _rename_joints.begin();
- spi != _rename_joints.end();
- ++spi) {
- const StringPair &sp = (*spi);
- int num_characters = _collection->get_num_characters();
- int ci;
- for (ci = 0; ci < num_characters; ++ci) {
- EggCharacterData *char_data = _collection->get_character(ci);
- EggJointData *joint = char_data->find_joint(sp._a);
- if (joint != nullptr) {
- nout << "Renaming joint " << sp._a << " to " << sp._b << "\n";
- joint->set_name(sp._b);
-
- int num_models = joint->get_num_models();
- for (int mn = 0; mn < num_models; ++mn) {
- if (joint->has_model(mn)) {
- EggBackPointer *model = joint->get_model(mn);
- model->set_name(sp._b);
- }
- }
-
- } else {
- nout << "Couldn't find joint " << sp._a << "\n";
- }
- }
- }
-}
-
-/**
- * Recursively walks the indicated egg hierarchy, renaming geometry to the
- * indicated name.
- */
-void EggOptchar::
-change_dart_type(EggGroupNode *egg_group, const string &new_dart_type) {
- EggGroupNode::iterator gi;
- for (gi = egg_group->begin(); gi != egg_group->end(); ++gi) {
- EggNode *child = (*gi);
- if (child->is_of_type(EggGroupNode::get_class_type())) {
- EggGroupNode *group = DCAST(EggGroupNode, child);
- if (child->is_of_type(EggGroup::get_class_type())) {
- EggGroup *gr = DCAST(EggGroup, child);
- EggGroup::DartType dt = gr->get_dart_type();
- if(dt != EggGroup::DT_none) {
- EggGroup::DartType newDt = gr->string_dart_type(new_dart_type);
- gr->set_dart_type(newDt);
- }
- }
- change_dart_type(group, new_dart_type);
- }
- }
-}
-
-
-/**
- * Recursively walks the indicated egg hierarchy, renaming geometry to the
- * indicated name.
- */
-void EggOptchar::
-rename_primitives(EggGroupNode *egg_group, const string &name) {
- EggGroupNode::iterator gi;
- for (gi = egg_group->begin(); gi != egg_group->end(); ++gi) {
- EggNode *child = (*gi);
-
- if (child->is_of_type(EggGroupNode::get_class_type())) {
- EggGroupNode *group = DCAST(EggGroupNode, child);
- rename_primitives(group, name);
-
- } else if (child->is_of_type(EggPrimitive::get_class_type())) {
- child->set_name(name);
- }
- }
-}
-
-/**
- * Generates the preload tables for each model.
- */
-void EggOptchar::
-do_preload() {
- // First, build up the list of AnimPreload entries, one for each animation
- // file.
- PT(EggGroup) anim_group = new EggGroup("preload");
-
- int num_characters = _collection->get_num_characters();
- int ci;
- for (ci = 0; ci < num_characters; ++ci) {
- EggCharacterData *char_data = _collection->get_character(ci);
-
- int num_models = char_data->get_num_models();
- for (int mn = 0; mn < num_models; ++mn) {
- EggNode *root = char_data->get_model_root(mn);
- if (root->is_of_type(EggTable::get_class_type())) {
- // This model represents an animation.
- EggData *data = char_data->get_egg_data(mn);
- string basename = data->get_egg_filename().get_basename_wo_extension();
- PT(EggAnimPreload) anim_preload = new EggAnimPreload(basename);
-
- int mi = char_data->get_model_index(mn);
- anim_preload->set_num_frames(char_data->get_num_frames(mi));
- double frame_rate = char_data->get_frame_rate(mi);
- if (frame_rate != 0.0) {
- anim_preload->set_fps(frame_rate);
- }
-
- anim_group->add_child(anim_preload);
- }
- }
- }
-
- // Now go back through and copy the preload tables into each of the model
- // files.
- for (ci = 0; ci < num_characters; ++ci) {
- EggCharacterData *char_data = _collection->get_character(ci);
-
- int num_models = char_data->get_num_models();
- for (int mn = 0; mn < num_models; ++mn) {
- EggNode *root = char_data->get_model_root(mn);
- if (root->is_of_type(EggGroup::get_class_type())) {
- // This is a model file. Copy in the table.
- EggGroup *model_root = DCAST(EggGroup, root);
- EggGroup::const_iterator ci;
- for (ci = anim_group->begin(); ci != anim_group->end(); ++ci) {
- EggAnimPreload *anim_preload = DCAST(EggAnimPreload, *ci);
- PT(EggAnimPreload) new_anim_preload = new EggAnimPreload(*anim_preload);
- model_root->add_child(new_anim_preload);
- }
- }
- }
- }
-}
-
-/**
- * Sets the initial pose for the character(s).
- */
-void EggOptchar::
-do_defpose() {
- // Split out the defpose parameter.
- Filename egg_filename;
- size_t comma = _defpose.find(',');
- egg_filename = _defpose.substr(0, comma);
-
- string frame_str;
- if (comma != string::npos) {
- frame_str = _defpose.substr(comma + 1);
- }
- frame_str = trim(frame_str);
- int frame = 0;
- if (!frame_str.empty()) {
- if (!string_to_int(frame_str, frame)) {
- nout << "Invalid integer in -defpose: " << frame_str << "\n";
- return;
- }
- }
-
- // Now find the named animation file in our egg list.
- int egg_index = -1;
- int num_eggs = _collection->get_num_eggs();
- int i;
-
- // First, look for an exact match.
- for (i = 0; i < num_eggs && egg_index == -1; ++i) {
- if (_collection->get_egg(i)->get_egg_filename() == egg_filename) {
- egg_index = i;
- }
- }
-
- // Then, look for an inexact match.
- string egg_basename = egg_filename.get_basename_wo_extension();
- for (i = 0; i < num_eggs && egg_index == -1; ++i) {
- if (_collection->get_egg(i)->get_egg_filename().get_basename_wo_extension() == egg_basename) {
- egg_index = i;
- }
- }
-
- if (egg_index == -1) {
- // No joy.
- nout << "Egg file " << egg_filename << " named in -defpose, but does not appear on command line.\n";
- return;
- }
-
- EggData *egg_data = _collection->get_egg(egg_index);
-
- if (_collection->get_num_models(egg_index) == 0) {
- nout << "Egg file " << egg_filename << " does not include any model or animation.\n";
- return;
- }
-
- // Now get the first model (or animation) named by this egg file.
- int mi = _collection->get_first_model_index(egg_index);
- EggCharacterData *ch = _collection->get_character_by_model_index(mi);
- EggJointData *root_joint = ch->get_root_joint();
-
- int anim_index = -1;
- for (i = 0; i < ch->get_num_models() && anim_index == -1; ++i) {
- if (ch->get_egg_data(i) == egg_data) {
- anim_index = i;
- }
- }
-
- // This couldn't possibly fail, since we already checked this above.
- nassertv(anim_index != -1);
-
- // Now we can recursively apply the default pose to the hierarchy.
- root_joint->apply_default_pose(anim_index, frame);
-}
-
-int main(int argc, char *argv[]) {
- EggOptchar prog;
- prog.parse_command_line(argc, argv);
- prog.run();
- return 0;
-}
diff --git a/pandatool/src/egg-optchar/eggOptchar.h b/pandatool/src/egg-optchar/eggOptchar.h
deleted file mode 100644
index 30ea4cdd..00000000
--- a/pandatool/src/egg-optchar/eggOptchar.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggOptchar.h
- * @author drose
- * @date 2003-07-18
- */
-
-#ifndef EGGOPTCHAR_H
-#define EGGOPTCHAR_H
-
-#include "pandatoolbase.h"
-
-#include "eggCharacterFilter.h"
-#include "luse.h"
-
-#include "pvector.h"
-#include "vector_string.h"
-#include "globPattern.h"
-
-class EggCharacterData;
-class EggComponentData;
-class EggJointData;
-class EggSliderData;
-class EggGroupNode;
-
-/**
- * Performs basic optimizations of a character model and its associated
- * animations, by analyzing the animation tables and removing unneeded joints
- * and/or morphs. Can also be used to restructure the character hierarchy.
- */
-class EggOptchar : public EggCharacterFilter {
-public:
- EggOptchar();
-
- void run();
-
-protected:
- virtual bool handle_args(Args &args);
-
-private:
- static bool dispatch_vector_string_pair(const std::string &opt, const std::string &arg, void *var);
- static bool dispatch_name_components(const std::string &opt, const std::string &arg, void *var);
- static bool dispatch_double_components(const std::string &opt, const std::string &arg, void *var);
- static bool dispatch_flag_groups(const std::string &opt, const std::string &arg, void *var);
-
- void determine_removed_components();
- void move_vertices();
- bool process_joints();
- EggJointData *find_best_parent(EggJointData *joint_data) const;
- EggJointData *find_best_vertex_joint(EggJointData *joint_data) const;
-
- bool apply_user_reparents();
- bool zero_channels();
- bool quantize_channels();
- void analyze_joints(EggJointData *joint_data, int level);
- void analyze_sliders(EggCharacterData *char_data);
- void list_joints(EggJointData *joint_data, int indent_level, bool verbose);
- void list_joints_p(EggJointData *joint_data, int &col);
- void list_scalars(EggCharacterData *char_data, bool verbose);
- void describe_component(EggComponentData *comp_data, int indent_level,
- bool verbose);
- void do_reparent();
-
- void quantize_vertices();
- void quantize_vertices(EggNode *egg_node);
- void quantize_vertex(EggVertex *egg_vertex);
-
- void do_flag_groups(EggGroupNode *egg_group);
- void rename_joints();
- void rename_primitives(EggGroupNode *egg_group, const std::string &name);
- void change_dart_type(EggGroupNode *egg_group, const std::string &new_dart_type);
- void do_preload();
- void do_defpose();
-
- bool _list_hierarchy;
- bool _list_hierarchy_v;
- bool _list_hierarchy_p;
- bool _preload;
- bool _keep_all;
-
- class StringPair {
- public:
- std::string _a;
- std::string _b;
- };
- typedef pvector StringPairs;
- StringPairs _new_joints;
- StringPairs _reparent_joints;
- StringPairs _zero_channels;
- StringPairs _rename_joints;
-
- vector_string _keep_components;
- vector_string _drop_components;
- vector_string _expose_components;
- vector_string _suppress_components;
-
- std::string _dart_type;
-
- class DoubleString {
- public:
- double _a;
- std::string _b;
- };
- typedef pvector DoubleStrings;
- DoubleStrings _quantize_anims;
-
- typedef pvector Globs;
-
- class FlagGroupsEntry {
- public:
- Globs _groups;
- std::string _name;
- };
- typedef pvector FlagGroups;
- FlagGroups _flag_groups;
-
- std::string _defpose;
-
- bool _optimal_hierarchy;
- double _vref_quantum;
-};
-
-#endif
diff --git a/pandatool/src/egg-optchar/eggOptcharUserData.I b/pandatool/src/egg-optchar/eggOptcharUserData.I
deleted file mode 100644
index 47f71ac4..00000000
--- a/pandatool/src/egg-optchar/eggOptcharUserData.I
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggOptcharUserData.I
- * @author drose
- * @date 2003-07-18
- */
-
-/**
- *
- */
-INLINE EggOptcharUserData::
-EggOptcharUserData() {
- _flags = 0;
- _static_mat = LMatrix4d::ident_mat();
- _static_value = 0.0;
-}
-
-
-/**
- *
- */
-INLINE EggOptcharUserData::
-EggOptcharUserData(const EggOptcharUserData ©) :
- EggUserData(copy),
- _flags(copy._flags),
- _static_mat(copy._static_mat),
- _static_value(copy._static_value)
-{
-}
-
-
-/**
- *
- */
-INLINE void EggOptcharUserData::
-operator = (const EggOptcharUserData ©) {
- EggUserData::operator = (copy);
- _flags = copy._flags;
- _static_mat = copy._static_mat;
- _static_value = copy._static_value;
-}
-
-/**
- *
- */
-INLINE bool EggOptcharUserData::
-is_static() const {
- return (_flags & F_static) != 0;
-}
-
-/**
- *
- */
-INLINE bool EggOptcharUserData::
-is_identity() const {
- return (_flags & F_identity) != 0;
-}
-
-/**
- *
- */
-INLINE bool EggOptcharUserData::
-is_empty() const {
- return (_flags & F_empty) != 0;
-}
-
-/**
- *
- */
-INLINE bool EggOptcharUserData::
-is_top() const {
- return (_flags & F_top) != 0;
-}
diff --git a/pandatool/src/egg-optchar/eggOptcharUserData.cxx b/pandatool/src/egg-optchar/eggOptcharUserData.cxx
deleted file mode 100644
index ecb6b32c..00000000
--- a/pandatool/src/egg-optchar/eggOptcharUserData.cxx
+++ /dev/null
@@ -1,16 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggOptcharUserData.cxx
- * @author drose
- * @date 2003-07-18
- */
-
-#include "eggOptcharUserData.h"
-
-TypeHandle EggOptcharUserData::_type_handle;
diff --git a/pandatool/src/egg-optchar/eggOptcharUserData.h b/pandatool/src/egg-optchar/eggOptcharUserData.h
deleted file mode 100644
index 2f12aae9..00000000
--- a/pandatool/src/egg-optchar/eggOptcharUserData.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggOptcharUserData.h
- * @author drose
- * @date 2003-07-18
- */
-
-#ifndef EGGOPTCHARUSERDATA_H
-#define EGGOPTCHARUSERDATA_H
-
-#include "pandatoolbase.h"
-#include "eggUserData.h"
-#include "luse.h"
-
-/**
- * This class contains extra user data which is piggybacked onto EggGroup
- * objects for the purpose of the maya converter.
- */
-class EggOptcharUserData : public EggUserData {
-public:
- INLINE EggOptcharUserData();
- INLINE EggOptcharUserData(const EggOptcharUserData ©);
- INLINE void operator = (const EggOptcharUserData ©);
-
- INLINE bool is_static() const;
- INLINE bool is_identity() const;
- INLINE bool is_empty() const;
- INLINE bool is_top() const;
-
- enum Flags {
- F_static = 0x0001,
- F_identity = 0x0002,
- F_empty = 0x0004,
- F_top = 0x0008,
- F_remove = 0x0010,
- F_expose = 0x0020,
- F_suppress = 0x0040,
- };
- int _flags;
- LMatrix4d _static_mat;
- double _static_value;
-
-public:
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- EggUserData::init_type();
- register_type(_type_handle, "EggOptcharUserData",
- EggUserData::get_class_type());
- }
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
-
-private:
- static TypeHandle _type_handle;
-};
-
-#include "eggOptcharUserData.I"
-
-#endif
diff --git a/pandatool/src/egg-optchar/vertexMembership.I b/pandatool/src/egg-optchar/vertexMembership.I
deleted file mode 100644
index f001b1d9..00000000
--- a/pandatool/src/egg-optchar/vertexMembership.I
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file vertexMembership.I
- * @author drose
- * @date 2003-07-21
- */
-
-/**
- *
- */
-INLINE VertexMembership::
-VertexMembership(EggGroup *group, double membership) :
- _group(group),
- _membership(membership)
-{
-}
-
-/**
- *
- */
-INLINE VertexMembership::
-VertexMembership(const VertexMembership ©) :
- _group(copy._group),
- _membership(copy._membership)
-{
-}
-
-/**
- *
- */
-INLINE void VertexMembership::
-operator = (const VertexMembership ©) {
- _group = copy._group;
- _membership = copy._membership;
-}
-
-/**
- *
- */
-INLINE bool VertexMembership::
-operator < (const VertexMembership &other) const {
- if (_membership != other._membership) {
- return _membership < other._membership;
- }
- return _group < other._group;
-}
diff --git a/pandatool/src/egg-optchar/vertexMembership.cxx b/pandatool/src/egg-optchar/vertexMembership.cxx
deleted file mode 100644
index d7eab777..00000000
--- a/pandatool/src/egg-optchar/vertexMembership.cxx
+++ /dev/null
@@ -1,14 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file vertexMembership.cxx
- * @author drose
- * @date 2003-07-21
- */
-
-#include "vertexMembership.h"
diff --git a/pandatool/src/egg-optchar/vertexMembership.h b/pandatool/src/egg-optchar/vertexMembership.h
deleted file mode 100644
index 31cc16ae..00000000
--- a/pandatool/src/egg-optchar/vertexMembership.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file vertexMembership.h
- * @author drose
- * @date 2003-07-21
- */
-
-#ifndef VERTEXMEMBERSHIP_H
-#define VERTEXMEMBERSHIP_H
-
-#include "pandatoolbase.h"
-
-#include "pvector.h"
-
-class EggGroup;
-
-/**
- * This class is used to help EggOptchar quantize the membership of one vertex
- * among its various groups.
- */
-class VertexMembership {
-public:
- INLINE VertexMembership(EggGroup *group, double membership);
- INLINE VertexMembership(const VertexMembership ©);
- INLINE void operator = (const VertexMembership ©);
-
- INLINE bool operator < (const VertexMembership &other) const;
-
- EggGroup *_group;
- double _membership;
-};
-
-typedef pvector VertexMemberships;
-
-#include "vertexMembership.I"
-
-#endif
diff --git a/pandatool/src/egg-palettize/CMakeLists.txt b/pandatool/src/egg-palettize/CMakeLists.txt
deleted file mode 100644
index 9af14457..00000000
--- a/pandatool/src/egg-palettize/CMakeLists.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-if(NOT BUILD_TOOLS)
- return()
-endif()
-
-if(NOT HAVE_EGG)
- return()
-endif()
-
-add_executable(egg-palettize eggPalettize.cxx eggPalettize.h)
-target_link_libraries(egg-palettize p3palettizer p3eggbase p3progbase)
-install(TARGETS egg-palettize EXPORT Tools COMPONENT Tools DESTINATION ${CMAKE_INSTALL_BINDIR})
-
-add_library(p3txafile txaFileFilter.cxx txaFileFilter.h txaFileFilter.I)
-set_target_properties(p3txafile PROPERTIES DEFINE_SYMBOL BUILDING_MISC)
-target_link_libraries(p3txafile PRIVATE p3palettizer)
-if(BUILD_SHARED_LIBS)
- # We can't install this if we're doing a static build, because it depends on
- # a static library that isn't installed.
- install(TARGETS p3txafile EXPORT Tools COMPONENT Tools DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
-endif()
diff --git a/pandatool/src/egg-palettize/eggPalettize.cxx b/pandatool/src/egg-palettize/eggPalettize.cxx
deleted file mode 100644
index 385dd789..00000000
--- a/pandatool/src/egg-palettize/eggPalettize.cxx
+++ /dev/null
@@ -1,878 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggPalettize.cxx
- * @author drose
- * @date 2000-11-28
- */
-
-#include "eggPalettize.h"
-#include "palettizer.h"
-#include "eggFile.h"
-#include "pal_string_utils.h"
-#include "filenameUnifier.h"
-
-#include "dcast.h"
-#include "eggData.h"
-#include "bamFile.h"
-#include "pnotify.h"
-#include "notifyCategory.h"
-#include "notifySeverity.h"
-
-#include
-
-/**
- *
- */
-EggPalettize::
-EggPalettize() : EggMultiFilter(true) {
- set_program_brief("pack textures from various .egg models into palette images");
- set_program_description
- ("egg-palettize attempts to pack several texture maps from various models "
- "together into one or more palette images, for improved rendering performance "
- "and ease of texture management. It can also resize textures and convert "
- "them to another image file format, whether or not they are actually "
- "placed on a palette, and can manage some "
- "simple texture properties, like mipmapping and rendering "
- "format.\n\n"
-
- "egg-palettize reads a texture attributes file, usually named "
- "textures.txa, which contains instructions from the user about "
- "resizing particular textures. Type egg-palettize -H for an "
- "introduction to the syntax of this file.\n\n"
-
- "The palettization information from previous runs is recorded in a file "
- "named textures.boo (assuming the attributes file is named "
- "textures.txa); a complete record of every egg file and every texture "
- "that has been referenced is kept here. This allows the program "
- "to intelligently manage the multiple egg files that may reference "
- "the textures in question.");
-
-
- clear_runlines();
- add_runline("[opts] file.egg [file.egg ...]");
-
- // We always have EggMultiBase's -f on: force complete load. In fact, we
- // use -f for our own purposes, below.
- remove_option("f");
- _force_complete = true;
-
- add_option
- ("af", "filename", 0,
- "Read the indicated file as the .txa file. The default is textures.txa.",
- &EggPalettize::dispatch_filename, &_got_txa_filename, &_txa_filename);
-
- add_option
- ("a", "filename", 0,
- "Deprecated option. This is the same as -af.",
- &EggPalettize::dispatch_filename, &_got_txa_filename, &_txa_filename);
-
- add_option
- ("as", "script", 0,
- "Accept the script specified on the command line as the contents of the "
- ".txa file, instead of reading a file on disk. This implies -nodb and "
- "-opt.",
- &EggPalettize::dispatch_string, &_got_txa_script, &_txa_script);
-
- add_option
- ("nodb", "", 0,
- "Don't read or record the state information to a .boo file. By default, "
- "the palettization information is recorded so it can be preserved "
- "between multiple invocations of egg-palettize. If you specify this "
- "parameter, all the egg files to be palettized together must be "
- "named at the same time. This also implies -opt, since there's no point "
- "in not making an optimal packing if you won't be preserving the "
- "state for future adjustments.",
- &EggPalettize::dispatch_none, &_nodb);
-
- add_option
- ("tn", "pattern", 0,
- "Specify the name to generate for each palette image. The string should "
- "contain %g for the group name, %p for the page name, and %i for the "
- "index within the page. The extension is inferred from the image "
- "type. The default is '%g_palette_%p_%i'.",
- &EggPalettize::dispatch_string, &_got_generated_image_pattern,
- &_generated_image_pattern);
-
- add_option
- ("pi", "", 0,
- "Do not process anything, but instead report the detailed palettization "
- "information written in the state file.",
- &EggPalettize::dispatch_none, &_report_pi);
-
- add_option
- ("s", "", 0,
- "Do not process anything, but report statistics on palette "
- "and texture utilization from the state file.",
- &EggPalettize::dispatch_none, &_report_statistics);
-
- add_option
- ("R", "", 0,
- "Remove the named egg files from the previously-generated state data "
- "file.",
- &EggPalettize::dispatch_none, &_remove_eggs);
-
- // We redefine -d using add_option() instead of redescribe_option() so it
- // gets listed along with these other options that relate.
- add_option
- ("d", "dirname", 0,
- "The directory in which to write the palettized egg files. This is "
- "only necessary if more than one egg file is processed at the same "
- "time; if it is included, each egg file will be processed and written "
- "into the indicated directory.",
- &EggPalettize::dispatch_filename, &_got_output_dirname, &_output_dirname);
- add_option
- ("dm", "dirname", 0,
- "The directory in which to place all maps: generated palettes, "
- "as well as images which were not placed on palettes "
- "(but may have been resized). If this contains the string %g, "
- "this will be replaced with the 'dir' string associated with a "
- "palette group; see egg-palettize -H.",
- &EggPalettize::dispatch_string, &_got_map_dirname, &_map_dirname);
- add_option
- ("ds", "dirname", 0,
- "The directory to write palette shadow images to. These are working "
- "copies of the palette images, useful when the palette image type is "
- "a lossy-compression type like JPEG; you can avoid generational loss "
- "of quality on the palette images with each pass through the palettes "
- "by storing these extra shadow images in a lossless image type. This "
- "directory is only used if the :shadowtype keyword appears in the .txa "
- "file.",
- &EggPalettize::dispatch_filename, &_got_shadow_dirname, &_shadow_dirname);
- add_option
- ("dr", "dirname", 0,
- "The directory to make map filenames relative to when writing egg "
- "files. If specified, this should be an initial substring of -dm.",
- &EggPalettize::dispatch_filename, &_got_rel_dirname, &_rel_dirname);
- add_option
- ("g", "group", 0,
- "The default palette group that egg files will be assigned to if they "
- "are not explicitly assigned to any other group.",
- &EggPalettize::dispatch_string, &_got_default_groupname, &_default_groupname);
- add_option
- ("gdir", "name", 0,
- "The \"dir\" string to associate with the default palette group "
- "specified with -g, if no other dir name is given in the .txa file.",
- &EggPalettize::dispatch_string, &_got_default_groupdir, &_default_groupdir);
-
- add_option
- ("all", "", 0,
- "Consider all the textures referenced in all egg files that have "
- "ever been palettized, not just the egg files that appear on "
- "the command line.",
- &EggPalettize::dispatch_none, &_all_textures);
- add_option
- ("egg", "", 0,
- "Regenerate all egg files that need modification, even those that "
- "aren't named on the command line.",
- &EggPalettize::dispatch_none, &_redo_eggs);
- add_option
- ("redo", "", 0,
- "Force a regeneration of each image from its original source(s). "
- "When used in conjunction with -egg, this also forces each egg file to "
- "be regenerated.",
- &EggPalettize::dispatch_none, &_redo_all);
- add_option
- ("opt", "", 0,
- "Force an optimal packing. By default, textures are added to "
- "existing palettes without disturbing them, which can lead to "
- "suboptimal packing. Including this switch forces the palettes "
- "to be rebuilt if necessary to optimize the packing, but this "
- "may invalidate other egg files which share this palette.",
- &EggPalettize::dispatch_none, &_optimal);
- add_option
- ("omitall", "", 0,
- "Re-enables the flag to omit all textures. This flag is normally on "
- "by default, causing nothing actually to be palettized, until the "
- "first time egg-palettize is run with the -opt flag, which turns off "
- "the omitall flag and thenceforth allows textures to be combined "
- "into palettes. Specifying this flag restores the original behavior "
- "of keeping every texture as a separate image (which is convenient for "
- "development).",
- &EggPalettize::dispatch_none, &_omitall);
-
- // This isn't even implemented yet. Presently, we never lock anyway.
- // Dangerous, but hard to implement reliable file locking across NFSSamba
- // and between multiple OS's.
- /*
- add_option
- ("nolock", "", 0,
- "Don't attempt to grab a file lock on the .txa file. Use "
- "with extreme caution, as multiple processes running on the same "
- ".txa file may overwrite each other. Use this only if the lock "
- "cannot be achieved for some reason.",
- &EggPalettize::dispatch_none, &_dont_lock_txa);
- */
-
- add_option
- ("H", "", 0,
- "Describe the syntax of the attributes file.",
- &EggPalettize::dispatch_none, &_describe_input_file);
-
- _txa_filename = "textures.txa";
-}
-
-
-/**
- * Does something with the additional arguments on the command line (after all
- * the -options have been parsed). Returns true if the arguments are good,
- * false otherwise.
- */
-bool EggPalettize::
-handle_args(ProgramBase::Args &args) {
- if (_describe_input_file) {
- describe_input_file();
- exit(1);
- }
-
- if (_remove_eggs) {
- // If we're removing these egg files from the database, we don't want to
- // try to load them up. Instead, just save the filenames.
- _remove_egg_list = args;
- return true;
- }
-
- // Otherwise, load the named egg files up normally.
- return EggMultiFilter::handle_args(args);
-}
-
-/**
- *
- */
-void EggPalettize::
-describe_input_file() {
- nout <<
- "An attributes file consists mostly of lines describing desired sizes of "
- "texture maps. The format resembles, but is not identical to, that of "
- "the qtess input file. Examples:\n\n"
-
- " texturename.rgb : 64 64\n"
- " texture-a.rgb texture-b.rgb : 32 16 margin 2\n"
- " *.rgb : 50% cont\n"
- " eyelids.rgb : 16 16 omit\n\n"
-
- "In general, each line consists of one or more filenames (and can "
- "contain shell globbing characters like '*' or '?'), and a colon "
- "followed by a size request. For each texture appearing in an egg "
- "file, the input list is scanned from the beginning and the first "
- "line that matches the filename defines the size of the texture, as "
- "well as other properties associated with the texture.\n\n"
-
- "A size request is most often a pair of numbers, giving a specific x y "
- "size of the texture. A third number may also be supplied, giving a "
- "specific number of channels to convert to (for instance, to force an "
- "image to a 64x64 grayscale image, set its size to 64 64 1). "
- "Alternatively, a percentage scaling may be specified, e.g. 30%. The "
- "requested size need not be a power of 2.\n\n"
-
- "Other valid keywords that may be specified on the same line with the "
- "texture are:\n\n";
-
- show_text(" omit", 10,
- "This indicates that the texture should not be placed on any "
- "palette image. It may still be resized, and it will in any "
- "case be copied into the install directory.\n\n");
-
- show_text(" margin i", 10,
- "This specifies the number of pixels that should be written "
- "around the border of the texture when it is placed in a "
- "palette image; i is the integer number of pixels. The "
- "use of a margin helps cut down on color bleed "
- "from neighboring images. If the texture does "
- "not end up placed in a palette image, the "
- "margin is not used. If not specified, the default margin is "
- "used, which is specified by the :margin command (see below).\n\n");
-
- show_text(" coverage f", 10,
- "This parameter specifies the maximum coverage to allow for this "
- "particular texture before rejecting it "
- "from the palette. If not specified, the default is "
- "specified by the :coverage command (see below).\n\n");
-
- nout << " nearest\n"
- << " linear\n";
- show_text(" mipmap", 10,
- "One of these options may be used to force the texture to use "
- "a particular minfilter/magfilter sampling mode. If this is not "
- "specified, the sampling mode specified in the egg file is "
- "used. Textures that use different sampling modes cannot "
- "be placed together on the same palette images.\n\n");
-
- show_text(" rgba", 10,
- "This specifies format 'rgba' should be in effect for this "
- "particular texture. Any valid egg texture format, such as "
- "rgba, rgba12, rgba8, rgb5, luminance, etc. may be specified. "
- "If nothing is specified, the format specified in the egg file "
- "is used. The format will automatically be downgraded to match "
- "the number of channels in the texture image; e.g. rgba will "
- "automatically be converted to rgb for a three-channel image. "
- "As with the filter modes above, textures that use different "
- "formats cannot be placed together on the same palette "
- "images.\n\n");
-
- show_text(" force-rgba", 10,
- "This specifies a particular format, as above, that should be "
- "in effect for this texture, but it will not be downgraded to "
- "match the number of channels. As above, any valid egg texture "
- "format may be used, e.g. force-rgba12, force-rgb5, etc.\n\n");
-
- show_text(" srgb", 10,
- "This specifies that this texture is in sRGB space and the format "
- "should be changed to reflect that. The texture format will be "
- "changed to the appropriate sRGB equivalent based on the number "
- "of image channels.\n\n");
-
- show_text(" keep-format", 10,
- "This specifies that the image format requested by an egg file "
- "should be exactly preserved, without attempting to optimize "
- "it by, for instance, automatically downgrading.\n\n");
-
- show_text(" generic", 10,
- "Specifies that any image format requested by an egg file "
- "that requests a particular bitdepth should be replaced by "
- "its generic equivalent, e.g. rgba8 should become rgba.\n\n");
-
- show_text(" (alpha mode)", 10,
- "A particular alpha mode may be applied to a texture by naming "
- "the alpha mode. This may be any valid egg alpha mode, e.g. "
- "blend, binary, ms, or dual.\n\n");
-
- show_text(" repeat_u, repeat_v, clamp_u, clamp_v", 10,
- "Explcitly specify whether the source texture should repeat or "
- "clamp in each direction. Although palette images are always "
- "clamped, this will affect the pixels that are painted into "
- "the palette image.\n\n");
-
- show_text(" (image type)", 10,
- "A texture may be converted to a particular image type, for "
- "instance jpg or rgb, by naming the type. If present, this "
- "overrides the :imagetype command, described below. As with "
- ":imagetype, you may also specify two type names separated "
- "by a comma, to indicate that a different file should be written "
- "for the color and alpha components.\n\n");
-
- show_text(" (group name)", 10,
- "A texture may also be assigned to a specific group by naming "
- "the group. The groups are defined using the :group command "
- "(see below). Normally, textures are not assigned directly "
- "to groups; instead, it is more useful to assign the egg files "
- "they are referenced in to groups; see below.\n\n");
-
- show_text(" cont", 10,
- "Normally, a texture file (or egg file) scans the lines in the "
- "attributes file from the top, and stops on the first line that "
- "matches its name. If the keyword 'cont' is included on the "
- "line, however, the texture will apply the properties given "
- "on the line, and then continue scanning. This trick may be "
- "used to specify general parameters for all files while still "
- "allowing the texture to match a more specific line below.\n\n");
-
- nout <<
- "The attributes file may also assign egg files to various "
- "named palette groups. The syntax is similar to the above:\n\n"
-
- " car-blue.egg : main\n"
- " road.egg house.egg : main\n"
- " plane.egg : phase_2 main\n"
- " *.egg : phase_2\n\n"
-
- "Any number of egg files may be named on one line, and the set of "
- "named egg files may be simultaneously assigned to one or more groups. "
- "Each group must have been previously defined using the :group command "
- "(see below). Each texture that is referenced by a given "
- "egg file will be palettized "
- "into at least one of the groups assigned to the egg file.\n\n"
-
- "Finally, there are a number of special commands that may appear in the "
- "attributes file; some of these have been alluded to in the above "
- "comments. These commands typically specify global parameters or "
- "palettization options. The command names begin with a colon to "
- "distinguish them from other kinds of lines. Each command must "
- "appear on a line by itself. The commands are:\n\n";
-
- show_text(" :palette xsize ysize", 10,
- "This specifies the size of the palette images to be "
- "created. The default is 512 by 512.\n\n");
-
- show_text(" :margin msize", 10,
- "This specifies the amount of default margin to apply to all "
- "textures that are placed within a palette image. The margin "
- "is a number of additional pixels that are written around the "
- "texture image to help prevent color bleeding between "
- "neighboring images within the same palette. The default "
- "is 2.\n\n");
-
- show_text(" :background r g b a", 10,
- "Specifies the background color of the generated palette "
- "images. Normally, this is black, and it doesn't matter much "
- "since the background color is, by definition, the color "
- "of the palette images where nothing is used.\n\n");
-
- show_text(" :coverage area", 10,
- "The 'coverage' of a texture refers to the fraction of "
- "the area in the texture image that is actually used, according "
- "to the UV's that appear in the various egg files. If a texture's "
- "coverage is less than 1, only some of the texture image is used "
- "(and only this part will be written to the palette). If the "
- "coverage is greater than 1, the texture repeats that number of "
- "times. A repeating texture may still be palettized by writing "
- "the required number of copies into the palette image, according "
- "to the coverage area.\n\n"
-
- "This command specifies the maximum coverage to allow for any "
- "texture before rejecting it from the palette. It may be any "
- "floating-point number greater than zero. Set this to 1 "
- "to avoid palettizing repeating textures altogether. This may "
- "also be overridden for a particular texture using the 'coverage' "
- "keyword on the texture line.\n\n");
-
- show_text(" :powertwo flag", 10,
- "Specifies whether textures should be forced to a power of two "
- "size when they are not placed within a palette. Use 1 for true, "
- "to force textures to a power of two; or 0 to leave them exactly "
- "the size they are specified. The default is true.\n\n");
-
- show_text(" :round fraction fuzz", 10,
- "When the coverage area is computed, it may optionally be "
- "rounded up to the next sizeable unit before placing the "
- "texture within the palette. This helps reduce constant "
- "repalettization caused by slight differences in coverage "
- "between egg files. For instance, say file a.egg references a "
- "texture with a coverage of 0.91, and then later file b.egg "
- "is discovered to reference the same texture with a coverage of "
- "0.92. If the texture was already palettized with the original "
- "coverage of 0.91, it must now be moved in the palette.\n\n"
-
- "Rounding the coverage area up to some fixed unit reduces this "
- "problem. For instance, if you specified a value 0.5 for "
- "fraction in the above command, it would round both of these "
- "values up to the next half-unit, or 1.0.\n\n"
-
- "The second number is a fuzz factor, and should be a small "
- "number; if the coverage area is just slightly larger than "
- "the last unit (within the fuzz factor), it is rounded down "
- "instead of up. This is intended to prevent UV coordinates "
- "that are just slightly out of the range [0, 1] (which happens "
- "fairly often) from forcing the palettization area all the "
- "way up to the next stop.\n\n"
-
- "The default if this is unspecified is 0.1 0.01. That is, "
- "round up to the next tenth, unless within a hundredth of the "
- "last tenth. To disable rounding, specify ':round no'. "
- "Rounding is implicitly disabled when you run with the -opt "
- "command line option.\n\n");
-
- show_text(" :remap (never | group | poly)", 10,
- "Sometimes two different parts of an egg file may reference "
- "different regions of a repeating texture. For instance, "
- "group A may reference UV coordinate values ranging from (0,5) "
- "to (1,6), for a coverage of 1.0, while group B references "
- "values ranging from (0,2) to (1,4), for a coverage of 2.0. "
- "The maximum coverage used is only 2.0, and thus the texture "
- "only needs to appear in the palette twice, but the total range "
- "of UV's is from (0,2) to (1,6), causing an apparent coverage "
- "of 4.0.\n\n"
-
- "It's possible for egg-palettize to reduce this kind of mistake "
- "by remapping both groups of UV's so that they overlap. This "
- "parameter specifies how this operation should be done. If "
- "the option is 'never', remapping will not be performed; if "
- "'group', entire groups will be remapped as a unit, if 'poly', "
- "individual polygons within a group may be remapped. This last "
- "option provides the greatest minimization of UV coverage, "
- "but possibly at the expense of triangle strips in the resulting "
- "model (since some vertices can no longer be shared).\n\n"
-
- "Sometimes, it may be necessary to be more restrictive on "
- "character geometry than on non-character geometry, because "
- "the cost of adding additional vertices on characters is "
- "greater. You can specify a different kind of remapping for "
- "characters only, by using the keyword 'char' on the same line, "
- "e.g. ':remap group char never'.\n\n"
-
- "The default remap mode for all geometry, character or otherwise, "
- "if no remap mode is specified is 'poly'.\n\n");
-
- show_text(" :imagetype type[,alpha_type]", 10,
- "This specifies the default type of image file that should be "
- "generated for each palette image and for each unplaced texture "
- "copied into the install directory. This may be overridden for "
- "a particular texture by specifying the image type on the "
- "texture line.\n\n"
-
- "If two image type names separate by a comma are given, it means "
- "to generate a second file of the second type for the alpha "
- "channel, for images that require an alpha channel. This allows "
- "support for image file formats that do not support alpha "
- "(for instance, JPEG).\n\n");
-
- show_text(" :shadowtype type[,alpha_type]", 10,
- "When generating palette images, egg-palettize sometimes has to "
- "read and write the same palette image repeatedly. If the "
- "palette image is stored in a lossy file format (like JPEG, see "
- ":imagetype), this can eventually lead to degradation of the "
- "palette images. As a workaround, egg-palettize can store "
- "its working copies of the palette images in lossless shadow "
- "images. Specify this to enable this feature; give it the "
- "name of a lossless image file format. The shadow images will "
- "be written to the directory specified by -ds on the command "
- "line.\n\n");
-
- show_text(" :group groupname [dir dirname] [on group1 group2 ...] [includes group1 group2 ...]", 10,
- "This defines a palette group, a logical division of textures. "
- "Each texture is assigned to one or more palette groups before "
- "being placed in any palette image; the palette images are "
- "tied to the groups.\n\n"
-
- "The optional parameter 'dir' specifies a directory name to "
- "associate with this group. This name is substituted in for "
- "the string '%g' when it appears in the map directory name "
- "specified on the command line with -dm; this may be used to "
- "install textures and palettes into different directories based "
- "on the groups they are assigned to.\n\n"
-
- "Palette groups can also be hierarchically related. The "
- "keyword 'on' specifies any number of groups that this "
- "palette group depends on; if a texture has already been "
- "assigned to one of this group's dependent groups, it will "
- "not need to be assigned to this group. This also implicitly "
- "specifies a dir if one has not already been specified.\n\n"
-
- "The keyword 'includes' names one or more groups that depend "
- "on this group.\n\n");
-
- show_text(" :textureswap groupname texturename0 texturename1 [texturename2 ...]", 10,
- "This option builds a set of matching, interchangeable palette images. "
- "All palette images in the set share the same internal texture layout. "
- "The intention is to be able to swap palette images out at runtime, "
- "to replace entire sets of textures on a model in one operation. "
- "The textures named by this option indicate the texture images "
- "which are similar to each other, and which all should be assigned "
- "to the same placement on the different palette images: "
- "texturename0 will be assigned to palette image 0, "
- "texturename1 to the same position on palette image 1, "
- "texturename2 to the same position on palette image 2, and so on. "
- "To define a complete palette image, you must repeat this option "
- "several times to associate all of the similar texture images.\n\n");
-
- nout <<
- "Comments may appear freely throughout the file, and are set off by a "
- "hash mark (#).\n\n";
-}
-
-
-/**
- *
- */
-void EggPalettize::
-run() {
- // Fiddle with the loader severity, so we don't confuse the user with
- // spurious "reading" and "writing" messages about the state file. If the
- // severity is currently NS_info (the default), set it to NS_warning
- // instead.
- Notify *notify = Notify::ptr();
- NotifyCategory *loader_cat = notify->get_category(":loader");
- if (loader_cat != nullptr &&
- loader_cat->get_severity() == NS_info) {
- loader_cat->set_severity(NS_warning);
- }
-
- Filename state_filename;
- BamFile state_file;
-
- if (_got_txa_script) {
- // If we got a command-line script instead of a .txa file, we won't be
- // encoding a .boo file either.
- _nodb = true;
-
- } else {
- // Look for the .txa file.
- if (!_txa_filename.exists() && !_got_txa_filename) {
- // If we did not specify a filename, and the default filename of
- // "textures.txa" doesn't exist, try looking in srcmaps, as another
- // likely possibility.
- Filename maybe = _txa_filename;
- maybe.set_dirname("src/maps");
- if (maybe.exists()) {
- _txa_filename = maybe;
- }
- }
-
- if (!_txa_filename.exists()) {
- nout << FilenameUnifier::make_user_filename(_txa_filename)
- << " does not exist; cannot run.\n";
- exit(1);
- }
-
- FilenameUnifier::set_txa_filename(_txa_filename);
-
- state_filename = _txa_filename;
- state_filename.set_extension("boo");
- }
-
- if (_nodb) {
- // -nodb means don't attempt to read textures.boo; in fact, don't even
- // bother reporting this absence to the user.
- pal = new Palettizer;
-
- // And -nodb implies -opt.
- _optimal = true;
-
- } else if (!state_filename.exists()) {
- nout << FilenameUnifier::make_user_filename(state_filename)
- << " does not exist; starting palettization from scratch.\n";
- pal = new Palettizer;
-
- // By default, the -omitall flag is true from the beginning.
- pal->_omit_everything = true;
-
- } else {
- // Read the Palettizer object from the Bam file written previously. This
- // will recover all of the state saved from the past session.
- nout << "Reading " << FilenameUnifier::make_user_filename(state_filename)
- << "\n";
-
- if (!state_file.open_read(state_filename)) {
- nout << FilenameUnifier::make_user_filename(state_filename)
- << " exists, but cannot be read. Perhaps you should "
- << "remove it so a new one can be created.\n";
- exit(1);
- }
-
- TypedWritable *obj = state_file.read_object();
- if (obj == nullptr || !state_file.resolve()) {
- nout << FilenameUnifier::make_user_filename(state_filename)
- << " exists, but appears to be corrupt. Perhaps you "
- << "should remove it so a new one can be created.\n";
- exit(1);
- }
-
- if (!obj->is_of_type(Palettizer::get_class_type())) {
- nout << FilenameUnifier::make_user_filename(state_filename)
- << " exists, but does not appear to be "
- << "an egg-palettize output file. Perhaps you "
- << "should remove it so a new one can be created.\n";
- exit(1);
- }
-
- state_file.close();
-
- pal = DCAST(Palettizer, obj);
-
- if (pal->_read_pi_version > pal->_pi_version) {
- nout << FilenameUnifier::make_user_filename(state_filename)
- << " was written by a more recent version of egg-palettize "
- << "than this one. You will need to update your egg-palettize.\n";
- exit(1);
- }
-
- if (pal->_read_pi_version < pal->_min_pi_version) {
- nout << FilenameUnifier::make_user_filename(state_filename)
- << " was written by an old version of egg-palettize.\n\n"
- << "You will need to make undo-pal (or simply remove the file "
- << FilenameUnifier::make_user_filename(state_filename)
- << " and try again).\n\n";
- exit(1);
- }
-
- if (!pal->is_valid()) {
- nout << FilenameUnifier::make_user_filename(state_filename)
- << " could not be properly read. You will need to remove it.\n";
- exit(1);
- }
- }
-
- pal->set_noabs(_noabs);
-
- if (_report_pi) {
- pal->report_pi();
- exit(0);
- }
-
- if (_report_statistics) {
- pal->report_statistics();
- exit(0);
- }
-
- bool okflag = true;
-
- if (_got_txa_script) {
- std::istringstream txa_script(_txa_script);
- pal->read_txa_file(txa_script, "command line");
-
- } else {
- _txa_filename.set_text();
- std::ifstream txa_file;
- if (!_txa_filename.open_read(txa_file)) {
- nout << "Unable to open " << _txa_filename << "\n";
- exit(1);
- }
- pal->read_txa_file(txa_file, _txa_filename);
- }
-
- if (_got_generated_image_pattern) {
- pal->_generated_image_pattern = _generated_image_pattern;
- }
-
- if (_got_default_groupname) {
- pal->_default_groupname = _default_groupname;
- } else {
- pal->_default_groupname = _txa_filename.get_basename_wo_extension();
- }
-
- if (_got_default_groupdir) {
- pal->_default_groupdir = _default_groupdir;
- }
-
- if (_got_map_dirname) {
- pal->_map_dirname = _map_dirname;
- }
- if (_got_shadow_dirname) {
- pal->_shadow_dirname = _shadow_dirname;
- }
- if (_got_rel_dirname) {
- pal->_rel_dirname = _rel_dirname;
- FilenameUnifier::set_rel_dirname(_rel_dirname);
- }
-
- // We only omit solitary textures from palettes if we're running in optimal
- // mode. Otherwise, we're likely to invalidate old egg files by changing a
- // texture from solitary to nonsolitary state or vice-versa.
- pal->_omit_solitary = _optimal;
-
- if (_omitall) {
- pal->_omit_everything = true;
- } else if (_optimal) {
- pal->_omit_everything = false;
- }
-
- pal->all_params_set();
-
- // Remove any files named for removal.
- Args::const_iterator ai;
- for (ai = _remove_egg_list.begin(); ai != _remove_egg_list.end(); ++ai) {
- Filename filename = (*ai);
- pal->remove_egg_file(filename.get_basename());
- }
-
- // And process the egg files named for addition.
- bool all_eggs_valid = true;
-
- std::string egg_comment = get_exec_command();
- Eggs::const_iterator ei;
- for (ei = _eggs.begin(); ei != _eggs.end(); ++ei) {
- EggData *egg_data = (*ei);
- Filename source_filename = egg_data->get_egg_filename();
- Filename dest_filename = get_output_filename(source_filename);
- std::string name = source_filename.get_basename();
-
- EggFile *egg_file = pal->get_egg_file(name);
- if (!egg_file->from_command_line(egg_data, source_filename, dest_filename,
- egg_comment)) {
- all_eggs_valid = false;
-
- } else {
- pal->add_command_line_egg(egg_file);
- }
- }
-
- if (!all_eggs_valid) {
- nout << "Errors reading egg file(s).\n";
- exit(1);
- }
-
- if (_optimal) {
- // If we're asking for an optimal packing, throw away the old packing and
- // start fresh.
- pal->reset_images();
- _all_textures = true;
-
- /* Asad: I disagree: unless :round is set to no from textures.txa, we
- should always leave the _round_uvs to default.
- // Also turn off the rounding-up of UV's for this purpose.
- pal->_round_uvs = false;
- */
- }
-
- if (_all_textures) {
- pal->process_all(_redo_all, state_filename);
- } else {
- pal->process_command_line_eggs(_redo_all, state_filename);
- }
-
- if (_optimal) {
- // If we're asking for optimal packing, this also implies we want to
- // resize the big empty palette images down.
- pal->optimal_resize();
- }
-
- if (_redo_eggs) {
- if (!pal->read_stale_eggs(_redo_all)) {
- okflag = false;
- }
- }
-
- if (okflag) {
- pal->generate_images(_redo_all);
-
- if (_redo_eggs) {
- // generate_images() might have made a few more stale egg files
- // (particularly if a texture palette changed filenames).
- if (!pal->read_stale_eggs(false)) {
- okflag = false;
- }
- }
- }
-
- if (okflag) {
- if (!pal->write_eggs()) {
- okflag = false;
- }
- }
-
- if (!_nodb) {
- // Make up a temporary filename to write the state file to, then move the
- // state file into place. We do this in case the user interrupts us (or
- // we core dump) before we're done; that way we won't leave the state file
- // incompletely written.
- std::string dirname = state_filename.get_dirname();
- if (dirname.empty()) {
- dirname = ".";
- }
- Filename temp_filename = Filename::temporary(dirname, "pi");
-
- if (!state_file.open_write(temp_filename) ||
- !state_file.write_object(pal)) {
- nout << "Unable to write palettization information to "
- << FilenameUnifier::make_user_filename(temp_filename)
- << "\n";
- exit(1);
- }
-
- state_file.close();
- state_filename.unlink();
- if (!temp_filename.rename_to(state_filename)) {
- nout << "Unable to rename temporary file "
- << FilenameUnifier::make_user_filename(temp_filename) << " to "
- << FilenameUnifier::make_user_filename(state_filename) << "\n";
- exit(1);
- }
- }
-
- if (!okflag) {
- exit(1);
- }
-}
-
-int
-main(int argc, char *argv[]) {
- EggPalettize prog;
- prog.parse_command_line(argc, argv);
- prog.run();
- return 0;
-}
diff --git a/pandatool/src/egg-palettize/eggPalettize.h b/pandatool/src/egg-palettize/eggPalettize.h
deleted file mode 100644
index d30a9d4f..00000000
--- a/pandatool/src/egg-palettize/eggPalettize.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggPalettize.h
- * @author drose
- * @date 2000-11-28
- */
-
-#ifndef EGGPALETTIZE_H
-#define EGGPALETTIZE_H
-
-#include "pandatoolbase.h"
-
-#include "eggMultiFilter.h"
-
-/**
- * This is the program wrapper for egg-palettize, but it mainly serves to read
- * in all the command-line parameters and then invoke the Palettizer.
- */
-class EggPalettize : public EggMultiFilter {
-public:
- EggPalettize();
-
- virtual bool handle_args(Args &args);
-
- void describe_input_file();
-
- void run();
-
- // The following parameter values specifically relate to textures and
- // palettes. These values are copied to the Palettizer.
- bool _got_txa_filename;
- Filename _txa_filename;
- bool _got_txa_script;
- std::string _txa_script;
- bool _nodb;
- std::string _generated_image_pattern;
- bool _got_generated_image_pattern;
- std::string _map_dirname;
- bool _got_map_dirname;
- Filename _shadow_dirname;
- bool _got_shadow_dirname;
- Filename _rel_dirname;
- bool _got_rel_dirname;
- std::string _default_groupname;
- bool _got_default_groupname;
- std::string _default_groupdir;
- bool _got_default_groupdir;
-
-private:
- // The following values control behavior specific to this session. They're
- // not saved for future sessions.
- bool _report_pi;
- bool _report_statistics;
- bool _all_textures;
- bool _optimal;
- bool _omitall;
- bool _redo_all;
- bool _redo_eggs;
-
- bool _describe_input_file;
- bool _remove_eggs;
- Args _remove_egg_list;
-};
-
-#endif
diff --git a/pandatool/src/egg-palettize/txaFileFilter.I b/pandatool/src/egg-palettize/txaFileFilter.I
deleted file mode 100644
index 44cde648..00000000
--- a/pandatool/src/egg-palettize/txaFileFilter.I
+++ /dev/null
@@ -1,12 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file txaFileFilter.I
- * @author drose
- * @date 2006-07-27
- */
diff --git a/pandatool/src/egg-palettize/txaFileFilter.cxx b/pandatool/src/egg-palettize/txaFileFilter.cxx
deleted file mode 100644
index d45bea3b..00000000
--- a/pandatool/src/egg-palettize/txaFileFilter.cxx
+++ /dev/null
@@ -1,148 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file txaFileFilter.cxx
- * @author drose
- * @date 2006-07-27
- */
-
-#include "txaFileFilter.h"
-#include "palettizer.h"
-#include "txaFile.h"
-#include "textureImage.h"
-#include "sourceTextureImage.h"
-#include "texturePool.h"
-#include "dconfig.h"
-#include "configVariableFilename.h"
-#include "virtualFileSystem.h"
-#include "config_putil.h"
-
-NotifyCategoryDeclNoExport(txafile);
-NotifyCategoryDef(txafile, "");
-
-// A few lines to register this filter type with the TexturePool when the
-// shared library is loaded.
-Configure(config_txaFileFilter);
-ConfigureFn(config_txaFileFilter) {
- TxaFileFilter::init_type();
- TexturePool::register_filter(new TxaFileFilter);
-}
-
-TypeHandle TxaFileFilter::_type_handle;
-TxaFile *TxaFileFilter::_txa_file;
-bool TxaFileFilter::_got_txa_file;
-
-/**
- * This method is called after each texture has been loaded from disk, via the
- * TexturePool, for the first time. By the time this method is called, the
- * Texture has already been fully read from disk. This method should return
- * the Texture pointer that the TexturePool should actually return (usually it
- * is the same as the pointer supplied).
- */
-PT(Texture) TxaFileFilter::
-post_load(Texture *tex) {
- if (!_got_txa_file) {
- read_txa_file();
- }
-
- TextureImage tex_image;
- std::string name = tex->get_filename().get_basename_wo_extension();
- tex_image.set_name(name);
-
- SourceTextureImage *source = tex_image.get_source
- (tex->get_fullpath(), tex->get_alpha_fullpath(), 0);
- PNMImage pnm_image;
- tex->store(pnm_image);
- source->set_header(pnm_image);
- tex_image.set_source_image(pnm_image);
-
- tex_image.pre_txa_file();
-
- bool matched = _txa_file->match_texture(&tex_image);
- if (txafile_cat.is_debug()) {
- if (!matched) {
- txafile_cat.debug()
- << "Not matched: " << name << "\n";
- } else {
- txafile_cat.debug()
- << "Matched: " << name << "\n";
- }
- }
-
- tex_image.post_txa_file();
-
- PNMImage dest(tex_image.get_x_size(),
- tex_image.get_y_size(),
- tex_image.get_num_channels(),
- pnm_image.get_maxval());
- dest.quick_filter_from(pnm_image);
-
- tex->load(dest);
-
- // Create an EggTexture to pass back the requested alpha mode to the egg
- // loader, if the texture is now being loaded from an egg file.
- PT_EggTexture egg_tex = new EggTexture(tex->get_name(), tex->get_fullpath());
- const TextureProperties &props = tex_image.get_properties();
-
- egg_tex->set_alpha_mode(tex_image.get_alpha_mode());
- egg_tex->set_format(props._format);
- egg_tex->set_minfilter(props._minfilter);
- egg_tex->set_magfilter(props._magfilter);
- egg_tex->set_anisotropic_degree(props._anisotropic_degree);
-
- tex->set_aux_data("egg", egg_tex);
-
- return tex;
-}
-
-/**
- * Reads the textures.txa file named by the variable txa-file. Called only
- * once, at startup.
- */
-void TxaFileFilter::
-read_txa_file() {
- VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr();
-
- // We need to create a global Palettizer object to hold some of the global
- // properties that may be specified in a txa file.
- if (pal == nullptr) {
- pal = new Palettizer;
- }
-
- _txa_file = new TxaFile;
- _got_txa_file = true;
-
- ConfigVariableFilename txa_file
- ("txa-file", Filename("textures.txa"),
- PRC_DESC("Specify the name of the txa file to load when the txafile texture filter"
- "is in effect."));
-
- Filename filename = txa_file;
- vfs->resolve_filename(filename, get_model_path());
-
- if (!vfs->exists(filename)) {
- txafile_cat.warning()
- << "Filename " << filename << " not found.\n";
- } else {
- filename.set_text();
- std::istream *ifile = vfs->open_read_file(filename, true);
- if (ifile == nullptr) {
- txafile_cat.warning()
- << "Filename " << filename << " cannot be read.\n";
- } else {
- if (!_txa_file->read(*ifile, filename)) {
- txafile_cat.warning()
- << "Syntax errors in " << filename << "\n";
- } else {
- txafile_cat.info()
- << "Read " << filename << "\n";
- }
- vfs->close_read_file(ifile);
- }
- }
-}
diff --git a/pandatool/src/egg-palettize/txaFileFilter.h b/pandatool/src/egg-palettize/txaFileFilter.h
deleted file mode 100644
index a2f13a71..00000000
--- a/pandatool/src/egg-palettize/txaFileFilter.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file txaFileFilter.h
- * @author drose
- * @date 2006-07-27
- */
-
-#ifndef TXAFILEFILTER_H
-#define TXAFILEFILTER_H
-
-#include "pandatoolbase.h"
-#include "texturePoolFilter.h"
-#include "pt_EggTexture.h"
-
-class TxaFile;
-
-/**
- * This is an abstract base class, a placeholder for any number of different
- * classes that may wish to implement an effect on every texture loaded from
- * disk via the TexturePool.
- *
- * In practice, as of the time of this writing, only the TxaFileFilter (in
- * pandatool) actually implements this. But other kinds of filters are
- * possible.
- *
- * This filter, once registered, will get a callback and a chance to modify
- * each texture as it is loaded from disk the first time. If more than one
- * filter is registered, each will be called in sequence, in the order in
- * which they were registered.
- *
- * The filter does not get called again if the texture is subsequently
- * reloaded from disk. It is suggested that filters for which this might be a
- * problem should call tex->set_keep_ram_image(true).
- */
-class EXPCL_MISC TxaFileFilter : public TexturePoolFilter {
-public:
- virtual PT(Texture) post_load(Texture *tex);
-
-private:
- static void read_txa_file();
-
-private:
- static TxaFile *_txa_file;
- static bool _got_txa_file;
-
-public:
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- TexturePoolFilter::init_type();
- register_type(_type_handle, "TxaFileFilter",
- TexturePoolFilter::get_class_type());
- }
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
-
-private:
- static TypeHandle _type_handle;
-};
-
-#include "txaFileFilter.I"
-
-#endif
diff --git a/pandatool/src/egg-qtess/CMakeLists.txt b/pandatool/src/egg-qtess/CMakeLists.txt
deleted file mode 100644
index 83e6ff1f..00000000
--- a/pandatool/src/egg-qtess/CMakeLists.txt
+++ /dev/null
@@ -1,35 +0,0 @@
-if(NOT BUILD_TOOLS)
- return()
-endif()
-
-if(NOT HAVE_EGG)
- return()
-endif()
-
-set(P3EGG_QTESS_HEADERS
- config_egg_qtess.h
- eggQtess.h
- isoPlacer.h isoPlacer.I
- qtessGlobals.h
- qtessInputEntry.h qtessInputEntry.I
- qtessInputFile.h qtessInputFile.I
- qtessSurface.h qtessSurface.I
- subdivSegment.h subdivSegment.I
-)
-
-set(P3EGG_QTESS_SOURCES
- config_egg_qtess.cxx
- eggQtess.cxx
- isoPlacer.cxx
- qtessGlobals.cxx
- qtessInputEntry.cxx
- qtessInputFile.cxx
- qtessSurface.cxx
- subdivSegment.cxx
-)
-
-composite_sources(egg-qtess P3EGG_QTESS_SOURCES)
-add_executable(egg-qtess ${P3EGG_QTESS_HEADERS} ${P3EGG_QTESS_SOURCES})
-target_link_libraries(egg-qtess p3eggbase)
-
-install(TARGETS egg-qtess EXPORT Tools COMPONENT Tools DESTINATION ${CMAKE_INSTALL_BINDIR})
diff --git a/pandatool/src/egg-qtess/config_egg_qtess.cxx b/pandatool/src/egg-qtess/config_egg_qtess.cxx
deleted file mode 100644
index de3dbf95..00000000
--- a/pandatool/src/egg-qtess/config_egg_qtess.cxx
+++ /dev/null
@@ -1,22 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file config_egg_qtess.cxx
- * @author drose
- * @date 2003-10-13
- */
-
-#include "config_egg_qtess.h"
-
-#include "dconfig.h"
-
-Configure(config_egg_qtess);
-NotifyCategoryDef(qtess, "");
-
-ConfigureFn(config_egg_qtess) {
-}
diff --git a/pandatool/src/egg-qtess/config_egg_qtess.h b/pandatool/src/egg-qtess/config_egg_qtess.h
deleted file mode 100644
index abc9ef39..00000000
--- a/pandatool/src/egg-qtess/config_egg_qtess.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file config_egg_qtess.h
- * @author drose
- * @date 2003-10-13
- */
-
-#ifndef CONFIG_EGG_QTESS_H
-#define CONFIG_EGG_QTESS_H
-
-#include "pandatoolbase.h"
-#include "notifyCategoryProxy.h"
-
-NotifyCategoryDeclNoExport(qtess);
-
-// No variables to declare here.
-
-#endif
diff --git a/pandatool/src/egg-qtess/egg-qtess_composite1.cxx b/pandatool/src/egg-qtess/egg-qtess_composite1.cxx
deleted file mode 100644
index 01ed99bd..00000000
--- a/pandatool/src/egg-qtess/egg-qtess_composite1.cxx
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "config_egg_qtess.cxx"
-#include "eggQtess.cxx"
-#include "isoPlacer.cxx"
-#include "qtessGlobals.cxx"
-#include "qtessInputEntry.cxx"
-#include "qtessInputFile.cxx"
-#include "qtessSurface.cxx"
-#include "subdivSegment.cxx"
diff --git a/pandatool/src/egg-qtess/eggQtess.cxx b/pandatool/src/egg-qtess/eggQtess.cxx
deleted file mode 100644
index 37473557..00000000
--- a/pandatool/src/egg-qtess/eggQtess.cxx
+++ /dev/null
@@ -1,337 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggQtess.cxx
- * @author drose
- * @date 2003-10-13
- */
-
-#include "eggQtess.h"
-#include "qtessGlobals.h"
-#include "dcast.h"
-
-/**
- *
- */
-EggQtess::
-EggQtess() {
- add_normals_options();
-
- set_program_brief("tesselate NURBS surfaces in .egg files");
- set_program_description
- ("egg-qtess reads an egg file, tessellates all of its NURBS surfaces "
- "using a simple uniform tessellation, and outputs a polygonal "
- "egg file.\n\n"
-
- "Characters are supported, soft-skinned and otherwise; joint "
- "ownership is computed correctly for each new polygon vertex. "
- "Primitives other than NURBS surfaces appearing in the egg file "
- "are unaffected.");
-
- add_option
- ("f", "filename", 0,
- "Read the indicated parameter file. Type egg-qtess -H "
- "to print a description of the parameter file format.",
- &EggQtess::dispatch_filename, nullptr, &_qtess_filename);
-
- add_option
- ("up", "subdiv", 0,
- "Specify a uniform subdivision per patch (isoparam). Each NURBS "
- "surface is made up of N x M patches, each of which is divided "
- "into subdiv x subdiv quads. A fractional number is allowed.",
- &EggQtess::dispatch_double, nullptr, &_uniform_per_isoparam);
-
- add_option
- ("us", "subdiv", 0,
- "Specify a uniform subdivision per surface. Each NURBS "
- "surface is subdivided into subdiv x subdiv quads, regardless "
- "of the number of isoparams it has. A fractional number is "
- "meaningless.",
- &EggQtess::dispatch_int, nullptr, &_uniform_per_surface);
-
- add_option
- ("t", "tris", 0,
- "Specify an approximate number of triangles to produce. This "
- "is the total number of triangles for the entire egg file, "
- "including those surfaces that have already been given an "
- "explicit tessellation by a parameter file.",
- &EggQtess::dispatch_int, nullptr, &_total_tris);
-
- add_option
- ("ap", "", 0,
- "Attempt to automatically place tessellation lines where they'll "
- "do the most good on each surface (once the number of polygons "
- "for the surface has already been determined).",
- &EggQtess::dispatch_none, &QtessGlobals::_auto_place);
-
- add_option
- ("ad", "", 0,
- "Attempt to automatically distribute polygons among the surfaces "
- "where they are most needed according to curvature and size, "
- "instead of according to the number of isoparams. This only has "
- "meaning when used in conjunction with -t.",
- &EggQtess::dispatch_none, &QtessGlobals::_auto_distribute);
-
- add_option
- ("ar", "ratio", 0,
- "Specify the ratio of dominance of size to curvature for -ap and "
- "-ad. A value of 0 forces placement by curvature only; a very "
- "large value (like 1000) forces placement by size only. The "
- "default is 5.0.",
- &EggQtess::dispatch_double, nullptr, &QtessGlobals::_curvature_ratio);
-
- add_option
- ("e", "", 0,
- "Respect subdivision parameters given in the egg file. If this "
- "is specified, the egg file may define the effective number of "
- "patches of each NURBS entry. This can be used alone or in "
- "conjunction with -u or -t to fine-tune the uniform tessellation "
- "on a per-surface basis. (This is ignored if -ad is in effect.)",
- &EggQtess::dispatch_none, &QtessGlobals::_respect_egg);
-
- add_option
- ("q", "", 0,
- "Instead of writing an egg file, generate a parameter file "
- "for output.",
- &EggQtess::dispatch_none, &_qtess_output);
-
- add_option
- ("H", "", 0,
- "Describe the format of the parameter file specified with -f.",
- &EggQtess::dispatch_none, &_describe_qtess);
-
- _uniform_per_isoparam = 0.0;
- _uniform_per_surface = 0;
- _total_tris = 0;
-}
-
-/**
- * Does something with the additional arguments on the command line (after all
- * the -options have been parsed). Returns true if the arguments are good,
- * false otherwise.
- */
-bool EggQtess::
-handle_args(ProgramBase::Args &args) {
- if (_describe_qtess) {
- describe_qtess_format();
- exit(0);
- }
-
- return EggFilter::handle_args(args);
-}
-
-/**
- *
- */
-void EggQtess::
-run() {
- bool read_qtess = false;
- if (!_qtess_filename.empty()) {
- if (!_qtess_file.read(_qtess_filename)) {
- exit(1);
- }
- read_qtess = true;
- }
-
- find_surfaces(_data);
-
- QtessInputEntry &default_entry = _qtess_file.get_default_entry();
- if (!read_qtess || default_entry.get_num_surfaces() == 0) {
- nout << _surfaces.size() << " NURBS surfaces found.\n";
-
- } else {
- nout << _surfaces.size() << " NURBS surfaces found; "
- << default_entry.get_num_surfaces()
- << " unaccounted for by input file.\n";
- }
-
- int num_tris = _qtess_file.count_tris();
-
- if (_total_tris != 0) {
- // Whatever number of triangles we have unaccounted for, assign to the
- // default bucket.
- int extra_tris = std::max(0, _total_tris - num_tris);
- if (read_qtess && default_entry.get_num_surfaces() != 0) {
- std::cerr << extra_tris << " triangles unaccounted for.\n";
- }
-
- default_entry.set_num_tris(extra_tris);
-
- } else if (_uniform_per_isoparam!=0.0) {
- default_entry.set_per_isoparam(_uniform_per_isoparam);
-
- } else if (_uniform_per_surface!=0.0) {
- default_entry.set_uv(_uniform_per_surface, _uniform_per_surface);
-
- } else {
- default_entry.set_per_isoparam(1.0);
- }
-
- default_entry.count_tris();
-
- if (_qtess_output) {
- // Sort the names into alphabetical order for aesthetics.
- // sort(_surfaces.begin(), _surfaces.end(), compare_surfaces());
-
- int tris = 0;
-
- std::ostream &out = get_output();
- Surfaces::const_iterator si;
- for (si = _surfaces.begin(); si != _surfaces.end(); ++si) {
- tris += (*si)->write_qtess_parameter(out);
- }
-
- std::cerr << tris << " tris generated.\n";
-
- } else {
-
- int tris = 0;
-
- Surfaces::const_iterator si;
- for (si = _surfaces.begin(); si != _surfaces.end(); ++si) {
- tris += (*si)->tesselate();
- }
-
- std::cerr << tris << " tris generated.\n";
-
- // Clear out the surfaces list before removing the vertices, since each
- // surface is holding reference counts to the previously-used vertices.
- _surfaces.clear();
-
- _data->remove_unused_vertices(true);
- write_egg_file();
- }
-}
-
-/**
- *
- */
-void EggQtess::
-describe_qtess_format() {
- nout <<
- "An egg-qtess parameter file consists of lines of the form:\n\n"
-
- "name [name...] : parameters\n\n"
-
- "Where name is a string (possibly including wildcard characters "
- "such as * and ?) that matches one or more surface "
- "names, and parameters is a tesselation specification, described below. "
- "The colon must be followed by at least one space to differentiate it "
- "from a colon character in the name(s). Multiple names "
- "may be combined on one line.\n\n\n"
-
-
- "The parameters may be any of the following. Lowercase letters are "
- "literal. NUM is any number.\n\n";
-
- show_text(" omit", 10,
- "Remove the surface from the output.\n\n");
-
- show_text(" NUM", 10,
- "Try to achieve the indicated number of triangles over all the "
- "surfaces matched by this line.\n\n");
-
- show_text(" NUM NUM [[!]u# [!]u# ...] [[!]v# [!]v# ...]", 10,
- "Tesselate to NUM x NUM quads. If u# or v# appear, they indicate "
- "additional isoparams to insert (or remove if preceded by an "
- "exclamation point). The range is [0, 1].\n\n");
-
- show_text(" iNUM", 10,
- "Subdivision amount per isoparam. Equivalent to the command-line "
- "option -u NUM.\n\n");
-
- show_text(" NUM%", 10,
- "This is a special parameter. This does not request any specific "
- "tesselation for the named surfaces, but instead gives a relative "
- "importance for them when they appear with other surfaces in a "
- "later entry (or are tesselated via -t on the command line). In "
- "general, a surface with a weight of 25% will be given a quarter "
- "of the share of the polygons it otherwise would have received; "
- "a weight of 150% will give the surface 50% more than its fair "
- "share.\n\n");
-
- show_text(" matchvu", 10,
- "This is a special parameter that indicates that two or more "
- "surfaces share a common edge, and must be tesselated the "
- "same way "
- "along that edge. Specifically, matchvu means that the V "
- "tesselation of the first named surface will be applied to the U "
- "tesselation of the second (and later) named surface(s). Similar "
- "definitions exist for matchuv, matchuu, and matchvv.\n\n");
-
- show_text(" minu NUM", 10,
- "This is another special parameter that specifies a "
- "minimum tesselation for all these surfaces in "
- "the U direction. This is "
- "the number of quads across the dimension the surface will be "
- "broken into. The default is 1 for an open surface, and 3 for "
- "a closed surface.\n\n");
-
- show_text(" minv NUM", 10,
- "Similar to minv, in the V direction.\n\n");
-
- nout <<
- "In addition, the following optional parameters may appear. If they appear, "
- "they override similar parameters given on the command line; if they do not "
- "appear, the defaults are taken from the command line:\n\n";
-
- show_text(" ap", 10,
- "Automatically place tesselation lines on each surface where they "
- "seem to be needed most.\n\n");
-
- show_text(" !ap", 10,
- "Do not move lines automatically; use a strict uniform "
- "tesselation.\n\n");
-
- show_text(" ad", 10,
- "Automatically distribute polygons to the surfaces that seem to "
- "need them the most.\n\n");
-
- show_text(" !ad", 10,
- "Do not automatically distribute polygons; distribute "
- "them according to the number of isoparams of each surface.\n\n");
-
- show_text(" arNUM", 10,
- "Specify the ratio of dominance of size to curvature.\n\n");
-
- nout <<
- "The hash symbol '#' begins a comment if it is preceded by whitespace or at the "
- "beginning of a line. The backslash character at the end of a line can be used "
- "to indicate a continuation.\n\n";
-}
-
-/**
- * Recursively walks the egg graph, collecting all the NURBS surfaces found.
- */
-void EggQtess::
-find_surfaces(EggNode *egg_node) {
- if (egg_node->is_of_type(EggNurbsSurface::get_class_type())) {
- PT(QtessSurface) surface =
- new QtessSurface(DCAST(EggNurbsSurface, egg_node));
- if (surface->is_valid()) {
- _surfaces.push_back(surface);
- QtessInputEntry::Type match_type = _qtess_file.match(surface);
- nassertv(match_type != QtessInputEntry::T_undefined);
- }
- }
-
- if (egg_node->is_of_type(EggGroupNode::get_class_type())) {
- EggGroupNode *egg_group = DCAST(EggGroupNode, egg_node);
- EggGroupNode::const_iterator ci;
- for (ci = egg_group->begin(); ci != egg_group->end(); ++ci) {
- find_surfaces(*ci);
- }
- }
-}
-
-int main(int argc, char *argv[]) {
- EggQtess prog;
- prog.parse_command_line(argc, argv);
- prog.run();
- return 0;
-}
diff --git a/pandatool/src/egg-qtess/eggQtess.h b/pandatool/src/egg-qtess/eggQtess.h
deleted file mode 100644
index c18db52e..00000000
--- a/pandatool/src/egg-qtess/eggQtess.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggQtess.h
- * @author drose
- * @date 2003-10-13
- */
-
-#ifndef EGGQTESS_H
-#define EGGQTESS_H
-
-#include "pandatoolbase.h"
-#include "eggFilter.h"
-#include "qtessInputFile.h"
-#include "qtessSurface.h"
-#include "pointerTo.h"
-#include "pvector.h"
-
-/**
- * A program to tesselate NURBS surfaces appearing within an egg file into
- * polygons, using variations on a quick uniform tesselation.
- */
-class EggQtess : public EggFilter {
-public:
- EggQtess();
-
- void run();
-
-protected:
- virtual bool handle_args(ProgramBase::Args &args);
-
-private:
- void describe_qtess_format();
- void find_surfaces(EggNode *egg_node);
-
- Filename _qtess_filename;
- double _uniform_per_isoparam;
- int _uniform_per_surface;
- int _total_tris;
- bool _qtess_output;
- bool _describe_qtess;
-
- QtessInputFile _qtess_file;
-
- typedef pvector< PT(QtessSurface) > Surfaces;
- Surfaces _surfaces;
-};
-
-#endif
diff --git a/pandatool/src/egg-qtess/isoPlacer.I b/pandatool/src/egg-qtess/isoPlacer.I
deleted file mode 100644
index f773b8fb..00000000
--- a/pandatool/src/egg-qtess/isoPlacer.I
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file isoPlacer.I
- * @author drose
- * @date 2003-10-13
- */
-
-/**
- *
- */
-INLINE IsoPlacer::
-IsoPlacer() {
-}
-
-
-/**
- *
- */
-INLINE double IsoPlacer::
-get_total_score() const {
- return _cint[_maxi];
-}
diff --git a/pandatool/src/egg-qtess/isoPlacer.cxx b/pandatool/src/egg-qtess/isoPlacer.cxx
deleted file mode 100644
index 0f7a6a3f..00000000
--- a/pandatool/src/egg-qtess/isoPlacer.cxx
+++ /dev/null
@@ -1,228 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file isoPlacer.cxx
- * @author drose
- * @date 2003-10-13
- */
-
-#include "isoPlacer.h"
-#include "qtessSurface.h"
-#include "subdivSegment.h"
-#include "nurbsSurfaceResult.h"
-#include "pvector.h"
-
-
-/**
- *
- */
-void IsoPlacer::
-get_scores(int subdiv, int across, double ratio,
- NurbsSurfaceResult *surf, bool s) {
- _maxi = subdiv - 1;
-
- _cscore.clear();
- _sscore.clear();
-
- _cscore.reserve(_maxi);
- _sscore.reserve(_maxi);
-
- // First, tally up the curvature and stretch scores across the surface.
- int i = 0;
- for (i = 0; i < _maxi; i++) {
- _cscore.push_back(0.0);
- _sscore.push_back(0.0);
- }
-
- int a;
- for (a = 0; a <= across; a++) {
- double v = (double)a / (double)across;
-
- LVecBase3 p1, p2, p3, pnext;
- LVecBase3 v1, v2;
- if (s) {
- surf->eval_point(0.0, v, p3);
- } else {
- surf->eval_point(v, 0.0, p3);
- }
- int num_points = 1;
-
- for (i = -1; i < _maxi; i++) {
- double u = (double)(i+1) / (double)(_maxi+1);
- if (s) {
- surf->eval_point(u, v, pnext);
- } else {
- surf->eval_point(v, u, pnext);
- }
-
- // We'll ignore consecutive equal points. They don't contribute to
- // curvature or size.
- if (!pnext.almost_equal(p3)) {
- num_points++;
- p1 = p2;
- p2 = p3;
- p3 = pnext;
-
- v1 = v2;
- v2 = p3 - p2;
- double vlength = length(v2);
- v2 /= vlength;
-
- if (i >= 0) {
- _sscore[i] += vlength;
- }
-
- if (num_points >= 3) {
- // We only have a meaningful v1, v2 when we've read at least three
- // non-equal points.
- double d = v1.dot(v2);
-
- _cscore[i] += acos(std::max(std::min(d, 1.0), -1.0));
- }
- }
- }
- }
-
- // Now integrate.
- _cint.clear();
- _cint.reserve(_maxi + 1);
-
- double net = 0.0;
- double ad = (double)(across+1);
- _cint.push_back(0.0);
- for (i = 0; i < _maxi; i++) {
- net += _cscore[i]/ad + ratio * _sscore[i]/ad;
- _cint.push_back(net);
- }
-}
-
-/**
- *
- */
-void IsoPlacer::
-place(int count, pvector &iso_points) {
- // Count up the average curvature.
- /*
- double avg_curve = 0.0;
- for (i = 0; i < _maxi; i++) {
- avg_curve += _cscore[i];
- }
- avg_curve /= (double)_maxi;
- */
-
- // Find all the local maxima in the curvature table. These are bend points.
- typedef pvector BendPoints;
- BendPoints bpoints;
- BendPoints::iterator bi, bnext;
-
- typedef pvector Segments;
- Segments segments;
- Segments::iterator si;
-
- /*
- // Having problems with bend points right now. Maybe this is just a bad
- // idea. It seems to work pretty well without them, anyway.
- for (i = 1; i < _maxi-1; i++) {
- // A point must be measurably higher than both its neighbors, as well as
- // at least 50% more curvy than the average curvature, to qualify as a
- // bend point.
- if (_cscore[i] > _cscore[i-1]+0.001 &&
- _cscore[i] > _cscore[i+1]+0.001 &&
- _cscore[i] > 1.5 * avg_curve) {
- bpoints.push_back(i);
- }
- }
- */
-
- // Now make sure there aren't any two bend points closer together than
- // maxicount. If there are, remove the smaller of the two.
- bi = bpoints.begin();
- int min_separation = _maxi/count;
- while (bi != bpoints.end()) {
- bnext = bi;
- ++bnext;
-
- if (bnext != bpoints.end() && (*bnext) - (*bi) < min_separation) {
- // Too close. Remove one.
- if (_cscore[*bnext] > _cscore[*bi]) {
- *bi = *bnext;
- }
- bpoints.erase(bnext);
- } else {
- // Not too close; keep going;
- bi = bnext;
- }
- }
-
- // Now, if we have fewer total subdivisions than bend points, then remove
- // the smallest bend points.
- while (count - 1 < (int)bpoints.size()) {
- bi = bpoints.begin();
- BendPoints::iterator mi = bi;
- for (++bi; bi != bpoints.end(); ++bi) {
- if (_cscore[*bi] < _cscore[*mi]) {
- mi = bi;
- }
- }
- bpoints.erase(mi);
- }
-
- // Now all the remaining bend points are valid.
- bi = bpoints.begin();
- int last = 0;
- for (bi = bpoints.begin(); bi != bpoints.end(); ++bi) {
- segments.push_back(SubdivSegment(&_cint[0], last, *bi));
- last = *bi;
- }
- segments.push_back(SubdivSegment(&_cint[0], last, _maxi));
-
- int nr = count - segments.size();
-
- // Now we have subdivided the curve into a number of smaller curves at the
- // bend points. We still have nr remaining cuts to make; distribute these
- // cuts among the curves evenly according to score.
-
- // Divvy out the extra cuts. First, each segment gets an amount
- // proportional to its score.
- double net_score = _cint[_maxi];
- nassertv(net_score > 0.0);
- int ns = 0;
- for (si = segments.begin(); si != segments.end(); ++si) {
- (*si)._num_cuts = (int)floor(nr * (*si).get_score() / net_score);
- nassertv((*si)._num_cuts <= nr); // This fails if net_score is nan.
- ns += (*si)._num_cuts;
- }
-
- // Then, assign the remaining cuts to the neediest segments.
- nr -= ns;
- while (nr > 0) {
- si = min_element(segments.begin(), segments.end());
- (*si)._num_cuts++;
- nr--;
- }
-
- // Now cut up the segments as indicated.
- for (si = segments.begin(); si != segments.end(); ++si) {
- (*si).cut();
- }
-
- // Finally, return the result.
- iso_points.erase(iso_points.begin(), iso_points.end());
-
- iso_points.push_back(0.0);
- for (si = segments.begin(); si != segments.end(); ++si) {
- pvector::iterator ci;
- for (ci = (*si)._cuts.begin(); ci != (*si)._cuts.end(); ++ci) {
- iso_points.push_back((*ci+1) / (double)(_maxi+1));
- }
- iso_points.push_back(((*si)._t+1) / (double)(_maxi+1));
- }
-
- // Oh, wait. The last segment is actually drawn all the way to 1.
- iso_points.back() = 1.0;
-}
diff --git a/pandatool/src/egg-qtess/isoPlacer.h b/pandatool/src/egg-qtess/isoPlacer.h
deleted file mode 100644
index b4696340..00000000
--- a/pandatool/src/egg-qtess/isoPlacer.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file isoPlacer.h
- * @author drose
- * @date 2003-10-13
- */
-
-#ifndef ISOPLACER_H
-#define ISOPLACER_H
-
-#include "pandatoolbase.h"
-#include "pvector.h"
-#include "vector_double.h"
-
-class NurbsSurfaceResult;
-
-/**
- * Contains the logic used to place isoparams where they'll do the most good
- * on a surface.
- */
-class IsoPlacer {
-public:
- INLINE IsoPlacer();
-
- void get_scores(int subdiv, int across, double ratio,
- NurbsSurfaceResult *surf, bool s);
- void place(int count, pvector &iso_points);
-
- INLINE double get_total_score() const;
-
- vector_double _cscore, _sscore, _cint;
- int _maxi;
-};
-
-#include "isoPlacer.I"
-
-#endif
diff --git a/pandatool/src/egg-qtess/qtessGlobals.cxx b/pandatool/src/egg-qtess/qtessGlobals.cxx
deleted file mode 100644
index 85fb91fb..00000000
--- a/pandatool/src/egg-qtess/qtessGlobals.cxx
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file qtessGlobals.cxx
- * @author drose
- * @date 2003-10-13
- */
-
-#include "qtessGlobals.h"
-
-bool QtessGlobals::_auto_place = false;
-bool QtessGlobals::_auto_distribute = false;
-double QtessGlobals::_curvature_ratio = 5.0;
-bool QtessGlobals::_respect_egg = false;
diff --git a/pandatool/src/egg-qtess/qtessGlobals.h b/pandatool/src/egg-qtess/qtessGlobals.h
deleted file mode 100644
index d7412934..00000000
--- a/pandatool/src/egg-qtess/qtessGlobals.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file qtessGlobals.h
- * @author drose
- * @date 2003-10-13
- */
-
-#ifndef QTESS_GLOBALS_H
-#define QTESS_GLOBALS_H
-
-#include "pandatoolbase.h"
-
-/**
- * Simply used as a namespace to scope some global variables for this program,
- * set from the command line.
- */
-class QtessGlobals {
-public:
- static bool _auto_place;
- static bool _auto_distribute;
- static double _curvature_ratio;
- static bool _respect_egg;
-};
-
-#endif
diff --git a/pandatool/src/egg-qtess/qtessInputEntry.I b/pandatool/src/egg-qtess/qtessInputEntry.I
deleted file mode 100644
index d8ab6de6..00000000
--- a/pandatool/src/egg-qtess/qtessInputEntry.I
+++ /dev/null
@@ -1,156 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file qtessInputEntry.I
- * @author drose
- * @date 2003-10-13
- */
-
-/**
- *
- */
-INLINE QtessInputEntry::
-QtessInputEntry(const QtessInputEntry ©) {
- (*this) = copy;
-}
-
-/**
- *
- */
-INLINE void QtessInputEntry::
-add_node_name(const std::string &name) {
- _node_names.push_back(GlobPattern(name));
-}
-
-/**
- *
- */
-INLINE void QtessInputEntry::
-set_importance(double i) {
- _importance = i;
- _type = T_importance;
-}
-
-/**
- *
- */
-INLINE void QtessInputEntry::
-set_match_uu() {
- _type = T_match_uu;
- _constrain_u = nullptr;
-}
-
-/**
- *
- */
-INLINE void QtessInputEntry::
-set_match_vv() {
- _type = T_match_vv;
- _constrain_v = nullptr;
-}
-
-/**
- *
- */
-INLINE void QtessInputEntry::
-set_match_uv() {
- _type = T_match_uv;
- _constrain_u = nullptr;
-}
-
-/**
- *
- */
-INLINE void QtessInputEntry::
-set_match_vu() {
- _type = T_match_vu;
- _constrain_v = nullptr;
-}
-
-/**
- *
- */
-INLINE void QtessInputEntry::
-set_min_u(int min_u) {
- _type = T_min_u;
- _num_u = min_u;
-}
-
-/**
- *
- */
-INLINE void QtessInputEntry::
-set_min_v(int min_v) {
- _type = T_min_v;
- _num_v = min_v;
-}
-
-/**
- *
- */
-INLINE void QtessInputEntry::
-set_undefined() {
- _type = T_undefined;
-}
-
-/**
- *
- */
-INLINE void QtessInputEntry::
-set_omit() {
- _type = T_omit;
-}
-
-/**
- *
- */
-INLINE void QtessInputEntry::
-set_num_tris(int nt) {
- _num_tris = nt;
- _type = T_num_tris;
-}
-
-/**
- *
- */
-INLINE void QtessInputEntry::
-set_uv(int u, int v) {
- set_uv(u, v, nullptr, 0);
-}
-
-/**
- *
- */
-INLINE void QtessInputEntry::
-set_per_isoparam(double pi) {
- _per_isoparam = pi;
- _type = T_per_isoparam;
-}
-
-/**
- *
- */
-INLINE void QtessInputEntry::
-set_per_score(double pi) {
- _per_isoparam = pi;
- _type = T_per_score;
-}
-
-/**
- *
- */
-INLINE int QtessInputEntry::
-get_num_surfaces() const {
- return _surfaces.size();
-}
-
-
-INLINE std::ostream &operator << (std::ostream &out, const QtessInputEntry &entry) {
- entry.output(out);
- return out;
-}
diff --git a/pandatool/src/egg-qtess/qtessInputEntry.cxx b/pandatool/src/egg-qtess/qtessInputEntry.cxx
deleted file mode 100644
index 66df4c88..00000000
--- a/pandatool/src/egg-qtess/qtessInputEntry.cxx
+++ /dev/null
@@ -1,465 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file qtessInputEntry.cxx
- * @author drose
- * @date 2003-10-13
- */
-
-#include "qtessInputEntry.h"
-#include "qtessSurface.h"
-#include "qtessGlobals.h"
-#include "config_egg_qtess.h"
-#include "indent.h"
-#include "string_utils.h"
-
-#include
-#include
-
-using std::string;
-
-/**
- *
- */
-QtessInputEntry::
-QtessInputEntry(const string &name) {
- _type = T_undefined;
- _num_patches = 0.0;
- _auto_place = QtessGlobals::_auto_place;
- _auto_distribute = QtessGlobals::_auto_distribute;
- _curvature_ratio = QtessGlobals::_curvature_ratio;
- if (!name.empty()) {
- add_node_name(name);
- }
-}
-
-/**
- *
- */
-void QtessInputEntry::
-operator = (const QtessInputEntry ©) {
- _node_names = copy._node_names;
- _type = copy._type;
- _num_tris = copy._num_tris;
- _num_u = copy._num_u;
- _num_v = copy._num_v;
- _per_isoparam = copy._per_isoparam;
- _iso_u = copy._iso_u;
- _iso_v = copy._iso_v;
- _surfaces = copy._surfaces;
- _num_patches = copy._num_patches;
- _auto_place = copy._auto_place;
- _auto_distribute = copy._auto_distribute;
- _curvature_ratio = copy._curvature_ratio;
- _importance = copy._importance;
- _constrain_u = copy._constrain_u;
- _constrain_v = copy._constrain_v;
-}
-
-/**
- * An STL function object to determine if two doubles are very nearly equal.
- * Used in set_uv(), below.
- */
-class DoublesAlmostEqual {
-public:
- int operator ()(double a, double b) const {
- return fabs(a - b) < 0.00001;
- }
-};
-
-/**
- * An STL function object to determine if a double is vert nearly equal the
- * supplied value . Used in set_uv(), below.
- */
-class DoubleAlmostMatches {
-public:
- DoubleAlmostMatches(double v) : _v(v) {}
- int operator ()(double a) const {
- return fabs(a - _v) < 0.00001;
- }
- double _v;
-};
-
-
-/**
- * Sets specific tesselation. The tesselation will be u by v quads, with the
- * addition of any isoparams described in the list of params.
- */
-void QtessInputEntry::
-set_uv(int u, int v, const string params[], int num_params) {
- _num_u = u;
- _num_v = v;
-
- // First, fill up the arrays with the defaults.
- int i;
- for (i = 0; i <= _num_u; i++) {
- _iso_u.push_back(i);
- }
- for (i = 0; i <= _num_v; i++) {
- _iso_v.push_back(i);
- }
-
- // Then get out all the additional entries.
- for (i = 0; i < num_params; i++) {
- const string ¶m = params[i];
-
- if (param[0] == '!' && param.size() > 2) {
- double value;
- if (!string_to_double(param.substr(2), value)) {
- qtess_cat.warning()
- << "Ignoring invalid parameter: " << param << "\n";
- } else {
- switch (tolower(param[1])) {
- case 'u':
- _auto_place = false;
- _iso_u.erase(remove_if(_iso_u.begin(), _iso_u.end(),
- DoubleAlmostMatches(value)),
- _iso_u.end());
- break;
-
- case 'v':
- _auto_place = false;
- _iso_v.erase(remove_if(_iso_v.begin(), _iso_v.end(),
- DoubleAlmostMatches(value)),
- _iso_v.end());
- break;
-
- default:
- qtess_cat.warning()
- << "Ignoring invalid parameter: " << params[i] << "\n";
- }
- }
- } else {
- double value;
- if (!string_to_double(param.substr(1), value)) {
- qtess_cat.warning()
- << "Ignoring invalid parameter: " << param << "\n";
- } else {
- switch (tolower(param[0])) {
- case 'u':
- _auto_place = false;
- _iso_u.push_back(value);
- break;
-
- case 'v':
- _auto_place = false;
- _iso_v.push_back(value);
- break;
-
- default:
- qtess_cat.warning()
- << "Ignoring invalid parameter: " << params[i] << "\n";
- }
- }
- }
- }
-
- // Now sort them into ascending order and remove duplicates.
- sort(_iso_u.begin(), _iso_u.end());
- sort(_iso_v.begin(), _iso_v.end());
- _iso_u.erase(unique(_iso_u.begin(), _iso_u.end(), DoublesAlmostEqual()), _iso_u.end());
- _iso_v.erase(unique(_iso_v.begin(), _iso_v.end(), DoublesAlmostEqual()), _iso_v.end());
-
- _type = T_uv;
-}
-
-
-/**
- * May be called a number of times before set_uv() to add specific additional
- * isoparams to the tesselation.
- */
-void QtessInputEntry::
-add_extra_u_isoparam(double u) {
- _iso_u.push_back(u);
-}
-
-/**
- * May be called a number of times before set_uv() to add specific additional
- * isoparams to the tesselation.
- */
-void QtessInputEntry::
-add_extra_v_isoparam(double v) {
- _iso_v.push_back(v);
-}
-
-/**
- * Tests the surface to see if it matches any of the regular expressions that
- * define this node entry. If so, adds it to the set of matched surfaces and
- * returns the type of the matching entry. If no match is found, returns
- * T_undefined.
- */
-QtessInputEntry::Type QtessInputEntry::
-match(QtessSurface *surface) {
- const string &name = surface->get_name();
-
- NodeNames::const_iterator nni;
- for (nni = _node_names.begin();
- nni != _node_names.end();
- ++nni) {
- const GlobPattern &pattern = (*nni);
- if (pattern.matches(name)) {
- // We have a winner!
- switch (_type) {
- case T_importance:
- // A type of "Importance" is a special case. This entry doesn't
- // specify any kind of tesselation on the surface, and in fact doesn't
- // preclude the surface from matching anything later. It just
- // specifies the relative importance of the surface to all the other
- // surfaces.
- if (qtess_cat.is_debug()) {
- qtess_cat.debug()
- << "Assigning importance of " << _importance*100.0
- << "% to " << name << "\n";
- }
- surface->set_importance(_importance);
- return T_undefined;
-
- case T_match_uu:
- case T_match_uv:
- // Similarly for type "matchUU". This indicates that all the surfaces
- // that match this one must all share the U-tesselation with whichever
- // surface first matched against the first node name.
- if (nni == _node_names.begin() && _constrain_u==nullptr) {
- // This is the lucky surface that dominates!
- _constrain_u = surface;
- } else {
- if (_type == T_match_uu) {
- surface->set_match_u(&_constrain_u, true);
- } else {
- surface->set_match_v(&_constrain_u, false);
- }
- }
- return T_undefined;
-
- case T_match_vv:
- case T_match_vu:
- // Ditto for "matchVV".
- if (nni == _node_names.begin() && _constrain_v==nullptr) {
- // This is the lucky surface that dominates!
- _constrain_v = surface;
- } else {
- if (_type == T_match_vv) {
- surface->set_match_v(&_constrain_v, true);
- } else {
- surface->set_match_u(&_constrain_v, false);
- }
- }
- return T_undefined;
-
- case T_min_u:
- // And for min U and V.
- if (qtess_cat.is_debug()) {
- qtess_cat.debug()
- << "Assigning minimum of " << _num_u << " in U to "
- << name << "\n";
- }
- surface->set_min_u(_num_u);
- return T_undefined;
-
- case T_min_v:
- if (qtess_cat.is_debug()) {
- qtess_cat.debug()
- << "Assigning minimum of " << _num_v << " in V to "
- << name << "\n";
- }
- surface->set_min_v(_num_v);
- return T_undefined;
-
- default:
- _surfaces.push_back(surface);
- if (_auto_distribute) {
- _num_patches += surface->get_score(_curvature_ratio);
- } else {
- _num_patches += surface->count_patches();
- }
- return _type;
- }
- }
- }
-
- return T_undefined;
-}
-
-/**
- * Determines the tesselation u,v amounts of each attached surface, and stores
- * this information in the surface pointer. Returns the total number of tris
- * that will be produced.
- */
-int QtessInputEntry::
-count_tris(double tri_factor, int attempts) {
- int total_tris = 0;
- bool aim_for_tris = false;
-
- if (_type == T_num_tris && _num_patches > 0.0) {
- // If we wanted to aim for a particular number of triangles for the group,
- // choose a per-isoparam setting that will approximately achieve this.
- if (_auto_distribute) {
- set_per_score(sqrt(0.5 * (double)_num_tris / _num_patches / tri_factor));
- } else {
- set_per_isoparam(sqrt(0.5 * (double)_num_tris / _num_patches / tri_factor));
- }
- aim_for_tris = true;
- }
-
- Surfaces::iterator si;
- for (si = _surfaces.begin(); si != _surfaces.end(); ++si) {
- QtessSurface *surface = (*si);
-
- switch (_type) {
- case T_undefined:
- case T_omit:
- surface->omit();
- break;
-
- case T_uv:
- if (!_iso_u.empty() && !_iso_v.empty() && !_auto_place) {
- surface->tesselate_specific(_iso_u, _iso_v);
- } else {
- surface->tesselate_uv(_num_u, _num_v, _auto_place, _curvature_ratio);
- }
- break;
-
- case T_per_isoparam:
- surface->tesselate_per_isoparam(_per_isoparam, _auto_place, _curvature_ratio);
- break;
-
- case T_per_score:
- surface->tesselate_per_score(_per_isoparam, _auto_place, _curvature_ratio);
- break;
-
- default:
- break;
- }
-
- total_tris += surface->count_tris();
- }
-
- if (aim_for_tris && attempts < 10 &&
- (double)total_tris / (double)_num_tris > 1.1) {
- // We'd like to get within 10% of the requested number of triangles, if
- // possible. Keep trying until we do, or until we just need to give up.
- set_num_tris(_num_tris);
- return count_tris(tri_factor * total_tris / _num_tris, attempts + 1);
- }
-
- return total_tris;
-}
-
-
-/**
- * This function is used to identify the extra isoparams in the list added by
- * user control.
- */
-void QtessInputEntry::
-output_extra(std::ostream &out, const pvector &iso, char axis) {
- pvector::const_iterator di;
- int expect = 0;
- for (di = iso.begin(); di != iso.end(); ++di) {
- while ((*di) > (double)expect) {
- // Didn't find one we were expecting. Omit it.
- out << " !" << axis << expect;
- }
- if ((*di)==(double)expect) {
- // Here's one we were expecting; ignore it.
- expect++;
- } else {
- // Here's a new one. Write it.
- out << " " << axis << *di;
- }
- }
-}
-
-/**
- *
- */
-void QtessInputEntry::
-output(std::ostream &out) const {
- NodeNames::const_iterator nni;
- for (nni = _node_names.begin();
- nni != _node_names.end();
- ++nni) {
- out << (*nni) << " ";
- }
- out << ": ";
-
- bool show_auto = false;
-
- switch (_type) {
- case T_undefined:
- break;
-
- case T_omit:
- out << "omit";
- break;
-
- case T_num_tris:
- out << _num_tris;
- show_auto = true;
- break;
-
- case T_uv:
- out << _num_u << " " << _num_v;
- output_extra(out, _iso_u, 'u');
- output_extra(out, _iso_v, 'v');
- show_auto = true;
- break;
-
- case T_per_isoparam:
- case T_per_score:
- out << "i" << _per_isoparam;
- show_auto = true;
- break;
-
- case T_importance:
- out << _importance * 100.0 << "%";
- break;
-
- case T_match_uu:
- out << "matchuu";
- break;
-
- case T_match_vv:
- out << "matchvv";
- break;
-
- case T_match_uv:
- out << "matchuv";
- break;
-
- case T_match_vu:
- out << "matchvu";
- break;
-
- case T_min_u:
- out << "minu " << _num_u;
- break;
-
- case T_min_v:
- out << "minv " << _num_v;
- break;
-
- default:
- out << "Invalid!";
- }
-
- if (show_auto) {
- out << " " << (_auto_place?"":"!") << "ap"
- << " " << (_auto_distribute?"":"!") << "ad";
- if (_auto_place || _auto_distribute) {
- out << " ar" << _curvature_ratio;
- }
- }
-}
-
-/**
- *
- */
-void QtessInputEntry::
-write(std::ostream &out, int indent_level) const {
- indent(out, indent_level) << (*this) << "\n";
-}
diff --git a/pandatool/src/egg-qtess/qtessInputEntry.h b/pandatool/src/egg-qtess/qtessInputEntry.h
deleted file mode 100644
index bffcca0d..00000000
--- a/pandatool/src/egg-qtess/qtessInputEntry.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file qtessInputEntry.h
- * @author drose
- * @date 2003-10-13
- */
-
-#ifndef QTESSINPUTENTRY_H
-#define QTESSINPUTENTRY_H
-
-#include "pandatoolbase.h"
-#include "globPattern.h"
-#include "pvector.h"
-
-class QtessSurface;
-
-/**
- * Stores one entry in the qtess input file. This consists of a list of name
- * patterns and a set of tesselation parameters.
- */
-class QtessInputEntry {
-public:
- enum Type {
- T_undefined, T_omit, T_num_tris, T_uv, T_per_isoparam, T_per_score,
- T_importance, T_match_uu, T_match_vv, T_match_uv, T_match_vu,
- T_min_u, T_min_v
- };
-
- QtessInputEntry(const std::string &name = std::string());
- INLINE QtessInputEntry(const QtessInputEntry ©);
- void operator = (const QtessInputEntry ©);
-
- INLINE void add_node_name(const std::string &name);
- INLINE void set_importance(double i);
- INLINE void set_match_uu();
- INLINE void set_match_vv();
- INLINE void set_match_uv();
- INLINE void set_match_vu();
- INLINE void set_min_u(int min_u);
- INLINE void set_min_v(int min_v);
- INLINE void set_undefined();
- INLINE void set_omit();
- INLINE void set_num_tris(int nt);
- INLINE void set_uv(int u, int v);
- void set_uv(int u, int v, const std::string params[], int num_params);
- INLINE void set_per_isoparam(double pi);
- INLINE void set_per_score(double pi);
- void add_extra_u_isoparam(double u);
- void add_extra_v_isoparam(double u);
-
- Type match(QtessSurface *surface);
- INLINE int get_num_surfaces() const;
- int count_tris(double tri_factor = 1.0, int attempts = 0);
-
- static void output_extra(std::ostream &out, const pvector &iso, char axis);
- void output(std::ostream &out) const;
- void write(std::ostream &out, int indent_level) const;
-
- bool _auto_place, _auto_distribute;
- double _curvature_ratio;
- double _importance;
- QtessSurface *_constrain_u, *_constrain_v;
-
-private:
- typedef pvector NodeNames;
- NodeNames _node_names;
-
- int _num_tris;
- int _num_u, _num_v;
- double _per_isoparam;
- pvector _iso_u, _iso_v;
- Type _type;
-
- typedef pvector Surfaces;
- Surfaces _surfaces;
-
- double _num_patches;
-};
-
-INLINE std::ostream &operator << (std::ostream &out, const QtessInputEntry &entry);
-
-#include "qtessInputEntry.I"
-
-#endif
diff --git a/pandatool/src/egg-qtess/qtessInputFile.I b/pandatool/src/egg-qtess/qtessInputFile.I
deleted file mode 100644
index 313b59c8..00000000
--- a/pandatool/src/egg-qtess/qtessInputFile.I
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file qtessInputFile.I
- * @author drose
- * @date 2003-10-13
- */
-
-/**
- *
- */
-INLINE QtessInputFile::
-QtessInputFile(const QtessInputFile ©) :
- _entries(copy._entries)
-{
-}
-
-/**
- *
- */
-INLINE void QtessInputFile::
-operator = (const QtessInputFile ©) {
- _entries = copy._entries;
-}
diff --git a/pandatool/src/egg-qtess/qtessInputFile.cxx b/pandatool/src/egg-qtess/qtessInputFile.cxx
deleted file mode 100644
index 180a2e95..00000000
--- a/pandatool/src/egg-qtess/qtessInputFile.cxx
+++ /dev/null
@@ -1,327 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file qtessInputFile.cxx
- * @author drose
- * @date 2003-10-13
- */
-
-#include "qtessInputFile.h"
-#include "config_egg_qtess.h"
-#include "string_utils.h"
-
-using std::string;
-
-/**
- *
- */
-QtessInputFile::
-QtessInputFile() {
-}
-
-/**
- * reads the input file.
- */
-bool QtessInputFile::
-read(const Filename &filename) {
- _filename = Filename::text_filename(filename);
- _entries.clear();
-
- std::ifstream input;
- if (!_filename.open_read(input)) {
- qtess_cat.error()
- << "Unable to open input file " << _filename << "\n";
- return false;
- }
-
- string complete_line;
-
- int line_number = 0;
- string line;
- while (std::getline(input, line)) {
- line_number++;
-
- // Eliminate comments. We have to scan the line repeatedly until we find
- // the first hash mark that's preceded by whitespace.
- size_t comment = line.find('#');
- while (comment != string::npos) {
- if (comment == 0 || isspace(line[comment - 1])) {
- line = line.substr(0, comment);
- comment = string::npos;
-
- } else {
- comment = line.find('#', comment + 1);
- }
- }
-
- // Check for a trailing backslash: continuation character.
- line = trim_right(line);
- if (!line.empty() && line[line.size() - 1] == '\\') {
- // We have a continuation character; go back and read some more.
- complete_line += line.substr(0, line.size() - 1);
-
- } else {
- // It's a complete line. Begin parsing.
- line = trim(complete_line + line);
- complete_line = string();
-
- if (!line.empty()) {
- QtessInputEntry entry;
-
- // Scan for the first colon followed by whitespace.
- size_t colon = line.find(": ");
- if (colon == string::npos) {
- qtess_cat.error()
- << _filename << ": line " << line_number
- << " has no colon followed by whitespace.\n";
- return false;
- }
- if (colon == 0) {
- qtess_cat.error()
- << _filename << ": line " << line_number
- << " has no nodes.\n";
- return false;
- }
-
- // Split the line into two groups of words at the colon: names before
- // the colon, and params following it.
- vector_string names, params;
- extract_words(line.substr(0, colon), names);
- extract_words(line.substr(colon + 1), params);
-
- vector_string::const_iterator ni;
- for (ni = names.begin(); ni != names.end(); ++ni) {
- entry.add_node_name(*ni);
- }
-
- // Scan for things like ap, ad, ar, and pull them out of the stream.
- vector_string::iterator ci, cnext;
- ci = params.begin();
- while (ci != params.end()) {
- cnext = ci;
- ++cnext;
-
- string param = *ci;
- bool invert = false;
- if (param[0] == '!' && param.size() > 1) {
- invert = true;
- param = param.substr(1);
- }
- if (tolower(param[0]) == 'a' && param.size() > 1) {
- switch (tolower(param[1])) {
- case 'p':
- entry._auto_place = !invert;
- break;
-
- case 'd':
- entry._auto_distribute = !invert;
- break;
-
- case 'r':
- if (!string_to_double(param.substr(2), entry._curvature_ratio)) {
- qtess_cat.error()
- << _filename << ": line " << line_number
- << " - invalid field " << param << "\n";
- return false;
- }
- break;
-
- default:
- qtess_cat.error()
- << _filename << ": invalid parameters at line "
- << line_number << ".\n";
- return false;
- }
- params.erase(ci);
- } else {
- ci = cnext;
- }
- }
-
- if (!params.empty()) {
- bool okflag = true;
- if (cmp_nocase(params[0], "omit")==0) {
- entry.set_omit();
-
- } else if (cmp_nocase(params[0], "matchuu")==0) {
- entry.set_match_uu();
- if (params.size() > 1 && cmp_nocase(params[1], "matchvv")==0) {
- entry.set_match_vv();
- }
-
- } else if (cmp_nocase(params[0], "matchvv")==0) {
- entry.set_match_vv();
- if (params.size() > 1 && cmp_nocase(params[1], "matchuu")==0) {
- entry.set_match_uu();
- }
-
- } else if (cmp_nocase(params[0], "matchuv")==0) {
- entry.set_match_uv();
- if (params.size() > 1 && cmp_nocase(params[1], "matchvu")==0) {
- entry.set_match_vu();
- }
-
- } else if (cmp_nocase(params[0], "matchvu")==0) {
- entry.set_match_vu();
- if (params.size() > 1 && cmp_nocase(params[1], "matchuv")==0) {
- entry.set_match_uv();
- }
-
- } else if (cmp_nocase(params[0], "minu")==0) {
- // minu #: minimum tesselation in U.
- if (params.size() < 2) {
- okflag = false;
- } else {
- int value = 0;
- okflag = string_to_int(params[1], value);
- entry.set_min_u(value);
- }
-
- } else if (cmp_nocase(params[0], "minv")==0) {
- // minu #: minimum tesselation in V.
- if (params.size() < 2) {
- okflag = false;
- } else {
- int value = 0;
- okflag = string_to_int(params[1], value);
- entry.set_min_v(value);
- }
-
- } else if (tolower(params[0][0]) == 'i') {
- // "i#": per-isoparam tesselation.
- int value = 0;
- okflag = string_to_int(params[0].substr(1), value);
- entry.set_per_isoparam(value);
-
- } else if (params[0][params[0].length() - 1] == '%') {
- double value = 0.0;
- okflag = string_to_double(params[0].substr(0, params[0].length() - 1), value);
- entry.set_importance(value / 100.0);
-
- } else if (params.size() == 1) {
- // One numeric parameter: the number of triangles.
- int value = 0;
- okflag = string_to_int(params[0], value);
- entry.set_num_tris(value);
-
- } else if (params.size() >= 2) {
- // Two or more numeric parameters: the number of u by v quads,
- // followed by an optional list of specific isoparams.
- int u = 0, v = 0;
- okflag = string_to_int(params[0], u) && string_to_int(params[1], v);
- entry.set_uv(u, v, ¶ms[2], params.size() - 2);
-
- } else {
- okflag = false;
- }
-
- if (!okflag) {
- qtess_cat.error()
- << _filename << ": invalid parameters at line "
- << line_number << ".\n";
- return false;
- }
- }
- _entries.push_back(entry);
- }
- }
- }
-
- if (qtess_cat.is_info()) {
- qtess_cat.info()
- << "read qtess parameter file " << _filename << ".\n";
- if (qtess_cat.is_debug()) {
- write(qtess_cat.debug(false));
- }
- }
-
- add_default_entry();
-
- return true;
-}
-
-/**
- * Returns a reference to the last entry on the list, which is the "default"
- * entry that will match any surface that does not get explicitly named in the
- * input file.
- */
-QtessInputEntry &QtessInputFile::
-get_default_entry() {
- if (_entries.empty()) {
- // No entries; create one.
- add_default_entry();
- }
- return _entries.back();
-}
-
-
-/**
- * Attempts to find a match for the given surface in the user input entries.
- * Searches in the order in which the entries were defined, and chooses the
- * first match.
- *
- * When a match is found, the surface is added to the entry's set of matched
- * surfaces. Returns the type of the matching node if a match is found, or
- * T_undefined otherwise.
- */
-QtessInputEntry::Type QtessInputFile::
-match(QtessSurface *surface) {
- QtessInputEntry::Type type;
-
- if (_entries.empty()) {
- // No entries; create one.
- add_default_entry();
- }
-
- Entries::iterator ei;
- for (ei = _entries.begin(); ei != _entries.end(); ++ei) {
- type = (*ei).match(surface);
- if (type != QtessInputEntry::T_undefined) {
- return type;
- }
- }
- return QtessInputEntry::T_undefined;
-}
-
-/**
- * Determines the tesselation u,v amounts of each attached surface, and stores
- * this information in the surface pointer. Returns the total number of tris
- * that will be produced.
- */
-int QtessInputFile::
-count_tris() {
- int total_tris = 0;
-
- Entries::iterator ei;
- for (ei = _entries.begin(); ei != _entries.end(); ++ei) {
- total_tris += (*ei).count_tris();
- }
- return total_tris;
-}
-
-/**
- *
- */
-void QtessInputFile::
-write(std::ostream &out, int indent_level) const {
- Entries::const_iterator ei;
- for (ei = _entries.begin(); ei != _entries.end(); ++ei) {
- (*ei).write(out, indent_level);
- }
-}
-
-/**
- * Adds one more entry to the end of the list, to catch all of the surfaces
- * that didn't get explicitly named.
- */
-void QtessInputFile::
-add_default_entry() {
- QtessInputEntry entry("*");
- entry.set_omit();
- _entries.push_back(entry);
-}
diff --git a/pandatool/src/egg-qtess/qtessInputFile.h b/pandatool/src/egg-qtess/qtessInputFile.h
deleted file mode 100644
index c5cb5fab..00000000
--- a/pandatool/src/egg-qtess/qtessInputFile.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file qtessInputFile.h
- * @author drose
- * @date 2003-10-13
- */
-
-#ifndef QTESSINPUTFILE_H
-#define QTESSINPUTFILE_H
-
-#include "pandatoolbase.h"
-#include "qtessInputEntry.h"
-#include "filename.h"
-#include "pvector.h"
-#include "vector_double.h"
-
-class QtessSurface;
-
-/**
- * Stores all the information read from a tesselation input file: a list of
- * QtessInputEntry's.
- */
-class QtessInputFile {
-public:
- QtessInputFile();
- INLINE QtessInputFile(const QtessInputFile ©);
- INLINE void operator = (const QtessInputFile ©);
-
- bool read(const Filename &filename);
- QtessInputEntry &get_default_entry();
-
- QtessInputEntry::Type match(QtessSurface *surface);
- int count_tris();
-
- void write(std::ostream &out, int indent_level = 0) const;
-
-private:
- void add_default_entry();
-
- Filename _filename;
-
- typedef pvector Entries;
- Entries _entries;
-};
-
-#include "qtessInputFile.I"
-
-#endif
diff --git a/pandatool/src/egg-qtess/qtessSurface.I b/pandatool/src/egg-qtess/qtessSurface.I
deleted file mode 100644
index d65f82c3..00000000
--- a/pandatool/src/egg-qtess/qtessSurface.I
+++ /dev/null
@@ -1,154 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file qtessSurface.I
- * @author drose
- * @date 2003-10-13
- */
-
-/**
- *
- */
-INLINE const std::string &QtessSurface::
-get_name() const {
- return _egg_surface->get_name();
-}
-
-/**
- * Returns true if the defined surface is valid, false otherwise.
- */
-INLINE bool QtessSurface::
-is_valid() const {
- return (_nurbs != nullptr);
-}
-
-/**
- * Sets the importance of the surface, as a ratio in proportion to the square
- * of its size.
- */
-INLINE void QtessSurface::
-set_importance(double importance2) {
- _importance = sqrt(importance2);
- _importance2 = importance2;
-}
-
-/**
- * Indicates the surface to which this surface must match in its U direction.
- * If u_to_u is true, it matches to the other surface's U direction;
- * otherwise, it matches to the other surface's V direction.
- *
- * Note that the surface pointer is an indirect pointer. The value passed in
- * is the address of the pointer to the actual surface (which may or may not
- * be filled in yet). The actual pointer may be filled in later.
- */
-INLINE void QtessSurface::
-set_match_u(QtessSurface **match_u, bool match_u_to_u) {
- _match_u = match_u;
- _match_u_to_u = match_u_to_u;
-}
-
-/**
- * Indicates the surface to which this surface must match in its V direction.
- * If v_to_v is true, it matches to the other surface's V direction;
- * otherwise, it matches to the other surface's U direction.
- *
- * Note that the surface pointer is an indirect pointer. The value passed in
- * is the address of the pointer to the actual surface (which may or may not
- * be filled in yet). The actual pointer may be filled in later.
- */
-INLINE void QtessSurface::
-set_match_v(QtessSurface **match_v, bool match_v_to_v) {
- _match_v = match_v;
- _match_v_to_v = match_v_to_v;
-}
-
-/**
- * Specifies the absolute minimum number of segments allowed in the U
- * direction.
- */
-INLINE void QtessSurface::
-set_min_u(int min_u) {
- _min_u = min_u;
-}
-
-/**
- * Specifies the absolute minimum number of segments allowed in the V
- * direction.
- */
-INLINE void QtessSurface::
-set_min_v(int min_v) {
- _min_v = min_v;
-}
-
-
-/**
- * Returns the number of patches the NURBS contains. Each patch is a square
- * area bounded by isoparams. This actually scales by the importance of the
- * surface, if it is not 1.
- */
-INLINE double QtessSurface::
-count_patches() const {
- return _num_u * _num_v * _importance2;
-}
-
-/**
- * Returns the number of triangles that will be generated by the current
- * tesselation parameters.
- */
-INLINE int QtessSurface::
-count_tris() const {
- return _tess_u * _tess_v * 2;
-}
-
-/**
- * Returns the extra dimension number within the surface where the vertex
- * membership in the indicated joint should be stored.
- */
-INLINE int QtessSurface::
-get_joint_membership_index(EggGroup *joint) {
- JointTable::iterator jti = _joint_table.find(joint);
- if (jti != _joint_table.end()) {
- return (*jti).second;
- }
- int d = _next_d;
- _next_d++;
- _joint_table[joint] = d;
- return d;
-}
-
-/**
- * Returns the extra dimension number within the surface where the indicated
- * Dxyz morph offset should be stored.
- */
-INLINE int QtessSurface::
-get_dxyz_index(const std::string &morph_name) {
- MorphTable::iterator mti = _dxyz_table.find(morph_name);
- if (mti != _dxyz_table.end()) {
- return (*mti).second;
- }
- int d = _next_d;
- _next_d += 3;
- _dxyz_table[morph_name] = d;
- return d;
-}
-
-/**
- * Returns the extra dimension number within the surface where the indicated
- * Drgba morph offset should be stored.
- */
-INLINE int QtessSurface::
-get_drgba_index(const std::string &morph_name) {
- MorphTable::iterator mti = _drgba_table.find(morph_name);
- if (mti != _drgba_table.end()) {
- return (*mti).second;
- }
- int d = _next_d;
- _next_d += 4;
- _drgba_table[morph_name] = d;
- return d;
-}
diff --git a/pandatool/src/egg-qtess/qtessSurface.cxx b/pandatool/src/egg-qtess/qtessSurface.cxx
deleted file mode 100644
index d7ccebe7..00000000
--- a/pandatool/src/egg-qtess/qtessSurface.cxx
+++ /dev/null
@@ -1,565 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file qtessSurface.cxx
- * @author drose
- * @date 2003-10-13
- */
-
-#include "qtessSurface.h"
-#include "qtessGlobals.h"
-#include "qtessInputEntry.h"
-#include "config_egg_qtess.h"
-#include "eggPolygon.h"
-#include "eggVertexPool.h"
-#include "eggVertex.h"
-#include "eggComment.h"
-#include "egg_parametrics.h"
-#include "pset.h"
-#include "pmap.h"
-
-using std::max;
-using std::string;
-
-/**
- *
- */
-QtessSurface::
-QtessSurface(EggNurbsSurface *egg_surface) :
- _egg_surface(egg_surface)
-{
- _nurbs = make_nurbs_surface(_egg_surface, LMatrix4d::ident_mat());
- _has_vertex_color = _egg_surface->has_vertex_color();
-
- // The first four slots are reserved for vertex color.
- _next_d = 4;
-
- _importance = 1.0;
- _importance2 = 1.0;
- _match_u = _match_v = nullptr;
- _tess_u = _tess_v = 0;
- _got_scores = false;
-
- // If the surface is closed in either dimension, the mininum tesselation in
- // that dimension is by default 3, so we don't ribbonize the surface.
- // Otherwise the minimum is 1.
- _min_u = _min_v = 1;
- if (egg_surface->is_closed_u()) {
- _min_u = 3;
- }
- if (egg_surface->is_closed_v()) {
- _min_v = 3;
- }
-
- if (_nurbs == nullptr) {
- _num_u = _num_v = 0;
-
- } else {
- record_vertex_extras();
-
- _nurbs->normalize_u_knots();
- _nurbs->normalize_v_knots();
- _nurbs_result = _nurbs->evaluate();
-
- _num_u = _nurbs->get_num_u_segments();
- _num_v = _nurbs->get_num_v_segments();
-
- if (QtessGlobals::_respect_egg) {
- if (egg_surface->get_u_subdiv() != 0) {
- _num_u = egg_surface->get_u_subdiv();
- }
- if (egg_surface->get_v_subdiv() != 0) {
- _num_v = egg_surface->get_v_subdiv();
- }
- }
- }
-}
-
-/**
- * Computes the curvature/stretch score for the surface, if it has not been
- * already computed, and returns the net surface score. This is used both for
- * automatically distributing isoparams among the surfaces by curvature, as
- * well as for automatically placing the isoparams within each surface by
- * curvature.
- */
-double QtessSurface::
-get_score(double ratio) {
- if (_nurbs == nullptr) {
- return 0.0;
- }
-
- if (!_got_scores) {
- _u_placer.get_scores(_nurbs->get_num_u_segments() * 100,
- _nurbs->get_num_v_segments() * 2,
- ratio, _nurbs_result, true);
- _v_placer.get_scores(_nurbs->get_num_v_segments() * 100,
- _nurbs->get_num_u_segments() * 2,
- ratio, _nurbs_result, false);
- _got_scores = true;
- }
-
- return _u_placer.get_total_score() * _v_placer.get_total_score() * _importance2;
-}
-
-/**
- * Applies the appropriate tesselation to the surface, and replaces its node
- * in the tree with an EggGroup containing both the new vertex pool and all of
- * the polygons.
- */
-int QtessSurface::
-tesselate() {
- apply_match();
- int tris = 0;
-
- PT(EggGroup) group = do_uniform_tesselate(tris);
- PT(EggNode) new_node = group.p();
- if (new_node == nullptr) {
- new_node = new EggComment(_egg_surface->get_name(),
- "Omitted NURBS surface.");
- tris = 0;
- }
- EggGroupNode *parent = _egg_surface->get_parent();
- nassertr(parent != nullptr, 0);
- parent->remove_child(_egg_surface);
- parent->add_child(new_node);
-
- return tris;
-}
-
-/**
- * Writes a line to the given output file telling qtess how this surface
- * should be tesselated uniformly. Returns the number of tris.
- */
-int QtessSurface::
-write_qtess_parameter(std::ostream &out) {
- apply_match();
-
- if (_tess_u == 0 || _tess_v == 0) {
- out << get_name() << " : omit\n";
-
- } else if (_iso_u.empty() || _iso_v.empty()) {
- out << get_name() << " : " << _tess_u << " " << _tess_v << "\n";
-
- } else {
- out << get_name() << " : " << _iso_u.back() << " " << _iso_v.back();
- QtessInputEntry::output_extra(out, _iso_u, 'u');
- QtessInputEntry::output_extra(out, _iso_v, 'v');
- out << "\n";
- }
-
- return count_tris();
-}
-
-
-/**
- * Sets up the surface to omit itself from the output.
- */
-void QtessSurface::
-omit() {
- _tess_u = 0;
- _tess_v = 0;
-}
-
-/**
- * Sets the surface up to tesselate itself uniformly at u x v, or if autoplace
- * is true, automatically with u x v quads.
- */
-void QtessSurface::
-tesselate_uv(int u, int v, bool autoplace, double ratio) {
- _tess_u = u;
- _tess_v = v;
- _iso_u.clear();
- _iso_v.clear();
- if (autoplace) {
- tesselate_auto(_tess_u, _tess_v, ratio);
- }
-}
-
-/**
- * Sets the surface up to tesselate itself at specific isoparams only.
- */
-void QtessSurface::
-tesselate_specific(const pvector &u_list,
- const pvector &v_list) {
- _iso_u = u_list;
- _iso_v = v_list;
- _tess_u = (int)_iso_u.size() - 1;
- _tess_v = (int)_iso_v.size() - 1;
-}
-
-/**
- * Sets the surface up to tesselate itself to a uniform amount per isoparam.
- */
-void QtessSurface::
-tesselate_per_isoparam(double pi, bool autoplace, double ratio) {
- if (_num_u == 0 || _num_v == 0) {
- omit();
-
- } else {
- _tess_u = max(_min_u, (int)floor(_num_u * _importance * pi + 0.5));
- _tess_v = max(_min_v, (int)floor(_num_v * _importance * pi + 0.5));
- _iso_u.clear();
- _iso_v.clear();
- if (autoplace) {
- tesselate_auto(_tess_u, _tess_v, ratio);
- }
- }
-}
-
-
-/**
- * Sets the surface up to tesselate itself according to its computed curvature
- * score in both dimensions.
- */
-void QtessSurface::
-tesselate_per_score(double pi, bool autoplace, double ratio) {
- if (get_score(ratio) <= 0.0) {
- omit();
-
- } else {
- _tess_u = max(_min_u, (int)floor(_u_placer.get_total_score() * _importance * pi + 0.5));
- _tess_v = max(_min_v, (int)floor(_v_placer.get_total_score() * _importance * pi + 0.5));
- _iso_u.clear();
- _iso_v.clear();
- if (autoplace) {
- tesselate_auto(_tess_u, _tess_v, ratio);
- }
- }
-}
-
-/**
- * Sets the surface up to tesselate itself by automatically determining the
- * best place to put the indicated u x v isoparams.
- */
-void QtessSurface::
-tesselate_auto(int u, int v, double ratio) {
- if (get_score(ratio) <= 0.0) {
- omit();
-
- } else {
- _u_placer.place(u, _iso_u);
- _v_placer.place(v, _iso_v);
- _tess_u = (int)_iso_u.size() - 1;
- _tess_v = (int)_iso_v.size() - 1;
- }
-}
-
-/**
- * Records the joint membership and morph offsets of each control vertex in
- * the extra-dimensional space of the NURBS, so that we can extract this data
- * out again later to apply to the polygon vertices.
- */
-void QtessSurface::
-record_vertex_extras() {
- int num_u_vertices = _egg_surface->get_num_u_cvs();
- int num_v_vertices = _egg_surface->get_num_v_cvs();
-
- for (int ui = 0; ui < num_u_vertices; ui++) {
- for (int vi = 0; vi < num_v_vertices; vi++) {
- int i = _egg_surface->get_vertex_index(ui, vi);
- EggVertex *egg_vertex = _egg_surface->get_vertex(i);
-
- // The joint membership.
- EggVertex::GroupRef::const_iterator gi;
- for (gi = egg_vertex->gref_begin(); gi != egg_vertex->gref_end(); ++gi) {
- EggGroup *joint = (*gi);
- int d = get_joint_membership_index(joint);
- double membership = joint->get_vertex_membership(egg_vertex);
- _nurbs->set_extended_vertex(ui, vi, d, membership);
- }
-
- // The xyz morphs.
- EggMorphVertexList::const_iterator dxi;
- for (dxi = egg_vertex->_dxyzs.begin();
- dxi != egg_vertex->_dxyzs.end();
- ++dxi) {
- const string &morph_name = (*dxi).get_name();
- LVector3 delta = LCAST(PN_stdfloat, (*dxi).get_offset());
- int d = get_dxyz_index(morph_name);
- _nurbs->set_extended_vertices(ui, vi, d, delta.get_data(), 3);
- }
-
- // The rgba morphs.
- EggMorphColorList::const_iterator dri;
- for (dri = egg_vertex->_drgbas.begin();
- dri != egg_vertex->_drgbas.end();
- ++dri) {
- const string &morph_name = (*dri).get_name();
- const LVector4 &delta = (*dri).get_offset();
- int d = get_drgba_index(morph_name);
- _nurbs->set_extended_vertices(ui, vi, d, delta.get_data(), 4);
- }
- }
- }
-}
-
-/**
- * If the surface was set up to copy its tesselation in either axis from
- * another surface, makes this copy now.
- */
-void QtessSurface::
-apply_match() {
- if (_match_u != nullptr) {
- QtessSurface *m = *_match_u;
- if (m == nullptr) {
- qtess_cat.warning()
- << "No surface to match " << get_name() << " to in U.\n";
- } else {
- if (qtess_cat.is_debug()) {
- qtess_cat.debug()
- << "Matching " << get_name() << " in U to " << m->get_name()
- << " in " << (_match_u_to_u?'U':'V') << ".\n";
- }
- if (_match_u_to_u) {
- _tess_u = m->_tess_u;
- _iso_u = m->_iso_u;
- } else {
- _tess_u = m->_tess_v;
- _iso_u = m->_iso_v;
- }
- }
- }
-
- if (_match_v != nullptr) {
- QtessSurface *m = *_match_v;
- if (m == nullptr) {
- qtess_cat.warning()
- << "No surface to match " << get_name() << " in V.\n";
- } else {
- if (qtess_cat.is_debug()) {
- qtess_cat.debug()
- << "Matching " << get_name() << " in V to " << m->get_name()
- << " in " << (_match_v_to_v?'V':'U') << ".\n";
- }
- if (_match_v_to_v) {
- _tess_v = m->_tess_v;
- _iso_v = m->_iso_v;
- } else {
- _tess_v = m->_tess_u;
- _iso_v = m->_iso_u;
- }
- }
- }
-}
-
-/**
- * Subdivide the surface uniformly according to the parameters specified by an
- * earlier call to omit(), teseselate_uv(), or tesselate_per_isoparam().
- */
-PT(EggGroup) QtessSurface::
-do_uniform_tesselate(int &tris) const {
- tris = 0;
-
- if (_tess_u == 0 || _tess_v == 0) {
- // No tesselation!
- if (qtess_cat.is_debug()) {
- qtess_cat.debug()
- << get_name() << " : omit\n";
- }
- return nullptr;
- }
-
- PT(EggGroup) group = new EggGroup(_egg_surface->get_name());
-
- // _tess_u and _tess_v are the number of patches to create. Convert that to
- // the number of vertices.
-
- int num_u = _tess_u + 1;
- int num_v = _tess_v + 1;
-
- if (qtess_cat.is_debug()) {
- qtess_cat.debug() << get_name() << " : " << tris << "\n";
- }
-
- assert(_iso_u.empty() || (int)_iso_u.size() == num_u);
- assert(_iso_v.empty() || (int)_iso_v.size() == num_v);
-
- // Now how many vertices is that total, and how many vertices per strip?
- int num_verts = num_u * num_v;
-
- // Create a vertex pool.
- PT(EggVertexPool) vpool = new EggVertexPool(_egg_surface->get_name());
- group->add_child(vpool);
-
- // Create all the vertices.
- int ui, vi;
- double u, v;
-
- typedef pvector VertexList;
- VertexList new_verts;
- new_verts.reserve(num_verts);
-
- // Also collect the vertices into this set to group them by spatial position
- // only. This is relevant for calculating normals.
- typedef pset NVertexGroup;
- typedef pmap NVertexCollection;
- NVertexCollection n_collection;
-
- for (vi = 0; vi < num_v; vi++) {
- if (_iso_v.empty()) {
- v = (double)vi / (double)(num_v-1);
- } else {
- v = _iso_v[vi] / _iso_v.back();
- }
- for (ui = 0; ui < num_u; ui++) {
- if (_iso_u.empty()) {
- u = (double)ui / (double)(num_u-1);
- } else {
- u = _iso_u[ui] / _iso_u.back();
- }
-
- PT(EggVertex) egg_vertex = evaluate_vertex(u, v);
- vpool->add_vertex(egg_vertex);
- new_verts.push_back(egg_vertex);
- n_collection[egg_vertex->get_pos3()].insert(egg_vertex);
- }
- }
- nassertr((int)new_verts.size() == num_verts, nullptr);
-
- // Now create a bunch of quads.
- for (vi = 1; vi < num_v; vi++) {
- for (ui = 1; ui < num_u; ui++) {
- PT(EggPolygon) poly = new EggPolygon;
- poly->add_vertex(new_verts[vi*num_u + (ui-1)]);
- poly->add_vertex(new_verts[(vi-1)*num_u + (ui-1)]);
- poly->add_vertex(new_verts[(vi-1)*num_u + ui]);
- poly->add_vertex(new_verts[vi*num_u + ui]);
-
- poly->copy_attributes(*_egg_surface);
-
- // We compute a polygon normal just so we can verify the calculated
- // vertex normals. It's also helpful for identifying degenerate
- // polygons.
- if (poly->recompute_polygon_normal()) {
- tris += 2;
- group->add_child(poly);
- }
- }
- }
-
- // Now check all the vertex normals by comparing them to the polygon
- // normals. Some might have not been computed at all; others might be
- // facing in the wrong direction.
-
- // Now go back through and normalize the computed normals.
- NVertexCollection::const_iterator nci;
- for (nci = n_collection.begin(); nci != n_collection.end(); ++nci) {
- const NVertexGroup &group = (*nci).second;
-
- // Calculate the normal these vertices should have based on the polygons
- // that share it.
- LNormald normal = LNormald::zero();
- int num_polys = 0;
- NVertexGroup::const_iterator ngi;
- for (ngi = group.begin(); ngi != group.end(); ++ngi) {
- EggVertex *egg_vertex = (*ngi);
- EggVertex::PrimitiveRef::const_iterator pri;
- for (pri = egg_vertex->pref_begin();
- pri != egg_vertex->pref_end();
- ++pri) {
- EggPrimitive *egg_primitive = (*pri);
- nassertr(egg_primitive->has_normal(), nullptr);
- normal += egg_primitive->get_normal();
- num_polys++;
- }
- }
-
- if (num_polys > 0) {
- normal /= (double)num_polys;
-
- // Now compare this normal with what the NURBS representation
- // calculated. It should be facing in at least vaguely the same
- // direction.
- for (ngi = group.begin(); ngi != group.end(); ++ngi) {
- EggVertex *egg_vertex = (*ngi);
- if (egg_vertex->has_normal()) {
- if (normal.dot(egg_vertex->get_normal()) < 0.0) {
- // This one is backwards.
- egg_vertex->set_normal(-egg_vertex->get_normal());
- }
- } else {
- // This vertex doesn't have a normal; it gets the computed normal.
- egg_vertex->set_normal(normal);
- }
- }
- }
- }
-
- return group;
-}
-
-/**
- * Evaluates the surface at the given u, v position and sets the vertex to the
- * appropriate values. Also sets the joint membership of the vertex.
- */
-PT(EggVertex) QtessSurface::
-evaluate_vertex(double u, double v) const {
- PT(EggVertex) egg_vertex = new EggVertex;
-
- LVertex point;
- LNormal normal;
- _nurbs_result->eval_point(u, v, point);
- _nurbs_result->eval_normal(u, v, normal);
-
- // If the normal is too short, don't consider it--it's probably inaccurate
- // due to numerical limitations. We'll recompute it later based on the
- // polygon normals.
- PN_stdfloat length = normal.length();
- if (length > 0.0001f) {
- normal /= length;
- egg_vertex->set_normal(LCAST(double, normal));
- }
-
- egg_vertex->set_pos(LCAST(double, point));
- egg_vertex->set_uv(LVecBase2d(u, v));
-
- // The color is stored, by convention, in slots 0-4 of the surface.
- if (_has_vertex_color) {
- LColor rgba;
- _nurbs_result->eval_extended_points(u, v, 0, &rgba[0], 4);
- egg_vertex->set_color(rgba);
- }
-
- // Also fill in the joint membership.
- JointTable::const_iterator jti;
- for (jti = _joint_table.begin(); jti != _joint_table.end(); ++jti) {
- EggGroup *joint = (*jti).first;
- int d = (*jti).second;
-
- double membership = _nurbs_result->eval_extended_point(u, v, d);
- if (membership > 0.0) {
- joint->ref_vertex(egg_vertex, membership);
- }
- }
-
- // And the morphs.
- MorphTable::const_iterator mti;
- for (mti = _dxyz_table.begin(); mti != _dxyz_table.end(); ++mti) {
- const string &morph_name = (*mti).first;
- int d = (*mti).second;
-
- LVector3 delta;
- _nurbs_result->eval_extended_points(u, v, d, &delta[0], 3);
- if (!delta.almost_equal(LVector3::zero())) {
- egg_vertex->_dxyzs.insert(EggMorphVertex(morph_name, LCAST(double, delta)));
- }
- }
-
- for (mti = _drgba_table.begin(); mti != _drgba_table.end(); ++mti) {
- const string &morph_name = (*mti).first;
- int d = (*mti).second;
-
- LVector4 delta;
- _nurbs_result->eval_extended_points(u, v, d, &delta[0], 4);
- if (!delta.almost_equal(LVector4::zero())) {
- egg_vertex->_drgbas.insert(EggMorphColor(morph_name, delta));
- }
- }
-
- return egg_vertex;
-}
diff --git a/pandatool/src/egg-qtess/qtessSurface.h b/pandatool/src/egg-qtess/qtessSurface.h
deleted file mode 100644
index fc3720e5..00000000
--- a/pandatool/src/egg-qtess/qtessSurface.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file qtessSurface.h
- * @author drose
- * @date 2003-10-13
- */
-
-#ifndef QTESSSURFACE_H
-#define QTESSSURFACE_H
-
-#include "pandatoolbase.h"
-#include "isoPlacer.h"
-#include "eggNurbsSurface.h"
-#include "eggGroup.h"
-#include "eggVertex.h"
-#include "nurbsSurfaceEvaluator.h"
-#include "nurbsSurfaceResult.h"
-#include "referenceCount.h"
-#include "pointerTo.h"
-
-/**
- * A reference to an EggNurbsSurface in the egg file, and its parameters as
- * set by the user input file and as computed in relation to the other
- * surfaces.
- */
-class QtessSurface : public ReferenceCount {
-public:
- QtessSurface(EggNurbsSurface *egg_surface);
-
- INLINE const std::string &get_name() const;
- INLINE bool is_valid() const;
-
- INLINE void set_importance(double importance2);
- INLINE void set_match_u(QtessSurface **match_u, bool match_u_to_u);
- INLINE void set_match_v(QtessSurface **match_v, bool match_v_to_v);
- INLINE void set_min_u(int min_u);
- INLINE void set_min_v(int min_v);
-
- INLINE double count_patches() const;
- INLINE int count_tris() const;
-
- double get_score(double ratio);
-
- int tesselate();
- int write_qtess_parameter(std::ostream &out);
- void omit();
- void tesselate_uv(int u, int v, bool autoplace, double ratio);
- void tesselate_specific(const pvector &u_list,
- const pvector &v_list);
- void tesselate_per_isoparam(double pi, bool autoplace, double ratio);
- void tesselate_per_score(double pi, bool autoplace, double ratio);
- void tesselate_auto(int u, int v, double ratio);
-
-private:
- void record_vertex_extras();
- INLINE int get_joint_membership_index(EggGroup *joint);
- INLINE int get_dxyz_index(const std::string &morph_name);
- INLINE int get_drgba_index(const std::string &morph_name);
-
- void apply_match();
- PT(EggGroup) do_uniform_tesselate(int &tris) const;
- PT(EggVertex) evaluate_vertex(double u, double v) const;
-
- PT(EggNurbsSurface) _egg_surface;
- PT(NurbsSurfaceEvaluator) _nurbs;
- PT(NurbsSurfaceResult) _nurbs_result;
- bool _has_vertex_color;
-
- // Mapping arbitrary attributes to integer extended dimension values, so we
- // can hang arbitrary data in the extra dimensional space of the surface.
- int _next_d;
- typedef std::map JointTable;
- JointTable _joint_table;
- typedef std::map MorphTable;
- MorphTable _dxyz_table;
- MorphTable _drgba_table;
-
- int _num_u, _num_v;
- int _tess_u, _tess_v;
- pvector _iso_u, _iso_v; // If nonempty, isoparams at which to tess.
-
- // _importance is the relative importance of the surface along either axis;
- // _importance2 is this number squared, which is the value set by
- // set_importance().
- double _importance;
- double _importance2;
-
- // _match_u and _match_v indicate which surface we must match exactly for
- // tesselation in U or V. This helps get edges to line up properly. They
- // are indirect pointers because we go through the surfaces in one pass, and
- // might need to fill in the correct value later.
- QtessSurface **_match_u, **_match_v;
- bool _match_u_to_u, _match_v_to_v;
-
- // _min_u and _min_v specify a mininum number of quads below which we should
- // not attempt to subdivide the surface in either dimension. This is
- // intended to prevent degenerate cases like knife-fingers.
- int _min_u, _min_v;
-
- IsoPlacer _u_placer, _v_placer;
- bool _got_scores;
-};
-
-#include "qtessSurface.I"
-
-#endif
diff --git a/pandatool/src/egg-qtess/subdivSegment.I b/pandatool/src/egg-qtess/subdivSegment.I
deleted file mode 100644
index 2210032e..00000000
--- a/pandatool/src/egg-qtess/subdivSegment.I
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file subdivSegment.I
- * @author drose
- * @date 2003-10-14
- */
-
-/**
- *
- */
-INLINE SubdivSegment::
-SubdivSegment(const double *cint, int f, int t) :
- _cint(cint),
- _f(f),
- _t(t)
-{
-}
-
-/**
- * Returns the net score of the segment.
- */
-INLINE double SubdivSegment::
-get_score() const {
- return _cint[_t] - _cint[_f];
-}
-
-/**
- * Returns a score that indicates how badly the segment needs to be further
- * subdivided. The greater the number, the greater the need.
- */
-INLINE double SubdivSegment::
-get_need() const {
- return get_score() / (double)(_num_cuts+1);
-}
-
-/**
- * Sorts the segments in descending order of need.
- */
-INLINE bool SubdivSegment::
-operator < (const SubdivSegment &other) const {
- return get_need() > other.get_need();
-}
diff --git a/pandatool/src/egg-qtess/subdivSegment.cxx b/pandatool/src/egg-qtess/subdivSegment.cxx
deleted file mode 100644
index 3c036e56..00000000
--- a/pandatool/src/egg-qtess/subdivSegment.cxx
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file subdivSegment.cxx
- * @author drose
- * @date 2003-10-14
- */
-
-#include "subdivSegment.h"
-
-
-
-
-/**
- * Performs a standard binary search. This utility function is used below.
- */
-static int
-binary_search(double val, const double *array, int bot, int top) {
- if (top < bot) {
- return bot;
- }
- int mid = (bot + top)/2;
-
- if (array[mid] < val) {
- return binary_search(val, array, mid+1, top);
- } else {
- return binary_search(val, array, bot, mid-1);
- }
-}
-
-
-/**
- * Applies _num_cuts cuts to the segment.
- */
-void SubdivSegment::
-cut() {
- int c;
- double ct = get_score();
-
- _cuts.erase(_cuts.begin(), _cuts.end());
- int last = _f;
- for (c = 1; c < _num_cuts+1; c++) {
- double val = (double)c * ct / (double)(_num_cuts+1) + _cint[_f];
- int i = binary_search(val, _cint, _f, _t);
- if (i != last && i < _t) {
- _cuts.push_back(i);
- }
- last = i;
- }
-
- while ((int)_cuts.size() < _num_cuts) {
- // Do we have any extra? Assign them into likely places.
- int last = _f;
- int mc = -1;
- int mv = 0;
- for (c = 0; c < (int)_cuts.size(); c++) {
- if (mc == -1 || _cuts[c] - last > mv) {
- mc = c;
- mv = _cuts[c] - last;
- }
- last = _cuts[c];
- }
-
- if (mc==-1) {
- // Surrender.
- return;
- }
- if (mc==0) {
- _cuts.insert(_cuts.begin() + mc, (_cuts[mc] + _f) / 2);
- } else {
- _cuts.insert(_cuts.begin() + mc, (_cuts[mc] + _cuts[mc-1]) / 2);
- }
- }
-}
diff --git a/pandatool/src/egg-qtess/subdivSegment.h b/pandatool/src/egg-qtess/subdivSegment.h
deleted file mode 100644
index abe6e58a..00000000
--- a/pandatool/src/egg-qtess/subdivSegment.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file subdivSegment.h
- * @author drose
- * @date 2003-10-14
- */
-
-#ifndef SUBDIVSEGMENT_H
-#define SUBDIVSEGMENT_H
-
-#include "pandatoolbase.h"
-#include "pvector.h"
-#include "vector_int.h"
-
-/**
- * Represents a single hypothetical subdivided segment, under consideration by
- * the IsoPlacer.
- */
-class SubdivSegment {
-public:
- INLINE SubdivSegment(const double *cint, int f, int t);
-
- INLINE double get_score() const;
- INLINE double get_need() const;
- INLINE bool operator < (const SubdivSegment &other) const;
-
- void cut();
-
- const double *_cint;
- int _f, _t;
- int _num_cuts;
- vector_int _cuts;
-};
-
-#include "subdivSegment.I"
-
-#endif
diff --git a/pandatool/src/eggbase/CMakeLists.txt b/pandatool/src/eggbase/CMakeLists.txt
deleted file mode 100644
index 892e8bb8..00000000
--- a/pandatool/src/eggbase/CMakeLists.txt
+++ /dev/null
@@ -1,33 +0,0 @@
-if(NOT HAVE_EGG)
- return()
-endif()
-
-set(P3EGGBASE_HEADERS
- eggBase.h eggConverter.h eggFilter.h
- eggMakeSomething.h
- eggMultiBase.h eggMultiFilter.h
- eggReader.h eggSingleBase.h
- eggToSomething.h eggWriter.h
- somethingToEgg.h
-)
-
-set(P3EGGBASE_SOURCES
- eggBase.cxx eggConverter.cxx eggFilter.cxx
- eggMakeSomething.cxx
- eggMultiBase.cxx
- eggMultiFilter.cxx eggReader.cxx eggSingleBase.cxx
- eggToSomething.cxx
- eggWriter.cxx somethingToEgg.cxx
-)
-
-composite_sources(p3eggbase P3EGGBASE_SOURCES)
-add_library(p3eggbase STATIC ${P3EGGBASE_HEADERS} ${P3EGGBASE_SOURCES})
-target_link_libraries(p3eggbase p3progbase p3converter)
-
-install(TARGETS p3eggbase
- EXPORT ToolsDevel COMPONENT ToolsDevel
- DESTINATION ${CMAKE_INSTALL_LIBDIR}
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
- INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/panda3d
- ARCHIVE COMPONENT ToolsDevel)
-install(FILES ${P3EGGBASE_HEADERS} COMPONENT ToolsDevel DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/panda3d)
diff --git a/pandatool/src/eggbase/eggBase.cxx b/pandatool/src/eggbase/eggBase.cxx
deleted file mode 100644
index 83d07a0a..00000000
--- a/pandatool/src/eggbase/eggBase.cxx
+++ /dev/null
@@ -1,405 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggBase.cxx
- * @author drose
- * @date 2000-02-14
- */
-
-#include "eggBase.h"
-
-#include "eggGroupNode.h"
-#include "eggTexture.h"
-#include "eggFilenameNode.h"
-#include "eggComment.h"
-#include "dcast.h"
-#include "string_utils.h"
-
-using std::string;
-
-/**
- *
- */
-EggBase::
-EggBase() {
- add_option
- ("cs", "coordinate-system", 80,
- "Specify the coordinate system to operate in. This may be one of "
- "'y-up', 'z-up', 'y-up-left', or 'z-up-left'.",
- &EggBase::dispatch_coordinate_system,
- &_got_coordinate_system, &_coordinate_system);
-
- _normals_mode = NM_preserve;
- _normals_threshold = 0.0;
-
- _got_tbnall = false;
- _got_tbnauto = false;
- _make_points = false;
-
- _got_transform = false;
- _transform = LMatrix4d::ident_mat();
-
- _got_coordinate_system = false;
- _coordinate_system = CS_yup_right;
-
- _noabs = false;
-}
-
-/**
- * Adds -no, -np, etc. as valid options for this program. If the user
- * specifies one of the options on the command line, the normals will be
- * adjusted when the egg file is written out.
- */
-void EggBase::
-add_normals_options() {
- static NormalsMode strip = NM_strip;
- static NormalsMode polygon = NM_polygon;
- static NormalsMode vertex = NM_vertex;
- static NormalsMode preserve = NM_preserve;
-
- add_option
- ("no", "", 48,
- "Strip all normals.",
- &EggBase::dispatch_normals, nullptr, &strip);
-
- add_option
- ("np", "", 48,
- "Strip existing normals and redefine polygon normals.",
- &EggBase::dispatch_normals, nullptr, &polygon);
-
- add_option
- ("nv", "threshold", 48,
- "Strip existing normals and redefine vertex normals. Consider an edge "
- "between adjacent polygons to be smooth if the angle between them "
- "is less than threshold degrees.",
- &EggBase::dispatch_normals, nullptr, &vertex);
-
- add_option
- ("nn", "", 48,
- "Preserve normals exactly as they are. This is the default.",
- &EggBase::dispatch_normals, nullptr, &preserve);
-
- add_option
- ("tbn", "name", 48,
- "Compute tangent and binormal for the named texture coordinate "
- "set(s). The name may include wildcard characters such as * and ?. "
- "The normal must already exist or have been computed via one of the "
- "above options. The tangent and binormal are used to implement "
- "bump mapping and related texture-based lighting effects. This option "
- "may be repeated as necessary to name multiple texture coordinate sets.",
- &EggBase::dispatch_vector_string, nullptr, &_tbn_names);
-
- add_option
- ("tbnall", "", 48,
- "Compute tangent and binormal for all texture coordinate "
- "sets. This is equivalent to -tbn \"*\".",
- &EggBase::dispatch_none, &_got_tbnall);
-
- add_option
- ("tbnauto", "", 48,
- "Compute tangent and binormal for all normal maps. ",
- &EggBase::dispatch_none, &_got_tbnauto);
-}
-
-/**
- * Adds -points as a valid option for this program.
- */
-void EggBase::
-add_points_options() {
- add_option
- ("points", "", 46,
- "Construct entries for any unreferenced vertices, to make them visible.",
- &EggBase::dispatch_none, &_make_points);
-}
-
-/**
- * Adds -TS, -TT, etc. as valid options for this program. If the user
- * specifies one of the options on the command line, the data will be
- * transformed when the egg file is written out.
- */
-void EggBase::
-add_transform_options() {
- add_option
- ("TS", "sx[,sy,sz]", 49,
- "Scale the model uniformly by the given factor (if only one number "
- "is given) or in each axis by sx, sy, sz (if three numbers are given).",
- &EggBase::dispatch_scale, &_got_transform, &_transform);
-
- add_option
- ("TR", "x,y,z", 49,
- "Rotate the model x degrees about the x axis, then y degrees about the "
- "y axis, and then z degrees about the z axis.",
- &EggBase::dispatch_rotate_xyz, &_got_transform, &_transform);
-
- add_option
- ("TA", "angle,x,y,z", 49,
- "Rotate the model angle degrees counterclockwise about the given "
- "axis.",
- &EggBase::dispatch_rotate_axis, &_got_transform, &_transform);
-
- add_option
- ("TT", "x,y,z", 49,
- "Translate the model by the indicated amount.\n\n"
- "All transformation options (-TS, -TR, -TA, -TT) are cumulative and are "
- "applied in the order they are encountered on the command line.",
- &EggBase::dispatch_translate, &_got_transform, &_transform);
-}
-
-/**
- * Recursively walks the egg hierarchy. Any filenames encountered are
- * replaced according to the indicated PathReplace.
- */
-void EggBase::
-convert_paths(EggNode *node, PathReplace *path_replace,
- const DSearchPath &additional_path) {
- if (node->is_of_type(EggTexture::get_class_type())) {
- EggTexture *egg_tex = DCAST(EggTexture, node);
- Filename fullpath, outpath;
- path_replace->full_convert_path(egg_tex->get_filename(), additional_path,
- fullpath, outpath);
- egg_tex->set_filename(outpath);
- egg_tex->set_fullpath(fullpath);
-
- if (egg_tex->has_alpha_filename()) {
- Filename alpha_fullpath, alpha_outpath;
- path_replace->full_convert_path(egg_tex->get_alpha_filename(), additional_path,
- alpha_fullpath, alpha_outpath);
- egg_tex->set_alpha_filename(alpha_outpath);
- egg_tex->set_alpha_fullpath(alpha_fullpath);
- }
-
- } else if (node->is_of_type(EggFilenameNode::get_class_type())) {
- EggFilenameNode *egg_fnode = DCAST(EggFilenameNode, node);
-
- Filename fullpath, outpath;
- path_replace->full_convert_path(egg_fnode->get_filename(), additional_path,
- fullpath, outpath);
- egg_fnode->set_filename(outpath);
- egg_fnode->set_fullpath(fullpath);
-
- } else if (node->is_of_type(EggGroupNode::get_class_type())) {
- EggGroupNode *egg_group = DCAST(EggGroupNode, node);
- EggGroupNode::const_iterator ci;
- for (ci = egg_group->begin(); ci != egg_group->end(); ++ci) {
- convert_paths(*ci, path_replace, additional_path);
- }
- }
-}
-
-/**
- * Inserts a comment into the beginning of the indicated egg file
- * corresponding to the command line that invoked this program.
- *
- * Normally this function is called automatically when appropriate by
- * EggWriter, and it's not necessary to call it explicitly.
- */
-void EggBase::
-append_command_comment(EggData *data) {
- append_command_comment(data, get_exec_command());
-}
-
-/**
- * Inserts a comment into the beginning of the indicated egg file
- * corresponding to the command line that invoked this program.
- *
- * Normally this function is called automatically when appropriate by
- * EggWriter, and it's not necessary to call it explicitly.
- */
-void EggBase::
-append_command_comment(EggData *data, const string &comment) {
- data->insert(data->begin(), new EggComment("", comment));
-}
-
-/**
- * Accepts one of -no, -np, etc. and sets _normals_mode as indicated. The
- * void * argument is a pointer to a NormalsMode variable that indicates which
- * switch was passed.
- */
-bool EggBase::
-dispatch_normals(ProgramBase *self, const string &opt, const string &arg, void *mode) {
- EggBase *base = (EggBase *)self;
- return base->ns_dispatch_normals(opt, arg, mode);
-}
-
-/**
- * Accepts one of -no, -np, etc. and sets _normals_mode as indicated. The
- * void * argument is a pointer to a NormalsMode variable that indicates which
- * switch was passed.
- */
-bool EggBase::
-ns_dispatch_normals(const string &opt, const string &arg, void *mode) {
- _normals_mode = *(NormalsMode *)mode;
-
- if (_normals_mode == NM_vertex) {
- if (!string_to_double(arg, _normals_threshold)) {
- nout << "Invalid numeric parameter for -" << opt << ": "
- << arg << "\n";
- return false;
- }
- }
-
- return true;
-}
-
-/**
- * Handles -TS, which specifies a scale transform. Var is an LMatrix4d.
- */
-bool EggBase::
-dispatch_scale(const string &opt, const string &arg, void *var) {
- LMatrix4d *transform = (LMatrix4d *)var;
-
- vector_string words;
- tokenize(arg, words, ",");
-
- double sx, sy, sz;
-
- bool okflag = false;
- if (words.size() == 3) {
- okflag =
- string_to_double(words[0], sx) &&
- string_to_double(words[1], sy) &&
- string_to_double(words[2], sz);
-
- } else if (words.size() == 1) {
- okflag =
- string_to_double(words[0], sx);
- sy = sz = sx;
- }
-
- if (!okflag) {
- nout << "-" << opt
- << " requires one or three numbers separated by commas.\n";
- return false;
- }
-
- *transform = (*transform) * LMatrix4d::scale_mat(sx, sy, sz);
-
- return true;
-}
-
-/**
- * Handles -TR, which specifies a rotate transform about the three cardinal
- * axes. Var is an LMatrix4d.
- */
-bool EggBase::
-dispatch_rotate_xyz(ProgramBase *self, const string &opt, const string &arg, void *var) {
- EggBase *base = (EggBase *)self;
- return base->ns_dispatch_rotate_xyz(opt, arg, var);
-}
-
-/**
- * Handles -TR, which specifies a rotate transform about the three cardinal
- * axes. Var is an LMatrix4d.
- */
-bool EggBase::
-ns_dispatch_rotate_xyz(const string &opt, const string &arg, void *var) {
- LMatrix4d *transform = (LMatrix4d *)var;
-
- vector_string words;
- tokenize(arg, words, ",");
-
- LVecBase3d xyz;
-
- bool okflag = false;
- if (words.size() == 3) {
- okflag =
- string_to_double(words[0], xyz[0]) &&
- string_to_double(words[1], xyz[1]) &&
- string_to_double(words[2], xyz[2]);
- }
-
- if (!okflag) {
- nout << "-" << opt
- << " requires three numbers separated by commas.\n";
- return false;
- }
-
- LMatrix4d mat =
- LMatrix4d::rotate_mat(xyz[0], LVector3d(1.0, 0.0, 0.0), _coordinate_system) *
- LMatrix4d::rotate_mat(xyz[1], LVector3d(0.0, 1.0, 0.0), _coordinate_system) *
- LMatrix4d::rotate_mat(xyz[2], LVector3d(0.0, 0.0, 1.0), _coordinate_system);
-
- *transform = (*transform) * mat;
-
- return true;
-}
-
-/**
- * Handles -TA, which specifies a rotate transform about an arbitrary axis.
- * Var is an LMatrix4d.
- */
-bool EggBase::
-dispatch_rotate_axis(ProgramBase *self, const string &opt, const string &arg, void *var) {
- EggBase *base = (EggBase *)self;
- return base->ns_dispatch_rotate_axis(opt, arg, var);
-}
-
-/**
- * Handles -TA, which specifies a rotate transform about an arbitrary axis.
- * Var is an LMatrix4d.
- */
-bool EggBase::
-ns_dispatch_rotate_axis(const string &opt, const string &arg, void *var) {
- LMatrix4d *transform = (LMatrix4d *)var;
-
- vector_string words;
- tokenize(arg, words, ",");
-
- double angle;
- LVecBase3d axis;
-
- bool okflag = false;
- if (words.size() == 4) {
- okflag =
- string_to_double(words[0], angle) &&
- string_to_double(words[1], axis[0]) &&
- string_to_double(words[2], axis[1]) &&
- string_to_double(words[3], axis[2]);
- }
-
- if (!okflag) {
- nout << "-" << opt
- << " requires four numbers separated by commas.\n";
- return false;
- }
-
- *transform = (*transform) * LMatrix4d::rotate_mat(angle, axis, _coordinate_system);
-
- return true;
-}
-
-/**
- * Handles -TT, which specifies a translate transform. Var is an LMatrix4d.
- */
-bool EggBase::
-dispatch_translate(const string &opt, const string &arg, void *var) {
- LMatrix4d *transform = (LMatrix4d *)var;
-
- vector_string words;
- tokenize(arg, words, ",");
-
- LVector3d trans;
-
- bool okflag = false;
- if (words.size() == 3) {
- okflag =
- string_to_double(words[0], trans[0]) &&
- string_to_double(words[1], trans[1]) &&
- string_to_double(words[2], trans[2]);
- }
-
- if (!okflag) {
- nout << "-" << opt
- << " requires three numbers separated by commas.\n";
- return false;
- }
-
- *transform = (*transform) * LMatrix4d::translate_mat(trans);
-
- return true;
-}
diff --git a/pandatool/src/eggbase/eggBase.h b/pandatool/src/eggbase/eggBase.h
deleted file mode 100644
index 4c6b1567..00000000
--- a/pandatool/src/eggbase/eggBase.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggBase.h
- * @author drose
- * @date 2000-02-14
- */
-
-#ifndef EGGBASE_H
-#define EGGBASE_H
-
-#include "pandatoolbase.h"
-
-#include "programBase.h"
-#include "eggData.h"
-
-/**
- * This is a base class for both EggSingleBase and EggMultiBase. Don't
- * inherit directly from this; use one of those two classes instead.
- *
- * This is just a base class; see EggReader, EggWriter, or EggFilter according
- * to your particular I/O needs.
- */
-class EggBase : public ProgramBase {
-public:
- EggBase();
-
- void add_normals_options();
- void add_points_options();
- void add_transform_options();
-
- static void convert_paths(EggNode *node, PathReplace *path_replace,
- const DSearchPath &additional_path);
-
-protected:
- void append_command_comment(EggData *_data);
- static void append_command_comment(EggData *_data, const std::string &comment);
-
- static bool dispatch_normals(ProgramBase *self, const std::string &opt, const std::string &arg, void *mode);
- bool ns_dispatch_normals(const std::string &opt, const std::string &arg, void *mode);
-
- static bool dispatch_scale(const std::string &opt, const std::string &arg, void *var);
- static bool dispatch_rotate_xyz(ProgramBase *self, const std::string &opt, const std::string &arg, void *var);
- bool ns_dispatch_rotate_xyz(const std::string &opt, const std::string &arg, void *var);
- static bool dispatch_rotate_axis(ProgramBase *self, const std::string &opt, const std::string &arg, void *var);
- bool ns_dispatch_rotate_axis(const std::string &opt, const std::string &arg, void *var);
- static bool dispatch_translate(const std::string &opt, const std::string &arg, void *var);
-
-protected:
- enum NormalsMode {
- NM_strip,
- NM_polygon,
- NM_vertex,
- NM_preserve
- };
- NormalsMode _normals_mode;
- double _normals_threshold;
- vector_string _tbn_names;
- bool _got_tbnall;
- bool _got_tbnauto;
-
- bool _make_points;
-
- bool _got_transform;
- LMatrix4d _transform;
-
- bool _got_coordinate_system;
- CoordinateSystem _coordinate_system;
-
- bool _noabs;
-};
-
-#endif
diff --git a/pandatool/src/eggbase/eggConverter.cxx b/pandatool/src/eggbase/eggConverter.cxx
deleted file mode 100644
index 036b7dea..00000000
--- a/pandatool/src/eggbase/eggConverter.cxx
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggConverter.cxx
- * @author drose
- * @date 2000-02-15
- */
-
-#include "eggConverter.h"
-
-/**
- * The first parameter to the constructor should be the one-word name of the
- * alien file format that is to be read or written, for instance "OpenFlight"
- * or "Alias". It's just used in printing error messages and such. The
- * second parameter is the preferred extension of files of this form, if any,
- * with a leading dot.
- */
-EggConverter::
-EggConverter(const std::string &format_name,
- const std::string &preferred_extension,
- bool allow_last_param,
- bool allow_stdout) :
- EggFilter(allow_last_param, allow_stdout),
- _format_name(format_name)
-{
- // Indicate the extension name we expect the user to supply for output
- // files.
- _preferred_extension = preferred_extension;
-}
diff --git a/pandatool/src/eggbase/eggConverter.h b/pandatool/src/eggbase/eggConverter.h
deleted file mode 100644
index 3922a6b8..00000000
--- a/pandatool/src/eggbase/eggConverter.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggConverter.h
- * @author drose
- * @date 2000-02-15
- */
-
-#ifndef EGGCONVERTER_H
-#define EGGCONVERTER_H
-
-#include "pandatoolbase.h"
-
-#include "eggFilter.h"
-
-/**
- * This is a general base class for programs that convert between egg files
- * and some other format. See EggToSomething and SomethingToEgg.
- */
-class EggConverter : public EggFilter {
-public:
- EggConverter(const std::string &format_name,
- const std::string &preferred_extension = std::string(),
- bool allow_last_param = true,
- bool allow_stdout = true);
-
-protected:
- std::string _format_name;
-};
-
-#endif
diff --git a/pandatool/src/eggbase/eggFilter.cxx b/pandatool/src/eggbase/eggFilter.cxx
deleted file mode 100644
index ef6c2967..00000000
--- a/pandatool/src/eggbase/eggFilter.cxx
+++ /dev/null
@@ -1,72 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggFilter.cxx
- * @author drose
- * @date 2000-02-14
- */
-
-#include "eggFilter.h"
-
-/**
- *
- */
-EggFilter::
-EggFilter(bool allow_last_param, bool allow_stdout) :
- EggWriter(allow_last_param, allow_stdout)
-{
- // The default path store for programs that read egg files and write them
- // again is PS_relative.
- _path_replace->_path_store = PS_relative;
-
- clear_runlines();
- if (allow_last_param) {
- add_runline("[opts] input.egg output.egg");
- }
- add_runline("[opts] -o output.egg input.egg");
- if (allow_stdout) {
- add_runline("[opts] input.egg >output.egg");
- }
-
- redescribe_option
- ("cs",
- "Specify the coordinate system of the resulting egg file. This may be "
- "one of 'y-up', 'z-up', 'y-up-left', or 'z-up-left'. The default "
- "is the same coordinate system as the input egg file. If this is "
- "different from the input egg file, a conversion will be performed.");
-}
-
-
-/**
- * Does something with the additional arguments on the command line (after all
- * the -options have been parsed). Returns true if the arguments are good,
- * false otherwise.
- */
-bool EggFilter::
-handle_args(ProgramBase::Args &args) {
- if (!check_last_arg(args, 1)) {
- return false;
- }
-
- if (!_got_path_directory && _got_output_filename) {
- // Put in the name of the output directory.
- _path_replace->_path_directory = _output_filename.get_dirname();
- }
-
- return EggReader::handle_args(args);
-}
-
-/**
- *
- */
-bool EggFilter::
-post_command_line() {
- // writer first, so we can fiddle with the _path_replace options if
- // necessary.
- return EggWriter::post_command_line() && EggReader::post_command_line();
-}
diff --git a/pandatool/src/eggbase/eggFilter.h b/pandatool/src/eggbase/eggFilter.h
deleted file mode 100644
index ebd6c87d..00000000
--- a/pandatool/src/eggbase/eggFilter.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggFilter.h
- * @author drose
- * @date 2000-02-14
- */
-
-#ifndef EGGFILTER_H
-#define EGGFILTER_H
-
-#include "pandatoolbase.h"
-
-#include "eggReader.h"
-#include "eggWriter.h"
-
-/**
- * This is the base class for a program that reads an egg file, operates on
- * it, and writes another egg file out.
- */
-class EggFilter : public EggReader, public EggWriter {
-public:
- EggFilter(bool allow_last_param = false, bool allow_stdout = true);
-
-protected:
- virtual bool handle_args(Args &args);
- virtual bool post_command_line();
-};
-
-#endif
diff --git a/pandatool/src/eggbase/eggMakeSomething.cxx b/pandatool/src/eggbase/eggMakeSomething.cxx
deleted file mode 100644
index 52543ec0..00000000
--- a/pandatool/src/eggbase/eggMakeSomething.cxx
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggMakeSomething.cxx
- * @author drose
- * @date 2003-10-01
- */
-
-#include "eggMakeSomething.h"
-
-/**
- *
- */
-EggMakeSomething::
-EggMakeSomething() :
- EggWriter(true, true)
-{
- add_normals_options();
- add_transform_options();
-}
diff --git a/pandatool/src/eggbase/eggMakeSomething.h b/pandatool/src/eggbase/eggMakeSomething.h
deleted file mode 100644
index b34aa348..00000000
--- a/pandatool/src/eggbase/eggMakeSomething.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggMakeSomething.h
- * @author drose
- * @date 2003-10-01
- */
-
-#ifndef EGGMAKESOMETHING_H
-#define EGGMAKESOMETHING_H
-
-#include "pandatoolbase.h"
-
-#include "eggWriter.h"
-
-/**
- * A base class for a family of programs that generate egg models of various
- * fundamental shapes.
- */
-class EggMakeSomething : public EggWriter {
-public:
- EggMakeSomething();
-};
-
-#endif
diff --git a/pandatool/src/eggbase/eggMultiBase.cxx b/pandatool/src/eggbase/eggMultiBase.cxx
deleted file mode 100644
index 426b62a9..00000000
--- a/pandatool/src/eggbase/eggMultiBase.cxx
+++ /dev/null
@@ -1,187 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggMultiBase.cxx
- * @author drose
- * @date 2000-11-02
- */
-
-#include "eggMultiBase.h"
-#include "eggBase.h"
-#include "eggData.h"
-#include "eggComment.h"
-#include "filename.h"
-#include "dSearchPath.h"
-
-/**
- *
- */
-EggMultiBase::
-EggMultiBase() {
- add_option
- ("f", "", 80,
- "Force complete loading: load up the egg file along with all of its "
- "external references.",
- &EggMultiBase::dispatch_none, &_force_complete);
-
- add_option
- ("noabs", "", 0,
- "Don't allow any of the named egg files to have absolute pathnames. "
- "If any do, abort with an error. This option is designed to help "
- "detect errors when populating or building a standalone model tree, "
- "which should be self-contained and include only relative pathnames.",
- &EggMultiBase::dispatch_none, &_noabs);
-}
-
-/**
- * Performs any processing of the egg file(s) that is appropriate before
- * writing them out. This includes any normal adjustments the user requested
- * via -np, etc.
- *
- * Normally, you should not need to call this function directly;
- * write_egg_files() calls it for you. You should call this only if you do
- * not use write_egg_files() to write out the resulting egg files.
- */
-void EggMultiBase::
-post_process_egg_files() {
- if (_eggs.empty()) {
- return;
- }
-
- Eggs::iterator ei;
- if (_got_transform) {
- nout << "Applying transform matrix:\n";
- _transform.write(nout, 2);
- LVecBase3d scale, hpr, translate;
- if (decompose_matrix(_transform, scale, hpr, translate,
- _eggs[0]->get_coordinate_system())) {
- nout << "(scale " << scale << ", hpr " << hpr << ", translate "
- << translate << ")\n";
- }
- for (ei = _eggs.begin(); ei != _eggs.end(); ++ei) {
- (*ei)->transform(_transform);
- }
- }
-
- if (_make_points) {
- nout << "Making points\n";
- for (ei = _eggs.begin(); ei != _eggs.end(); ++ei) {
- (*ei)->make_point_primitives();
- }
- }
-
- switch (_normals_mode) {
- case NM_strip:
- nout << "Stripping normals.\n";
- for (ei = _eggs.begin(); ei != _eggs.end(); ++ei) {
- (*ei)->strip_normals();
- (*ei)->remove_unused_vertices(true);
- }
- break;
-
- case NM_polygon:
- nout << "Recomputing polygon normals.\n";
- for (ei = _eggs.begin(); ei != _eggs.end(); ++ei) {
- (*ei)->recompute_polygon_normals();
- (*ei)->remove_unused_vertices(true);
- }
- break;
-
- case NM_vertex:
- nout << "Recomputing vertex normals.\n";
- for (ei = _eggs.begin(); ei != _eggs.end(); ++ei) {
- (*ei)->recompute_vertex_normals(_normals_threshold);
- (*ei)->remove_unused_vertices(true);
- }
- break;
-
- case NM_preserve:
- // Do nothing.
- break;
- }
-
- if (_got_tbnall) {
- for (ei = _eggs.begin(); ei != _eggs.end(); ++ei) {
- if ((*ei)->recompute_tangent_binormal(GlobPattern("*"))) {
- (*ei)->remove_unused_vertices(true);
- }
- }
- } else {
- if (_got_tbnauto) {
- for (ei = _eggs.begin(); ei != _eggs.end(); ++ei) {
- if ((*ei)->recompute_tangent_binormal_auto()) {
- (*ei)->remove_unused_vertices(true);
- }
- }
- }
-
- for (vector_string::const_iterator si = _tbn_names.begin();
- si != _tbn_names.end();
- ++si) {
- GlobPattern uv_name(*si);
- nout << "Computing tangent and binormal for \"" << uv_name << "\"\n";
- for (ei = _eggs.begin(); ei != _eggs.end(); ++ei) {
- (*ei)->recompute_tangent_binormal(uv_name);
- (*ei)->remove_unused_vertices(true);
- }
- }
- }
-}
-
-
-/**
- * Allocates and returns a new EggData structure that represents the indicated
- * egg file. If the egg file cannot be read for some reason, returns NULL.
- *
- * This can be overridden by derived classes to control how the egg files are
- * read, or to extend the information stored with each egg structure, by
- * deriving from EggData.
- */
-PT(EggData) EggMultiBase::
-read_egg(const Filename &filename) {
- PT(EggData) data = new EggData;
-
- if (!data->read(filename)) {
- // Failure reading.
- return nullptr;
- }
-
- if (_noabs && data->original_had_absolute_pathnames()) {
- nout << filename.get_basename()
- << " includes absolute pathnames!\n";
- return nullptr;
- }
-
- DSearchPath file_path;
- file_path.append_directory(filename.get_dirname());
-
- // We always resolve filenames first based on the source egg filename, since
- // egg files almost always store relative paths. This is a temporary kludge
- // around integrating the path_replace system with the EggData better.
- // Update: I believe this kludge is obsolete. Commenting out. - Josh.
- // data->resolve_filenames(file_path);
-
- if (_force_complete) {
- if (!data->load_externals()) {
- return nullptr;
- }
- }
-
- // Now resolve the filenames again according to the user's specified
- // _path_replace.
- EggBase::convert_paths(data, _path_replace, file_path);
-
- if (_got_coordinate_system) {
- data->set_coordinate_system(_coordinate_system);
- } else {
- _coordinate_system = data->get_coordinate_system();
- _got_coordinate_system = true;
- }
-
- return data;
-}
diff --git a/pandatool/src/eggbase/eggMultiBase.h b/pandatool/src/eggbase/eggMultiBase.h
deleted file mode 100644
index 1442de61..00000000
--- a/pandatool/src/eggbase/eggMultiBase.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggMultiBase.h
- * @author drose
- * @date 2000-11-02
- */
-
-#ifndef EGGMULTIBASE_H
-#define EGGMULTIBASE_H
-
-#include "pandatoolbase.h"
-
-#include "eggBase.h"
-#include "coordinateSystem.h"
-#include "eggData.h"
-#include "pointerTo.h"
-
-class Filename;
-
-/**
- * This specialization of ProgramBase is intended for programs that read
- * and/or write multiple egg files.
- *
- * See also EggMultiFilter, for a class that also knows how to read a bunch of
- * egg files in and write them out again.
- */
-class EggMultiBase : public EggBase {
-public:
- EggMultiBase();
-
- void post_process_egg_files();
-
-protected:
- virtual PT(EggData) read_egg(const Filename &filename);
-
-protected:
- typedef pvector< PT(EggData) > Eggs;
- Eggs _eggs;
-
- bool _force_complete;
-};
-
-#endif
diff --git a/pandatool/src/eggbase/eggMultiFilter.cxx b/pandatool/src/eggbase/eggMultiFilter.cxx
deleted file mode 100644
index 981c8ad4..00000000
--- a/pandatool/src/eggbase/eggMultiFilter.cxx
+++ /dev/null
@@ -1,210 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggMultiFilter.cxx
- * @author drose
- * @date 2000-11-02
- */
-
-#include "eggMultiFilter.h"
-
-#include "pnotify.h"
-#include "eggData.h"
-
-/**
- *
- */
-EggMultiFilter::
-EggMultiFilter(bool allow_empty) : _allow_empty(allow_empty) {
- clear_runlines();
- add_runline("-o output.egg [opts] input.egg");
- add_runline("-d dirname [opts] file.egg [file.egg ...]");
- add_runline("-inplace [opts] file.egg [file.egg ...]");
- add_runline("-inf input_list_filename [opts]");
-
- add_option
- ("o", "filename", 50,
- "Specify the filename to which the resulting egg file will be written. "
- "This is only valid when there is only one input egg file on the command "
- "line. If you want to process multiple files simultaneously, you must "
- "use either -d or -inplace.",
- &EggMultiFilter::dispatch_filename, &_got_output_filename, &_output_filename);
-
- add_option
- ("d", "dirname", 50,
- "Specify the name of the directory in which to write the resulting egg "
- "files. If you are processing only one egg file, this may be omitted "
- "in lieu of the -o option. If you are processing multiple egg files, "
- "this may be omitted only if you specify -inplace instead.",
- &EggMultiFilter::dispatch_filename, &_got_output_dirname, &_output_dirname);
-
- add_option
- ("inplace", "", 50,
- "If this option is given, the input egg files will be rewritten in "
- "place with the results. This obviates the need to specify -d "
- "for an output directory; however, it's risky because the original "
- "input egg files are lost.",
- &EggMultiFilter::dispatch_none, &_inplace);
-
- add_option
- ("inf", "filename", 95,
- "Reads input args from a text file instead of the command line. "
- "Useful for really, really large lists of args that break the "
- "OS-imposed limits on the length of command lines.",
- &EggMultiFilter::dispatch_filename, &_got_input_filename, &_input_filename);
-
- // Derived programs will set this true when they discover some command-line
- // option that will prevent the program from generating output. This
- // removes some checks for an output specification in handle_args.
- _read_only = false;
-}
-
-
-/**
- * Does something with the additional arguments on the command line (after all
- * the -options have been parsed). Returns true if the arguments are good,
- * false otherwise.
- */
-bool EggMultiFilter::
-handle_args(ProgramBase::Args &args) {
- if (_got_input_filename) {
- nout << "Populating args from input file: " << _input_filename << "\n";
- // Makes sure the file is set is_text
- _filename = Filename::text_filename(_input_filename);
- std::ifstream input;
- if (!_filename.open_read(input)) {
- nout << "Error opening file: " << _input_filename << "\n";
- return false;
- }
- std::string line;
- // File should be a space-delimited list of egg files
- while (std::getline(input, line, ' ')) {
- args.push_back(line);
- }
- }
- if (args.empty()) {
- if (!_allow_empty) {
- nout << "You must specify the egg file(s) to read on the command line.\n";
- return false;
- }
- } else {
- // These only apply if we have specified any egg files.
- if (_got_output_filename && args.size() == 1) {
- if (_got_output_dirname) {
- nout << "Cannot specify both -o and -d.\n";
- return false;
- } else if (_inplace) {
- nout << "Cannot specify both -o and -inplace.\n";
- return false;
- }
-
- } else {
- if (_got_output_filename) {
- nout << "Cannot use -o when multiple egg files are specified.\n";
- return false;
- }
-
- if (_got_output_dirname && _inplace) {
- nout << "Cannot specify both -inplace and -d.\n";
- return false;
-
- } else if (!_got_output_dirname && !_inplace) {
- if (!_read_only) {
- nout << "You must specify either -inplace or -d.\n";
- return false;
- }
- }
- }
- }
-
- // We need to set up _path_replace before we call read_egg().
- if (!_got_path_directory) {
- // Put in the name of the output directory.
- if (_got_output_filename) {
- _path_replace->_path_directory = _output_filename.get_dirname();
- } else if (_got_output_dirname) {
- _path_replace->_path_directory = _output_dirname;
- }
- }
-
- Args::const_iterator ai;
- for (ai = args.begin(); ai != args.end(); ++ai) {
- PT(EggData) data = read_egg(Filename::from_os_specific(*ai));
- if (data == nullptr) {
- // Rather than returning false, we simply exit here, so the ProgramBase
- // won't try to tell the user how to run the program just because we got
- // a bad egg file.
- exit(1);
- }
-
- _eggs.push_back(data);
- }
-
- return true;
-}
-
-/**
- *
- */
-bool EggMultiFilter::
-post_command_line() {
- Eggs::iterator ei;
- for (ei = _eggs.begin(); ei != _eggs.end(); ++ei) {
- EggData *data = (*ei);
- if (_got_coordinate_system) {
- data->set_coordinate_system(_coordinate_system);
- }
- append_command_comment(data);
- }
-
- return EggMultiBase::post_command_line();
-}
-
-/**
- * Returns the output filename of the egg file with the given input filename.
- * This is based on the user's choice of -inplace, -o, or -d.
- */
-Filename EggMultiFilter::
-get_output_filename(const Filename &source_filename) const {
- if (_got_output_filename) {
- nassertr(!_inplace && !_got_output_dirname && _eggs.size() == 1, Filename());
- return _output_filename;
-
- } else if (_got_output_dirname) {
- nassertr(!_inplace, Filename());
- Filename result = source_filename;
- result.set_dirname(_output_dirname);
- return result;
- }
-
- nassertr(_inplace, Filename());
- return source_filename;
-}
-
-/**
- * Writes out all of the egg files in the _eggs vector, to the output
- * directory if one is specified, or over the input files if -inplace was
- * specified.
- */
-void EggMultiFilter::
-write_eggs() {
- nassertv(!_read_only);
- post_process_egg_files();
- Eggs::iterator ei;
- for (ei = _eggs.begin(); ei != _eggs.end(); ++ei) {
- EggData *data = (*ei);
- Filename filename = get_output_filename(data->get_egg_filename());
-
- nout << "Writing " << filename << "\n";
- filename.make_dir();
- if (!data->write_egg(filename)) {
- // Error writing an egg file; abort.
- exit(1);
- }
- }
-}
diff --git a/pandatool/src/eggbase/eggMultiFilter.h b/pandatool/src/eggbase/eggMultiFilter.h
deleted file mode 100644
index 402e5183..00000000
--- a/pandatool/src/eggbase/eggMultiFilter.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggMultiFilter.h
- * @author drose
- * @date 2000-11-02
- */
-
-#ifndef EGGMULTIFILTER_H
-#define EGGMULTIFILTER_H
-
-#include "pandatoolbase.h"
-
-#include "eggMultiBase.h"
-
-/**
- * This is a base class for a program that reads in a number of egg files,
- * operates on them, and writes them out again (presumably to a different
- * directory).
- */
-class EggMultiFilter : public EggMultiBase {
-public:
- EggMultiFilter(bool allow_empty = false);
-
-protected:
- virtual bool handle_args(Args &args);
- virtual bool post_command_line();
-
- Filename get_output_filename(const Filename &source_filename) const;
- virtual void write_eggs();
-
-protected:
- bool _allow_empty;
- bool _got_output_filename;
- Filename _output_filename;
- bool _got_output_dirname;
- Filename _output_dirname;
- bool _inplace;
- Filename _input_filename;
- Filename _filename;
- bool _got_input_filename;
-
- bool _read_only;
-};
-
-#endif
diff --git a/pandatool/src/eggbase/eggReader.cxx b/pandatool/src/eggbase/eggReader.cxx
deleted file mode 100644
index 4146189a..00000000
--- a/pandatool/src/eggbase/eggReader.cxx
+++ /dev/null
@@ -1,375 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggReader.cxx
- * @author drose
- * @date 2000-02-14
- */
-
-#include "eggReader.h"
-
-#include "pnmImage.h"
-#include "config_putil.h"
-#include "eggTextureCollection.h"
-#include "eggGroup.h"
-#include "eggGroupNode.h"
-#include "eggSwitchCondition.h"
-#include "string_utils.h"
-#include "dcast.h"
-
-/**
- *
- */
-EggReader::
-EggReader() {
- clear_runlines();
- add_runline("[opts] input.egg");
-
- redescribe_option
- ("cs",
- "Specify the coordinate system to operate in. This may be "
- " one of 'y-up', 'z-up', 'y-up-left', or 'z-up-left'. The default "
- "is the coordinate system of the input egg file.");
-
- add_option
- ("f", "", 80,
- "Force complete loading: load up the egg file along with all of its "
- "external references.",
- &EggReader::dispatch_none, &_force_complete);
-
- add_option
- ("noabs", "", 0,
- "Don't allow the input egg file to have absolute pathnames. "
- "If it does, abort with an error. This option is designed to help "
- "detect errors when populating or building a standalone model tree, "
- "which should be self-contained and include only relative pathnames.",
- &EggReader::dispatch_none, &_noabs);
-
- _tex_type = nullptr;
- _delod = -1.0;
-
- _got_tex_dirname = false;
- _got_tex_extension = false;
- _exit_on_failure = true;
-}
-
-/**
- * Adds -td, -te, etc. as valid options for this program. If the user
- * specifies one of the options on the command line, the textures will be
- * copied and converted as each egg file is read.
- *
- * Note that if you call this function to add these options, you must call
- * do_reader_options() at the appropriate point before or during processing to
- * execute the options if the user specified them.
- */
-void EggReader::
-add_texture_options() {
- add_option
- ("td", "dirname", 40,
- "Copy textures to the indicated directory. The copy is performed "
- "only if the destination file does not exist or is older than the "
- "source file.",
- &EggReader::dispatch_filename, &_got_tex_dirname, &_tex_dirname);
-
- add_option
- ("te", "ext", 40,
- "Rename textures to have the indicated extension. This also "
- "automatically copies them to the new filename (possibly in a "
- "different directory if -td is also specified), and may implicitly "
- "convert to a different image format according to the extension.",
- &EggReader::dispatch_string, &_got_tex_extension, &_tex_extension);
-
- add_option
- ("tt", "type", 40,
- "Explicitly specifies the image format to convert textures to "
- "when copying them via -td or -te. Normally, this is unnecessary as "
- "the image format can be determined by the extension, but sometimes "
- "the extension is insufficient to unambiguously specify an image "
- "type.",
- &EggReader::dispatch_image_type, nullptr, &_tex_type);
-}
-
-/**
- * Adds -delod as a valid option for this program.
- *
- * Note that if you call this function to add these options, you must call
- * do_reader_options() at the appropriate point before or during processing to
- * execute the options if the user specified them.
- */
-void EggReader::
-add_delod_options(double default_delod) {
- _delod = default_delod;
-
- if (default_delod < 0) {
- add_option
- ("delod", "dist", 40,
- "Eliminate LOD's by choosing the level that would be appropriate for "
- "a camera at the indicated fixed distance from each LOD. "
- "Use -delod -1 to keep all the LOD's as they are, which is "
- "the default.\n",
- &EggReader::dispatch_double, nullptr, &_delod);
-
- } else {
- add_option
- ("delod", "dist", 40,
- "Eliminate LOD's by choosing the level that would be appropriate for "
- "a camera at the indicated fixed distance from each LOD. "
- "Use -delod -1 to keep all the LOD's as they are. The default value "
- "is " + format_string(default_delod) + ".",
- &EggReader::dispatch_double, nullptr, &_delod);
- }
-}
-
-/**
- * Sets whether the reader will quit the program upon encountering a fatal error.
- *
- * If true, the entire program will quit as soon as an egg loading error occurs.
- */
-void EggReader::
-set_exit_on_failure(bool exit_on_failure) {
- _exit_on_failure = exit_on_failure;
-}
-
-/**
- * Returns this object as an EggReader pointer, if it is in fact an EggReader,
- * or NULL if it is not.
- *
- * This is intended to work around the C++ limitation that prevents downcasts
- * past virtual inheritance. Since both EggReader and EggWriter inherit
- * virtually from EggSingleBase, we need functions like this to downcast to
- * the appropriate pointer.
- */
-EggReader *EggReader::
-as_reader() {
- return this;
-}
-
-/**
- * Performs any processing of the egg file that is appropriate after reading
- * it in.
- *
- * Normally, you should not need to call this function directly; it is called
- * automatically at startup.
- */
-void EggReader::
-pre_process_egg_file() {
-}
-
-/**
- *
- */
-bool EggReader::
-handle_args(ProgramBase::Args &args) {
- if (args.empty()) {
- nout << "You must specify the egg file(s) to read on the command line.\n";
- return false;
- }
-
- // Any separate egg files that are listed on the command line will get
- // implicitly loaded up into one big egg file.
-
- if (!args.empty()) {
- _data->set_egg_filename(Filename::from_os_specific(args[0]));
- }
- Args::const_iterator ai;
- for (ai = args.begin(); ai != args.end(); ++ai) {
- Filename filename = Filename::from_os_specific(*ai);
-
- EggData file_data;
- if (filename != "-") {
- if (!file_data.read(filename)) {
- // Rather than returning false, we simply exit here, so the ProgramBase
- // won't try to tell the user how to run the program just because we got
- // a bad egg file.
- if (_exit_on_failure) {
- exit(1);
- }
- return false;
- }
- } else {
- if (!file_data.read(std::cin)) {
- if (_exit_on_failure) {
- exit(1);
- }
- return false;
- }
- }
-
- if (_noabs && file_data.original_had_absolute_pathnames()) {
- nout << filename.get_basename()
- << " includes absolute pathnames!\n";
- if (_exit_on_failure) {
- exit(1);
- }
- return false;
- }
-
- DSearchPath file_path;
- file_path.append_directory(filename.get_dirname());
-
- if (_force_complete) {
- if (!file_data.load_externals(file_path)) {
- if (_exit_on_failure) {
- exit(1);
- }
- return false;
- }
- }
-
- // Now resolve the filenames again according to the user's specified
- // _path_replace.
- convert_paths(&file_data, _path_replace, file_path);
-
- _data->merge(file_data);
- }
-
- pre_process_egg_file();
-
- return true;
-}
-
-/**
- * This is called after the command line has been completely processed, and it
- * gives the program a chance to do some last-minute processing and validation
- * of the options and arguments. It should return true if everything is fine,
- * false if there is an error.
- */
-bool EggReader::
-post_command_line() {
- return EggSingleBase::post_command_line();
-}
-
-/**
- * Postprocesses the egg file as the user requested according to whatever
- * command-line options are in effect. Returns true if everything is done
- * correctly, false if there was some problem.
- */
-bool EggReader::
-do_reader_options() {
- bool okflag = true;
-
- if (_got_tex_dirname || _got_tex_extension) {
- if (!copy_textures()) {
- okflag = false;
- }
- }
-
- if (_delod >= 0.0) {
- do_delod(_data);
- }
-
- return okflag;
-}
-
-/**
- * Renames and copies the textures referenced in the egg file, if so specified
- * by the -td and -te options. Returns true if all textures are copied
- * successfully, false if any one of them failed.
- */
-bool EggReader::
-copy_textures() {
- bool success = true;
- EggTextureCollection textures;
- textures.find_used_textures(_data);
-
- EggTextureCollection::const_iterator ti;
- for (ti = textures.begin(); ti != textures.end(); ++ti) {
- EggTexture *tex = (*ti);
- Filename orig_filename = tex->get_filename();
- if (!orig_filename.exists()) {
- bool found = orig_filename.resolve_filename(get_model_path());
- if (!found) {
- nout << "Cannot find " << orig_filename << "\n";
- success = false;
- continue;
- }
- }
-
- Filename new_filename = orig_filename;
- if (_got_tex_dirname) {
- new_filename.set_dirname(_tex_dirname);
- }
- if (_got_tex_extension) {
- new_filename.set_extension(_tex_extension);
- }
-
- if (orig_filename != new_filename) {
- tex->set_filename(new_filename);
-
- // The new filename is different; does it need copying?
- int compare =
- orig_filename.compare_timestamps(new_filename, true, true);
- if (compare > 0) {
- // Yes, it does. Copy it!
- nout << "Reading " << orig_filename << "\n";
- PNMImage image;
- if (!image.read(orig_filename)) {
- nout << " unable to read!\n";
- success = false;
- } else {
- nout << "Writing " << new_filename << "\n";
- if (!image.write(new_filename, _tex_type)) {
- nout << " unable to write!\n";
- success = false;
- }
- }
- }
- }
- }
-
- return success;
-}
-
-/**
- * Removes all the LOD's in the egg file by treating the camera as being
- * _delod distance from each LOD. Returns true if this particular group should
- * be preserved, false if it should be removed.
- */
-bool EggReader::
-do_delod(EggNode *node) {
- if (node->is_of_type(EggGroup::get_class_type())) {
- EggGroup *group = DCAST(EggGroup, node);
- if (group->has_lod()) {
- const EggSwitchCondition &cond = group->get_lod();
- if (cond.is_of_type(EggSwitchConditionDistance::get_class_type())) {
- const EggSwitchConditionDistance *dist =
- DCAST(EggSwitchConditionDistance, &cond);
- if (_delod >= dist->_switch_out && _delod < dist->_switch_in) {
- // Preserve this group node, but not the LOD information itself.
- nout << "Preserving LOD " << node->get_name()
- << " (" << dist->_switch_out << " to " << dist->_switch_in
- << ")\n";
- group->clear_lod();
- } else {
- // Remove this group node.
- nout << "Eliminating LOD " << node->get_name()
- << " (" << dist->_switch_out << " to " << dist->_switch_in
- << ")\n";
- return false;
- }
- }
- }
- }
-
- // Now process all the children.
- if (node->is_of_type(EggGroupNode::get_class_type())) {
- EggGroupNode *group = DCAST(EggGroupNode, node);
- EggGroupNode::iterator ci;
- ci = group->begin();
- while (ci != group->end()) {
- EggNode *child = *ci;
- ++ci;
-
- if (!do_delod(child)) {
- group->remove_child(child);
- }
- }
- }
-
- return true;
-}
diff --git a/pandatool/src/eggbase/eggReader.h b/pandatool/src/eggbase/eggReader.h
deleted file mode 100644
index 305b58a2..00000000
--- a/pandatool/src/eggbase/eggReader.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggReader.h
- * @author drose
- * @date 2000-02-14
- */
-
-#ifndef EGGREADER_H
-#define EGGREADER_H
-
-#include "pandatoolbase.h"
-
-#include "eggSingleBase.h"
-#include "filename.h"
-
-class PNMFileType;
-
-/**
- * This is the base class for a program that reads egg files, but doesn't
- * write an egg file.
- */
-class EggReader : virtual public EggSingleBase {
-public:
- EggReader();
-
- void add_texture_options();
- void add_delod_options(double default_delod = -1.0);
- void set_exit_on_failure(bool exit_on_failure);
-
- virtual EggReader *as_reader();
- virtual void pre_process_egg_file();
-
-protected:
- virtual bool handle_args(Args &args);
- virtual bool post_command_line();
-
- bool do_reader_options();
-
-private:
- bool copy_textures();
- bool do_delod(EggNode *node);
-
-protected:
- bool _force_complete;
- bool _exit_on_failure;
-
-private:
- Filename _tex_dirname;
- bool _got_tex_dirname;
- std::string _tex_extension;
- bool _got_tex_extension;
- PNMFileType *_tex_type;
- double _delod;
-};
-
-#endif
diff --git a/pandatool/src/eggbase/eggSingleBase.cxx b/pandatool/src/eggbase/eggSingleBase.cxx
deleted file mode 100644
index a3cda117..00000000
--- a/pandatool/src/eggbase/eggSingleBase.cxx
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggSingleBase.cxx
- * @author drose
- * @date 2003-07-21
- */
-
-#include "eggSingleBase.h"
-
-#include "eggGroupNode.h"
-#include "eggTexture.h"
-#include "eggFilenameNode.h"
-#include "eggComment.h"
-#include "dcast.h"
-#include "string_utils.h"
-
-/**
- *
- */
-EggSingleBase::
-EggSingleBase() :
- _data(new EggData)
-{
-}
-
-/**
- * Returns this object as an EggReader pointer, if it is in fact an EggReader,
- * or NULL if it is not.
- *
- * This is intended to work around the C++ limitation that prevents downcasts
- * past virtual inheritance. Since both EggReader and EggWriter inherit
- * virtually from EggSingleBase, we need functions like this to downcast to
- * the appropriate pointer.
- */
-EggReader *EggSingleBase::
-as_reader() {
- return nullptr;
-}
-
-/**
- * Returns this object as an EggWriter pointer, if it is in fact an EggWriter,
- * or NULL if it is not.
- *
- * This is intended to work around the C++ limitation that prevents downcasts
- * past virtual inheritance. Since both EggReader and EggWriter inherit
- * virtually from EggSingleBase, we need functions like this to downcast to
- * the appropriate pointer.
- */
-EggWriter *EggSingleBase::
-as_writer() {
- return nullptr;
-}
-
-/**
- *
- */
-bool EggSingleBase::
-post_command_line() {
- if (_got_coordinate_system) {
- _data->set_coordinate_system(_coordinate_system);
- }
-
- return EggBase::post_command_line();
-}
diff --git a/pandatool/src/eggbase/eggSingleBase.h b/pandatool/src/eggbase/eggSingleBase.h
deleted file mode 100644
index 32c15d83..00000000
--- a/pandatool/src/eggbase/eggSingleBase.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggSingleBase.h
- * @author drose
- * @date 2003-07-21
- */
-
-#ifndef EGGSINGLEBASE_H
-#define EGGSINGLEBASE_H
-
-#include "pandatoolbase.h"
-
-#include "eggBase.h"
-#include "coordinateSystem.h"
-#include "eggData.h"
-#include "pointerTo.h"
-
-class EggReader;
-class EggWriter;
-class EggNode;
-class PathReplace;
-
-/**
- * This specialization of EggBase is intended for programs that read and/or
- * write a single egg file. (See EggMultiBase for programs that operate on
- * multiple egg files at once.)
- *
- * This is just a base class; see EggReader, EggWriter, or EggFilter according
- * to your particular I/O needs.
- */
-class EggSingleBase : public EggBase {
-public:
- EggSingleBase();
-
- virtual EggReader *as_reader();
- virtual EggWriter *as_writer();
-
-protected:
- virtual bool post_command_line();
-
-protected:
- PT(EggData) _data;
-};
-
-#endif
diff --git a/pandatool/src/eggbase/eggToSomething.cxx b/pandatool/src/eggbase/eggToSomething.cxx
deleted file mode 100644
index eb6adc89..00000000
--- a/pandatool/src/eggbase/eggToSomething.cxx
+++ /dev/null
@@ -1,155 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggToSomething.cxx
- * @author drose
- * @date 2000-02-15
- */
-
-#include "eggToSomething.h"
-
-/**
- * The first parameter to the constructor should be the one-word name of the
- * file format that is to be read, for instance "OpenFlight" or "Alias". It's
- * just used in printing error messages and such.
- */
-EggToSomething::
-EggToSomething(const std::string &format_name,
- const std::string &preferred_extension,
- bool allow_last_param, bool allow_stdout) :
- EggConverter(format_name, preferred_extension, allow_last_param,
- allow_stdout)
-{
- clear_runlines();
- if (_allow_last_param) {
- add_runline("[opts] input.egg output" + _preferred_extension);
- }
- add_runline("[opts] -o output" + _preferred_extension + " input.egg");
- if (_allow_stdout) {
- add_runline("[opts] input.egg >output" + _preferred_extension);
- }
-
- std::string o_description;
-
- if (_allow_stdout) {
- if (_allow_last_param) {
- o_description =
- "Specify the filename to which the resulting " + format_name +
- " file will be written. "
- "If this option is omitted, the last parameter name is taken to be the "
- "name of the output file, or standard output is used if there are no "
- "other parameters.";
- } else {
- o_description =
- "Specify the filename to which the resulting " + format_name +
- " file will be written. "
- "If this option is omitted, the " + format_name +
- " file is written to standard output.";
- }
- } else {
- if (_allow_last_param) {
- o_description =
- "Specify the filename to which the resulting " + format_name +
- " file will be written. "
- "If this option is omitted, the last parameter name is taken to be the "
- "name of the output file.";
- } else {
- o_description =
- "Specify the filename to which the resulting " + format_name +
- " file will be written.";
- }
- }
-
- redescribe_option("o", o_description);
-
- redescribe_option
- ("cs",
- "Specify the coordinate system of the resulting " + _format_name +
- " file. This may be "
- "one of 'y-up', 'z-up', 'y-up-left', or 'z-up-left'. The default "
- "is the same coordinate system as the input egg file. If this is "
- "different from the input egg file, a conversion will be performed.");
-
- _input_units = DU_invalid;
- _output_units = DU_invalid;
-}
-
-/**
- * Adds -ui and -uo as valid options for this program. If the user specifies
- * -uo and -ui, or just -uo and the program specifies -ui by setting
- * _input_units, the indicated units conversion will be automatically applied
- * before writing out the egg file.
- */
-void EggToSomething::
-add_units_options() {
- add_option
- ("ui", "units", 40,
- "Specify the units of the input egg file. If this is "
- "specified, the vertices in the egg file will be scaled as "
- "necessary to make the appropriate units conversion; otherwise, "
- "the vertices will be left as they are.",
- &EggToSomething::dispatch_units, nullptr, &_input_units);
-
- add_option
- ("uo", "units", 40,
- "Specify the units of the resulting " + _format_name +
- " file. Normally, the default units for the format are used.",
- &EggToSomething::dispatch_units, nullptr, &_output_units);
-}
-
-/**
- * Applies the scale indicated by the input and output units to the indicated
- * egg file. This is normally done automatically when the file is read in.
- */
-void EggToSomething::
-apply_units_scale(EggData *data) {
-
- // [gjeon] since maya's internal unit is fixed to cm and when we can't
- // change UI unit without affecting data we need to convert data to cm for
- // now this will be set later to proper output unit user provided by using
- // MayaApi::set_units() in eggToMaya.cxx
- DistanceUnit output_units = _output_units;
- if (_format_name == "Maya")
- _output_units = DU_centimeters;
-
- if (_output_units != DU_invalid && _input_units != DU_invalid &&
- _input_units != _output_units) {
- nout << "Converting from " << format_long_unit(_input_units)
- << " to " << format_long_unit(_output_units) << "\n";
- double scale = convert_units(_input_units, _output_units);
- data->transform(LMatrix4d::scale_mat(scale));
- }
- _output_units = output_units;
-}
-
-/**
- * Performs any processing of the egg file that is appropriate after reading
- * it in.
- *
- * Normally, you should not need to call this function directly; it is called
- * automatically at startup.
- */
-void EggToSomething::
-pre_process_egg_file() {
- apply_units_scale(_data);
- EggConverter::pre_process_egg_file();
-}
-
-/**
- * Does something with the additional arguments on the command line (after all
- * the -options have been parsed). Returns true if the arguments are good,
- * false otherwise.
- */
-bool EggToSomething::
-handle_args(ProgramBase::Args &args) {
- if (!check_last_arg(args, 1)) {
- return false;
- }
-
- return EggConverter::handle_args(args);
-}
diff --git a/pandatool/src/eggbase/eggToSomething.h b/pandatool/src/eggbase/eggToSomething.h
deleted file mode 100644
index aafc045a..00000000
--- a/pandatool/src/eggbase/eggToSomething.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggToSomething.h
- * @author drose
- * @date 2000-02-15
- */
-
-#ifndef EGGTOSOMETHING_H
-#define EGGTOSOMETHING_H
-
-#include "pandatoolbase.h"
-
-#include "eggConverter.h"
-#include "distanceUnit.h"
-
-/**
- * This is the general base class for a file-converter program that reads some
- * model file format and generates an egg file.
- */
-class EggToSomething : public EggConverter {
-public:
- EggToSomething(const std::string &format_name,
- const std::string &preferred_extension = std::string(),
- bool allow_last_param = true,
- bool allow_stdout = true);
-
- void add_units_options();
-
-protected:
- void apply_units_scale(EggData *data);
- virtual void pre_process_egg_file();
- virtual bool handle_args(Args &args);
-
- DistanceUnit _input_units;
- DistanceUnit _output_units;
-};
-
-#endif
diff --git a/pandatool/src/eggbase/eggWriter.cxx b/pandatool/src/eggbase/eggWriter.cxx
deleted file mode 100644
index c881991a..00000000
--- a/pandatool/src/eggbase/eggWriter.cxx
+++ /dev/null
@@ -1,224 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggWriter.cxx
- * @author drose
- * @date 2000-02-14
- */
-
-#include "eggWriter.h"
-
-#include "string_utils.h"
-#include "compose_matrix.h"
-#include "globPattern.h"
-
-/**
- * Egg-writing type programs may specify their output file using either the
- * last-filename convention, the -o convention, and/or implicitly writing the
- * result to standard output. Not all interfaces are appropriate for all
- * applications; some may be confusing or dangerous.
- *
- * The calling application should pass allow_last_param true to allow the user
- * to specify the output filename as the last parameter on the command line
- * (the most dangerous, but convenient, method), and allow_stdout true to
- * allow the user to omit the output filename altogether and have the output
- * implicitly go to standard output (not terribly dangerous, but inappropriate
- * when writing binary file formats).
- */
-EggWriter::
-EggWriter(bool allow_last_param, bool allow_stdout) :
- WithOutputFile(allow_last_param, allow_stdout, false)
-{
- // Indicate the extension name we expect the user to supply for output
- // files.
- _preferred_extension = ".egg";
-
- clear_runlines();
- if (_allow_last_param) {
- add_runline("[opts] output.egg");
- }
- add_runline("[opts] -o output.egg");
- if (_allow_stdout) {
- add_runline("[opts] >output.egg");
- }
-
- std::string o_description;
-
- if (_allow_stdout) {
- if (_allow_last_param) {
- o_description =
- "Specify the filename to which the resulting egg file will be written. "
- "If this option is omitted, the last parameter name is taken to be the "
- "name of the output file, or standard output is used if there are no "
- "other parameters.";
- } else {
- o_description =
- "Specify the filename to which the resulting egg file will be written. "
- "If this option is omitted, the egg file is written to standard output.";
- }
- } else {
- if (_allow_last_param) {
- o_description =
- "Specify the filename to which the resulting egg file will be written. "
- "If this option is omitted, the last parameter name is taken to be the "
- "name of the output file.";
- } else {
- o_description =
- "Specify the filename to which the resulting egg file will be written.";
- }
- }
-
- add_option
- ("o", "filename", 50, o_description,
- &EggWriter::dispatch_filename, &_got_output_filename, &_output_filename);
-
- redescribe_option
- ("cs",
- "Specify the coordinate system of the resulting egg file. This may be "
- "one of 'y-up', 'z-up', 'y-up-left', or 'z-up-left'. The default is "
- "y-up.");
-}
-
-
-/**
- * Returns this object as an EggWriter pointer, if it is in fact an EggWriter,
- * or NULL if it is not.
- *
- * This is intended to work around the C++ limitation that prevents downcasts
- * past virtual inheritance. Since both EggReader and EggWriter inherit
- * virtually from EggSingleBase, we need functions like this to downcast to
- * the appropriate pointer.
- */
-EggWriter *EggWriter::
-as_writer() {
- return this;
-}
-
-/**
- * Performs any processing of the egg file that is appropriate before writing
- * it out. This includes any normal adjustments the user requested via -np,
- * etc.
- *
- * Normally, you should not need to call this function directly;
- * write_egg_file() calls it for you. You should call this only if you do not
- * use write_egg_file() to write out the resulting egg file.
- */
-void EggWriter::
-post_process_egg_file() {
- if (_got_transform) {
- nout << "Applying transform matrix:\n";
- _transform.write(nout, 2);
- LVecBase3d scale, hpr, translate;
- if (decompose_matrix(_transform, scale, hpr, translate,
- _data->get_coordinate_system())) {
- nout << "(scale " << scale << ", hpr " << hpr << ", translate "
- << translate << ")\n";
- }
- _data->transform(_transform);
- }
-
- if (_make_points) {
- nout << "Making points\n";
- _data->make_point_primitives();
- }
-
- bool needs_remove = false;
-
- switch (_normals_mode) {
- case NM_strip:
- nout << "Stripping normals.\n";
- _data->strip_normals();
- needs_remove = true;
- break;
-
- case NM_polygon:
- nout << "Recomputing polygon normals.\n";
- _data->recompute_polygon_normals();
- needs_remove = true;
- break;
-
- case NM_vertex:
- nout << "Recomputing vertex normals.\n";
- _data->recompute_vertex_normals(_normals_threshold);
- needs_remove = true;
- break;
-
- case NM_preserve:
- // Do nothing.
- break;
- }
-
- if (_got_tbnall) {
- needs_remove |= _data->recompute_tangent_binormal(GlobPattern("*"));
- } else {
- if (_got_tbnauto) {
- needs_remove |= _data->recompute_tangent_binormal_auto();
- }
- needs_remove |= _data->recompute_tangent_binormal(_tbn_names);
- }
-
- if (needs_remove) {
- _data->remove_unused_vertices(true);
- }
-}
-
-/**
- * Writes out the egg file as the normal result of the program. This calls
- * post_process_egg_file() to perform any last minute processing (like normal
- * computation) and then writes out the file to the output stream returned by
- * get_output().
- */
-void EggWriter::
-write_egg_file() {
- post_process_egg_file();
- _data->write_egg(get_output());
-}
-
-/**
- * Does something with the additional arguments on the command line (after all
- * the -options have been parsed). Returns true if the arguments are good,
- * false otherwise.
- */
-bool EggWriter::
-handle_args(ProgramBase::Args &args) {
- if (!check_last_arg(args, 0)) {
- return false;
- }
-
- if (!args.empty()) {
- nout << "Unexpected arguments on command line:\n";
- Args::const_iterator ai;
- for (ai = args.begin(); ai != args.end(); ++ai) {
- nout << (*ai) << " ";
- }
- nout << "\r";
- return false;
- }
-
- if (!_got_path_directory && _got_output_filename) {
- // Put in the name of the output directory.
- _path_replace->_path_directory = _output_filename.get_dirname();
- }
-
- return true;
-}
-
-/**
- *
- */
-bool EggWriter::
-post_command_line() {
- if (!_allow_stdout && !_got_output_filename) {
- nout << "You must specify the filename to write with -o.\n";
- return false;
- }
-
- append_command_comment(_data);
-
- return EggSingleBase::post_command_line();
-}
diff --git a/pandatool/src/eggbase/eggWriter.h b/pandatool/src/eggbase/eggWriter.h
deleted file mode 100644
index 9037fe7e..00000000
--- a/pandatool/src/eggbase/eggWriter.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggWriter.h
- * @author drose
- * @date 2000-02-14
- */
-
-#ifndef EGGWRITER_H
-#define EGGWRITER_H
-
-#include "pandatoolbase.h"
-#include "eggSingleBase.h"
-#include "withOutputFile.h"
-
-#include "filename.h"
-#include "luse.h"
-
-/**
- * This is the base class for a program that generates an egg file output, but
- * doesn't read any for input.
- */
-class EggWriter : virtual public EggSingleBase, public WithOutputFile {
-public:
- EggWriter(bool allow_last_param = false, bool allow_stdout = true);
-
- virtual EggWriter *as_writer();
-
- virtual void post_process_egg_file();
- void write_egg_file();
-
-protected:
- virtual bool handle_args(Args &args);
- virtual bool post_command_line();
-
-private:
- std::ofstream _output_stream;
-};
-
-#endif
diff --git a/pandatool/src/eggbase/p3eggbase_composite1.cxx b/pandatool/src/eggbase/p3eggbase_composite1.cxx
deleted file mode 100644
index 7f2f3a72..00000000
--- a/pandatool/src/eggbase/p3eggbase_composite1.cxx
+++ /dev/null
@@ -1,13 +0,0 @@
-
-#include "eggBase.cxx"
-#include "eggConverter.cxx"
-#include "eggFilter.cxx"
-#include "eggMakeSomething.cxx"
-#include "eggMultiBase.cxx"
-#include "eggMultiFilter.cxx"
-#include "eggReader.cxx"
-#include "eggWriter.cxx"
-#include "eggSingleBase.cxx"
-#include "eggToSomething.cxx"
-#include "somethingToEgg.cxx"
-
diff --git a/pandatool/src/eggbase/somethingToEgg.cxx b/pandatool/src/eggbase/somethingToEgg.cxx
deleted file mode 100644
index 45d705f1..00000000
--- a/pandatool/src/eggbase/somethingToEgg.cxx
+++ /dev/null
@@ -1,328 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file somethingToEgg.cxx
- * @author drose
- * @date 2000-02-15
- */
-
-#include "somethingToEgg.h"
-#include "somethingToEggConverter.h"
-
-#include "config_putil.h"
-
-/**
- * The first parameter to the constructor should be the one-word name of the
- * file format that is to be read, for instance "OpenFlight" or "Alias". It's
- * just used in printing error messages and such.
- */
-SomethingToEgg::
-SomethingToEgg(const std::string &format_name,
- const std::string &preferred_extension,
- bool allow_last_param, bool allow_stdout) :
- EggConverter(format_name, preferred_extension, allow_last_param, allow_stdout)
-{
- clear_runlines();
- if (_allow_last_param) {
- add_runline("[opts] input" + _preferred_extension + " output.egg");
- }
- add_runline("[opts] -o output.egg input" + _preferred_extension);
- if (_allow_stdout) {
- add_runline("[opts] input" + _preferred_extension + " >output.egg");
- }
-
- // -f doesn't make sense if we aren't reading egg files.
- remove_option("f");
-
- redescribe_option
- ("cs",
- "Specify the coordinate system of the input " + _format_name +
- " file. Normally, this can inferred from the file itself.");
-
- add_option
- ("noabs", "", 0,
- "Don't allow the input " + _format_name + " file to have absolute pathnames. "
- "If it does, abort with an error. This option is designed to help "
- "detect errors when populating or building a standalone model tree, "
- "which should be self-contained and include only relative pathnames.",
- &SomethingToEgg::dispatch_none, &_noabs);
-
- add_option
- ("noexist", "", 0,
- "Don't treat it as an error if the input file references pathnames "
- "(e.g. textures) that don't exist. Normally, this will be flagged as "
- "an error and the command aborted; with this option, an egg file will "
- "be generated anyway, referencing pathnames that do not exist.",
- &SomethingToEgg::dispatch_none, &_noexist);
-
- add_option
- ("ignore", "", 0,
- "Ignore non-fatal errors and generate an egg file anyway.",
- &SomethingToEgg::dispatch_none, &_allow_errors);
-
- _input_units = DU_invalid;
- _output_units = DU_invalid;
- _animation_convert = AC_none;
- _got_start_frame = false;
- _got_end_frame = false;
- _got_frame_inc = false;
- _got_neutral_frame = false;
- _got_input_frame_rate = false;
- _got_output_frame_rate = false;
- _merge_externals = false;
-}
-
-/**
- * Adds -ui and -uo as valid options for this program. If the user specifies
- * -uo and -ui, or just -uo and the program specifies -ui by setting
- * _input_units, the indicated units conversion will be automatically applied
- * before writing out the egg file.
- */
-void SomethingToEgg::
-add_units_options() {
- add_option
- ("ui", "units", 40,
- "Specify the units of the input " + _format_name +
- " file. Normally, this can be inferred from the file itself.",
- &SomethingToEgg::dispatch_units, nullptr, &_input_units);
-
- add_option
- ("uo", "units", 40,
- "Specify the units of the resulting egg file. If this is "
- "specified, the vertices in the egg file will be scaled as "
- "necessary to make the appropriate units conversion; otherwise, "
- "the vertices will be left as they are.",
- &SomethingToEgg::dispatch_units, nullptr, &_output_units);
-}
-
-/**
- * Adds options appropriate to animation packages.
- */
-void SomethingToEgg::
-add_animation_options() {
- add_option
- ("a", "animation-mode", 40,
- "Specifies how animation from the " + _format_name + " file is "
- "converted to egg, if at all. At present, the following keywords "
- "are supported: none, pose, flip, strobe, model, chan, or both. "
- "The default is none, which means not to convert animation.",
- &SomethingToEgg::dispatch_animation_convert, nullptr, &_animation_convert);
-
- add_option
- ("cn", "name", 40,
- "Specifies the name of the animation character. This should match "
- "between all of the model files and all of the channel files for a "
- "particular model and its associated channels.",
- &SomethingToEgg::dispatch_string, nullptr, &_character_name);
-
- add_option
- ("sf", "start-frame", 40,
- "Specifies the starting frame of animation to extract. If omitted, "
- "the first frame of the time slider will be used. For -a pose, this "
- "is the one frame of animation to extract.",
- &SomethingToEgg::dispatch_double, &_got_start_frame, &_start_frame);
-
- add_option
- ("ef", "end-frame", 40,
- "Specifies the ending frame of animation to extract. If omitted, "
- "the last frame of the time slider will be used.",
- &SomethingToEgg::dispatch_double, &_got_end_frame, &_end_frame);
-
- add_option
- ("if", "frame-inc", 40,
- "Specifies the increment between successive frames. If omitted, "
- "this is taken from the time slider settings, or 1.0 if the time "
- "slider does not specify.",
- &SomethingToEgg::dispatch_double, &_got_frame_inc, &_frame_inc);
-
- add_option
- ("nf", "neutral-frame", 40,
- "Specifies the frame number to use for the neutral pose. The model "
- "will be set to this frame before extracting out the neutral character. "
- "If omitted, the current frame of the model is used. This is only "
- "relevant for -a model or -a both.",
- &SomethingToEgg::dispatch_double, &_got_neutral_frame, &_neutral_frame);
-
- add_option
- ("fri", "fps", 40,
- "Specify the frame rate (frames per second) of the input " + _format_name +
- " file. Normally, this can be inferred from the file itself.",
- &SomethingToEgg::dispatch_double, &_got_input_frame_rate, &_input_frame_rate);
-
- add_option
- ("fro", "fps", 40,
- "Specify the frame rate (frames per second) of the generated animation. "
- "If this is specified, the animation speed is scaled by the appropriate "
- "factor based on the frame rate of the input file (see -fri).",
- &SomethingToEgg::dispatch_double, &_got_output_frame_rate, &_output_frame_rate);
-}
-
-/**
- * Adds -f.
- */
-void SomethingToEgg::
-add_merge_externals_options() {
- add_option
- ("f", "", 40,
- "Follow and convert all external references in the source file.",
- &SomethingToEgg::dispatch_none, &_merge_externals);
-}
-
-/**
- * Applies the scale indicated by the input and output units to the indicated
- * egg file. This is normally done automatically when the file is written
- * out.
- */
-void SomethingToEgg::
-apply_units_scale(EggData *data) {
- if (_output_units != DU_invalid && _input_units != DU_invalid &&
- _input_units != _output_units) {
- nout << "Converting from " << format_long_unit(_input_units)
- << " to " << format_long_unit(_output_units) << "\n";
- double scale = convert_units(_input_units, _output_units);
- data->transform(LMatrix4d::scale_mat(scale));
- }
-}
-
-/**
- * Copies the relevant parameters specified by the user on the command line
- * (if add_path_replace_options(), add_path_store_options(), or
- * add_animation_options() was used) to the converter.
- */
-void SomethingToEgg::
-apply_parameters(SomethingToEggConverter &converter) {
- _path_replace->_noabs = _noabs;
- _path_replace->_exists = !_noexist;
- converter.set_path_replace(_path_replace);
-
- converter.set_animation_convert(_animation_convert);
- converter.set_character_name(_character_name);
- if (_got_start_frame) {
- converter.set_start_frame(_start_frame);
- }
- if (_got_end_frame) {
- converter.set_end_frame(_end_frame);
- }
- if (_got_frame_inc) {
- converter.set_frame_inc(_frame_inc);
- }
- if (_got_neutral_frame) {
- converter.set_neutral_frame(_neutral_frame);
- }
- if (_got_input_frame_rate) {
- converter.set_input_frame_rate(_input_frame_rate);
- }
- if (_got_output_frame_rate) {
- converter.set_output_frame_rate(_output_frame_rate);
- }
-}
-
-/**
- *
- */
-bool SomethingToEgg::
-handle_args(Args &args) {
- if (_allow_last_param && !_got_output_filename && args.size() > 1) {
- _got_output_filename = true;
- _output_filename = Filename::from_os_specific(args.back());
- args.pop_back();
-
- if (!(_output_filename.get_extension() == "egg")) {
- nout << "Output filename " << _output_filename
- << " does not end in .egg. If this is really what you intended, "
- "use the -o output_file syntax.\n";
- return false;
- }
-
- if (!verify_output_file_safe()) {
- return false;
- }
- }
-
- if (args.empty()) {
- nout << "You must specify the " << _format_name
- << " file to read on the command line.\n";
- return false;
- }
-
- if (args.size() != 1) {
- nout << "You may only specify one " << _format_name
- << " file to read on the command line. "
- << "You specified: ";
- Args::const_iterator ai;
- for (ai = args.begin(); ai != args.end(); ++ai) {
- nout << (*ai) << " ";
- }
- nout << "\n";
- return false;
- }
-
- _input_filename = Filename::from_os_specific(args[0]);
-
- if (!_input_filename.exists()) {
- nout << "Cannot find input file " << _input_filename << "\n";
- return false;
- }
-
- if (!_got_path_directory && _got_output_filename) {
- // Put in the name of the output directory.
- _path_replace->_path_directory = _output_filename.get_dirname();
- }
-
- return true;
-}
-
-/**
- * This is called after the command line has been completely processed, and it
- * gives the program a chance to do some last-minute processing and validation
- * of the options and arguments. It should return true if everything is fine,
- * false if there is an error.
- */
-bool SomethingToEgg::
-post_command_line() {
- // Prepend the source filename to the model path.
- ConfigVariableSearchPath &model_path = get_model_path();
- Filename directory = _input_filename.get_dirname();
- if (directory.empty()) {
- directory = ".";
- }
- model_path.prepend_directory(directory);
-
- return EggConverter::post_command_line();
-}
-
-/**
- * Performs any processing of the egg file that is appropriate before writing
- * it out. This includes any normal adjustments the user requested via -np,
- * etc.
- *
- * Normally, you should not need to call this function directly;
- * write_egg_file() calls it for you. You should call this only if you do not
- * use write_egg_file() to write out the resulting egg file.
- */
-void SomethingToEgg::
-post_process_egg_file() {
- apply_units_scale(_data);
- EggConverter::post_process_egg_file();
-}
-
-/**
- * Dispatch function to set the given animation convert mode according to the
- * specified parameter. var is a pointer to an AnimationConvert variable.
- */
-bool SomethingToEgg::
-dispatch_animation_convert(const std::string &opt, const std::string &arg, void *var) {
- AnimationConvert *ip = (AnimationConvert *)var;
- (*ip) = string_animation_convert(arg);
- if ((*ip) == AC_invalid) {
- nout << "Invalid keyword for -" << opt << ": " << arg << "\n";
- return false;
- }
-
- return true;
-}
diff --git a/pandatool/src/eggbase/somethingToEgg.h b/pandatool/src/eggbase/somethingToEgg.h
deleted file mode 100644
index 5c5427dc..00000000
--- a/pandatool/src/eggbase/somethingToEgg.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file somethingToEgg.h
- * @author drose
- * @date 2000-02-15
- */
-
-#ifndef SOMETHINGTOEGG_H
-#define SOMETHINGTOEGG_H
-
-#include "pandatoolbase.h"
-
-#include "eggConverter.h"
-#include "distanceUnit.h"
-#include "animationConvert.h"
-
-class SomethingToEggConverter;
-
-/**
- * This is the general base class for a file-converter program that reads some
- * model file format and generates an egg file.
- */
-class SomethingToEgg : public EggConverter {
-public:
- SomethingToEgg(const std::string &format_name,
- const std::string &preferred_extension = std::string(),
- bool allow_last_param = true,
- bool allow_stdout = true);
-
- void add_units_options();
- void add_animation_options();
- void add_merge_externals_options();
-
-protected:
- void apply_units_scale(EggData *data);
- void apply_parameters(SomethingToEggConverter &converter);
-
- virtual bool handle_args(Args &args);
- virtual bool post_command_line();
- virtual void post_process_egg_file();
-
- static bool dispatch_animation_convert(const std::string &opt, const std::string &arg, void *var);
-
-
- Filename _input_filename;
-
- DistanceUnit _input_units;
- DistanceUnit _output_units;
-
- AnimationConvert _animation_convert;
- std::string _character_name;
- double _start_frame;
- double _end_frame;
- double _frame_inc;
- double _neutral_frame;
- double _input_frame_rate;
- double _output_frame_rate;
- bool _got_start_frame;
- bool _got_end_frame;
- bool _got_frame_inc;
- bool _got_neutral_frame;
- bool _got_input_frame_rate;
- bool _got_output_frame_rate;
-
- bool _merge_externals;
- bool _noexist;
- bool _allow_errors;
-};
-
-#endif
diff --git a/pandatool/src/eggcharbase/CMakeLists.txt b/pandatool/src/eggcharbase/CMakeLists.txt
deleted file mode 100644
index 384bebe0..00000000
--- a/pandatool/src/eggcharbase/CMakeLists.txt
+++ /dev/null
@@ -1,46 +0,0 @@
-if(NOT HAVE_EGG)
- return()
-endif()
-
-set(P3EGGCHARBASE_HEADERS
- config_eggcharbase.h
- eggBackPointer.h
- eggCharacterCollection.h eggCharacterCollection.I
- eggCharacterData.h eggCharacterData.I
- eggCharacterDb.h eggCharacterDb.I
- eggCharacterFilter.h
- eggComponentData.h eggComponentData.I
- eggJointData.h eggJointData.I
- eggJointNodePointer.h
- eggJointPointer.h eggJointPointer.I
- eggMatrixTablePointer.h
- eggScalarTablePointer.h
- eggSliderData.h eggSliderData.I
- eggSliderPointer.h
- eggVertexPointer.h
-)
-
-set(P3EGGCHARBASE_SOURCES
- config_eggcharbase.cxx
- eggBackPointer.cxx
- eggCharacterCollection.cxx
- eggCharacterData.cxx
- eggCharacterDb.cxx
- eggCharacterFilter.cxx
- eggComponentData.cxx
- eggJointData.cxx
- eggJointNodePointer.cxx
- eggJointPointer.cxx
- eggMatrixTablePointer.cxx
- eggScalarTablePointer.cxx
- eggSliderData.cxx
- eggSliderPointer.cxx
- eggVertexPointer.cxx
-)
-
-composite_sources(p3eggcharbase P3EGGCHARBASE_SOURCES)
-add_library(p3eggcharbase STATIC ${P3EGGCHARBASE_HEADERS} ${P3EGGCHARBASE_SOURCES})
-target_link_libraries(p3eggcharbase p3eggbase)
-
-# This is only needed for binaries in the pandatool package. It is not useful
-# for user applications, so it is not installed.
diff --git a/pandatool/src/eggcharbase/config_eggcharbase.cxx b/pandatool/src/eggcharbase/config_eggcharbase.cxx
deleted file mode 100644
index 734939a4..00000000
--- a/pandatool/src/eggcharbase/config_eggcharbase.cxx
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file config_eggcharbase.cxx
- * @author drose
- * @date 2001-02-26
- */
-
-#include "config_eggcharbase.h"
-#include "eggBackPointer.h"
-#include "eggComponentData.h"
-#include "eggJointData.h"
-#include "eggJointNodePointer.h"
-#include "eggJointPointer.h"
-#include "eggMatrixTablePointer.h"
-#include "eggScalarTablePointer.h"
-#include "eggSliderData.h"
-#include "eggSliderPointer.h"
-#include "eggVertexPointer.h"
-
-#include "dconfig.h"
-
-
-Configure(config_eggcharbase);
-
-// NotifyCategoryDef(eggcharbase, "");
-
-ConfigureFn(config_eggcharbase) {
- init_libeggcharbase();
-}
-
-/**
- * Initializes the library. This must be called at least once before any of
- * the functions or classes in this library can be used. Normally it will be
- * called by the static initializers and need not be called explicitly, but
- * special cases exist.
- */
-void
-init_libeggcharbase() {
- static bool initialized = false;
- if (initialized) {
- return;
- }
- initialized = true;
-
- EggBackPointer::init_type();
- EggComponentData::init_type();
- EggJointData::init_type();
- EggJointNodePointer::init_type();
- EggJointPointer::init_type();
- EggMatrixTablePointer::init_type();
- EggScalarTablePointer::init_type();
- EggSliderData::init_type();
- EggSliderPointer::init_type();
- EggVertexPointer::init_type();
-}
diff --git a/pandatool/src/eggcharbase/config_eggcharbase.h b/pandatool/src/eggcharbase/config_eggcharbase.h
deleted file mode 100644
index d6d1404e..00000000
--- a/pandatool/src/eggcharbase/config_eggcharbase.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file config_eggcharbase.h
- * @author drose
- * @date 2001-02-26
- */
-
-#ifndef CONFIG_EGGCHARBASE_H
-#define CONFIG_EGGCHARBASE_H
-
-#include "pandabase.h"
-
-// Commented out to resolve link problem #include "notifyCategoryProxy.h"
-// NotifyCategoryDecl(eggcharbase, EXPCL_MISC, EXPTP_MISC);
-
-extern void init_libeggcharbase();
-
-#endif
diff --git a/pandatool/src/eggcharbase/eggBackPointer.cxx b/pandatool/src/eggcharbase/eggBackPointer.cxx
deleted file mode 100644
index cc6110d0..00000000
--- a/pandatool/src/eggcharbase/eggBackPointer.cxx
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggBackPointer.cxx
- * @author drose
- * @date 2001-02-26
- */
-
-#include "eggBackPointer.h"
-
-#include "pnotify.h"
-
-
-TypeHandle EggBackPointer::_type_handle;
-
-/**
- *
- */
-EggBackPointer::
-EggBackPointer() {
-}
-
-/**
- * Returns the stated frame rate of this particular joint, or 0.0 if it
- * doesn't state.
- */
-double EggBackPointer::
-get_frame_rate() const {
- return 0.0;
-}
-
-/**
- * Extends the table to the indicated number of frames.
- */
-void EggBackPointer::
-extend_to(int num_frames) {
- // Whoops, can't extend this kind of table!
- nassert_raise("can't extend this kind of table");
-}
-
-/**
- * Returns true if there are any vertices referenced by the node this points
- * to, false otherwise. For certain kinds of back pointers (e.g. table
- * animation entries), this is always false.
- */
-bool EggBackPointer::
-has_vertices() const {
- return false;
-}
-
-/**
- * Applies the indicated name change to the egg file.
- */
-void EggBackPointer::
-set_name(const std::string &name) {
-}
diff --git a/pandatool/src/eggcharbase/eggBackPointer.h b/pandatool/src/eggcharbase/eggBackPointer.h
deleted file mode 100644
index 2595c09d..00000000
--- a/pandatool/src/eggcharbase/eggBackPointer.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggBackPointer.h
- * @author drose
- * @date 2001-02-26
- */
-
-#ifndef EGGBACKPOINTER_H
-#define EGGBACKPOINTER_H
-
-#include "pandatoolbase.h"
-
-#include "typedObject.h"
-
-/**
- * This stores a pointer from an EggJointData or EggSliderData object back to
- * the referencing data in an egg file. One of these objects corresponds to
- * each model appearing in an egg file, and may reference either a single
- * node, or a table, or a slew of vertices and primitives, depending on the
- * type of data stored.
- *
- * This is just an abstract base class. The actual details are stored in the
- * various subclasses.
- */
-class EggBackPointer : public TypedObject {
-public:
- EggBackPointer();
-
- virtual double get_frame_rate() const;
- virtual int get_num_frames() const=0;
- virtual void extend_to(int num_frames);
- virtual bool has_vertices() const;
-
- virtual void set_name(const std::string &name);
-
-public:
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- TypedObject::init_type();
- register_type(_type_handle, "EggBackPointer",
- TypedObject::get_class_type());
- }
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
-
-private:
- static TypeHandle _type_handle;
-};
-
-#endif
diff --git a/pandatool/src/eggcharbase/eggCharacterCollection.I b/pandatool/src/eggcharbase/eggCharacterCollection.I
deleted file mode 100644
index fc1f2696..00000000
--- a/pandatool/src/eggcharbase/eggCharacterCollection.I
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggCharacterCollection.I
- * @author drose
- * @date 2001-02-26
- */
-
-/**
- * Returns the number of egg files that have successfully been added to the
- * Character table.
- */
-INLINE int EggCharacterCollection::
-get_num_eggs() const {
- return _eggs.size();
-}
-
-/**
- * Returns the ith egg file.
- */
-INLINE EggData *EggCharacterCollection::
-get_egg(int i) const {
- nassertr(i >= 0 && i < (int)_eggs.size(), nullptr);
- return _eggs[i]._egg;
-}
-
-/**
- * Returns the first model index associated with the indicated egg file. An
- * egg file may contain multiple models, which will be consecutive integers
- * beginning at get_first_model_index() and continuing for get_num_models().
- *
- * Each "model" corresponds to a single character model, or one LOD of a
- * multiple-LOD model, or a single animation bundle.
- */
-INLINE int EggCharacterCollection::
-get_first_model_index(int egg_index) const {
- nassertr(egg_index >= 0 && egg_index < (int)_eggs.size(), 0);
- return _eggs[egg_index]._first_model_index;
-}
-
-/**
- * Returns the number of different models found in the indicated egg file. An
- * egg file may contain multiple models, which will be consecutive integers
- * beginning at get_first_model_index() and continuing for get_num_models().
- *
- * Each "model" corresponds to a single character model, or one LOD of a
- * multiple-LOD model, or a single animation bundle.
- */
-INLINE int EggCharacterCollection::
-get_num_models(int egg_index) const {
- nassertr(egg_index >= 0 && egg_index < (int)_eggs.size(), 0);
- return _eggs[egg_index]._models.size();
-}
-
-/**
- * Returns the number of separate Characters that have been discovered in the
- * various egg files added to the collection.
- */
-INLINE int EggCharacterCollection::
-get_num_characters() const {
- return _characters.size();
-}
-
-/**
- * Returns the ith character in the collection.
- */
-INLINE EggCharacterData *EggCharacterCollection::
-get_character(int i) const {
- nassertr(i >= 0 && i < (int)_characters.size(), nullptr);
- return _characters[i];
-}
-
-/**
- * Returns the character associated with the indicated model index.
- */
-INLINE EggCharacterData *EggCharacterCollection::
-get_character_by_model_index(int model_index) const {
- nassertr(model_index >= 0 && model_index < (int)_characters_by_model_index.size(),
- nullptr);
- return _characters_by_model_index[model_index];
-}
-
-/**
- *
- */
-INLINE EggCharacterCollection::ModelDescription::
-ModelDescription() {
- _root_node = nullptr;
-}
diff --git a/pandatool/src/eggcharbase/eggCharacterCollection.cxx b/pandatool/src/eggcharbase/eggCharacterCollection.cxx
deleted file mode 100644
index f90c7d9a..00000000
--- a/pandatool/src/eggcharbase/eggCharacterCollection.cxx
+++ /dev/null
@@ -1,680 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggCharacterCollection.cxx
- * @author drose
- * @date 2001-02-26
- */
-
-#include "eggCharacterCollection.h"
-#include "eggCharacterData.h"
-#include "eggJointData.h"
-#include "eggSliderData.h"
-
-#include "dcast.h"
-#include "eggGroup.h"
-#include "eggTable.h"
-#include "eggPrimitive.h"
-#include "eggVertex.h"
-#include "eggVertexUV.h"
-#include "eggMorphList.h"
-#include "eggSAnimData.h"
-#include "indirectCompareNames.h"
-#include "indent.h"
-
-#include
-
-using std::string;
-
-
-/**
- *
- */
-EggCharacterCollection::
-EggCharacterCollection() {
- _next_model_index = 0;
-}
-
-/**
- *
- */
-EggCharacterCollection::
-~EggCharacterCollection() {
- Characters::iterator ci;
-
- for (ci = _characters.begin(); ci != _characters.end(); ++ci) {
- delete (*ci);
- }
-}
-
-/**
- * Adds a new egg file to the list of models and animation files for this
- * particular character.
- *
- * Returns the new egg_index if the file is successfully added, or -1 if there
- * is some problem (for instance, it does not contain a character model or
- * animation table).
- *
- * If the joint hierarchy does not match the existing joint hierarchy, a best
- * match is attempted.
- */
-int EggCharacterCollection::
-add_egg(EggData *egg) {
- _top_egg_nodes.clear();
-
- if (!scan_hierarchy(egg)) {
- return -1;
- }
-
- int egg_index = _eggs.size();
- _eggs.push_back(EggInfo());
- EggInfo &egg_info = _eggs.back();
- egg_info._egg = egg;
- egg_info._first_model_index = 0;
-
- // Now, for each model, add an entry in the egg_info and match the joint
- // hierarchy to the known joints.
- TopEggNodesByName::iterator tni;
- for (tni = _top_egg_nodes.begin(); tni != _top_egg_nodes.end(); ++tni) {
- string character_name = (*tni).first;
- TopEggNodes &top_nodes = (*tni).second;
- EggCharacterData *char_data = make_character(character_name);
- EggJointData *root_joint = char_data->get_root_joint();
-
- TopEggNodes::iterator ti;
- for (ti = top_nodes.begin(); ti != top_nodes.end(); ++ti) {
- EggNode *model_root = (*ti).first;
- ModelDescription &desc = (*ti).second;
-
- int model_index = _next_model_index++;
- if (egg_info._models.empty()) {
- egg_info._first_model_index = model_index;
- }
- egg_info._models.push_back(model_root);
-
- char_data->add_model(model_index, model_root, egg);
- nassertr(model_index == (int)_characters_by_model_index.size(), -1);
- _characters_by_model_index.push_back(char_data);
- root_joint->add_back_pointer(model_index, desc._root_node);
-
- match_egg_nodes(char_data, root_joint, desc._top_nodes,
- egg_index, model_index);
-
- scan_for_morphs(model_root, model_index, char_data);
- scan_for_sliders(model_root, model_index, char_data);
- }
- }
-
- return egg_index;
-}
-
-/**
- * Returns the Character with the indicated name, if it exists in the
- * collection, or NULL if it does not.
- */
-EggCharacterData *EggCharacterCollection::
-get_character_by_name(const string &character_name) const {
- Characters::const_iterator ci;
- for (ci = _characters.begin(); ci != _characters.end(); ++ci) {
- EggCharacterData *char_data = (*ci);
- if (char_data->get_name() == character_name) {
- return char_data;
- }
- }
-
- return nullptr;
-}
-
-
-/**
- * Allocates and returns a new EggCharacterData structure. This is primarily
- * intended as a hook so derived classes can customize the type of
- * EggCharacterData nodes used to represent the characters in this collection.
- */
-EggCharacterData *EggCharacterCollection::
-make_character_data() {
- return new EggCharacterData(this);
-}
-
-/**
- * Allocates and returns a new EggJointData structure for the given character.
- * This is primarily intended as a hook so derived classes can customize the
- * type of EggJointData nodes used to represent the joint hierarchy.
- */
-EggJointData *EggCharacterCollection::
-make_joint_data(EggCharacterData *char_data) {
- return new EggJointData(this, char_data);
-}
-
-/**
- * Allocates and returns a new EggSliderData structure for the given
- * character. This is primarily intended as a hook so derived classes can
- * customize the type of EggSliderData nodes used to represent the slider
- * list.
- */
-EggSliderData *EggCharacterCollection::
-make_slider_data(EggCharacterData *char_data) {
- return new EggSliderData(this, char_data);
-}
-
-/**
- * Allocates and returns a new EggCharacterData object representing the named
- * character, if there is not already a character by that name.
- */
-EggCharacterData *EggCharacterCollection::
-make_character(const string &character_name) {
- // Does the named character exist yet?
-
- Characters::iterator ci;
- for (ci = _characters.begin(); ci != _characters.end(); ++ci) {
- EggCharacterData *char_data = (*ci);
- if (char_data->get_name() == character_name) {
- return char_data;
- }
- }
-
- // Define a new character.
- EggCharacterData *char_data = make_character_data();
- char_data->set_name(character_name);
- _characters.push_back(char_data);
- return char_data;
-}
-
-/**
- * Walks the given egg data's hierarchy, looking for either the start of an
- * animation channel or the start of a character model. Returns true if
- * either (or both) is found, false if the model appears to have nothing to do
- * with characters.
- *
- * Fills up the _top_egg_nodes according to the nodes found.
- */
-bool EggCharacterCollection::
-scan_hierarchy(EggNode *egg_node) {
- if (egg_node->is_of_type(EggGroup::get_class_type())) {
- EggGroup *group = DCAST(EggGroup, egg_node);
- if (group->get_dart_type() != EggGroup::DT_none) {
- // A group with a flag begins a character model.
- scan_for_top_joints(group, group, group->get_name());
- return true;
- }
-
- } else if (egg_node->is_of_type(EggTable::get_class_type())) {
- EggTable *table = DCAST(EggTable, egg_node);
- if (table->get_table_type() == EggTable::TT_bundle) {
- // A begins an animation table.
- scan_for_top_tables(table, table, table->get_name());
- return true;
- }
- }
-
- bool character_found = false;
- if (egg_node->is_of_type(EggGroupNode::get_class_type())) {
- EggGroupNode *group = DCAST(EggGroupNode, egg_node);
- EggGroupNode::iterator gi;
- for (gi = group->begin(); gi != group->end(); ++gi) {
- if (scan_hierarchy(*gi)) {
- character_found = true;
- }
- }
- }
-
- return character_found;
-}
-
-/**
- * Once a character model has been found, continue scanning the egg hierarchy
- * to look for the topmost nodes encountered.
- */
-void EggCharacterCollection::
-scan_for_top_joints(EggNode *egg_node, EggNode *model_root,
- const string &character_name) {
- if (egg_node->is_of_type(EggGroup::get_class_type())) {
- EggGroup *group = DCAST(EggGroup, egg_node);
-
- if (group->has_lod()) {
- // This group has an LOD specification; that indicates multiple skeleton
- // hierarchies for this character, one for each LOD. We call each of
- // these a separate model.
- model_root = group;
- }
- if (group->get_group_type() == EggGroup::GT_joint) {
- // A node begins a model hierarchy.
- ModelDescription &desc = _top_egg_nodes[character_name][model_root];
- desc._root_node = model_root;
- desc._top_nodes.push_back(group);
- return;
- }
- }
-
- if (egg_node->is_of_type(EggGroupNode::get_class_type())) {
- EggGroupNode *group = DCAST(EggGroupNode, egg_node);
- EggGroupNode::iterator gi;
- for (gi = group->begin(); gi != group->end(); ++gi) {
- scan_for_top_joints(*gi, model_root, character_name);
- }
- }
-}
-
-/**
- * Once an animation has been found, continue scanning the egg hierarchy to
- * look for the topmost nodes encountered.
- */
-void EggCharacterCollection::
-scan_for_top_tables(EggTable *bundle, EggNode *model_root,
- const string &character_name) {
- // We really only need to check the immediate children of the bundle for a
- // table node called "".
- EggGroupNode::iterator gi;
- for (gi = bundle->begin(); gi != bundle->end(); ++gi) {
- EggNode *child = (*gi);
- if (child->is_of_type(EggTable::get_class_type())) {
- EggTable *table = DCAST(EggTable, child);
- if (table->get_name() == "") {
- // Here it is! Now the immediate children of this node are the top
- // tables.
- ModelDescription &desc = _top_egg_nodes[character_name][model_root];
- desc._root_node = table;
-
- EggGroupNode::iterator cgi;
- for (cgi = table->begin(); cgi != table->end(); ++cgi) {
- EggNode *grandchild = (*cgi);
- if (grandchild->is_of_type(EggTable::get_class_type())) {
- desc._top_nodes.push_back(grandchild);
- }
- }
- }
- }
- }
-}
-
-/**
- * Go back through a model's hierarchy and look for morph targets on the
- * vertices and primitives.
- */
-void EggCharacterCollection::
-scan_for_morphs(EggNode *egg_node, int model_index,
- EggCharacterData *char_data) {
- if (egg_node->is_of_type(EggPrimitive::get_class_type())) {
- EggPrimitive *prim = DCAST(EggPrimitive, egg_node);
- // Check for morphs on the primitive.
- add_morph_back_pointers(prim, prim, model_index, char_data);
-
- // Also check for morphs on each of the prim's vertices.
- EggPrimitive::const_iterator vi;
- for (vi = prim->begin(); vi != prim->end(); ++vi) {
- EggVertex *vertex = (*vi);
-
- add_morph_back_pointers(vertex, vertex, model_index, char_data);
- add_morph_back_pointers_vertex(vertex, vertex, model_index, char_data);
-
- EggMorphVertexList::const_iterator mvi;
- for (mvi = vertex->_dxyzs.begin();
- mvi != vertex->_dxyzs.end();
- ++mvi) {
- const EggMorphVertex &morph = (*mvi);
- char_data->make_slider(morph.get_name())->add_back_pointer(model_index, vertex);
- }
- }
- }
-
- if (egg_node->is_of_type(EggGroupNode::get_class_type())) {
- EggGroupNode *group = DCAST(EggGroupNode, egg_node);
- EggGroupNode::iterator gi;
- for (gi = group->begin(); gi != group->end(); ++gi) {
- scan_for_morphs(*gi, model_index, char_data);
- }
- }
-}
-
-/**
- * Go back to the animation tables and look for morph slider animation
- * channels.
- */
-void EggCharacterCollection::
-scan_for_sliders(EggNode *egg_node, int model_index,
- EggCharacterData *char_data) {
- if (egg_node->is_of_type(EggTable::get_class_type())) {
- EggTable *bundle = DCAST(EggTable, egg_node);
-
- // We really only need to check the immediate children of the bundle for a
- // table node called "morph". This is a sibling of "", which we
- // found a minute ago, but we weren't ready to scan for the morph sliders
- // at the time, so we have to look again now.
-
- EggGroupNode::iterator gi;
- for (gi = bundle->begin(); gi != bundle->end(); ++gi) {
- EggNode *child = (*gi);
- if (child->is_of_type(EggTable::get_class_type())) {
- EggTable *table = DCAST(EggTable, child);
- if (table->get_name() == "morph") {
- // Here it is! Now the immediate children of this node are all the
- // slider channels.
-
- EggGroupNode::iterator cgi;
- for (cgi = table->begin(); cgi != table->end(); ++cgi) {
- EggNode *grandchild = (*cgi);
- if (grandchild->is_of_type(EggSAnimData::get_class_type())) {
- char_data->make_slider(grandchild->get_name())->add_back_pointer(model_index, grandchild);
- }
- }
- }
- }
- }
- }
-}
-
-/**
- * Adds the back pointers for the kinds of morphs we might find in an
- * EggAttributes object.
- */
-void EggCharacterCollection::
-add_morph_back_pointers(EggAttributes *attrib, EggObject *egg_object,
- int model_index, EggCharacterData *char_data) {
- EggMorphNormalList::const_iterator mni;
- for (mni = attrib->_dnormals.begin();
- mni != attrib->_dnormals.end();
- ++mni) {
- const EggMorphNormal &morph = (*mni);
- char_data->make_slider(morph.get_name())->add_back_pointer(model_index, egg_object);
- }
-
- EggMorphColorList::const_iterator mci;
- for (mci = attrib->_drgbas.begin();
- mci != attrib->_drgbas.end();
- ++mci) {
- const EggMorphColor &morph = (*mci);
- char_data->make_slider(morph.get_name())->add_back_pointer(model_index, egg_object);
- }
-}
-
-/**
- * Adds the back pointers for the kinds of morphs we might find in an
- * EggVertex object.
- */
-void EggCharacterCollection::
-add_morph_back_pointers_vertex(EggVertex *vertex, EggObject *egg_object,
- int model_index, EggCharacterData *char_data) {
- EggVertex::const_uv_iterator ui;
- for (ui = vertex->uv_begin(); ui != vertex->uv_end(); ++ui) {
- EggVertexUV *vert_uv = (*ui);
- EggMorphTexCoordList::const_iterator mti;
- for (mti = vert_uv->_duvs.begin();
- mti != vert_uv->_duvs.end();
- ++mti) {
- const EggMorphTexCoord &morph = (*mti);
- char_data->make_slider(morph.get_name())->add_back_pointer(model_index, egg_object);
- }
- }
-}
-
-/**
- * Attempts to match up the indicated list of egg_nodes with the children of
- * the given joint_data, by name if possible.
- *
- * Also recurses on each matched joint to build up the entire joint hierarchy.
- */
-void EggCharacterCollection::
-match_egg_nodes(EggCharacterData *char_data, EggJointData *joint_data,
- EggNodeList &egg_nodes, int egg_index, int model_index) {
- // Sort the list of egg_nodes in order by name. This will make the matching
- // up by names easier and more reliable.
- sort(egg_nodes.begin(), egg_nodes.end(), IndirectCompareNames());
-
- if (joint_data->_children.empty()) {
- // If the EggJointData has no children yet, we must be the first.
- // Gleefully define all the joints.
- EggNodeList::iterator ei;
- for (ei = egg_nodes.begin(); ei != egg_nodes.end(); ++ei) {
- EggNode *egg_node = (*ei);
- EggJointData *data = make_joint_data(char_data);
- joint_data->_children.push_back(data);
- char_data->_joints.push_back(data);
- char_data->_components.push_back(data);
- data->_parent = joint_data;
- data->_new_parent = joint_data;
- found_egg_match(char_data, data, egg_node, egg_index, model_index);
- }
-
- } else {
- // The EggJointData already has children; therefore, we have to match our
- // joints up with the already-existing ones.
-
- EggNodeList extra_egg_nodes;
- EggJointData::Children extra_data;
-
- EggNodeList::iterator ei;
- EggJointData::Children::iterator di;
-
- ei = egg_nodes.begin();
- di = joint_data->_children.begin();
-
- while (ei != egg_nodes.end() && di != joint_data->_children.end()) {
- EggNode *egg_node = (*ei);
- EggJointData *data = (*di);
-
- if (egg_node->get_name() < data->get_name()) {
- // Here's a joint in the egg file, unmatched in the data.
- extra_egg_nodes.push_back(egg_node);
- ++ei;
-
- } else if (data->get_name() < egg_node->get_name()) {
- // Here's a joint in the data, umatched by the egg file.
- extra_data.push_back(data);
- ++di;
-
- } else {
- // Hey, these two match! Hooray!
- found_egg_match(char_data, data, egg_node, egg_index, model_index);
- ++ei;
- ++di;
- }
- }
-
- while (ei != egg_nodes.end()) {
- EggNode *egg_node = (*ei);
-
- // Here's a joint in the egg file, unmatched in the data.
- extra_egg_nodes.push_back(egg_node);
- ++ei;
- }
-
- while (di != joint_data->_children.end()) {
- EggJointData *data = (*di);
-
- // Here's a joint in the data, umatched by the egg file.
- extra_data.push_back(data);
- ++di;
- }
-
- if (!extra_egg_nodes.empty()) {
- // If we have some extra egg_nodes, we have to find a place to match
- // them. (If we only had extra data, we don't care.)
-
- // First, check to see if any of the names match any past-used name.
- EggNodeList more_egg_nodes;
-
- for (ei = extra_egg_nodes.begin(); ei != extra_egg_nodes.end(); ++ei) {
- EggNode *egg_node = (*ei);
- bool matched = false;
- for (di = extra_data.begin(); di != extra_data.end(); ++di) {
- EggJointData *data = (*di);
- if (data->matches_name(egg_node->get_name())) {
- found_egg_match(char_data, data, egg_node, egg_index, model_index);
- extra_data.erase(di);
- matched = true;
- break;
- }
- }
-
- if (!matched) {
- // This joint name was never seen before.
- more_egg_nodes.push_back(egg_node);
- }
- }
- extra_egg_nodes.swap(more_egg_nodes);
- }
-
- if (!extra_egg_nodes.empty()) {
- // Ok, we've still got to find a home for these remaining egg_nodes.
- if (extra_egg_nodes.size() == extra_data.size()) {
- // Match 'em up one-for-one.
- size_t i;
- for (i = 0; i < extra_egg_nodes.size(); i++) {
- EggNode *egg_node = extra_egg_nodes[i];
- EggJointData *data = extra_data[i];
- found_egg_match(char_data, data, egg_node, egg_index, model_index);
- }
-
- } else {
- // Just tack 'em on the end.
- EggNodeList::iterator ei;
- for (ei = extra_egg_nodes.begin(); ei != extra_egg_nodes.end(); ++ei) {
- EggNode *egg_node = (*ei);
- EggJointData *data = make_joint_data(char_data);
- joint_data->_children.push_back(data);
- char_data->_joints.push_back(data);
- char_data->_components.push_back(data);
- data->_parent = joint_data;
- data->_new_parent = joint_data;
- found_egg_match(char_data, data, egg_node, egg_index, model_index);
- }
- }
- }
- }
-
- // Now sort the generated joint data hierarchy by name, just to be sure.
- sort(joint_data->_children.begin(), joint_data->_children.end(),
- IndirectCompareNames());
-}
-
-/**
- * Marks a one-to-one association between the indicated EggJointData and the
- * indicated EggNode, and then recurses below.
- */
-void EggCharacterCollection::
-found_egg_match(EggCharacterData *char_data, EggJointData *joint_data,
- EggNode *egg_node, int egg_index, int model_index) {
- if (egg_node->has_name()) {
- joint_data->add_name(egg_node->get_name(), char_data->_component_names);
- }
- egg_node->set_name(joint_data->get_name());
- joint_data->add_back_pointer(model_index, egg_node);
-
- if (egg_node->is_of_type(EggGroupNode::get_class_type())) {
- EggGroupNode *group_node = DCAST(EggGroupNode, egg_node);
-
- // Now consider all the children of egg_node that are themselves joints or
- // tables.
- EggNodeList egg_nodes;
-
- // Two approaches: either we are scanning a model with joints, or an
- // animation bundle with tables.
-
- if (egg_node->is_of_type(EggGroup::get_class_type())) {
- // A model with joints.
- EggGroupNode::iterator gi;
- for (gi = group_node->begin(); gi != group_node->end(); ++gi) {
- EggNode *child = (*gi);
- if (child->is_of_type(EggGroup::get_class_type())) {
- EggGroup *group = DCAST(EggGroup, child);
- if (group->get_group_type() == EggGroup::GT_joint) {
- egg_nodes.push_back(group);
- }
- }
- }
-
- } else {
- // An animation bundle with tables.
- EggGroupNode::iterator gi;
- for (gi = group_node->begin(); gi != group_node->end(); ++gi) {
- EggNode *child = (*gi);
- if (child->is_of_type(EggTable::get_class_type())) {
- EggTable *table = DCAST(EggTable, child);
- if (!(table->get_name() == "xform")) {
- egg_nodes.push_back(table);
- }
- }
- }
- }
-
- if (!egg_nodes.empty()) {
- match_egg_nodes(char_data, joint_data, egg_nodes,
- egg_index, model_index);
- }
- }
-}
-
-/**
- * Renames the ith character to the indicated name. This name must not
- * already be used by another character in the collection.
- */
-void EggCharacterCollection::
-rename_char(int i, const string &name) {
- nassertv(i >= 0 && i < (int)_characters.size());
-
- EggCharacterData *char_data = _characters[i];
- if (char_data->get_name() != name) {
- nassertv(get_character_by_name(name) == nullptr);
- char_data->rename_char(name);
- }
-}
-
-/**
- *
- */
-void EggCharacterCollection::
-write(std::ostream &out, int indent_level) const {
- Characters::const_iterator ci;
-
- for (ci = _characters.begin(); ci != _characters.end(); ++ci) {
- EggCharacterData *char_data = (*ci);
- char_data->write(out, indent_level);
- }
-}
-
-/**
- * Can be called after the collection has been completely filled up with egg
- * files to output any messages from warning conditions that have been
- * detected, such as inconsistent animation tables.
- *
- * In addition to reporting this errors, calling this function will also
- * ensure that they are all repaired. Pass force_initial_rest_frame as true
- * to also force rest frames from different models to be the same if they are
- * initially different.
- */
-void EggCharacterCollection::
-check_errors(std::ostream &out, bool force_initial_rest_frame) {
- Characters::const_iterator ci;
- for (ci = _characters.begin(); ci != _characters.end(); ++ci) {
- EggCharacterData *char_data = (*ci);
- int num_joints = char_data->get_num_joints();
- for (int j = 0; j < num_joints; j++) {
- EggJointData *joint_data = char_data->get_joint(j);
- if (joint_data->rest_frames_differ()) {
- if (force_initial_rest_frame) {
- joint_data->force_initial_rest_frame();
- out << "Forced rest frames the same for " << joint_data->get_name()
- << ".\n";
- } else {
- out << "Warning: rest frames for " << joint_data->get_name()
- << " differ.\n";
- }
- }
- }
-
- int num_models = char_data->get_num_models();
- for (int mi = 0; mi < num_models; mi++) {
- int model_index = char_data->get_model_index(mi);
- if (!char_data->check_num_frames(model_index)) {
- out << "Warning: animation from "
- << char_data->get_egg_data(model_index)->get_egg_filename().get_basename()
- << " had an inconsistent number of frames.\n";
- }
- }
- }
-}
diff --git a/pandatool/src/eggcharbase/eggCharacterCollection.h b/pandatool/src/eggcharbase/eggCharacterCollection.h
deleted file mode 100644
index 8a0bbd4f..00000000
--- a/pandatool/src/eggcharbase/eggCharacterCollection.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggCharacterCollection.h
- * @author drose
- * @date 2001-02-26
- */
-
-#ifndef EGGCHARACTERCOLLECTION_H
-#define EGGCHARACTERCOLLECTION_H
-
-#include "pandatoolbase.h"
-
-#include "eggCharacterData.h"
-
-#include "eggData.h"
-#include "eggNode.h"
-#include "pointerTo.h"
-
-class EggTable;
-class EggAttributes;
-
-/**
- * Represents a set of characters, as read and collected from possibly several
- * model and/or animation egg files.
- */
-class EggCharacterCollection {
-public:
- EggCharacterCollection();
- virtual ~EggCharacterCollection();
-
- int add_egg(EggData *egg);
-
- INLINE int get_num_eggs() const;
- INLINE EggData *get_egg(int i) const;
- INLINE int get_first_model_index(int egg_index) const;
- INLINE int get_num_models(int egg_index) const;
-
- INLINE int get_num_characters() const;
- INLINE EggCharacterData *get_character(int i) const;
- EggCharacterData *get_character_by_name(const std::string &character_name) const;
-
- INLINE EggCharacterData *get_character_by_model_index(int model_index) const;
-
- void rename_char(int i, const std::string &name);
-
- virtual void write(std::ostream &out, int indent_level = 0) const;
- void check_errors(std::ostream &out, bool force_initial_rest_frame);
-
- virtual EggCharacterData *make_character_data();
- virtual EggJointData *make_joint_data(EggCharacterData *char_data);
- virtual EggSliderData *make_slider_data(EggCharacterData *char_data);
-
-public:
- EggCharacterData *make_character(const std::string &character_name);
-
- class EggInfo {
- public:
- PT(EggData) _egg;
- typedef pvector< PT(EggNode) > Models;
- Models _models;
- int _first_model_index;
- };
-
- typedef pvector Eggs;
- Eggs _eggs;
-
- typedef pvector Characters;
- Characters _characters;
- Characters _characters_by_model_index;
-
-private:
- bool scan_hierarchy(EggNode *egg_node);
- void scan_for_top_joints(EggNode *egg_node, EggNode *model_root,
- const std::string &character_name);
- void scan_for_top_tables(EggTable *bundle, EggNode *model_root,
- const std::string &character_name);
- void scan_for_morphs(EggNode *egg_node, int model_index,
- EggCharacterData *char_data);
- void scan_for_sliders(EggNode *egg_node, int model_index,
- EggCharacterData *char_data);
-
- void add_morph_back_pointers(EggAttributes *attrib, EggObject *egg_object,
- int model_index, EggCharacterData *char_data);
- void add_morph_back_pointers_vertex(EggVertex *vertex, EggObject *egg_object,
- int model_index, EggCharacterData *char_data);
-
- // The _top_egg_nodes member is only used temporarily, when adding each pre-
- // existing egg file to the structure for the first time.
- typedef pvector EggNodeList;
- class ModelDescription {
- public:
- INLINE ModelDescription();
- EggNodeList _top_nodes;
- EggObject *_root_node;
- };
-
- typedef pmap TopEggNodes;
- typedef pmap TopEggNodesByName;
- TopEggNodesByName _top_egg_nodes;
-
- int _next_model_index;
-
- void match_egg_nodes(EggCharacterData *char_Data, EggJointData *joint_data,
- EggNodeList &egg_nodes, int egg_index, int model_index);
- void found_egg_match(EggCharacterData *char_data, EggJointData *joint_data,
- EggNode *egg_node, int egg_index, int model_index);
-};
-
-#include "eggCharacterCollection.I"
-
-#endif
diff --git a/pandatool/src/eggcharbase/eggCharacterData.I b/pandatool/src/eggcharbase/eggCharacterData.I
deleted file mode 100644
index fc3d3f1b..00000000
--- a/pandatool/src/eggcharbase/eggCharacterData.I
+++ /dev/null
@@ -1,150 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggCharacterData.I
- * @author drose
- * @date 2001-02-23
- */
-
-/**
- * Returns the total number of models associated with this character.
- *
- * A "model" here is either a character model (or one LOD of a character
- * model), or a character animation file: in either case, a hierarchy of
- * joints.
- */
-INLINE int EggCharacterData::
-get_num_models() const {
- return _models.size();
-}
-
-/**
- * Returns the model_index of the nth model associated with this character.
- * This model_index may be used to ask questions about the particular model
- * from the EggCharacterCollection object, or from the individual EggJointData
- * and EggSliderData objects.
- *
- * A "model" here is either a character model (or one LOD of a character
- * model), or a character animation file: in either case, a hierarchy of
- * joints.
- */
-INLINE int EggCharacterData::
-get_model_index(int n) const {
- nassertr(n >= 0 && n < (int)_models.size(), 0);
- return _models[n]._model_index;
-}
-
-/**
- * Returns the model_root of the nth model associated with this character.
- *
- * This is the node at which the character, animation bundle, or LOD
- * officially began within its particular egg file.
- */
-INLINE EggNode *EggCharacterData::
-get_model_root(int n) const {
- nassertr(n >= 0 && n < (int)_models.size(), nullptr);
- return _models[n]._model_root;
-}
-
-/**
- * Returns the EggData representing the egg file that defined this particular
- * model. Note that one egg file might contain multiple models.
- */
-INLINE EggData *EggCharacterData::
-get_egg_data(int n) const {
- nassertr(n >= 0 && n < (int)_models.size(), nullptr);
- return _models[n]._egg_data;
-}
-
-/**
- * Returns the root joint of the character hierarchy. This root joint does
- * not represent an actual joint in the hierarchy, but instead is a fictitious
- * joint that is the parent of all the top joints in the hierarchy (since the
- * hierarchy may actually contain zero or more top joints).
- */
-INLINE EggJointData *EggCharacterData::
-get_root_joint() const {
- return _root_joint;
-}
-
-/**
- * Returns the first joint found with the indicated name, or NULL if no joint
- * has that name.
- */
-INLINE EggJointData *EggCharacterData::
-find_joint(const std::string &name) const {
- return _root_joint->find_joint(name);
-}
-
-/**
- * Creates a new joint as a child of the indicated joint and returns it. The
- * new joint will be initialized to the identity transform, so that in
- * inherits the net transform of the indicated parent joint.
- */
-INLINE EggJointData *EggCharacterData::
-make_new_joint(const std::string &name, EggJointData *parent) {
- EggJointData *joint = parent->make_new_joint(name);
- _joints.push_back(joint);
- _components.push_back(joint);
- return joint;
-}
-
-/**
- * Returns the total number of joints in the character joint hierarchy.
- */
-INLINE int EggCharacterData::
-get_num_joints() const {
- return _joints.size();
-}
-
-/**
- * Returns the nth joint in the character joint hierarchy. This returns all
- * of the joints in the hierarchy in an arbitrary ordering.
- */
-INLINE EggJointData *EggCharacterData::
-get_joint(int n) const {
- nassertr(n >= 0 && n < (int)_joints.size(), nullptr);
- return _joints[n];
-}
-
-/**
- * Returns the number of sliders in the character slider list.
- */
-INLINE int EggCharacterData::
-get_num_sliders() const {
- return _sliders.size();
-}
-
-/**
- * Returns the nth slider in the character slider list.
- */
-INLINE EggSliderData *EggCharacterData::
-get_slider(int n) const {
- nassertr(n >= 0 && n < (int)_sliders.size(), nullptr);
- return _sliders[n];
-}
-
-/**
- * Returns the total number of joints and sliders in the character.
- */
-INLINE int EggCharacterData::
-get_num_components() const {
- return _components.size();
-}
-
-/**
- * Returns the nth joint or slider in the character. This can be used to walk
- * linearly through all joints and sliders in the character when you don't
- * care about making a distinction between the two; it returns the same
- * objects that can also be discovered via get_slider() and get_root_joint().
- */
-INLINE EggComponentData *EggCharacterData::
-get_component(int n) const {
- nassertr(n >= 0 && n < (int)_components.size(), nullptr);
- return _components[n];
-}
diff --git a/pandatool/src/eggcharbase/eggCharacterData.cxx b/pandatool/src/eggcharbase/eggCharacterData.cxx
deleted file mode 100644
index d3c7a545..00000000
--- a/pandatool/src/eggcharbase/eggCharacterData.cxx
+++ /dev/null
@@ -1,410 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggCharacterData.cxx
- * @author drose
- * @date 2001-02-23
- */
-
-#include "eggCharacterData.h"
-#include "eggCharacterCollection.h"
-#include "eggCharacterDb.h"
-#include "eggJointData.h"
-#include "eggSliderData.h"
-#include "indent.h"
-
-#include
-
-// An STL function object to sort the joint list in order from highest to
-// lowest in the new hierarchy. Used in do_reparent().
-class OrderJointsByNewDepth {
-public:
- bool operator()(const EggJointData *a, const EggJointData *b) const {
- return a->_new_parent_depth < b->_new_parent_depth;
- }
-};
-
-
-/**
- *
- */
-EggCharacterData::
-EggCharacterData(EggCharacterCollection *collection) :
- _component_names("_", "joint_")
-{
- _collection = collection;
- _root_joint = _collection->make_joint_data(this);
- // The fictitious root joint is not added to the _components list.
-}
-
-/**
- *
- */
-EggCharacterData::
-~EggCharacterData() {
- delete _root_joint;
-
- Sliders::iterator si;
- for (si = _sliders.begin(); si != _sliders.end(); ++si) {
- EggSliderData *slider = (*si);
- delete slider;
- }
-}
-
-/**
- * Renames all of the models in the character data to the indicated name.
- * This is the name that is used to identify unique skeleton hierarchies; if
- * you set two different models to the same name, they will be loaded together
- * as if they are expected to have the same skeleton hierarchy.
- */
-void EggCharacterData::
-rename_char(const std::string &name) {
- Models::iterator mi;
- for (mi = _models.begin(); mi != _models.end(); ++mi) {
- (*mi)._model_root->set_name(name);
- }
-
- set_name(name);
-}
-
-/**
- * Indicates that the given model_index (with the indicated model_root) is
- * associated with this character. This is normally called by the
- * EggCharacterCollection class as new models are discovered.
- *
- * A "model" here is either a character model (or one LOD of a character
- * model), or a character animation file: in either case, a hierarchy of
- * joints.
- */
-void EggCharacterData::
-add_model(int model_index, EggNode *model_root, EggData *egg_data) {
- Model m;
- m._model_index = model_index;
- m._model_root = model_root;
- m._egg_data = egg_data;
- _models.push_back(m);
-}
-
-/**
- * Returns the number of frames of animation of the indicated model. This is
- * more reliable than asking a particular joint or slider of the animation for
- * its number of frames, since a particular joint may have only 1 frame (if it
- * is unanimated), even though the overall animation has many frames.
- */
-int EggCharacterData::
-get_num_frames(int model_index) const {
- int max_num_frames = 0;
- Components::const_iterator ci;
- for (ci = _components.begin(); ci != _components.end(); ++ci) {
- EggComponentData *component = (*ci);
- int num_frames = component->get_num_frames(model_index);
- if (num_frames > 1) {
- // We have a winner. Assume all other components will be similar.
- return num_frames;
- }
- max_num_frames = std::max(max_num_frames, num_frames);
- }
-
- // Every component had either 1 frame or 0 frames. Return the maximum of
- // these.
- return max_num_frames;
-}
-
-/**
- * Returns the stated frame rate of the specified model. Similar to
- * get_num_frames().
- */
-double EggCharacterData::
-get_frame_rate(int model_index) const {
- Components::const_iterator ci;
- for (ci = _components.begin(); ci != _components.end(); ++ci) {
- EggComponentData *component = (*ci);
- double frame_rate = component->get_frame_rate(model_index);
- if (frame_rate != 0.0) {
- // We have a winner. Assume all other components will be similar.
- return frame_rate;
- }
- }
-
- return 0.0;
-}
-
-/**
- * Walks through each component and ensures that all have the same number of
- * frames of animation (except for those that contain 0 or 1 frames, of
- * course). Returns true if all are valid, false if there is a discreprency
- * (in which case the shorter component are extended).
- */
-bool EggCharacterData::
-check_num_frames(int model_index) {
- int max_num_frames = 0;
- bool any_violations = false;
- Components::const_iterator ci;
- for (ci = _components.begin(); ci != _components.end(); ++ci) {
- EggComponentData *component = (*ci);
- int num_frames = component->get_num_frames(model_index);
- if (num_frames > 1 && max_num_frames > 1 &&
- max_num_frames != num_frames) {
- // If we have two different opinions about the number of frames (other
- // than 0 or 1), we have a discrepency. This is an error condition.
- any_violations = true;
- }
- max_num_frames = std::max(max_num_frames, num_frames);
- }
-
- if (any_violations) {
- // Now go back through and force all components to the appropriate length.
- for (ci = _components.begin(); ci != _components.end(); ++ci) {
- EggComponentData *component = (*ci);
- int num_frames = component->get_num_frames(model_index);
- if (num_frames > 1 && max_num_frames != num_frames) {
- component->extend_to(model_index, max_num_frames);
- }
- }
- }
-
- return !any_violations;
-}
-
-/**
- * Begins the process of restructuring the joint hierarchy according to the
- * previous calls to reparent_to() on various joints. This will reparent the
- * joint hierachy in all models as requested, while adjusting the transforms
- * as appropriate so that each joint retains the same net transform across all
- * frames that it had before the operation. Returns true on success, false on
- * failure.
- */
-bool EggCharacterData::
-do_reparent() {
- typedef pset InvalidSet;
- InvalidSet invalid_set;
-
- // To begin, make sure the list of new_children is accurate.
- Joints::const_iterator ji;
- for (ji = _joints.begin(); ji != _joints.end(); ++ji) {
- EggJointData *joint_data = (*ji);
- joint_data->do_begin_reparent();
- }
- // We also need to clear the children on the root joint, but the root joint
- // doesn't get any of the other operations (including finish_reparent)
- // applied to it.
- _root_joint->do_begin_reparent();
-
-
- // Now, check for cycles in the new parenting hierarchy, and also sort the
- // joints in order from top to bottom in the new hierarchy.
- for (ji = _joints.begin(); ji != _joints.end(); ++ji) {
- EggJointData *joint_data = (*ji);
- pset chain;
- if (joint_data->calc_new_parent_depth(chain)) {
- nout << "Cycle detected in parent chain for " << joint_data->get_name()
- << "!\n";
- return false;
- }
- }
- sort(_joints.begin(), _joints.end(), OrderJointsByNewDepth());
-
- // Now compute the new transforms for the joints' new positions. This is
- // done recursively through the new parent hierarchy, so we can take
- // advantage of caching the net value for a particular frame.
- Models::const_iterator mi;
- for (mi = _models.begin(); mi != _models.end(); ++mi) {
- EggCharacterDb db;
- int model_index = (*mi)._model_index;
- int num_frames = get_num_frames(model_index);
- nout << " computing " << (mi - _models.begin()) + 1
- << " of " << _models.size()
- << ": " << (*mi)._egg_data->get_egg_filename()
- << " (" << num_frames << " frames)\n";
- for (int f = 0; f < num_frames; f++) {
- // First, walk through all the joints and flush the computed net
- // transforms from before.
- for (ji = _joints.begin(); ji != _joints.end(); ++ji) {
- EggJointData *joint_data = (*ji);
- joint_data->do_begin_compute_reparent();
- }
- _root_joint->do_begin_compute_reparent();
-
- // Now go back through and compute the reparented transforms, caching
- // net transforms as necessary.
- for (ji = _joints.begin(); ji != _joints.end(); ++ji) {
- EggJointData *joint_data = (*ji);
- if (!joint_data->do_compute_reparent(model_index, f, db)) {
- // Oops, we got an invalid transform.
- invalid_set.insert(joint_data);
- }
- }
- }
-
- // Finally, apply the computations to the joints.
- for (ji = _joints.begin(); ji != _joints.end(); ++ji) {
- EggJointData *joint_data = (*ji);
- if (!joint_data->do_joint_rebuild(model_index, db)) {
- invalid_set.insert(joint_data);
- }
- }
- }
-
- // Now remove all of the old children and add in the new children.
- for (ji = _joints.begin(); ji != _joints.end(); ++ji) {
- EggJointData *joint_data = (*ji);
- joint_data->do_finish_reparent();
- }
-
- // Report the set of joints that failed. It really shouldn't be possible
- // for any joints to fail, so if you see anything reported here, something
- // went wrong at a fundamental level. Perhaps a problem with
- // decompose_matrix().
- InvalidSet::const_iterator si;
- for (si = invalid_set.begin(); si != invalid_set.end(); ++si) {
- EggJointData *joint_data = (*si);
- // Don't bother reporting joints that no longer have a parent, since we
- // don't care about joints that are now outside the hierarchy.
- if (joint_data->get_parent() != nullptr) {
- nout << "Warning: reparenting " << joint_data->get_name()
- << " to ";
- if (joint_data->get_parent() == _root_joint) {
- nout << "the root";
- } else {
- nout << joint_data->get_parent()->get_name();
- }
- nout << " results in an invalid transform.\n";
- }
- }
-
- return invalid_set.empty();
-}
-
-/**
- * Chooses the best possible parent joint for each of the joints in the
- * hierarchy, based on the score computed by
- * EggJointData::score_reparent_to(). This is a fairly expensive operation
- * that involves lots of recomputing of transforms across the hierarchy.
- *
- * The joints are not actually reparented yet, but the new_parent of each
- * joint is set. Call do_reparent() to actually perform the suggested
- * reparenting operation.
- */
-void EggCharacterData::
-choose_optimal_hierarchy() {
- EggCharacterDb db;
-
- Joints::const_iterator ji, jj;
- for (ji = _joints.begin(); ji != _joints.end(); ++ji) {
- EggJointData *joint_data = (*ji);
-
- EggJointData *best_parent = joint_data->get_parent();
- int best_score = joint_data->score_reparent_to(best_parent, db);
-
- for (jj = _joints.begin(); jj != _joints.end(); ++jj) {
- EggJointData *possible_parent = (*jj);
- if (possible_parent != joint_data && possible_parent != best_parent &&
- !joint_data->is_new_ancestor(possible_parent)) {
-
- int score = joint_data->score_reparent_to(possible_parent, db);
- if (score >= 0 && (best_score < 0 || score < best_score)) {
- best_parent = possible_parent;
- best_score = score;
- }
- }
- }
-
- // Also consider reparenting the node to the root.
- EggJointData *possible_parent = get_root_joint();
- if (possible_parent != best_parent) {
- int score = joint_data->score_reparent_to(possible_parent, db);
- if (score >= 0 && (best_score < 0 || score < best_score)) {
- best_parent = possible_parent;
- best_score = score;
- }
- }
-
- if (best_parent != nullptr &&
- best_parent != joint_data->_parent) {
- nout << "best parent for " << joint_data->get_name() << " is "
- << best_parent->get_name() << "\n";
- joint_data->reparent_to(best_parent);
- }
- }
-}
-
-/**
- * Returns the slider with the indicated name, or NULL if no slider has that
- * name.
- */
-EggSliderData *EggCharacterData::
-find_slider(const std::string &name) const {
- SlidersByName::const_iterator si;
- si = _sliders_by_name.find(name);
- if (si != _sliders_by_name.end()) {
- return (*si).second;
- }
-
- return nullptr;
-}
-
-/**
- * Returns the slider matching the indicated name. If no such slider exists
- * already, creates a new one.
- */
-EggSliderData *EggCharacterData::
-make_slider(const std::string &name) {
- SlidersByName::const_iterator si;
- si = _sliders_by_name.find(name);
- if (si != _sliders_by_name.end()) {
- return (*si).second;
- }
-
- EggSliderData *slider = _collection->make_slider_data(this);
- slider->set_name(name);
- _sliders_by_name.insert(SlidersByName::value_type(name, slider));
- _sliders.push_back(slider);
- _components.push_back(slider);
- return slider;
-}
-
-/**
- * Returns the estimated amount of memory, in megabytes, that will be required
- * to perform the do_reparent() operation. This is used mainly be
- * EggCharacterDb to decide up front whether to store this data in-RAM or on-
- * disk.
- */
-size_t EggCharacterData::
-estimate_db_size() const {
- // Count how much memory we will need to store the interim transforms. This
- // is models * joints * frames * 3 * sizeof(LMatrix4d).
- size_t mj_frames = 0;
- Models::const_iterator mi;
- for (mi = _models.begin(); mi != _models.end(); ++mi) {
- int model_index = (*mi)._model_index;
- size_t num_frames = (size_t)get_num_frames(model_index);
- mj_frames += num_frames * _joints.size();
- }
-
- // We do this operation a bit carefully, to guard against integer overflow.
- size_t mb_needed = ((mj_frames * 3 / 1024) * sizeof(LMatrix4d)) / 1024;
-
- return mb_needed;
-}
-
-
-/**
- *
- */
-void EggCharacterData::
-write(std::ostream &out, int indent_level) const {
- indent(out, indent_level)
- << "Character " << get_name() << ":\n";
- get_root_joint()->write(out, indent_level + 2);
-
- Sliders::const_iterator si;
- for (si = _sliders.begin(); si != _sliders.end(); ++si) {
- EggSliderData *slider = (*si);
- slider->write(out, indent_level + 2);
- }
-}
diff --git a/pandatool/src/eggcharbase/eggCharacterData.h b/pandatool/src/eggcharbase/eggCharacterData.h
deleted file mode 100644
index f488e335..00000000
--- a/pandatool/src/eggcharbase/eggCharacterData.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggCharacterData.h
- * @author drose
- * @date 2001-02-23
- */
-
-#ifndef EGGCHARACTERDATA_H
-#define EGGCHARACTERDATA_H
-
-#include "pandatoolbase.h"
-
-#include "eggJointData.h"
-#include "eggNode.h"
-#include "eggData.h"
-#include "pointerTo.h"
-#include "namable.h"
-#include "nameUniquifier.h"
-
-#include "pmap.h"
-
-class EggCharacterCollection;
-class EggSliderData;
-class EggCharacterDb;
-
-/**
- * Represents a single character, as read and collected from several models
- * and animation files. This contains a hierarchy of EggJointData nodes
- * representing the skeleton, as well as a list of EggSliderData nodes
- * representing the morph channels for the character.
- *
- * This is very similar to the Character class from Panda, in that it's
- * capable of associating skeleton-morph animation channels with models and
- * calculating the vertex position for each frame. To some degree, it
- * duplicates the functionality of Character. However, it differs in one
- * fundamental principle: it is designed to be a non-real-time operation,
- * working directly on the Egg structures as they are, instead of first
- * boiling the Egg data into native Panda Geom tables for real-time animation.
- * Because of this, it is (a) double-precision instead of single precision,
- * (b) capable of generating modified Egg files, and (c) about a hundred times
- * slower than the Panda Character class.
- *
- * The data in this structure is normally filled in by the
- * EggCharacterCollection class.
- */
-class EggCharacterData : public Namable {
-public:
- EggCharacterData(EggCharacterCollection *collection);
- virtual ~EggCharacterData();
-
- void rename_char(const std::string &name);
-
- void add_model(int model_index, EggNode *model_root, EggData *egg_data);
- INLINE int get_num_models() const;
- INLINE int get_model_index(int n) const;
- INLINE EggNode *get_model_root(int n) const;
- INLINE EggData *get_egg_data(int n) const;
- int get_num_frames(int model_index) const;
- bool check_num_frames(int model_index);
- double get_frame_rate(int model_index) const;
-
- INLINE EggJointData *get_root_joint() const;
- INLINE EggJointData *find_joint(const std::string &name) const;
- INLINE EggJointData *make_new_joint(const std::string &name, EggJointData *parent);
- INLINE int get_num_joints() const;
- INLINE EggJointData *get_joint(int n) const;
-
- bool do_reparent();
- void choose_optimal_hierarchy();
-
- INLINE int get_num_sliders() const;
- INLINE EggSliderData *get_slider(int n) const;
- EggSliderData *find_slider(const std::string &name) const;
- EggSliderData *make_slider(const std::string &name);
-
- INLINE int get_num_components() const;
- INLINE EggComponentData *get_component(int n) const;
-
- size_t estimate_db_size() const;
-
- virtual void write(std::ostream &out, int indent_level = 0) const;
-
-private:
- class Model {
- public:
- int _model_index;
- PT(EggNode) _model_root;
- PT(EggData) _egg_data;
- };
- typedef pvector Models;
- Models _models;
-
- EggCharacterCollection *_collection;
- EggJointData *_root_joint;
-
- typedef pmap SlidersByName;
- SlidersByName _sliders_by_name;
-
- typedef pvector Sliders;
- Sliders _sliders;
-
- typedef pvector Joints;
- Joints _joints;
-
- typedef pvector Components;
- Components _components;
-
- NameUniquifier _component_names;
-
- friend class EggCharacterCollection;
-};
-
-#include "eggCharacterData.I"
-
-#endif
diff --git a/pandatool/src/eggcharbase/eggCharacterDb.I b/pandatool/src/eggcharbase/eggCharacterDb.I
deleted file mode 100644
index f530b93a..00000000
--- a/pandatool/src/eggcharbase/eggCharacterDb.I
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggCharacterDb.I
- * @author drose
- * @date 2006-10-05
- */
-
-/**
- *
- */
-INLINE EggCharacterDb::Key::
-Key(const EggJointPointer *joint, TableType table_type, int frame) :
- _joint(joint),
- _table_type(table_type),
- _frame(frame)
-{
-}
-
-/**
- * Provides an arbitrary unique ordering for all keys.
- */
-INLINE bool EggCharacterDb::Key::
-operator < (const EggCharacterDb::Key &other) const {
- if (_joint != other._joint) {
- return _joint < other._joint;
- }
- if (_table_type != other._table_type) {
- return _table_type < other._table_type;
- }
- return _frame < other._frame;
-}
diff --git a/pandatool/src/eggcharbase/eggCharacterDb.cxx b/pandatool/src/eggcharbase/eggCharacterDb.cxx
deleted file mode 100644
index e959499b..00000000
--- a/pandatool/src/eggcharbase/eggCharacterDb.cxx
+++ /dev/null
@@ -1,125 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggCharacterDb.cxx
- * @author drose
- * @date 2006-10-05
- */
-
-#include "eggCharacterDb.h"
-#include "eggCharacterData.h"
-
-/**
- * Constructs a database for storing the interim work for the indicated
- * EggCharacterData. The parameter max_ram_mb indicates the maximum amount of
- * RAM (in MB) that the database should consume; if it the database would
- * roughly fit within this limit, it will be stored in RAM; otherwise, it will
- * be written to disk (if Berkeley DB is available).
- */
-EggCharacterDb::
-EggCharacterDb() {
- /*
-#ifdef HAVE_BDB
- _db = NULL;
-
- _db = new Db(NULL, 0);
- _db_filename = Filename::temporary("", "eggc_", ".db");
-
- string os_db_filename = _db_filename.to_os_specific();
- _db->open(NULL, os_db_filename.c_str(), NULL,
- DB_BTREE, DB_CREATE | DB_EXCL, 0);
-
- nout << "Using " << os_db_filename << " for rebuild database.\n";
-#endif // HAVE_BDB
- */
-}
-
-/**
- *
- */
-EggCharacterDb::
-~EggCharacterDb() {
- /*
-#ifdef HAVE_BDB
- if (_db != (Db *)NULL){
- _db->close(0);
- delete _db;
- _db = NULL;
-
- string os_db_filename = _db_filename.to_os_specific();
- Db rmdb(NULL, 0);
- rmdb.remove(os_db_filename.c_str(), NULL, 0);
- }
-#endif // HAVE_BDB
- */
-}
-
-/**
- * Looks up the data for the indicated joint, type, and frame, and fills it in
- * result (and returns true) if it is found. Returns false if this data has
- * not been stored in the database.
- */
-bool EggCharacterDb::
-get_matrix(const EggJointPointer *joint, TableType type,
- int frame, LMatrix4d &mat) const {
- Key key(joint, type, frame);
-
- /*
-#ifdef HAVE_BDB
- if (_db != (Db *)NULL){
- Dbt db_key(&key, sizeof(Key));
- Dbt db_data(&mat, sizeof(LMatrix4d));
- db_data.set_ulen(sizeof(LMatrix4d));
- db_data.set_flags(DB_DBT_USERMEM);
-
- int result = _db->get(NULL, &db_key, &db_data, 0);
- if (result == DB_NOTFOUND) {
- return false;
- }
- nassertr(result == 0, false);
- return true;
- }
-#endif // HAVE_BDB
- */
-
- Table::const_iterator ti;
- ti = _table.find(key);
- if (ti == _table.end()) {
- return false;
- }
-
- mat = (*ti).second;
- return true;
-}
-
-/**
- * Stores the matrix for the indicated joint, type, and frame in the database.
- * It is an error to call this more than once for any given key combination
- * (not for any technical reason, but because we don't expect this to happen).
- */
-void EggCharacterDb::
-set_matrix(const EggJointPointer *joint, TableType type,
- int frame, const LMatrix4d &mat) {
- Key key(joint, type, frame);
-
- /*
-#ifdef HAVE_BDB
- if (_db != (Db *)NULL){
- Dbt db_key(&key, sizeof(Key));
- Dbt db_data((void *)&mat, sizeof(LMatrix4d));
- int result = _db->put(NULL, &db_key, &db_data, DB_NOOVERWRITE);
- nassertv(result != DB_KEYEXIST);
- nassertv(result == 0);
- return;
- }
-#endif // HAVE_BDB
- */
-
- bool inserted = _table.insert(Table::value_type(key, mat)).second;
- nassertv(inserted);
-}
diff --git a/pandatool/src/eggcharbase/eggCharacterDb.h b/pandatool/src/eggcharbase/eggCharacterDb.h
deleted file mode 100644
index 31af55f2..00000000
--- a/pandatool/src/eggcharbase/eggCharacterDb.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggCharacterDb.h
- * @author drose
- * @date 2006-10-05
- */
-
-#ifndef EGGCHARACTERDB_H
-#define EGGCHARACTERDB_H
-
-#include "pandatoolbase.h"
-#include "pmap.h"
-
-/*
-#ifdef HAVE_BDB
-
-// Apparently, we have to define this to make db_cxx files include the modern
-// header files.
-#define HAVE_CXX_STDHEADERS 1
-#include
-
-#endif // HAVE_BDB
-*/
-
-class EggJointPointer;
-class LMatrix4d;
-
-/**
- * This class is used during joint optimization or restructuring to store the
- * table of interim joint computations.
- *
- * That is to say, this class provides an temporary data store for three
- * tables of matrices per each EggJointPointer per frame.
- */
-class EggCharacterDb {
-public:
- EggCharacterDb();
- ~EggCharacterDb();
-
- enum TableType {
- TT_rebuild_frame,
- TT_net_frame,
- TT_net_frame_inv,
- };
-
- bool get_matrix(const EggJointPointer *joint, TableType type,
- int frame, LMatrix4d &mat) const;
- void set_matrix(const EggJointPointer *joint, TableType type,
- int frame, const LMatrix4d &mat);
-
-private:
- class Key {
- public:
- INLINE Key(const EggJointPointer *joint,
- TableType table_type,
- int frame);
- INLINE bool operator < (const Key &other) const;
-
- private:
- const EggJointPointer *_joint;
- TableType _table_type;
- int _frame;
- };
-
- /*
-#ifdef HAVE_BDB
- Db *_db;
- Filename _db_filename;
-#endif // HAVE_BDB
- */
-
- typedef pmap Table;
- Table _table;
-};
-
-#include "eggCharacterDb.I"
-
-#endif
diff --git a/pandatool/src/eggcharbase/eggCharacterFilter.cxx b/pandatool/src/eggcharbase/eggCharacterFilter.cxx
deleted file mode 100644
index 02289dbe..00000000
--- a/pandatool/src/eggcharbase/eggCharacterFilter.cxx
+++ /dev/null
@@ -1,108 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggCharacterFilter.cxx
- * @author drose
- * @date 2001-02-23
- */
-
-#include "eggCharacterFilter.h"
-#include "eggCharacterCollection.h"
-#include "eggCharacterData.h"
-
-
-/**
- *
- */
-EggCharacterFilter::
-EggCharacterFilter() : EggMultiFilter(false) {
- _collection = nullptr;
-
- _force_initial_rest_frame = false;
-}
-
-/**
- *
- */
-EggCharacterFilter::
-~EggCharacterFilter() {
- delete _collection;
-}
-
-/**
- *
- */
-void EggCharacterFilter::
-add_fixrest_option() {
- add_option
- ("fixrest", "", 30,
- "Specify this to force all the initial rest frames of the various "
- "model files to the same value as the first model specified. This "
- "is a fairly drastic way to repair models whose initial rest frame "
- "values are completely bogus, but should not be performed when the "
- "input models are correct.",
- &EggCharacterFilter::dispatch_none, &_force_initial_rest_frame);
-}
-
-
-/**
- *
- */
-bool EggCharacterFilter::
-post_command_line() {
- if (_collection == nullptr) {
- _collection = make_collection();
- }
-
- if (!EggMultiFilter::post_command_line()) {
- return false;
- }
-
- Eggs::iterator ei;
- for (ei = _eggs.begin(); ei != _eggs.end(); ++ei) {
- EggData *data = (*ei);
-
- if (_collection->add_egg(data) < 0) {
- nout << data->get_egg_filename().get_basename()
- << " does not contain a character model or animation channel.\n";
- return false;
- }
- }
-
- _collection->check_errors(nout, _force_initial_rest_frame);
-
- return true;
-}
-
-/**
- * Writes out all of the egg files in the _eggs vector, to the output
- * directory if one is specified, or over the input files if -inplace was
- * specified.
- */
-void EggCharacterFilter::
-write_eggs() {
- // Optimize (that is, collapse redudant nodes) in all of the characters'
- // joint tables before writing them out.
- int num_characters = _collection->get_num_characters();
- for (int i = 0; i < num_characters; i++) {
- EggCharacterData *char_data = _collection->get_character(i);
- char_data->get_root_joint()->optimize();
- }
-
- EggMultiFilter::write_eggs();
-}
-
-/**
- * Allocates and returns a new EggCharacterCollection structure. This is
- * primarily intended as a hook so derived classes can customize the type of
- * EggCharacterCollection object used to represent the character information.
- */
-EggCharacterCollection *EggCharacterFilter::
-make_collection() {
- return new EggCharacterCollection;
-}
diff --git a/pandatool/src/eggcharbase/eggCharacterFilter.h b/pandatool/src/eggcharbase/eggCharacterFilter.h
deleted file mode 100644
index c58536fa..00000000
--- a/pandatool/src/eggcharbase/eggCharacterFilter.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggCharacterFilter.h
- * @author drose
- * @date 2001-02-23
- */
-
-#ifndef EGGCHARACTERFILTER_H
-#define EGGCHARACTERFILTER_H
-
-#include "pandatoolbase.h"
-
-#include "eggMultiFilter.h"
-
-class EggCharacterData;
-class EggCharacterCollection;
-
-/**
- * This is the base class for a family of programs that operate on a number of
- * character models and their associated animation files together. It reads
- * in a number of egg files, any combination of model files or character files
- * which must all represent the same character skeleton, and maintains a
- * single hierarchy of joints and sliders that may be operated on before
- * writing the files back out.
- */
-class EggCharacterFilter : public EggMultiFilter {
-public:
- EggCharacterFilter();
- virtual ~EggCharacterFilter();
-
- void add_fixrest_option();
-
-protected:
- virtual bool post_command_line();
- virtual void write_eggs();
-
- virtual EggCharacterCollection *make_collection();
-
- EggCharacterCollection *_collection;
- bool _force_initial_rest_frame;
-};
-
-#endif
diff --git a/pandatool/src/eggcharbase/eggComponentData.I b/pandatool/src/eggcharbase/eggComponentData.I
deleted file mode 100644
index e0064948..00000000
--- a/pandatool/src/eggcharbase/eggComponentData.I
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggComponentData.I
- * @author drose
- * @date 2001-02-26
- */
-
-/**
- * Returns the maximum number of back pointers this component may have. The
- * component may store a back pointer for models indexed 0 .. num_models - 1.
- * You must call has_model() on each model index to confirm whether a
- * particular model in that range has a back pointer.
- */
-INLINE int EggComponentData::
-get_num_models() const {
- return _back_pointers.size();
-}
-
-/**
- * Returns true if the component has a back pointer to an egg file somewhere
- * for the indicated model, false otherwise.
- */
-INLINE bool EggComponentData::
-has_model(int model_index) const {
- if (model_index >= 0 && model_index < (int)_back_pointers.size()) {
- return _back_pointers[model_index] != nullptr;
- }
- return false;
-}
-
-/**
- * Returns the back pointer to an egg file for the indicated model if it
- * exists, or NULL if it does not.
- */
-INLINE EggBackPointer *EggComponentData::
-get_model(int model_index) const {
- if (model_index >= 0 && model_index < (int)_back_pointers.size()) {
- return _back_pointers[model_index];
- }
- return nullptr;
-}
diff --git a/pandatool/src/eggcharbase/eggComponentData.cxx b/pandatool/src/eggcharbase/eggComponentData.cxx
deleted file mode 100644
index ab57e5bd..00000000
--- a/pandatool/src/eggcharbase/eggComponentData.cxx
+++ /dev/null
@@ -1,128 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggComponentData.cxx
- * @author drose
- * @date 2001-02-26
- */
-
-#include "eggComponentData.h"
-#include "eggBackPointer.h"
-#include "nameUniquifier.h"
-
-#include "indent.h"
-
-TypeHandle EggComponentData::_type_handle;
-
-
-/**
- *
- */
-EggComponentData::
-EggComponentData(EggCharacterCollection *collection,
- EggCharacterData *char_data) :
- _collection(collection),
- _char_data(char_data)
-{
-}
-
-/**
- *
- */
-EggComponentData::
-~EggComponentData() {
- for (EggBackPointer *back : _back_pointers) {
- delete back;
- }
-}
-
-/**
- * Adds the indicated name to the set of names that this component can be
- * identified with. If this is the first name added, it becomes the primary
- * name of the component; later names added do not replace the primary name,
- * but do get added to the list of names that will be accepted by
- * matched_name().
- */
-void EggComponentData::
-add_name(const std::string &name, NameUniquifier &uniquifier) {
- if (_names.insert(name).second) {
- // This is a new name for this component.
- if (!has_name()) {
- set_name(uniquifier.add_name(name));
- if (get_name() != name) {
- nout << "Warning: renamed " << name << " to " << get_name()
- << " to avoid naming conflict.\n";
- }
- }
- }
-}
-
-/**
- * Returns true if the indicated name matches any name that was ever matched
- * with this particular joint, false otherwise.
- */
-bool EggComponentData::
-matches_name(const std::string &name) const {
- if (name == get_name()) {
- return true;
- }
- return (_names.find(name) != _names.end());
-}
-
-/**
- * Returns the number of frames of animation for this particular component in
- * the indicated model.
- */
-int EggComponentData::
-get_num_frames(int model_index) const {
- EggBackPointer *back = get_model(model_index);
- if (back == nullptr) {
- return 0;
- }
- return back->get_num_frames();
-}
-
-/**
- * Extends the number of frames in the indicated model (presumably an
- * animation table model) to the given number.
- */
-void EggComponentData::
-extend_to(int model_index, int num_frames) const {
- EggBackPointer *back = get_model(model_index);
- nassertv(back != nullptr);
- back->extend_to(num_frames);
-}
-
-/**
- * Returns the number of frames of animation for this particular component in
- * the indicated model.
- */
-double EggComponentData::
-get_frame_rate(int model_index) const {
- EggBackPointer *back = get_model(model_index);
- if (back == nullptr) {
- return 0.0;
- }
- return back->get_frame_rate();
-}
-
-/**
- * Sets the back_pointer associated with the given model_index.
- */
-void EggComponentData::
-set_model(int model_index, EggBackPointer *back) {
- while ((int)_back_pointers.size() <= model_index) {
- _back_pointers.push_back(nullptr);
- }
-
- if (_back_pointers[model_index] != nullptr) {
- nout << "Warning: deleting old back pointer.\n";
- delete _back_pointers[model_index];
- }
- _back_pointers[model_index] = back;
-}
diff --git a/pandatool/src/eggcharbase/eggComponentData.h b/pandatool/src/eggcharbase/eggComponentData.h
deleted file mode 100644
index b54c20ff..00000000
--- a/pandatool/src/eggcharbase/eggComponentData.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggComponentData.h
- * @author drose
- * @date 2001-02-26
- */
-
-#ifndef EGGCOMPONENTDATA_H
-#define EGGCOMPONENTDATA_H
-
-#include "pandatoolbase.h"
-
-#include "eggObject.h"
-#include "namable.h"
-#include "pset.h"
-
-class EggCharacterCollection;
-class EggCharacterData;
-class EggBackPointer;
-class NameUniquifier;
-
-/**
- * This is the base class of both EggJointData and EggSliderData. It
- * represents a single component of a character, either a joint or a slider,
- * along with back pointers to the references to this component in all model
- * and animation egg files read.
- */
-class EggComponentData : public EggObject, public Namable {
-public:
- EggComponentData(EggCharacterCollection *collection,
- EggCharacterData *char_data);
- virtual ~EggComponentData();
-
- void add_name(const std::string &name, NameUniquifier &uniquifier);
- bool matches_name(const std::string &name) const;
-
- int get_num_frames(int model_index) const;
- void extend_to(int model_index, int num_frames) const;
- double get_frame_rate(int model_index) const;
-
- virtual void add_back_pointer(int model_index, EggObject *egg_object)=0;
- virtual void write(std::ostream &out, int indent_level = 0) const=0;
-
- INLINE int get_num_models() const;
- INLINE bool has_model(int model_index) const;
- INLINE EggBackPointer *get_model(int model_index) const;
- void set_model(int model_index, EggBackPointer *back);
-
-protected:
-
- // This points back to all the egg structures that reference this particular
- // table or slider.
- typedef pvector BackPointers;
- BackPointers _back_pointers;
-
- typedef pset Names;
- Names _names;
-
- EggCharacterCollection *_collection;
- EggCharacterData *_char_data;
-
-
-public:
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- EggObject::init_type();
- register_type(_type_handle, "EggComponentData",
- EggObject::get_class_type());
- }
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
-
-private:
- static TypeHandle _type_handle;
-};
-
-#include "eggComponentData.I"
-
-#endif
diff --git a/pandatool/src/eggcharbase/eggJointData.I b/pandatool/src/eggcharbase/eggJointData.I
deleted file mode 100644
index c8b81967..00000000
--- a/pandatool/src/eggcharbase/eggJointData.I
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggJointData.I
- * @author drose
- * @date 2001-02-23
- */
-
-/**
- *
- */
-INLINE EggJointData *EggJointData::
-get_parent() const {
- return _parent;
-}
-
-/**
- *
- */
-INLINE int EggJointData::
-get_num_children() const {
- return _children.size();
-}
-
-/**
- *
- */
-INLINE EggJointData *EggJointData::
-get_child(int n) const {
- nassertr(n >= 0 && n < (int)_children.size(), nullptr);
- return _children[n];
-}
-
-/**
- * Returns the first descendent joint found with the indicated name, or NULL
- * if no joint has that name.
- */
-INLINE EggJointData *EggJointData::
-find_joint(const std::string &name) {
- EggJointData *joint = find_joint_exact(name);
- if (joint == nullptr) {
- joint = find_joint_matches(name);
- }
- return joint;
-}
-
-
-/**
- * Returns true if the joint knows its rest frame, false otherwise. In
- * general, this will be true as long as the joint is included in at least one
- * model file, or false if it appears only in animation files.
- */
-INLINE bool EggJointData::
-has_rest_frame() const {
- return _has_rest_frame;
-}
-
-/**
- * Returns true if the rest frames for different models differ in their
- * initial value. This is not technically an error, but it is unusual enough
- * to be suspicious.
- */
-INLINE bool EggJointData::
-rest_frames_differ() const {
- return _rest_frames_differ;
-}
-
-/**
- * Returns the rest frame of the joint. This is the matrix value that appears
- * for the joint in each model file; it should be the same transform in each
- * model.
- */
-INLINE const LMatrix4d &EggJointData::
-get_rest_frame() const {
- nassertr(has_rest_frame(), LMatrix4d::ident_mat());
- return _rest_frame;
-}
-
-/**
- * Indicates an intention to change the parent of this joint to the indicated
- * joint, or NULL to remove it from the hierarchy. The joint is not
- * reparented immediately, but rather all of the joints are reparented at once
- * when do_reparent() is called.
- */
-INLINE void EggJointData::
-reparent_to(EggJointData *new_parent) {
- _new_parent = new_parent;
-}
diff --git a/pandatool/src/eggcharbase/eggJointData.cxx b/pandatool/src/eggcharbase/eggJointData.cxx
deleted file mode 100644
index ebf656b1..00000000
--- a/pandatool/src/eggcharbase/eggJointData.cxx
+++ /dev/null
@@ -1,769 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggJointData.cxx
- * @author drose
- * @date 2001-02-23
- */
-
-#include "eggJointData.h"
-
-#include "eggCharacterDb.h"
-#include "eggJointNodePointer.h"
-#include "eggMatrixTablePointer.h"
-#include "pvector.h"
-#include "dcast.h"
-#include "eggGroup.h"
-#include "eggTable.h"
-#include "indent.h"
-#include "fftCompressor.h"
-#include "zStream.h"
-
-using std::string;
-
-TypeHandle EggJointData::_type_handle;
-
-
-/**
- *
- */
-EggJointData::
-EggJointData(EggCharacterCollection *collection,
- EggCharacterData *char_data) :
- EggComponentData(collection, char_data)
-{
- _parent = nullptr;
- _new_parent = nullptr;
- _has_rest_frame = false;
- _rest_frames_differ = false;
-}
-
-/**
- * Returns the local transform matrix corresponding to this joint position in
- * the nth frame in the indicated model.
- */
-LMatrix4d EggJointData::
-get_frame(int model_index, int n) const {
- EggBackPointer *back = get_model(model_index);
- if (back == nullptr) {
- return LMatrix4d::ident_mat();
- }
-
- EggJointPointer *joint;
- DCAST_INTO_R(joint, back, LMatrix4d::ident_mat());
-
- return joint->get_frame(n);
-}
-
-/**
- * Returns the complete transform from the root corresponding to this joint
- * position in the nth frame in the indicated model.
- */
-LMatrix4d EggJointData::
-get_net_frame(int model_index, int n, EggCharacterDb &db) const {
- EggBackPointer *back = get_model(model_index);
- if (back == nullptr) {
- return LMatrix4d::ident_mat();
- }
-
- EggJointPointer *joint;
- DCAST_INTO_R(joint, back, LMatrix4d::ident_mat());
-
- LMatrix4d mat;
- if (!db.get_matrix(joint, EggCharacterDb::TT_net_frame, n, mat)) {
- // Compute this frame's net, and stuff it in.
- mat = get_frame(model_index, n);
- if (_parent != nullptr) {
- mat = mat * _parent->get_net_frame(model_index, n, db);
- }
- db.set_matrix(joint, EggCharacterDb::TT_net_frame, n, mat);
- }
-
- return mat;
-}
-
-/**
- * Returns the inverse of get_net_frame().
- */
-LMatrix4d EggJointData::
-get_net_frame_inv(int model_index, int n, EggCharacterDb &db) const {
- EggBackPointer *back = get_model(model_index);
- if (back == nullptr) {
- return LMatrix4d::ident_mat();
- }
-
- EggJointPointer *joint;
- DCAST_INTO_R(joint, back, LMatrix4d::ident_mat());
-
- LMatrix4d mat;
- if (!db.get_matrix(joint, EggCharacterDb::TT_net_frame_inv, n, mat)) {
- // Compute this frame's net inverse, and stuff it in.
- LMatrix4d mat = get_net_frame(model_index, n, db);
- mat.invert_in_place();
- db.set_matrix(joint, EggCharacterDb::TT_net_frame_inv, n, mat);
- }
-
- return mat;
-}
-
-/**
- * Forces all of the joints to have the same rest frame value as the first
- * joint read in. This is a drastic way to repair models whose rest frame
- * values are completely bogus, but should not be performed on models that are
- * otherwise correct.
- */
-void EggJointData::
-force_initial_rest_frame() {
- if (!has_rest_frame()) {
- return;
- }
- int num_models = get_num_models();
- for (int model_index = 0; model_index < num_models; model_index++) {
- if (has_model(model_index)) {
- EggJointPointer *joint;
- DCAST_INTO_V(joint, get_model(model_index));
- if (joint->is_of_type(EggJointNodePointer::get_class_type())) {
- joint->set_frame(0, get_rest_frame());
- }
- }
- }
- _rest_frames_differ = false;
-}
-
-/**
- * Moves the vertices assigned to this joint into the indicated joint, without
- * changing their weight assignments.
- */
-void EggJointData::
-move_vertices_to(EggJointData *new_owner) {
- int num_models = get_num_models();
-
- if (new_owner == nullptr) {
- for (int model_index = 0; model_index < num_models; model_index++) {
- if (has_model(model_index)) {
- EggJointPointer *joint;
- DCAST_INTO_V(joint, get_model(model_index));
- joint->move_vertices_to(nullptr);
- }
- }
- } else {
- for (int model_index = 0; model_index < num_models; model_index++) {
- if (has_model(model_index) && new_owner->has_model(model_index)) {
- EggJointPointer *joint, *new_joint;
- DCAST_INTO_V(joint, get_model(model_index));
- DCAST_INTO_V(new_joint, new_owner->get_model(model_index));
- joint->move_vertices_to(new_joint);
- }
- }
- }
-}
-
-/**
- * Computes a score >= 0 reflecting the similarity of the current joint's
- * animation (in world space) to that of the indicated potential parent joint
- * (in world space). The lower the number, the more similar the motion, and
- * the more suitable is the proposed parent-child relationship. Returns -1 if
- * there is an error.
- */
-int EggJointData::
-score_reparent_to(EggJointData *new_parent, EggCharacterDb &db) {
- if (!FFTCompressor::is_compression_available()) {
- // If we don't have compression compiled in, we can't meaningfully score
- // the joints.
- return -1;
- }
-
- // First, build up a big array of the new transforms this joint would
- // receive in all frames of all models, were it reparented to the indicated
- // joint.
- vector_stdfloat i, j, k, a, b, c, x, y, z;
- pvector hprs;
- int num_rows = 0;
-
- int num_models = get_num_models();
- for (int model_index = 0; model_index < num_models; model_index++) {
- EggBackPointer *back = get_model(model_index);
- if (back != nullptr) {
- EggJointPointer *joint;
- DCAST_INTO_R(joint, back, false);
-
- int num_frames = get_num_frames(model_index);
- for (int n = 0; n < num_frames; n++) {
- LMatrix4d transform;
- if (_parent == new_parent) {
- // We already have this parent.
- transform = LMatrix4d::ident_mat();
-
- } else if (_parent == nullptr) {
- // We are moving from outside the joint hierarchy to within it.
- transform = new_parent->get_net_frame_inv(model_index, n, db);
-
- } else if (new_parent == nullptr) {
- // We are moving from within the hierarchy to outside it.
- transform = _parent->get_net_frame(model_index, n, db);
-
- } else {
- // We are changing parents within the hierarchy.
- transform =
- _parent->get_net_frame(model_index, n, db) *
- new_parent->get_net_frame_inv(model_index, n, db);
- }
-
- transform = joint->get_frame(n) * transform;
- LVecBase3d scale, shear, hpr, translate;
- if (!decompose_matrix(transform, scale, shear, hpr, translate)) {
- // Invalid transform.
- return -1;
- }
- i.push_back(scale[0]);
- j.push_back(scale[1]);
- k.push_back(scale[2]);
- a.push_back(shear[0]);
- b.push_back(shear[1]);
- c.push_back(shear[2]);
- hprs.push_back(LCAST(PN_stdfloat, hpr));
- x.push_back(translate[0]);
- y.push_back(translate[1]);
- z.push_back(translate[2]);
- num_rows++;
- }
- }
- }
-
- if (num_rows == 0) {
- // No data, no score.
- return -1;
- }
-
- // Now, we derive a score, by the simple expedient of using the
- // FFTCompressor to compress the generated transforms, and measuring the
- // length of the resulting bitstream.
- FFTCompressor compressor;
- Datagram dg;
- compressor.write_reals(dg, &i[0], num_rows);
- compressor.write_reals(dg, &j[0], num_rows);
- compressor.write_reals(dg, &k[0], num_rows);
- compressor.write_reals(dg, &a[0], num_rows);
- compressor.write_reals(dg, &b[0], num_rows);
- compressor.write_reals(dg, &c[0], num_rows);
- compressor.write_hprs(dg, &hprs[0], num_rows);
- compressor.write_reals(dg, &x[0], num_rows);
- compressor.write_reals(dg, &y[0], num_rows);
- compressor.write_reals(dg, &z[0], num_rows);
-
-
-#ifndef HAVE_ZLIB
- return dg.get_length();
-
-#else
- // The FFTCompressor does minimal run-length encoding, but to really get an
- // accurate measure we should zlib-compress the resulting stream.
- std::ostringstream sstr;
- OCompressStream zstr(&sstr, false);
- zstr.write((const char *)dg.get_data(), dg.get_length());
- zstr.flush();
- return sstr.str().length();
-#endif
-}
-
-/**
- * Calls do_rebuild() on all models, and recursively on all joints at this
- * node and below. Returns true if all models returned true, false otherwise.
- */
-bool EggJointData::
-do_rebuild_all(EggCharacterDb &db) {
- bool all_ok = true;
-
- BackPointers::iterator bpi;
- for (bpi = _back_pointers.begin(); bpi != _back_pointers.end(); ++bpi) {
- EggBackPointer *back = (*bpi);
- if (back != nullptr) {
- EggJointPointer *joint;
- DCAST_INTO_R(joint, back, false);
- if (!joint->do_rebuild(db)) {
- all_ok = false;
- }
- }
- }
-
- Children::iterator ci;
- for (ci = _children.begin(); ci != _children.end(); ++ci) {
- EggJointData *child = (*ci);
- if (!child->do_rebuild_all(db)) {
- all_ok = false;
- }
- }
-
- return all_ok;
-}
-
-/**
- * Calls optimize() on all models, and recursively on all joints at this node
- * and below.
- */
-void EggJointData::
-optimize() {
- BackPointers::iterator bpi;
- for (bpi = _back_pointers.begin(); bpi != _back_pointers.end(); ++bpi) {
- EggBackPointer *back = (*bpi);
- if (back != nullptr) {
- EggJointPointer *joint;
- DCAST_INTO_V(joint, back);
- joint->optimize();
- }
- }
-
- Children::iterator ci;
- for (ci = _children.begin(); ci != _children.end(); ++ci) {
- EggJointData *child = (*ci);
- child->optimize();
- }
-}
-
-/**
- * Calls expose() on all models for this joint, but does not recurse
- * downwards.
- */
-void EggJointData::
-expose(EggGroup::DCSType dcs_type) {
- BackPointers::iterator bpi;
- for (bpi = _back_pointers.begin(); bpi != _back_pointers.end(); ++bpi) {
- EggBackPointer *back = (*bpi);
- if (back != nullptr) {
- EggJointPointer *joint;
- DCAST_INTO_V(joint, back);
- joint->expose(dcs_type);
- }
- }
-}
-
-/**
- * Calls zero_channels() on all models for this joint, but does not recurse
- * downwards.
- */
-void EggJointData::
-zero_channels(const string &components) {
- BackPointers::iterator bpi;
- for (bpi = _back_pointers.begin(); bpi != _back_pointers.end(); ++bpi) {
- EggBackPointer *back = (*bpi);
- if (back != nullptr) {
- EggJointPointer *joint;
- DCAST_INTO_V(joint, back);
- joint->zero_channels(components);
- }
- }
-}
-
-/**
- * Calls quantize_channels() on all models for this joint, and then recurses
- * downwards to all joints below.
- */
-void EggJointData::
-quantize_channels(const string &components, double quantum) {
- BackPointers::iterator bpi;
- for (bpi = _back_pointers.begin(); bpi != _back_pointers.end(); ++bpi) {
- EggBackPointer *back = (*bpi);
- if (back != nullptr) {
- EggJointPointer *joint;
- DCAST_INTO_V(joint, back);
- joint->quantize_channels(components, quantum);
- }
- }
-
- Children::iterator ci;
- for (ci = _children.begin(); ci != _children.end(); ++ci) {
- EggJointData *child = (*ci);
- child->quantize_channels(components, quantum);
- }
-}
-
-/**
- * Applies the pose from the indicated frame of the indicated source
- * model_index as the initial pose for this joint, and does this recursively
- * on all joints below.
- */
-void EggJointData::
-apply_default_pose(int source_model, int frame) {
- if (has_model(source_model)) {
- EggJointPointer *source_joint;
- DCAST_INTO_V(source_joint, _back_pointers[source_model]);
- BackPointers::iterator bpi;
- for (bpi = _back_pointers.begin(); bpi != _back_pointers.end(); ++bpi) {
- EggBackPointer *back = (*bpi);
- if (back != nullptr) {
- EggJointPointer *joint;
- DCAST_INTO_V(joint, back);
- joint->apply_default_pose(source_joint, frame);
- }
- }
- }
-
- Children::iterator ci;
- for (ci = _children.begin(); ci != _children.end(); ++ci) {
- EggJointData *child = (*ci);
- child->apply_default_pose(source_model, frame);
- }
-}
-
-/**
- * Adds the indicated model joint or anim table to the data.
- */
-void EggJointData::
-add_back_pointer(int model_index, EggObject *egg_object) {
- nassertv(egg_object != nullptr);
- if (egg_object->is_of_type(EggGroup::get_class_type())) {
- // It must be a .
- EggJointNodePointer *joint = new EggJointNodePointer(egg_object);
- set_model(model_index, joint);
- if (!_has_rest_frame) {
- _rest_frame = joint->get_frame(0);
- _has_rest_frame = true;
-
- } else {
- // If this new node doesn't come within an acceptable tolerance of our
- // first reading of this joint's rest frame, set a warning flag.
- if (!_rest_frame.almost_equal(joint->get_frame(0), 0.0001)) {
- _rest_frames_differ = true;
- }
- }
-
- } else if (egg_object->is_of_type(EggTable::get_class_type())) {
- // It's a with an "xform" child beneath it.
- EggMatrixTablePointer *xform = new EggMatrixTablePointer(egg_object);
- set_model(model_index, xform);
-
- } else {
- nout << "Invalid object added to joint for back pointer.\n";
- }
-}
-
-/**
- *
- */
-void EggJointData::
-write(std::ostream &out, int indent_level) const {
- indent(out, indent_level)
- << "Joint " << get_name()
- << " (models:";
- int num_models = get_num_models();
- for (int model_index = 0; model_index < num_models; model_index++) {
- if (has_model(model_index)) {
- out << " " << model_index;
- }
- }
- out << ") {\n";
-
- Children::const_iterator ci;
- for (ci = _children.begin(); ci != _children.end(); ++ci) {
- (*ci)->write(out, indent_level + 2);
- }
-
- indent(out, indent_level) << "}\n";
-}
-
-/**
- * Clears out the _children vector in preparation for refilling it from the
- * _new_parent information.
- */
-void EggJointData::
-do_begin_reparent() {
- _got_new_parent_depth = false;
- _children.clear();
-}
-
-/**
- * Calculates the number of joints above this joint in its intended position,
- * as specified by a recent call to reparent_to(), and also checks for a cycle
- * in the new parent chain. Returns true if a cycle is detected, and false
- * otherwise. If a cycle is not detected, _new_parent_depth can be consulted
- * for the depth in the new hierarchy.
- *
- * This is used by EggCharacterData::do_reparent() to determine the order in
- * which to apply the reparent operations. It should be called after
- * do_begin_reparent().
- */
-bool EggJointData::
-calc_new_parent_depth(pset &chain) {
- if (_got_new_parent_depth) {
- return false;
- }
- if (_new_parent == nullptr) {
- // Here's the top of the new hierarchy.
- _got_new_parent_depth = true;
- _new_parent_depth = 0;
- return false;
- }
- if (!chain.insert(this).second) {
- // We've already visited this joint; that means there's a cycle.
- return true;
- }
- bool cycle = _new_parent->calc_new_parent_depth(chain);
- _new_parent_depth = _new_parent->_new_parent_depth + 1;
- return cycle;
-}
-
-/**
- * Eliminates any cached values before beginning a walk through all the joints
- * for do_compute_reparent(), for a given model/frame.
- */
-void EggJointData::
-do_begin_compute_reparent() {
- _got_new_net_frame = false;
- _got_new_net_frame_inv = false;
- _computed_reparent = false;
-}
-
-/**
- * Prepares the reparent operation by computing a new transform for each frame
- * of each model, designed to keep the net transform the same when the joint
- * is moved to its new parent. Returns true on success, false on failure.
- */
-bool EggJointData::
-do_compute_reparent(int model_index, int n, EggCharacterDb &db) {
- if (_computed_reparent) {
- // We've already done this joint. This is possible because we have to
- // recursively compute joints upwards, so we might visit the same joint
- // more than once.
- return _computed_ok;
- }
- _computed_reparent = true;
-
- if (_parent == _new_parent) {
- // Trivial (and most common) case: we are not moving the joint. No
- // recomputation necessary.
- _computed_ok = true;
- return true;
- }
-
- EggBackPointer *back = get_model(model_index);
- if (back == nullptr) {
- // This joint doesn't have any data to modify.
- _computed_ok = true;
- return true;
- }
-
- EggJointPointer *joint;
- DCAST_INTO_R(joint, back, false);
-
- LMatrix4d transform;
- if (_parent == nullptr) {
- // We are moving from outside the joint hierarchy to within it.
- transform = _new_parent->get_new_net_frame_inv(model_index, n, db);
-
- } else if (_new_parent == nullptr) {
- // We are moving from within the hierarchy to outside it.
- transform = _parent->get_net_frame(model_index, n, db);
-
- } else {
- // We are changing parents within the hierarchy.
- transform =
- _parent->get_net_frame(model_index, n, db) *
- _new_parent->get_new_net_frame_inv(model_index, n, db);
- }
-
- db.set_matrix(joint, EggCharacterDb::TT_rebuild_frame, n,
- joint->get_frame(n) * transform);
- _computed_ok = true;
-
- return _computed_ok;
-}
-
-/**
- * Calls do_rebuild() on the joint for the indicated model index. Returns
- * true on success, false on failure (false shouldn't be possible).
- */
-bool EggJointData::
-do_joint_rebuild(int model_index, EggCharacterDb &db) {
- bool all_ok = true;
-
- EggJointPointer *parent_joint = nullptr;
- if (_new_parent != nullptr && _new_parent->has_model(model_index)) {
- DCAST_INTO_R(parent_joint, _new_parent->get_model(model_index), false);
- }
-
- if (has_model(model_index)) {
- EggJointPointer *joint;
- DCAST_INTO_R(joint, get_model(model_index), false);
- if (!joint->do_rebuild(db)) {
- all_ok = false;
- }
- }
-
- return all_ok;
-}
-
-/**
- * Performs the actual reparenting operation by removing all of the old
- * children and replacing them with the set of new children.
- */
-void EggJointData::
-do_finish_reparent() {
- int num_models = get_num_models();
- for (int model_index = 0; model_index < num_models; model_index++) {
- EggJointPointer *parent_joint = nullptr;
- if (_new_parent != nullptr && _new_parent->has_model(model_index)) {
- DCAST_INTO_V(parent_joint, _new_parent->get_model(model_index));
- }
-
- if (has_model(model_index)) {
- EggJointPointer *joint;
- DCAST_INTO_V(joint, get_model(model_index));
- joint->do_finish_reparent(parent_joint);
- }
- }
-
- _parent = _new_parent;
- if (_parent != nullptr) {
- _parent->_children.push_back(this);
- }
-}
-
-/**
- * Creates a new joint as a child of this joint and returns it. This is
- * intended to be called only from EggCharacterData::make_new_joint().
- */
-EggJointData *EggJointData::
-make_new_joint(const string &name) {
- EggJointData *child = new EggJointData(_collection, _char_data);
- child->set_name(name);
- child->_parent = this;
- child->_new_parent = this;
- _children.push_back(child);
-
- // Also create new back pointers in each of the models.
- int num_models = get_num_models();
- for (int i = 0; i < num_models; i++) {
- if (has_model(i)) {
- EggJointPointer *joint;
- DCAST_INTO_R(joint, get_model(i), nullptr);
- EggJointPointer *new_joint = joint->make_new_joint(name);
- child->set_model(i, new_joint);
- }
- }
-
- return child;
-}
-
-/**
- * The recursive implementation of find_joint, this flavor searches
- * recursively for an exact match of the preferred joint name.
- */
-EggJointData *EggJointData::
-find_joint_exact(const string &name) {
- Children::const_iterator ci;
- for (ci = _children.begin(); ci != _children.end(); ++ci) {
- EggJointData *child = (*ci);
- if (child->get_name() == name) {
- return child;
- }
- EggJointData *result = child->find_joint_exact(name);
- if (result != nullptr) {
- return result;
- }
- }
-
- return nullptr;
-}
-
-/**
- * The recursive implementation of find_joint, this flavor searches
- * recursively for any acceptable match.
- */
-EggJointData *EggJointData::
-find_joint_matches(const string &name) {
- Children::const_iterator ci;
- for (ci = _children.begin(); ci != _children.end(); ++ci) {
- EggJointData *child = (*ci);
- if (child->matches_name(name)) {
- return child;
- }
- EggJointData *result = child->find_joint_matches(name);
- if (result != nullptr) {
- return result;
- }
- }
-
- return nullptr;
-}
-
-/**
- * Returns true if this joint is an ancestor of the indicated joint, in the
- * "new" hierarchy (that is, the one defined by _new_parent, as set by
- * reparent_to() before do_finish_reparent() is called).
- */
-bool EggJointData::
-is_new_ancestor(EggJointData *child) const {
- if (child == this) {
- return true;
- }
-
- if (child->_new_parent == nullptr) {
- return false;
- }
-
- return is_new_ancestor(child->_new_parent);
-}
-
-/**
- * Similar to get_net_frame(), but computed for the prospective new parentage
- * of the node, before do_finish_reparent() is called. This is generally
- * useful only when called within do_compute_reparent().
- */
-const LMatrix4d &EggJointData::
-get_new_net_frame(int model_index, int n, EggCharacterDb &db) {
- if (!_got_new_net_frame) {
- _new_net_frame = get_new_frame(model_index, n, db);
- if (_new_parent != nullptr) {
- _new_net_frame = _new_net_frame * _new_parent->get_new_net_frame(model_index, n, db);
- }
- _got_new_net_frame = true;
- }
- return _new_net_frame;
-}
-
-/**
- * Returns the inverse of get_new_net_frame().
- */
-const LMatrix4d &EggJointData::
-get_new_net_frame_inv(int model_index, int n, EggCharacterDb &db) {
- if (!_got_new_net_frame_inv) {
- _new_net_frame_inv.invert_from(get_new_frame(model_index, n, db));
- if (_new_parent != nullptr) {
- _new_net_frame_inv = _new_parent->get_new_net_frame_inv(model_index, n, db) * _new_net_frame_inv;
- }
- _got_new_net_frame_inv = true;
- }
- return _new_net_frame_inv;
-}
-
-/**
- * Returns the local transform matrix corresponding to this joint position in
- * the nth frame in the indicated model, as it will be when
- * do_finish_reparent() is called.
- */
-LMatrix4d EggJointData::
-get_new_frame(int model_index, int n, EggCharacterDb &db) {
- do_compute_reparent(model_index, n, db);
-
- EggBackPointer *back = get_model(model_index);
- if (back == nullptr) {
- return LMatrix4d::ident_mat();
- }
-
- EggJointPointer *joint;
- DCAST_INTO_R(joint, back, LMatrix4d::ident_mat());
-
- LMatrix4d mat;
- if (!db.get_matrix(joint, EggCharacterDb::TT_rebuild_frame, n, mat)) {
- // No rebuild frame; return the regular frame.
- return joint->get_frame(n);
- }
-
- // Return the rebuild frame, as computed.
- return mat;
-}
diff --git a/pandatool/src/eggcharbase/eggJointData.h b/pandatool/src/eggcharbase/eggJointData.h
deleted file mode 100644
index bf9cf7b3..00000000
--- a/pandatool/src/eggcharbase/eggJointData.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggJointData.h
- * @author drose
- * @date 2001-02-23
- */
-
-#ifndef EGGJOINTDATA_H
-#define EGGJOINTDATA_H
-
-#include "pandatoolbase.h"
-#include "eggComponentData.h"
-#include "eggGroup.h"
-#include "luse.h"
-#include "pset.h"
-
-class EggCharacterDb;
-
-/**
- * This is one node of a hierarchy of EggJointData nodes, each of which
- * represents a single joint of the character hierarchy across all loaded
- * files: the various models, the LOD's of each model, and the various
- * animation channel files.
- */
-class EggJointData : public EggComponentData {
-public:
- EggJointData(EggCharacterCollection *collection,
- EggCharacterData *char_data);
-
- INLINE EggJointData *get_parent() const;
- INLINE int get_num_children() const;
- INLINE EggJointData *get_child(int n) const;
- INLINE EggJointData *find_joint(const std::string &name);
-
- LMatrix4d get_frame(int model_index, int n) const;
- LMatrix4d get_net_frame(int model_index, int n, EggCharacterDb &db) const;
- LMatrix4d get_net_frame_inv(int model_index, int n, EggCharacterDb &db) const;
-
- INLINE bool has_rest_frame() const;
- INLINE bool rest_frames_differ() const;
- INLINE const LMatrix4d &get_rest_frame() const;
- void force_initial_rest_frame();
-
- INLINE void reparent_to(EggJointData *new_parent);
- void move_vertices_to(EggJointData *new_owner);
- int score_reparent_to(EggJointData *new_parent, EggCharacterDb &db);
-
- bool do_rebuild_all(EggCharacterDb &db);
- void optimize();
- void expose(EggGroup::DCSType dcs_type = EggGroup::DC_default);
- void zero_channels(const std::string &components);
- void quantize_channels(const std::string &components, double quantum);
- void apply_default_pose(int source_model, int frame);
-
- virtual void add_back_pointer(int model_index, EggObject *egg_object);
- virtual void write(std::ostream &out, int indent_level = 0) const;
-
-protected:
- void do_begin_reparent();
- bool calc_new_parent_depth(pset &chain);
- void do_begin_compute_reparent();
- bool do_compute_reparent(int model_index, int n, EggCharacterDb &db);
- bool do_joint_rebuild(int model_index, EggCharacterDb &db);
- void do_finish_reparent();
-
-private:
- EggJointData *make_new_joint(const std::string &name);
- EggJointData *find_joint_exact(const std::string &name);
- EggJointData *find_joint_matches(const std::string &name);
-
- bool is_new_ancestor(EggJointData *child) const;
- const LMatrix4d &get_new_net_frame(int model_index, int n, EggCharacterDb &db);
- const LMatrix4d &get_new_net_frame_inv(int model_index, int n, EggCharacterDb &db);
- LMatrix4d get_new_frame(int model_index, int n, EggCharacterDb &db);
-
- bool _has_rest_frame;
- bool _rest_frames_differ;
- LMatrix4d _rest_frame;
-
- // These are used to cache the above results for optimizing
- // do_compute_reparent().
- LMatrix4d _new_net_frame, _new_net_frame_inv;
- bool _got_new_net_frame, _got_new_net_frame_inv;
- bool _computed_reparent;
- bool _computed_ok;
-
-protected:
- typedef pvector Children;
- Children _children;
- EggJointData *_parent;
- EggJointData *_new_parent;
- int _new_parent_depth;
- bool _got_new_parent_depth;
-
-
-public:
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- EggComponentData::init_type();
- register_type(_type_handle, "EggJointData",
- EggComponentData::get_class_type());
- }
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
-
-private:
- static TypeHandle _type_handle;
-
- friend class EggCharacterCollection;
- friend class EggCharacterData;
- friend class OrderJointsByNewDepth;
-};
-
-#include "eggJointData.I"
-
-#endif
diff --git a/pandatool/src/eggcharbase/eggJointNodePointer.cxx b/pandatool/src/eggcharbase/eggJointNodePointer.cxx
deleted file mode 100644
index 23bf7ea4..00000000
--- a/pandatool/src/eggcharbase/eggJointNodePointer.cxx
+++ /dev/null
@@ -1,209 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggJointNodePointer.cxx
- * @author drose
- * @date 2001-02-26
- */
-
-#include "eggJointNodePointer.h"
-
-#include "dcast.h"
-#include "eggCharacterDb.h"
-#include "eggGroup.h"
-#include "eggObject.h"
-#include "pointerTo.h"
-
-
-TypeHandle EggJointNodePointer::_type_handle;
-
-/**
- *
- */
-EggJointNodePointer::
-EggJointNodePointer(EggObject *object) {
- _joint = DCAST(EggGroup, object);
-
- if (_joint != nullptr && _joint->is_joint()) {
- // Quietly insist that the joint has a transform, for neatness. If it
- // does not, give it the identity transform.
- if (!_joint->has_transform()) {
- _joint->set_transform3d(LMatrix4d::ident_mat());
- }
- }
-}
-
-/**
- * Returns the number of frames of animation for this particular joint.
- *
- * In the case of a EggJointNodePointer, which just stores a pointer to a
- * entry for a character model (not an animation table), there is
- * always exactly one frame: the rest pose.
- */
-int EggJointNodePointer::
-get_num_frames() const {
- return 1;
-}
-
-/**
- * Returns the transform matrix corresponding to this joint position in the
- * nth frame.
- *
- * In the case of a EggJointNodePointer, which just stores a pointer to a
- * entry for a character model (not an animation table), there is
- * always exactly one frame: the rest pose.
- */
-LMatrix4d EggJointNodePointer::
-get_frame(int n) const {
- nassertr(n == 0, LMatrix4d::ident_mat());
- return _joint->get_transform3d();
-}
-
-/**
- * Sets the transform matrix corresponding to this joint position in the nth
- * frame.
- *
- * In the case of a EggJointNodePointer, which just stores a pointer to a
- * entry for a character model (not an animation table), there is
- * always exactly one frame: the rest pose.
- */
-void EggJointNodePointer::
-set_frame(int n, const LMatrix4d &mat) {
- nassertv(n == 0);
- _joint->set_transform3d(mat);
-}
-
-/**
- * Performs the actual reparenting operation by removing the node from its old
- * parent and associating it with its new parent, if any.
- */
-void EggJointNodePointer::
-do_finish_reparent(EggJointPointer *new_parent) {
- if (new_parent == nullptr) {
- // No new parent; unparent the joint.
- EggGroupNode *egg_parent = _joint->get_parent();
- if (egg_parent != nullptr) {
- egg_parent->remove_child(_joint.p());
- egg_parent->steal_children(*_joint);
- }
-
- } else {
- // Reparent the joint to its new parent (implicitly unparenting it from
- // its previous parent).
- EggJointNodePointer *new_node = DCAST(EggJointNodePointer, new_parent);
- if (new_node->_joint != _joint->get_parent()) {
- new_node->_joint->add_child(_joint.p());
- }
- }
-}
-
-/**
- * Moves the vertices assigned to this joint into the other joint (which
- * should be of the same type).
- */
-void EggJointNodePointer::
-move_vertices_to(EggJointPointer *new_joint) {
- if (new_joint == nullptr) {
- _joint->unref_all_vertices();
-
- } else {
- EggJointNodePointer *new_node;
- DCAST_INTO_V(new_node, new_joint);
-
- new_node->_joint->steal_vrefs(_joint);
- }
-}
-
-/**
- * Rebuilds the entire table all at once, based on the frames added by
- * repeated calls to add_rebuild_frame() since the last call to
- * begin_rebuild().
- *
- * Until do_rebuild() is called, the animation table is not changed.
- *
- * The return value is true if all frames are acceptable, or false if there is
- * some problem.
- */
-bool EggJointNodePointer::
-do_rebuild(EggCharacterDb &db) {
- LMatrix4d mat;
- if (!db.get_matrix(this, EggCharacterDb::TT_rebuild_frame, 0, mat)) {
- // No rebuild frame; this is OK.
- return true;
- }
-
- _joint->set_transform3d(mat);
-
- // We shouldn't have a frame 1.
- nassertr(!db.get_matrix(this, EggCharacterDb::TT_rebuild_frame, 1, mat), false);
-
- return true;
-}
-
-/**
- * Flags the joint with the indicated DCS flag so that it will be loaded as a
- * separate node in the player.
- */
-void EggJointNodePointer::
-expose(EggGroup::DCSType dcs_type) {
- if (_joint != nullptr) {
- _joint->set_dcs_type(dcs_type);
- }
-}
-
-/**
- * Applies the pose from the indicated frame of the indicated source joint as
- * the initial pose for this joint.
- */
-void EggJointNodePointer::
-apply_default_pose(EggJointPointer *source_joint, int frame) {
- if (_joint != nullptr) {
- LMatrix4d pose;
- if (frame >= 0 && frame < source_joint->get_num_frames()) {
- pose = source_joint->get_frame(frame);
- } else {
- pose = get_frame(0);
- }
- _joint->clear_default_pose();
- _joint->modify_default_pose().add_matrix4(pose);
- }
-}
-
-/**
- * Returns true if there are any vertices referenced by the node this points
- * to, false otherwise. For certain kinds of back pointers (e.g. table
- * animation entries), this is always false.
- */
-bool EggJointNodePointer::
-has_vertices() const {
- if (_joint != nullptr) {
- return (_joint->vref_size() != 0) || _joint->joint_has_primitives();
- }
-
- return false;
-}
-
-/**
- * Creates a new child of the current joint in the egg data, and returns a
- * pointer to it.
- */
-EggJointPointer *EggJointNodePointer::
-make_new_joint(const std::string &name) {
- EggGroup *new_joint = new EggGroup(name);
- new_joint->set_group_type(EggGroup::GT_joint);
- _joint->add_child(new_joint);
- return new EggJointNodePointer(new_joint);
-}
-
-/**
- * Applies the indicated name change to the egg file.
- */
-void EggJointNodePointer::
-set_name(const std::string &name) {
- _joint->set_name(name);
-}
diff --git a/pandatool/src/eggcharbase/eggJointNodePointer.h b/pandatool/src/eggcharbase/eggJointNodePointer.h
deleted file mode 100644
index 8a979f11..00000000
--- a/pandatool/src/eggcharbase/eggJointNodePointer.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggJointNodePointer.h
- * @author drose
- * @date 2001-02-26
- */
-
-#ifndef EGGJOINTNODEPOINTER_H
-#define EGGJOINTNODEPOINTER_H
-
-#include "pandatoolbase.h"
-
-#include "eggJointPointer.h"
-
-#include "eggGroup.h"
-#include "pointerTo.h"
-
-/**
- * This stores a pointer back to a node.
- */
-class EggJointNodePointer : public EggJointPointer {
-public:
- EggJointNodePointer(EggObject *object);
-
- virtual int get_num_frames() const;
- virtual LMatrix4d get_frame(int n) const;
- virtual void set_frame(int n, const LMatrix4d &mat);
-
- virtual void do_finish_reparent(EggJointPointer *new_parent);
- virtual void move_vertices_to(EggJointPointer *new_joint);
-
- virtual bool do_rebuild(EggCharacterDb &db);
- virtual void expose(EggGroup::DCSType dcs_type);
- virtual void apply_default_pose(EggJointPointer *source_joint, int frame);
-
- virtual bool has_vertices() const;
-
- virtual EggJointPointer *make_new_joint(const std::string &name);
-
- virtual void set_name(const std::string &name);
-
-private:
- PT(EggGroup) _joint;
-
-public:
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- EggJointPointer::init_type();
- register_type(_type_handle, "EggJointNodePointer",
- EggJointPointer::get_class_type());
- }
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
-
-private:
- static TypeHandle _type_handle;
-};
-
-#endif
diff --git a/pandatool/src/eggcharbase/eggJointPointer.I b/pandatool/src/eggcharbase/eggJointPointer.I
deleted file mode 100644
index 57bd7cf3..00000000
--- a/pandatool/src/eggcharbase/eggJointPointer.I
+++ /dev/null
@@ -1,12 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggJointPointer.I
- * @author drose
- * @date 2003-07-20
- */
diff --git a/pandatool/src/eggcharbase/eggJointPointer.cxx b/pandatool/src/eggcharbase/eggJointPointer.cxx
deleted file mode 100644
index 6a5ed440..00000000
--- a/pandatool/src/eggcharbase/eggJointPointer.cxx
+++ /dev/null
@@ -1,89 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggJointPointer.cxx
- * @author drose
- * @date 2001-02-26
- */
-
-#include "eggJointPointer.h"
-
-
-TypeHandle EggJointPointer::_type_handle;
-
-
-/**
- * Appends a new frame onto the end of the data, if possible; returns true if
- * not possible, or false otherwise (e.g. for a static joint).
- */
-bool EggJointPointer::
-add_frame(const LMatrix4d &) {
- return false;
-}
-
-/**
- * Moves the vertices assigned to this joint into the other joint (which
- * should be of the same type).
- */
-void EggJointPointer::
-move_vertices_to(EggJointPointer *) {
-}
-
-/**
- * Rebuilds the entire table all at once, based on the frames added by
- * repeated calls to add_rebuild_frame() since the last call to
- * begin_rebuild().
- *
- * Until do_rebuild() is called, the animation table is not changed.
- *
- * The return value is true if all frames are acceptable, or false if there is
- * some problem.
- */
-bool EggJointPointer::
-do_rebuild(EggCharacterDb &db) {
- return true;
-}
-
-/**
- * Resets the table before writing to disk so that redundant rows (e.g. i { 1
- * 1 1 1 1 1 1 1 }) are collapsed out.
- */
-void EggJointPointer::
-optimize() {
-}
-
-/**
- * Flags the joint with the indicated DCS flag so that it will be loaded as a
- * separate node in the player.
- */
-void EggJointPointer::
-expose(EggGroup::DCSType) {
-}
-
-/**
- * Zeroes out the named components of the transform in the animation frames.
- */
-void EggJointPointer::
-zero_channels(const std::string &) {
-}
-
-/**
- * Rounds the named components of the transform to the nearest multiple of
- * quantum.
- */
-void EggJointPointer::
-quantize_channels(const std::string &, double) {
-}
-
-/**
- * Applies the pose from the indicated frame of the indicated source joint as
- * the initial pose for this joint.
- */
-void EggJointPointer::
-apply_default_pose(EggJointPointer *source_joint, int frame) {
-}
diff --git a/pandatool/src/eggcharbase/eggJointPointer.h b/pandatool/src/eggcharbase/eggJointPointer.h
deleted file mode 100644
index 94a8a318..00000000
--- a/pandatool/src/eggcharbase/eggJointPointer.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggJointPointer.h
- * @author drose
- * @date 2001-02-26
- */
-
-#ifndef EGGJOINTPOINTER_H
-#define EGGJOINTPOINTER_H
-
-#include "pandatoolbase.h"
-#include "eggBackPointer.h"
-#include "eggGroup.h"
-#include "luse.h"
-
-class EggCharacterDb;
-
-/**
- * This is a base class for EggJointNodePointer and EggMatrixTablePointer. It
- * stores a back pointer to either a entry or an xform data,
- * and thus presents an interface that returns 1-n matrices, one for each
- * frame. ( entries, for model files, appear the same as one-frame
- * animations.)
- */
-class EggJointPointer : public EggBackPointer {
-public:
- virtual int get_num_frames() const=0;
- virtual LMatrix4d get_frame(int n) const=0;
- virtual void set_frame(int n, const LMatrix4d &mat)=0;
- virtual bool add_frame(const LMatrix4d &mat);
-
- virtual void do_finish_reparent(EggJointPointer *new_parent)=0;
- virtual void move_vertices_to(EggJointPointer *new_joint);
-
- virtual bool do_rebuild(EggCharacterDb &db);
-
- virtual void optimize();
- virtual void expose(EggGroup::DCSType dcs_type);
- virtual void zero_channels(const std::string &components);
- virtual void quantize_channels(const std::string &components, double quantum);
- virtual void apply_default_pose(EggJointPointer *source_joint, int frame);
-
- virtual EggJointPointer *make_new_joint(const std::string &name)=0;
-
-public:
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- EggBackPointer::init_type();
- register_type(_type_handle, "EggJointPointer",
- EggBackPointer::get_class_type());
- }
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
-
-private:
- static TypeHandle _type_handle;
-};
-
-#include "eggJointPointer.I"
-
-#endif
diff --git a/pandatool/src/eggcharbase/eggMatrixTablePointer.cxx b/pandatool/src/eggcharbase/eggMatrixTablePointer.cxx
deleted file mode 100644
index 26729648..00000000
--- a/pandatool/src/eggcharbase/eggMatrixTablePointer.cxx
+++ /dev/null
@@ -1,295 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggMatrixTablePointer.cxx
- * @author drose
- * @date 2001-02-26
- */
-
-#include "eggMatrixTablePointer.h"
-
-#include "dcast.h"
-#include "eggCharacterDb.h"
-#include "eggSAnimData.h"
-#include "eggXfmAnimData.h"
-#include "eggXfmSAnim.h"
-
-using std::string;
-
-TypeHandle EggMatrixTablePointer::_type_handle;
-
-/**
- *
- */
-EggMatrixTablePointer::
-EggMatrixTablePointer(EggObject *object) {
- _table = DCAST(EggTable, object);
-
- if (_table != nullptr) {
- // Now search for the child named "xform". This contains the actual table
- // data.
- EggGroupNode::iterator ci;
- bool found = false;
- for (ci = _table->begin(); ci != _table->end() && !found; ++ci) {
- EggNode *child = (*ci);
- if (child->get_name() == "xform") {
- if (child->is_of_type(EggXfmSAnim::get_class_type())) {
- _xform = DCAST(EggXfmSAnim, child);
- _xform->normalize();
- found = true;
-
- } else if (child->is_of_type(EggXfmAnimData::get_class_type())) {
- // Quietly replace old-style XfmAnim tables with new-style XfmSAnim
- // tables.
- PT(EggXfmAnimData) anim = DCAST(EggXfmAnimData, child);
- _xform = new EggXfmSAnim(*anim);
- _table->replace(ci, _xform.p());
- found = true;
- }
- }
- }
- }
-}
-
-/**
- * Returns the stated frame rate of this particular joint, or 0.0 if it
- * doesn't state.
- */
-double EggMatrixTablePointer::
-get_frame_rate() const {
- if (_xform == nullptr || !_xform->has_fps()) {
- return 0.0;
- } else {
- return _xform->get_fps();
- }
-}
-
-/**
- * Returns the number of frames of animation for this particular joint.
- */
-int EggMatrixTablePointer::
-get_num_frames() const {
- if (_xform == nullptr) {
- return 0;
- } else {
- return _xform->get_num_rows();
- }
-}
-
-/**
- * Extends the table to the indicated number of frames.
- */
-void EggMatrixTablePointer::
-extend_to(int num_frames) {
- nassertv(_xform != nullptr);
- _xform->normalize();
- int num_rows = _xform->get_num_rows();
- LMatrix4d last_mat;
- if (num_rows == 0) {
- last_mat = LMatrix4d::ident_mat();
- } else {
- _xform->get_value(num_rows - 1, last_mat);
- }
-
- while (num_rows < num_frames) {
- _xform->add_data(last_mat);
- num_rows++;
- }
-}
-
-/**
- * Returns the transform matrix corresponding to this joint position in the
- * nth frame.
- */
-LMatrix4d EggMatrixTablePointer::
-get_frame(int n) const {
- if (get_num_frames() == 1) {
- // If we have exactly one frame, then we have as many frames as we want;
- // just repeat the first frame.
- n = 0;
-
- } else if (get_num_frames() == 0) {
- // If we have no frames, we really have the identity matrix.
- return LMatrix4d::ident_mat();
- }
-
- nassertr(n >= 0 && n < get_num_frames(), LMatrix4d::ident_mat());
- LMatrix4d mat;
- _xform->get_value(n, mat);
- return mat;
-}
-
-/**
- * Sets the transform matrix corresponding to this joint position in the nth
- * frame.
- */
-void EggMatrixTablePointer::
-set_frame(int n, const LMatrix4d &mat) {
- nassertv(n >= 0 && n < get_num_frames());
- _xform->set_value(n, mat);
-}
-
-/**
- * Appends a new frame onto the end of the data, if possible; returns true if
- * not possible, or false otherwise (e.g. for a static joint).
- */
-bool EggMatrixTablePointer::
-add_frame(const LMatrix4d &mat) {
- if (_xform == nullptr) {
- return false;
- }
-
- return _xform->add_data(mat);
-}
-
-/**
- * Performs the actual reparenting operation by removing the node from its old
- * parent and associating it with its new parent, if any.
- */
-void EggMatrixTablePointer::
-do_finish_reparent(EggJointPointer *new_parent) {
- if (new_parent == nullptr) {
- // No new parent; unparent the joint.
- EggGroupNode *egg_parent = _table->get_parent();
- if (egg_parent != nullptr) {
- egg_parent->remove_child(_table.p());
- }
-
- } else {
- // Reparent the joint to its new parent (implicitly unparenting it from
- // its previous parent).
- EggMatrixTablePointer *new_node = DCAST(EggMatrixTablePointer, new_parent);
- if (new_node->_table != _table->get_parent()) {
- new_node->_table->add_child(_table.p());
- }
- }
-}
-
-/**
- * Rebuilds the entire table all at once, based on the frames added by
- * repeated calls to add_rebuild_frame() since the last call to
- * begin_rebuild().
- *
- * Until do_rebuild() is called, the animation table is not changed.
- *
- * The return value is true if all frames are acceptable, or false if there is
- * some problem.
- */
-bool EggMatrixTablePointer::
-do_rebuild(EggCharacterDb &db) {
- LMatrix4d mat;
- if (!db.get_matrix(this, EggCharacterDb::TT_rebuild_frame, 0, mat)) {
- // No rebuild frame; this is OK.
- return true;
- }
-
- if (_xform == nullptr) {
- return false;
- }
-
- bool all_ok = true;
-
- _xform->clear_data();
- if (!_xform->add_data(mat)) {
- all_ok = false;
- }
-
- // Assume all frames will be contiguous.
- int n = 1;
- while (db.get_matrix(this, EggCharacterDb::TT_rebuild_frame, n, mat)) {
- if (!_xform->add_data(mat)) {
- all_ok = false;
- }
- ++n;
- }
-
- return all_ok;
-}
-
-/**
- * Resets the table before writing to disk so that redundant rows (e.g. i { 1
- * 1 1 1 1 1 1 1 }) are collapsed out.
- */
-void EggMatrixTablePointer::
-optimize() {
- if (_xform != nullptr) {
- _xform->optimize();
- }
-}
-
-/**
- * Zeroes out the named components of the transform in the animation frames.
- */
-void EggMatrixTablePointer::
-zero_channels(const string &components) {
- if (_xform == nullptr) {
- return;
- }
-
- // This is particularly easy: we only have to remove children from the
- // _xform object whose name is listed in the components.
- string::const_iterator si;
- for (si = components.begin(); si != components.end(); ++si) {
- string table_name(1, *si);
- EggNode *child = _xform->find_child(table_name);
- if (child != nullptr) {
- _xform->remove_child(child);
- }
- }
-}
-
-/**
- * Rounds the named components of the transform to the nearest multiple of
- * quantum.
- */
-void EggMatrixTablePointer::
-quantize_channels(const string &components, double quantum) {
- if (_xform == nullptr) {
- return;
- }
-
- // This is similar to the above: we quantize children of the _xform object
- // whose name is listed in the components.
- string::const_iterator si;
- for (si = components.begin(); si != components.end(); ++si) {
- string table_name(1, *si);
- EggNode *child = _xform->find_child(table_name);
- if (child != nullptr &&
- child->is_of_type(EggSAnimData::get_class_type())) {
- EggSAnimData *anim = DCAST(EggSAnimData, child);
- anim->quantize(quantum);
- }
- }
-}
-
-/**
- * Creates a new child of the current joint in the egg data, and returns a
- * pointer to it.
- */
-EggJointPointer *EggMatrixTablePointer::
-make_new_joint(const string &name) {
- EggTable *new_table = new EggTable(name);
- _table->add_child(new_table);
- CoordinateSystem cs = CS_default;
- if (_xform != nullptr) {
- cs = _xform->get_coordinate_system();
- }
- EggXfmSAnim *new_xform = new EggXfmSAnim("xform", cs);
- new_table->add_child(new_xform);
- new_xform->add_data(LMatrix4d::ident_mat());
-
- return new EggMatrixTablePointer(new_table);
-}
-
-/**
- * Applies the indicated name change to the egg file.
- */
-void EggMatrixTablePointer::
-set_name(const string &name) {
- _table->set_name(name);
-}
diff --git a/pandatool/src/eggcharbase/eggMatrixTablePointer.h b/pandatool/src/eggcharbase/eggMatrixTablePointer.h
deleted file mode 100644
index cbdeeecc..00000000
--- a/pandatool/src/eggcharbase/eggMatrixTablePointer.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggMatrixTablePointer.h
- * @author drose
- * @date 2001-02-26
- */
-
-#ifndef EGGMATRIXTABLEPOINTER_H
-#define EGGMATRIXTABLEPOINTER_H
-
-#include "pandatoolbase.h"
-
-#include "eggJointPointer.h"
-
-#include "eggTable.h"
-#include "eggXfmSAnim.h"
-#include "pointerTo.h"
-
-/**
- * This stores a pointer back to an EggXfmSAnim table (i.e. an
- * entry in an egg file), corresponding to the animation data from a single
- * bundle for this joint.
- */
-class EggMatrixTablePointer : public EggJointPointer {
-public:
- EggMatrixTablePointer(EggObject *object);
-
- virtual double get_frame_rate() const;
- virtual int get_num_frames() const;
- virtual void extend_to(int num_frames);
- virtual LMatrix4d get_frame(int n) const;
- virtual void set_frame(int n, const LMatrix4d &mat);
- virtual bool add_frame(const LMatrix4d &mat);
-
- virtual void do_finish_reparent(EggJointPointer *new_parent);
-
- virtual bool do_rebuild(EggCharacterDb &db);
-
- virtual void optimize();
- virtual void zero_channels(const std::string &components);
- virtual void quantize_channels(const std::string &components, double quantum);
-
- virtual EggJointPointer *make_new_joint(const std::string &name);
-
- virtual void set_name(const std::string &name);
-
-private:
- PT(EggTable) _table;
- PT(EggXfmSAnim) _xform;
-
-public:
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- EggJointPointer::init_type();
- register_type(_type_handle, "EggMatrixTablePointer",
- EggJointPointer::get_class_type());
- }
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
-
-private:
- static TypeHandle _type_handle;
-};
-
-#endif
diff --git a/pandatool/src/eggcharbase/eggScalarTablePointer.cxx b/pandatool/src/eggcharbase/eggScalarTablePointer.cxx
deleted file mode 100644
index 450bb548..00000000
--- a/pandatool/src/eggcharbase/eggScalarTablePointer.cxx
+++ /dev/null
@@ -1,97 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggScalarTablePointer.cxx
- * @author drose
- * @date 2003-07-18
- */
-
-#include "eggScalarTablePointer.h"
-
-#include "dcast.h"
-
-TypeHandle EggScalarTablePointer::_type_handle;
-
-/**
- *
- */
-EggScalarTablePointer::
-EggScalarTablePointer(EggObject *object) {
- _data = DCAST(EggSAnimData, object);
-}
-
-/**
- * Returns the stated frame rate of this particular joint, or 0.0 if it
- * doesn't state.
- */
-double EggScalarTablePointer::
-get_frame_rate() const {
- if (_data == nullptr || !_data->has_fps()) {
- return 0.0;
- } else {
- return _data->get_fps();
- }
-}
-
-/**
- * Returns the number of frames of animation for this particular slider.
- */
-int EggScalarTablePointer::
-get_num_frames() const {
- if (_data == nullptr) {
- return 0;
- } else {
- return _data->get_num_rows();
- }
-}
-
-/**
- * Extends the table to the indicated number of frames.
- */
-void EggScalarTablePointer::
-extend_to(int num_frames) {
- nassertv(_data != nullptr);
- int num_rows = _data->get_num_rows();
- double last_value;
- if (num_rows == 0) {
- last_value = 0.0;
- } else {
- last_value = _data->get_value(num_rows - 1);
- }
-
- while (num_rows < num_frames) {
- _data->add_data(last_value);
- num_rows++;
- }
-}
-
-/**
- * Returns the value corresponding to this slider position in the nth frame.
- */
-double EggScalarTablePointer::
-get_frame(int n) const {
- if (get_num_frames() == 1) {
- // If we have exactly one frame, then we have as many frames as we want;
- // just repeat the first frame.
- n = 0;
- }
-
- nassertr(n >= 0 && n < get_num_frames(), 0.0);
- return _data->get_value(n);
-}
-
-/**
- * Applies the indicated name change to the egg file.
- */
-void EggScalarTablePointer::
-set_name(const std::string &name) {
- // Actually, let's not rename the slider table (yet), because we haven't
- // written the code to rename all of the morph targets.
-
- // _data->set_name(name);
-}
diff --git a/pandatool/src/eggcharbase/eggScalarTablePointer.h b/pandatool/src/eggcharbase/eggScalarTablePointer.h
deleted file mode 100644
index c0a74879..00000000
--- a/pandatool/src/eggcharbase/eggScalarTablePointer.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggScalarTablePointer.h
- * @author drose
- * @date 2003-07-18
- */
-
-#ifndef EGGSCALARTABLEPOINTER_H
-#define EGGSCALARTABLEPOINTER_H
-
-#include "pandatoolbase.h"
-
-#include "eggSliderPointer.h"
-
-#include "eggSAnimData.h"
-#include "pointerTo.h"
-
-/**
- * This stores a pointer back to an EggSAnimData table (i.e. an
- * entry in an egg file), corresponding to the animation data from a single
- * bundle for this slider.
- */
-class EggScalarTablePointer : public EggSliderPointer {
-public:
- EggScalarTablePointer(EggObject *object);
-
- virtual double get_frame_rate() const;
- virtual int get_num_frames() const;
- virtual void extend_to(int num_frames);
- virtual double get_frame(int n) const;
-
- virtual void set_name(const std::string &name);
-
-private:
- PT(EggSAnimData) _data;
-
-public:
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- EggSliderPointer::init_type();
- register_type(_type_handle, "EggScalarTablePointer",
- EggSliderPointer::get_class_type());
- }
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
-
-private:
- static TypeHandle _type_handle;
-};
-
-#endif
diff --git a/pandatool/src/eggcharbase/eggSliderData.I b/pandatool/src/eggcharbase/eggSliderData.I
deleted file mode 100644
index d925c04a..00000000
--- a/pandatool/src/eggcharbase/eggSliderData.I
+++ /dev/null
@@ -1,12 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggSliderData.I
- * @author drose
- * @date 2001-02-26
- */
diff --git a/pandatool/src/eggcharbase/eggSliderData.cxx b/pandatool/src/eggcharbase/eggSliderData.cxx
deleted file mode 100644
index 91d04136..00000000
--- a/pandatool/src/eggcharbase/eggSliderData.cxx
+++ /dev/null
@@ -1,102 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggSliderData.cxx
- * @author drose
- * @date 2001-02-26
- */
-
-#include "eggSliderData.h"
-#include "eggVertexPointer.h"
-#include "eggScalarTablePointer.h"
-#include "eggSliderPointer.h"
-#include "dcast.h"
-#include "eggPrimitive.h"
-#include "eggVertex.h"
-#include "eggSAnimData.h"
-#include "indent.h"
-
-TypeHandle EggSliderData::_type_handle;
-
-/**
- *
- */
-EggSliderData::
-EggSliderData(EggCharacterCollection *collection,
- EggCharacterData *char_data) :
- EggComponentData(collection, char_data)
-{
-}
-
-/**
- * Returns the value corresponding to this slider position in the nth frame in
- * the indicated model.
- */
-double EggSliderData::
-get_frame(int model_index, int n) const {
- EggBackPointer *back = get_model(model_index);
- if (back == nullptr) {
- return 0.0;
- }
-
- EggSliderPointer *slider;
- DCAST_INTO_R(slider, back, 0.0);
-
- return slider->get_frame(n);
-}
-
-/**
- * Adds the indicated vertex, primitive, or morph table to the data.
- */
-void EggSliderData::
-add_back_pointer(int model_index, EggObject *egg_object) {
- if (egg_object->is_of_type(EggPrimitive::get_class_type())) {
- // A primitive!
- EggBackPointer *back = get_model(model_index);
- if (back == nullptr) {
- back = new EggVertexPointer(egg_object);
- set_model(model_index, back);
- }
-
- } else if (egg_object->is_of_type(EggVertex::get_class_type())) {
- // A vertex!
- EggBackPointer *back = get_model(model_index);
- if (back == nullptr) {
- back = new EggVertexPointer(egg_object);
- set_model(model_index, back);
- }
-
- } else if (egg_object->is_of_type(EggSAnimData::get_class_type())) {
- // A slider animation table! Woo hoo!
- EggBackPointer *back = get_model(model_index);
- if (back == nullptr) {
- back = new EggScalarTablePointer(egg_object);
- set_model(model_index, back);
- }
-
- } else {
- nout << "Invalid object added to slider for back pointer.\n";
- }
-}
-
-/**
- *
- */
-void EggSliderData::
-write(std::ostream &out, int indent_level) const {
- indent(out, indent_level)
- << "Slider " << get_name()
- << " (models:";
- int num_models = get_num_models();
- for (int model_index = 0; model_index < num_models; model_index++) {
- if (has_model(model_index)) {
- out << " " << model_index;
- }
- }
- out << ")\n";
-}
diff --git a/pandatool/src/eggcharbase/eggSliderData.h b/pandatool/src/eggcharbase/eggSliderData.h
deleted file mode 100644
index dd0e4c34..00000000
--- a/pandatool/src/eggcharbase/eggSliderData.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggSliderData.h
- * @author drose
- * @date 2001-02-26
- */
-
-#ifndef EGGSLIDERDATA_H
-#define EGGSLIDERDATA_H
-
-#include "pandatoolbase.h"
-
-#include "eggComponentData.h"
-
-
-/**
- * This corresponds to a single morph slider control. It contains back
- * pointers to all the vertices and primitives that reference this slider
- * across all models, as well as all the tables in which it appears in all
- * animation files.
- */
-class EggSliderData : public EggComponentData {
-public:
- EggSliderData(EggCharacterCollection *collection,
- EggCharacterData *char_data);
-
- double get_frame(int model_index, int n) const;
-
- virtual void add_back_pointer(int model_index, EggObject *egg_object);
- virtual void write(std::ostream &out, int indent_level = 0) const;
-
-
-public:
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- EggComponentData::init_type();
- register_type(_type_handle, "EggSliderData",
- EggComponentData::get_class_type());
- }
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
-
-private:
- static TypeHandle _type_handle;
-};
-
-#include "eggSliderData.I"
-
-#endif
diff --git a/pandatool/src/eggcharbase/eggSliderPointer.cxx b/pandatool/src/eggcharbase/eggSliderPointer.cxx
deleted file mode 100644
index bad2934a..00000000
--- a/pandatool/src/eggcharbase/eggSliderPointer.cxx
+++ /dev/null
@@ -1,16 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggSliderPointer.cxx
- * @author drose
- * @date 2003-07-18
- */
-
-#include "eggSliderPointer.h"
-
-TypeHandle EggSliderPointer::_type_handle;
diff --git a/pandatool/src/eggcharbase/eggSliderPointer.h b/pandatool/src/eggcharbase/eggSliderPointer.h
deleted file mode 100644
index 19129f45..00000000
--- a/pandatool/src/eggcharbase/eggSliderPointer.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggSliderPointer.h
- * @author drose
- * @date 2003-07-18
- */
-
-#ifndef EGGSLIDERPOINTER_H
-#define EGGSLIDERPOINTER_H
-
-#include "pandatoolbase.h"
-
-#include "eggBackPointer.h"
-
-#include "luse.h"
-
-/**
- * This is a base class for EggVertexPointer and EggScalarTablePointer.
- */
-class EggSliderPointer : public EggBackPointer {
-public:
- virtual int get_num_frames() const=0;
- virtual double get_frame(int n) const=0;
-
-public:
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- EggBackPointer::init_type();
- register_type(_type_handle, "EggSliderPointer",
- EggBackPointer::get_class_type());
- }
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
-
-private:
- static TypeHandle _type_handle;
-};
-
-#endif
diff --git a/pandatool/src/eggcharbase/eggVertexPointer.cxx b/pandatool/src/eggcharbase/eggVertexPointer.cxx
deleted file mode 100644
index 09af9d77..00000000
--- a/pandatool/src/eggcharbase/eggVertexPointer.cxx
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggVertexPointer.cxx
- * @author drose
- * @date 2001-02-26
- */
-
-#include "eggVertexPointer.h"
-
-
-TypeHandle EggVertexPointer::_type_handle;
-
-/**
- *
- */
-EggVertexPointer::
-EggVertexPointer(EggObject *egg_object) {
-}
-
-/**
- * Returns the number of frames of animation for this particular slider.
- */
-int EggVertexPointer::
-get_num_frames() const {
- return 0;
-}
-
-/**
- * Returns the value corresponding to this slider position in the nth frame.
- */
-double EggVertexPointer::
-get_frame(int n) const {
- nassertr(false, 0.0);
- return 0.0;
-}
-
-/**
- * Returns true if there are any vertices referenced by the node this points
- * to, false otherwise. For certain kinds of back pointers (e.g. table
- * animation entries), this is always false.
- */
-bool EggVertexPointer::
-has_vertices() const {
- return true;
-}
diff --git a/pandatool/src/eggcharbase/eggVertexPointer.h b/pandatool/src/eggcharbase/eggVertexPointer.h
deleted file mode 100644
index 8403edab..00000000
--- a/pandatool/src/eggcharbase/eggVertexPointer.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggVertexPointer.h
- * @author drose
- * @date 2001-02-26
- */
-
-#ifndef EGGVERTEXPOINTER_H
-#define EGGVERTEXPOINTER_H
-
-#include "pandatoolbase.h"
-
-#include "eggSliderPointer.h"
-
-#include "eggGroup.h"
-#include "pointerTo.h"
-
-/**
- * This stores a pointer back to a , or to a particular pritimive like
- * a , representing a morph offset.
- */
-class EggVertexPointer : public EggSliderPointer {
-public:
- EggVertexPointer(EggObject *egg_object);
-
- virtual int get_num_frames() const;
- virtual double get_frame(int n) const;
-
- virtual bool has_vertices() const;
-
-public:
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- EggSliderPointer::init_type();
- register_type(_type_handle, "EggVertexPointer",
- EggSliderPointer::get_class_type());
- }
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
-
-private:
- static TypeHandle _type_handle;
-};
-
-#endif
diff --git a/pandatool/src/eggcharbase/p3eggcharbase_composite1.cxx b/pandatool/src/eggcharbase/p3eggcharbase_composite1.cxx
deleted file mode 100644
index 5aa73594..00000000
--- a/pandatool/src/eggcharbase/p3eggcharbase_composite1.cxx
+++ /dev/null
@@ -1,17 +0,0 @@
-
-#include "config_eggcharbase.cxx"
-#include "eggBackPointer.cxx"
-#include "eggCharacterCollection.cxx"
-#include "eggCharacterData.cxx"
-#include "eggCharacterDb.cxx"
-#include "eggCharacterFilter.cxx"
-#include "eggComponentData.cxx"
-#include "eggJointData.cxx"
-#include "eggJointPointer.cxx"
-#include "eggJointNodePointer.cxx"
-#include "eggMatrixTablePointer.cxx"
-#include "eggScalarTablePointer.cxx"
-#include "eggSliderData.cxx"
-#include "eggSliderPointer.cxx"
-#include "eggVertexPointer.cxx"
-
diff --git a/pandatool/src/eggprogs/CMakeLists.txt b/pandatool/src/eggprogs/CMakeLists.txt
deleted file mode 100644
index e845c57d..00000000
--- a/pandatool/src/eggprogs/CMakeLists.txt
+++ /dev/null
@@ -1,43 +0,0 @@
-if(NOT BUILD_TOOLS)
- return()
-endif()
-
-if(NOT HAVE_EGG)
- return()
-endif()
-
-add_executable(egg-crop eggCrop.cxx eggCrop.h)
-target_link_libraries(egg-crop p3eggbase)
-install(TARGETS egg-crop EXPORT Tools COMPONENT Tools DESTINATION ${CMAKE_INSTALL_BINDIR})
-
-add_executable(egg-list-textures eggListTextures.cxx eggListTextures.h)
-target_link_libraries(egg-list-textures p3eggbase)
-install(TARGETS egg-list-textures EXPORT Tools COMPONENT Tools DESTINATION ${CMAKE_INSTALL_BINDIR})
-
-add_executable(egg-make-tube eggMakeTube.cxx eggMakeTube.h)
-target_link_libraries(egg-make-tube p3eggbase)
-install(TARGETS egg-make-tube EXPORT Tools COMPONENT Tools DESTINATION ${CMAKE_INSTALL_BINDIR})
-
-add_executable(egg-rename eggRename.cxx eggRename.h)
-target_link_libraries(egg-rename p3eggbase)
-install(TARGETS egg-rename EXPORT Tools COMPONENT Tools DESTINATION ${CMAKE_INSTALL_BINDIR})
-
-add_executable(egg-retarget-anim eggRetargetAnim.cxx eggRetargetAnim.h)
-target_link_libraries(egg-retarget-anim p3eggcharbase)
-install(TARGETS egg-retarget-anim EXPORT Tools COMPONENT Tools DESTINATION ${CMAKE_INSTALL_BINDIR})
-
-add_executable(egg-texture-cards eggTextureCards.cxx eggTextureCards.h)
-target_link_libraries(egg-texture-cards p3eggbase)
-install(TARGETS egg-texture-cards EXPORT Tools COMPONENT Tools DESTINATION ${CMAKE_INSTALL_BINDIR})
-
-add_executable(egg2c eggToC.cxx eggToC.h)
-target_link_libraries(egg2c p3eggbase)
-install(TARGETS egg2c EXPORT Tools COMPONENT Tools DESTINATION ${CMAKE_INSTALL_BINDIR})
-
-add_executable(egg-topstrip eggTopstrip.cxx eggTopstrip.h)
-target_link_libraries(egg-topstrip p3eggcharbase)
-install(TARGETS egg-topstrip EXPORT Tools COMPONENT Tools DESTINATION ${CMAKE_INSTALL_BINDIR})
-
-add_executable(egg-trans eggTrans.cxx eggTrans.h)
-target_link_libraries(egg-trans p3eggbase)
-install(TARGETS egg-trans EXPORT Tools COMPONENT Tools DESTINATION ${CMAKE_INSTALL_BINDIR})
diff --git a/pandatool/src/eggprogs/eggCrop.cxx b/pandatool/src/eggprogs/eggCrop.cxx
deleted file mode 100644
index 38edb932..00000000
--- a/pandatool/src/eggprogs/eggCrop.cxx
+++ /dev/null
@@ -1,124 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggCrop.cxx
- * @author drose
- * @date 2002-06-10
- */
-
-#include "eggCrop.h"
-
-#include "eggGroupNode.h"
-#include "eggPrimitive.h"
-#include "eggVertex.h"
-#include "dcast.h"
-
-/**
- *
- */
-EggCrop::
-EggCrop() {
- set_program_brief("crop geometry in an .egg file");
- set_program_description
- ("egg-crop strips out all parts of an egg file that fall outside of an "
- "arbitrary bounding volume, specified with a minimum and maximum point "
- "in world coordinates.");
-
- add_option
- ("min", "x,y,z", 0,
- "Specify the minimum point.",
- &EggCrop::dispatch_double_triple, &_got_min, &_min[0]);
-
- add_option
- ("max", "x,y,z", 0,
- "Specify the maximum point.",
- &EggCrop::dispatch_double_triple, &_got_max, &_max[0]);
-}
-
-/**
- * This is called after the command line has been completely processed, and it
- * gives the program a chance to do some last-minute processing and validation
- * of the options and arguments. It should return true if everything is fine,
- * false if there is an error.
- */
-bool EggCrop::
-post_command_line() {
- if (!_got_min || !_got_max) {
- nout << "You must specify both a minimum and a maximum bounds.\n";
- return false;
- }
-
- return true;
-}
-
-/**
- *
- */
-void EggCrop::
-run() {
- int num_removed = strip_prims(_data);
- nout << "Removed " << num_removed << " primitives.\n";
-
- _data->remove_unused_vertices(true);
- write_egg_file();
-}
-
-
-/**
- * Recursively walks the scene graph, looking for primitives that exceed the
- * specified bounding volume, and removes them. Returns the number of
- * primitives removed.
- */
-int EggCrop::
-strip_prims(EggGroupNode *group) {
- int num_removed = 0;
-
- EggGroupNode::iterator ci;
- ci = group->begin();
- while (ci != group->end()) {
- EggNode *child = (*ci);
- bool all_in = true;
-
- if (child->is_of_type(EggPrimitive::get_class_type())) {
- EggPrimitive *prim = DCAST(EggPrimitive, child);
- EggPrimitive::iterator vi;
- for (vi = prim->begin(); vi != prim->end() && all_in; ++vi) {
- EggVertex *vert = (*vi);
- LPoint3d pos = vert->get_pos3();
-
- all_in = (pos[0] >= _min[0] && pos[0] <= _max[0] &&
- pos[1] >= _min[1] && pos[1] <= _max[1] &&
- pos[2] >= _min[2] && pos[2] <= _max[2]);
-
- }
- }
-
- if (!all_in) {
- // Reject this primitive.
- ci = group->erase(ci);
- num_removed++;
- } else {
- // Keep this primitive.
- if (child->is_of_type(EggGroupNode::get_class_type())) {
- EggGroupNode *group_child = DCAST(EggGroupNode, child);
- num_removed += strip_prims(group_child);
- }
- ++ci;
- }
- }
-
- return num_removed;
-}
-
-
-int main(int argc, char *argv[]) {
- EggCrop prog;
- prog.parse_command_line(argc, argv);
- prog.run();
- return 0;
-}
diff --git a/pandatool/src/eggprogs/eggCrop.h b/pandatool/src/eggprogs/eggCrop.h
deleted file mode 100644
index df3203c8..00000000
--- a/pandatool/src/eggprogs/eggCrop.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggCrop.h
- * @author drose
- * @date 2002-06-10
- */
-
-#ifndef EGGCROP_H
-#define EGGCROP_H
-
-#include "pandatoolbase.h"
-
-#include "eggFilter.h"
-
-class EggGroupNode;
-
-/**
- * A program to read an egg file and write an equivalent egg file, possibly
- * performing some minor operations along the way.
- */
-class EggCrop : public EggFilter {
-public:
- EggCrop();
-
- virtual bool post_command_line();
- void run();
-
-private:
- int strip_prims(EggGroupNode *group);
-
- bool _got_min, _got_max;
- LVecBase3d _min, _max;
-};
-
-#endif
diff --git a/pandatool/src/eggprogs/eggListTextures.cxx b/pandatool/src/eggprogs/eggListTextures.cxx
deleted file mode 100644
index fd44c73a..00000000
--- a/pandatool/src/eggprogs/eggListTextures.cxx
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggListTextures.cxx
- * @author drose
- * @date 2005-05-23
- */
-
-#include "eggListTextures.h"
-#include "eggTextureCollection.h"
-#include "pnmImageHeader.h"
-
-/**
- *
- */
-EggListTextures::
-EggListTextures() {
- set_program_brief("list textures referenced by an .egg file");
- set_program_description
- ("egg-list-textures reads an egg file and writes a list of the "
- "textures it references. It is particularly useful for building "
- "up the textures.txa file used for egg-palettize, since the output "
- "format is crafted to be compatible with that file's input format.");
-}
-
-/**
- *
- */
-void EggListTextures::
-run() {
- if (!do_reader_options()) {
- exit(1);
- }
-
- EggTextureCollection tc;
- tc.find_used_textures(_data);
- EggTextureCollection::TextureReplacement treplace;
- tc.collapse_equivalent_textures(EggTexture::E_complete_filename, treplace);
- tc.sort_by_basename();
-
- EggTextureCollection::iterator ti;
- for (ti = tc.begin(); ti != tc.end(); ++ti) {
- Filename fullpath = (*ti)->get_fullpath();
- PNMImageHeader header;
- if (header.read_header(fullpath)) {
- std::cout << fullpath.get_basename() << " : "
- << header.get_x_size() << " " << header.get_y_size() << "\n";
- } else {
- std::cout << fullpath.get_basename() << " : unknown\n";
- }
- }
-}
-
-
-int main(int argc, char *argv[]) {
- EggListTextures prog;
- prog.parse_command_line(argc, argv);
- prog.run();
- return 0;
-}
diff --git a/pandatool/src/eggprogs/eggListTextures.h b/pandatool/src/eggprogs/eggListTextures.h
deleted file mode 100644
index 5460b49e..00000000
--- a/pandatool/src/eggprogs/eggListTextures.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggListTextures.h
- * @author drose
- * @date 2005-05-23
- */
-
-#ifndef EGGLISTTEXTURES_H
-#define EGGLISTTEXTURES_H
-
-#include "pandatoolbase.h"
-
-#include "eggReader.h"
-
-/**
- * Reads an egg file and outputs the list of textures it uses.
- */
-class EggListTextures : public EggReader {
-public:
- EggListTextures();
-
- void run();
-};
-
-#endif
diff --git a/pandatool/src/eggprogs/eggMakeTube.cxx b/pandatool/src/eggprogs/eggMakeTube.cxx
deleted file mode 100644
index 85ec8508..00000000
--- a/pandatool/src/eggprogs/eggMakeTube.cxx
+++ /dev/null
@@ -1,270 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggMakeTube.cxx
- * @author drose
- * @date 2003-10-01
- */
-
-#include "eggMakeTube.h"
-#include "eggGroup.h"
-#include "eggVertexPool.h"
-#include "eggVertex.h"
-#include "eggPolygon.h"
-#include "pointerTo.h"
-#include "look_at.h"
-
-/**
- *
- */
-EggMakeTube::
-EggMakeTube() {
-
- set_program_brief("generate a tube or sphere from geometry in an .egg file");
- set_program_description
- ("egg-make-tube generates an egg file representing a \"tube\" model, "
- "a cylinder capped on both ends by hemispheres. This is similar "
- "in shape to the CollisionCapsule object within Panda.\n\n"
- "This program can also generate spheres if you omit -b; in this "
- "case, you are generating a degenerate tube of length 0.");
-
- add_option
- ("a", "x,y,z", 0,
- "Specify the first endpoint of the tube.",
- &EggWriter::dispatch_double_triple, nullptr, _point_a);
-
- add_option
- ("b", "x,y,z", 0,
- "Specify the second endpoint of the tube.",
- &EggWriter::dispatch_double_triple, &_got_point_b, _point_b);
-
- add_option
- ("r", "radius", 0,
- "Specify the radius of the tube. The tube will extend beyond "
- "the endpoints in each direction by the amount of radius.",
- &EggWriter::dispatch_double, nullptr, &_radius);
-
- add_option
- ("slices", "count", 0,
- "Specify the number of slices appearing radially around the tube.",
- &EggWriter::dispatch_int, nullptr, &_num_slices);
-
- add_option
- ("crings", "count", 0,
- "Specify the number of rings appearing in each endcap of the tube.",
- &EggWriter::dispatch_int, nullptr, &_num_crings);
-
- add_option
- ("trings", "count", 0,
- "Specify the number of rings appearing in the cylindrical body "
- "of the tube.",
- &EggWriter::dispatch_int, nullptr, &_num_trings);
-
- _point_a[0] = 0.0;
- _point_a[1] = 0.0;
- _point_a[2] = 0.0;
-
- _point_b[0] = 0.0;
- _point_b[1] = 0.0;
- _point_b[2] = 0.0;
-
- _radius = 1.0;
-
- _num_slices = 8;
- _num_crings = 4;
- _num_trings = 1;
-}
-
-/**
- *
- */
-void EggMakeTube::
-run() {
- if (!_got_point_b) {
- _point_b[0] = _point_a[0];
- _point_b[1] = _point_a[1];
- _point_b[2] = _point_a[2];
- }
-
- // We will generate the vertices in the canonical space (along the y axis),
- // then transform it to the desired point.
- LVector3d direction(_point_b[0] - _point_a[0],
- _point_b[1] - _point_a[1],
- _point_b[2] - _point_a[2]);
- _length = direction.length();
-
- // First, create an enclosing group and a vertex pool.
- _group = new EggGroup("tube");
- _data->add_child(_group);
-
- _vpool = new EggVertexPool("tube");
- _group->add_child(_vpool);
-
- // Generate the first endcap.
- int ri, si;
- EggVertex *vtx_1;
- EggVertex *vtx_2;
-
- for (ri = 0; ri < _num_crings; ri++) {
- vtx_1 = nullptr;
- vtx_2 = nullptr;
- for (si = 0; si <= _num_slices; si++) {
- EggVertex *vtx_3 = calc_sphere1_vertex(ri, si);
- EggVertex *vtx_4 = calc_sphere1_vertex(ri + 1, si);
- add_polygon(vtx_1, vtx_2, vtx_4, vtx_3);
- vtx_1 = vtx_3;
- vtx_2 = vtx_4;
- }
- }
-
- // Now the cylinder sides.
- if (_length != 0.0) {
- for (ri = 0; ri < _num_trings; ri++) {
- vtx_1 = nullptr;
- vtx_2 = nullptr;
- for (si = 0; si <= _num_slices; si++) {
- EggVertex *vtx_3 = calc_tube_vertex(ri, si);
- EggVertex *vtx_4 = calc_tube_vertex(ri + 1, si);
- add_polygon(vtx_1, vtx_2, vtx_4, vtx_3);
- vtx_1 = vtx_3;
- vtx_2 = vtx_4;
- }
- }
- }
-
- // And the second endcap.
- for (ri = _num_crings - 1; ri >= 0; ri--) {
- vtx_1 = nullptr;
- vtx_2 = nullptr;
- for (si = 0; si <= _num_slices; si++) {
- EggVertex *vtx_3 = calc_sphere2_vertex(ri + 1, si);
- EggVertex *vtx_4 = calc_sphere2_vertex(ri, si);
- add_polygon(vtx_1, vtx_2, vtx_4, vtx_3);
- vtx_1 = vtx_3;
- vtx_2 = vtx_4;
- }
- }
-
- // Now transform the vertices out of the canonical position.
- LMatrix4d mat;
- look_at(mat, direction, LVector3d(0.0, 0.0, 1.0), CS_zup_right);
- mat.set_row(3, LPoint3d(_point_a[0], _point_a[1], _point_a[2]));
- _group->transform(mat);
-
- write_egg_file();
-}
-
-/**
- * Calculates a particular vertex on the surface of the first endcap
- * hemisphere.
- */
-EggVertex *EggMakeTube::
-calc_sphere1_vertex(int ri, int si) {
- double r = (double)ri / (double)_num_crings;
- double s = (double)si / (double)_num_slices;
-
- // Find the point on the rim, based on the slice.
- double theta = s * 2.0 * MathNumbers::pi;
- double x_rim = cos(theta);
- double z_rim = sin(theta);
-
- // Now pull that point in towards the pole, based on the ring.
- double phi = r * 0.5 * MathNumbers::pi;
- double to_pole = sin(phi);
-
- double x = _radius * x_rim * to_pole;
- double y = -_radius * cos(phi);
- double z = _radius * z_rim * to_pole;
-
- EggVertex vert;
- vert.set_pos(LPoint3d(x, y, z));
-
- return _vpool->create_unique_vertex(vert);
-}
-
-/**
- * Calculates a vertex on the side of the cylindrical body of the tube.
- */
-EggVertex *EggMakeTube::
-calc_tube_vertex(int ri, int si) {
- double r = (double)ri / (double)_num_trings;
- double s = (double)si / (double)_num_slices;
-
- // Find the point on the rim, based on the slice.
- double theta = s * 2.0 * MathNumbers::pi;
- double x_rim = cos(theta);
- double z_rim = sin(theta);
-
- double x = _radius * x_rim;
- double y = _length * r;
- double z = _radius * z_rim;
-
- EggVertex vert;
- vert.set_pos(LPoint3d(x, y, z));
-
- return _vpool->create_unique_vertex(vert);
-}
-
-/**
- * Calculates a particular vertex on the surface of the second endcap
- * hemisphere.
- */
-EggVertex *EggMakeTube::
-calc_sphere2_vertex(int ri, int si) {
- double r = (double)ri / (double)_num_crings;
- double s = (double)si / (double)_num_slices;
-
- // Find the point on the rim, based on the slice.
- double theta = s * 2.0 * MathNumbers::pi;
- double x_rim = cos(theta);
- double z_rim = sin(theta);
-
- // Now pull that point in towards the pole, based on the ring.
- double phi = r * 0.5 * MathNumbers::pi;
- double to_pole = sin(phi);
-
- double x = _radius * x_rim * to_pole;
- double y = _length + _radius * cos(phi);
- double z = _radius * z_rim * to_pole;
-
- EggVertex vert;
- vert.set_pos(LPoint3d(x, y, z));
-
- return _vpool->create_unique_vertex(vert);
-}
-
-/**
- * Adds the polygon defined by the indicated four vertices to the group. If
- * the first vertex is NULL, does nothing.
- */
-void EggMakeTube::
-add_polygon(EggVertex *a, EggVertex *b, EggVertex *c, EggVertex *d) {
- if (a == nullptr) {
- return;
- }
-
- PT(EggPolygon) poly = new EggPolygon;
- poly->add_vertex(a);
- if (a != b) {
- poly->add_vertex(b);
- }
- poly->add_vertex(c);
- if (c != d) {
- poly->add_vertex(d);
- }
-
- _group->add_child(poly.p());
-}
-
-
-int main(int argc, char *argv[]) {
- EggMakeTube prog;
- prog.parse_command_line(argc, argv);
- prog.run();
- return 0;
-}
diff --git a/pandatool/src/eggprogs/eggMakeTube.h b/pandatool/src/eggprogs/eggMakeTube.h
deleted file mode 100644
index 3031b1c7..00000000
--- a/pandatool/src/eggprogs/eggMakeTube.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggMakeTube.h
- * @author drose
- * @date 2003-10-01
- */
-
-#ifndef EGGMAKETUBE_H
-#define EGGMAKETUBE_H
-
-#include "pandatoolbase.h"
-
-#include "eggMakeSomething.h"
-
-class EggGroup;
-class EggVertexPool;
-class EggVertex;
-
-/**
- * A program to generate an egg file representing a tube model, similar in
- * shape to a CollisionCapsule.
- */
-class EggMakeTube : public EggMakeSomething {
-public:
- EggMakeTube();
-
- void run();
-
-private:
- EggVertex *calc_sphere1_vertex(int ri, int si);
- EggVertex *calc_sphere2_vertex(int ri, int si);
- EggVertex *calc_tube_vertex(int ri, int si);
- void add_polygon(EggVertex *a, EggVertex *b, EggVertex *c, EggVertex *d);
-
-private:
- double _point_a[3];
- double _point_b[3];
- bool _got_point_b;
- double _radius;
- int _num_slices;
- int _num_crings;
- int _num_trings;
-
- double _length;
- EggGroup *_group;
- EggVertexPool *_vpool;
-};
-
-#endif
diff --git a/pandatool/src/eggprogs/eggRename.cxx b/pandatool/src/eggprogs/eggRename.cxx
deleted file mode 100644
index 6b2c9869..00000000
--- a/pandatool/src/eggprogs/eggRename.cxx
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggRename.cxx
- * @author masad
- * @date 2005-04-22
- */
-
-#include "eggRename.h"
-
-/**
- *
- */
-EggRename::
-EggRename() {
- set_program_brief("rename nodes in .egg files");
- set_program_description
- ("egg-rename reads one or more egg files and writes back with modified"
- "node names. ie. suppressing prefix from all the nodes' names. ");
-
- add_option
- ("strip_prefix", "name", 0,
- "strips out the prefix that is put on all nodes, by maya ext. ref",
- &EggRename::dispatch_vector_string, nullptr, &_strip_prefix);
-}
-
-/**
- *
- */
-void EggRename::
-run() {
- if (!_strip_prefix.empty()) {
- nout << "Stripping prefix from nodes.\n";
- int num_renamed = 0;
- //int num_egg_files = 0;
- Eggs::iterator ei;
- for (ei = _eggs.begin(); ei != _eggs.end(); ++ei) {
- num_renamed += (*ei)->rename_nodes(_strip_prefix, true);
- //++num_egg_files;
- }
- nout << " (" << num_renamed << " renamed.)\n";
- }
-
- write_eggs();
-}
-
-
-int main(int argc, char *argv[]) {
- EggRename prog;
- prog.parse_command_line(argc, argv);
- prog.run();
- return 0;
-}
diff --git a/pandatool/src/eggprogs/eggRename.h b/pandatool/src/eggprogs/eggRename.h
deleted file mode 100644
index 51bd5344..00000000
--- a/pandatool/src/eggprogs/eggRename.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggRename.h
- * @author masad
- * @date 2005-04-22
- */
-
-#ifndef EGGRENAME_H
-#define EGGRENAME_H
-
-#include "pandatoolbase.h"
-
-#include "eggMultiFilter.h"
-
-/**
- * A program to read an egg file and write an equivalent egg file, with
- * stripping prefix for now, but more along the way.
- */
-class EggRename : public EggMultiFilter {
-public:
- EggRename();
-
- void run();
-
- vector_string _strip_prefix;
-};
-
-#endif
diff --git a/pandatool/src/eggprogs/eggRetargetAnim.cxx b/pandatool/src/eggprogs/eggRetargetAnim.cxx
deleted file mode 100644
index ba55d19b..00000000
--- a/pandatool/src/eggprogs/eggRetargetAnim.cxx
+++ /dev/null
@@ -1,192 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggRetargetAnim.cxx
- * @author drose
- * @date 2005-05-05
- */
-
-#include "eggRetargetAnim.h"
-
-#include "dcast.h"
-#include "eggJointData.h"
-#include "eggCharacterCollection.h"
-#include "eggCharacterData.h"
-#include "eggCharacterDb.h"
-#include "eggJointPointer.h"
-#include "eggTable.h"
-#include "compose_matrix.h"
-
-/**
- *
- */
-EggRetargetAnim::
-EggRetargetAnim() {
- add_path_replace_options();
- add_path_store_options();
-
- set_program_brief("remove transformations from animation data in .egg files");
- set_program_description
- ("egg-retarget-anim reads a character model and its associated animation "
- "files, and removes the translations and scales from the animation "
- "files, replacing them with the translations and scales from the "
- "rest position of the character model.\n\n"
-
- "This allows an animation that was generated for a model with one "
- "skeleton to be played successfully on a model with a different "
- "skeleton, provided that both skeletons have the same hierarchy and "
- "differ only in scales and/or translations of the various joints, "
- "and that scales and translations are not part of the per-frame "
- "animations.");
-
- add_option
- ("r", "file.egg", 0,
- "Read the reference model from the indicated egg file. All of the "
- "animations will be retargeted to match the indicated file.",
- &EggRetargetAnim::dispatch_filename, nullptr, &_reference_filename);
-
- add_option
- ("keep", "joint[,joint...]", 0,
- "Preserve the full animation on the named joint(s). This is especially "
- "appropriate for the root joint.",
- &EggRetargetAnim::dispatch_vector_string_comma, nullptr, &_keep_joints);
-}
-
-/**
- *
- */
-void EggRetargetAnim::
-run() {
- nassertv(_collection != nullptr);
- nassertv(_collection->get_num_eggs() > 0);
-
- if (_reference_filename.empty()) {
- nout << "No reference filename specified.\n";
- exit(1);
- }
-
- int num_characters = _collection->get_num_characters();
- if (num_characters != 1) {
- nout << "All animations must have the same character name.\n";
- exit(1);
- }
-
- // Read in the extra egg file that we use for extracting the references out.
- PT(EggData) reference_egg = read_egg(_reference_filename);
- if (reference_egg == nullptr) {
- nout << "Cannot read " << _reference_filename << "\n";
- exit(1);
- }
-
- // First, we add it to a separate EggCharacterCollection, so we can figure
- // out its name.
- EggCharacterCollection col;
- if (col.add_egg(reference_egg) < 0) {
- nout << _reference_filename
- << " does not contain a character model or animation reference.\n";
- exit(1);
- }
-
- if (col.get_num_characters() != 1) {
- nout << "Reference model must contain only one character.\n";
- exit(1);
- }
-
- std::string ref_name = col.get_character(0)->get_name();
-
- // Now rename all of the animations to the same name as the reference model,
- // and add the reference animation in to the same collection to match it up
- // joint-for-joint.
- _collection->rename_char(0, ref_name);
- int reference_egg_index = _collection->add_egg(reference_egg);
- nassertv(reference_egg_index > 0);
- nassertv(_collection->get_num_characters() == 1);
-
- int reference_model = _collection->get_first_model_index(reference_egg_index);
- EggCharacterData *char_data = _collection->get_character(0);
- nout << "Processing " << char_data->get_name() << "\n";
-
- typedef pset Names;
- Names keep_names;
-
- vector_string::const_iterator si;
- for (si = _keep_joints.begin(); si != _keep_joints.end(); ++si) {
- keep_names.insert(*si);
- }
-
- EggCharacterDb db;
- EggJointData *root_joint = char_data->get_root_joint();
- retarget_anim(char_data, root_joint, reference_model, keep_names, db);
- root_joint->do_rebuild_all(db);
-
- write_eggs();
-}
-
-/**
- * Recursively replaces the scale and translate information on all of the
- * joints in the char_data hierarchy wiht this from reference_char.
- */
-void EggRetargetAnim::
-retarget_anim(EggCharacterData *char_data, EggJointData *joint_data,
- int reference_model, const pset &keep_names,
- EggCharacterDb &db) {
- if (keep_names.find(joint_data->get_name()) != keep_names.end()) {
- // Don't retarget this joint; keep the translation and scale and whatever.
-
- } else {
- // Retarget this joint.
- int num_models = joint_data->get_num_models();
- for (int i = 0; i < num_models; i++) {
- if (joint_data->has_model(i)) {
- int num_frames = char_data->get_num_frames(i);
-
- EggBackPointer *back = joint_data->get_model(i);
- nassertv(back != nullptr);
- EggJointPointer *joint;
- DCAST_INTO_V(joint, back);
-
- LMatrix4d ref = joint_data->get_frame(reference_model, 0);
- LVecBase3d ref_scale, ref_shear, ref_hpr, ref_translate;
- if (!decompose_matrix(ref, ref_scale, ref_shear, ref_hpr, ref_translate)) {
- nout << "Could not decompose rest frame for "
- << joint_data->get_name() << "\n";
- } else {
- int f;
- for (f = 0; f < num_frames; f++) {
- LMatrix4d mat = joint_data->get_frame(i, f);
-
- LVecBase3d scale, shear, hpr, translate;
- if (decompose_matrix(mat, scale, shear, hpr, translate)) {
- compose_matrix(mat, ref_scale, ref_shear, hpr, ref_translate);
- } else {
- nout << "Could not decompose matrix for " << joint_data->get_name()
- << "\n";
- }
-
- db.set_matrix(joint, EggCharacterDb::TT_rebuild_frame,
- f, mat);
- }
- }
- }
- }
- }
-
- int num_children = joint_data->get_num_children();
- for (int i = 0; i < num_children; i++) {
- EggJointData *next_joint_data = joint_data->get_child(i);
- retarget_anim(char_data, next_joint_data, reference_model, keep_names, db);
- }
-}
-
-
-int main(int argc, char *argv[]) {
- EggRetargetAnim prog;
- prog.parse_command_line(argc, argv);
- prog.run();
- return 0;
-}
diff --git a/pandatool/src/eggprogs/eggRetargetAnim.h b/pandatool/src/eggprogs/eggRetargetAnim.h
deleted file mode 100644
index 455942ae..00000000
--- a/pandatool/src/eggprogs/eggRetargetAnim.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggRetargetAnim.h
- * @author drose
- * @date 2005-05-05
- */
-
-#ifndef EGGRETARGETANIM_H
-#define EGGRETARGETANIM_H
-
-#include "pandatoolbase.h"
-
-#include "eggCharacterFilter.h"
-#include "luse.h"
-#include "pvector.h"
-#include "pset.h"
-
-class EggCharacterData;
-class EggJointData;
-class EggCharacterDb;
-
-/**
- * Retargets one or more animation files from one particular skeleton to a
- * similar, but differently scaled skeleton by preserving the rotation
- * information but discarding translation and/or scale.
- */
-class EggRetargetAnim : public EggCharacterFilter {
-public:
- EggRetargetAnim();
-
- void run();
-
- void retarget_anim(EggCharacterData *char_data, EggJointData *joint_data,
- int reference_model, const pset &keep_names,
- EggCharacterDb &db);
-
- Filename _reference_filename;
- vector_string _keep_joints;
-};
-
-#endif
diff --git a/pandatool/src/eggprogs/eggTextureCards.cxx b/pandatool/src/eggprogs/eggTextureCards.cxx
deleted file mode 100644
index 255b145a..00000000
--- a/pandatool/src/eggprogs/eggTextureCards.cxx
+++ /dev/null
@@ -1,492 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggTextureCards.cxx
- * @author drose
- * @date 2001-02-21
- */
-
-#include "eggTextureCards.h"
-
-#include "eggGroup.h"
-#include "eggVertexPool.h"
-#include "eggVertex.h"
-#include "eggTexture.h"
-#include "eggPolygon.h"
-#include "pnmImageHeader.h"
-
-#include
-
-using std::string;
-
-/**
- *
- */
-EggTextureCards::
-EggTextureCards() : EggWriter(true, true) {
- set_program_brief("generate an .egg file containing texture cards");
- set_program_description
- ("egg-texture-cards generates an egg file consisting of several "
- "square polygons, one for each texture name that appears on the "
- "command line.\n\n"
-
- "This is a handy thing to have for importing texture images through "
- "egg-palettize, even when those textures do not appear on any real "
- "geometry; it can also be used for creating a lot of simple polygons "
- "for rendering click buttons and similar interfaces.");
-
- clear_runlines();
- add_runline("[opts] texture [texture ...] output.egg");
- add_runline("[opts] -o output.egg texture [texture ...]");
- add_runline("[opts] texture [texture ...] >output.egg");
-
- add_option
- ("g", "left,right,bottom,top", 0,
- "Specifies the geometry of each polygon. The default is a unit polygon "
- "centered on the origin: -0.5,0.5,-0.5,0.5. Polygons are always created "
- "on the X-Y plane. If -p is not also specified, all polygons will be "
- "the same size and shape.",
- &EggTextureCards::dispatch_double_quad, nullptr, &_polygon_geometry[0]);
-
- add_option
- ("p", "xpixels,ypixels", 0,
- "Indicates that polygons should be sized in proportion to the pixel "
- "size of the texture image. This will potentially create a "
- "different size and shape polygon for each texture. The coordinate "
- "pair represents the image size in "
- "pixels that will exactly fill up the polygon described with -g (or the "
- "default polygon if -g is not specified); smaller images will be "
- "given proportionately smaller polygons, and larger images will be "
- "given proportionately larger polygons.",
- &EggTextureCards::dispatch_double_pair, &_got_pixel_scale, &_pixel_scale[0]);
-
- add_option
- ("suffix", "string", 0,
- "Normally, each polygon is given a name based on the basename of its "
- "corresponding texture's filename (without the filename extension). "
- "This option specifies an ignorable suffix in the texture filename(s); "
- "if this suffix is present, it is not included in the polygon's name. "
- "This option may be repeated multiple times.",
- &EggTextureCards::dispatch_vector_string, nullptr, &_suffixes);
-
- add_option
- ("c", "r,g,b[,a]", 0,
- "Specifies the color of each polygon. The default is white: 1,1,1,1.",
- &EggTextureCards::dispatch_color, nullptr, &_polygon_color[0]);
-
- add_option
- ("wm", "wrap", 0,
- "Indicates the wrap mode of the texture: \"repeat\", \"clamp\", "
- "or any of the other modes supported by egg syntax. "
- "The default is to leave this unspecified.",
- &EggTextureCards::dispatch_wrap_mode, nullptr, &_wrap_mode);
-
- add_option
- ("wmu", "wrap_u", 0,
- "Indicates the wrap mode of the texture in the U direction. This "
- "overrides -wm, if specified.",
- &EggTextureCards::dispatch_wrap_mode, nullptr, &_wrap_u);
-
- add_option
- ("wmv", "wrap_v", 0,
- "Indicates the wrap mode of the texture in the V direction. This "
- "overrides -wm, if specified.",
- &EggTextureCards::dispatch_wrap_mode, nullptr, &_wrap_v);
-
- add_option
- ("minf", "filter", 0,
- "Indicates the minfilter mode of the texture: \"linear\", \"mipmap\", "
- "or any of the other modes supported by egg syntax. "
- "The default is to leave this unspecified.",
- &EggTextureCards::dispatch_filter_type, nullptr, &_minfilter);
-
- add_option
- ("magf", "filter", 0,
- "Indicates the magfilter mode of the texture: \"linear\" or \"nearest\". "
- "The default is to leave this unspecified.",
- &EggTextureCards::dispatch_filter_type, nullptr, &_magfilter);
-
- add_option
- ("aniso", "degree", 0,
- "Indicates the anisotropic degree of the texture. "
- "The default is to leave this unspecified.",
- &EggTextureCards::dispatch_int, &_got_aniso_degree, &_aniso_degree);
-
- add_option
- ("ql", "[default | fastest | normal | best]", 0,
- "Specifies the quality level of the texture. This mainly affects "
- "the tinydisplay software renderer.",
- &EggTextureCards::dispatch_quality_level, nullptr, &_quality_level);
-
- add_option
- ("f", "format", 0,
- "Indicates the format for all textures: typical choices are \"rgba12\" "
- "or \"rgb5\" or \"alpha\". The default is to leave this unspecified.",
- &EggTextureCards::dispatch_format, nullptr, &_format);
-
- add_option
- ("f1", "format", 0,
- "Indicates the format for one-channel textures only. If specified, this "
- "overrides the format specified by -f.",
- &EggTextureCards::dispatch_format, nullptr, &_format_1);
-
- add_option
- ("f2", "format", 0,
- "Indicates the format for two-channel textures only. If specified, this "
- "overrides the format specified by -f.",
- &EggTextureCards::dispatch_format, nullptr, &_format_2);
-
- add_option
- ("f3", "format", 0,
- "Indicates the format for three-channel textures only. If specified, this "
- "overrides the format specified by -f.",
- &EggTextureCards::dispatch_format, nullptr, &_format_3);
-
- add_option
- ("f4", "format", 0,
- "Indicates the format for four-channel textures only. If specified, this "
- "overrides the format specified by -f.",
- &EggTextureCards::dispatch_format, nullptr, &_format_4);
-
- add_option
- ("b", "", 0,
- "Make the textured polygons backfaced (two-sided).",
- &EggTextureCards::dispatch_none, &_apply_bface);
-
- add_option
- ("fps", "frame-rate", 0,
- "Normally, all of the texture cards are created as a series of nodes "
- "beneath a SequenceNode. This allows all of the cards to be viewed, "
- "one at a time, if the output file is loaded in pview. It also has the "
- "nice side-effect of creating an automatic texture flip that can be "
- "used directly by applications; use this parameter to specify the "
- "frame rate of that texture flip.",
- &EggTextureCards::dispatch_double, nullptr, &_frame_rate);
-
- add_option
- ("noexist", "", 0,
- "Don't treat it as an error if the input file references pathnames "
- "(e.g. textures) that don't exist. Normally, this will be flagged as "
- "an error and the command aborted; with this option, an egg file will "
- "be generated anyway, referencing pathnames that do not exist.",
- &EggTextureCards::dispatch_none, &_noexist);
-
- _polygon_geometry.set(-0.5, 0.5, -0.5, 0.5);
- _polygon_color.set(1.0, 1.0, 1.0, 1.0);
- _wrap_mode = EggTexture::WM_unspecified;
- _wrap_u = EggTexture::WM_unspecified;
- _wrap_v = EggTexture::WM_unspecified;
- _minfilter = EggTexture::FT_unspecified;
- _magfilter = EggTexture::FT_unspecified;
- _aniso_degree = 0;
- _quality_level = EggTexture::QL_unspecified;
- _format = EggTexture::F_unspecified;
- _format_1 = EggTexture::F_unspecified;
- _format_2 = EggTexture::F_unspecified;
- _format_3 = EggTexture::F_unspecified;
- _format_4 = EggTexture::F_unspecified;
- _frame_rate = 2.0;
-}
-
-/**
- * Does something with the additional arguments on the command line (after all
- * the -options have been parsed). Returns true if the arguments are good,
- * false otherwise.
- */
-bool EggTextureCards::
-handle_args(ProgramBase::Args &args) {
- if (!check_last_arg(args, 0)) {
- return false;
- }
-
- if (args.empty()) {
- nout << "No texture names specified on the command line.\n";
- return false;
- }
-
- ProgramBase::Args::iterator ai;
- for (ai = args.begin(); ai != args.end(); ++ai) {
- _texture_names.push_back(Filename::from_os_specific(*ai));
- }
-
- return true;
-}
-
-/**
- * Standard dispatch function for an option that takes one parameter, which is
- * to be interpreted as a WrapMode string. The data pointer is to a WrapMode
- * enum variable.
- */
-bool EggTextureCards::
-dispatch_wrap_mode(const string &opt, const string &arg, void *var) {
- EggTexture::WrapMode *wmp = (EggTexture::WrapMode *)var;
-
- *wmp = EggTexture::string_wrap_mode(arg);
- if (*wmp == EggTexture::WM_unspecified) {
- // An unknown string. Let's check for our special cases.
- if (arg == "r") {
- *wmp = EggTexture::WM_repeat;
- } else if (arg == "c") {
- *wmp = EggTexture::WM_clamp;
- } else {
- nout << "Invalid wrap mode parameter for -" << opt << ": "
- << arg << "\n";
- return false;
- }
- }
-
- return true;
-}
-
-/**
- * Standard dispatch function for an option that takes one parameter, which is
- * to be interpreted as a FilterType string. The data pointer is to a
- * FilterType enum variable.
- */
-bool EggTextureCards::
-dispatch_filter_type(const string &opt, const string &arg, void *var) {
- EggTexture::FilterType *ftp = (EggTexture::FilterType *)var;
-
- *ftp = EggTexture::string_filter_type(arg);
- if (*ftp == EggTexture::FT_unspecified) {
- // An unknown string.
- nout << "Invalid filter type parameter for -" << opt << ": "
- << arg << "\n";
- return false;
- }
-
- return true;
-}
-
-/**
- * Standard dispatch function for an option that takes one parameter, which is
- * to be interpreted as a QualityLevel string. The data pointer is to a
- * QualityLevel enum variable.
- */
-bool EggTextureCards::
-dispatch_quality_level(const string &opt, const string &arg, void *var) {
- EggTexture::QualityLevel *qlp = (EggTexture::QualityLevel *)var;
-
- *qlp = EggTexture::string_quality_level(arg);
- if (*qlp == EggTexture::QL_unspecified) {
- nout << "Invalid quality level parameter for -" << opt << ": "
- << arg << "\n";
- return false;
- }
-
- return true;
-}
-
-/**
- * Standard dispatch function for an option that takes one parameter, which is
- * to be interpreted as a Format string. The data pointer is to a Format enum
- * variable.
- */
-bool EggTextureCards::
-dispatch_format(const string &opt, const string &arg, void *var) {
- EggTexture::Format *fp = (EggTexture::Format *)var;
-
- *fp = EggTexture::string_format(arg);
- if (*fp == EggTexture::F_unspecified) {
- nout << "Invalid format parameter for -" << opt << ": "
- << arg << "\n";
- return false;
- }
-
- return true;
-}
-
-
-/**
- * Reads the texture image header to determine its size, and based on this
- * size, computes the appropriate left,right,bottom,top geometry of the card
- * that correspond to this texture.
- *
- * Returns true if successful, or false if the texture cannot be read.
- */
-bool EggTextureCards::
-scan_texture(const Filename &filename, LVecBase4d &geometry,
- int &num_channels) {
- PNMImageHeader header;
- if (!header.read_header(filename)) {
- nout << "Unable to read image " << filename << "\n";
- return false;
- }
-
- num_channels = header.get_num_channels();
-
- double xscale = header.get_x_size() / _pixel_scale[0];
- double yscale = header.get_y_size() / _pixel_scale[1];
-
- geometry.set(_polygon_geometry[0] * xscale,
- _polygon_geometry[1] * xscale,
- _polygon_geometry[2] * yscale,
- _polygon_geometry[3] * yscale);
- return true;
-}
-
-/**
- * Creates a set of four vertices for the polygon according to the
- * left,right,bottom,top geometry.
- */
-void EggTextureCards::
-make_vertices(const LPoint4d &geometry, EggVertexPool *vpool,
- EggVertex *&v1, EggVertex *&v2, EggVertex *&v3, EggVertex *&v4) {
- // 1 4 2 3
-
- v1 = vpool->make_new_vertex
- (LPoint3d(geometry[0], geometry[3], 0.0));
- v2 = vpool->make_new_vertex
- (LPoint3d(geometry[0], geometry[2], 0.0));
- v3 = vpool->make_new_vertex
- (LPoint3d(geometry[1], geometry[2], 0.0));
- v4 = vpool->make_new_vertex
- (LPoint3d(geometry[1], geometry[3], 0.0));
-
- v1->set_uv(LTexCoordd(0.0, 1.0));
- v2->set_uv(LTexCoordd(0.0, 0.0));
- v3->set_uv(LTexCoordd(1.0, 0.0));
- v4->set_uv(LTexCoordd(1.0, 1.0));
-}
-
-/**
- *
- */
-void EggTextureCards::
-run() {
- // First, create an enclosing group and a vertex pool with four vertices.
- // We can use the same four vertices on all polygons.
- bool all_ok = true;
-
- EggGroup *group = new EggGroup();
- _data->add_child(group);
-
- // If we have more than one tile, make the group a sequence, as a
- // convenience. If we view the egg file directly we can see all the tiles
- // one at a time.
- if (_texture_names.size() > 1) {
- group->set_switch_flag(true);
- group->set_switch_fps(_frame_rate);
- }
-
- EggVertexPool *vpool = new EggVertexPool("vpool");
- group->add_child(vpool);
-
- EggVertex *v1, *v2, *v3, *v4;
-
- bool got_pixel_scale = _got_pixel_scale;
- if (!got_pixel_scale) {
- // If we don't have a per-texture pixel scale, all the polygons will be
- // the same size, and hence may all share the same four vertices.
- make_vertices(_polygon_geometry, vpool, v1, v2, v3, v4);
- }
-
- // Now, create a texture reference and a polygon for each texture.
-
- vector_string::const_iterator ti;
- for (ti = _texture_names.begin(); ti != _texture_names.end(); ++ti) {
- Filename filename = (*ti);
- string name = filename.get_basename_wo_extension();
-
- // Strip off any suffixes from the name.
- vector_string::const_iterator si;
- for (si = _suffixes.begin(); si != _suffixes.end(); ++si) {
- const string &suffix = (*si);
- int prefix = (int)name.length() - (int)suffix.length();
- if (prefix > 0 && name.substr(prefix) == suffix) {
- name = name.substr(0, prefix);
- }
- }
-
- // Read in the texture header and determine its size.
- LVecBase4d geometry;
- int num_channels;
- bool texture_ok = scan_texture(filename, geometry, num_channels);
- if (!texture_ok) {
- all_ok = false;
- }
-
- if (got_pixel_scale) {
- if (texture_ok) {
- make_vertices(geometry, vpool, v1, v2, v3, v4);
- } else {
- make_vertices(_polygon_geometry, vpool, v1, v2, v3, v4);
- }
- }
-
- EggTexture *tref = new EggTexture(name, filename);
- tref->set_wrap_mode(_wrap_mode);
- tref->set_wrap_u(_wrap_u);
- tref->set_wrap_v(_wrap_v);
- tref->set_minfilter(_minfilter);
- tref->set_magfilter(_magfilter);
- if (_got_aniso_degree) {
- tref->set_anisotropic_degree(_aniso_degree);
- }
- tref->set_quality_level(_quality_level);
-
- if (texture_ok) {
- switch (num_channels) {
- case 1:
- tref->set_format(_format_1);
- break;
-
- case 2:
- tref->set_format(_format_2);
- break;
-
- case 3:
- tref->set_format(_format_3);
- break;
-
- case 4:
- tref->set_format(_format_4);
- break;
- }
- }
-
- if (tref->get_format() == EggTexture::F_unspecified) {
- tref->set_format(_format);
- }
-
- group->add_child(tref);
-
- // Each polygon gets placed in its own sub-group. This will make pulling
- // them out by name at runtime possible.
- EggGroup *sub_group = new EggGroup(name);
- group->add_child(sub_group);
- EggPolygon *poly = new EggPolygon();
- sub_group->add_child(poly);
- poly->set_texture(tref);
- poly->set_color(_polygon_color);
- if (_apply_bface){
- poly->set_bface_flag(1);
- }
-
- poly->add_vertex(v1);
- poly->add_vertex(v2);
- poly->add_vertex(v3);
- poly->add_vertex(v4);
- }
-
- // Done!
- if (all_ok || _noexist) {
- write_egg_file();
- } else {
- nout << "Some textures not found; not generating egg file.\n";
- exit(1);
- }
-}
-
-
-int main(int argc, char *argv[]) {
- EggTextureCards prog;
- prog.parse_command_line(argc, argv);
- prog.run();
- return 0;
-}
diff --git a/pandatool/src/eggprogs/eggTextureCards.h b/pandatool/src/eggprogs/eggTextureCards.h
deleted file mode 100644
index c30e926d..00000000
--- a/pandatool/src/eggprogs/eggTextureCards.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggTextureCards.h
- * @author drose
- * @date 2001-02-21
- */
-
-#ifndef EGGTEXTURECARDS_H
-#define EGGTEXTURECARDS_H
-
-#include "pandatoolbase.h"
-
-#include "eggWriter.h"
-#include "eggTexture.h"
-#include "luse.h"
-#include "vector_string.h"
-
-class EggVertexPool;
-class EggVertex;
-
-/**
- * Generates an egg file featuring a number of polygons, one for each named
- * texture. This is a support program for getting textures through egg-
- * palettize.
- */
-class EggTextureCards : public EggWriter {
-public:
- EggTextureCards();
-
-protected:
- virtual bool handle_args(Args &args);
-
- static bool dispatch_wrap_mode(const std::string &opt, const std::string &arg, void *var);
- static bool dispatch_filter_type(const std::string &opt, const std::string &arg, void *var);
- static bool dispatch_quality_level(const std::string &opt, const std::string &arg, void *var);
- static bool dispatch_format(const std::string &opt, const std::string &arg, void *var);
-
-private:
- bool scan_texture(const Filename &filename, LVecBase4d &geometry,
- int &num_channels);
- void make_vertices(const LPoint4d &geometry, EggVertexPool *vpool,
- EggVertex *&v1, EggVertex *&v2, EggVertex *&v3, EggVertex *&v4);
-
-public:
- void run();
-
- LVecBase4d _polygon_geometry;
- LVecBase2d _pixel_scale;
- bool _got_pixel_scale;
- vector_string _suffixes;
- LColor _polygon_color;
- vector_string _texture_names;
- EggTexture::WrapMode _wrap_mode;
- EggTexture::WrapMode _wrap_u;
- EggTexture::WrapMode _wrap_v;
- EggTexture::FilterType _minfilter;
- EggTexture::FilterType _magfilter;
- bool _got_aniso_degree;
- int _aniso_degree;
- EggTexture::QualityLevel _quality_level;
- EggTexture::Format _format;
- EggTexture::Format _format_1, _format_2, _format_3, _format_4;
- bool _apply_bface;
- double _frame_rate;
- bool _noexist;
-};
-
-#endif
diff --git a/pandatool/src/eggprogs/eggToC.cxx b/pandatool/src/eggprogs/eggToC.cxx
deleted file mode 100644
index bafc37fd..00000000
--- a/pandatool/src/eggprogs/eggToC.cxx
+++ /dev/null
@@ -1,373 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggToC.cxx
- * @author drose
- * @date 2001-08-03
- */
-
-#include "eggToC.h"
-
-#include "eggVertexPool.h"
-#include "eggVertex.h"
-#include "eggPolygon.h"
-#include "eggPrimitive.h"
-#include "eggGroupNode.h"
-#include "eggPolysetMaker.h"
-#include "eggBin.h"
-#include "string_utils.h"
-
-using std::ostream;
-using std::string;
-
-/**
- *
- */
-EggToC::
-EggToC() :
- EggToSomething("C", ".c", true, true)
-{
- set_program_brief("convert .egg geometry into compilable C tables");
- set_program_description
- ("This program reads Egg files and outputs code that will almost "
- "compile as a C or C++ program. You get to define the data structures "
- "for the program after the fact; the program only generates tables "
- "of vertices and polygons.");
-
- // -f is always in effect for egg2c. It doesn't make sense to provide it as
- // an option to the user.
- remove_option("f");
-
- add_option
- ("v", "", 0,
- "Generate a table of vertex positions.",
- &EggToC::dispatch_none, &_vertices);
-
- add_option
- ("u", "", 0,
- "Generate a table of UV's per each vertex.",
- &EggToC::dispatch_none, &_uvs);
-
- add_option
- ("vn", "", 0,
- "Generate a table of normals per each vertex.",
- &EggToC::dispatch_none, &_vertex_normals);
-
- add_option
- ("vc", "", 0,
- "Generate a table of colors per each vertex.",
- &EggToC::dispatch_none, &_vertex_colors);
-
- add_option
- ("p", "", 0,
- "Generate a table of polygons that index into the above tables.",
- &EggToC::dispatch_none, &_polygons);
-
- add_option
- ("pn", "", 0,
- "Generate a table of normals per each polygon.",
- &EggToC::dispatch_none, &_polygon_normals);
-
- add_option
- ("pc", "", 0,
- "Generate a table of colors per each polygon.",
- &EggToC::dispatch_none, &_polygon_colors);
-
- add_option
- ("t", "", 0,
- "Output only triangles by subdividing higher-order polygons.",
- &EggToC::dispatch_none, &_triangulate_polygons);
-}
-
-/**
- *
- */
-void EggToC::
-run() {
- nout << "Removing invalid primitives.\n";
- int num_removed = _data->remove_invalid_primitives(true);
- nout << " (" << num_removed << " removed.)\n";
-
- if (_triangulate_polygons) {
- nout << "Triangulating polygons.\n";
- int num_produced = _data->triangulate_polygons(~0);
- nout << " (" << num_produced << " triangles produced.)\n";
- }
-
- _data->apply_texmats();
- _data->flatten_transforms();
- _data->remove_unused_vertices(true);
-
- // Collect all the polygons together into polysets.
- EggPolysetMaker pmaker;
- pmaker.set_properties(0);
- pmaker.make_bins(_data);
-
- get_output()
- << "/*\n"
- << " * Generated by:\n"
- << " * " << get_exec_command() << "\n"
- << " *\n"
- << " */\n\n";
-
- _next_vpool_index = 0;
- _next_bin_index = 0;
- traverse(_data);
-}
-
-/**
- *
- */
-void EggToC::
-traverse(EggNode *node) {
- if (node->is_of_type(EggVertexPool::get_class_type())) {
- write_vertex_pool(DCAST(EggVertexPool, node));
-
- } else if (node->is_of_type(EggBin::get_class_type())) {
- write_bin(DCAST(EggBin, node));
-
- } else if (node->is_of_type(EggGroupNode::get_class_type())) {
- EggGroupNode *group = DCAST(EggGroupNode, node);
-
- EggGroupNode::const_iterator ci;
- for (ci = group->begin(); ci != group->end(); ++ci) {
- traverse(*ci);
- }
- }
-}
-
-/**
- *
- */
-void EggToC::
-write_vertex_pool(EggVertexPool *vpool) {
- int highest_index = vpool->get_highest_index();
- int i;
-
- ostream &out = get_output();
- out << "/* Vertex pool index " << _next_vpool_index
- << ": " << vpool->get_name() << " */\n";
- _vertex_pools[vpool] = _next_vpool_index;
- _next_vpool_index++;
-
- if (_vertices) {
- out << "/* Vertex definition for " << vpool->get_name() << " */\n"
- << "vertex vertices_" << vpool->get_name() << "[" << highest_index
- << "] = {\n";
- for (i = 0; i < highest_index; i++) {
- EggVertex *vert = vpool->get_vertex(i);
- if (vert == nullptr) {
- out << " vertex(), /* " << i << " */\n";
- } else {
- LPoint4d p = vert->get_pos4();
- switch (vert->get_num_dimensions()) {
- case 1:
- out << " vertex(" << p[0] << "), /* " << i << " */\n";
- break;
-
- case 2:
- out << " vertex(" << p[0] << ", " << p[1]
- << "), /* " << i << " */\n";
- break;
-
- case 3:
- out << " vertex(" << p[0] << ", " << p[1] << ", " << p[2]
- << "), /* " << i << " */\n";
- break;
-
- case 4:
- out << " vertex(" << p[0] << ", " << p[1] << ", " << p[2]
- << ", " << p[3] << "), /* " << i << " */\n";
- break;
-
- default:
- out << " vertex(), /* error */\n";
- }
- }
- }
- out << "};\n\n";
- }
-
- if (_uvs) {
- out << "/* UV's for " << vpool->get_name() << " */\n"
- << "uv uvs_" << vpool->get_name() << "[" << highest_index
- << "] = {\n";
- for (i = 0; i < highest_index; i++) {
- EggVertex *vert = vpool->get_vertex(i);
- if (vert == nullptr || !vert->has_uv()) {
- out << " uv(), /* " << i << " */\n";
- } else {
- LTexCoordd uv = vert->get_uv();
- out << " uv(" << uv[0] << ", " << uv[1]
- << "), /* " << i << " */\n";
- }
- }
- out << "};\n\n";
- }
-
- if (_vertex_normals) {
- out << "/* Vertex normals for " << vpool->get_name() << " */\n"
- << "normal normals_" << vpool->get_name() << "[" << highest_index
- << "] = {\n";
- for (i = 0; i < highest_index; i++) {
- EggVertex *vert = vpool->get_vertex(i);
- if (vert == nullptr || !vert->has_normal()) {
- out << " normal(), /* " << i << " */\n";
- } else {
- LNormald n = vert->get_normal();
- out << " normal(" << n[0] << ", " << n[1] << ", " << n[2]
- << "), /* " << i << " */\n";
- }
- }
- out << "};\n\n";
- }
-
- if (_vertex_colors) {
- out << "/* Vertex colors for " << vpool->get_name() << " */\n"
- << "color colors_" << vpool->get_name() << "[" << highest_index
- << "] = {\n";
- for (i = 0; i < highest_index; i++) {
- EggVertex *vert = vpool->get_vertex(i);
- if (vert == nullptr || !vert->has_color()) {
- out << " color(), /* " << i << " */\n";
- } else {
- LColor c = vert->get_color();
- out << " color(" << c[0] << ", " << c[1] << ", " << c[2]
- << ", " << c[3] << "), /* " << i << " */\n";
- }
- }
- out << "};\n\n";
- }
-}
-
-
-/**
- *
- */
-void EggToC::
-write_bin(EggBin *bin) {
- ostream &out = get_output();
- string bin_name = bin->get_name();
- if (bin_name.empty()) {
- bin_name = format_string(_next_bin_index);
- _next_bin_index++;
- }
-
- out << "/* Polygon group " << bin_name << " */\n";
-
- size_t num_children = bin->size();
-
- if (_polygons) {
- out << "/* Polygon definitions for " << bin_name << " */\n";
- string prim_type = "polygon";
- if (_triangulate_polygons) {
- prim_type = "triangle";
- }
-
- out << prim_type << " polys_" << bin_name << "[" << num_children
- << "] = {\n";
-
- if (_triangulate_polygons) {
- out << " /* vpool index, vertex0, vertex1, vertex2 */\n";
- } else {
- out << " /* vpool index, num vertices, vertex0, vertex1, vertex2, ... */\n";
- }
-
- EggGroupNode::const_iterator ci;
- size_t prim_index = 0;
- for (ci = bin->begin(); ci != bin->end(); ++ci) {
- EggNode *child = (*ci);
- if (!child->is_of_type(EggPrimitive::get_class_type())) {
- out << " " << prim_type << "(), /* error */\n";
- } else {
- EggPrimitive *prim = DCAST(EggPrimitive, child);
- EggVertexPool *vpool = prim->get_pool();
- int vpool_index = -1;
- VertexPools::const_iterator pi = _vertex_pools.find(vpool);
- if (pi != _vertex_pools.end()) {
- vpool_index = (*pi).second;
- }
-
- out << " " << prim_type << "(" << vpool_index;
- if (!_triangulate_polygons) {
- out << ", " << prim->size();
- }
- EggPrimitive::const_iterator vi;
- for (vi = prim->begin(); vi != prim->end(); ++vi) {
- EggVertex *vert = (*vi);
- out << ", " << vert->get_index();
- }
- out << "), /* " << prim_index << " */\n";
- prim_index++;
- }
- }
- out << "};\n\n";
- }
-
- if (_polygon_normals) {
- ostream &out = get_output();
- out << "/* Polygon normals for " << bin_name << " */\n";
- out << "normal polys_" << bin_name << "[" << num_children
- << "] = {\n";
-
- EggGroupNode::const_iterator ci;
- size_t prim_index = 0;
- for (ci = bin->begin(); ci != bin->end(); ++ci) {
- EggNode *child = (*ci);
- if (!child->is_of_type(EggPrimitive::get_class_type())) {
- out << " normal(), /* error */\n";
- } else {
- EggPrimitive *prim = DCAST(EggPrimitive, child);
- if (!prim->has_normal()) {
- out << " normal(), /* " << prim_index << " */\n";
- } else {
- LNormald n = prim->get_normal();
- out << " normal(" << n[0] << ", " << n[1] << ", " << n[2]
- << "), /* " << prim_index << " */\n";
- }
- prim_index++;
- }
- }
- out << "};\n\n";
- }
-
- if (_polygon_colors) {
- ostream &out = get_output();
- out << "/* Polygon colors for " << bin_name << " */\n";
- out << "color polys_" << bin_name << "[" << num_children
- << "] = {\n";
-
- EggGroupNode::const_iterator ci;
- size_t prim_index = 0;
- for (ci = bin->begin(); ci != bin->end(); ++ci) {
- EggNode *child = (*ci);
- if (!child->is_of_type(EggPrimitive::get_class_type())) {
- out << " color(), /* error */\n";
- } else {
- EggPrimitive *prim = DCAST(EggPrimitive, child);
- if (!prim->has_color()) {
- out << " color(), /* " << prim_index << " */\n";
- } else {
- LColor c = prim->get_color();
- out << " color(" << c[0] << ", " << c[1] << ", " << c[2]
- << ", " << c[3] << "), /* " << prim_index << " */\n";
- }
- prim_index++;
- }
- }
- out << "};\n\n";
- }
-}
-
-
-int main(int argc, char *argv[]) {
- EggToC prog;
- prog.parse_command_line(argc, argv);
- prog.run();
- return 0;
-}
diff --git a/pandatool/src/eggprogs/eggToC.h b/pandatool/src/eggprogs/eggToC.h
deleted file mode 100644
index 9c5f328f..00000000
--- a/pandatool/src/eggprogs/eggToC.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggToC.h
- * @author drose
- * @date 2001-08-03
- */
-
-#ifndef EGGTOC_H
-#define EGGTOC_H
-
-#include "pandatoolbase.h"
-
-#include "eggToSomething.h"
-
-#include "pmap.h"
-
-class EggNode;
-class EggVertexPool;
-class EggBin;
-
-/**
- *
- */
-class EggToC : public EggToSomething {
-public:
- EggToC();
-
- void run();
-
- void traverse(EggNode *node);
- void write_vertex_pool(EggVertexPool *vpool);
- void write_bin(EggBin *bin);
-
- bool _vertices;
- bool _uvs;
- bool _vertex_normals;
- bool _vertex_colors;
- bool _polygons;
- bool _polygon_normals;
- bool _polygon_colors;
-
- bool _triangulate_polygons;
-
- typedef pmap VertexPools;
- VertexPools _vertex_pools;
- int _next_vpool_index;
- int _next_bin_index;
-};
-
-#endif
diff --git a/pandatool/src/eggprogs/eggTopstrip.cxx b/pandatool/src/eggprogs/eggTopstrip.cxx
deleted file mode 100644
index 2a46431f..00000000
--- a/pandatool/src/eggprogs/eggTopstrip.cxx
+++ /dev/null
@@ -1,349 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggTopstrip.cxx
- * @author drose
- * @date 2001-02-23
- */
-
-#include "eggTopstrip.h"
-
-#include "dcast.h"
-#include "eggJointData.h"
-#include "eggCharacterCollection.h"
-#include "eggCharacterData.h"
-#include "eggCharacterDb.h"
-#include "eggJointPointer.h"
-#include "eggTable.h"
-#include "compose_matrix.h"
-
-/**
- *
- */
-EggTopstrip::
-EggTopstrip() {
- add_path_replace_options();
- add_path_store_options();
-
- set_program_brief("unapplies animation from a joint in an .egg file");
- set_program_description
- ("egg-topstrip reads a character model and its associated animation "
- "files, and unapplies the animation from one of the top joints. "
- "This effectively freezes that particular joint, and makes the rest "
- "of the character relative to that joint.\n\n"
-
- "This is a particularly useful thing to do to generate character "
- "models that can stack one on top of the other in a sensible way.");
-
- add_option
- ("t", "name", 0,
- "Specify the name of the 'top' joint, from which to draw the "
- "animation channels which will be applied to the entire animation.",
- &EggTopstrip::dispatch_string, nullptr, &_top_joint_name);
-
- add_option
- ("i", "", 0,
- "Invert the matrix before applying. This causes a subtractive "
- "effect. This is the default unless -r is specified.",
- &EggTopstrip::dispatch_true, &_got_invert_transform, &_invert_transform);
-
- add_option
- ("n", "", 0,
- "Do not invert the matrix before applying. This causes an "
- "additive effect.",
- &EggTopstrip::dispatch_false, &_got_invert_transform, &_invert_transform);
-
- add_option
- ("s", "[ijkphrxyz]", 0,
- "Specify the components of the transform that are to be applied. Use "
- "any combination of the nine token letters: i, j, k represent the "
- "three scale axes; h, p, r represent rotation; and x, y, z represent "
- "translation. The default is everything: -s ijkphrxyz.",
- &EggTopstrip::dispatch_string, nullptr, &_transform_channels);
-
- add_option
- ("r", "file.egg", 0,
- "Read the animation channel from the indicated egg file. If this "
- "is not specified, each egg file will supply its own animation channel.",
- &EggTopstrip::dispatch_filename, nullptr, &_channel_filename);
-
- _invert_transform = true;
- _transform_channels = "ijkphrxyz";
-}
-
-/**
- *
- */
-void EggTopstrip::
-run() {
- nassertv(_collection != nullptr);
- nassertv(_collection->get_num_eggs() > 0);
-
- check_transform_channels();
-
- // Get the number of characters first, in case adding the _channel_egg
- // changes this.
- int num_characters = _collection->get_num_characters();
-
- // Determine which model and character we'll be pulling the animation
- // channels from.
- int from_model = -1;
-
- if (!_channel_filename.empty()) {
- // Read in the extra egg file that we use for extracting the channels out.
- PT(EggData) channel_egg = read_egg(_channel_filename);
- if (channel_egg == nullptr) {
- nout << "Cannot read " << _channel_filename << "\n";
- exit(1);
- }
- int channel_egg_index = _collection->add_egg(channel_egg);
- if (channel_egg_index < 0) {
- nout << _channel_filename
- << " does not contain a character model or animation channel.\n";
- exit(1);
- }
-
- from_model = _collection->get_first_model_index(channel_egg_index);
-
- if (!_got_invert_transform) {
- // With -r, the default is not to invert the transform.
- _invert_transform = false;
- }
- }
-
- // Now process each character.
- EggCharacterDb db;
-
- int ci;
- for (ci = 0; ci < num_characters; ci++) {
- EggCharacterData *char_data = _collection->get_character(ci);
- nout << "Processing " << char_data->get_name() << "\n";
-
- EggJointData *root_joint = char_data->get_root_joint();
-
- // We'll read the transform to apply from this character, which will be
- // the same character unless -r was specified.
- EggCharacterData *from_char = char_data;
- if (from_model != -1) {
- from_char = _collection->get_character_by_model_index(from_model);
- }
-
- // Determine which joint we'll use to extract the transform to apply.
- EggJointData *top_joint = nullptr;
- if (_top_joint_name.empty()) {
- // The default top joint name is the alphabetically first joint in the
- // top level.
- if (root_joint->get_num_children() == 0) {
- nout << "Character " << from_char->get_name() << " has no joints.\n";
- exit(1);
- }
- top_joint = root_joint->get_child(0);
- } else {
- top_joint = from_char->find_joint(_top_joint_name);
- if (top_joint == nullptr) {
- nout << "Character " << from_char->get_name()
- << " has no joint named " << _top_joint_name << "\n";
- exit(1);
- }
- }
-
- // First, transform all the joints.
- int num_children = root_joint->get_num_children();
- for (int i = 0; i < num_children; i++) {
- EggJointData *joint_data = root_joint->get_child(i);
- strip_anim(char_data, joint_data, from_model, from_char, top_joint, db);
- }
-
- // We also need to transform the vertices for any models involved here.
- int num_models = char_data->get_num_models();
- for (int m = 0; m < num_models; m++) {
- EggNode *node = char_data->get_model_root(m);
- if (!node->is_of_type(EggTable::get_class_type())) {
- strip_anim_vertices(node, char_data->get_model_index(m),
- from_model, top_joint, db);
- }
- }
- }
-
- // Now, trigger the actual rebuilding of all the joint data.
- for (ci = 0; ci < num_characters; ci++) {
- EggCharacterData *char_data = _collection->get_character(ci);
- char_data->get_root_joint()->do_rebuild_all(db);
- }
-
- write_eggs();
-}
-
-/**
- * Checks the _transform_channels string to ensure that it contains only the
- * expected nine letters, or a subset.
- */
-void EggTopstrip::
-check_transform_channels() {
- static std::string expected = "ijkphrxyz";
- static const int num_channels = 9;
- bool has_each[num_channels];
- memset(has_each, 0, num_channels * sizeof(bool));
-
- for (size_t p = 0; p < _transform_channels.size(); p++) {
- int i = expected.find(_transform_channels[p]);
- if (i == (int)std::string::npos) {
- nout << "Invalid letter for -s: " << _transform_channels[p] << "\n";
- exit(1);
- }
- nassertv(i < num_channels);
- has_each[i] = true;
- }
-
- _transform_channels = "";
- for (int i = 0; i < num_channels; i++) {
- if (has_each[i]) {
- _transform_channels += expected[i];
- }
- }
-
- if (_transform_channels.empty()) {
- nout << "No transform specified for -s.\n";
- exit(1);
- }
-}
-
-
-/**
- * Applies the channels from joint _top_joint in model from_model to the joint
- * referenced by joint_data.
- */
-void EggTopstrip::
-strip_anim(EggCharacterData *char_data, EggJointData *joint_data,
- int from_model, EggCharacterData *from_char,
- EggJointData *top_joint, EggCharacterDb &db) {
- int num_models = joint_data->get_num_models();
- for (int i = 0; i < num_models; i++) {
- int model = (from_model < 0) ? i : from_model;
- if (joint_data->has_model(i)) {
- if (!top_joint->has_model(model)) {
- nout << "Warning: Joint " << top_joint->get_name()
- << " is not defined in all models.\n";
- return;
- }
-
- int num_into_frames = char_data->get_num_frames(i);
- int num_from_frames = from_char->get_num_frames(model);
-
- int num_frames = std::max(num_into_frames, num_from_frames);
-
- EggBackPointer *back = joint_data->get_model(i);
- nassertv(back != nullptr);
- EggJointPointer *joint;
- DCAST_INTO_V(joint, back);
-
- // Compute and apply the new transforms.
-
- int f;
- for (f = 0; f < num_frames; f++) {
- LMatrix4d into = joint_data->get_frame(i, f % num_into_frames);
- LMatrix4d from = top_joint->get_net_frame(model, f % num_from_frames, db);
-
- adjust_transform(from);
-
- db.set_matrix(joint, EggCharacterDb::TT_rebuild_frame,
- f, into * from);
- }
- }
- }
-}
-
-/**
- * Applies the channels from joint _top_joint in model from_model to the
- * vertices at egg_node.
- */
-void EggTopstrip::
-strip_anim_vertices(EggNode *egg_node, int into_model, int from_model,
- EggJointData *top_joint, EggCharacterDb &db) {
- int model = (from_model < 0) ? into_model : from_model;
- if (!top_joint->has_model(model)) {
- nout << "Warning: Joint " << top_joint->get_name()
- << " is not defined in all models.\n";
- return;
- }
-
- LMatrix4d from = top_joint->get_net_frame(model, 0, db);
- adjust_transform(from);
-
- egg_node->transform_vertices_only(from);
-}
-
-
-/**
- * Adjust the transform extracted from the "top" joint according to the -s and
- * -i/-n options, prior to applying it to the skeleton.
- */
-void EggTopstrip::
-adjust_transform(LMatrix4d &mat) const {
- if (_transform_channels.length() != 9) {
- // Decompose and recompose the matrix, so we can eliminate the parts the
- // user doesn't want.
-
- LVecBase3d scale, hpr, translate;
- bool result = decompose_matrix(mat, scale, hpr, translate, _coordinate_system);
- if (!result) {
- nout << "Warning: skew transform in animation.\n";
- } else {
- LVecBase3d new_scale(1.0, 1.0, 1.0);
- LVecBase3d new_hpr(0.0, 0.0, 0.0);
- LVecBase3d new_translate(0.0, 0.0, 0.0);
-
- for (size_t i = 0; i < _transform_channels.size(); i++) {
- switch (_transform_channels[i]) {
- case 'i':
- new_scale[0] = scale[0];
- break;
- case 'j':
- new_scale[1] = scale[1];
- break;
- case 'k':
- new_scale[2] = scale[2];
- break;
-
- case 'h':
- new_hpr[0] = hpr[0];
- break;
- case 'p':
- new_hpr[1] = hpr[1];
- break;
- case 'r':
- new_hpr[2] = hpr[2];
- break;
-
- case 'x':
- new_translate[0] = translate[0];
- break;
- case 'y':
- new_translate[1] = translate[1];
- break;
- case 'z':
- new_translate[2] = translate[2];
- break;
- }
- }
-
- compose_matrix(mat, new_scale, new_hpr, new_translate, _coordinate_system);
- }
- }
- if (_invert_transform) {
- mat.invert_in_place();
- }
-}
-
-
-int main(int argc, char *argv[]) {
- EggTopstrip prog;
- prog.parse_command_line(argc, argv);
- prog.run();
- return 0;
-}
diff --git a/pandatool/src/eggprogs/eggTopstrip.h b/pandatool/src/eggprogs/eggTopstrip.h
deleted file mode 100644
index 8e04b7e0..00000000
--- a/pandatool/src/eggprogs/eggTopstrip.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggTopstrip.h
- * @author drose
- * @date 2001-02-23
- */
-
-#ifndef EGGTOPSTRIP_H
-#define EGGTOPSTRIP_H
-
-#include "pandatoolbase.h"
-
-#include "eggCharacterFilter.h"
-#include "luse.h"
-
-#include "pvector.h"
-
-class EggCharacterData;
-class EggCharacterDb;
-class EggJointData;
-class EggJointPointer;
-
-/**
- * Reads a character model and/or animations and strips out the animation from
- * one of the top joints from the entire character. Particularly useful for
- * generating stackable character models from separately-extracted characters.
- */
-class EggTopstrip : public EggCharacterFilter {
-public:
- EggTopstrip();
-
- void run();
- void check_transform_channels();
-
- void strip_anim(EggCharacterData *char_data, EggJointData *joint_data,
- int from_model, EggCharacterData *from_char,
- EggJointData *top_joint, EggCharacterDb &db);
- void strip_anim_vertices(EggNode *egg_node, int into_model,
- int from_model, EggJointData *top_joint,
- EggCharacterDb &db);
-
- void adjust_transform(LMatrix4d &mat) const;
-
-
- std::string _top_joint_name;
- bool _got_invert_transform;
- bool _invert_transform;
- std::string _transform_channels;
- Filename _channel_filename;
-};
-
-#endif
diff --git a/pandatool/src/eggprogs/eggTrans.cxx b/pandatool/src/eggprogs/eggTrans.cxx
deleted file mode 100644
index 28d439e6..00000000
--- a/pandatool/src/eggprogs/eggTrans.cxx
+++ /dev/null
@@ -1,137 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggTrans.cxx
- * @author drose
- * @date 2000-02-14
- */
-
-#include "eggTrans.h"
-#include "eggGroupUniquifier.h"
-
-/**
- *
- */
-EggTrans::
-EggTrans() {
- add_path_replace_options();
- add_path_store_options();
- add_normals_options();
- add_transform_options();
- add_texture_options();
- add_delod_options();
-
- set_program_brief("apply transformations and optimizations to an .egg file");
- set_program_description
- ("egg-trans reads an egg file and writes an essentially equivalent "
- "egg file to the standard output, or to the file specified with -o. "
- "Some simple operations on the egg file are supported.");
-
- add_option
- ("F", "", 0,
- "Flatten out transforms.",
- &EggTrans::dispatch_none, &_flatten_transforms);
-
- add_option
- ("t", "", 0,
- "Apply texture matrices to UV's.",
- &EggTrans::dispatch_none, &_apply_texmats);
-
- add_option
- ("T", "", 0,
- "Collapse equivalent texture references.",
- &EggTrans::dispatch_none, &_collapse_equivalent_textures);
-
- add_option
- ("c", "", 0,
- "Clean out degenerate polygons and unused vertices.",
- &EggTrans::dispatch_none, &_remove_invalid_primitives);
-
- add_option
- ("C", "", 0,
- "Clean out higher-order polygons by subdividing into triangles.",
- &EggTrans::dispatch_none, &_triangulate_polygons);
-
- add_option
- ("mesh", "", 0,
- "Mesh triangles into triangle strips. This is mainly useful as a "
- "tool to visualize the work that the mesher will do, since triangles "
- "are automatically meshed whenever an egg file is loaded. Note that, "
- "unlike the automatic meshing at load time, you are must ensure that "
- "you do not start out with multiple triangles with different attributes "
- "(e.g. texture) together in the same group.",
- &EggTrans::dispatch_none, &_mesh_triangles);
-
- add_option
- ("N", "", 0,
- "Standardize and uniquify group names.",
- &EggTrans::dispatch_none, &_standardize_names);
-
-}
-
-/**
- *
- */
-void EggTrans::
-run() {
- if (_remove_invalid_primitives) {
- nout << "Removing invalid primitives.\n";
- int num_removed = _data->remove_invalid_primitives(true);
- nout << " (" << num_removed << " removed.)\n";
- _data->remove_unused_vertices(true);
- }
-
- if (_triangulate_polygons) {
- nout << "Triangulating polygons.\n";
- int num_produced = _data->triangulate_polygons(~0);
- nout << " (" << num_produced << " triangles produced.)\n";
- }
-
- if (_mesh_triangles) {
- nout << "Meshing triangles.\n";
- _data->mesh_triangles(~0);
- }
-
- if (_apply_texmats) {
- nout << "Applying texture matrices.\n";
- _data->apply_texmats();
- _data->remove_unused_vertices(true);
- }
-
- if (_collapse_equivalent_textures) {
- nout << "Collapsing equivalent textures.\n";
- int num_removed = _data->collapse_equivalent_textures();
- nout << " (" << num_removed << " removed.)\n";
- }
-
- if (_flatten_transforms) {
- nout << "Flattening transforms.\n";
- _data->flatten_transforms();
- _data->remove_unused_vertices(true);
- }
-
- if (_standardize_names) {
- nout << "Standardizing group names.\n";
- EggGroupUniquifier uniquifier;
- uniquifier.uniquify(_data);
- }
-
- if (!do_reader_options()) {
- exit(1);
- }
-
- write_egg_file();
-}
-
-
-int main(int argc, char *argv[]) {
- EggTrans prog;
- prog.parse_command_line(argc, argv);
- prog.run();
- return 0;
-}
diff --git a/pandatool/src/eggprogs/eggTrans.h b/pandatool/src/eggprogs/eggTrans.h
deleted file mode 100644
index 350ece14..00000000
--- a/pandatool/src/eggprogs/eggTrans.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggTrans.h
- * @author drose
- * @date 2000-02-14
- */
-
-#ifndef EGGTRANS_H
-#define EGGTRANS_H
-
-#include "pandatoolbase.h"
-
-#include "eggFilter.h"
-
-/**
- * A program to read an egg file and write an equivalent egg file, possibly
- * performing some minor operations along the way.
- */
-class EggTrans : public EggFilter {
-public:
- EggTrans();
-
- void run();
-
- bool _flatten_transforms;
- bool _apply_texmats;
- bool _collapse_equivalent_textures;
- bool _remove_invalid_primitives;
- bool _triangulate_polygons;
- bool _mesh_triangles;
- bool _standardize_names;
-};
-
-#endif
diff --git a/pandatool/src/flt/CMakeLists.txt b/pandatool/src/flt/CMakeLists.txt
deleted file mode 100644
index 02f096b8..00000000
--- a/pandatool/src/flt/CMakeLists.txt
+++ /dev/null
@@ -1,90 +0,0 @@
-set(P3FLT_HEADERS
- config_flt.h
- fltBead.h
- fltBeadID.h
- fltCurve.h fltCurve.I
- fltError.h
- fltExternalReference.h
- fltEyepoint.h
- fltFace.h fltFace.I
- fltGeometry.h fltGeometry.I
- fltGroup.h
- fltHeader.h
- fltInstanceDefinition.h
- fltInstanceRef.h
- fltLightSourceDefinition.h
- fltLocalVertexPool.h fltLocalVertexPool.I
- fltLOD.h
- fltMaterial.h
- fltMesh.h fltMesh.I
- fltMeshPrimitive.h fltMeshPrimitive.I
- fltObject.h
- fltOpcode.h
- fltPackedColor.h fltPackedColor.I
- fltRecord.h fltRecord.I
- fltRecordReader.h
- fltRecordWriter.h
- fltTexture.h
- fltTrackplane.h
- fltTransformGeneralMatrix.h
- fltTransformPut.h
- fltTransformRecord.h
- fltTransformRotateAboutEdge.h
- fltTransformRotateAboutPoint.h
- fltTransformRotateScale.h
- fltTransformScale.h
- fltTransformTranslate.h
- fltUnsupportedRecord.h
- fltVectorRecord.h
- fltVertex.h fltVertex.I
- fltVertexList.h
-)
-
-set(P3FLT_SOURCES
- config_flt.cxx
- fltBead.cxx
- fltBeadID.cxx
- fltCurve.cxx
- fltError.cxx
- fltExternalReference.cxx
- fltEyepoint.cxx
- fltFace.cxx
- fltGeometry.cxx
- fltGroup.cxx
- fltHeader.cxx
- fltInstanceDefinition.cxx
- fltInstanceRef.cxx
- fltLightSourceDefinition.cxx
- fltLocalVertexPool.cxx
- fltLOD.cxx
- fltMaterial.cxx
- fltMesh.cxx
- fltMeshPrimitive.cxx
- fltObject.cxx
- fltOpcode.cxx
- fltPackedColor.cxx
- fltRecord.cxx
- fltRecordReader.cxx
- fltRecordWriter.cxx
- fltTexture.cxx
- fltTrackplane.cxx
- fltTransformGeneralMatrix.cxx
- fltTransformPut.cxx
- fltTransformRecord.cxx
- fltTransformRotateAboutEdge.cxx
- fltTransformRotateAboutPoint.cxx
- fltTransformRotateScale.cxx
- fltTransformScale.cxx
- fltTransformTranslate.cxx
- fltUnsupportedRecord.cxx
- fltVectorRecord.cxx
- fltVertex.cxx
- fltVertexList.cxx
-)
-
-composite_sources(p3flt P3FLT_SOURCES)
-add_library(p3flt STATIC ${P3FLT_HEADERS} ${P3FLT_SOURCES})
-target_link_libraries(p3flt p3pandatoolbase panda)
-
-# This is only needed for binaries in the pandatool package. It is not useful
-# for user applications, so it is not installed.
diff --git a/pandatool/src/flt/config_flt.cxx b/pandatool/src/flt/config_flt.cxx
deleted file mode 100644
index 1e4f0f9d..00000000
--- a/pandatool/src/flt/config_flt.cxx
+++ /dev/null
@@ -1,112 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file config_flt.cxx
- * @author drose
- * @date 2000-08-24
- */
-
-#include "config_flt.h"
-#include "fltRecord.h"
-#include "fltBead.h"
-#include "fltBeadID.h"
-#include "fltGroup.h"
-#include "fltObject.h"
-#include "fltGeometry.h"
-#include "fltFace.h"
-#include "fltCurve.h"
-#include "fltMesh.h"
-#include "fltLocalVertexPool.h"
-#include "fltMeshPrimitive.h"
-#include "fltVectorRecord.h"
-#include "fltVertexList.h"
-#include "fltLOD.h"
-#include "fltInstanceDefinition.h"
-#include "fltInstanceRef.h"
-#include "fltHeader.h"
-#include "fltVertex.h"
-#include "fltMaterial.h"
-#include "fltTexture.h"
-#include "fltLightSourceDefinition.h"
-#include "fltUnsupportedRecord.h"
-#include "fltTransformRecord.h"
-#include "fltTransformGeneralMatrix.h"
-#include "fltTransformPut.h"
-#include "fltTransformRotateAboutEdge.h"
-#include "fltTransformRotateAboutPoint.h"
-#include "fltTransformScale.h"
-#include "fltTransformTranslate.h"
-#include "fltTransformRotateScale.h"
-#include "fltExternalReference.h"
-
-#include "dconfig.h"
-
-Configure(config_flt);
-NotifyCategoryDef(flt, "");
-
-
-ConfigVariableBool flt_error_abort
-("flt-error-abort", false,
- PRC_DESC("Set this true to trigger an assertion failure (and core dump) "
- "immediately when an error is detected on reading or writing a flt "
- "file. This is primarily useful for debugging the flt reader itself, "
- "to generate a stack trace to determine precisely at what point a flt "
-
- "file failed."));
-
-
-ConfigureFn(config_flt) {
- init_libflt();
-}
-
-/**
- * Initializes the library. This must be called at least once before any of
- * the functions or classes in this library can be used. Normally it will be
- * called by the static initializers and need not be called explicitly, but
- * special cases exist.
- */
-void
-init_libflt() {
- static bool initialized = false;
- if (initialized) {
- return;
- }
- initialized = true;
-
- FltRecord::init_type();
- FltBead::init_type();
- FltBeadID::init_type();
- FltGroup::init_type();
- FltObject::init_type();
- FltGeometry::init_type();
- FltFace::init_type();
- FltCurve::init_type();
- FltMesh::init_type();
- FltLocalVertexPool::init_type();
- FltMeshPrimitive::init_type();
- FltVectorRecord::init_type();
- FltVertexList::init_type();
- FltLOD::init_type();
- FltInstanceDefinition::init_type();
- FltInstanceRef::init_type();
- FltHeader::init_type();
- FltVertex::init_type();
- FltMaterial::init_type();
- FltTexture::init_type();
- FltLightSourceDefinition::init_type();
- FltUnsupportedRecord::init_type();
- FltTransformRecord::init_type();
- FltTransformGeneralMatrix::init_type();
- FltTransformPut::init_type();
- FltTransformRotateAboutEdge::init_type();
- FltTransformRotateAboutPoint::init_type();
- FltTransformScale::init_type();
- FltTransformTranslate::init_type();
- FltTransformRotateScale::init_type();
- FltExternalReference::init_type();
-}
diff --git a/pandatool/src/flt/config_flt.h b/pandatool/src/flt/config_flt.h
deleted file mode 100644
index 789179ce..00000000
--- a/pandatool/src/flt/config_flt.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file config_flt.h
- * @author drose
- * @date 2000-08-24
- */
-
-#ifndef CONFIG_FLT_H
-#define CONFIG_FLT_H
-
-#include "pandatoolbase.h"
-
-#include "notifyCategoryProxy.h"
-#include "configVariableBool.h"
-
-NotifyCategoryDeclNoExport(flt);
-
-extern ConfigVariableBool flt_error_abort;
-
-extern void init_libflt();
-
-static const int header_size = 4;
-
-#endif
diff --git a/pandatool/src/flt/fltBead.cxx b/pandatool/src/flt/fltBead.cxx
deleted file mode 100644
index 8cc21f8c..00000000
--- a/pandatool/src/flt/fltBead.cxx
+++ /dev/null
@@ -1,357 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltBead.cxx
- * @author drose
- * @date 2000-08-24
- */
-
-#include "fltBead.h"
-#include "fltRecordReader.h"
-#include "fltRecordWriter.h"
-#include "fltTransformGeneralMatrix.h"
-#include "fltTransformPut.h"
-#include "fltTransformRotateAboutEdge.h"
-#include "fltTransformRotateAboutPoint.h"
-#include "fltTransformScale.h"
-#include "fltTransformTranslate.h"
-#include "fltTransformRotateScale.h"
-#include "config_flt.h"
-
-#include "dcast.h"
-
-#include
-
-TypeHandle FltBead::_type_handle;
-
-/**
- *
- */
-FltBead::
-FltBead(FltHeader *header) : FltRecord(header) {
- _has_transform = false;
- _transform = LMatrix4d::ident_mat();
- _replicate_count = 0;
-}
-
-/**
- * Returns true if the bead has been transformed, false otherwise. If this
- * returns true, get_transform() will return the single-precision net
- * transformation, and get_num_transform_steps() will return nonzero.
- */
-bool FltBead::
-has_transform() const {
- return _has_transform;
-}
-
-/**
- * Returns the single-precision 4x4 matrix that represents the transform
- * applied to this bead, or the identity matrix if the bead has not been
- * transformed.
- */
-const LMatrix4d &FltBead::
-get_transform() const {
- return _has_transform ? _transform : LMatrix4d::ident_mat();
-}
-
-/**
- * Replaces the transform matrix on this bead. This implicitly removes all of
- * the transform steps added previously, and replaces them with a single 4x4
- * general matrix transform step.
- */
-void FltBead::
-set_transform(const LMatrix4d &mat) {
- clear_transform();
- FltTransformGeneralMatrix *step = new FltTransformGeneralMatrix(_header);
- step->set_matrix(mat);
- add_transform_step(step);
-}
-
-/**
- * Removes any transform matrix and all transform steps on this bead.
- */
-void FltBead::
-clear_transform() {
- _has_transform = false;
- _transform = LMatrix4d::ident_mat();
- _transform_steps.clear();
-}
-
-/**
- * Returns the number of individual steps that define the net transform on
- * this bead as returned by set_transform(). Each step is a single
- * transformation; the concatenation of all transformations will produce the
- * matrix represented by set_transform().
- */
-int FltBead::
-get_num_transform_steps() const {
- return _transform_steps.size();
-}
-
-/**
- * Returns the nth individual step that defines the net transform on this
- * bead. See get_num_transform_steps().
- */
-FltTransformRecord *FltBead::
-get_transform_step(int n) {
- nassertr(n >= 0 && n < (int)_transform_steps.size(),
- nullptr);
- return _transform_steps[n];
-}
-
-/**
- * Returns the nth individual step that defines the net transform on this
- * bead. See get_num_transform_steps().
- */
-const FltTransformRecord *FltBead::
-get_transform_step(int n) const {
- nassertr(n >= 0 && n < (int)_transform_steps.size(),
- nullptr);
- return _transform_steps[n];
-}
-
-/**
- * Applies the indicated transform step to the net transformation applied to
- * the bead.
- */
-void FltBead::
-add_transform_step(FltTransformRecord *record) {
- if (!_has_transform) {
- _has_transform = true;
- _transform = record->get_matrix();
- } else {
- _transform = record->get_matrix() * _transform;
- }
- _transform_steps.push_back(record);
-}
-
-/**
- * Returns the replicate count of this bead. If this is nonzero, it means
- * that the bead is implicitly copied this number of additional times (for
- * replicate_count + 1 total copies), applying the transform on this bead for
- * each copy. In this case, the transform does *not* apply to the initial
- * copy of the bead.
- */
-int FltBead::
-get_replicate_count() const {
- return _replicate_count;
-}
-
-/**
- * Changes the replicate count of this bead. If you are setting the replicate
- * count to some nonzero number, you must also set a transform on the bead.
- * See set_replicate_count().
- */
-void FltBead::
-set_replicate_count(int count) {
- _replicate_count = count;
-}
-
-/**
- * Fills in the information in this bead based on the information given in the
- * indicated datagram, whose opcode has already been read. Returns true on
- * success, false if the datagram is invalid.
- */
-bool FltBead::
-extract_record(FltRecordReader &reader) {
- if (!FltRecord::extract_record(reader)) {
- return false;
- }
- return true;
-}
-
-/**
- * Checks whether the given bead, which follows this bead sequentially in the
- * file, is an ancillary record of this bead. If it is, extracts the relevant
- * information and returns true; otherwise, leaves it alone and returns false.
- */
-bool FltBead::
-extract_ancillary(FltRecordReader &reader) {
- FltTransformRecord *step = nullptr;
-
- switch (reader.get_opcode()) {
- case FO_transform_matrix:
- return extract_transform_matrix(reader);
-
- case FO_general_matrix:
- step = new FltTransformGeneralMatrix(_header);
- break;
-
- case FO_put:
- step = new FltTransformPut(_header);
- break;
-
- case FO_rotate_about_edge:
- step = new FltTransformRotateAboutEdge(_header);
- break;
-
- case FO_rotate_about_point:
- step = new FltTransformRotateAboutPoint(_header);
- break;
-
- case FO_scale:
- step = new FltTransformScale(_header);
- break;
-
- case FO_translate:
- step = new FltTransformTranslate(_header);
- break;
-
- case FO_rotate_and_scale:
- step = new FltTransformRotateScale(_header);
- break;
-
- case FO_replicate:
- return extract_replicate_count(reader);
-
- default:
- return FltRecord::extract_ancillary(reader);
- }
-
- // A transform step.
- nassertr(step != nullptr, false);
- if (!step->extract_record(reader)) {
- return false;
- }
- _transform_steps.push_back(DCAST(FltTransformRecord, step));
-
- return true;
-}
-
-/**
- * Fills up the current record on the FltRecordWriter with data for this
- * record, but does not advance the writer. Returns true on success, false if
- * there is some error.
- */
-bool FltBead::
-build_record(FltRecordWriter &writer) const {
- if (!FltRecord::build_record(writer)) {
- return false;
- }
- return true;
-}
-
-/**
- * Writes whatever ancillary records are required for this record. Returns
- * FE_ok on success, or something else if there is some error.
- */
-FltError FltBead::
-write_ancillary(FltRecordWriter &writer) const {
- if (_has_transform) {
- FltError result = write_transform(writer);
- if (result != FE_ok) {
- return result;
- }
- }
- if (_replicate_count != 0) {
- FltError result = write_replicate_count(writer);
- if (result != FE_ok) {
- return result;
- }
- }
-
-
- return FltRecord::write_ancillary(writer);
-}
-
-/**
- * Reads a transform matrix ancillary bead. This defines the net
- * transformation that has been applied to the bead, and precedes the set of
- * individual transform steps that define how this net transform was computed.
- */
-bool FltBead::
-extract_transform_matrix(FltRecordReader &reader) {
- nassertr(reader.get_opcode() == FO_transform_matrix, false);
- DatagramIterator &iterator = reader.get_iterator();
-
- LMatrix4d matrix;
- for (int r = 0; r < 4; r++) {
- for (int c = 0; c < 4; c++) {
- matrix(r, c) = iterator.get_be_float32();
- }
- }
- check_remaining_size(iterator);
-
- _transform_steps.clear();
- _has_transform = true;
- _transform = matrix;
-
- return true;
-}
-
-/**
- * Reads a replicate count ancillary bead.
- */
-bool FltBead::
-extract_replicate_count(FltRecordReader &reader) {
- nassertr(reader.get_opcode() == FO_replicate, false);
- DatagramIterator &iterator = reader.get_iterator();
-
- _replicate_count = iterator.get_be_int16();
- iterator.skip_bytes(2);
-
- check_remaining_size(iterator);
- return true;
-}
-
-/**
- * Writes out the transformation and all of its defining steps.
- */
-FltError FltBead::
-write_transform(FltRecordWriter &writer) const {
- // First, write out the initial transform indication.
- writer.set_opcode(FO_transform_matrix);
- Datagram &datagram = writer.update_datagram();
-
- for (int r = 0; r < 4; r++) {
- for (int c = 0; c < 4; c++) {
- datagram.add_be_float32(_transform(r, c));
- }
- }
-
- FltError result = writer.advance();
- if (result != FE_ok) {
- return result;
- }
-
- // Now, write out each of the steps of the transform.
- Transforms::const_iterator ti;
- for (ti = _transform_steps.begin(); ti != _transform_steps.end(); ++ti) {
- if (!(*ti)->build_record(writer)) {
- assert(!flt_error_abort);
- return FE_invalid_record;
- }
- FltError result = writer.advance();
- if (result != FE_ok) {
- return result;
- }
- }
-
- return FE_ok;
-}
-
-/**
- * Writes out the replicate count, if needed.
- */
-FltError FltBead::
-write_replicate_count(FltRecordWriter &writer) const {
- if (_replicate_count != 0) {
- writer.set_opcode(FO_replicate);
- Datagram &datagram = writer.update_datagram();
-
- datagram.add_be_int16(_replicate_count);
- datagram.pad_bytes(2);
-
- FltError result = writer.advance();
- if (result != FE_ok) {
- return result;
- }
- }
-
- return FE_ok;
-}
diff --git a/pandatool/src/flt/fltBead.h b/pandatool/src/flt/fltBead.h
deleted file mode 100644
index d1b98779..00000000
--- a/pandatool/src/flt/fltBead.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltBead.h
- * @author drose
- * @date 2000-08-24
- */
-
-#ifndef FLTBEAD_H
-#define FLTBEAD_H
-
-#include "pandatoolbase.h"
-
-#include "fltRecord.h"
-#include "fltTransformRecord.h"
-
-#include "luse.h"
-
-/**
- * A base class for any of a broad family of flt records that represent
- * particular beads in the hierarchy. These are things like group beads and
- * object beads, as opposed to things like push and pop or comment records.
- */
-class FltBead : public FltRecord {
-public:
- FltBead(FltHeader *header);
-
- bool has_transform() const;
- const LMatrix4d &get_transform() const;
- void set_transform(const LMatrix4d &mat);
- void clear_transform();
-
- int get_num_transform_steps() const;
- FltTransformRecord *get_transform_step(int n);
- const FltTransformRecord *get_transform_step(int n) const;
- void add_transform_step(FltTransformRecord *record);
-
- int get_replicate_count() const;
- void set_replicate_count(int count);
-
-protected:
- virtual bool extract_record(FltRecordReader &reader);
- virtual bool extract_ancillary(FltRecordReader &reader);
-
- virtual bool build_record(FltRecordWriter &writer) const;
- virtual FltError write_ancillary(FltRecordWriter &writer) const;
-
-private:
- bool extract_transform_matrix(FltRecordReader &reader);
- bool extract_replicate_count(FltRecordReader &reader);
-
- FltError write_transform(FltRecordWriter &writer) const;
- FltError write_replicate_count(FltRecordWriter &writer) const;
-
-private:
- bool _has_transform;
- LMatrix4d _transform;
-
- typedef pvector Transforms;
- Transforms _transform_steps;
-
- int _replicate_count;
-
-public:
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- FltRecord::init_type();
- register_type(_type_handle, "FltBead",
- FltRecord::get_class_type());
- }
-
-private:
- static TypeHandle _type_handle;
-};
-
-#endif
diff --git a/pandatool/src/flt/fltBeadID.cxx b/pandatool/src/flt/fltBeadID.cxx
deleted file mode 100644
index 4b6dc695..00000000
--- a/pandatool/src/flt/fltBeadID.cxx
+++ /dev/null
@@ -1,124 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltBeadID.cxx
- * @author drose
- * @date 2000-08-24
- */
-
-#include "fltBeadID.h"
-#include "fltRecordReader.h"
-#include "fltRecordWriter.h"
-
-TypeHandle FltBeadID::_type_handle;
-
-/**
- *
- */
-FltBeadID::
-FltBeadID(FltHeader *header) : FltBead(header) {
-}
-
-/**
- * Returns the id (name) of this particular bead. Each MultiGen bead will
- * have a unique name.
- */
-const std::string &FltBeadID::
-get_id() const {
- return _id;
-}
-
-/**
- * Changes the id (name) of this particular bead. This should be a name that
- * is unique to this bead.
- */
-void FltBeadID::
-set_id(const std::string &id) {
- _id = id;
-}
-
-/**
- * Writes a quick one-line description of the record, but not its children.
- * This is a human-readable description, primarily for debugging; to write a
- * flt file, use FltHeader::write_flt().
- */
-void FltBeadID::
-output(std::ostream &out) const {
- out << get_type();
- if (!_id.empty()) {
- out << " " << _id;
- }
-}
-
-/**
- * Fills in the information in this bead based on the information given in the
- * indicated datagram, whose opcode has already been read. Returns true on
- * success, false if the datagram is invalid.
- */
-bool FltBeadID::
-extract_record(FltRecordReader &reader) {
- if (!FltBead::extract_record(reader)) {
- return false;
- }
-
- _id = reader.get_iterator().get_fixed_string(8);
- return true;
-}
-
-/**
- * Checks whether the given bead, which follows this bead sequentially in the
- * file, is an ancillary record of this bead. If it is, extracts the relevant
- * information and returns true; otherwise, leaves it alone and returns false.
- */
-bool FltBeadID::
-extract_ancillary(FltRecordReader &reader) {
- if (reader.get_opcode() == FO_long_id) {
- DatagramIterator &di = reader.get_iterator();
- _id = di.get_fixed_string(di.get_remaining_size());
- return true;
- }
-
- return FltBead::extract_ancillary(reader);
-}
-
-/**
- * Fills up the current record on the FltRecordWriter with data for this
- * record, but does not advance the writer. Returns true on success, false if
- * there is some error.
- */
-bool FltBeadID::
-build_record(FltRecordWriter &writer) const {
- if (!FltBead::build_record(writer)) {
- return false;
- }
-
- writer.update_datagram().add_fixed_string(_id.substr(0, 7), 8);
- return true;
-}
-
-/**
- * Writes whatever ancillary records are required for this record. Returns
- * FE_ok on success, or something else if there is some error.
- */
-FltError FltBeadID::
-write_ancillary(FltRecordWriter &writer) const {
- if (_id.length() > 7) {
- Datagram dc;
-
- // Although the manual mentions nothing of this, it is essential that the
- // length of the record be a multiple of 4 bytes.
- dc.add_fixed_string(_id, (_id.length() + 3) & ~3);
-
- FltError result = writer.write_record(FO_long_id, dc);
- if (result != FE_ok) {
- return result;
- }
- }
-
- return FltBead::write_ancillary(writer);
-}
diff --git a/pandatool/src/flt/fltBeadID.h b/pandatool/src/flt/fltBeadID.h
deleted file mode 100644
index d7e943b2..00000000
--- a/pandatool/src/flt/fltBeadID.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltBeadID.h
- * @author drose
- * @date 2000-08-24
- */
-
-#ifndef FLTBEADID_H
-#define FLTBEADID_H
-
-#include "pandatoolbase.h"
-
-#include "fltBead.h"
-
-/**
- * A base class for any of a broad family of flt beads that include an ID.
- */
-class FltBeadID : public FltBead {
-public:
- FltBeadID(FltHeader *header);
-
- const std::string &get_id() const;
- void set_id(const std::string &id);
-
- virtual void output(std::ostream &out) const;
-
-protected:
- virtual bool extract_record(FltRecordReader &reader);
- virtual bool extract_ancillary(FltRecordReader &reader);
-
- virtual bool build_record(FltRecordWriter &writer) const;
- virtual FltError write_ancillary(FltRecordWriter &writer) const;
-
-private:
- std::string _id;
-
-public:
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- FltBead::init_type();
- register_type(_type_handle, "FltBeadID",
- FltBead::get_class_type());
- }
-
-private:
- static TypeHandle _type_handle;
-};
-
-#endif
diff --git a/pandatool/src/flt/fltCurve.I b/pandatool/src/flt/fltCurve.I
deleted file mode 100644
index cb3d37d2..00000000
--- a/pandatool/src/flt/fltCurve.I
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltCurve.I
- * @author drose
- * @date 2001-02-28
- */
-
-/**
- * Returns the number of control points assigned to the curve.
- */
-INLINE int FltCurve::
-get_num_control_points() const {
- return _control_points.size();
-}
-
-/**
- * Returns the nth control point assigned to the curve.
- */
-INLINE const LPoint3d &FltCurve::
-get_control_point(int n) const {
-#ifndef NDEBUG
- static LPoint3d bogus(0.0, 0.0, 0.0);
- nassertr(n >= 0 && n < (int)_control_points.size(), bogus);
-#endif
- return _control_points[n];
-}
diff --git a/pandatool/src/flt/fltCurve.cxx b/pandatool/src/flt/fltCurve.cxx
deleted file mode 100644
index d9b3ae8b..00000000
--- a/pandatool/src/flt/fltCurve.cxx
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltCurve.cxx
- * @author drose
- * @date 2001-02-28
- */
-
-#include "fltCurve.h"
-#include "fltRecordReader.h"
-#include "fltRecordWriter.h"
-#include "fltHeader.h"
-#include "fltMaterial.h"
-
-TypeHandle FltCurve::_type_handle;
-
-/**
- *
- */
-FltCurve::
-FltCurve(FltHeader *header) : FltBeadID(header) {
- _curve_type = CT_b_spline;
-}
-
-/**
- * Fills in the information in this bead based on the information given in the
- * indicated datagram, whose opcode has already been read. Returns true on
- * success, false if the datagram is invalid.
- */
-bool FltCurve::
-extract_record(FltRecordReader &reader) {
- if (!FltBeadID::extract_record(reader)) {
- return false;
- }
-
- nassertr(reader.get_opcode() == FO_curve, false);
- DatagramIterator &iterator = reader.get_iterator();
-
- iterator.skip_bytes(4);
- _curve_type = (CurveType)iterator.get_be_int32();
-
- int num_control_points = iterator.get_be_int32();
- iterator.skip_bytes(8);
- for (int i = 0; i < num_control_points; i++) {
- double x = iterator.get_be_float64();
- double y = iterator.get_be_float64();
- double z = iterator.get_be_float64();
- _control_points.push_back(LPoint3d(x, y, z));
- }
-
- check_remaining_size(iterator);
- return true;
-}
-
-/**
- * Fills up the current record on the FltRecordWriter with data for this
- * record, but does not advance the writer. Returns true on success, false if
- * there is some error.
- */
-bool FltCurve::
-build_record(FltRecordWriter &writer) const {
- if (!FltBeadID::build_record(writer)) {
- return false;
- }
-
- writer.set_opcode(FO_curve);
- Datagram &datagram = writer.update_datagram();
-
- datagram.pad_bytes(4);
- datagram.add_be_int32(_curve_type);
- datagram.add_be_int32(_control_points.size());
- datagram.pad_bytes(8);
-
- ControlPoints::const_iterator ci;
- for (ci = _control_points.begin(); ci != _control_points.end(); ++ci) {
- const LPoint3d &p = (*ci);
- datagram.add_be_float64(p[0]);
- datagram.add_be_float64(p[1]);
- datagram.add_be_float64(p[2]);
- }
-
- return true;
-}
diff --git a/pandatool/src/flt/fltCurve.h b/pandatool/src/flt/fltCurve.h
deleted file mode 100644
index 79f19daf..00000000
--- a/pandatool/src/flt/fltCurve.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltCurve.h
- * @author drose
- * @date 2001-02-28
- */
-
-#ifndef FLTCURVE_H
-#define FLTCURVE_H
-
-#include "pandatoolbase.h"
-
-#include "fltBeadID.h"
-#include "fltHeader.h"
-
-#include "luse.h"
-
-/**
- * A single curve, like a Bezier or B-Spline.
- */
-class FltCurve : public FltBeadID {
-public:
- FltCurve(FltHeader *header);
-
- enum CurveType {
- CT_b_spline = 4,
- CT_cardinal = 5,
- CT_bezier = 6
- };
-
- typedef pvector ControlPoints;
-
- CurveType _curve_type;
- ControlPoints _control_points;
-
-public:
- INLINE int get_num_control_points() const;
- INLINE const LPoint3d &get_control_point(int n) const;
-
-
-protected:
- virtual bool extract_record(FltRecordReader &reader);
- virtual bool build_record(FltRecordWriter &writer) const;
-
-public:
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- FltBeadID::init_type();
- register_type(_type_handle, "FltCurve",
- FltBeadID::get_class_type());
- }
-
-private:
- static TypeHandle _type_handle;
-};
-
-#include "fltCurve.I"
-
-#endif
diff --git a/pandatool/src/flt/fltError.cxx b/pandatool/src/flt/fltError.cxx
deleted file mode 100644
index b0b58ea6..00000000
--- a/pandatool/src/flt/fltError.cxx
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltError.cxx
- * @author drose
- * @date 2000-08-24
- */
-
-#include "fltError.h"
-
-std::ostream &
-operator << (std::ostream &out, FltError error) {
- switch (error) {
- case FE_ok:
- return out << "no error";
-
- case FE_could_not_open:
- return out << "could not open file";
-
- case FE_empty_file:
- return out << "empty file";
-
- case FE_end_of_file:
- return out << "unexpected end of file";
-
- case FE_read_error:
- return out << "read error on file";
-
- case FE_invalid_record:
- return out << "invalid record";
-
- case FE_extra_data:
- return out << "extra data at end of file";
-
- case FE_write_error:
- return out << "write error on file";
-
- case FE_bad_data:
- return out << "bad data";
-
- case FE_not_implemented:
- return out << "not implemented";
-
- case FE_internal:
- return out << "internal error";
-
- default:
- return out << "unknown error " << (int)error;
- }
-}
diff --git a/pandatool/src/flt/fltError.h b/pandatool/src/flt/fltError.h
deleted file mode 100644
index 29c44538..00000000
--- a/pandatool/src/flt/fltError.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltError.h
- * @author drose
- * @date 2000-08-24
- */
-
-#ifndef FLTERROR_H
-#define FLTERROR_H
-
-#include "pandatoolbase.h"
-
-// Return values for various functions in the flt library.
-enum FltError {
- FE_ok = 0,
- FE_could_not_open,
- FE_empty_file,
- FE_end_of_file,
- FE_read_error,
- FE_invalid_record,
- FE_extra_data,
- FE_write_error,
- FE_bad_data,
- FE_not_implemented,
- FE_undefined_instance,
- FE_internal
-};
-
-std::ostream &operator << (std::ostream &out, FltError error);
-
-#endif
diff --git a/pandatool/src/flt/fltExternalReference.cxx b/pandatool/src/flt/fltExternalReference.cxx
deleted file mode 100644
index fa6aaa05..00000000
--- a/pandatool/src/flt/fltExternalReference.cxx
+++ /dev/null
@@ -1,136 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltExternalReference.cxx
- * @author drose
- * @date 2000-08-30
- */
-
-#include "fltExternalReference.h"
-#include "fltRecordReader.h"
-#include "fltRecordWriter.h"
-#include "fltHeader.h"
-#include "pathReplace.h"
-
-TypeHandle FltExternalReference::_type_handle;
-
-/**
- *
- */
-FltExternalReference::
-FltExternalReference(FltHeader *header) : FltBead(header) {
- _flags = 0;
-}
-
-/**
- * Walks the hierarchy at this record and below and copies the
- * _converted_filename record into the _orig_filename record, so the flt file
- * will be written out with the converted filename instead of what was
- * originally read in.
- */
-void FltExternalReference::
-apply_converted_filenames() {
- _orig_filename = _converted_filename.to_os_generic();
- FltBead::apply_converted_filenames();
-}
-
-/**
- * Writes a quick one-line description of the record, but not its children.
- * This is a human-readable description, primarily for debugging; to write a
- * flt file, use FltHeader::write_flt().
- */
-void FltExternalReference::
-output(std::ostream &out) const {
- out << "External " << get_ref_filename();
- if (!_bead_id.empty()) {
- out << " (" << _bead_id << ")";
- }
-}
-
-/**
- * Returns the name of the referenced file.
- */
-Filename FltExternalReference::
-get_ref_filename() const {
- return _converted_filename;
-}
-
-/**
- * Changes the name of the referenced file.
- */
-void FltExternalReference::
-set_ref_filename(const Filename &filename) {
- _converted_filename = filename;
- _orig_filename = _converted_filename.to_os_generic();
-}
-
-/**
- * Fills in the information in this bead based on the information given in the
- * indicated datagram, whose opcode has already been read. Returns true on
- * success, false if the datagram is invalid.
- */
-bool FltExternalReference::
-extract_record(FltRecordReader &reader) {
- if (!FltBead::extract_record(reader)) {
- return false;
- }
-
- nassertr(reader.get_opcode() == FO_external_ref, false);
- DatagramIterator &iterator = reader.get_iterator();
-
- std::string name = iterator.get_fixed_string(200);
- iterator.skip_bytes(1 + 1);
- iterator.skip_bytes(2); // Undocumented additional padding.
- _flags = iterator.get_be_uint32();
- iterator.skip_bytes(2);
- iterator.skip_bytes(2); // Undocumented additional padding.
-
- _orig_filename = name;
-
- if (!name.empty() && name[name.length() - 1] == '>') {
- // Extract out the bead name.
- size_t open = name.rfind('<');
- if (open != std::string::npos) {
- _orig_filename = name.substr(0, open);
- _bead_id = name.substr(open + 1, name.length() - open - 2);
- }
- }
- _converted_filename = _header->convert_path(Filename::from_os_specific(_orig_filename));
-
- check_remaining_size(iterator);
- return true;
-}
-
-/**
- * Fills up the current record on the FltRecordWriter with data for this
- * record, but does not advance the writer. Returns true on success, false if
- * there is some error.
- */
-bool FltExternalReference::
-build_record(FltRecordWriter &writer) const {
- if (!FltBead::build_record(writer)) {
- return false;
- }
-
- writer.set_opcode(FO_external_ref);
- Datagram &datagram = writer.update_datagram();
-
- std::string name = _orig_filename;
- if (!_bead_id.empty()) {
- name += "<" + _bead_id + ">";
- }
-
- datagram.add_fixed_string(name.substr(0, 199), 200);
- datagram.pad_bytes(1 + 1);
- datagram.pad_bytes(2); // Undocumented additional padding.
- datagram.add_be_uint32(_flags);
- datagram.pad_bytes(2);
- datagram.pad_bytes(2); // Undocumented additional padding.
-
- return true;
-}
diff --git a/pandatool/src/flt/fltExternalReference.h b/pandatool/src/flt/fltExternalReference.h
deleted file mode 100644
index 03cac968..00000000
--- a/pandatool/src/flt/fltExternalReference.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltExternalReference.h
- * @author drose
- * @date 2000-08-30
- */
-
-#ifndef FLTEXTERNALREFERENCE_H
-#define FLTEXTERNALREFERENCE_H
-
-#include "pandatoolbase.h"
-
-#include "fltBead.h"
-
-#include "filename.h"
-
-/**
- * An external reference to another flt file (possibly to a specific bead
- * within the flt file).
- */
-class FltExternalReference : public FltBead {
-public:
- FltExternalReference(FltHeader *header);
-
- virtual void apply_converted_filenames();
- virtual void output(std::ostream &out) const;
-
- enum Flags {
- F_color_palette_override = 0x80000000,
- F_material_palette_override = 0x40000000,
- F_texture_palette_override = 0x20000000,
- F_line_style_palette_override = 0x10000000,
- F_sound_palette_override = 0x08000000,
- F_light_palette_override = 0x04000000
- };
-
- std::string _orig_filename;
- Filename _converted_filename;
- std::string _bead_id;
- int _flags;
-
- Filename get_ref_filename() const;
- void set_ref_filename(const Filename &filename);
-
-protected:
- virtual bool extract_record(FltRecordReader &reader);
- virtual bool build_record(FltRecordWriter &writer) const;
-
-public:
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- FltBead::init_type();
- register_type(_type_handle, "FltExternalReference",
- FltBead::get_class_type());
- }
-
-private:
- static TypeHandle _type_handle;
-};
-
-#endif
diff --git a/pandatool/src/flt/fltEyepoint.cxx b/pandatool/src/flt/fltEyepoint.cxx
deleted file mode 100644
index 068fc4ee..00000000
--- a/pandatool/src/flt/fltEyepoint.cxx
+++ /dev/null
@@ -1,135 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltEyepoint.cxx
- * @author drose
- * @date 2000-08-26
- */
-
-#include "fltEyepoint.h"
-#include "fltRecordReader.h"
-#include "fltRecordWriter.h"
-
-/**
- *
- */
-FltEyepoint::
-FltEyepoint() {
- _rotation_center.set(0.0, 0.0, 0.0);
- _hpr.set(0.0, 0.0, 0.0);
- _rotation = LMatrix4::ident_mat();
- _fov = 60.0;
- _scale = 1.0;
- _near_clip = 0.1;
- _far_clip = 10000.0;
- _fly_through = LMatrix4::ident_mat();
- _eyepoint.set(0.0, 0.0, 0.0);
- _fly_through_yaw = 0.0;
- _fly_through_pitch = 0.0;
- _eyepoint_direction.set(0.0, 1.0, 0.0);
- _no_fly_through = true;
- _ortho_mode = false;
- _is_valid = true;
- _image_offset_x = 0;
- _image_offset_y = 0;
- _image_zoom = 1;
-}
-
-/**
- *
- */
-bool FltEyepoint::
-extract_record(FltRecordReader &reader) {
- DatagramIterator &iterator = reader.get_iterator();
-
- _rotation_center[0] = iterator.get_be_float64();
- _rotation_center[1] = iterator.get_be_float64();
- _rotation_center[2] = iterator.get_be_float64();
- _hpr[0] = iterator.get_be_float32();
- _hpr[1] = iterator.get_be_float32();
- _hpr[2] = iterator.get_be_float32();
- int r;
- for (r = 0; r < 4; r++) {
- for (int c = 0; c < 4; c++) {
- _rotation(r, c) = iterator.get_be_float32();
- }
- }
- _fov = iterator.get_be_float32();
- _scale = iterator.get_be_float32();
- _near_clip = iterator.get_be_float32();
- _far_clip = iterator.get_be_float32();
- for (r = 0; r < 4; r++) {
- for (int c = 0; c < 4; c++) {
- _fly_through(r, c) = iterator.get_be_float32();
- }
- }
- _eyepoint[0] = iterator.get_be_float32();
- _eyepoint[1] = iterator.get_be_float32();
- _eyepoint[2] = iterator.get_be_float32();
- _fly_through_yaw = iterator.get_be_float32();
- _fly_through_pitch = iterator.get_be_float32();
- _eyepoint_direction[0] = iterator.get_be_float32();
- _eyepoint_direction[1] = iterator.get_be_float32();
- _eyepoint_direction[2] = iterator.get_be_float32();
- _no_fly_through = (iterator.get_be_int32() != 0);
- _ortho_mode = (iterator.get_be_int32() != 0);
- _is_valid = (iterator.get_be_int32() != 0);
- _image_offset_x = iterator.get_be_int32();
- _image_offset_y = iterator.get_be_int32();
- _image_zoom = iterator.get_be_int32();
- iterator.skip_bytes(4*9);
-
- return true;
-}
-
-/**
- *
- */
-bool FltEyepoint::
-build_record(FltRecordWriter &writer) const {
- Datagram &datagram = writer.update_datagram();
-
- datagram.add_be_float64(_rotation_center[0]);
- datagram.add_be_float64(_rotation_center[1]);
- datagram.add_be_float64(_rotation_center[2]);
- datagram.add_be_float32(_hpr[0]);
- datagram.add_be_float32(_hpr[1]);
- datagram.add_be_float32(_hpr[2]);
- int r;
- for (r = 0; r < 4; r++) {
- for (int c = 0; c < 4; c++) {
- datagram.add_be_float32(_rotation(r, c));
- }
- }
- datagram.add_be_float32(_fov);
- datagram.add_be_float32(_scale);
- datagram.add_be_float32(_near_clip);
- datagram.add_be_float32(_far_clip);
- for (r = 0; r < 4; r++) {
- for (int c = 0; c < 4; c++) {
- datagram.add_be_float32(_fly_through(r, c));
- }
- }
- datagram.add_be_float32(_eyepoint[0]);
- datagram.add_be_float32(_eyepoint[1]);
- datagram.add_be_float32(_eyepoint[2]);
- datagram.add_be_float32(_fly_through_yaw);
- datagram.add_be_float32(_fly_through_pitch);
- datagram.add_be_float32(_eyepoint_direction[0]);
- datagram.add_be_float32(_eyepoint_direction[1]);
- datagram.add_be_float32(_eyepoint_direction[2]);
- datagram.add_be_int32(_no_fly_through);
- datagram.add_be_int32(_ortho_mode);
- datagram.add_be_int32(_is_valid);
- datagram.add_be_int32(_image_offset_x);
- datagram.add_be_int32(_image_offset_y);
- datagram.add_be_int32(_image_zoom);
- datagram.pad_bytes(4*9);
-
- return true;
-}
diff --git a/pandatool/src/flt/fltEyepoint.h b/pandatool/src/flt/fltEyepoint.h
deleted file mode 100644
index bef59fee..00000000
--- a/pandatool/src/flt/fltEyepoint.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltEyepoint.h
- * @author drose
- * @date 2000-08-26
- */
-
-#ifndef FLTEYEPOINT_H
-#define FLTEYEPOINT_H
-
-#include "pandatoolbase.h"
-
-#include "luse.h"
-
-class FltRecordReader;
-class FltRecordWriter;
-
-/**
- * A single eyepoint entry in the eyepoint/trackplane palette.
- */
-class FltEyepoint {
-public:
- FltEyepoint();
-
- bool extract_record(FltRecordReader &reader);
- bool build_record(FltRecordWriter &writer) const;
-
-public:
- LPoint3d _rotation_center;
- LVecBase3 _hpr;
- LMatrix4 _rotation;
- PN_stdfloat _fov;
- PN_stdfloat _scale;
- PN_stdfloat _near_clip;
- PN_stdfloat _far_clip;
- LMatrix4 _fly_through;
- LPoint3 _eyepoint;
- PN_stdfloat _fly_through_yaw;
- PN_stdfloat _fly_through_pitch;
- LVector3 _eyepoint_direction;
- bool _no_fly_through;
- bool _ortho_mode;
- bool _is_valid;
- int _image_offset_x;
- int _image_offset_y;
- int _image_zoom;
-};
-
-#endif
diff --git a/pandatool/src/flt/fltFace.I b/pandatool/src/flt/fltFace.I
deleted file mode 100644
index 934927d7..00000000
--- a/pandatool/src/flt/fltFace.I
+++ /dev/null
@@ -1,12 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltFace.I
- * @author drose
- * @date 2000-08-30
- */
diff --git a/pandatool/src/flt/fltFace.cxx b/pandatool/src/flt/fltFace.cxx
deleted file mode 100644
index 8770d3b6..00000000
--- a/pandatool/src/flt/fltFace.cxx
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltFace.cxx
- * @author drose
- * @date 2000-08-25
- */
-
-#include "fltFace.h"
-#include "fltRecordReader.h"
-#include "fltRecordWriter.h"
-#include "fltHeader.h"
-#include "fltMaterial.h"
-
-TypeHandle FltFace::_type_handle;
-
-/**
- *
- */
-FltFace::
-FltFace(FltHeader *header) : FltGeometry(header) {
-}
-
-/**
- * Fills in the information in this bead based on the information given in the
- * indicated datagram, whose opcode has already been read. Returns true on
- * success, false if the datagram is invalid.
- */
-bool FltFace::
-extract_record(FltRecordReader &reader) {
- if (!FltBeadID::extract_record(reader)) {
- return false;
- }
- if (!FltGeometry::extract_record(reader)) {
- return false;
- }
-
- nassertr(reader.get_opcode() == FO_face, false);
-
- DatagramIterator &iterator = reader.get_iterator();
- check_remaining_size(iterator);
- return true;
-}
-
-/**
- * Fills up the current record on the FltRecordWriter with data for this
- * record, but does not advance the writer. Returns true on success, false if
- * there is some error.
- */
-bool FltFace::
-build_record(FltRecordWriter &writer) const {
- if (!FltBeadID::build_record(writer)) {
- return false;
- }
- if (!FltGeometry::build_record(writer)) {
- return false;
- }
-
- writer.set_opcode(FO_face);
-
- return true;
-}
diff --git a/pandatool/src/flt/fltFace.h b/pandatool/src/flt/fltFace.h
deleted file mode 100644
index 404a4966..00000000
--- a/pandatool/src/flt/fltFace.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltFace.h
- * @author drose
- * @date 2000-08-25
- */
-
-#ifndef FLTFACE_H
-#define FLTFACE_H
-
-#include "pandatoolbase.h"
-
-#include "fltGeometry.h"
-
-/**
- * A single face bead, e.g. a polygon.
- */
-class FltFace : public FltGeometry {
-public:
- FltFace(FltHeader *header);
-
-
-protected:
- virtual bool extract_record(FltRecordReader &reader);
- virtual bool build_record(FltRecordWriter &writer) const;
-
-public:
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- FltGeometry::init_type();
- register_type(_type_handle, "FltFace",
- FltGeometry::get_class_type());
- }
-
-private:
- static TypeHandle _type_handle;
-};
-
-#include "fltFace.I"
-
-#endif
diff --git a/pandatool/src/flt/fltGeometry.I b/pandatool/src/flt/fltGeometry.I
deleted file mode 100644
index c584c520..00000000
--- a/pandatool/src/flt/fltGeometry.I
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltGeometry.I
- * @author drose
- * @date 2001-02-28
- */
-
-/**
- * Returns true if the face has a texture applied, false otherwise.
- */
-INLINE bool FltGeometry::
-has_texture() const {
- return (_texture_index >= 0 && _header->has_texture(_texture_index));
-}
-
-/**
- * Returns the texture applied to this face, or NULL if no texture was
- * applied.
- */
-INLINE FltTexture *FltGeometry::
-get_texture() const {
- return _header->get_texture(_texture_index);
-}
-
-/**
- * Applies the indicated texture to this face, or if the texture is NULL,
- * clears it.
- */
-INLINE void FltGeometry::
-set_texture(FltTexture *texture) {
- if (texture == nullptr) {
- _texture_index = -1;
- } else {
- _header->add_texture(texture);
- _texture_index = texture->_pattern_index;
- }
-}
-
-/**
- * Returns true if the face has a material applied, false otherwise.
- */
-INLINE bool FltGeometry::
-has_material() const {
- return (_material_index >= 0 && _header->has_material(_material_index));
-}
-
-/**
- * Returns the material applied to this face, or NULL if no material was
- * applied.
- */
-INLINE FltMaterial *FltGeometry::
-get_material() const {
- return _header->get_material(_material_index);
-}
-
-/**
- * Applies the indicated material to this face, or if the material is NULL,
- * clears it.
- */
-INLINE void FltGeometry::
-set_material(FltMaterial *material) {
- if (material == nullptr) {
- _material_index = -1;
- } else {
- _header->add_material(material);
- _material_index = material->_material_index;
- }
-}
-
-/**
- * Returns true if the face has a primary color indicated, false otherwise.
- */
-INLINE bool FltGeometry::
-has_color() const {
- // Even if the no_color bit is not set, if the color_index is -1, the face
- // doesn't have a color (unless we've got packed color). On the other hand,
- // if we have a material than we always have color.
- return ((_flags & F_no_color) == 0 &&
- (_color_index != -1 || ((_flags & F_packed_color) != 0)))
- || has_material();
-}
diff --git a/pandatool/src/flt/fltGeometry.cxx b/pandatool/src/flt/fltGeometry.cxx
deleted file mode 100644
index 25820487..00000000
--- a/pandatool/src/flt/fltGeometry.cxx
+++ /dev/null
@@ -1,262 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltGeometry.cxx
- * @author drose
- * @date 2001-02-28
- */
-
-#include "fltGeometry.h"
-#include "fltRecordReader.h"
-#include "fltRecordWriter.h"
-#include "fltHeader.h"
-#include "fltMaterial.h"
-
-TypeHandle FltGeometry::_type_handle;
-
-/**
- *
- */
-FltGeometry::
-FltGeometry(FltHeader *header) : FltBeadID(header) {
- _ir_color = 0;
- _relative_priority = 0;
- _draw_type = DT_solid_cull_backface;
- _texwhite = false;
- _color_name_index = 0;
- _alt_color_name_index = 0;
- _billboard_type = BT_none;
- _detail_texture_index = -1;
- _texture_index = -1;
- _material_index = -1;
- _dfad_material_code = 0;
- _dfad_feature_id = 0;
- _ir_material_code = 0;
- _transparency = 0;
- _lod_generation_control = 0;
- _line_style_index = 0;
- _flags = F_no_color;
- _light_mode = LM_face_no_normal;
- _texture_mapping_index = 0;
- _color_index = 0;
- _alt_color_index = 0;
-}
-
-
-/**
- * Returns the primary color of the face, as a four-component value (including
- * alpha as the transparency channel).
- *
- * If has_color() is false, the result is white, but still reflects the
- * transparency correctly.
- */
-LColor FltGeometry::
-get_color() const {
- LColor color;
-
- if (!has_color() || (_texwhite && has_texture())) {
- // Force this one white.
- color.set(1.0, 1.0, 1.0, 1.0);
-
- } else if (has_material()) {
- // If we have a material, that replaces the color.
- FltMaterial *material = get_material();
- color.set(material->_diffuse[0],
- material->_diffuse[1],
- material->_diffuse[2],
- material->_alpha);
- } else {
- LRGBColor rgb =
- _header->get_rgb(_color_index, (_flags & F_packed_color) != 0,
- _packed_color);
- color.set(rgb[0], rgb[1], rgb[2], 1.0);
- }
-
- // Modify the whole thing by our transparency.
- PN_stdfloat alpha = 1.0 - (_transparency / 65535.0);
- color[3] *= alpha;
-
- return color;
-}
-
-/**
- * Sets the primary color of the face, using the packed color convention.
- */
-void FltGeometry::
-set_color(const LColor &color) {
- set_rgb(LRGBColor(color[0], color[1], color[2]));
- _transparency = (int)floor((1.0 - color[3]) * 65535.0);
-}
-
-/**
- * Returns the primary color of the face, as a three-component value ignoring
- * transparency.
- */
-LRGBColor FltGeometry::
-get_rgb() const {
- if (!has_color() || (_texwhite && has_texture())) {
- // Force this one white.
- return LRGBColor(1.0, 1.0, 1.0);
- }
-
- if (has_material()) {
- // If we have a material, that replaces the color.
- FltMaterial *material = get_material();
- return material->_diffuse;
- }
-
- return _header->get_rgb(_color_index, (_flags & F_packed_color) != 0,
- _packed_color);
-}
-
-/**
- * Sets the primary color of the face, using the packed color convention; does
- * not affect transparency.
- */
-void FltGeometry::
-set_rgb(const LRGBColor &rgb) {
- _packed_color.set_rgb(rgb);
- _flags = ((_flags & ~F_no_color) | F_packed_color);
-
- // If we have a color, we can't have a material.
- _material_index = -1;
- _texwhite = false;
-}
-
-/**
- * Returns true if the face has an alternate color indicated, false otherwise.
- */
-bool FltGeometry::
-has_alt_color() const {
- return (_flags & F_no_alt_color) == 0;
-}
-
-/**
- * If has_alt_color() indicates true, returns the alternate color of the face,
- * as a four-component value (including alpha as the transparency channel).
- */
-LColor FltGeometry::
-get_alt_color() const {
- nassertr(has_alt_color(), LColor(0.0, 0.0, 0.0, 0.0));
-
- return _header->get_color(_alt_color_index, (_flags & F_packed_color) != 0,
- _alt_packed_color, _transparency);
-}
-
-/**
- * If has_alt_color() indicates true, returns the alternate color of the face,
- * as a three-component value ignoring transparency.
- */
-LRGBColor FltGeometry::
-get_alt_rgb() const {
- nassertr(has_alt_color(), LRGBColor(0.0, 0.0, 0.0));
-
- return _header->get_rgb(_alt_color_index, (_flags & F_packed_color) != 0,
- _alt_packed_color);
-}
-
-/**
- * Fills in the information in this bead based on the information given in the
- * indicated datagram, whose opcode has already been read. Returns true on
- * success, false if the datagram is invalid.
- */
-bool FltGeometry::
-extract_record(FltRecordReader &reader) {
- DatagramIterator &iterator = reader.get_iterator();
-
- _ir_color = iterator.get_be_int32();
- _relative_priority = iterator.get_be_int16();
- _draw_type = (DrawType)iterator.get_int8();
- _texwhite = (iterator.get_int8() != 0);
- _color_name_index = iterator.get_be_int16();
- _alt_color_name_index = iterator.get_be_int16();
- iterator.skip_bytes(1);
- _billboard_type = (BillboardType)iterator.get_int8();
- _detail_texture_index = iterator.get_be_int16();
- _texture_index = iterator.get_be_int16();
- _material_index = iterator.get_be_int16();
- _dfad_material_code = iterator.get_be_int16();
- _dfad_feature_id = iterator.get_be_int16();
- _ir_material_code = iterator.get_be_int32();
- _transparency = iterator.get_be_uint16();
- _lod_generation_control = iterator.get_uint8();
- _line_style_index = iterator.get_uint8();
- if (_header->get_flt_version() >= 1420) {
- _flags = iterator.get_be_uint32();
- _light_mode = (LightMode)iterator.get_uint8();
- iterator.skip_bytes(1 + 4);
- iterator.skip_bytes(2); // Undocumented padding.
-
- if (!_packed_color.extract_record(reader)) {
- return false;
- }
- if (!_alt_packed_color.extract_record(reader)) {
- return false;
- }
-
- if (_header->get_flt_version() >= 1520) {
- _texture_mapping_index = iterator.get_be_int16();
- iterator.skip_bytes(2);
- _color_index = iterator.get_be_int32();
- _alt_color_index = iterator.get_be_int32();
- iterator.skip_bytes(2 + 2);
- }
- }
-
- return true;
-}
-
-/**
- * Fills up the current record on the FltRecordWriter with data for this
- * record, but does not advance the writer. Returns true on success, false if
- * there is some error.
- */
-bool FltGeometry::
-build_record(FltRecordWriter &writer) const {
- Datagram &datagram = writer.update_datagram();
-
- datagram.add_be_int32(_ir_color);
- datagram.add_be_int16(_relative_priority);
- datagram.add_int8(_draw_type);
- datagram.add_int8(_texwhite);
- datagram.add_be_uint16(_color_name_index);
- datagram.add_be_uint16(_alt_color_name_index);
- datagram.pad_bytes(1);
- datagram.add_int8(_billboard_type);
- datagram.add_be_int16(_detail_texture_index);
- datagram.add_be_int16(_texture_index);
- datagram.add_be_int16(_material_index);
- datagram.add_be_int16(_dfad_material_code);
- datagram.add_be_int16(_dfad_feature_id);
- datagram.add_be_int32(_ir_material_code);
- datagram.add_be_uint16(_transparency);
- datagram.add_uint8(_lod_generation_control);
- datagram.add_uint8(_line_style_index);
- datagram.add_be_uint32(_flags);
- datagram.add_uint8(_light_mode);
- datagram.pad_bytes(1 + 4);
- datagram.pad_bytes(2); // Undocumented padding.
-
- if (!_packed_color.build_record(writer)) {
- return false;
- }
- if (!_alt_packed_color.build_record(writer)) {
- return false;
- }
-
- if (_header->get_flt_version() >= 1520) {
- // New with 15.2
- datagram.add_be_int16(_texture_mapping_index);
- datagram.pad_bytes(2);
- datagram.add_be_int32(_color_index);
- datagram.add_be_int32(_alt_color_index);
- datagram.pad_bytes(2 + 2);
- }
-
- return true;
-}
diff --git a/pandatool/src/flt/fltGeometry.h b/pandatool/src/flt/fltGeometry.h
deleted file mode 100644
index f8041f10..00000000
--- a/pandatool/src/flt/fltGeometry.h
+++ /dev/null
@@ -1,139 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltGeometry.h
- * @author drose
- * @date 2001-02-28
- */
-
-#ifndef FLTGEOMETRY_H
-#define FLTGEOMETRY_H
-
-#include "pandatoolbase.h"
-
-#include "fltBeadID.h"
-#include "fltPackedColor.h"
-#include "fltHeader.h"
-
-#include "luse.h"
-
-class FltTexture;
-class FltMaterial;
-
-/**
- * This is a base class for both FltFace and FltMesh, which are two different
- * kinds of geometric primitives that might be encountered in a MultiGen file.
- * They have similar properties.
- */
-class FltGeometry : public FltBeadID {
-public:
- FltGeometry(FltHeader *header);
-
- enum DrawType {
- DT_solid_cull_backface = 0,
- DT_solid_no_cull = 1,
- DT_wireframe = 2,
- DT_wireframe_close = 3,
- DT_wireframe_highlight = 4,
- DT_omni_light = 8,
- DT_uni_light = 9,
- DT_bi_light = 10
- };
-
- enum BillboardType {
- BT_none = 0,
- BT_fixed = 1,
- BT_axial = 2,
- BT_point = 4
- };
-
- enum Flags {
- F_terrain = 0x80000000,
- F_no_color = 0x40000000,
- F_no_alt_color = 0x20000000,
- F_packed_color = 0x10000000,
- F_terrain_footprint = 0x08000000,
- F_hidden = 0x04000000
- };
-
- enum LightMode {
- LM_face_no_normal = 0,
- LM_vertex_no_normal = 1,
- LM_face_with_normal = 2,
- LM_vertex_with_normal = 3
- };
-
- int _ir_color;
- int _relative_priority;
- DrawType _draw_type;
- bool _texwhite;
- int _color_name_index;
- int _alt_color_name_index;
- BillboardType _billboard_type;
- int _detail_texture_index;
- int _texture_index;
- int _material_index;
- int _dfad_material_code;
- int _dfad_feature_id;
- int _ir_material_code;
- int _transparency;
- int _lod_generation_control;
- int _line_style_index;
- unsigned int _flags;
- LightMode _light_mode;
- FltPackedColor _packed_color;
- FltPackedColor _alt_packed_color;
- int _texture_mapping_index;
- int _color_index;
- int _alt_color_index;
-
-public:
- INLINE bool has_texture() const;
- INLINE FltTexture *get_texture() const;
- INLINE void set_texture(FltTexture *texture);
-
- INLINE bool has_material() const;
- INLINE FltMaterial *get_material() const;
- INLINE void set_material(FltMaterial *material);
-
- INLINE bool has_color() const;
- LColor get_color() const;
- void set_color(const LColor &color);
- LRGBColor get_rgb() const;
- void set_rgb(const LRGBColor &rgb);
-
- bool has_alt_color() const;
- LColor get_alt_color() const;
- LRGBColor get_alt_rgb() const;
-
-
-protected:
- virtual bool extract_record(FltRecordReader &reader);
- virtual bool build_record(FltRecordWriter &writer) const;
-
-public:
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- FltBeadID::init_type();
- register_type(_type_handle, "FltGeometry",
- FltBeadID::get_class_type());
- }
-
-private:
- static TypeHandle _type_handle;
-};
-
-#include "fltGeometry.I"
-
-#endif
diff --git a/pandatool/src/flt/fltGroup.cxx b/pandatool/src/flt/fltGroup.cxx
deleted file mode 100644
index c194769f..00000000
--- a/pandatool/src/flt/fltGroup.cxx
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltGroup.cxx
- * @author drose
- * @date 2000-08-24
- */
-
-#include "fltGroup.h"
-#include "fltRecordReader.h"
-#include "fltRecordWriter.h"
-#include "fltHeader.h"
-
-TypeHandle FltGroup::_type_handle;
-
-/**
- *
- */
-FltGroup::
-FltGroup(FltHeader *header) : FltBeadID(header) {
- _relative_priority = 0;
- _flags = 0;
- _special_id1 = 0;
- _special_id2 = 0;
- _significance = 0;
- _layer_id = 0;
-}
-
-/**
- * Fills in the information in this bead based on the information given in the
- * indicated datagram, whose opcode has already been read. Returns true on
- * success, false if the datagram is invalid.
- */
-bool FltGroup::
-extract_record(FltRecordReader &reader) {
- if (!FltBeadID::extract_record(reader)) {
- return false;
- }
-
- nassertr(reader.get_opcode() == FO_group, false);
- DatagramIterator &iterator = reader.get_iterator();
-
- _relative_priority = iterator.get_be_int16();
- iterator.skip_bytes(2);
- _flags = iterator.get_be_uint32();
- _special_id1 = iterator.get_be_int16();
- _special_id2 = iterator.get_be_int16();
- _significance = iterator.get_be_int16();
- _layer_id = iterator.get_int8();
- iterator.skip_bytes(1);
- if (_header->get_flt_version() >= 1420) {
- iterator.skip_bytes(4);
- }
-
- check_remaining_size(iterator);
- return true;
-}
-
-/**
- * Fills up the current record on the FltRecordWriter with data for this
- * record, but does not advance the writer. Returns true on success, false if
- * there is some error.
- */
-bool FltGroup::
-build_record(FltRecordWriter &writer) const {
- if (!FltBeadID::build_record(writer)) {
- return false;
- }
-
- writer.set_opcode(FO_group);
- Datagram &datagram = writer.update_datagram();
-
- datagram.add_be_int16(_relative_priority);
- datagram.pad_bytes(2);
- datagram.add_be_uint32(_flags);
- datagram.add_be_int16(_special_id1);
- datagram.add_be_int16(_special_id2);
- datagram.add_be_int16(_significance);
- datagram.add_int8(_layer_id);
- datagram.pad_bytes(5);
-
- return true;
-}
diff --git a/pandatool/src/flt/fltGroup.h b/pandatool/src/flt/fltGroup.h
deleted file mode 100644
index c1f38198..00000000
--- a/pandatool/src/flt/fltGroup.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltGroup.h
- * @author drose
- * @date 2000-08-24
- */
-
-#ifndef FLTGROUP_H
-#define FLTGROUP_H
-
-#include "pandatoolbase.h"
-
-#include "fltBeadID.h"
-
-/**
- * The main grouping bead of the flt file.
- */
-class FltGroup : public FltBeadID {
-public:
- FltGroup(FltHeader *header);
-
- enum Flags {
- F_forward_animation = 0x40000000,
- F_swing_animation = 0x20000000,
- F_bounding_box = 0x10000000,
- F_freeze_bounding_box = 0x08000000,
- F_default_parent = 0x04000000,
- };
-
- int _relative_priority;
- unsigned int _flags;
- int _special_id1, _special_id2;
- int _significance;
- int _layer_id;
-
-protected:
- virtual bool extract_record(FltRecordReader &reader);
- virtual bool build_record(FltRecordWriter &writer) const;
-
-public:
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- FltBeadID::init_type();
- register_type(_type_handle, "FltGroup",
- FltBeadID::get_class_type());
- }
-
-private:
- static TypeHandle _type_handle;
-};
-
-#endif
diff --git a/pandatool/src/flt/fltHeader.cxx b/pandatool/src/flt/fltHeader.cxx
deleted file mode 100644
index a0874863..00000000
--- a/pandatool/src/flt/fltHeader.cxx
+++ /dev/null
@@ -1,1703 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltHeader.cxx
- * @author drose
- * @date 2000-08-24
- */
-
-#include "fltHeader.h"
-#include "fltRecordReader.h"
-#include "fltRecordWriter.h"
-#include "fltUnsupportedRecord.h"
-#include "config_flt.h"
-#include "zStream.h"
-#include "nearly_zero.h"
-#include "virtualFileSystem.h"
-
-#include
-#include
-
-TypeHandle FltHeader::_type_handle;
-
-/**
- * The FltHeader constructor accepts a PathReplace pointer; it uses this
- * object to automatically convert all external filename and texture
- * references. (This is necessary because the FltHeader has to look in the
- * same directory as the texture to find the .attr file, so it must pre-
- * convert at least the texture references.)
- *
- * Most of the other file converters do not have this requirement, so they do
- * not need to pre-convert any pathname references.
- */
-FltHeader::
-FltHeader(PathReplace *path_replace) : FltBeadID(this) {
- if (path_replace == nullptr) {
- _path_replace = new PathReplace;
- _path_replace->_path_store = PS_absolute;
- } else {
- _path_replace = path_replace;
- }
-
- _format_revision_level = 1570;
- _edit_revision_level = 1570;
- _next_group_id = 1;
- _next_lod_id = 1;
- _next_object_id = 1;
- _next_face_id = 1;
- _unit_multiplier = 1;
- _vertex_units = U_feet;
- _texwhite_new = false;
- _flags = 0;
- _projection_type = PT_flat_earth;
- _next_dof_id = 1;
- _vertex_storage_type = VTS_double;
- _database_origin = DO_open_flight;
- _sw_x = 0.0;
- _sw_y = 0.0;
- _delta_x = 0.0;
- _delta_y = 0.0;
- _next_sound_id = 1;
- _next_path_id = 1;
- _next_clip_id = 1;
- _next_text_id = 1;
- _next_bsp_id = 1;
- _next_switch_id = 1;
- _sw_lat = 0.0;
- _sw_long = 0.0;
- _ne_lat = 0.0;
- _ne_long = 0.0;
- _origin_lat = 0.0;
- _origin_long = 0.0;
- _lambert_upper_lat = 0.0;
- _lambert_lower_lat = 0.0;
- _next_light_id = 1;
- _next_road_id = 1;
- _next_cat_id = 1;
-
- // New with 15.2
- _earth_model = EM_wgs84;
-
- // New with 15.6
- _next_adaptive_id = 0;
- _next_curve_id = 0;
-
- // New with 15.7
- _delta_z = 0.0;
- _radius = 0.0;
- _next_mesh_id = 0;
-
- _vertex_lookups_stale = false;
- _current_vertex_offset = 0;
- _next_material_index = 1;
- _next_pattern_index = 1;
- _got_color_palette = false;
- _got_14_material_palette = false;
- _got_eyepoint_trackplane_palette = false;
-
- _auto_attr_update = AU_if_missing;
-}
-
-/**
- * Walks the hierarchy at this record and below and copies the
- * _converted_filename record into the _orig_filename record, so the flt file
- * will be written out with the converted filename instead of what was
- * originally read in.
- */
-void FltHeader::
-apply_converted_filenames() {
- Textures::const_iterator ti;
- for (ti = _textures.begin(); ti != _textures.end(); ++ti) {
- FltTexture *texture = (*ti).second;
- texture->apply_converted_filenames();
- }
-
- FltBeadID::apply_converted_filenames();
-}
-
-/**
- * Replaces the PathReplace object (which specifies how to mangle paths from
- * the source to the destination file) with a new one.
- */
-void FltHeader::
-set_path_replace(PathReplace *path_replace) {
- _path_replace = path_replace;
-}
-
-/**
- * Returns a pointer to the PathReplace object associated with this converter.
- * If the converter is non-const, this returns a non-const pointer, which can
- * be adjusted.
- */
-PathReplace *FltHeader::
-get_path_replace() {
- return _path_replace;
-}
-
-/**
- * Returns a pointer to the PathReplace object associated with this converter.
- * If the converter is non-const, this returns a non-const pointer, which can
- * be adjusted.
- */
-const PathReplace *FltHeader::
-get_path_replace() const {
- return _path_replace;
-}
-
-/**
- * Uses the PathReplace object to convert the named filename as read from the
- * flt record to its actual name.
- */
-Filename FltHeader::
-convert_path(const Filename &orig_filename, const DSearchPath &additional_path) {
- DSearchPath file_path;
- if (!_flt_filename.empty()) {
- file_path.append_directory(_flt_filename.get_dirname());
- }
- file_path.append_path(additional_path);
- return _path_replace->convert_path(orig_filename, file_path);
-}
-
-/**
- * Sets the filename--especially the directory part--in which the flt file is
- * considered to reside. This is also implicitly set by read_flt().
- */
-void FltHeader::
-set_flt_filename(const Filename &flt_filename) {
- _flt_filename = flt_filename;
-}
-
-/**
- * Returns the directory in which the flt file is considered to reside.
- */
-const Filename &FltHeader::
-get_flt_filename() const {
- return _flt_filename;
-}
-
-/**
- * Opens the indicated filename for reading and attempts to read the complete
- * Flt file. Returns FE_ok on success, otherwise on failure.
- */
-FltError FltHeader::
-read_flt(Filename filename) {
- filename.set_binary();
- _flt_filename = filename;
-
- VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr();
- std::istream *in = vfs->open_read_file(filename, true);
- if (in == nullptr) {
- assert(!flt_error_abort);
- return FE_could_not_open;
- }
- FltError result = read_flt(*in);
- vfs->close_read_file(in);
- return result;
-}
-
-/**
- * Attempts to read a complete Flt file from the already-opened stream.
- * Returns FE_ok on success, otherwise on failure.
- */
-FltError FltHeader::
-read_flt(std::istream &in) {
- FltRecordReader reader(in);
- FltError result = reader.advance();
- if (result == FE_end_of_file) {
- assert(!flt_error_abort);
- return FE_empty_file;
- } else if (result != FE_ok) {
- return result;
- }
-
- result = read_record_and_children(reader);
- if (result != FE_ok) {
- return result;
- }
-
- if (!reader.eof()) {
- assert(!flt_error_abort);
- return FE_extra_data;
- }
-
- return FE_ok;
-}
-
-
-/**
- * Opens the indicated filename for writing and attempts to write the complete
- * Flt file. Returns FE_ok on success, otherwise on failure.
- */
-FltError FltHeader::
-write_flt(Filename filename) {
- filename.set_binary();
-
- std::ofstream out;
- if (!filename.open_write(out)) {
- assert(!flt_error_abort);
- return FE_could_not_open;
- }
-
-#ifdef HAVE_ZLIB
- if (filename.get_extension() == "pz") {
- // The filename ends in .pz, which means to automatically compress the flt
- // file that we write.
- OCompressStream compressor(&out, false);
- return write_flt(compressor);
- }
-#endif // HAVE_ZLIB
-
- return write_flt(out);
-}
-
-/**
- * Attempts to write a complete Flt file to the already-opened stream.
- * Returns FE_ok on success, otherwise on failure.
- */
-FltError FltHeader::
-write_flt(std::ostream &out) {
- FltRecordWriter writer(out);
- FltError result = write_record_and_children(writer);
-
- if (out.fail()) {
- assert(!flt_error_abort);
- return FE_write_error;
- }
- return result;
-}
-
-/**
- * Controls whether texture .attr files are written automatically when
- * write_flt() is called. There are three possibilities:
- *
- * AU_none: the .attr files are not written automatically; they must be
- * written explicitly via a call to FltTexture::write_attr_data() if you want
- * them to be written.
- *
- * AU_if_missing: the .attr files are written only if they do not already
- * exist. This will not update any .attr files, even if the data is changed.
- *
- * AU_always: the .attr files are always rewritten, even if they already exist
- * and even if the data has not changed.
- *
- * The default is AU_if_missing.
- */
-void FltHeader::
-set_auto_attr_update(FltHeader::AttrUpdate attr) {
- _auto_attr_update = attr;
-}
-
-/**
- * Returns the current setting of the auto_attr_update flag. See
- * sett_auto_attr_update().
- */
-FltHeader::AttrUpdate FltHeader::
-get_auto_attr_update() const {
- return _auto_attr_update;
-}
-
-/**
- * Returns the version number of the flt file as reported in the header, times
- * 100. Divide by 100 to get the floating-point version number.
- */
-int FltHeader::
-get_flt_version() const {
- if (_format_revision_level < 1420) {
- return _format_revision_level * 100;
- } else {
- return _format_revision_level;
- }
-}
-
-/**
- * Changes the version number of the flt file that will be reported in the
- * header. Pass in the floating-point version number times 100.
- */
-void FltHeader::
-set_flt_version(int version) {
- if (version < 14.2) {
- _format_revision_level = version / 100;
- } else {
- _format_revision_level = version;
- }
-}
-
-/**
- * Returns the earliest flt version number that this codebase supports (times
- * 100). Earlier versions will probably not work.
- */
-int FltHeader::
-min_flt_version() {
- return 1400;
-}
-
-/**
- * Returns the latest flt version number that this codebase is known to
- * support (times 100). Later versions might work, but then again they may
- * not.
- */
-int FltHeader::
-max_flt_version() {
- return 1570;
-}
-
-/**
- * Verifies that the version number read from the header is an understood
- * version number, and prints a warning to the user if this is not so--the
- * read may or may not succeed. Returns true if the version number is
- * acceptable (and no warning is printed), or false if it is questionable (and
- * a warning is printed).
- */
-bool FltHeader::
-check_version() const {
- int version = get_flt_version();
-
- if (version < min_flt_version()) {
- nout << "Warning! The version number of this file appears to be "
- << version / 100.0 << ", which is older than " << min_flt_version() / 100.0
- << ", the oldest OpenFlight version understood by this program. "
- "It is unlikely that this program will be able to read the file "
- "correctly.\n";
- return false;
- }
-
- if (version > max_flt_version()) {
- nout << "Warning! The version number of this file appears to be "
- << version / 100.0 << ", which is newer than " << max_flt_version() / 100.0
- << ", the newest OpenFlight version understood by this program. "
- "Chances are good that the program will still be able to read it "
- "correctly, but any features in the file that are specific to "
- "the latest version of OpenFlight will not be understood.\n";
- return false;
- }
-
- return true;
-}
-
-/**
- * Returns the units indicated by the flt header, or DU_invalid if the units
- * in the header are not understood.
- */
-DistanceUnit FltHeader::
-get_units() const {
- switch (_vertex_units) {
- case FltHeader::U_meters:
- return DU_meters;
-
- case FltHeader::U_kilometers:
- return DU_kilometers;
-
- case FltHeader::U_feet:
- return DU_feet;
-
- case FltHeader::U_inches:
- return DU_inches;
-
- case FltHeader::U_nautical_miles:
- return DU_nautical_miles;
- }
-
- // Unknown units.
- return DU_invalid;
-}
-
-/**
- * Returns true if a instance subtree with the given index has been defined.
- */
-bool FltHeader::
-has_instance(int instance_index) const {
- return (_instances.count(instance_index) != 0);
-}
-
-/**
- * Returns the instance subtree associated with the given index, or NULL if
- * there is no such instance.
- */
-FltInstanceDefinition *FltHeader::
-get_instance(int instance_index) const {
- Instances::const_iterator mi;
- mi = _instances.find(instance_index);
- if (mi != _instances.end()) {
- return (*mi).second;
- }
- return nullptr;
-}
-
-/**
- * Removes all instance subtrees from the instance pool.
- */
-void FltHeader::
-clear_instances() {
- _instances.clear();
-}
-
-/**
- * Defines a new instance subtree. This subtree is not itself part of the
- * hierarchy; it marks geometry that may be instanced to various beads
- * elsewhere in the hierarchy by creating a corresponding FltInstanceRef bead.
- */
-void FltHeader::
-add_instance(FltInstanceDefinition *instance) {
- _instances[instance->_instance_index] = instance;
-}
-
-/**
- * Removes a particular instance subtree from the pool, if it exists.
- */
-void FltHeader::
-remove_instance(int instance_index) {
- _instances.erase(instance_index);
-}
-
-/**
- * Returns the number of vertices in the vertex palette.
- */
-int FltHeader::
-get_num_vertices() const {
- return _vertices.size();
-}
-
-/**
- * Returns the nth vertex of the vertex palette.
- */
-FltVertex *FltHeader::
-get_vertex(int n) const {
- nassertr(n >= 0 && n < (int)_vertices.size(), nullptr);
- return _vertices[n];
-}
-
-/**
- * Removes all vertices from the vertex palette.
- */
-void FltHeader::
-clear_vertices() {
- _vertices.clear();
- _unique_vertices.clear();
- _vertices_by_offset.clear();
- _offsets_by_vertex.clear();
- _vertex_lookups_stale = false;
-}
-
-/**
- * Adds a new vertex to the end of the vertex palette. If this particular
- * vertex was already present in the palette, does nothing.
- */
-void FltHeader::
-add_vertex(FltVertex *vertex) {
- bool inserted = _unique_vertices.insert(vertex).second;
- if (inserted) {
- _vertices.push_back(vertex);
- }
- _vertex_lookups_stale = true;
- nassertv(_unique_vertices.size() == _vertices.size());
-}
-
-/**
- * Returns the particular vertex pointer associated with the given byte offset
- * into the vertex palette. If there is no such vertex in the palette, this
- * generates an error message and returns NULL.
- */
-FltVertex *FltHeader::
-get_vertex_by_offset(int offset) {
- if (_vertex_lookups_stale) {
- update_vertex_lookups();
- }
-
- VerticesByOffset::const_iterator vi;
- vi = _vertices_by_offset.find(offset);
- if (vi == _vertices_by_offset.end()) {
- nout << "No vertex with offset " << offset << "\n";
- return nullptr;
- }
- return (*vi).second;
-}
-
-/**
- * Returns the byte offset into the vertex palette associated with the given
- * vertex pointer. If there is no such vertex in the palette, this generates
- * an error message and returns 0.
- */
-int FltHeader::
-get_offset_by_vertex(FltVertex *vertex) {
- if (_vertex_lookups_stale) {
- update_vertex_lookups();
- }
-
- OffsetsByVertex::const_iterator vi;
- vi = _offsets_by_vertex.find(vertex);
- if (vi == _offsets_by_vertex.end()) {
- nout << "Vertex does not appear in palette.\n";
- return 0;
- }
- return (*vi).second;
-}
-
-/**
- * Returns the total number of different colors in the color palette. This
- * includes all different colors, and represents the complete range of
- * alloable color indices. This is different from the actual number of color
- * entries as read directly from the color palette, since each color entry
- * defines a number of different intensity levels--the value returned by
- * get_num_colors() is equal to get_num_color_entries() *
- * get_num_color_shades().
- */
-int FltHeader::
-get_num_colors() const {
- return _colors.size() * get_num_color_shades();
-}
-
-/**
- * Returns the four-component color corresponding to the given color index.
- * Each component will be in the range [0, 1].
- */
-LColor FltHeader::
-get_color(int color_index) const {
- nassertr(color_index >= 0 && color_index < get_num_colors(),
- LColor(0.0, 0.0, 0.0, 0.0));
- int num_color_shades = get_num_color_shades();
-
- int index = (color_index / num_color_shades);
- int level = (color_index % num_color_shades);
- nassertr(index >= 0 && index < (int)_colors.size(),
- LColor(0.0, 0.0, 0.0, 0.0));
-
- LColor color = _colors[index].get_color();
- return color * ((double)level / (double)(num_color_shades - 1));
-}
-
-/**
- * Returns the three-component color corresponding to the given color index,
- * ignoring the alpha component. Each component will be in the range [0, 1].
- */
-LRGBColor FltHeader::
-get_rgb(int color_index) const {
- nassertr(color_index >= 0 && color_index < get_num_colors(),
- LRGBColor(0.0, 0.0, 0.0));
- int num_color_shades = get_num_color_shades();
-
- int index = (color_index / num_color_shades);
- int level = (color_index % num_color_shades);
- nassertr(index >= 0 && index < (int)_colors.size(),
- LRGBColor(0.0, 0.0, 0.0));
-
- LRGBColor color = _colors[index].get_rgb();
- return color * ((double)level / (double)(num_color_shades - 1));
-}
-
-/**
- * Returns true if the given color is named, false otherwise.
- */
-bool FltHeader::
-has_color_name(int color_index) const {
- return (_color_names.count(color_index) != 0);
-}
-
-/**
- * Returns the name associated with the given color, if any.
- */
-std::string FltHeader::
-get_color_name(int color_index) const {
- ColorNames::const_iterator ni;
- ni = _color_names.find(color_index);
- if (ni != _color_names.end()) {
- return (*ni).second;
- }
- return std::string();
-}
-
-/**
- * Returns the color index of the nearest color in the palette that matches
- * the given four-component color, including alpha.
- */
-int FltHeader::
-get_closest_color(const LColor &color0) const {
- // Since the colortable stores the brightest colors, with num_color_shades
- // scaled versions of each color implicitly available, we really only care
- // about the relative brightnesses of the various components. Normalize the
- // color in terms of the largest of these.
- LColor color = color0;
-
- double scale = 1.0;
-
- if (color[0] == 0.0 && color[1] == 0.0 && color[2] == 0.0 && color[3] == 0.0) {
- // Oh, this is invisible black.
- scale = 0.0;
- color.set(1.0, 1.0, 1.0, 1.0);
-
- } else {
- if (color[0] >= color[1] && color[0] >= color[2] && color[0] >= color[3]) {
- // color[0] is largest.
- scale = color[0];
-
- } else if (color[1] >= color[2] && color[1] >= color[3]) {
- // color[1] is largest.
- scale = color[1];
-
- } else if (color[2] >= color[3]) {
- // color[2] is largest.
- scale = color[2];
-
- } else {
- // color[3] is largest.
- scale = color[3];
- }
- color /= scale;
- }
-
- // Now search for the best match.
- PN_stdfloat best_dist = 5.0; // Greater than 4.
- int best_i = -1;
-
- int num_color_entries = get_num_color_entries();
- for (int i = 0; i < num_color_entries; i++) {
- LColor consider = _colors[i].get_color();
- PN_stdfloat dist2 = dot(consider - color, consider - color);
- nassertr(dist2 < 5.0, 0);
-
- if (dist2 < best_dist) {
- best_dist = dist2;
- best_i = i;
- }
- }
- nassertr(best_i >= 0, 0);
-
- int num_color_shades = get_num_color_shades();
- int shade_index = (int)floor((num_color_shades-1) * scale + 0.5);
-
- return (best_i * num_color_shades) + shade_index;
-}
-
-/**
- * Returns the color index of the nearest color in the palette that matches
- * the given three-component color, ignoring alpha.
- */
-int FltHeader::
-get_closest_rgb(const LRGBColor &color0) const {
- // Since the colortable stores the brightest colors, with num_color_shades
- // scaled versions of each color implicitly available, we really only care
- // about the relative brightnesses of the various components. Normalize the
- // color in terms of the largest of these.
-
- LRGBColor color = color0;
- double scale = 1.0;
-
- if (color[0] == 0.0 && color[1] == 0.0 && color[2] == 0.0) {
- // Oh, this is black.
- scale = 0.0;
- color.set(1.0, 1.0, 1.0);
-
- } else {
- if (color[0] >= color[1] && color[0] >= color[2]) {
- // color[0] is largest.
- scale = color[0];
-
- } else if (color[1] >= color[2]) {
- // color[1] is largest.
- scale = color[1];
-
- } else {
- // color[2] is largest.
- scale = color[2];
- }
- color /= scale;
- }
-
- // Now search for the best match.
- PN_stdfloat best_dist = 5.0; // Greater than 4.
- int best_i = -1;
-
- int num_color_entries = get_num_color_entries();
- for (int i = 0; i < num_color_entries; i++) {
- LRGBColor consider = _colors[i].get_rgb();
- PN_stdfloat dist2 = dot(consider - color, consider - color);
- nassertr(dist2 < 5.0, 0);
-
- if (dist2 < best_dist) {
- best_dist = dist2;
- best_i = i;
- }
- }
- nassertr(best_i >= 0, 0);
-
- int num_color_shades = get_num_color_shades();
- int shade_index = (int)floor((num_color_shades-1) * scale + 0.5);
-
- return (best_i * num_color_shades) + shade_index;
-}
-
-/**
- * Returns the number of actual entries in the color palette. This is based
- * on the version of the flt file, and is usually either 512 or 1024.
- */
-int FltHeader::
-get_num_color_entries() const {
- return _colors.size();
-}
-
-/**
- * Returns the number of shades of brightness of each entry in the color
- * palette. This is a fixed property of MultiGen files: each entry in the
- * palette actually represents a range of this many colors.
- */
-int FltHeader::
-get_num_color_shades() const {
- return 128;
-}
-
-/**
- * Decodes a MultiGen color, as stored on a face or vertex, into an actual
- * four-component LColor. Normally you need not call this directly; there are
- * color accessors defined on faces and vertices that do this.
- */
-LColor FltHeader::
-get_color(int color_index, bool use_packed_color,
- const FltPackedColor &packed_color,
- int transparency) {
- if (!use_packed_color) {
- return get_color(color_index);
- }
-
- LColor color;
- color[0] = packed_color._r / 255.0;
- color[1] = packed_color._g / 255.0;
- color[2] = packed_color._b / 255.0;
- // MultiGen doesn't yet use the A component of RGBA. color[3] =
- // packed_color._a 255.0;
- color[3] = 1.0 - (transparency / 65535.0);
- return color;
-}
-
-/**
- * Decodes a MultiGen color, as stored on a face or vertex, into an actual
- * three-component LRGBColor. Normally you need not call this directly; there
- * are color accessors defined on faces and vertices that do this.
- */
-LRGBColor FltHeader::
-get_rgb(int color_index, bool use_packed_color,
- const FltPackedColor &packed_color) {
- if (!use_packed_color) {
- return get_rgb(color_index);
- }
-
- LRGBColor color;
- color[0] = packed_color._r / 255.0;
- color[1] = packed_color._g / 255.0;
- color[2] = packed_color._b / 255.0;
- return color;
-}
-
-/**
- * Returns true if a material with the given index has been defined.
- */
-bool FltHeader::
-has_material(int material_index) const {
- return (_materials.count(material_index) != 0);
-}
-
-/**
- * Returns the material associated with the given index, or NULL if there is
- * no such material.
- */
-FltMaterial *FltHeader::
-get_material(int material_index) const {
- Materials::const_iterator mi;
- mi = _materials.find(material_index);
- if (mi != _materials.end()) {
- return (*mi).second;
- }
- return nullptr;
-}
-
-/**
- * Removes all materials from the palette.
- */
-void FltHeader::
-clear_materials() {
- _materials.clear();
-}
-
-/**
- * Defines a new material. The material is added in the position indicated by
- * the material's index number. If there is already a material defined for
- * that index number, it is replaced.
- */
-void FltHeader::
-add_material(FltMaterial *material) {
- if (material->_material_index < 0) {
- // We need to make up a new material index for the material.
- material->_material_index = _next_material_index;
- _next_material_index++;
-
- } else {
- // Make sure our next generated material index will be different from any
- // existing material indices.
- _next_material_index = std::max(_next_material_index, material->_material_index + 1);
- }
-
- _materials[material->_material_index] = material;
-}
-
-/**
- * Removes a particular material from the material palette, if it exists.
- */
-void FltHeader::
-remove_material(int material_index) {
- _materials.erase(material_index);
-}
-
-/**
- * Returns true if a texture with the given index has been defined.
- */
-bool FltHeader::
-has_texture(int texture_index) const {
- return (_textures.count(texture_index) != 0);
-}
-
-/**
- * Returns the texture associated with the given index, or NULL if there is no
- * such texture.
- */
-FltTexture *FltHeader::
-get_texture(int texture_index) const {
- Textures::const_iterator mi;
- mi = _textures.find(texture_index);
- if (mi != _textures.end()) {
- return (*mi).second;
- }
- return nullptr;
-}
-
-/**
- * Removes all textures from the palette.
- */
-void FltHeader::
-clear_textures() {
- _textures.clear();
-}
-
-/**
- * Defines a new texture. The texture is added in the position indicated by
- * the texture's index number. If there is already a texture defined for that
- * index number, it is replaced.
- */
-void FltHeader::
-add_texture(FltTexture *texture) {
- if (texture->_pattern_index < 0) {
- // We need to make up a new pattern index for the texture.
- texture->_pattern_index = _next_pattern_index;
- _next_pattern_index++;
-
- } else {
- // Make sure our next generated pattern index will be different from any
- // existing texture indices.
- _next_pattern_index = std::max(_next_pattern_index, texture->_pattern_index + 1);
- }
-
- _textures[texture->_pattern_index] = texture;
-}
-
-/**
- * Removes a particular texture from the texture palette, if it exists.
- */
-void FltHeader::
-remove_texture(int texture_index) {
- _textures.erase(texture_index);
-}
-
-/**
- * Returns true if a light source with the given index has been defined.
- */
-bool FltHeader::
-has_light_source(int light_index) const {
- return (_light_sources.count(light_index) != 0);
-}
-
-/**
- * Returns the light source associated with the given index, or NULL if there
- * is no such light source.
- */
-FltLightSourceDefinition *FltHeader::
-get_light_source(int light_index) const {
- LightSources::const_iterator li;
- li = _light_sources.find(light_index);
- if (li != _light_sources.end()) {
- return (*li).second;
- }
- return nullptr;
-}
-
-/**
- * Removes all light sources from the palette.
- */
-void FltHeader::
-clear_light_sources() {
- _light_sources.clear();
-}
-
-/**
- * Defines a new light source. The light source is added in the position
- * indicated by its light index number. If there is already a light source
- * defined for that index number, it is replaced.
- */
-void FltHeader::
-add_light_source(FltLightSourceDefinition *light_source) {
- _light_sources[light_source->_light_index] = light_source;
-}
-
-/**
- * Removes a particular light source from the light source palette, if it
- * exists.
- */
-void FltHeader::
-remove_light_source(int light_index) {
- _light_sources.erase(light_index);
-}
-
-/**
- * Returns true if we have read an eyepoint/trackplane palette, and at least
- * some of the eyepoints and trackplanes are therefore expected to be
- * meaningful.
- */
-bool FltHeader::
-got_eyepoint_trackplane_palette() const {
- return _got_eyepoint_trackplane_palette;
-}
-
-/**
- * Sets the state of the eyepoint/trackplane palette flag. When this is
- * false, the palette is believed to be meaningless, and will not be written;
- * when it is true, the palette is believed to contain at least some
- * meaningful data, and will be written.
- */
-void FltHeader::
-set_eyepoint_trackplane_palette(bool flag) {
- _got_eyepoint_trackplane_palette = flag;
-}
-
-/**
- * Returns the number of eyepoints in the eyepoint/trackplane palette. This
- * is presently fixed at 10, according to the MultiGen specs.
- */
-int FltHeader::
-get_num_eyepoints() const {
- return 10;
-}
-
-/**
- * Returns the nth eyepoint in the eyepoint/trackplane palette.
- */
-FltEyepoint *FltHeader::
-get_eyepoint(int n) {
- nassertr(n >= 0 && n < get_num_eyepoints(), nullptr);
- return &_eyepoints[n];
-}
-
-/**
- * Returns the number of trackplanes in the eyepoint/trackplane palette. This
- * is presently fixed at 10, according to the MultiGen specs.
- */
-int FltHeader::
-get_num_trackplanes() const {
- return 10;
-}
-
-/**
- * Returns the nth trackplane in the eyepoint/trackplane palette.
- */
-FltTrackplane *FltHeader::
-get_trackplane(int n) {
- nassertr(n >= 0 && n < get_num_trackplanes(), nullptr);
- return &_trackplanes[n];
-}
-
-/**
- * Recomputes the offsets_by_vertex and vertices_by_offset tables. This
- * reflects the flt file as it will be written out, but not necessarily as it
- * was read in.
- *
- * The return value is the total length of the vertex palette, including the
- * header record.
- */
-int FltHeader::
-update_vertex_lookups() {
- // We start with the length of the vertex palette record itself.
- int offset = 8;
-
- Vertices::const_iterator vi;
- for (vi = _vertices.begin(); vi != _vertices.end(); ++vi) {
- FltVertex *vertex = (*vi);
-
- _offsets_by_vertex[vertex] = offset;
- _vertices_by_offset[offset] = vertex;
- offset += vertex->get_record_length();
- }
-
- _vertex_lookups_stale = false;
-
- return offset;
-}
-
-/**
- * Fills in the information in this bead based on the information given in the
- * indicated datagram, whose opcode has already been read. Returns true on
- * success, false if the datagram is invalid.
- */
-bool FltHeader::
-extract_record(FltRecordReader &reader) {
- if (!FltBeadID::extract_record(reader)) {
- return false;
- }
-
- nassertr(reader.get_opcode() == FO_header, false);
- DatagramIterator &iterator = reader.get_iterator();
-
- _format_revision_level = iterator.get_be_int32();
- _edit_revision_level = iterator.get_be_int32();
- _last_revision = iterator.get_fixed_string(32);
- _next_group_id = iterator.get_be_int16();
- _next_lod_id = iterator.get_be_int16();
- _next_object_id = iterator.get_be_int16();
- _next_face_id = iterator.get_be_int16();
- _unit_multiplier = iterator.get_be_int16();
- _vertex_units = (Units)iterator.get_int8();
- _texwhite_new = (iterator.get_int8() != 0);
- _flags = iterator.get_be_uint32();
- iterator.skip_bytes(24);
- _projection_type = (ProjectionType)iterator.get_be_int32();
- iterator.skip_bytes(28);
- _next_dof_id = iterator.get_be_int16();
- _vertex_storage_type = (VertexStorageType)iterator.get_be_int16();
- _database_origin = (DatabaseOrigin)iterator.get_be_int32();
- _sw_x = iterator.get_be_float64();
- _sw_y = iterator.get_be_float64();
- _delta_x = iterator.get_be_float64();
- _delta_y = iterator.get_be_float64();
- _next_sound_id = iterator.get_be_int16();
- _next_path_id = iterator.get_be_int16();
- iterator.skip_bytes(8);
- _next_clip_id = iterator.get_be_int16();
- _next_text_id = iterator.get_be_int16();
- _next_bsp_id = iterator.get_be_int16();
- _next_switch_id = iterator.get_be_int16();
- iterator.skip_bytes(4);
- _sw_lat = iterator.get_be_float64();
- _sw_long = iterator.get_be_float64();
- _ne_lat = iterator.get_be_float64();
- _ne_long = iterator.get_be_float64();
- _origin_lat = iterator.get_be_float64();
- _origin_long = iterator.get_be_float64();
- _lambert_upper_lat = iterator.get_be_float64();
- _lambert_lower_lat = iterator.get_be_float64();
- _next_light_id = iterator.get_be_int16();
- iterator.skip_bytes(2);
- if (get_flt_version() >= 1420 && iterator.get_remaining_size() > 0) {
- _next_road_id = iterator.get_be_int16();
- _next_cat_id = iterator.get_be_int16();
-
- if (get_flt_version() >= 1520 && iterator.get_remaining_size() > 0) {
- iterator.skip_bytes(2 + 2 + 2 + 2);
- _earth_model = (EarthModel)iterator.get_be_int32();
-
- // Undocumented padding.
- iterator.skip_bytes(4);
-
- if (get_flt_version() >= 1560 && iterator.get_remaining_size() > 0) {
- _next_adaptive_id = iterator.get_be_int16();
- _next_curve_id = iterator.get_be_int16();
- iterator.skip_bytes(4);
-
- if (get_flt_version() >= 1570 && iterator.get_remaining_size() > 0) {
- _delta_z = iterator.get_be_float64();
- _radius = iterator.get_be_float64();
- _next_mesh_id = iterator.get_be_int16();
- iterator.skip_bytes(2);
-
- // Undocumented padding.
- iterator.skip_bytes(4);
- }
- }
- }
- }
-
- check_remaining_size(iterator);
- return true;
-}
-
-/**
- * Checks whether the given bead, which follows this bead sequentially in the
- * file, is an ancillary record of this bead. If it is, extracts the relevant
- * information and returns true; otherwise, leaves it alone and returns false.
- */
-bool FltHeader::
-extract_ancillary(FltRecordReader &reader) {
- switch (reader.get_opcode()) {
- case FO_vertex_palette:
- // We're about to begin the vertex palette!
- clear_vertices();
- _current_vertex_offset = reader.get_record_length();
- return true;
-
- case FO_vertex_c:
- case FO_vertex_cn:
- case FO_vertex_cnu:
- case FO_vertex_cu:
- // Here's a new vertex for the palette.
- return extract_vertex(reader);
-
- case FO_color_palette:
- return extract_color_palette(reader);
-
- case FO_15_material:
- return extract_material(reader);
-
- case FO_14_material_palette:
- return extract_14_material_palette(reader);
-
- case FO_texture:
- return extract_texture(reader);
-
- case FO_texture_map_palette:
- return extract_texture_map(reader);
-
- case FO_light_definition:
- return extract_light_source(reader);
-
- case FO_eyepoint_palette:
- return extract_eyepoint_palette(reader);
-
- default:
- return FltBeadID::extract_ancillary(reader);
- }
-}
-
-/**
- * Fills up the current record on the FltRecordWriter with data for this
- * record, but does not advance the writer. Returns true on success, false if
- * there is some error.
- */
-bool FltHeader::
-build_record(FltRecordWriter &writer) const {
- if (!FltBeadID::build_record(writer)) {
- return false;
- }
-
- writer.set_opcode(FO_header);
- Datagram &datagram = writer.update_datagram();
-
- datagram.add_be_int32(_format_revision_level);
- datagram.add_be_int32(_edit_revision_level);
- datagram.add_fixed_string(_last_revision, 32);
- datagram.add_be_int16(_next_group_id);
- datagram.add_be_int16(_next_lod_id);
- datagram.add_be_int16(_next_object_id);
- datagram.add_be_int16(_next_face_id);
- datagram.add_be_int16(_unit_multiplier);
- datagram.add_int8(_vertex_units);
- datagram.add_int8(_texwhite_new);
- datagram.add_be_uint32(_flags);
- datagram.pad_bytes(24);
- datagram.add_be_int32(_projection_type);
- datagram.pad_bytes(28);
- datagram.add_be_int16(_next_dof_id);
- datagram.add_be_int16(_vertex_storage_type);
- datagram.add_be_int32(_database_origin);
- datagram.add_be_float64(_sw_x);
- datagram.add_be_float64(_sw_y);
- datagram.add_be_float64(_delta_x);
- datagram.add_be_float64(_delta_y);
- datagram.add_be_int16(_next_sound_id);
- datagram.add_be_int16(_next_path_id);
- datagram.pad_bytes(8);
- datagram.add_be_int16(_next_clip_id);
- datagram.add_be_int16(_next_text_id);
- datagram.add_be_int16(_next_bsp_id);
- datagram.add_be_int16(_next_switch_id);
- datagram.pad_bytes(4);
- datagram.add_be_float64(_sw_lat);
- datagram.add_be_float64(_sw_long);
- datagram.add_be_float64(_ne_lat);
- datagram.add_be_float64(_ne_long);
- datagram.add_be_float64(_origin_lat);
- datagram.add_be_float64(_origin_long);
- datagram.add_be_float64(_lambert_upper_lat);
- datagram.add_be_float64(_lambert_lower_lat);
- datagram.add_be_int16(_next_light_id);
- datagram.pad_bytes(2);
- datagram.add_be_int16(_next_road_id);
- datagram.add_be_int16(_next_cat_id);
-
- if (get_flt_version() >= 1520) {
- // New with 15.2
- datagram.pad_bytes(2 + 2 + 2 + 2);
- datagram.add_be_int32(_earth_model);
-
- datagram.pad_bytes(4);
-
- if (get_flt_version() >= 1560) {
- // New with 15.6
- datagram.add_be_int16(_next_adaptive_id);
- datagram.add_be_int16(_next_curve_id);
- datagram.pad_bytes(4);
-
- if (get_flt_version() >= 1570) {
- // New with 15.7
- datagram.add_be_float64(_delta_z);
- datagram.add_be_float64(_radius);
- datagram.add_be_int16(_next_mesh_id);
- datagram.pad_bytes(2);
- datagram.pad_bytes(4);
- }
- }
- }
-
- return true;
-}
-
-/**
- * Writes whatever ancillary records are required for this bead. Returns
- * FE_ok on success, or something else on error.
- */
-FltError FltHeader::
-write_ancillary(FltRecordWriter &writer) const {
- FltError result;
-
- result = write_color_palette(writer);
- if (result != FE_ok) {
- return result;
- }
-
- result = write_material_palette(writer);
- if (result != FE_ok) {
- return result;
- }
-
- result = write_texture_palette(writer);
- if (result != FE_ok) {
- return result;
- }
-
- result = write_light_source_palette(writer);
- if (result != FE_ok) {
- return result;
- }
-
- result = write_eyepoint_palette(writer);
- if (result != FE_ok) {
- return result;
- }
-
- result = write_vertex_palette(writer);
- if (result != FE_ok) {
- return result;
- }
-
- return FltBeadID::write_ancillary(writer);
-}
-
-/**
- * Reads a single vertex ancillary record. It is assumed that all the vertex
- * records will immediately follow the vertex palette record.
- */
-bool FltHeader::
-extract_vertex(FltRecordReader &reader) {
- FltVertex *vertex = new FltVertex(this);
- if (!vertex->extract_record(reader)) {
- return false;
- }
- _vertices.push_back(vertex);
- _unique_vertices.insert(vertex);
- _offsets_by_vertex[vertex] = _current_vertex_offset;
- _vertices_by_offset[_current_vertex_offset] = vertex;
- _current_vertex_offset += reader.get_record_length();
-
- // _vertex_lookups_stale remains false.
-
- return true;
-}
-
-/**
- * Reads the color palette.
- */
-bool FltHeader::
-extract_color_palette(FltRecordReader &reader) {
- nassertr(reader.get_opcode() == FO_color_palette, false);
- DatagramIterator &iterator = reader.get_iterator();
-
- if (_got_color_palette) {
- nout << "Warning: multiple color palettes found.\n";
- }
- _got_color_palette = true;
-
- static const int expected_color_entries = 1024;
-
- iterator.skip_bytes(128);
- _colors.clear();
- for (int i = 0; i < expected_color_entries; i++) {
- if (iterator.get_remaining_size() == 0) {
- // An early end to the palette is acceptable.
- return true;
- }
- FltPackedColor color;
- if (!color.extract_record(reader)) {
- return false;
- }
- _colors.push_back(color);
- }
-
- // Now pull out the color names.
- while (iterator.get_remaining_size() > 0) {
- int entry_length = iterator.get_be_uint16();
- iterator.skip_bytes(2);
- if (iterator.get_remaining_size() > 0) {
- int color_index = iterator.get_be_int16();
- iterator.skip_bytes(2);
-
- int name_length = entry_length - 8;
- nassertr(color_index >= 0 && color_index < (int)_colors.size(), false);
- _color_names[color_index] = iterator.get_fixed_string(name_length);
- }
- }
-
- check_remaining_size(iterator, "color palette");
- return true;
-}
-
-/**
- * Reads a single material ancillary record.
- */
-bool FltHeader::
-extract_material(FltRecordReader &reader) {
- PT(FltMaterial) material = new FltMaterial(this);
- if (!material->extract_record(reader)) {
- return false;
- }
- add_material(material);
-
- return true;
-}
-
-/**
- * Reads the v14.2 material palette.
- */
-bool FltHeader::
-extract_14_material_palette(FltRecordReader &reader) {
- nassertr(reader.get_opcode() == FO_14_material_palette, false);
- DatagramIterator &iterator = reader.get_iterator();
-
- if (_got_14_material_palette) {
- nout << "Warning: multiple material palettes found.\n";
- }
- _got_14_material_palette = true;
-
- static const int expected_material_entries = 64;
-
- _materials.clear();
- for (int i = 0; i < expected_material_entries; i++) {
- if (iterator.get_remaining_size() == 0) {
- // An early end to the palette is acceptable.
- return true;
- }
- PT(FltMaterial) material = new FltMaterial(this);
- if (!material->extract_14_record(i, iterator)) {
- return false;
- }
- add_material(material);
- }
-
- check_remaining_size(iterator, "material palette");
- return true;
-}
-
-/**
- * Reads a single texture ancillary record.
- */
-bool FltHeader::
-extract_texture(FltRecordReader &reader) {
- FltTexture *texture = new FltTexture(this);
- if (!texture->extract_record(reader)) {
- return false;
- }
- add_texture(texture);
-
- return true;
-}
-
-/**
- * Reads the a single texture mapping ancillary record. This describes a kind
- * of texture mapping in the texture mapping palette.
- */
-bool FltHeader::
-extract_texture_map(FltRecordReader &reader) {
- // At the moment, we ignore this, since it's not needed for meaningful
- // extraction of data: we can get this information from the UV's for a
- // particular model. We just add an UnsupportedRecord for it.
- FltUnsupportedRecord *rec = new FltUnsupportedRecord(this);
- if (!rec->extract_record(reader)) {
- return false;
- }
- add_ancillary(rec);
-
- return true;
-}
-
-/**
- * Reads a single light source ancillary record.
- */
-bool FltHeader::
-extract_light_source(FltRecordReader &reader) {
- FltLightSourceDefinition *light_source = new FltLightSourceDefinition(this);
- if (!light_source->extract_record(reader)) {
- return false;
- }
- add_light_source(light_source);
-
- return true;
-}
-
-/**
- * Reads the eyepoint/trackplane palette.
- */
-bool FltHeader::
-extract_eyepoint_palette(FltRecordReader &reader) {
- nassertr(reader.get_opcode() == FO_eyepoint_palette, false);
- DatagramIterator &iterator = reader.get_iterator();
-
- iterator.skip_bytes(4);
-
- int i;
- int num_eyepoints = get_num_eyepoints();
- for (i = 0; i < num_eyepoints; i++) {
- if (!_eyepoints[i].extract_record(reader)) {
- return false;
- }
- }
-
- int num_trackplanes = get_num_trackplanes();
- for (i = 0; i < num_trackplanes; i++) {
- if (!_trackplanes[i].extract_record(reader)) {
- return false;
- }
- }
-
- _got_eyepoint_trackplane_palette = true;
-
- if (get_flt_version() >= 1420) {
- // I have no idea what bytes are supposed to be here in earlier versions
- // that 14.2, but who really cares? Don't bother reporting it if there
- // are too many bytes in old versions.
- check_remaining_size(iterator, "eyepoint palette");
- }
- return true;
-}
-
-/**
- * Writes out the vertex palette with all of its vertices.
- */
-FltError FltHeader::
-write_vertex_palette(FltRecordWriter &writer) const {
- FltError result;
-
- int vertex_palette_length =
- ((FltHeader *)this)->update_vertex_lookups();
- Datagram vertex_palette;
- vertex_palette.add_be_int32(vertex_palette_length);
- result = writer.write_record(FO_vertex_palette, vertex_palette);
- if (result != FE_ok) {
- return result;
- }
- // Now write out each vertex in the palette.
- Vertices::const_iterator vi;
- for (vi = _vertices.begin(); vi != _vertices.end(); ++vi) {
- FltVertex *vertex = (*vi);
- vertex->build_record(writer);
- result = writer.advance();
- if (result != FE_ok) {
- return result;
- }
- }
-
- return FE_ok;
-}
-
-
-/**
- * Writes out the color palette.
- */
-FltError FltHeader::
-write_color_palette(FltRecordWriter &writer) const {
- writer.set_opcode(FO_color_palette);
- Datagram &datagram = writer.update_datagram();
-
- datagram.pad_bytes(128);
-
- // How many colors should we write?
- int num_colors = 1024;
-
- Colors::const_iterator ci;
- for (ci = _colors.begin(); num_colors > 0 && ci != _colors.end(); ++ci) {
- if (!(*ci).build_record(writer)) {
- assert(!flt_error_abort);
- return FE_invalid_record;
- }
- num_colors--;
- }
-
- // Now we might need to pad the record to fill up the required number of
- // colors.
- if (num_colors > 0) {
- FltPackedColor empty;
- while (num_colors > 0) {
- if (!empty.build_record(writer)) {
- assert(!flt_error_abort);
- return FE_invalid_record;
- }
- num_colors--;
- }
- }
-
- // Now append all the names at the end.
- ColorNames::const_iterator ni;
- for (ni = _color_names.begin(); ni != _color_names.end(); ++ni) {
- std::string name = (*ni).second.substr(0, 80);
- int entry_length = name.length() + 8;
- datagram.add_be_uint16(entry_length);
- datagram.pad_bytes(2);
- datagram.add_be_uint16((*ni).first);
- datagram.pad_bytes(2);
- datagram.add_fixed_string(name, name.length());
- }
-
- return writer.advance();
-}
-
-/**
- * Writes out the material palette.
- */
-FltError FltHeader::
-write_material_palette(FltRecordWriter &writer) const {
- FltError result;
-
- if (get_flt_version() >= 1520) {
- // Write a version 15 material palette.
- Materials::const_iterator mi;
- for (mi = _materials.begin(); mi != _materials.end(); ++mi) {
- FltMaterial *material = (*mi).second;
- material->build_record(writer);
-
- result = writer.advance();
- if (result != FE_ok) {
- return result;
- }
- }
-
- } else {
- // Write a version 14 material palette.
- if (_materials.empty()) {
- // No palette is OK.
- return FE_ok;
- }
- writer.set_opcode(FO_14_material_palette);
- Datagram &datagram = writer.update_datagram();
-
- PT(FltMaterial) dummy_material = new FltMaterial(_header);
-
- Materials::const_iterator mi = _materials.lower_bound(0);
- int index;
- static const int expected_material_entries = 64;
- for (index = 0; index < expected_material_entries; index++) {
- if (mi == _materials.end() || index < (*mi).first) {
- dummy_material->build_14_record(datagram);
- } else {
- nassertr(index == (*mi).first, FE_internal);
- FltMaterial *material = (*mi).second;
- material->build_14_record(datagram);
- ++mi;
- }
- }
-
- result = writer.advance();
- if (result != FE_ok) {
- return result;
- }
- }
-
- return FE_ok;
-}
-
-/**
- * Writes out the texture palette.
- */
-FltError FltHeader::
-write_texture_palette(FltRecordWriter &writer) const {
- FltError result;
-
- Textures::const_iterator ti;
- for (ti = _textures.begin(); ti != _textures.end(); ++ti) {
- FltTexture *texture = (*ti).second;
- texture->build_record(writer);
- result = writer.advance();
- if (result != FE_ok) {
- return result;
- }
- }
-
- return FE_ok;
-}
-
-/**
- * Writes out the light source palette.
- */
-FltError FltHeader::
-write_light_source_palette(FltRecordWriter &writer) const {
- FltError result;
-
- LightSources::const_iterator li;
- for (li = _light_sources.begin(); li != _light_sources.end(); ++li) {
- FltLightSourceDefinition *light_source = (*li).second;
- light_source->build_record(writer);
- result = writer.advance();
- if (result != FE_ok) {
- return result;
- }
- }
-
- return FE_ok;
-}
-
-/**
- * Writes out the eyepoint/trackplane palette, if we have one.
- */
-FltError FltHeader::
-write_eyepoint_palette(FltRecordWriter &writer) const {
- if (!_got_eyepoint_trackplane_palette) {
- return FE_ok;
- }
-
- writer.set_opcode(FO_eyepoint_palette);
- Datagram &datagram = writer.update_datagram();
- datagram.pad_bytes(4);
-
- int i;
- int num_eyepoints = get_num_eyepoints();
- for (i = 0; i < num_eyepoints; i++) {
- if (!_eyepoints[i].build_record(writer)) {
- assert(!flt_error_abort);
- return FE_bad_data;
- }
- }
-
- int num_trackplanes = get_num_trackplanes();
- for (i = 0; i < num_trackplanes; i++) {
- if (!_trackplanes[i].build_record(writer)) {
- assert(!flt_error_abort);
- return FE_bad_data;
- }
- }
-
- return writer.advance();
-}
diff --git a/pandatool/src/flt/fltHeader.h b/pandatool/src/flt/fltHeader.h
deleted file mode 100644
index 620e553a..00000000
--- a/pandatool/src/flt/fltHeader.h
+++ /dev/null
@@ -1,340 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltHeader.h
- * @author drose
- * @date 2000-08-24
- */
-
-#ifndef FLTHEADER_H
-#define FLTHEADER_H
-
-#include "pandatoolbase.h"
-
-#include "fltBeadID.h"
-#include "fltVertex.h"
-#include "fltMaterial.h"
-#include "fltTexture.h"
-#include "fltLightSourceDefinition.h"
-#include "fltEyepoint.h"
-#include "fltTrackplane.h"
-#include "fltInstanceDefinition.h"
-
-#include "pathReplace.h"
-#include "pointerTo.h"
-#include "filename.h"
-#include "dSearchPath.h"
-#include "distanceUnit.h"
-#include "pvector.h"
-#include "pset.h"
-#include "pmap.h"
-
-/**
- * This is the first bead in the file, the top of the bead hierarchy, and the
- * primary interface to reading and writing a Flt file. You always read a Flt
- * file by creating a header and calling read_flt(), which fills in its
- * children beads automatically; you write a Flt file by creating a header,
- * adding its children, and calling write_flt().
- */
-class FltHeader : public FltBeadID {
-public:
- FltHeader(PathReplace *path_replace);
-
- virtual void apply_converted_filenames();
-
- void set_path_replace(PathReplace *path_replace);
- PathReplace *get_path_replace();
- const PathReplace *get_path_replace() const;
- Filename convert_path(const Filename &orig_filename,
- const DSearchPath &additional_path = DSearchPath());
-
- void set_flt_filename(const Filename &flt_filename);
- const Filename &get_flt_filename() const;
-
- FltError read_flt(Filename filename);
- FltError read_flt(std::istream &in);
- FltError write_flt(Filename filename);
- FltError write_flt(std::ostream &out);
-
- enum AttrUpdate {
- AU_none,
- AU_if_missing,
- AU_always
- };
-
- void set_auto_attr_update(AttrUpdate attr);
- AttrUpdate get_auto_attr_update() const;
-
- enum Units {
- U_meters = 0,
- U_kilometers = 1,
- U_feet = 4,
- U_inches = 5,
- U_nautical_miles = 8
- };
-
- enum Flags {
- F_save_vertex_normals = 0x80000000
- };
-
- enum ProjectionType {
- PT_flat_earth = 0,
- PT_trapezoidal = 1,
- PT_round_earth = 2,
- PT_lambert = 3,
- PT_utm = 4
- };
-
- enum VertexStorageType {
- VTS_double = 1
- };
-
- enum DatabaseOrigin {
- DO_open_flight = 100,
- DO_dig = 200,
- DO_es_ct6 = 300,
- DO_psp = 400,
- DO_ge_civ = 600,
- DO_es_gdf = 700,
- };
-
- enum EarthModel {
- EM_wgs84 = 0,
- EM_wgs72 = 1,
- EM_bessel = 2,
- EM_clarke_1866 = 3,
- EM_nad27 = 4
- };
-
- int _format_revision_level;
- int _edit_revision_level;
- std::string _last_revision;
- int _next_group_id;
- int _next_lod_id;
- int _next_object_id;
- int _next_face_id;
- int _unit_multiplier;
- Units _vertex_units;
- bool _texwhite_new;
- unsigned int _flags;
- ProjectionType _projection_type;
- int _next_dof_id;
- VertexStorageType _vertex_storage_type;
- DatabaseOrigin _database_origin;
- double _sw_x, _sw_y;
- double _delta_x, _delta_y;
- int _next_sound_id;
- int _next_path_id;
- int _next_clip_id;
- int _next_text_id;
- int _next_bsp_id;
- int _next_switch_id;
- double _sw_lat, _sw_long;
- double _ne_lat, _ne_long;
- double _origin_lat, _origin_long;
- double _lambert_upper_lat, _lambert_lower_lat;
- int _next_light_id;
- int _next_road_id;
- int _next_cat_id;
- EarthModel _earth_model;
- int _next_adaptive_id;
- int _next_curve_id;
- double _delta_z;
- double _radius;
- int _next_mesh_id;
-
-public:
- int get_flt_version() const;
- void set_flt_version(int version);
- static int min_flt_version();
- static int max_flt_version();
- bool check_version() const;
-
- DistanceUnit get_units() const;
-
- // Accessors into the instance pool.
- bool has_instance(int instance_index) const;
- FltInstanceDefinition *get_instance(int instance_index) const;
- void clear_instances();
- void add_instance(FltInstanceDefinition *instance);
- void remove_instance(int instance_index);
-
-
- // Accessors into the vertex palette.
- int get_num_vertices() const;
- FltVertex *get_vertex(int n) const;
- void clear_vertices();
- void add_vertex(FltVertex *vertex);
-
- FltVertex *get_vertex_by_offset(int offset);
- int get_offset_by_vertex(FltVertex *vertex);
-
-
- // Accessors into the color palette. This is read-only; why would you want
- // to mess with building a new color palette?
- int get_num_colors() const;
- LColor get_color(int color_index) const;
- LRGBColor get_rgb(int color_index) const;
- bool has_color_name(int color_index) const;
- std::string get_color_name(int color_index) const;
-
- int get_closest_color(const LColor &color) const;
- int get_closest_rgb(const LRGBColor &color) const;
-
- int get_num_color_entries() const;
- int get_num_color_shades() const;
-
- // These functions are mainly used behind-the-scenes to decode the strange
- // forest of color options defined for faces and vertices.
- LColor get_color(int color_index, bool use_packed_color,
- const FltPackedColor &packed_color,
- int transparency);
- LRGBColor get_rgb(int color_index, bool use_packed_color,
- const FltPackedColor &packed_color);
-
- // Accessors into the material palette.
- bool has_material(int material_index) const;
- FltMaterial *get_material(int material_index) const;
- void clear_materials();
- void add_material(FltMaterial *material);
- void remove_material(int material_index);
-
-
- // Accessors into the texture palette.
- bool has_texture(int texture_index) const;
- FltTexture *get_texture(int texture_index) const;
- void clear_textures();
- void add_texture(FltTexture *texture);
- void remove_texture(int texture_index);
-
-
- // Accessors into the light source palette.
- bool has_light_source(int light_index) const;
- FltLightSourceDefinition *get_light_source(int light_index) const;
- void clear_light_sources();
- void add_light_source(FltLightSourceDefinition *light_source);
- void remove_light_source(int light_index);
-
-
- // Accessors into the eyepointtrackplane palette.
- bool got_eyepoint_trackplane_palette() const;
- void set_eyepoint_trackplane_palette(bool flag);
-
- int get_num_eyepoints() const;
- FltEyepoint *get_eyepoint(int n);
- int get_num_trackplanes() const;
- FltTrackplane *get_trackplane(int n);
-
-private:
- // Instance subtrees. These are standalone subtrees, which may be
- // referenced by various points in the hierarchy, stored by instance ID
- // number.
- typedef pmap Instances;
- Instances _instances;
-
-
- // Support for the vertex palette.
- int update_vertex_lookups();
-
- typedef pvector Vertices;
- typedef pset UniqueVertices;
-
- typedef pmap VerticesByOffset;
- typedef pmap OffsetsByVertex;
-
- Vertices _vertices;
- UniqueVertices _unique_vertices;
- VerticesByOffset _vertices_by_offset;
- OffsetsByVertex _offsets_by_vertex;
-
- bool _vertex_lookups_stale;
-
- // This is maintained while the header is being read, to map the vertices to
- // their corresponding offsets in the vertex palette.
- int _current_vertex_offset;
-
-
- // Support for the color palette.
- bool _got_color_palette;
- typedef pvector Colors;
- typedef pmap ColorNames;
- Colors _colors;
- ColorNames _color_names;
-
-
- // Support for the material palette.
- bool _got_14_material_palette;
- typedef pmap Materials;
- Materials _materials;
- int _next_material_index;
-
-
- // Support for the texture palette.
- AttrUpdate _auto_attr_update;
- typedef pmap Textures;
- Textures _textures;
- int _next_pattern_index;
-
-
- // Support for the light source palette.
- typedef pmap LightSources;
- LightSources _light_sources;
-
-
- // Support for the eyepointtrackplane palette.
- bool _got_eyepoint_trackplane_palette;
- FltEyepoint _eyepoints[10];
- FltTrackplane _trackplanes[10];
-
- // This pointer is used to resolve references in the flt file.
- PT(PathReplace) _path_replace;
- Filename _flt_filename;
-
-protected:
- virtual bool extract_record(FltRecordReader &reader);
- virtual bool extract_ancillary(FltRecordReader &reader);
-
- virtual bool build_record(FltRecordWriter &writer) const;
- virtual FltError write_ancillary(FltRecordWriter &writer) const;
-
-private:
- bool extract_vertex(FltRecordReader &reader);
- bool extract_color_palette(FltRecordReader &reader);
- bool extract_material(FltRecordReader &reader);
- bool extract_14_material_palette(FltRecordReader &reader);
- bool extract_texture(FltRecordReader &reader);
- bool extract_texture_map(FltRecordReader &reader);
- bool extract_light_source(FltRecordReader &reader);
- bool extract_eyepoint_palette(FltRecordReader &reader);
-
- FltError write_vertex_palette(FltRecordWriter &writer) const;
- FltError write_color_palette(FltRecordWriter &writer) const;
- FltError write_material_palette(FltRecordWriter &writer) const;
- FltError write_texture_palette(FltRecordWriter &writer) const;
- FltError write_light_source_palette(FltRecordWriter &writer) const;
- FltError write_eyepoint_palette(FltRecordWriter &writer) const;
-
-public:
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- FltBeadID::init_type();
- register_type(_type_handle, "FltHeader",
- FltBeadID::get_class_type());
- }
-
-private:
- static TypeHandle _type_handle;
-};
-
-#endif
diff --git a/pandatool/src/flt/fltInstanceDefinition.cxx b/pandatool/src/flt/fltInstanceDefinition.cxx
deleted file mode 100644
index 83cf3238..00000000
--- a/pandatool/src/flt/fltInstanceDefinition.cxx
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltInstanceDefinition.cxx
- * @author drose
- * @date 2000-08-30
- */
-
-#include "fltInstanceDefinition.h"
-#include "fltRecordReader.h"
-#include "fltRecordWriter.h"
-
-TypeHandle FltInstanceDefinition::_type_handle;
-
-/**
- *
- */
-FltInstanceDefinition::
-FltInstanceDefinition(FltHeader *header) : FltBead(header) {
- _instance_index = 0;
-}
-
-/**
- * Fills in the information in this bead based on the information given in the
- * indicated datagram, whose opcode has already been read. Returns true on
- * success, false if the datagram is invalid.
- */
-bool FltInstanceDefinition::
-extract_record(FltRecordReader &reader) {
- if (!FltBead::extract_record(reader)) {
- return false;
- }
-
- nassertr(reader.get_opcode() == FO_instance, false);
- DatagramIterator &iterator = reader.get_iterator();
-
- iterator.skip_bytes(2);
- _instance_index = iterator.get_be_int16();
-
- check_remaining_size(iterator);
- return true;
-}
-
-/**
- * Fills up the current record on the FltRecordWriter with data for this
- * record, but does not advance the writer. Returns true on success, false if
- * there is some error.
- */
-bool FltInstanceDefinition::
-build_record(FltRecordWriter &writer) const {
- if (!FltBead::build_record(writer)) {
- return false;
- }
-
- writer.set_opcode(FO_instance);
- Datagram &datagram = writer.update_datagram();
-
- datagram.pad_bytes(2);
- datagram.add_be_int16(_instance_index);
-
- return true;
-}
diff --git a/pandatool/src/flt/fltInstanceDefinition.h b/pandatool/src/flt/fltInstanceDefinition.h
deleted file mode 100644
index 0a17f014..00000000
--- a/pandatool/src/flt/fltInstanceDefinition.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltInstanceDefinition.h
- * @author drose
- * @date 2000-08-30
- */
-
-#ifndef FLTINSTANCEDEFINITION_H
-#define FLTINSTANCEDEFINITION_H
-
-#include "pandatoolbase.h"
-
-#include "fltBead.h"
-
-/**
- * This special kind of record marks the top node of an instance subtree.
- * This subtree lives outside of the normal hierarchy, and is MultiGen's way
- * of supporting instancing--each instance subtree has a unique index, which
- * may be referenced in a FltInstanceRef object to make the instance appear in
- * various places in the hierarchy.
- */
-class FltInstanceDefinition : public FltBead {
-public:
- FltInstanceDefinition(FltHeader *header);
-
- int _instance_index;
-
-protected:
- virtual bool extract_record(FltRecordReader &reader);
- virtual bool build_record(FltRecordWriter &writer) const;
-
-public:
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- FltBead::init_type();
- register_type(_type_handle, "FltInstanceDefinition",
- FltBead::get_class_type());
- }
-
-private:
- static TypeHandle _type_handle;
-
- friend class FltInstanceRef;
- friend class FltRecordWriter;
-};
-
-#endif
diff --git a/pandatool/src/flt/fltInstanceRef.cxx b/pandatool/src/flt/fltInstanceRef.cxx
deleted file mode 100644
index f33ef3b1..00000000
--- a/pandatool/src/flt/fltInstanceRef.cxx
+++ /dev/null
@@ -1,112 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltInstanceRef.cxx
- * @author drose
- * @date 2000-08-30
- */
-
-#include "fltInstanceRef.h"
-#include "fltRecordReader.h"
-#include "fltRecordWriter.h"
-#include "fltInstanceDefinition.h"
-#include "fltHeader.h"
-
-TypeHandle FltInstanceRef::_type_handle;
-
-/**
- *
- */
-FltInstanceRef::
-FltInstanceRef(FltHeader *header) : FltBead(header) {
- _instance_index = 0;
-}
-
-/**
- * Returns the instance subtree referenced by this node, or NULL if the
- * reference is invalid.
- */
-FltInstanceDefinition *FltInstanceRef::
-get_instance() const {
- return _header->get_instance(_instance_index);
-}
-
-/**
- * Writes a multiple-line description of the record and all of its children.
- * This is a human-readable description, primarily for debugging; to write a
- * flt file, use FltHeader::write_flt().
- */
-void FltInstanceRef::
-write(std::ostream &out, int indent_level) const {
- indent(out, indent_level) << "instance";
- FltInstanceDefinition *def = _header->get_instance(_instance_index);
- if (def != nullptr) {
- def->write_children(out, indent_level + 2);
- indent(out, indent_level) << "}\n";
- } else {
- out << "\n";
- }
-}
-
-/**
- * Fills in the information in this bead based on the information given in the
- * indicated datagram, whose opcode has already been read. Returns true on
- * success, false if the datagram is invalid.
- */
-bool FltInstanceRef::
-extract_record(FltRecordReader &reader) {
- if (!FltBead::extract_record(reader)) {
- return false;
- }
-
- nassertr(reader.get_opcode() == FO_instance_ref, false);
- DatagramIterator &iterator = reader.get_iterator();
-
- iterator.skip_bytes(2);
- _instance_index = iterator.get_be_int16();
-
- check_remaining_size(iterator);
- return true;
-}
-
-/**
- * Writes this record out to the flt file, along with all of its ancillary
- * records and children records. Returns FE_ok on success, or something else
- * on error.
- */
-FltError FltInstanceRef::
-write_record_and_children(FltRecordWriter &writer) const {
- // First, make sure our instance definition has already been written.
- FltError result = writer.write_instance_def(_header, _instance_index);
- if (result != FE_ok) {
- return result;
- }
-
- // Then write out our own record.
- return FltBead::write_record_and_children(writer);
-}
-
-/**
- * Fills up the current record on the FltRecordWriter with data for this
- * record, but does not advance the writer. Returns true on success, false if
- * there is some error.
- */
-bool FltInstanceRef::
-build_record(FltRecordWriter &writer) const {
- if (!FltBead::build_record(writer)) {
- return false;
- }
-
- writer.set_opcode(FO_instance_ref);
- Datagram &datagram = writer.update_datagram();
-
- datagram.pad_bytes(2);
- datagram.add_be_int16(_instance_index);
-
- return true;
-}
diff --git a/pandatool/src/flt/fltInstanceRef.h b/pandatool/src/flt/fltInstanceRef.h
deleted file mode 100644
index 2f8e281c..00000000
--- a/pandatool/src/flt/fltInstanceRef.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltInstanceRef.h
- * @author drose
- * @date 2000-08-30
- */
-
-#ifndef FLTINSTANCEREF_H
-#define FLTINSTANCEREF_H
-
-#include "pandatoolbase.h"
-
-#include "fltBead.h"
-
-class FltInstanceDefinition;
-
-/**
- * This bead appears in the hierarchy to refer to a FltInstanceDefinition node
- * defined elsewhere. It indicates that the subtree beginning at the
- * FltInstanceDefinition should be considered to be instanced here.
- */
-class FltInstanceRef : public FltBead {
-public:
- FltInstanceRef(FltHeader *header);
-
- int _instance_index;
-
- FltInstanceDefinition *get_instance() const;
-
- virtual void write(std::ostream &out, int indent_level = 0) const;
-
-protected:
- virtual bool extract_record(FltRecordReader &reader);
- virtual FltError write_record_and_children(FltRecordWriter &writer) const;
- virtual bool build_record(FltRecordWriter &writer) const;
-
-public:
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- FltBead::init_type();
- register_type(_type_handle, "FltInstanceRef",
- FltBead::get_class_type());
- }
-
-private:
- static TypeHandle _type_handle;
-};
-
-#endif
diff --git a/pandatool/src/flt/fltLOD.cxx b/pandatool/src/flt/fltLOD.cxx
deleted file mode 100644
index abe655ae..00000000
--- a/pandatool/src/flt/fltLOD.cxx
+++ /dev/null
@@ -1,91 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltLOD.cxx
- * @author drose
- * @date 2000-08-25
- */
-
-#include "fltLOD.h"
-#include "fltRecordReader.h"
-#include "fltRecordWriter.h"
-
-TypeHandle FltLOD::_type_handle;
-
-/**
- *
- */
-FltLOD::
-FltLOD(FltHeader *header) : FltBeadID(header) {
- _switch_in = 0.0;
- _switch_out = 0.0;
- _special_id1 = 0;
- _special_id2 = 0;
- _flags = 0;
- _center_x = 0.0;
- _center_y = 0.0;
- _center_z = 0.0;
- _transition_range = 0.0;
-}
-
-/**
- * Fills in the information in this bead based on the information given in the
- * indicated datagram, whose opcode has already been read. Returns true on
- * success, false if the datagram is invalid.
- */
-bool FltLOD::
-extract_record(FltRecordReader &reader) {
- if (!FltBeadID::extract_record(reader)) {
- return false;
- }
-
- nassertr(reader.get_opcode() == FO_lod, false);
- DatagramIterator &iterator = reader.get_iterator();
-
- iterator.skip_bytes(4);
- _switch_in = iterator.get_be_float64();
- _switch_out = iterator.get_be_float64();
- _special_id1 = iterator.get_be_int16();
- _special_id2 = iterator.get_be_int16();
- _flags = iterator.get_be_uint32();
- _center_x = iterator.get_be_float64();
- _center_y = iterator.get_be_float64();
- _center_z = iterator.get_be_float64();
- _transition_range = iterator.get_be_float64();
-
- check_remaining_size(iterator);
- return true;
-}
-
-/**
- * Fills up the current record on the FltRecordWriter with data for this
- * record, but does not advance the writer. Returns true on success, false if
- * there is some error.
- */
-bool FltLOD::
-build_record(FltRecordWriter &writer) const {
- if (!FltBeadID::build_record(writer)) {
- return false;
- }
-
- writer.set_opcode(FO_lod);
- Datagram &datagram = writer.update_datagram();
-
- datagram.pad_bytes(4);
- datagram.add_be_float64(_switch_in);
- datagram.add_be_float64(_switch_out);
- datagram.add_be_int16(_special_id1);
- datagram.add_be_int16(_special_id2);
- datagram.add_be_uint32(_flags);
- datagram.add_be_float64(_center_x);
- datagram.add_be_float64(_center_y);
- datagram.add_be_float64(_center_z);
- datagram.add_be_float64(_transition_range);
-
- return true;
-}
diff --git a/pandatool/src/flt/fltLOD.h b/pandatool/src/flt/fltLOD.h
deleted file mode 100644
index 36e5ccb6..00000000
--- a/pandatool/src/flt/fltLOD.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltLOD.h
- * @author drose
- * @date 2000-08-25
- */
-
-#ifndef FLTLOD_H
-#define FLTLOD_H
-
-#include "pandatoolbase.h"
-
-#include "fltBeadID.h"
-
-/**
- * A Level-of-Detail record.
- */
-class FltLOD : public FltBeadID {
-public:
- FltLOD(FltHeader *header);
-
- enum Flags {
- F_use_previous_slant = 0x80000000,
- F_freeze_center = 0x20000000
- };
-
- double _switch_in;
- double _switch_out;
- int _special_id1, _special_id2;
- unsigned int _flags;
- double _center_x;
- double _center_y;
- double _center_z;
- double _transition_range;
-
-protected:
- virtual bool extract_record(FltRecordReader &reader);
- virtual bool build_record(FltRecordWriter &writer) const;
-
-public:
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- FltBeadID::init_type();
- register_type(_type_handle, "FltLOD",
- FltBeadID::get_class_type());
- }
-
-private:
- static TypeHandle _type_handle;
-};
-
-#endif
diff --git a/pandatool/src/flt/fltLightSourceDefinition.cxx b/pandatool/src/flt/fltLightSourceDefinition.cxx
deleted file mode 100644
index 52964251..00000000
--- a/pandatool/src/flt/fltLightSourceDefinition.cxx
+++ /dev/null
@@ -1,129 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltLightSourceDefinition.cxx
- * @author drose
- * @date 2000-08-26
- */
-
-#include "fltLightSourceDefinition.h"
-#include "fltRecordReader.h"
-#include "fltRecordWriter.h"
-
-TypeHandle FltLightSourceDefinition::_type_handle;
-
-/**
- *
- */
-FltLightSourceDefinition::
-FltLightSourceDefinition(FltHeader *header) : FltRecord(header) {
- _light_index = 0;
- _ambient.set(0.0, 0.0, 0.0, 1.0);
- _diffuse.set(1.0, 1.0, 1.0, 1.0);
- _specular.set(0.0, 0.0, 0.0, 1.0);
- _light_type = LT_infinite;
- _exponential_dropoff = 1.0;
- _cutoff_angle = 180.0;
- _yaw = 0.0;
- _pitch = 0.0;
- _constant_coefficient = 0.0;
- _linear_coefficient = 0.0;
- _quadratic_coefficient = 1.0;
- _modeling_light = false;
-}
-
-/**
- * Fills in the information in this record based on the information given in
- * the indicated datagram, whose opcode has already been read. Returns true
- * on success, false if the datagram is invalid.
- */
-bool FltLightSourceDefinition::
-extract_record(FltRecordReader &reader) {
- if (!FltRecord::extract_record(reader)) {
- return false;
- }
-
- nassertr(reader.get_opcode() == FO_light_definition, false);
- DatagramIterator &iterator = reader.get_iterator();
-
- _light_index = iterator.get_be_int32();
- iterator.skip_bytes(2*4);
- _light_name = iterator.get_fixed_string(20);
- iterator.skip_bytes(4);
- _ambient[0] = iterator.get_be_float32();
- _ambient[1] = iterator.get_be_float32();
- _ambient[2] = iterator.get_be_float32();
- _ambient[3] = iterator.get_be_float32();
- _diffuse[0] = iterator.get_be_float32();
- _diffuse[1] = iterator.get_be_float32();
- _diffuse[2] = iterator.get_be_float32();
- _diffuse[3] = iterator.get_be_float32();
- _specular[0] = iterator.get_be_float32();
- _specular[1] = iterator.get_be_float32();
- _specular[2] = iterator.get_be_float32();
- _specular[3] = iterator.get_be_float32();
- _light_type = (LightType)iterator.get_be_int32();
- iterator.skip_bytes(4*10);
- _exponential_dropoff = iterator.get_be_float32();
- _cutoff_angle = iterator.get_be_float32();
- _yaw = iterator.get_be_float32();
- _pitch = iterator.get_be_float32();
- _constant_coefficient = iterator.get_be_float32();
- _linear_coefficient = iterator.get_be_float32();
- _quadratic_coefficient = iterator.get_be_float32();
- _modeling_light = (iterator.get_be_int32() != 0);
- iterator.skip_bytes(4*19);
-
- check_remaining_size(iterator);
- return true;
-}
-
-/**
- * Fills up the current record on the FltRecordWriter with data for this
- * record, but does not advance the writer. Returns true on success, false if
- * there is some error.
- */
-bool FltLightSourceDefinition::
-build_record(FltRecordWriter &writer) const {
- if (!FltRecord::build_record(writer)) {
- return false;
- }
-
- writer.set_opcode(FO_light_definition);
- Datagram &datagram = writer.update_datagram();
-
- datagram.add_be_int32(_light_index);
- datagram.pad_bytes(2*4);
- datagram.add_fixed_string(_light_name, 20);
- datagram.pad_bytes(4);
- datagram.add_be_float32(_ambient[0]);
- datagram.add_be_float32(_ambient[1]);
- datagram.add_be_float32(_ambient[2]);
- datagram.add_be_float32(_ambient[3]);
- datagram.add_be_float32(_diffuse[0]);
- datagram.add_be_float32(_diffuse[1]);
- datagram.add_be_float32(_diffuse[2]);
- datagram.add_be_float32(_diffuse[3]);
- datagram.add_be_float32(_specular[0]);
- datagram.add_be_float32(_specular[1]);
- datagram.add_be_float32(_specular[2]);
- datagram.add_be_float32(_specular[3]);
- datagram.add_be_int32(_light_type);
- datagram.pad_bytes(4*10);
- datagram.add_be_float32(_exponential_dropoff);
- datagram.add_be_float32(_cutoff_angle);
- datagram.add_be_float32(_yaw);
- datagram.add_be_float32(_pitch);
- datagram.add_be_float32(_constant_coefficient);
- datagram.add_be_float32(_linear_coefficient);
- datagram.add_be_float32(_quadratic_coefficient);
- datagram.add_be_int32(_modeling_light);
- datagram.pad_bytes(4*19);
-
- return true;
-}
diff --git a/pandatool/src/flt/fltLightSourceDefinition.h b/pandatool/src/flt/fltLightSourceDefinition.h
deleted file mode 100644
index e96d2752..00000000
--- a/pandatool/src/flt/fltLightSourceDefinition.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltLightSourceDefinition.h
- * @author drose
- * @date 2000-08-26
- */
-
-#ifndef FLTLIGHTSOURCEDEFINITION_H
-#define FLTLIGHTSOURCEDEFINITION_H
-
-#include "pandatoolbase.h"
-
-#include "fltRecord.h"
-
-#include "luse.h"
-
-/**
- * Represents a single entry in the light source palette. This completely
- * defines the color, etc. of a single light source, which may be referenced
- * later by a FltLightSource bead in the hierarchy.
- */
-class FltLightSourceDefinition : public FltRecord {
-public:
- FltLightSourceDefinition(FltHeader *header);
-
- enum LightType {
- LT_infinite = 0,
- LT_local = 1,
- LT_spot = 2
- };
-
- int _light_index;
- std::string _light_name;
- LColor _ambient;
- LColor _diffuse;
- LColor _specular;
- LightType _light_type;
- PN_stdfloat _exponential_dropoff;
- PN_stdfloat _cutoff_angle; // in degrees
-
- // yaw and pitch only for modeling lights, which are positioned at the
- // eyepoint.
- PN_stdfloat _yaw;
- PN_stdfloat _pitch;
-
- PN_stdfloat _constant_coefficient;
- PN_stdfloat _linear_coefficient;
- PN_stdfloat _quadratic_coefficient;
- bool _modeling_light;
-
-protected:
- virtual bool extract_record(FltRecordReader &reader);
- virtual bool build_record(FltRecordWriter &writer) const;
-
-public:
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- FltRecord::init_type();
- register_type(_type_handle, "FltLightSourceDefinition",
- FltRecord::get_class_type());
- }
-
-private:
- static TypeHandle _type_handle;
-
- friend class FltHeader;
-};
-
-#endif
diff --git a/pandatool/src/flt/fltLocalVertexPool.I b/pandatool/src/flt/fltLocalVertexPool.I
deleted file mode 100644
index d91696c8..00000000
--- a/pandatool/src/flt/fltLocalVertexPool.I
+++ /dev/null
@@ -1,12 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltLocalVertexPool.I
- * @author drose
- * @date 2001-02-28
- */
diff --git a/pandatool/src/flt/fltLocalVertexPool.cxx b/pandatool/src/flt/fltLocalVertexPool.cxx
deleted file mode 100644
index 96082ac7..00000000
--- a/pandatool/src/flt/fltLocalVertexPool.cxx
+++ /dev/null
@@ -1,234 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltLocalVertexPool.cxx
- * @author drose
- * @date 2001-02-28
- */
-
-#include "fltLocalVertexPool.h"
-#include "fltRecordReader.h"
-#include "fltRecordWriter.h"
-#include "fltHeader.h"
-#include "fltMaterial.h"
-
-TypeHandle FltLocalVertexPool::_type_handle;
-
-/**
- *
- */
-FltLocalVertexPool::
-FltLocalVertexPool(FltHeader *header) : FltRecord(header) {
-}
-
-/**
- * Fills in the information in this bead based on the information given in the
- * indicated datagram, whose opcode has already been read. Returns true on
- * success, false if the datagram is invalid.
- */
-bool FltLocalVertexPool::
-extract_record(FltRecordReader &reader) {
- if (!FltRecord::extract_record(reader)) {
- return false;
- }
-
- nassertr(reader.get_opcode() == FO_local_vertex_pool, false);
- DatagramIterator &iterator = reader.get_iterator();
-
- int num_vertices = iterator.get_be_int32();
- int attributes = iterator.get_be_int32();
-
- for (int i = 0; i < num_vertices; i++) {
- FltVertex *vertex = new FltVertex(_header);
- _vertices.push_back(vertex);
-
- if ((attributes & AM_has_position) != 0) {
- vertex->_pos[0] = iterator.get_be_float64();
- vertex->_pos[1] = iterator.get_be_float64();
- vertex->_pos[2] = iterator.get_be_float64();
- }
-
- if ((attributes & AM_has_color_index) != 0) {
- vertex->_color_index = iterator.get_be_int32();
-
- } else if ((attributes & AM_has_packed_color) != 0) {
- if (!vertex->_packed_color.extract_record(reader)) {
- return false;
- }
- vertex->_flags |= FltVertex::F_packed_color;
-
- } else {
- vertex->_flags |= FltVertex::F_no_color;
- }
-
- if ((attributes & AM_has_normal) != 0) {
- vertex->_normal[0] = iterator.get_be_float32();
- vertex->_normal[1] = iterator.get_be_float32();
- vertex->_normal[2] = iterator.get_be_float32();
- vertex->_has_normal = true;
- }
-
- if ((attributes & AM_has_base_uv) != 0) {
- vertex->_uv[0] = iterator.get_be_float32();
- vertex->_uv[1] = iterator.get_be_float32();
- vertex->_has_uv = true;
- }
-
- if ((attributes & AM_has_uv_1) != 0) {
- iterator.get_be_float32();
- iterator.get_be_float32();
- }
-
- if ((attributes & AM_has_uv_2) != 0) {
- iterator.get_be_float32();
- iterator.get_be_float32();
- }
-
- if ((attributes & AM_has_uv_3) != 0) {
- iterator.get_be_float32();
- iterator.get_be_float32();
- }
-
- if ((attributes & AM_has_uv_4) != 0) {
- iterator.get_be_float32();
- iterator.get_be_float32();
- }
-
- if ((attributes & AM_has_uv_5) != 0) {
- iterator.get_be_float32();
- iterator.get_be_float32();
- }
-
- if ((attributes & AM_has_uv_6) != 0) {
- iterator.get_be_float32();
- iterator.get_be_float32();
- }
-
- if ((attributes & AM_has_uv_7) != 0) {
- iterator.get_be_float32();
- iterator.get_be_float32();
- }
- }
-
- check_remaining_size(iterator);
- return true;
-}
-
-/**
- * Fills up the current record on the FltRecordWriter with data for this
- * record, but does not advance the writer. Returns true on success, false if
- * there is some error.
- */
-bool FltLocalVertexPool::
-build_record(FltRecordWriter &writer) const {
- if (!FltRecord::build_record(writer)) {
- return false;
- }
-
- writer.set_opcode(FO_local_vertex_pool);
- Datagram &datagram = writer.update_datagram();
-
- // Determine what kind of vertices we have.
- int attributes = AM_has_position;
-
- Vertices::const_iterator vi;
- for (vi = _vertices.begin(); vi != _vertices.end(); ++vi) {
- FltVertex *vertex = (*vi);
- if ((vertex->_flags & FltVertex::F_no_color) != 0) {
- // No color.
-
- } else if ((vertex->_flags & FltVertex::F_packed_color) != 0) {
- // Packed color.
- attributes |= AM_has_packed_color;
-
- } else {
- // Indexed color.
- attributes |= AM_has_color_index;
- }
-
- if (vertex->_has_normal) {
- attributes |= AM_has_normal;
- }
-
- if (vertex->_has_uv) {
- attributes |= AM_has_base_uv;
- }
- }
-
- if ((attributes & AM_has_packed_color) != 0 &&
- (attributes & AM_has_color_index) != 0) {
- // We cannot have both a packed color and a color index. If we want both,
- // used packed color.
- attributes &= ~AM_has_color_index;
- }
-
- datagram.add_be_int32(_vertices.size());
- datagram.add_be_int32(attributes);
-
- // Now write out each vertex.
- for (vi = _vertices.begin(); vi != _vertices.end(); ++vi) {
- FltVertex *vertex = (*vi);
-
- if ((attributes & AM_has_position) != 0) {
- datagram.add_be_float64(vertex->_pos[0]);
- datagram.add_be_float64(vertex->_pos[1]);
- datagram.add_be_float64(vertex->_pos[2]);
- }
-
- if ((attributes & AM_has_color_index) != 0) {
- if ((vertex->_flags & (FltVertex::F_no_color | FltVertex::F_packed_color)) != 0) {
- // This particular vertex does not have a color index. Make it white.
- datagram.add_be_int32(_header->get_closest_rgb(LRGBColor(1.0, 1.0, 1.0)));
- } else {
- datagram.add_be_int32(vertex->_color_index);
- }
-
- } else if ((attributes & AM_has_packed_color) != 0) {
- // We extract our own FltPackedColor instead of writing out the vertex's
- // _packed_color directly, just in case the vertex is actually index
- // colored. This bit of code will work regardless of the kind of color
- // the vertex has.
-
- FltPackedColor color;
- if (vertex->has_color()) {
- color.set_color(vertex->get_color());
- } else {
- // An uncolored vertex. Make it white.
- color.set_color(LColor(1.0, 1.0, 1.0, 1.0));
- }
-
- if (!color.build_record(writer)) {
- return false;
- }
- }
-
- if ((attributes & AM_has_normal) != 0) {
- if (!vertex->_has_normal) {
- datagram.add_be_float32(0.0);
- datagram.add_be_float32(0.0);
- datagram.add_be_float32(0.0);
- } else {
- datagram.add_be_float32(vertex->_normal[0]);
- datagram.add_be_float32(vertex->_normal[1]);
- datagram.add_be_float32(vertex->_normal[2]);
- }
- }
-
- if ((attributes & AM_has_base_uv) != 0) {
- if (!vertex->_has_uv) {
- datagram.add_be_float32(0.0);
- datagram.add_be_float32(0.0);
- } else {
- datagram.add_be_float32(vertex->_uv[0]);
- datagram.add_be_float32(vertex->_uv[1]);
- }
- }
- }
-
- return true;
-}
diff --git a/pandatool/src/flt/fltLocalVertexPool.h b/pandatool/src/flt/fltLocalVertexPool.h
deleted file mode 100644
index f070dbc0..00000000
--- a/pandatool/src/flt/fltLocalVertexPool.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltLocalVertexPool.h
- * @author drose
- * @date 2001-02-28
- */
-
-#ifndef FLTLOCALVERTEXPOOL_H
-#define FLTLOCALVERTEXPOOL_H
-
-#include "pandatoolbase.h"
-
-#include "fltRecord.h"
-#include "fltHeader.h"
-#include "fltVertex.h"
-
-#include "pointerTo.h"
-
-/**
- * A local vertex pool, as might appear in the middle of the hierarchy, for
- * instance for a mesh.
- */
-class FltLocalVertexPool : public FltRecord {
-public:
- FltLocalVertexPool(FltHeader *header);
-
- // These bits are not stored in the vertex pool, but are read from the .flt
- // file and used immediately.
- enum AttributeMask {
- AM_has_position = 0x80000000,
- AM_has_color_index = 0x40000000,
- AM_has_packed_color = 0x20000000,
- AM_has_normal = 0x10000000,
- AM_has_base_uv = 0x08000000,
- AM_has_uv_1 = 0x04000000,
- AM_has_uv_2 = 0x02000000,
- AM_has_uv_3 = 0x01000000,
- AM_has_uv_4 = 0x00800000,
- AM_has_uv_5 = 0x00400000,
- AM_has_uv_6 = 0x00200000,
- AM_has_uv_7 = 0x00100000
- };
-
- typedef pvector Vertices;
- Vertices _vertices;
-
-public:
- virtual bool extract_record(FltRecordReader &reader);
- virtual bool build_record(FltRecordWriter &writer) const;
-
-public:
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- FltRecord::init_type();
- register_type(_type_handle, "FltLocalVertexPool",
- FltRecord::get_class_type());
- }
-
-private:
- static TypeHandle _type_handle;
-};
-
-#include "fltLocalVertexPool.I"
-
-#endif
diff --git a/pandatool/src/flt/fltMaterial.cxx b/pandatool/src/flt/fltMaterial.cxx
deleted file mode 100644
index 81411696..00000000
--- a/pandatool/src/flt/fltMaterial.cxx
+++ /dev/null
@@ -1,164 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltMaterial.cxx
- * @author drose
- * @date 2000-08-25
- */
-
-#include "fltMaterial.h"
-#include "fltRecordReader.h"
-#include "fltRecordWriter.h"
-
-TypeHandle FltMaterial::_type_handle;
-
-/**
- *
- */
-FltMaterial::
-FltMaterial(FltHeader *header) : FltRecord(header) {
- _material_index = -1;
- _flags = 0;
- _ambient.set(0.0, 0.0, 0.0);
- _diffuse.set(0.0, 0.0, 0.0);
- _specular.set(0.0, 0.0, 0.0);
- _emissive.set(0.0, 0.0, 0.0);
- _shininess = 0.0;
- _alpha = 1.0;
-}
-
-/**
- * Fills in the information in this record based on the information given in
- * the indicated datagram, whose opcode has already been read. Returns true
- * on success, false if the datagram is invalid.
- */
-bool FltMaterial::
-extract_record(FltRecordReader &reader) {
- if (!FltRecord::extract_record(reader)) {
- return false;
- }
-
- nassertr(reader.get_opcode() == FO_15_material, false);
- DatagramIterator &iterator = reader.get_iterator();
-
- _material_index = iterator.get_be_int32();
- _material_name = iterator.get_fixed_string(12);
- _flags = iterator.get_be_uint32();
- _ambient[0] = iterator.get_be_float32();
- _ambient[1] = iterator.get_be_float32();
- _ambient[2] = iterator.get_be_float32();
- _diffuse[0] = iterator.get_be_float32();
- _diffuse[1] = iterator.get_be_float32();
- _diffuse[2] = iterator.get_be_float32();
- _specular[0] = iterator.get_be_float32();
- _specular[1] = iterator.get_be_float32();
- _specular[2] = iterator.get_be_float32();
- _emissive[0] = iterator.get_be_float32();
- _emissive[1] = iterator.get_be_float32();
- _emissive[2] = iterator.get_be_float32();
- _shininess = iterator.get_be_float32();
- _alpha = iterator.get_be_float32();
- iterator.skip_bytes(4);
-
- check_remaining_size(iterator);
- return true;
-}
-
-/**
- * Fills up the current record on the FltRecordWriter with data for this
- * record, but does not advance the writer. Returns true on success, false if
- * there is some error.
- */
-bool FltMaterial::
-build_record(FltRecordWriter &writer) const {
- if (!FltRecord::build_record(writer)) {
- return false;
- }
-
- writer.set_opcode(FO_15_material);
- Datagram &datagram = writer.update_datagram();
-
- datagram.add_be_int32(_material_index);
- datagram.add_fixed_string(_material_name, 12);
- datagram.add_be_uint32(_flags);
- datagram.add_be_float32(_ambient[0]);
- datagram.add_be_float32(_ambient[1]);
- datagram.add_be_float32(_ambient[2]);
- datagram.add_be_float32(_diffuse[0]);
- datagram.add_be_float32(_diffuse[1]);
- datagram.add_be_float32(_diffuse[2]);
- datagram.add_be_float32(_specular[0]);
- datagram.add_be_float32(_specular[1]);
- datagram.add_be_float32(_specular[2]);
- datagram.add_be_float32(_emissive[0]);
- datagram.add_be_float32(_emissive[1]);
- datagram.add_be_float32(_emissive[2]);
- datagram.add_be_float32(_shininess);
- datagram.add_be_float32(_alpha);
- datagram.pad_bytes(4);
-
- return true;
-}
-
-/**
- * Fills in the information in this record based on the information from the
- * current position within the v14 material palette. Leaves the iterator at
- * the beginning of the next material.
- */
-bool FltMaterial::
-extract_14_record(int index, DatagramIterator &di) {
- _material_index = index;
-
- _ambient[0] = di.get_be_float32();
- _ambient[1] = di.get_be_float32();
- _ambient[2] = di.get_be_float32();
- _diffuse[0] = di.get_be_float32();
- _diffuse[1] = di.get_be_float32();
- _diffuse[2] = di.get_be_float32();
- _specular[0] = di.get_be_float32();
- _specular[1] = di.get_be_float32();
- _specular[2] = di.get_be_float32();
- _emissive[0] = di.get_be_float32();
- _emissive[1] = di.get_be_float32();
- _emissive[2] = di.get_be_float32();
- _shininess = di.get_be_float32();
- _alpha = di.get_be_float32();
- _flags = di.get_be_uint32();
- _material_name = di.get_fixed_string(12);
- di.skip_bytes(4 * 28);
-
- return true;
-}
-
-/**
- * Fills up the current record on the FltRecordWriter with data for this
- * record, formatted as a part of a v14 material palette. Returns true on
- * success, false if there is some error.
- */
-bool FltMaterial::
-build_14_record(Datagram &datagram) {
- datagram.add_be_float32(_ambient[0]);
- datagram.add_be_float32(_ambient[1]);
- datagram.add_be_float32(_ambient[2]);
- datagram.add_be_float32(_diffuse[0]);
- datagram.add_be_float32(_diffuse[1]);
- datagram.add_be_float32(_diffuse[2]);
- datagram.add_be_float32(_specular[0]);
- datagram.add_be_float32(_specular[1]);
- datagram.add_be_float32(_specular[2]);
- datagram.add_be_float32(_emissive[0]);
- datagram.add_be_float32(_emissive[1]);
- datagram.add_be_float32(_emissive[2]);
- datagram.add_be_float32(_shininess);
- datagram.add_be_float32(_alpha);
- datagram.add_be_uint32(_flags);
- datagram.add_fixed_string(_material_name, 12);
- datagram.pad_bytes(4 * 28);
-
- return true;
-}
diff --git a/pandatool/src/flt/fltMaterial.h b/pandatool/src/flt/fltMaterial.h
deleted file mode 100644
index fadc3acc..00000000
--- a/pandatool/src/flt/fltMaterial.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltMaterial.h
- * @author drose
- * @date 2000-08-25
- */
-
-#ifndef FLTMATERIAL_H
-#define FLTMATERIAL_H
-
-#include "pandatoolbase.h"
-
-#include "fltRecord.h"
-
-#include "luse.h"
-
-class DatagramIterator;
-
-/**
- * Represents a single material in the material palette.
- */
-class FltMaterial : public FltRecord {
-public:
- FltMaterial(FltHeader *header);
-
- enum Flags {
- F_materials_used = 0x80000000,
- };
-
- int _material_index;
- std::string _material_name;
- unsigned int _flags;
- LRGBColor _ambient;
- LRGBColor _diffuse;
- LRGBColor _specular;
- LRGBColor _emissive;
- PN_stdfloat _shininess;
- PN_stdfloat _alpha;
-
-protected:
- virtual bool extract_record(FltRecordReader &reader);
- virtual bool build_record(FltRecordWriter &writer) const;
-
-public:
- bool extract_14_record(int index, DatagramIterator &di);
- bool build_14_record(Datagram &datagram);
-
-public:
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- FltRecord::init_type();
- register_type(_type_handle, "FltMaterial",
- FltRecord::get_class_type());
- }
-
-private:
- static TypeHandle _type_handle;
-
- friend class FltHeader;
-};
-
-#endif
diff --git a/pandatool/src/flt/fltMesh.I b/pandatool/src/flt/fltMesh.I
deleted file mode 100644
index d1d9c0de..00000000
--- a/pandatool/src/flt/fltMesh.I
+++ /dev/null
@@ -1,12 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltMesh.I
- * @author drose
- * @date 2001-02-28
- */
diff --git a/pandatool/src/flt/fltMesh.cxx b/pandatool/src/flt/fltMesh.cxx
deleted file mode 100644
index e77b8636..00000000
--- a/pandatool/src/flt/fltMesh.cxx
+++ /dev/null
@@ -1,110 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltMesh.cxx
- * @author drose
- * @date 2001-02-28
- */
-
-#include "fltMesh.h"
-#include "fltRecordReader.h"
-#include "fltRecordWriter.h"
-#include "fltHeader.h"
-#include "fltMaterial.h"
-#include "config_flt.h"
-
-TypeHandle FltMesh::_type_handle;
-
-/**
- *
- */
-FltMesh::
-FltMesh(FltHeader *header) : FltGeometry(header) {
-}
-
-/**
- * Fills in the information in this bead based on the information given in the
- * indicated datagram, whose opcode has already been read. Returns true on
- * success, false if the datagram is invalid.
- */
-bool FltMesh::
-extract_record(FltRecordReader &reader) {
- if (!FltBeadID::extract_record(reader)) {
- return false;
- }
-
- DatagramIterator &iterator = reader.get_iterator();
- iterator.skip_bytes(4); // Undocumented padding.
-
- if (!FltGeometry::extract_record(reader)) {
- return false;
- }
-
- nassertr(reader.get_opcode() == FO_mesh, false);
-
- check_remaining_size(iterator);
- return true;
-}
-
-/**
- * Checks whether the given bead, which follows this bead sequentially in the
- * file, is an ancillary record of this bead. If it is, extracts the relevant
- * information and returns true; otherwise, leaves it alone and returns false.
- */
-bool FltMesh::
-extract_ancillary(FltRecordReader &reader) {
- if (reader.get_opcode() == FO_local_vertex_pool) {
- _vpool = new FltLocalVertexPool(_header);
- return _vpool->extract_record(reader);
- }
-
- return FltBeadID::extract_ancillary(reader);
-}
-
-/**
- * Fills up the current record on the FltRecordWriter with data for this
- * record, but does not advance the writer. Returns true on success, false if
- * there is some error.
- */
-bool FltMesh::
-build_record(FltRecordWriter &writer) const {
- if (!FltBeadID::build_record(writer)) {
- return false;
- }
-
- Datagram &datagram = writer.update_datagram();
- datagram.pad_bytes(4); // Undocumented padding.
-
- if (!FltGeometry::build_record(writer)) {
- return false;
- }
-
- writer.set_opcode(FO_mesh);
-
- return true;
-}
-
-/**
- * Writes whatever ancillary records are required for this record. Returns
- * FE_ok on success, or something else if there is some error.
- */
-FltError FltMesh::
-write_ancillary(FltRecordWriter &writer) const {
- if (_vpool != nullptr) {
- if (!_vpool->build_record(writer)) {
- assert(!flt_error_abort);
- return FE_bad_data;
- }
- FltError result = writer.advance();
- if (result != FE_ok) {
- return result;
- }
- }
-
- return FltBeadID::write_ancillary(writer);
-}
diff --git a/pandatool/src/flt/fltMesh.h b/pandatool/src/flt/fltMesh.h
deleted file mode 100644
index a66bdf62..00000000
--- a/pandatool/src/flt/fltMesh.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltMesh.h
- * @author drose
- * @date 2001-02-28
- */
-
-#ifndef FLTMESH_H
-#define FLTMESH_H
-
-#include "pandatoolbase.h"
-
-#include "fltGeometry.h"
-#include "fltLocalVertexPool.h"
-
-#include "pointerTo.h"
-
-/**
- * A mesh of connected polygons and tristrips, etc., with a local vertex pool.
- */
-class FltMesh : public FltGeometry {
-public:
- FltMesh(FltHeader *header);
-
- PT(FltLocalVertexPool) _vpool;
-
-protected:
- virtual bool extract_record(FltRecordReader &reader);
- virtual bool extract_ancillary(FltRecordReader &reader);
-
- virtual bool build_record(FltRecordWriter &writer) const;
- virtual FltError write_ancillary(FltRecordWriter &writer) const;
-
-public:
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- FltGeometry::init_type();
- register_type(_type_handle, "FltMesh",
- FltGeometry::get_class_type());
- }
-
-private:
- static TypeHandle _type_handle;
-};
-
-#include "fltMesh.I"
-
-#endif
diff --git a/pandatool/src/flt/fltMeshPrimitive.I b/pandatool/src/flt/fltMeshPrimitive.I
deleted file mode 100644
index 70923ab8..00000000
--- a/pandatool/src/flt/fltMeshPrimitive.I
+++ /dev/null
@@ -1,12 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltMeshPrimitive.I
- * @author drose
- * @date 2001-02-28
- */
diff --git a/pandatool/src/flt/fltMeshPrimitive.cxx b/pandatool/src/flt/fltMeshPrimitive.cxx
deleted file mode 100644
index 6db78c80..00000000
--- a/pandatool/src/flt/fltMeshPrimitive.cxx
+++ /dev/null
@@ -1,126 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltMeshPrimitive.cxx
- * @author drose
- * @date 2001-02-28
- */
-
-#include "fltMeshPrimitive.h"
-#include "fltRecordReader.h"
-#include "fltRecordWriter.h"
-#include "fltHeader.h"
-#include "fltMaterial.h"
-
-TypeHandle FltMeshPrimitive::_type_handle;
-
-/**
- *
- */
-FltMeshPrimitive::
-FltMeshPrimitive(FltHeader *header) : FltBead(header) {
- _primitive_type = PT_tristrip;
-}
-
-/**
- * Fills in the information in this bead based on the information given in the
- * indicated datagram, whose opcode has already been read. Returns true on
- * success, false if the datagram is invalid.
- */
-bool FltMeshPrimitive::
-extract_record(FltRecordReader &reader) {
- if (!FltBead::extract_record(reader)) {
- return false;
- }
-
- nassertr(reader.get_opcode() == FO_mesh_primitive, false);
- DatagramIterator &iterator = reader.get_iterator();
-
- _primitive_type = (PrimitiveType)iterator.get_be_int16();
-
- int vertex_width = iterator.get_be_int16();
- int num_vertices = iterator.get_be_int32();
-
- if (vertex_width == 1) {
- for (int i = 0; i < num_vertices; i++) {
- _vertices.push_back(iterator.get_uint8());
- }
-
- } else if (vertex_width == 2) {
- for (int i = 0; i < num_vertices; i++) {
- _vertices.push_back(iterator.get_be_uint16());
- }
-
- } else if (vertex_width == 4) {
- for (int i = 0; i < num_vertices; i++) {
- _vertices.push_back(iterator.get_be_int32());
- }
-
- } else {
- nout << "Invalid vertex width in mesh primitive: " << vertex_width
- << "\n";
- return false;
- }
-
- check_remaining_size(iterator);
- return true;
-}
-
-/**
- * Fills up the current record on the FltRecordWriter with data for this
- * record, but does not advance the writer. Returns true on success, false if
- * there is some error.
- */
-bool FltMeshPrimitive::
-build_record(FltRecordWriter &writer) const {
- if (!FltBead::build_record(writer)) {
- return false;
- }
-
- writer.set_opcode(FO_mesh_primitive);
- Datagram &datagram = writer.update_datagram();
-
- datagram.add_be_int16(_primitive_type);
-
- // Determine the optimum index width, based on the largest vertex index.
- int max_index = 0;
- Vertices::const_iterator vi;
- for (vi = _vertices.begin(); vi != _vertices.end(); ++vi) {
- max_index = std::max(max_index, (*vi));
- }
-
- int vertex_width;
- if (max_index < 0x100) {
- vertex_width = 1;
- } else if (max_index < 0x10000) {
- vertex_width = 2;
- } else {
- vertex_width = 4;
- }
-
- datagram.add_be_int16(vertex_width);
- datagram.add_be_int32(_vertices.size());
-
- if (vertex_width == 1) {
- for (vi = _vertices.begin(); vi != _vertices.end(); ++vi) {
- datagram.add_uint8(*vi);
- }
-
- } else if (vertex_width == 2) {
- for (vi = _vertices.begin(); vi != _vertices.end(); ++vi) {
- datagram.add_be_uint16(*vi);
- }
-
- } else {
- for (vi = _vertices.begin(); vi != _vertices.end(); ++vi) {
- datagram.add_be_int32(*vi);
- }
- }
-
- return true;
-}
diff --git a/pandatool/src/flt/fltMeshPrimitive.h b/pandatool/src/flt/fltMeshPrimitive.h
deleted file mode 100644
index bca21cc4..00000000
--- a/pandatool/src/flt/fltMeshPrimitive.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltMeshPrimitive.h
- * @author drose
- * @date 2001-02-28
- */
-
-#ifndef FLTMESHPRIMITIVE_H
-#define FLTMESHPRIMITIVE_H
-
-#include "pandatoolbase.h"
-
-#include "fltBead.h"
-#include "fltHeader.h"
-
-#include "luse.h"
-#include "vector_int.h"
-
-/**
- * A single primitive of a mesh, like a triangle strip or fan.
- */
-class FltMeshPrimitive : public FltBead {
-public:
- FltMeshPrimitive(FltHeader *header);
-
- enum PrimitiveType {
- PT_tristrip = 1,
- PT_trifan = 2,
- PT_quadstrip = 3,
- PT_polygon = 4,
- };
-
- typedef vector_int Vertices;
-
- PrimitiveType _primitive_type;
- Vertices _vertices;
-
-
-protected:
- virtual bool extract_record(FltRecordReader &reader);
- virtual bool build_record(FltRecordWriter &writer) const;
-
-public:
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- FltBead::init_type();
- register_type(_type_handle, "FltMeshPrimitive",
- FltBead::get_class_type());
- }
-
-private:
- static TypeHandle _type_handle;
-};
-
-#include "fltMeshPrimitive.I"
-
-#endif
diff --git a/pandatool/src/flt/fltObject.cxx b/pandatool/src/flt/fltObject.cxx
deleted file mode 100644
index ce809741..00000000
--- a/pandatool/src/flt/fltObject.cxx
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltObject.cxx
- * @author drose
- * @date 2000-08-24
- */
-
-#include "fltObject.h"
-#include "fltRecordReader.h"
-#include "fltRecordWriter.h"
-
-TypeHandle FltObject::_type_handle;
-
-/**
- *
- */
-FltObject::
-FltObject(FltHeader *header) : FltBeadID(header) {
-}
-
-/**
- * Fills in the information in this bead based on the information given in the
- * indicated datagram, whose opcode has already been read. Returns true on
- * success, false if the datagram is invalid.
- */
-bool FltObject::
-extract_record(FltRecordReader &reader) {
- if (!FltBeadID::extract_record(reader)) {
- return false;
- }
-
- nassertr(reader.get_opcode() == FO_object, false);
- DatagramIterator &iterator = reader.get_iterator();
-
- _flags = iterator.get_be_uint32();
- _relative_priority = iterator.get_be_int16();
- _transparency = iterator.get_be_int16();
- _special_id1 = iterator.get_be_int16();
- _special_id2 = iterator.get_be_int16();
- _significance = iterator.get_be_int16();
- iterator.skip_bytes(2);
-
- check_remaining_size(iterator);
- return true;
-}
-
-/**
- * Fills up the current record on the FltRecordWriter with data for this
- * record, but does not advance the writer. Returns true on success, false if
- * there is some error.
- */
-bool FltObject::
-build_record(FltRecordWriter &writer) const {
- if (!FltBeadID::build_record(writer)) {
- return false;
- }
-
- writer.set_opcode(FO_object);
- Datagram &datagram = writer.update_datagram();
-
- datagram.add_be_uint32(_flags);
- datagram.add_be_int16(_relative_priority);
- datagram.add_be_int16(_transparency);
- datagram.add_be_int16(_special_id1);
- datagram.add_be_int16(_special_id2);
- datagram.add_be_int16(_significance);
- datagram.pad_bytes(2);
-
- return true;
-}
diff --git a/pandatool/src/flt/fltObject.h b/pandatool/src/flt/fltObject.h
deleted file mode 100644
index 35a77ce7..00000000
--- a/pandatool/src/flt/fltObject.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltObject.h
- * @author drose
- * @date 2000-08-24
- */
-
-#ifndef FLTOBJECT_H
-#define FLTOBJECT_H
-
-#include "pandatoolbase.h"
-
-#include "fltBeadID.h"
-
-/**
- * The main objecting bead of the flt file.
- */
-class FltObject : public FltBeadID {
-public:
- FltObject(FltHeader *header);
-
- enum Flags {
- F_no_daylight = 0x80000000,
- F_no_dusk = 0x40000000,
- F_no_night = 0x20000000,
- F_no_illuminate = 0x10000000,
- F_flat_shaded = 0x08000000,
- F_shadow_object = 0x04000000,
- };
-
- unsigned int _flags;
- int _relative_priority;
- int _transparency;
- int _special_id1, _special_id2;
- int _significance;
-
-protected:
- virtual bool extract_record(FltRecordReader &reader);
- virtual bool build_record(FltRecordWriter &writer) const;
-
-public:
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- FltBeadID::init_type();
- register_type(_type_handle, "FltObject",
- FltBeadID::get_class_type());
- }
-
-private:
- static TypeHandle _type_handle;
-};
-
-#endif
diff --git a/pandatool/src/flt/fltOpcode.cxx b/pandatool/src/flt/fltOpcode.cxx
deleted file mode 100644
index 92fd64af..00000000
--- a/pandatool/src/flt/fltOpcode.cxx
+++ /dev/null
@@ -1,297 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltOpcode.cxx
- * @author drose
- * @date 2000-08-24
- */
-
-#include "fltOpcode.h"
-
-std::ostream &
-operator << (std::ostream &out, FltOpcode opcode) {
- switch (opcode) {
- case FO_none:
- return out << "null opcode";
-
- case FO_header:
- return out << "header";
-
- case FO_group:
- return out << "group";
-
- case FO_OB_scale:
- case FO_OB_scale2:
- case FO_OB_scale3:
- return out << "(obsolete) scale";
-
- case FO_object:
- return out << "object";
-
- case FO_face:
- return out << "face";
-
- case FO_OB_vertex_i:
- return out << "(obsolete) vertex with ID";
-
- case FO_OB_short_vertex:
- return out << "(obsolete) short vertex";
-
- case FO_OB_vertex_c:
- return out << "(obsolete) vertex with color";
-
- case FO_OB_vertex_cn:
- return out << "(obsolete) vertex with color and normal";
-
- case FO_push:
- return out << "push";
-
- case FO_pop:
- return out << "pop";
-
- case FO_OB_translate:
- case FO_OB_translate2:
- case FO_OB_translate3:
- return out << "(obsolete) translate";
-
- case FO_OB_dof:
- return out << "(obsolete) degree-of-freedom";
-
- case FO_dof:
- return out << "degree-of-freedom";
-
- case FO_OB_instance_ref:
- return out << "(obsolete) instance reference";
-
- case FO_OB_instance:
- return out << "(obsolete) instance definition";
-
- case FO_push_face:
- return out << "push subface";
-
- case FO_pop_face:
- return out << "pop subface";
-
- case FO_push_extension:
- return out << "push extension";
-
- case FO_pop_extension:
- return out << "pop extension";
-
- case FO_continuation:
- return out << "continuation";
-
- case FO_comment:
- return out << "comment";
-
- case FO_color_palette:
- return out << "color palette";
-
- case FO_long_id:
- return out << "long ID";
-
- case FO_transform_matrix:
- return out << "transformation matrix";
-
- case FO_OB_rotate_point:
- case FO_OB_rotate_point2:
- return out << "(obsolete) rotate about point";
-
- case FO_OB_rotate_edge:
- return out << "(obsolete) rotate about edge";
-
- case FO_OB_nu_scale:
- return out << "(obsolete) non-uniform scale";
-
- case FO_OB_rotate_to_point:
- return out << "(obsolete) rotate to point";
-
- case FO_OB_put:
- return out << "(obsolete) put";
-
- case FO_OB_bounding_box:
- return out << "(obsolete) bounding box";
-
- case FO_vector:
- return out << "vector";
-
- case FO_multitexture:
- return out << "multitexture";
-
- case FO_uv_list:
- return out << "UV list";
-
- case FO_bsp:
- return out << "BSP";
-
- case FO_replicate:
- return out << "replicate";
-
- case FO_instance_ref:
- return out << "instance reference";
-
- case FO_instance:
- return out << "instance definition";
-
- case FO_external_ref:
- return out << "external reference";
-
- case FO_texture:
- return out << "texture";
-
- case FO_OB_eyepoint_palette:
- return out << "(obsolete) eyepoint palette";
-
- case FO_14_material_palette:
- return out << "v14 material palette";
-
- case FO_vertex_palette:
- return out << "vertex palette";
-
- case FO_vertex_c:
- return out << "vertex with color";
-
- case FO_vertex_cn:
- return out << "vertex with color and normal";
-
- case FO_vertex_cnu:
- return out << "vertex with color, normal, and uv";
-
- case FO_vertex_cu:
- return out << "vertex with color and uv";
-
- case FO_vertex_list:
- return out << "vertex list";
-
- case FO_lod:
- return out << "LOD";
-
- case FO_bounding_box:
- return out << "bounding box";
-
- case FO_rotate_about_edge:
- return out << "rotate about edge";
-
- case FO_translate:
- return out << "translate";
-
- case FO_scale:
- return out << "scale";
-
- case FO_rotate_about_point:
- return out << "rotate about point";
-
- case FO_rotate_and_scale:
- return out << "rotate and/or scale";
-
- case FO_put:
- return out << "put";
-
- case FO_eyepoint_palette:
- return out << "eyepoint palette";
-
- case FO_mesh:
- return out << "mesh";
-
- case FO_local_vertex_pool:
- return out << "local vertex pool";
-
- case FO_mesh_primitive:
- return out << "mesh primitive";
-
- case FO_road_segment:
- return out << "road segment";
-
- case FO_road_zone:
- return out << "road zone";
-
- case FO_morph_list:
- return out << "morph vertex list";
-
- case FO_behavior_palette:
- return out << "behavior palette";
-
- case FO_sound:
- return out << "sound";
-
- case FO_road_path:
- return out << "road path";
-
- case FO_sound_palette:
- return out << "sound palette";
-
- case FO_general_matrix:
- return out << "general matrix";
-
- case FO_text:
- return out << "text";
-
- case FO_switch:
- return out << "switch";
-
- case FO_line_style:
- return out << "line style";
-
- case FO_clip_region:
- return out << "clip region";
-
- case FO_light_source:
- return out << "light source";
-
- case FO_light_definition:
- return out << "light source definition";
-
- case FO_bounding_sphere:
- return out << "bounding sphere";
-
- case FO_bounding_cylinder:
- return out << "bounding cylinder";
-
- case FO_bv_center:
- return out << "bounding volume center";
-
- case FO_bv_orientation:
- return out << "bounding volume orientation";
-
- case FO_light_point:
- return out << "light point";
-
- case FO_texture_map_palette:
- return out << "texture mapping palette";
-
- case FO_15_material:
- return out << "material";
-
- case FO_name_table:
- return out << "name table";
-
- case FO_cat:
- return out << "continuously adaptive terrain";
-
- case FO_cat_data:
- return out << "CAT Data";
-
- case FO_push_attribute:
- return out << "push attribute";
-
- case FO_pop_attribute:
- return out << "pop attribute";
-
- case FO_adaptive_attribute:
- return out << "adaptive attribute";
-
- case FO_curve:
- return out << "curve";
-
- case FO_road_construction:
- return out << "road construction";
-
- default:
- return out << "unknown opcode " << (int)opcode;
- }
-}
diff --git a/pandatool/src/flt/fltOpcode.h b/pandatool/src/flt/fltOpcode.h
deleted file mode 100644
index f9bbeb9e..00000000
--- a/pandatool/src/flt/fltOpcode.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltOpcode.h
- * @author drose
- * @date 2000-08-24
- */
-
-#ifndef FLTOPCODE_H
-#define FLTOPCODE_H
-
-#include "pandatoolbase.h"
-
-// Known opcodes, as of the latest version of flt.
-enum FltOpcode {
- FO_none = 0,
- FO_header = 1,
- FO_group = 2,
- FO_OB_scale = 3, // obsolete
- FO_object = 4,
- FO_face = 5,
- FO_OB_vertex_i = 6, // obsolete
- FO_OB_short_vertex = 7, // obsolete
- FO_OB_vertex_c = 8, // obsolete
- FO_OB_vertex_cn = 9, // obsolete
- FO_push = 10,
- FO_pop = 11,
- FO_OB_translate = 12, // obsolete
- FO_OB_dof = 13, // obsolete
- FO_dof = 14,
- FO_OB_instance_ref = 16, // obsolete
- FO_OB_instance = 17, // obsolete
- FO_push_face = 19,
- FO_pop_face = 20,
- FO_push_extension = 21,
- FO_pop_extension = 22,
- FO_continuation = 23,
-
- FO_comment = 31,
- FO_color_palette = 32,
- FO_long_id = 33,
- FO_OB_translate2 = 40, // obsolete
- FO_OB_rotate_point = 41, // obsolete
- FO_OB_rotate_edge = 42, // obsolete
- FO_OB_scale2 = 43, // obsolete
- FO_OB_translate3 = 44, // obsolete
- FO_OB_nu_scale = 45, // obsolete
- FO_OB_rotate_point2 = 46, // obsolete
- FO_OB_rotate_to_point = 47, // obsolete
- FO_OB_put = 48, // obsolete
- FO_transform_matrix = 49,
- FO_vector = 50,
- FO_OB_bounding_box = 51, // obsolete
- FO_multitexture = 52,
- FO_uv_list = 53,
- FO_bsp = 55,
- FO_replicate = 60,
- FO_instance_ref = 61,
- FO_instance = 62,
- FO_external_ref = 63,
- FO_texture = 64,
- FO_OB_eyepoint_palette = 65, // obsolete
- FO_14_material_palette = 66,
- FO_vertex_palette = 67,
- FO_vertex_c = 68,
- FO_vertex_cn = 69,
- FO_vertex_cnu = 70,
- FO_vertex_cu = 71,
- FO_vertex_list = 72,
- FO_lod = 73,
- FO_bounding_box = 74,
- FO_rotate_about_edge = 76,
- FO_OB_scale3 = 77, // obsolete
- FO_translate = 78,
- FO_scale = 79,
- FO_rotate_about_point = 80,
- FO_rotate_and_scale = 81,
- FO_put = 82,
- FO_eyepoint_palette = 83,
- FO_mesh = 84,
- FO_local_vertex_pool = 85,
- FO_mesh_primitive = 86,
- FO_road_segment = 87,
- FO_road_zone = 88,
- FO_morph_list = 89,
- FO_behavior_palette = 90,
- FO_sound = 91,
- FO_road_path = 92,
- FO_sound_palette = 93,
- FO_general_matrix = 94,
- FO_text = 95,
- FO_switch = 96,
- FO_line_style = 97,
- FO_clip_region = 98,
- FO_extension = 100,
- FO_light_source = 101,
- FO_light_definition = 102,
- FO_bounding_sphere = 105,
- FO_bounding_cylinder = 106,
- FO_bv_center = 108,
- FO_bv_orientation = 109,
- FO_light_point = 111,
- FO_texture_map_palette = 112,
- FO_15_material = 113,
- FO_name_table = 114,
- FO_cat = 115,
- FO_cat_data = 116,
- FO_push_attribute = 122,
- FO_pop_attribute = 123,
- FO_adaptive_attribute = 125,
- FO_curve = 126,
- FO_road_construction = 127
-};
-
-std::ostream &operator << (std::ostream &out, FltOpcode opcode);
-
-#endif
diff --git a/pandatool/src/flt/fltPackedColor.I b/pandatool/src/flt/fltPackedColor.I
deleted file mode 100644
index 50ae5906..00000000
--- a/pandatool/src/flt/fltPackedColor.I
+++ /dev/null
@@ -1,72 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltPackedColor.I
- * @author drose
- * @date 2000-08-25
- */
-
-INLINE std::ostream &
-operator << (std::ostream &out, const FltPackedColor &color) {
- color.output(out);
- return out;
-}
-
-
-/**
- *
- */
-INLINE FltPackedColor::
-FltPackedColor() {
- _a = 0;
- _b = 0;
- _g = 0;
- _r = 0;
-}
-
-/**
- * Returns the four-component color as a LColor, where each component is in
- * the range [0, 1].
- */
-INLINE LColor FltPackedColor::
-get_color() const {
- return LColor(_r / 255.0, _g / 255.0, _b / 255.0, _a / 255.0);
-}
-
-/**
- * Returns the three-component color as an LRGBColor (ignoring the alpha
- * component), where each component is in the range [0, 1].
- */
-INLINE LRGBColor FltPackedColor::
-get_rgb() const {
- return LRGBColor(_r / 255.0, _g / 255.0, _b / 255.0);
-}
-
-/**
- * Sets the color according to the indicated four-component LColor value
- * (including alpha).
- */
-INLINE void FltPackedColor::
-set_color(const LColor &color) {
- _r = (int)floor(color[0] * 255.0);
- _g = (int)floor(color[1] * 255.0);
- _b = (int)floor(color[2] * 255.0);
- _a = (int)floor(color[3] * 255.0);
-}
-
-/**
- * Sets the color according to the indicated three-component LRGBColor value,
- * and set the alpha to 1.0.
- */
-INLINE void FltPackedColor::
-set_rgb(const LRGBColor &color) {
- _r = (int)floor(color[0] * 255.0);
- _g = (int)floor(color[1] * 255.0);
- _b = (int)floor(color[2] * 255.0);
- _a = 255;
-}
diff --git a/pandatool/src/flt/fltPackedColor.cxx b/pandatool/src/flt/fltPackedColor.cxx
deleted file mode 100644
index 0faa4eb6..00000000
--- a/pandatool/src/flt/fltPackedColor.cxx
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltPackedColor.cxx
- * @author drose
- * @date 2000-08-25
- */
-
-#include "fltPackedColor.h"
-#include "fltRecordReader.h"
-#include "fltRecordWriter.h"
-
-/**
- *
- */
-void FltPackedColor::
-output(std::ostream &out) const {
- out << "(" << _r << " " << _g << " " << _b << " " << _a << ")";
-}
-
-/**
- *
- */
-bool FltPackedColor::
-extract_record(FltRecordReader &reader) {
- DatagramIterator &iterator = reader.get_iterator();
-
- _a = iterator.get_uint8();
- _b = iterator.get_uint8();
- _g = iterator.get_uint8();
- _r = iterator.get_uint8();
-
- return true;
-}
-
-/**
- *
- */
-bool FltPackedColor::
-build_record(FltRecordWriter &writer) const {
- Datagram &datagram = writer.update_datagram();
-
- datagram.add_uint8(_a);
- datagram.add_uint8(_b);
- datagram.add_uint8(_g);
- datagram.add_uint8(_r);
-
- return true;
-}
diff --git a/pandatool/src/flt/fltPackedColor.h b/pandatool/src/flt/fltPackedColor.h
deleted file mode 100644
index 1e38e02b..00000000
--- a/pandatool/src/flt/fltPackedColor.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltPackedColor.h
- * @author drose
- * @date 2000-08-25
- */
-
-#ifndef FLTPACKEDCOLOR_H
-#define FLTPACKEDCOLOR_H
-
-#include "pandatoolbase.h"
-
-#include "luse.h"
-#include
-
-class FltRecordReader;
-class FltRecordWriter;
-
-/**
- * A packed color record, A, B, G, R. This appears, for instance, within a
- * face bead.
- */
-class FltPackedColor {
-public:
- INLINE FltPackedColor();
-
- INLINE LColor get_color() const;
- INLINE LRGBColor get_rgb() const;
- INLINE void set_color(const LColor &color);
- INLINE void set_rgb(const LRGBColor &rgb);
-
- void output(std::ostream &out) const;
- bool extract_record(FltRecordReader &reader);
- bool build_record(FltRecordWriter &writer) const;
-
-public:
- int _a;
- int _b;
- int _g;
- int _r;
-};
-
-INLINE std::ostream &operator << (std::ostream &out, const FltPackedColor &color);
-
-#include "fltPackedColor.I"
-
-#endif
diff --git a/pandatool/src/flt/fltRecord.I b/pandatool/src/flt/fltRecord.I
deleted file mode 100644
index add78f2d..00000000
--- a/pandatool/src/flt/fltRecord.I
+++ /dev/null
@@ -1,18 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltRecord.I
- * @author drose
- * @date 2000-08-24
- */
-
-INLINE std::ostream &
-operator << (std::ostream &out, const FltRecord &record) {
- record.output(out);
- return out;
-}
diff --git a/pandatool/src/flt/fltRecord.cxx b/pandatool/src/flt/fltRecord.cxx
deleted file mode 100644
index 9fcc52fc..00000000
--- a/pandatool/src/flt/fltRecord.cxx
+++ /dev/null
@@ -1,746 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltRecord.cxx
- * @author drose
- * @date 2000-08-24
- */
-
-#include "fltRecord.h"
-#include "fltRecordReader.h"
-#include "fltRecordWriter.h"
-#include "fltHeader.h"
-#include "fltGroup.h"
-#include "fltObject.h"
-#include "fltFace.h"
-#include "fltCurve.h"
-#include "fltMesh.h"
-#include "fltLocalVertexPool.h"
-#include "fltMeshPrimitive.h"
-#include "fltVertexList.h"
-#include "fltLOD.h"
-#include "fltInstanceDefinition.h"
-#include "fltInstanceRef.h"
-#include "fltUnsupportedRecord.h"
-#include "fltExternalReference.h"
-#include "fltVectorRecord.h"
-#include "config_flt.h"
-
-#include "dcast.h"
-#include "indent.h"
-#include "datagramIterator.h"
-
-#include
-
-TypeHandle FltRecord::_type_handle;
-
-/**
- *
- */
-FltRecord::
-FltRecord(FltHeader *header) :
- _header(header)
-{
-}
-
-/**
- *
- */
-FltRecord::
-~FltRecord() {
-}
-
-/**
- * Returns the number of child records of this record. This reflects the
- * normal scene graph hierarchy.
- */
-int FltRecord::
-get_num_children() const {
- return _children.size();
-}
-
-/**
- * Returns the nth child of this record.
- */
-FltRecord *FltRecord::
-get_child(int n) const {
- nassertr(n >= 0 && n < (int)_children.size(), nullptr);
- return _children[n];
-}
-
-/**
- * Removes all children from this record.
- */
-void FltRecord::
-clear_children() {
- _children.clear();
-}
-
-/**
- * Adds a new child to the end of the list of children for this record.
- */
-void FltRecord::
-add_child(FltRecord *child) {
- _children.push_back(child);
-}
-
-/**
- * Returns the number of subface records of this record. Normally, subfaces
- * will only be present on object records, although it is logically possible
- * for them to appear anywhere.
- */
-int FltRecord::
-get_num_subfaces() const {
- return _subfaces.size();
-}
-
-/**
- * Returns the nth subface of this record.
- */
-FltRecord *FltRecord::
-get_subface(int n) const {
- nassertr(n >= 0 && n < (int)_subfaces.size(), nullptr);
- return _subfaces[n];
-}
-
-/**
- * Removes all subfaces from this record.
- */
-void FltRecord::
-clear_subfaces() {
- _subfaces.clear();
-}
-
-/**
- * Adds a new subface to the end of the list of subfaces for this record.
- */
-void FltRecord::
-add_subface(FltRecord *subface) {
- _subfaces.push_back(subface);
-}
-
-/**
- * Returns the number of extension attribute records for this object. These
- * are auxiliary nodes, presumably of type FO_extension, that have some local
- * meaning to the object.
- */
-int FltRecord::
-get_num_extensions() const {
- return _extensions.size();
-}
-
-/**
- * Returns the nth extension of this record.
- */
-FltRecord *FltRecord::
-get_extension(int n) const {
- nassertr(n >= 0 && n < (int)_extensions.size(), nullptr);
- return _extensions[n];
-}
-
-/**
- * Removes all extensions from this record.
- */
-void FltRecord::
-clear_extensions() {
- _extensions.clear();
-}
-
-/**
- * Adds a new extension to the end of the list of extensions for this record.
- * This should be a record of type FO_extension.
- */
-void FltRecord::
-add_extension(FltRecord *extension) {
- _extensions.push_back(extension);
-}
-
-/**
- * Returns the number of unsupported ancillary records of this record. These
- * are ancillary records that appeared following this record in the flt file
- * but that aren't directly understood by the flt loader--normally, an
- * ancillary record is examined and decoded on the spot, and no pointer to it
- * is kept.
- */
-int FltRecord::
-get_num_ancillary() const {
- return _ancillary.size();
-}
-
-/**
- * Returns the nth unsupported ancillary record of this record. See
- * get_num_ancillary().
- */
-FltRecord *FltRecord::
-get_ancillary(int n) const {
- nassertr(n >= 0 && n < (int)_ancillary.size(), nullptr);
- return _ancillary[n];
-}
-
-/**
- * Removes all unsupported ancillary records from this record. See
- * get_num_ancillary().
- */
-void FltRecord::
-clear_ancillary() {
- _ancillary.clear();
-}
-
-/**
- * Adds a new unsupported ancillary record to the end of the list of ancillary
- * records for this record. This record will be written to the flt file
- * following this record, without attempting to understand what is in it.
- *
- * Normally, there is no reason to use this function; if the data stored in
- * the FltRecord requires one or more ancillary record, the appropriate
- * records will automatically be generated when the record is written. This
- * function is only required to output a record whose type is not supported by
- * the flt loader. But it would be better to extend the flt loader to know
- * about this new kind of data record.
- */
-void FltRecord::
-add_ancillary(FltRecord *ancillary) {
- _ancillary.push_back(ancillary);
-}
-
-/**
- * Returns true if this record has a nonempty comment, false otherwise.
- */
-bool FltRecord::
-has_comment() const {
- return !_comment.empty();
-}
-
-/**
- * Retrieves the comment for this record, or empty string if the record has no
- * comment.
- */
-const std::string &FltRecord::
-get_comment() const {
- return _comment;
-}
-
-/**
- * Removes the comment for this record.
- */
-void FltRecord::
-clear_comment() {
- _comment = "";
-}
-
-/**
- * Changes the comment for this record.
- */
-void FltRecord::
-set_comment(const std::string &comment) {
- _comment = comment;
-}
-
-/**
- * Checks that the iterator has no bytes left, as it should at the end of a
- * successfully read record. If there *are* remaining bytes, print a warning
- * message but otherwise don't worry about it.
- *
- * If we are attempting to read a flt file whose version is newer than the
- * newest this program understands, don't even print a warning message, since
- * this is exactly the sort of thing we expect.
- */
-void FltRecord::
-check_remaining_size(const DatagramIterator &di, const std::string &name) const {
- if (di.get_remaining_size() == 0) {
- return;
- }
-
- if (_header->get_flt_version() <= _header->max_flt_version()) {
- nout << "Warning! Ignoring extra " << di.get_remaining_size()
- << " bytes at the end of a ";
- if (name.empty()) {
- nout << get_type();
- } else {
- nout << name;
- }
- nout << " record.\n";
- }
-}
-
-/**
- * Walks the hierarchy at this record and below and copies the
- * _converted_filename record into the _orig_filename record, so the flt file
- * will be written out with the converted filename instead of what was
- * originally read in.
- */
-void FltRecord::
-apply_converted_filenames() {
- Records::const_iterator ci;
- for (ci = _subfaces.begin(); ci != _subfaces.end(); ++ci) {
- (*ci)->apply_converted_filenames();
- }
- for (ci = _children.begin(); ci != _children.end(); ++ci) {
- (*ci)->apply_converted_filenames();
- }
-}
-
-/**
- * Writes a quick one-line description of the record, but not its children.
- * This is a human-readable description, primarily for debugging; to write a
- * flt file, use FltHeader::write_flt().
- */
-void FltRecord::
-output(std::ostream &out) const {
- out << get_type();
-}
-
-/**
- * Writes a multiple-line description of the record and all of its children.
- * This is a human-readable description, primarily for debugging; to write a
- * flt file, use FltHeader::write_flt().
- */
-void FltRecord::
-write(std::ostream &out, int indent_level) const {
- indent(out, indent_level) << *this;
- write_children(out, indent_level);
-}
-
-/**
- * Assuming the current write position has been left at the end of the last
- * line of the record description, writes out the list of children.
- */
-void FltRecord::
-write_children(std::ostream &out, int indent_level) const {
- if (!_ancillary.empty()) {
- out << " + " << _ancillary.size() << " ancillary";
- }
- if (!_extensions.empty()) {
- out << " + " << _extensions.size() << " extensions";
- }
- if (!_subfaces.empty()) {
- out << " [";
- Records::const_iterator ci;
- for (ci = _subfaces.begin(); ci != _subfaces.end(); ++ci) {
- out << " " << *(*ci);
- }
- out << " ]";
- }
- if (!_children.empty()) {
- out << " {\n";
- Records::const_iterator ci;
- for (ci = _children.begin(); ci != _children.end(); ++ci) {
- (*ci)->write(out, indent_level + 2);
- }
- indent(out, indent_level) << "}\n";
- } else {
- out << "\n";
- }
-}
-
- /*
- virtual void write(ostream &out) const;
- virtual void build_record(Datagram &datagram) const;
- */
-
-/**
- * Returns true if the indicated opcode corresponds to an ancillary record
- * type, false otherwise. In general, this function is used to identify
- * ancillary records that are not presently supported by the FltReader; these
- * will be ignored. Normally, ancillary records will be detected and
- * processed by extract_ancillary().
- */
-bool FltRecord::
-is_ancillary(FltOpcode opcode) {
- switch (opcode) {
- case FO_comment:
- case FO_long_id:
- case FO_multitexture:
- case FO_uv_list:
- case FO_replicate:
- case FO_road_zone:
- case FO_transform_matrix:
- case FO_rotate_about_edge:
- case FO_translate:
- case FO_scale:
- case FO_rotate_about_point:
- case FO_rotate_and_scale:
- case FO_put:
- case FO_general_matrix:
- case FO_vector:
- case FO_bounding_box:
- case FO_bounding_sphere:
- case FO_bounding_cylinder:
- case FO_bv_center:
- case FO_bv_orientation:
- case FO_local_vertex_pool:
- case FO_cat_data:
-
- case FO_14_material_palette:
- case FO_vertex_palette:
- case FO_vertex_c:
- case FO_vertex_cn:
- case FO_vertex_cnu:
- case FO_vertex_cu:
- case FO_color_palette:
- case FO_name_table:
- case FO_15_material:
- case FO_texture:
- case FO_eyepoint_palette:
- case FO_light_definition:
- case FO_texture_map_palette:
- return true;
-
- case FO_header:
- case FO_mesh:
- case FO_mesh_primitive:
- case FO_group:
- case FO_object:
- case FO_face:
- case FO_light_point:
- case FO_dof:
- case FO_vertex_list:
- case FO_morph_list:
- case FO_bsp:
- case FO_external_ref:
- case FO_lod:
- case FO_sound:
- case FO_light_source:
- case FO_road_segment:
- case FO_road_construction:
- case FO_road_path:
- case FO_clip_region:
- case FO_text:
- case FO_switch:
- case FO_cat:
- case FO_extension:
- case FO_curve:
- return false;
-
- case FO_push:
- case FO_pop:
- case FO_push_face:
- case FO_pop_face:
- case FO_push_attribute:
- case FO_pop_attribute:
- case FO_push_extension:
- case FO_pop_extension:
- case FO_instance:
- case FO_instance_ref:
- return false;
-
- default:
- nout << "Don't know whether " << opcode << " is ancillary.\n";
- return false;
- }
-}
-
-/**
- * Creates a new FltRecord corresponding to the opcode. If the opcode is
- * unknown, creates a FltUnsupportedRecord.
- */
-FltRecord *FltRecord::
-create_new_record(FltOpcode opcode) const {
- switch (opcode) {
- case FO_group:
- return new FltGroup(_header);
-
- case FO_object:
- return new FltObject(_header);
-
- case FO_face:
- return new FltFace(_header);
-
- case FO_curve:
- return new FltCurve(_header);
-
- case FO_mesh:
- return new FltMesh(_header);
-
- case FO_local_vertex_pool:
- return new FltLocalVertexPool(_header);
-
- case FO_mesh_primitive:
- return new FltMeshPrimitive(_header);
-
- case FO_vertex_list:
- return new FltVertexList(_header);
-
- case FO_lod:
- return new FltLOD(_header);
-
- case FO_instance:
- return new FltInstanceDefinition(_header);
-
- case FO_instance_ref:
- return new FltInstanceRef(_header);
-
- case FO_external_ref:
- return new FltExternalReference(_header);
-
- case FO_vector:
- return new FltVectorRecord(_header);
-
- default:
- nout << "Ignoring unsupported record " << opcode << "\n";
- return new FltUnsupportedRecord(_header);
- }
-}
-
-/**
- * Extracts this record information from the current record presented in the
- * reader, then advances the reader and continues to read any children, if
- * present. On return, the reader is position on the next sibling record to
- * this record.
- *
- * Returns FE_ok if successful, otherwise on error.
- */
-FltError FltRecord::
-read_record_and_children(FltRecordReader &reader) {
- if (!extract_record(reader)) {
- nout << "Could not extract record for " << *this << "\n";
- assert(!flt_error_abort);
- return FE_invalid_record;
- }
- FltError result = reader.advance();
- if (result == FE_end_of_file) {
- return FE_ok;
- } else if (result != FE_ok) {
- return result;
- }
-
- while (true) {
- if (extract_ancillary(reader)) {
- // Ok, a known ancillary record. Fine.
-
- } else if (reader.get_opcode() == FO_push) {
- // A push begins a new list of children.
- result = reader.advance();
- if (result != FE_ok) {
- return result;
- }
-
- while (reader.get_opcode() != FO_pop) {
- PT(FltRecord) child = create_new_record(reader.get_opcode());
- FltError result = child->read_record_and_children(reader);
- if (result != FE_ok) {
- return result;
- }
-
- if (child->is_of_type(FltInstanceDefinition::get_class_type())) {
- // A special case for an instance definition. These shouldn't
- // appear in the hierarchy, but should instead be added directly to
- // the header.
- _header->add_instance(DCAST(FltInstanceDefinition, child));
-
- } else {
- add_child(child);
- }
-
- if (reader.eof() || reader.error()) {
- assert(!flt_error_abort);
- return FE_end_of_file;
- }
- }
-
- } else if (reader.get_opcode() == FO_push_face) {
- // A push subface begins a new list of subfaces.
- result = reader.advance();
- if (result != FE_ok) {
- return result;
- }
-
- while (reader.get_opcode() != FO_pop_face) {
- PT(FltRecord) subface = create_new_record(reader.get_opcode());
- FltError result = subface->read_record_and_children(reader);
- if (result != FE_ok) {
- return result;
- }
- add_subface(subface);
- if (reader.eof() || reader.error()) {
- assert(!flt_error_abort);
- return FE_end_of_file;
- }
- }
-
- } else if (reader.get_opcode() == FO_push_extension) {
- // A push extension begins a new list of extensions.
- result = reader.advance();
- if (result != FE_ok) {
- return result;
- }
-
- while (reader.get_opcode() != FO_pop_extension) {
- PT(FltRecord) extension = create_new_record(reader.get_opcode());
- FltError result = extension->read_record_and_children(reader);
- if (result != FE_ok) {
- return result;
- }
- add_extension(extension);
- if (reader.eof() || reader.error()) {
- assert(!flt_error_abort);
- return FE_end_of_file;
- }
- }
-
- } else if (is_ancillary(reader.get_opcode())) {
- // An unsupported ancillary record. Skip it.
- PT(FltRecord) ancillary = create_new_record(reader.get_opcode());
- ancillary->extract_record(reader);
- _ancillary.push_back(ancillary);
-
- } else {
- // None of the above: we're done.
- return FE_ok;
- }
-
- // Skip to the next record. If that's the end, fine.
- result = reader.advance(true);
- if (reader.eof() || result != FE_ok) {
- return result;
- }
- }
-}
-
-/**
- * Fills in the information in this record based on the information given in
- * the indicated datagram, whose opcode has already been read. Returns true
- * on success, false if the datagram is invalid.
- */
-bool FltRecord::
-extract_record(FltRecordReader &) {
- return true;
-}
-
-/**
- * Checks whether the given record, which follows this record sequentially in
- * the file, is an ancillary record of this record. If it is, extracts the
- * relevant information and returns true; otherwise, leaves it alone and
- * returns false.
- */
-bool FltRecord::
-extract_ancillary(FltRecordReader &reader) {
- if (reader.get_opcode() == FO_comment) {
- DatagramIterator &di = reader.get_iterator();
- _comment = di.get_fixed_string(di.get_remaining_size());
- return true;
- }
-
- return false;
-}
-
-/**
- * Writes this record out to the flt file, along with all of its ancillary
- * records and children records. Returns FE_ok on success, or something else
- * on error.
- */
-FltError FltRecord::
-write_record_and_children(FltRecordWriter &writer) const {
- // First, write the record.
- if (!build_record(writer)) {
- assert(!flt_error_abort);
- return FE_bad_data;
- }
-
- FltError result = writer.advance();
- if (result != FE_ok) {
- return result;
- }
-
- // Then the ancillary data.
- result = write_ancillary(writer);
- if (result != FE_ok) {
- return result;
- }
- Records::const_iterator ci;
- for (ci = _ancillary.begin(); ci != _ancillary.end(); ++ci) {
- if (!(*ci)->build_record(writer)) {
- assert(!flt_error_abort);
- return FE_bad_data;
- }
- result = writer.advance();
- if (result != FE_ok) {
- return result;
- }
- }
-
- // Any extensions?
- if (!_extensions.empty()) {
- result = writer.write_record(FO_push_face);
- if (result != FE_ok) {
- return result;
- }
-
- for (ci = _extensions.begin(); ci != _extensions.end(); ++ci) {
- (*ci)->write_record_and_children(writer);
- }
-
- result = writer.write_record(FO_pop_face);
- if (result != FE_ok) {
- return result;
- }
- }
-
- // Finally, write all the children.
- if (!_children.empty()) {
- result = writer.write_record(FO_push);
- if (result != FE_ok) {
- return result;
- }
-
- for (ci = _children.begin(); ci != _children.end(); ++ci) {
- (*ci)->write_record_and_children(writer);
- }
-
- result = writer.write_record(FO_pop);
- if (result != FE_ok) {
- return result;
- }
- }
-
- // We must write subfaces *after* the list of children, or Creator will
- // crash trying to load the file.
- if (!_subfaces.empty()) {
- result = writer.write_record(FO_push_face);
- if (result != FE_ok) {
- return result;
- }
-
- for (ci = _subfaces.begin(); ci != _subfaces.end(); ++ci) {
- (*ci)->write_record_and_children(writer);
- }
-
- result = writer.write_record(FO_pop_face);
- if (result != FE_ok) {
- return result;
- }
- }
-
- return FE_ok;
-}
-
-/**
- * Fills up the current record on the FltRecordWriter with data for this
- * record, but does not advance the writer. Returns true on success, false if
- * there is some error.
- */
-bool FltRecord::
-build_record(FltRecordWriter &) const {
- return true;
-}
-
-/**
- * Writes whatever ancillary records are required for this record. Returns
- * FE_ok on success, or something else if there is some error.
- */
-FltError FltRecord::
-write_ancillary(FltRecordWriter &writer) const {
- if (!_comment.empty()) {
- Datagram dc(_comment.data(), _comment.size());
- FltError result = writer.write_record(FO_comment, dc);
- if (result != FE_ok) {
- return result;
- }
- }
- return FE_ok;
-}
diff --git a/pandatool/src/flt/fltRecord.h b/pandatool/src/flt/fltRecord.h
deleted file mode 100644
index 9fc8e3ad..00000000
--- a/pandatool/src/flt/fltRecord.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltRecord.h
- * @author drose
- * @date 2000-08-24
- */
-
-#ifndef FLTRECORD_H
-#define FLTRECORD_H
-
-#include "pandatoolbase.h"
-
-#include "fltOpcode.h"
-#include "fltError.h"
-
-#include "typedObject.h"
-#include "typedReferenceCount.h"
-#include "pointerTo.h"
-
-class FltHeader;
-class FltRecordReader;
-class FltRecordWriter;
-class DatagramIterator;
-
-/**
- * The base class for all kinds of records in a MultiGen OpenFlight file. A
- * flt file consists of a hierarchy of "beads" of various kinds, each of which
- * may be followed by n ancillary records, written sequentially to the file.
- */
-class FltRecord : public TypedReferenceCount {
-public:
- FltRecord(FltHeader *header);
- virtual ~FltRecord();
-
- int get_num_children() const;
- FltRecord *get_child(int n) const;
- void clear_children();
- void add_child(FltRecord *child);
-
- int get_num_subfaces() const;
- FltRecord *get_subface(int n) const;
- void clear_subfaces();
- void add_subface(FltRecord *subface);
-
- int get_num_extensions() const;
- FltRecord *get_extension(int n) const;
- void clear_extensions();
- void add_extension(FltRecord *extension);
-
- int get_num_ancillary() const;
- FltRecord *get_ancillary(int n) const;
- void clear_ancillary();
- void add_ancillary(FltRecord *ancillary);
-
- bool has_comment() const;
- const std::string &get_comment() const;
- void clear_comment();
- void set_comment(const std::string &comment);
-
- void check_remaining_size(const DatagramIterator &di,
- const std::string &name = std::string()) const;
-
- virtual void apply_converted_filenames();
-
- virtual void output(std::ostream &out) const;
- virtual void write(std::ostream &out, int indent_level = 0) const;
-
-protected:
- void write_children(std::ostream &out, int indent_level) const;
-
- static bool is_ancillary(FltOpcode opcode);
-
- FltRecord *create_new_record(FltOpcode opcode) const;
- FltError read_record_and_children(FltRecordReader &reader);
- virtual bool extract_record(FltRecordReader &reader);
- virtual bool extract_ancillary(FltRecordReader &reader);
-
- virtual FltError write_record_and_children(FltRecordWriter &writer) const;
- virtual bool build_record(FltRecordWriter &writer) const;
- virtual FltError write_ancillary(FltRecordWriter &writer) const;
-
-protected:
- FltHeader *_header;
-
-private:
- typedef pvector Records;
- Records _children;
- Records _subfaces;
- Records _extensions;
- Records _ancillary;
-
- std::string _comment;
-
-
-public:
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- TypedReferenceCount::init_type();
- register_type(_type_handle, "FltRecord",
- TypedReferenceCount::get_class_type());
- }
-
-private:
- static TypeHandle _type_handle;
-};
-
-INLINE std::ostream &operator << (std::ostream &out, const FltRecord &record);
-
-#include "fltRecord.I"
-
-#endif
diff --git a/pandatool/src/flt/fltRecordReader.cxx b/pandatool/src/flt/fltRecordReader.cxx
deleted file mode 100644
index 8e1993c9..00000000
--- a/pandatool/src/flt/fltRecordReader.cxx
+++ /dev/null
@@ -1,242 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltRecordReader.cxx
- * @author drose
- * @date 2000-08-24
- */
-
-#include "fltRecordReader.h"
-#include "config_flt.h"
-
-#include "datagramIterator.h"
-
-#include
-
-/**
- *
- */
-FltRecordReader::
-FltRecordReader(std::istream &in) :
- _in(in)
-{
- _opcode = FO_none;
- _record_length = 0;
- _iterator = nullptr;
- _state = S_begin;
- _next_error = FE_ok;
- _next_opcode = FO_none;
- _next_record_length = 0;
-
- // Read the first header to get us going.
- read_next_header();
-}
-
-/**
- *
- */
-FltRecordReader::
-~FltRecordReader() {
- delete _iterator;
- _iterator = nullptr;
-}
-
-/**
- * Returns the opcode associated with the current record.
- */
-FltOpcode FltRecordReader::
-get_opcode() const {
- nassertr(_state == S_normal, FO_none);
- return _opcode;
-}
-
-/**
- * Returns an iterator suitable for extracting data from the current record.
- */
-DatagramIterator &FltRecordReader::
-get_iterator() {
- nassertr(_state == S_normal, *_iterator);
- return *_iterator;
-}
-
-/**
- * Returns the datagram representing the entire record, less the four-byte
- * header.
- */
-const Datagram &FltRecordReader::
-get_datagram() {
-#ifndef NDEBUG
- static Datagram bogus_datagram;
- nassertr(_state == S_normal, bogus_datagram);
-#endif
- return _iterator->get_datagram();
-}
-
-/**
- * Returns the entire length of the record, including the four-byte header.
- */
-int FltRecordReader::
-get_record_length() const {
- return _record_length;
-}
-
-/**
- * Extracts the next record from the file. Returns true if there is another
- * record, or false if the end of file has been reached.
- */
-FltError FltRecordReader::
-advance(bool ok_eof) {
- if (_state == S_eof) {
- assert(!flt_error_abort);
- return FE_end_of_file;
- }
- if (_state == S_error) {
- assert(!flt_error_abort);
- return FE_read_error;
- }
- if (_iterator != nullptr) {
- delete _iterator;
- _iterator = nullptr;
- }
-
- if (_next_error == FE_end_of_file) {
- _state = S_eof;
- if (ok_eof) {
- return FE_ok;
- }
- assert(!flt_error_abort);
- return FE_end_of_file;
-
- } else if (_next_error != FE_ok) {
- _state = S_error;
- assert(!flt_error_abort);
- return _next_error;
- }
-
- _opcode = _next_opcode;
- _record_length = _next_record_length;
-
- if (flt_cat.is_debug()) {
- flt_cat.debug()
- << "Reading " << _opcode
- << " of length " << _record_length << "\n";
- }
-
- // And now read the full record based on the length.
- int length = _next_record_length - header_size;
- if (length > 0) {
- vector_uchar data((size_t)length);
- _in.read((char *)&data[0], length);
- _datagram = Datagram(std::move(data));
- } else {
- _datagram = Datagram();
- }
-
- if (_in.fail()) {
- if (_in.eof()) {
- _state = S_eof;
- assert(!flt_error_abort);
- return FE_end_of_file;
- }
-
- _state = S_error;
- assert(!flt_error_abort);
- return FE_read_error;
- }
-
- // Check out the next header in case it's a continuation.
- read_next_header();
- while (_next_error == FE_ok && _next_opcode == FO_continuation) {
- if (flt_cat.is_debug()) {
- flt_cat.debug()
- << "Reading continuation of length " << _next_record_length << "\n";
- }
-
- // Read the continuation and tack it on.
- _record_length += _next_record_length;
- length = _next_record_length - header_size;
-
- if (length > 0) {
- char *buffer = new char[length];
- _in.read(buffer, length);
- _datagram.append_data(buffer, length);
- delete[] buffer;
- }
-
- if (_in.fail()) {
- if (_in.eof()) {
- _state = S_eof;
- assert(!flt_error_abort);
- return FE_end_of_file;
- }
-
- _state = S_error;
- assert(!flt_error_abort);
- return FE_read_error;
- }
-
- read_next_header();
- }
-
- // Finally, create a new iterator to read this record.
- _iterator = new DatagramIterator(_datagram);
- _state = S_normal;
-
- return FE_ok;
-}
-
-/**
- * Returns true if end-of-file has been reached without error.
- */
-bool FltRecordReader::
-eof() const {
- return _state == S_eof;
-}
-
-/**
- * Returns true if some error has been encountered while reading (for
- * instance, a truncated file).
- */
-bool FltRecordReader::
-error() const {
- return _state == S_error;
-}
-
-/**
- * Reads the four-byte header for the next record, which contains the next
- * opcode and record length.
- *
- * We need read the next header in advance so we can check to see if it
- * happens to be a continuation record. If it is, we will need to concatenate
- * the records together before returning.
- */
-void FltRecordReader::
-read_next_header() {
- char bytes[header_size];
- _in.read(bytes, header_size);
-
- if (_in.fail()) {
- if (_in.eof()) {
- _next_error = FE_end_of_file;
- return;
- }
- _next_error = FE_read_error;
- return;
- }
-
- // Now extract out the opcode and length.
- Datagram dg(bytes, header_size);
- DatagramIterator dgi(dg);
- _next_opcode = (FltOpcode)dgi.get_be_int16();
- _next_record_length = dgi.get_be_uint16();
-
- if (_next_record_length < header_size) {
- _next_error = FE_invalid_record;
- return;
- }
-}
diff --git a/pandatool/src/flt/fltRecordReader.h b/pandatool/src/flt/fltRecordReader.h
deleted file mode 100644
index 8817e800..00000000
--- a/pandatool/src/flt/fltRecordReader.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltRecordReader.h
- * @author drose
- * @date 2000-08-24
- */
-
-#ifndef FLTRECORDREADER_H
-#define FLTRECORDREADER_H
-
-#include "pandatoolbase.h"
-
-#include "fltOpcode.h"
-#include "fltError.h"
-
-#include "datagram.h"
-#include "datagramIterator.h"
-
-/**
- * This class turns an istream into a sequence of FltRecords by reading a
- * sequence of Datagrams and extracting the opcode from each one. It
- * remembers where it is in the file and what the current record is.
- */
-class FltRecordReader {
-public:
- FltRecordReader(std::istream &in);
- ~FltRecordReader();
-
- FltOpcode get_opcode() const;
- DatagramIterator &get_iterator();
- const Datagram &get_datagram();
- int get_record_length() const;
-
- FltError advance(bool ok_eof = false);
-
- bool eof() const;
- bool error() const;
-
-private:
- void read_next_header();
-
- std::istream &_in;
- Datagram _datagram;
- FltOpcode _opcode;
- int _record_length;
- DatagramIterator *_iterator;
-
- FltError _next_error;
- FltOpcode _next_opcode;
- int _next_record_length;
-
- enum State {
- S_begin,
- S_normal,
- S_eof,
- S_error
- };
- State _state;
-};
-
-#endif
diff --git a/pandatool/src/flt/fltRecordWriter.cxx b/pandatool/src/flt/fltRecordWriter.cxx
deleted file mode 100644
index 909e5ce2..00000000
--- a/pandatool/src/flt/fltRecordWriter.cxx
+++ /dev/null
@@ -1,151 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltRecordWriter.cxx
- * @author drose
- * @date 2000-08-24
- */
-
-#include "fltRecordWriter.h"
-#include "fltInstanceDefinition.h"
-#include "fltHeader.h"
-#include "config_flt.h"
-
-#include "datagram.h"
-
-#include
-
-// Don't attempt to write more than this number of bytes in one record. If
-// the record requires more than this, use continuation records.
-static const int max_write_length = 65532;
-
-/**
- *
- */
-FltRecordWriter::
-FltRecordWriter(std::ostream &out) :
- _out(out)
-{
-}
-
-/**
- *
- */
-FltRecordWriter::
-~FltRecordWriter() {
-}
-
-/**
- * Sets the opcode associated with the current record.
- */
-void FltRecordWriter::
-set_opcode(FltOpcode opcode) {
- _opcode = opcode;
-}
-
-/**
- * Sets the datagram that will be written when advance() is called.
- */
-void FltRecordWriter::
-set_datagram(const Datagram &datagram) {
- _datagram = datagram;
-}
-
-/**
- * Returns a modifiable reference to the datagram associated with the current
- * record. This datagram should then be stuffed with data corresponding to
- * the data in the record, in preparation for calling advance() to write the
- * data.
- */
-Datagram &FltRecordWriter::
-update_datagram() {
- return _datagram;
-}
-
-/**
- * Writes the current record to the flt file, and resets the current record to
- * receive new data. Returns FE_ok on success, or something else on error.
- */
-FltError FltRecordWriter::
-advance() {
- int start_byte = 0;
- int write_length =
- std::min((int)_datagram.get_length() - start_byte, max_write_length - header_size);
- FltOpcode opcode = _opcode;
-
- do {
- if (flt_cat.is_debug()) {
- flt_cat.debug()
- << "Writing " << opcode << " of length "
- << write_length + header_size << "\n";
- }
-
- // Build a mini-datagram to write the header.
- Datagram dg;
- dg.add_be_int16(opcode);
- dg.add_be_int16(write_length + header_size);
-
- nassertr((int)dg.get_length() == header_size, FE_internal);
-
- _out.write((const char *)dg.get_data(), dg.get_length());
- if (_out.fail()) {
- assert(!flt_error_abort);
- return FE_write_error;
- }
-
- // Now write the rest of the record.
- _out.write((const char *)_datagram.get_data() + start_byte, write_length);
- if (_out.fail()) {
- assert(!flt_error_abort);
- return FE_write_error;
- }
-
- start_byte += write_length;
- write_length =
- std::min((int)_datagram.get_length() - start_byte, max_write_length - header_size);
- opcode = FO_continuation;
- } while (write_length > 0);
-
- _datagram.clear();
- _opcode = FO_none;
-
- return FE_ok;
-}
-
-/**
- * A convenience function to quickly write a simple record that consists of an
- * opcode and possibly a datagram.
- */
-FltError FltRecordWriter::
-write_record(FltOpcode opcode, const Datagram &datagram) {
- _opcode = opcode;
- _datagram = datagram;
- return advance();
-}
-
-/**
- * Ensures that the given instance definition has already been written to the
- * file. If it has not, writes it now.
- */
-FltError FltRecordWriter::
-write_instance_def(FltHeader *header, int instance_index) {
- bool inserted = _instances_written.insert(instance_index).second;
-
- if (!inserted) {
- // It's already been written.
- return FE_ok;
- }
-
- FltInstanceDefinition *instance = header->get_instance(instance_index);
- if (instance == nullptr) {
- assert(!flt_error_abort);
- return FE_undefined_instance;
- }
-
- return instance->write_record_and_children(*this);
-}
diff --git a/pandatool/src/flt/fltRecordWriter.h b/pandatool/src/flt/fltRecordWriter.h
deleted file mode 100644
index 8cd4e4b6..00000000
--- a/pandatool/src/flt/fltRecordWriter.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltRecordWriter.h
- * @author drose
- * @date 2000-08-24
- */
-
-#ifndef FLTRECORDWRITER_H
-#define FLTRECORDWRITER_H
-
-#include "pandatoolbase.h"
-
-#include "fltOpcode.h"
-#include "fltError.h"
-
-#include "datagram.h"
-#include "pset.h"
-
-class FltHeader;
-
-/**
- * This class writes a sequence of FltRecords to an ostream, handling opcode
- * and size counts properly.
- */
-class FltRecordWriter {
-public:
- FltRecordWriter(std::ostream &out);
- ~FltRecordWriter();
-
- void set_opcode(FltOpcode opcode);
- const Datagram &get_datagram() const;
- void set_datagram(const Datagram &datagram);
- Datagram &update_datagram();
-
- FltError advance();
-
- FltError write_record(FltOpcode opcode,
- const Datagram &datagram = Datagram());
-
- FltError write_instance_def(FltHeader *header, int instance_index);
-
-private:
- std::ostream &_out;
- Datagram _datagram;
- FltOpcode _opcode;
-
- typedef pset Instances;
- Instances _instances_written;
-};
-
-#endif
diff --git a/pandatool/src/flt/fltTexture.cxx b/pandatool/src/flt/fltTexture.cxx
deleted file mode 100644
index c65f5a05..00000000
--- a/pandatool/src/flt/fltTexture.cxx
+++ /dev/null
@@ -1,475 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltTexture.cxx
- * @author drose
- * @date 2000-08-25
- */
-
-#include "fltTexture.h"
-#include "fltRecordReader.h"
-#include "fltRecordWriter.h"
-#include "fltHeader.h"
-#include "pathReplace.h"
-#include "config_putil.h"
-
-TypeHandle FltTexture::_type_handle;
-
-/**
- *
- */
-FltTexture::
-FltTexture(FltHeader *header) : FltRecord(header) {
- _pattern_index = -1;
- _x_location = 0;
- _y_location = 0;
-
- _num_texels_u = 0;
- _num_texels_v = 0;
- _real_world_size_u = 0;
- _real_world_size_v = 0;
- _up_vector_x = 0;
- _up_vector_y = 1;
- _file_format = FF_none;
- _min_filter = MN_point;
- _mag_filter = MG_point;
- _repeat = RT_repeat;
- _repeat_u = RT_repeat;
- _repeat_v = RT_repeat;
- _modify_flag = 0;
- _x_pivot_point = 0;
- _y_pivot_point = 0;
- _env_type = ET_modulate;
- _intensity_is_alpha = false;
- _float_real_world_size_u = 0.0;
- _float_real_world_size_v = 0.0;
- _imported_origin_code = 0;
- _kernel_version = 1520;
- _internal_format = IF_default;
- _external_format = EF_default;
- _use_mipmap_kernel = false;
- memset(_mipmap_kernel, 0, sizeof(_mipmap_kernel));
- _use_lod_scale = false;
- memset(_lod_scale, 0, sizeof(_lod_scale));
- _clamp = 0.0;
- _mag_filter_alpha = MG_point;
- _mag_filter_color = MG_point;
- _lambert_conic_central_meridian = 0.0;
- _lambert_conic_upper_latitude = 0.0;
- _lambert_conic_lower_latitude = 0.0;
- _use_detail = false;
- _detail_j = 0;
- _detail_k = 0;
- _detail_m = 0;
- _detail_n = 0;
- _detail_scramble = 0;
- _use_tile = false;
- _tile_lower_left_u = 0.0;
- _tile_lower_left_v = 0.0;
- _tile_upper_right_u = 0.0;
- _tile_upper_right_v = 0.0;
- _projection = PT_flat_earth;
- _earth_model = EM_wgs84;
- _utm_zone = 0;
- _image_origin = IO_lower_left;
- _geospecific_points_units = PU_degrees;
- _geospecific_hemisphere = H_southern;
- _file_version = 1501;
-}
-
-/**
- * Walks the hierarchy at this record and below and copies the
- * _converted_filename record into the _orig_filename record, so the flt file
- * will be written out with the converted filename instead of what was
- * originally read in.
- */
-void FltTexture::
-apply_converted_filenames() {
- _orig_filename = _converted_filename.to_os_generic();
- FltRecord::apply_converted_filenames();
-}
-
-/**
- * Returns the name of the texture image file.
- */
-Filename FltTexture::
-get_texture_filename() const {
- return _converted_filename;
-}
-
-/**
- * Changes the name of the texture image file.
- */
-void FltTexture::
-set_texture_filename(const Filename &filename) {
- _converted_filename = filename;
- _orig_filename = _converted_filename.to_os_generic();
-}
-
-/**
- * Returns the name of the texture's associated .attr file. This contains
- * some additional MultiGen information about the texture parameters. This
- * is, of course, just the name of the texture with .attr appended.
- *
- * Normally, it won't be necessary to access this file directly; you can call
- * read_attr_data() or write_attr_data() to get at the data stored in this
- * file. (And read_attr_data() is called automatically when the Flt file is
- * read in.)
- */
-Filename FltTexture::
-get_attr_filename() const {
- std::string texture_filename = get_texture_filename();
- return Filename::binary_filename(texture_filename + ".attr");
-}
-
-/**
- * Opens up the texture's .attr file and reads its data into the extra
- * FltTexture fields. This is normally performed automatically when the Flt
- * file is read from disk.
- */
-FltError FltTexture::
-read_attr_data() {
- Filename attr_filename = get_attr_filename();
-
- std::ifstream attr;
- if (!attr_filename.open_read(attr)) {
- return FE_could_not_open;
- }
-
- // Determine the file's size so we can read it all into one big datagram.
- attr.seekg(0, std::ios::end);
- if (attr.fail()) {
- return FE_read_error;
- }
- std::streampos length = attr.tellg();
-
- char *buffer = new char[length];
-
- attr.seekg(0, std::ios::beg);
- attr.read(buffer, length);
- if (attr.fail()) {
- return FE_read_error;
- }
-
- Datagram datagram(buffer, length);
- delete[] buffer;
-
- return unpack_attr(datagram);
-}
-
-/**
- * Writes the texture's .attr file. This may or may not be performed
- * automatically, according to the setting of
- * FltHeader::set_auto_attr_update().
- */
-FltError FltTexture::
-write_attr_data() const {
- return write_attr_data(get_attr_filename());
-}
-
-/**
- * Writes the texture's .attr file to the named file.
- */
-FltError FltTexture::
-write_attr_data(Filename attr_filename) const {
- Datagram datagram;
- FltError result = pack_attr(datagram);
- if (result != FE_ok) {
- return result;
- }
-
- attr_filename.set_binary();
- std::ofstream attr;
- if (!attr_filename.open_write(attr)) {
- return FE_could_not_open;
- }
-
- attr.write((const char *)datagram.get_data(), datagram.get_length());
- if (attr.fail()) {
- return FE_write_error;
- }
- return FE_ok;
-}
-
-/**
- * Fills in the information in this record based on the information given in
- * the indicated datagram, whose opcode has already been read. Returns true
- * on success, false if the datagram is invalid.
- */
-bool FltTexture::
-extract_record(FltRecordReader &reader) {
- if (!FltRecord::extract_record(reader)) {
- return false;
- }
-
- nassertr(reader.get_opcode() == FO_texture, false);
- DatagramIterator &iterator = reader.get_iterator();
-
- if (_header->get_flt_version() < 1420) {
- _orig_filename = iterator.get_fixed_string(80);
- } else {
- _orig_filename = iterator.get_fixed_string(200);
- }
- _converted_filename = _header->convert_path(Filename::from_os_specific(_orig_filename), get_model_path());
- _pattern_index = iterator.get_be_int32();
- _x_location = iterator.get_be_int32();
- _y_location = iterator.get_be_int32();
-
- if (read_attr_data() != FE_ok) {
- nout << "Unable to read attribute file " << get_attr_filename() << "\n";
- }
-
- check_remaining_size(iterator);
- return true;
-}
-
-/**
- * Fills up the current record on the FltRecordWriter with data for this
- * record, but does not advance the writer. Returns true on success, false if
- * there is some error.
- */
-bool FltTexture::
-build_record(FltRecordWriter &writer) const {
- if (!FltRecord::build_record(writer)) {
- return false;
- }
-
- writer.set_opcode(FO_texture);
- Datagram &datagram = writer.update_datagram();
-
- datagram.add_fixed_string(_orig_filename, 200);
- datagram.add_be_int32(_pattern_index);
- datagram.add_be_int32(_x_location);
- datagram.add_be_int32(_y_location);
-
- if (_header->get_auto_attr_update() == FltHeader::AU_always ||
- (_header->get_auto_attr_update() == FltHeader::AU_if_missing &&
- !get_attr_filename().exists())) {
- if (write_attr_data() != FE_ok) {
- nout << "Unable to write attribute file " << get_attr_filename() << "\n";
- }
- }
-
- return true;
-}
-
-/**
- * Reads the data from the attribute file.
- */
-FltError FltTexture::
-unpack_attr(const Datagram &datagram) {
- DatagramIterator iterator(datagram);
-
- _num_texels_u = iterator.get_be_int32();
- _num_texels_v = iterator.get_be_int32();
- _real_world_size_u = iterator.get_be_int32();
- _real_world_size_v = iterator.get_be_int32();
- _up_vector_x = iterator.get_be_int32();
- _up_vector_y = iterator.get_be_int32();
- _file_format = (FileFormat)iterator.get_be_int32();
- _min_filter = (Minification)iterator.get_be_int32();
- _mag_filter = (Magnification)iterator.get_be_int32();
- _repeat = (RepeatType)iterator.get_be_int32();
- _repeat_u = (RepeatType)iterator.get_be_int32();
- _repeat_v = (RepeatType)iterator.get_be_int32();
- _modify_flag = iterator.get_be_int32();
- _x_pivot_point = iterator.get_be_int32();
- _y_pivot_point = iterator.get_be_int32();
- _env_type = (EnvironmentType)iterator.get_be_int32();
- _intensity_is_alpha = (iterator.get_be_int32() != 0);
- iterator.skip_bytes(4 * 8);
- iterator.skip_bytes(4); // Undocumented padding.
- _float_real_world_size_u = iterator.get_be_float64();
- _float_real_world_size_v = iterator.get_be_float64();
- _imported_origin_code = iterator.get_be_int32();
- _kernel_version = iterator.get_be_int32();
- _internal_format = (InternalFormat)iterator.get_be_int32();
- _external_format = (ExternalFormat)iterator.get_be_int32();
- _use_mipmap_kernel = (iterator.get_be_int32() != 0);
- int i;
- for (i = 0; i < 8; i++) {
- _mipmap_kernel[i] = iterator.get_be_float32();
- }
- _use_lod_scale = (iterator.get_be_int32() != 0);
- for (i = 0; i < 8; i++) {
- _lod_scale[i]._lod = iterator.get_be_float32();
- _lod_scale[i]._scale = iterator.get_be_float32();
- }
- _clamp = iterator.get_be_float32();
- _mag_filter_alpha = (Magnification)iterator.get_be_int32();
- _mag_filter_color = (Magnification)iterator.get_be_int32();
- iterator.skip_bytes(4 + 4 * 8);
- _lambert_conic_central_meridian = iterator.get_be_float64();
- _lambert_conic_upper_latitude = iterator.get_be_float64();
- _lambert_conic_lower_latitude = iterator.get_be_float64();
- iterator.skip_bytes(8 + 4 * 5);
- _use_detail = (iterator.get_be_int32() != 0);
- _detail_j = iterator.get_be_int32();
- _detail_k = iterator.get_be_int32();
- _detail_m = iterator.get_be_int32();
- _detail_n = iterator.get_be_int32();
- _detail_scramble = iterator.get_be_int32();
- _use_tile = (iterator.get_be_int32() != 0);
- _tile_lower_left_u = iterator.get_be_float32();
- _tile_lower_left_v = iterator.get_be_float32();
- _tile_upper_right_u = iterator.get_be_float32();
- _tile_upper_right_v = iterator.get_be_float32();
- _projection = (ProjectionType)iterator.get_be_int32();
- _earth_model = (EarthModel)iterator.get_be_int32();
- iterator.skip_bytes(4);
- _utm_zone = iterator.get_be_int32();
- _image_origin = (ImageOrigin)iterator.get_be_int32();
- _geospecific_points_units = (PointsUnits)iterator.get_be_int32();
- _geospecific_hemisphere = (Hemisphere)iterator.get_be_int32();
- iterator.skip_bytes(4 + 4 + 149 * 4);
- iterator.skip_bytes(8); // Undocumented padding.
- _comment = iterator.get_fixed_string(512);
-
- if (iterator.get_remaining_size() != 0) {
- iterator.skip_bytes(13 * 4);
- iterator.skip_bytes(4); // Undocumented padding.
- _file_version = iterator.get_be_int32();
-
- // Now read the geospecific control points.
- _geospecific_control_points.clear();
- int num_points = iterator.get_be_int32();
- if (num_points > 0) {
- iterator.skip_bytes(4);
-
- while (num_points > 0) {
- GeospecificControlPoint gcp;
- gcp._uv[0] = iterator.get_be_float64();
- gcp._uv[1] = iterator.get_be_float64();
- gcp._real_earth[0] = iterator.get_be_float64();
- gcp._real_earth[1] = iterator.get_be_float64();
- }
- }
-
- if (iterator.get_remaining_size() != 0) {
- int num_defs = iterator.get_be_int32();
- while (num_defs > 0) {
- SubtextureDef def;
- def._name = iterator.get_fixed_string(32);
- def._left = iterator.get_be_int32();
- def._bottom = iterator.get_be_int32();
- def._right = iterator.get_be_int32();
- def._top = iterator.get_be_int32();
- }
- }
- }
-
- check_remaining_size(iterator);
- return FE_ok;
-}
-
-/**
- * Packs the attribute data into a big datagram.
- */
-FltError FltTexture::
-pack_attr(Datagram &datagram) const {
- datagram.add_be_int32(_num_texels_u);
- datagram.add_be_int32(_num_texels_v);
- datagram.add_be_int32(_real_world_size_u);
- datagram.add_be_int32(_real_world_size_v);
- datagram.add_be_int32(_up_vector_x);
- datagram.add_be_int32(_up_vector_y);
- datagram.add_be_int32(_file_format);
- datagram.add_be_int32(_min_filter);
- datagram.add_be_int32(_mag_filter);
- datagram.add_be_int32(_repeat);
- datagram.add_be_int32(_repeat_u);
- datagram.add_be_int32(_repeat_v);
- datagram.add_be_int32(_modify_flag);
- datagram.add_be_int32(_x_pivot_point);
- datagram.add_be_int32(_y_pivot_point);
- datagram.add_be_int32(_env_type);
- datagram.add_be_int32(_intensity_is_alpha);
- datagram.pad_bytes(4 * 8);
- datagram.pad_bytes(4); // Undocumented padding.
- datagram.add_be_float64(_float_real_world_size_u);
- datagram.add_be_float64(_float_real_world_size_v);
- datagram.add_be_int32(_imported_origin_code);
- datagram.add_be_int32(_kernel_version);
- datagram.add_be_int32(_internal_format);
- datagram.add_be_int32(_external_format);
- datagram.add_be_int32(_use_mipmap_kernel);
- int i;
- for (i = 0; i < 8; i++) {
- datagram.add_be_float32(_mipmap_kernel[i]);
- }
- datagram.add_be_int32(_use_lod_scale);
- for (i = 0; i < 8; i++) {
- datagram.add_be_float32(_lod_scale[i]._lod);
- datagram.add_be_float32(_lod_scale[i]._scale);
- }
- datagram.add_be_float32(_clamp);
- datagram.add_be_int32(_mag_filter_alpha);
- datagram.add_be_int32(_mag_filter_color);
- datagram.pad_bytes(4 + 4 * 8);
- datagram.add_be_float64(_lambert_conic_central_meridian);
- datagram.add_be_float64(_lambert_conic_upper_latitude);
- datagram.add_be_float64(_lambert_conic_lower_latitude);
- datagram.pad_bytes(8 + 4 * 5);
- datagram.add_be_int32(_use_detail);
- datagram.add_be_int32(_detail_j);
- datagram.add_be_int32(_detail_k);
- datagram.add_be_int32(_detail_m);
- datagram.add_be_int32(_detail_n);
- datagram.add_be_int32(_detail_scramble);
- datagram.add_be_int32(_use_tile);
- datagram.add_be_float32(_tile_lower_left_u);
- datagram.add_be_float32(_tile_lower_left_v);
- datagram.add_be_float32(_tile_upper_right_u);
- datagram.add_be_float32(_tile_upper_right_v);
- datagram.add_be_int32(_projection);
- datagram.add_be_int32(_earth_model);
- datagram.pad_bytes(4);
- datagram.add_be_int32(_utm_zone);
- datagram.add_be_int32(_image_origin);
- datagram.add_be_int32(_geospecific_points_units);
- datagram.add_be_int32(_geospecific_hemisphere);
- datagram.pad_bytes(4 + 4 + 149 * 4);
- datagram.pad_bytes(8); // Undocumented padding.
- datagram.add_fixed_string(_comment, 512);
- datagram.pad_bytes(13 * 4);
- datagram.pad_bytes(4); // Undocumented padding.
- datagram.add_be_int32(_file_version);
-
- // Now write the geospecific control points.
- datagram.add_be_int32(_geospecific_control_points.size());
- if (!_geospecific_control_points.empty()) {
- datagram.pad_bytes(4);
- GeospecificControlPoints::const_iterator pi;
- for (pi = _geospecific_control_points.begin();
- pi != _geospecific_control_points.end();
- ++pi) {
- const GeospecificControlPoint &gcp = (*pi);
- datagram.add_be_float64(gcp._uv[0]);
- datagram.add_be_float64(gcp._uv[1]);
- datagram.add_be_float64(gcp._real_earth[0]);
- datagram.add_be_float64(gcp._real_earth[1]);
- }
- }
-
- // Also write out the subtexture definitions.
- datagram.add_be_int32(_subtexture_defs.size());
- SubtextureDefs::const_iterator di;
- for (di = _subtexture_defs.begin();
- di != _subtexture_defs.end();
- ++di) {
- const SubtextureDef &def = (*di);
- datagram.add_fixed_string(def._name, 31);
- datagram.add_int8(0);
- datagram.add_be_int32(def._left);
- datagram.add_be_int32(def._bottom);
- datagram.add_be_int32(def._right);
- datagram.add_be_int32(def._top);
- }
-
- return FE_ok;
-}
diff --git a/pandatool/src/flt/fltTexture.h b/pandatool/src/flt/fltTexture.h
deleted file mode 100644
index 34a487e1..00000000
--- a/pandatool/src/flt/fltTexture.h
+++ /dev/null
@@ -1,252 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltTexture.h
- * @author drose
- * @date 2000-08-25
- */
-
-#ifndef FLTTEXTURE_H
-#define FLTTEXTURE_H
-
-#include "pandatoolbase.h"
-
-#include "fltRecord.h"
-
-#include "filename.h"
-#include "luse.h"
-
-/**
- * Represents a single texture in the texture palette.
- */
-class FltTexture : public FltRecord {
-public:
- FltTexture(FltHeader *header);
-
- virtual void apply_converted_filenames();
-
- std::string _orig_filename;
- Filename _converted_filename;
- int _pattern_index;
- int _x_location;
- int _y_location;
-
- Filename get_texture_filename() const;
- void set_texture_filename(const Filename &filename);
- Filename get_attr_filename() const;
- FltError read_attr_data();
- FltError write_attr_data() const;
- FltError write_attr_data(Filename attr_filename) const;
-
- // The remaining fields are from the attr file.
- enum FileFormat {
- FF_none = -1,
- FF_att_8_pattern = 0,
- FF_att_8_template = 1,
- FF_sgi_i = 2,
- FF_sgi_ia = 3,
- FF_sgi_rgb = 4,
- FF_sgi_rgba = 5
- };
-
- enum Minification {
- MN_point = 0,
- MN_bilinear = 1,
- MN_OB_mipmap = 2, // obsolete
- MN_mipmap_point = 3,
- MN_mipmap_linear = 4,
- MN_mipmap_bilinear = 5,
- MN_mipmap_trilinear = 6,
- MN_bicubic = 8,
- MN_bilinear_gequal = 9,
- MN_bilinear_lequal = 10,
- MN_bicubic_gequal = 11,
- MN_bicubic_lequal = 12
- };
-
- enum Magnification {
- MG_point = 0,
- MG_bilinear = 1,
- MG_bicubic = 3,
- MG_sharpen = 4,
- MG_add_detail = 5,
- MG_modulate_detail = 6,
- MG_bilinear_gequal = 7,
- MG_bilinear_lequal = 8,
- MG_bicubic_gequal = 9,
- MG_bicubic_lequal = 10
- };
-
- enum RepeatType {
- RT_repeat = 0,
- RT_clamp = 1
- };
-
- enum EnvironmentType {
- ET_modulate = 0,
- ET_blend = 1,
- ET_decal = 2,
- ET_color = 3
- };
-
- enum InternalFormat {
- IF_default = 0,
- IF_i_12a_4 = 1,
- IF_ia_8 = 2,
- IF_rgb_5 = 3,
- IF_rgba_4 = 4,
- IF_ia_12 = 5,
- IF_rgba_8 = 6,
- IF_rgba_12 = 7,
- IF_i_16 = 8, // shadow mode only
- IF_rgb_12 = 9
- };
-
- enum ExternalFormat {
- EF_default = 0,
- EF_pack_8 = 1,
- EF_pack_16 = 2
- };
-
- enum ProjectionType {
- PT_flat_earth = 0,
- PT_lambert = 3,
- PT_utm = 4,
- PT_undefined = 7
- };
-
- enum EarthModel {
- EM_wgs84 = 0,
- EM_wgs72 = 1,
- EM_bessel = 2,
- EM_clarke_1866 = 3,
- EM_nad27 = 4
- };
-
- enum ImageOrigin {
- IO_lower_left = 0,
- IO_upper_left = 1
- };
-
- enum PointsUnits {
- PU_degrees = 0,
- PU_meters = 1,
- PU_pixels = 2
- };
-
- enum Hemisphere {
- H_southern = 0,
- H_northern = 1,
- };
-
- struct LODScale {
- PN_stdfloat _lod;
- PN_stdfloat _scale;
- };
-
- struct GeospecificControlPoint {
- LPoint2d _uv;
- LPoint2d _real_earth;
- };
-
- typedef pvector GeospecificControlPoints;
-
- struct SubtextureDef {
- std::string _name;
- int _left;
- int _bottom;
- int _right;
- int _top;
- };
- typedef pvector SubtextureDefs;
-
- int _num_texels_u;
- int _num_texels_v;
- int _real_world_size_u;
- int _real_world_size_v;
- int _up_vector_x;
- int _up_vector_y;
- FileFormat _file_format;
- Minification _min_filter;
- Magnification _mag_filter;
- RepeatType _repeat;
- RepeatType _repeat_u;
- RepeatType _repeat_v;
- int _modify_flag;
- int _x_pivot_point;
- int _y_pivot_point;
- EnvironmentType _env_type;
- bool _intensity_is_alpha; // if true, a one-channel image is actually
- // an alpha image, not an intensity image.
- double _float_real_world_size_u;
- double _float_real_world_size_v;
- int _imported_origin_code;
- int _kernel_version;
- InternalFormat _internal_format;
- ExternalFormat _external_format;
- bool _use_mipmap_kernel;
- PN_stdfloat _mipmap_kernel[8];
- bool _use_lod_scale;
- LODScale _lod_scale[8];
- PN_stdfloat _clamp;
- Magnification _mag_filter_alpha;
- Magnification _mag_filter_color;
- double _lambert_conic_central_meridian;
- double _lambert_conic_upper_latitude;
- double _lambert_conic_lower_latitude;
- bool _use_detail;
- int _detail_j;
- int _detail_k;
- int _detail_m;
- int _detail_n;
- int _detail_scramble;
- bool _use_tile;
- PN_stdfloat _tile_lower_left_u;
- PN_stdfloat _tile_lower_left_v;
- PN_stdfloat _tile_upper_right_u;
- PN_stdfloat _tile_upper_right_v;
- ProjectionType _projection;
- EarthModel _earth_model;
- int _utm_zone;
- ImageOrigin _image_origin;
- PointsUnits _geospecific_points_units;
- Hemisphere _geospecific_hemisphere;
- std::string _comment;
- int _file_version;
- GeospecificControlPoints _geospecific_control_points;
- SubtextureDefs _subtexture_defs;
-
-protected:
- virtual bool extract_record(FltRecordReader &reader);
- virtual bool build_record(FltRecordWriter &writer) const;
-
-private:
- FltError unpack_attr(const Datagram &datagram);
- FltError pack_attr(Datagram &datagram) const;
-
-public:
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- FltRecord::init_type();
- register_type(_type_handle, "FltTexture",
- FltRecord::get_class_type());
- }
-
-private:
- static TypeHandle _type_handle;
-
- friend class FltHeader;
-};
-
-#endif
diff --git a/pandatool/src/flt/fltTrackplane.cxx b/pandatool/src/flt/fltTrackplane.cxx
deleted file mode 100644
index 13f8a58c..00000000
--- a/pandatool/src/flt/fltTrackplane.cxx
+++ /dev/null
@@ -1,97 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltTrackplane.cxx
- * @author drose
- * @date 2000-08-26
- */
-
-#include "fltTrackplane.h"
-#include "fltRecordReader.h"
-#include "fltRecordWriter.h"
-
-/**
- *
- */
-FltTrackplane::
-FltTrackplane() {
- _origin.set(0.0, 0.0, 0.0);
- _alignment.set(0.0, 0.0, 0.0);
- _plane.set(0.0, 0.0, 1.0);
- _grid_state = false;
- _grid_under = false;
- _grid_angle = 0.0;
- _grid_spacing_x = 1;
- _grid_spacing_y = 1;
- _snap_to_grid = false;
- _grid_size = 10.0;
- _grid_spacing_direction = 0;
- _grid_mask = 0;
-}
-
-/**
- *
- */
-bool FltTrackplane::
-extract_record(FltRecordReader &reader) {
- DatagramIterator &iterator = reader.get_iterator();
-
- _origin[0] = iterator.get_be_float64();
- _origin[1] = iterator.get_be_float64();
- _origin[2] = iterator.get_be_float64();
- _alignment[0] = iterator.get_be_float64();
- _alignment[1] = iterator.get_be_float64();
- _alignment[0] = iterator.get_be_float64();
- _plane[0] = iterator.get_be_float64();
- _plane[1] = iterator.get_be_float64();
- _plane[2] = iterator.get_be_float64();
- _grid_state = (iterator.get_be_int32() != 0);
- _grid_under = (iterator.get_be_int32() != 0);
- _grid_angle = iterator.get_be_float32();
- iterator.skip_bytes(4);
- _grid_spacing_x = iterator.get_be_float64();
- _grid_spacing_y = iterator.get_be_float64();
- _snap_to_grid = (iterator.get_be_int32() != 0);
- _grid_size = iterator.get_be_float64();
- _grid_spacing_direction = iterator.get_be_int32();
- _grid_mask = iterator.get_be_int32();
- iterator.skip_bytes(4);
-
- return true;
-}
-
-/**
- *
- */
-bool FltTrackplane::
-build_record(FltRecordWriter &writer) const {
- Datagram &datagram = writer.update_datagram();
-
- datagram.add_be_float64(_origin[0]);
- datagram.add_be_float64(_origin[1]);
- datagram.add_be_float64(_origin[2]);
- datagram.add_be_float64(_alignment[0]);
- datagram.add_be_float64(_alignment[1]);
- datagram.add_be_float64(_alignment[2]);
- datagram.add_be_float64(_plane[0]);
- datagram.add_be_float64(_plane[1]);
- datagram.add_be_float64(_plane[2]);
- datagram.add_be_int32(_grid_state);
- datagram.add_be_int32(_grid_under);
- datagram.add_be_float32(_grid_angle);
- datagram.pad_bytes(4);
- datagram.add_be_float64(_grid_spacing_x);
- datagram.add_be_float64(_grid_spacing_y);
- datagram.add_be_int32(_snap_to_grid);
- datagram.add_be_float64(_grid_size);
- datagram.add_be_int32(_grid_spacing_direction);
- datagram.add_be_int32(_grid_mask);
- datagram.pad_bytes(4);
-
- return true;
-}
diff --git a/pandatool/src/flt/fltTrackplane.h b/pandatool/src/flt/fltTrackplane.h
deleted file mode 100644
index 306f81e9..00000000
--- a/pandatool/src/flt/fltTrackplane.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltTrackplane.h
- * @author drose
- * @date 2000-08-26
- */
-
-#ifndef FLTTRACKPLANE_H
-#define FLTTRACKPLANE_H
-
-#include "pandatoolbase.h"
-
-#include "luse.h"
-
-class FltRecordReader;
-class FltRecordWriter;
-
-/**
- * A single trackplane entry in the eyepoint/trackplane palette.
- */
-class FltTrackplane {
-public:
- FltTrackplane();
-
- bool extract_record(FltRecordReader &reader);
- bool build_record(FltRecordWriter &writer) const;
-
-public:
- LPoint3d _origin;
- LPoint3d _alignment;
- LVector3d _plane;
- bool _grid_state;
- bool _grid_under;
- PN_stdfloat _grid_angle;
- double _grid_spacing_x;
- double _grid_spacing_y;
- bool _snap_to_grid;
- double _grid_size;
- int _grid_spacing_direction;
- int _grid_mask;
-};
-
-#endif
diff --git a/pandatool/src/flt/fltTransformGeneralMatrix.cxx b/pandatool/src/flt/fltTransformGeneralMatrix.cxx
deleted file mode 100644
index 1c8adf4c..00000000
--- a/pandatool/src/flt/fltTransformGeneralMatrix.cxx
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltTransformGeneralMatrix.cxx
- * @author drose
- * @date 2000-08-24
- */
-
-#include "fltTransformGeneralMatrix.h"
-#include "fltRecordReader.h"
-#include "fltRecordWriter.h"
-
-TypeHandle FltTransformGeneralMatrix::_type_handle;
-
-/**
- *
- */
-FltTransformGeneralMatrix::
-FltTransformGeneralMatrix(FltHeader *header) : FltTransformRecord(header) {
-}
-
-/**
- * Directly sets the general matrix.
- */
-void FltTransformGeneralMatrix::
-set_matrix(const LMatrix4d &matrix) {
- _matrix = matrix;
-}
-
-/**
- * Directly sets the general matrix.
- */
-void FltTransformGeneralMatrix::
-set_matrix(const LMatrix4f &matrix) {
- _matrix = LCAST(double, matrix);
-}
-
-/**
- * Fills in the information in this record based on the information given in
- * the indicated datagram, whose opcode has already been read. Returns true
- * on success, false if the datagram is invalid.
- */
-bool FltTransformGeneralMatrix::
-extract_record(FltRecordReader &reader) {
- if (!FltTransformRecord::extract_record(reader)) {
- return false;
- }
-
- nassertr(reader.get_opcode() == FO_general_matrix, false);
- DatagramIterator &iterator = reader.get_iterator();
-
- for (int r = 0; r < 4; r++) {
- for (int c = 0; c < 4; c++) {
- _matrix(r, c) = iterator.get_be_float32();
- }
- }
-
- check_remaining_size(iterator);
- return true;
-}
-
-/**
- * Fills up the current record on the FltRecordWriter with data for this
- * record, but does not advance the writer. Returns true on success, false if
- * there is some error.
- */
-bool FltTransformGeneralMatrix::
-build_record(FltRecordWriter &writer) const {
- if (!FltTransformRecord::build_record(writer)) {
- return false;
- }
-
- writer.set_opcode(FO_general_matrix);
- Datagram &datagram = writer.update_datagram();
-
- for (int r = 0; r < 4; r++) {
- for (int c = 0; c < 4; c++) {
- datagram.add_be_float32(_matrix(r, c));
- }
- }
-
- return true;
-}
diff --git a/pandatool/src/flt/fltTransformGeneralMatrix.h b/pandatool/src/flt/fltTransformGeneralMatrix.h
deleted file mode 100644
index e56fe94e..00000000
--- a/pandatool/src/flt/fltTransformGeneralMatrix.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltTransformGeneralMatrix.h
- * @author drose
- * @date 2000-08-24
- */
-
-#ifndef FLTTRANSFORMGENERALMATRIX_H
-#define FLTTRANSFORMGENERALMATRIX_H
-
-#include "pandatoolbase.h"
-
-#include "fltTransformRecord.h"
-
-/**
- * A general 4x4 matrix. This appears in the flt file when there is no record
- * of the composition of the transform.
- */
-class FltTransformGeneralMatrix : public FltTransformRecord {
-public:
- FltTransformGeneralMatrix(FltHeader *header);
-
- void set_matrix(const LMatrix4d &matrix);
- void set_matrix(const LMatrix4f &matrix);
-
-protected:
- virtual bool extract_record(FltRecordReader &reader);
- virtual bool build_record(FltRecordWriter &writer) const;
-
-public:
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- FltTransformRecord::init_type();
- register_type(_type_handle, "FltTransformGeneralMatrix",
- FltTransformRecord::get_class_type());
- }
-
-private:
- static TypeHandle _type_handle;
-};
-
-#endif
diff --git a/pandatool/src/flt/fltTransformPut.cxx b/pandatool/src/flt/fltTransformPut.cxx
deleted file mode 100644
index 612c6b07..00000000
--- a/pandatool/src/flt/fltTransformPut.cxx
+++ /dev/null
@@ -1,195 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltTransformPut.cxx
- * @author drose
- * @date 2000-08-29
- */
-
-#include "fltTransformPut.h"
-#include "fltRecordReader.h"
-#include "fltRecordWriter.h"
-
-#include "look_at.h"
-
-TypeHandle FltTransformPut::_type_handle;
-
-/**
- *
- */
-FltTransformPut::
-FltTransformPut(FltHeader *header) : FltTransformRecord(header) {
- _from_origin.set(0.0, 0.0, 0.0);
- _from_align.set(1.0, 0.0, 0.0);
- _from_track.set(1.0, 0.0, 0.0);
- _to_origin.set(0.0, 0.0, 0.0);
- _to_align.set(1.0, 0.0, 0.0);
- _to_track.set(1.0, 0.0, 0.0);
-}
-
-/**
- * Defines the put explicitly. The transformation will map the three "from"
- * points to the corresponding three "to" points.
- */
-void FltTransformPut::
-set(const LPoint3d &from_origin, const LPoint3d &from_align,
- const LPoint3d &from_track,
- const LPoint3d &to_origin, const LPoint3d &to_align,
- const LPoint3d &to_track) {
- _from_origin = from_origin;
- _from_align = from_align;
- _from_track = from_track;
- _to_origin = to_origin;
- _to_align = to_align;
- _to_track = to_track;
-
- recompute_matrix();
-}
-
-/**
- *
- */
-const LPoint3d &FltTransformPut::
-get_from_origin() const {
- return _from_origin;
-}
-
-/**
- *
- */
-const LPoint3d &FltTransformPut::
-get_from_align() const {
- return _from_align;
-}
-
-/**
- *
- */
-const LPoint3d &FltTransformPut::
-get_from_track() const {
- return _from_track;
-}
-
-/**
- *
- */
-const LPoint3d &FltTransformPut::
-get_to_origin() const {
- return _to_origin;
-}
-
-/**
- *
- */
-const LPoint3d &FltTransformPut::
-get_to_align() const {
- return _to_align;
-}
-
-/**
- *
- */
-const LPoint3d &FltTransformPut::
-get_to_track() const {
- return _to_track;
-}
-
-/**
- *
- */
-void FltTransformPut::
-recompute_matrix() {
- LMatrix4d r1, r2;
- look_at(r1, _from_align - _from_origin, _from_track - _from_origin, CS_zup_right);
- look_at(r2, _to_align - _to_origin, _to_track - _to_origin, CS_zup_right);
-
- _matrix =
- LMatrix4d::translate_mat(-_from_origin) *
- invert(r1) *
- r2 *
- LMatrix4d::translate_mat(_to_origin);
-}
-
-/**
- * Fills in the information in this record based on the information given in
- * the indicated datagram, whose opcode has already been read. Returns true
- * on success, false if the datagram is invalid.
- */
-bool FltTransformPut::
-extract_record(FltRecordReader &reader) {
- if (!FltTransformRecord::extract_record(reader)) {
- return false;
- }
-
- nassertr(reader.get_opcode() == FO_put, false);
- DatagramIterator &iterator = reader.get_iterator();
-
- iterator.skip_bytes(4); // Undocumented additional padding.
-
- _from_origin[0] = iterator.get_be_float64();
- _from_origin[1] = iterator.get_be_float64();
- _from_origin[2] = iterator.get_be_float64();
- _from_align[0] = iterator.get_be_float64();
- _from_align[1] = iterator.get_be_float64();
- _from_align[2] = iterator.get_be_float64();
- _from_track[0] = iterator.get_be_float64();
- _from_track[1] = iterator.get_be_float64();
- _from_track[2] = iterator.get_be_float64();
- _to_origin[0] = iterator.get_be_float64();
- _to_origin[1] = iterator.get_be_float64();
- _to_origin[2] = iterator.get_be_float64();
- _to_align[0] = iterator.get_be_float64();
- _to_align[1] = iterator.get_be_float64();
- _to_align[2] = iterator.get_be_float64();
- _to_track[0] = iterator.get_be_float64();
- _to_track[1] = iterator.get_be_float64();
- _to_track[2] = iterator.get_be_float64();
-
- recompute_matrix();
-
- check_remaining_size(iterator);
- return true;
-}
-
-/**
- * Fills up the current record on the FltRecordWriter with data for this
- * record, but does not advance the writer. Returns true on success, false if
- * there is some error.
- */
-bool FltTransformPut::
-build_record(FltRecordWriter &writer) const {
- if (!FltTransformRecord::build_record(writer)) {
- return false;
- }
-
- writer.set_opcode(FO_put);
- Datagram &datagram = writer.update_datagram();
-
- datagram.pad_bytes(4); // Undocumented additional padding.
-
- datagram.add_be_float64(_from_origin[0]);
- datagram.add_be_float64(_from_origin[1]);
- datagram.add_be_float64(_from_origin[2]);
- datagram.add_be_float64(_from_align[0]);
- datagram.add_be_float64(_from_align[1]);
- datagram.add_be_float64(_from_align[2]);
- datagram.add_be_float64(_from_track[0]);
- datagram.add_be_float64(_from_track[1]);
- datagram.add_be_float64(_from_track[2]);
- datagram.add_be_float64(_to_origin[0]);
- datagram.add_be_float64(_to_origin[1]);
- datagram.add_be_float64(_to_origin[2]);
- datagram.add_be_float64(_to_align[0]);
- datagram.add_be_float64(_to_align[1]);
- datagram.add_be_float64(_to_align[2]);
- datagram.add_be_float64(_to_track[0]);
- datagram.add_be_float64(_to_track[1]);
- datagram.add_be_float64(_to_track[2]);
-
- return true;
-}
diff --git a/pandatool/src/flt/fltTransformPut.h b/pandatool/src/flt/fltTransformPut.h
deleted file mode 100644
index fdfab778..00000000
--- a/pandatool/src/flt/fltTransformPut.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltTransformPut.h
- * @author drose
- * @date 2000-08-29
- */
-
-#ifndef FLTTRANSFORMPUT_H
-#define FLTTRANSFORMPUT_H
-
-#include "pandatoolbase.h"
-
-#include "fltTransformRecord.h"
-
-/**
- * A "put", which is a MultiGen concept of defining a transformation by
- * mapping three arbitrary points to three new arbitrary points.
- */
-class FltTransformPut : public FltTransformRecord {
-public:
- FltTransformPut(FltHeader *header);
-
- void set(const LPoint3d &from_origin,
- const LPoint3d &from_align,
- const LPoint3d &from_track,
- const LPoint3d &to_origin,
- const LPoint3d &to_align,
- const LPoint3d &to_track);
-
- const LPoint3d &get_from_origin() const;
- const LPoint3d &get_from_align() const;
- const LPoint3d &get_from_track() const;
- const LPoint3d &get_to_origin() const;
- const LPoint3d &get_to_align() const;
- const LPoint3d &get_to_track() const;
-
-private:
- void recompute_matrix();
-
- LPoint3d _from_origin;
- LPoint3d _from_align;
- LPoint3d _from_track;
- LPoint3d _to_origin;
- LPoint3d _to_align;
- LPoint3d _to_track;
-
-protected:
- virtual bool extract_record(FltRecordReader &reader);
- virtual bool build_record(FltRecordWriter &writer) const;
-
-public:
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- FltTransformRecord::init_type();
- register_type(_type_handle, "FltTransformPut",
- FltTransformRecord::get_class_type());
- }
-
-private:
- static TypeHandle _type_handle;
-};
-
-#endif
diff --git a/pandatool/src/flt/fltTransformRecord.cxx b/pandatool/src/flt/fltTransformRecord.cxx
deleted file mode 100644
index bc1275bc..00000000
--- a/pandatool/src/flt/fltTransformRecord.cxx
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltTransformRecord.cxx
- * @author drose
- * @date 2000-08-24
- */
-
-#include "fltTransformRecord.h"
-
-TypeHandle FltTransformRecord::_type_handle;
-
-/**
- *
- */
-FltTransformRecord::
-FltTransformRecord(FltHeader *header) : FltRecord(header) {
- _matrix = LMatrix4d::ident_mat();
-}
-
-/**
- * Returns the transform matrix represented by this particular component of
- * the transform.
- */
-const LMatrix4d &FltTransformRecord::
-get_matrix() const {
- return _matrix;
-}
diff --git a/pandatool/src/flt/fltTransformRecord.h b/pandatool/src/flt/fltTransformRecord.h
deleted file mode 100644
index b2679b84..00000000
--- a/pandatool/src/flt/fltTransformRecord.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltTransformRecord.h
- * @author drose
- * @date 2000-08-24
- */
-
-#ifndef FLTTRANSFORMRECORD_H
-#define FLTTRANSFORMRECORD_H
-
-#include "pandatoolbase.h"
-
-#include "fltRecord.h"
-
-#include "luse.h"
-
-/**
- * A base class for a number of types of ancillary records that follow beads
- * and indicate some kind of a transformation. Pointers of this type are
- * collected in the FltTransformation class.
- */
-class FltTransformRecord : public FltRecord {
-public:
- FltTransformRecord(FltHeader *header);
-
- const LMatrix4d &get_matrix() const;
-
-protected:
- LMatrix4d _matrix;
-
-public:
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- FltRecord::init_type();
- register_type(_type_handle, "FltTransformRecord",
- FltRecord::get_class_type());
- }
-
-private:
- static TypeHandle _type_handle;
-
- friend class FltBead;
-};
-
-#endif
diff --git a/pandatool/src/flt/fltTransformRotateAboutEdge.cxx b/pandatool/src/flt/fltTransformRotateAboutEdge.cxx
deleted file mode 100644
index ec4bbf95..00000000
--- a/pandatool/src/flt/fltTransformRotateAboutEdge.cxx
+++ /dev/null
@@ -1,144 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltTransformRotateAboutEdge.cxx
- * @author drose
- * @date 2000-08-30
- */
-
-#include "fltTransformRotateAboutEdge.h"
-#include "fltRecordReader.h"
-#include "fltRecordWriter.h"
-
-TypeHandle FltTransformRotateAboutEdge::_type_handle;
-
-/**
- *
- */
-FltTransformRotateAboutEdge::
-FltTransformRotateAboutEdge(FltHeader *header) : FltTransformRecord(header) {
- _point_a.set(0.0, 0.0, 0.0);
- _point_b.set(1.0, 0.0, 0.0);
- _angle = 0.0;
-}
-
-/**
- * Defines the rotation. The angle is given in degrees, counterclockwise
- * about the axis as seen from point a.
- */
-void FltTransformRotateAboutEdge::
-set(const LPoint3d &point_a, const LPoint3d &point_b, PN_stdfloat angle) {
- _point_a = point_a;
- _point_b = point_b;
- _angle = angle;
-
- recompute_matrix();
-}
-
-/**
- *
- */
-const LPoint3d &FltTransformRotateAboutEdge::
-get_point_a() const {
- return _point_a;
-}
-
-/**
- *
- */
-const LPoint3d &FltTransformRotateAboutEdge::
-get_point_b() const {
- return _point_b;
-}
-
-/**
- * Returns the angle of rotation, in degrees counterclockwise about the axis
- * as seen from point a.
- */
-PN_stdfloat FltTransformRotateAboutEdge::
-get_angle() const {
- return _angle;
-}
-
-/**
- *
- */
-void FltTransformRotateAboutEdge::
-recompute_matrix() {
- if (_point_a == _point_b) {
- // Degenerate case.
- _matrix = LMatrix4d::ident_mat();
- } else {
- LVector3d axis = _point_b - _point_a;
- _matrix =
- LMatrix4d::translate_mat(-_point_a) *
- LMatrix4d::rotate_mat(_angle, normalize(axis), CS_zup_right) *
- LMatrix4d::translate_mat(_point_a);
- }
-}
-
-/**
- * Fills in the information in this record based on the information given in
- * the indicated datagram, whose opcode has already been read. Returns true
- * on success, false if the datagram is invalid.
- */
-bool FltTransformRotateAboutEdge::
-extract_record(FltRecordReader &reader) {
- if (!FltTransformRecord::extract_record(reader)) {
- return false;
- }
-
- nassertr(reader.get_opcode() == FO_rotate_about_edge, false);
- DatagramIterator &iterator = reader.get_iterator();
-
- iterator.skip_bytes(4); // Undocumented additional padding.
-
- _point_a[0] = iterator.get_be_float64();
- _point_a[1] = iterator.get_be_float64();
- _point_a[2] = iterator.get_be_float64();
- _point_b[0] = iterator.get_be_float64();
- _point_b[1] = iterator.get_be_float64();
- _point_b[2] = iterator.get_be_float64();
- _angle = iterator.get_be_float32();
-
- iterator.skip_bytes(4); // Undocumented additional padding.
-
- recompute_matrix();
-
- check_remaining_size(iterator);
- return true;
-}
-
-/**
- * Fills up the current record on the FltRecordWriter with data for this
- * record, but does not advance the writer. Returns true on success, false if
- * there is some error.
- */
-bool FltTransformRotateAboutEdge::
-build_record(FltRecordWriter &writer) const {
- if (!FltTransformRecord::build_record(writer)) {
- return false;
- }
-
- writer.set_opcode(FO_rotate_about_edge);
- Datagram &datagram = writer.update_datagram();
-
- datagram.pad_bytes(4); // Undocumented additional padding.
-
- datagram.add_be_float64(_point_a[0]);
- datagram.add_be_float64(_point_a[1]);
- datagram.add_be_float64(_point_a[2]);
- datagram.add_be_float64(_point_b[0]);
- datagram.add_be_float64(_point_b[1]);
- datagram.add_be_float64(_point_b[2]);
- datagram.add_be_float32(_angle);
-
- datagram.pad_bytes(4); // Undocumented additional padding.
-
- return true;
-}
diff --git a/pandatool/src/flt/fltTransformRotateAboutEdge.h b/pandatool/src/flt/fltTransformRotateAboutEdge.h
deleted file mode 100644
index 34ce5854..00000000
--- a/pandatool/src/flt/fltTransformRotateAboutEdge.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltTransformRotateAboutEdge.h
- * @author drose
- * @date 2000-08-30
- */
-
-#ifndef FLTTRANSFORMROTATEABOUTEDGE_H
-#define FLTTRANSFORMROTATEABOUTEDGE_H
-
-#include "pandatoolbase.h"
-
-#include "fltTransformRecord.h"
-
-/**
- * A transformation that rotates about a particular axis in space, defined by
- * two endpoints.
- */
-class FltTransformRotateAboutEdge : public FltTransformRecord {
-public:
- FltTransformRotateAboutEdge(FltHeader *header);
-
- void set(const LPoint3d &point_a, const LPoint3d &point_b, PN_stdfloat angle);
-
- const LPoint3d &get_point_a() const;
- const LPoint3d &get_point_b() const;
- PN_stdfloat get_angle() const;
-
-private:
- void recompute_matrix();
-
- LPoint3d _point_a;
- LPoint3d _point_b;
- PN_stdfloat _angle;
-
-protected:
- virtual bool extract_record(FltRecordReader &reader);
- virtual bool build_record(FltRecordWriter &writer) const;
-
-public:
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- FltTransformRecord::init_type();
- register_type(_type_handle, "FltTransformRotateAboutEdge",
- FltTransformRecord::get_class_type());
- }
-
-private:
- static TypeHandle _type_handle;
-};
-
-#endif
diff --git a/pandatool/src/flt/fltTransformRotateAboutPoint.cxx b/pandatool/src/flt/fltTransformRotateAboutPoint.cxx
deleted file mode 100644
index 1c6db879..00000000
--- a/pandatool/src/flt/fltTransformRotateAboutPoint.cxx
+++ /dev/null
@@ -1,140 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltTransformRotateAboutPoint.cxx
- * @author drose
- * @date 2000-08-30
- */
-
-#include "fltTransformRotateAboutPoint.h"
-#include "fltRecordReader.h"
-#include "fltRecordWriter.h"
-
-TypeHandle FltTransformRotateAboutPoint::_type_handle;
-
-/**
- *
- */
-FltTransformRotateAboutPoint::
-FltTransformRotateAboutPoint(FltHeader *header) : FltTransformRecord(header) {
- _center.set(0.0, 0.0, 0.0);
- _axis.set(1.0, 0.0, 0.0);
- _angle = 0.0;
-}
-
-/**
- * Defines the rotation. The angle is given in degrees, counterclockwise
- * about the axis as seen from point a.
- */
-void FltTransformRotateAboutPoint::
-set(const LPoint3d ¢er, const LVector3 &axis, PN_stdfloat angle) {
- _center = center;
- _axis = axis;
- _angle = angle;
-
- recompute_matrix();
-}
-
-/**
- *
- */
-const LPoint3d &FltTransformRotateAboutPoint::
-get_center() const {
- return _center;
-}
-
-/**
- *
- */
-const LVector3 &FltTransformRotateAboutPoint::
-get_axis() const {
- return _axis;
-}
-
-/**
- * Returns the angle of rotation, in degrees counterclockwise about the axis.
- */
-PN_stdfloat FltTransformRotateAboutPoint::
-get_angle() const {
- return _angle;
-}
-
-/**
- *
- */
-void FltTransformRotateAboutPoint::
-recompute_matrix() {
- if (_axis == LVector3::zero()) {
- // Degenerate case.
- _matrix = LMatrix4d::ident_mat();
- } else {
- LVector3d axis = LCAST(double, _axis);
-
- _matrix =
- LMatrix4d::translate_mat(-_center) *
- LMatrix4d::rotate_mat(_angle, axis, CS_zup_right) *
- LMatrix4d::translate_mat(_center);
- }
-}
-
-/**
- * Fills in the information in this record based on the information given in
- * the indicated datagram, whose opcode has already been read. Returns true
- * on success, false if the datagram is invalid.
- */
-bool FltTransformRotateAboutPoint::
-extract_record(FltRecordReader &reader) {
- if (!FltTransformRecord::extract_record(reader)) {
- return false;
- }
-
- nassertr(reader.get_opcode() == FO_rotate_about_point, false);
- DatagramIterator &iterator = reader.get_iterator();
-
- iterator.skip_bytes(4); // Undocumented additional padding.
-
- _center[0] = iterator.get_be_float64();
- _center[1] = iterator.get_be_float64();
- _center[2] = iterator.get_be_float64();
- _axis[0] = iterator.get_be_float32();
- _axis[1] = iterator.get_be_float32();
- _axis[2] = iterator.get_be_float32();
- _angle = iterator.get_be_float32();
-
- recompute_matrix();
-
- check_remaining_size(iterator);
- return true;
-}
-
-/**
- * Fills up the current record on the FltRecordWriter with data for this
- * record, but does not advance the writer. Returns true on success, false if
- * there is some error.
- */
-bool FltTransformRotateAboutPoint::
-build_record(FltRecordWriter &writer) const {
- if (!FltTransformRecord::build_record(writer)) {
- return false;
- }
-
- writer.set_opcode(FO_rotate_about_point);
- Datagram &datagram = writer.update_datagram();
-
- datagram.pad_bytes(4); // Undocumented additional padding.
-
- datagram.add_be_float64(_center[0]);
- datagram.add_be_float64(_center[1]);
- datagram.add_be_float64(_center[2]);
- datagram.add_be_float32(_axis[0]);
- datagram.add_be_float32(_axis[1]);
- datagram.add_be_float32(_axis[2]);
- datagram.add_be_float32(_angle);
-
- return true;
-}
diff --git a/pandatool/src/flt/fltTransformRotateAboutPoint.h b/pandatool/src/flt/fltTransformRotateAboutPoint.h
deleted file mode 100644
index 716bb56c..00000000
--- a/pandatool/src/flt/fltTransformRotateAboutPoint.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltTransformRotateAboutPoint.h
- * @author drose
- * @date 2000-08-30
- */
-
-#ifndef FLTTRANSFORMROTATEABOUTPOINT_H
-#define FLTTRANSFORMROTATEABOUTPOINT_H
-
-#include "pandatoolbase.h"
-
-#include "fltTransformRecord.h"
-
-/**
- * A transformation that rotates about a particular axis in space, defined by
- * a point and vector.
- */
-class FltTransformRotateAboutPoint : public FltTransformRecord {
-public:
- FltTransformRotateAboutPoint(FltHeader *header);
-
- void set(const LPoint3d ¢er, const LVector3 &axis, PN_stdfloat angle);
-
- const LPoint3d &get_center() const;
- const LVector3 &get_axis() const;
- PN_stdfloat get_angle() const;
-
-private:
- void recompute_matrix();
-
- LPoint3d _center;
- LVector3 _axis;
- PN_stdfloat _angle;
-
-protected:
- virtual bool extract_record(FltRecordReader &reader);
- virtual bool build_record(FltRecordWriter &writer) const;
-
-public:
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- FltTransformRecord::init_type();
- register_type(_type_handle, "FltTransformRotateAboutPoint",
- FltTransformRecord::get_class_type());
- }
-
-private:
- static TypeHandle _type_handle;
-};
-
-#endif
diff --git a/pandatool/src/flt/fltTransformRotateScale.cxx b/pandatool/src/flt/fltTransformRotateScale.cxx
deleted file mode 100644
index e81dbb47..00000000
--- a/pandatool/src/flt/fltTransformRotateScale.cxx
+++ /dev/null
@@ -1,208 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltTransformRotateScale.cxx
- * @author drose
- * @date 2000-08-30
- */
-
-#include "fltTransformRotateScale.h"
-#include "fltRecordReader.h"
-#include "fltRecordWriter.h"
-
-#include "mathNumbers.h"
-#include "look_at.h"
-
-TypeHandle FltTransformRotateScale::_type_handle;
-
-/**
- *
- */
-FltTransformRotateScale::
-FltTransformRotateScale(FltHeader *header) : FltTransformRecord(header) {
- _center.set(0.0, 0.0, 0.0);
- _reference_point.set(0.0, 0.0, 0.0);
- _to_point.set(0.0, 0.0, 0.0);
- _overall_scale = 1.0;
- _axis_scale = 1.0;
- _angle = 0.0;
-}
-
-/**
- * Defines the transform explicitly. The angle of rotation is determined by
- * the angle between the reference point and the to point (relative to the
- * center), and the scale factor is determined by the distance between the
- * reference point and the center point. If axis_scale is true, the scale is
- * along reference point axis only; otherwise, it is a uniform scale.
- */
-void FltTransformRotateScale::
-set(const LPoint3d ¢er, const LPoint3d &reference_point,
- const LPoint3d &to_point, bool axis_scale) {
- _center = center;
- _reference_point = reference_point;
- _to_point = to_point;
-
- LVector3d v1 = _reference_point - _center;
- LVector3d v2 = _to_point - _center;
-
- _angle =
- acos(dot(normalize(v1), normalize(v2))) * 180.0 / MathNumbers::pi;
-
- if (axis_scale) {
- _axis_scale = length(v1);
- _overall_scale = 1.0;
- } else {
- _overall_scale = length(v1);
- _axis_scale = 1.0;
- }
-
- recompute_matrix();
-}
-
-/**
- *
- */
-const LPoint3d &FltTransformRotateScale::
-get_center() const {
- return _center;
-}
-
-/**
- *
- */
-const LPoint3d &FltTransformRotateScale::
-get_reference_point() const {
- return _reference_point;
-}
-
-/**
- *
- */
-const LPoint3d &FltTransformRotateScale::
-get_to_point() const {
- return _to_point;
-}
-
-/**
- * Returns the overall scale factor.
- */
-PN_stdfloat FltTransformRotateScale::
-get_overall_scale() const {
- return _overall_scale;
-}
-
-/**
- * Returns the scale factor in the direction of the axis.
- */
-PN_stdfloat FltTransformRotateScale::
-get_axis_scale() const {
- return _axis_scale;
-}
-
-/**
- * Returns the angle of rotation in degrees.
- */
-PN_stdfloat FltTransformRotateScale::
-get_angle() const {
- return _angle;
-}
-
-/**
- *
- */
-void FltTransformRotateScale::
-recompute_matrix() {
- LVector3d v1 = _reference_point - _center;
- LVector3d v2 = _to_point - _center;
- LVector3d rotate_axis = normalize(cross(v1, v2));
-
- // To scale along an axis, we have to do a bit of work. First determine the
- // matrices to rotate and unrotate the rotate axis to the y-forward axis.
- LMatrix4d r1;
- look_at(r1, v1, rotate_axis, CS_zup_right);
-
- _matrix =
- LMatrix4d::translate_mat(-_center) *
- r1 *
- LMatrix4d::scale_mat(1.0, _axis_scale, 1.0) *
- LMatrix4d::scale_mat(_overall_scale) *
- invert(r1) *
- LMatrix4d::rotate_mat(_angle, rotate_axis, CS_zup_right) *
- LMatrix4d::translate_mat(_center);
-}
-
-/**
- * Fills in the information in this record based on the information given in
- * the indicated datagram, whose opcode has already been read. Returns true
- * on success, false if the datagram is invalid.
- */
-bool FltTransformRotateScale::
-extract_record(FltRecordReader &reader) {
- if (!FltTransformRecord::extract_record(reader)) {
- return false;
- }
-
- nassertr(reader.get_opcode() == FO_rotate_and_scale, false);
- DatagramIterator &iterator = reader.get_iterator();
-
- iterator.skip_bytes(4); // Undocumented additional padding.
-
- _center[0] = iterator.get_be_float64();
- _center[1] = iterator.get_be_float64();
- _center[2] = iterator.get_be_float64();
- _reference_point[0] = iterator.get_be_float64();
- _reference_point[1] = iterator.get_be_float64();
- _reference_point[2] = iterator.get_be_float64();
- _to_point[0] = iterator.get_be_float64();
- _to_point[1] = iterator.get_be_float64();
- _to_point[2] = iterator.get_be_float64();
- _overall_scale = iterator.get_be_float32();
- _axis_scale = iterator.get_be_float32();
- _angle = iterator.get_be_float32();
-
- iterator.skip_bytes(4); // Undocumented additional padding.
-
- recompute_matrix();
-
- check_remaining_size(iterator);
- return true;
-}
-
-/**
- * Fills up the current record on the FltRecordWriter with data for this
- * record, but does not advance the writer. Returns true on success, false if
- * there is some error.
- */
-bool FltTransformRotateScale::
-build_record(FltRecordWriter &writer) const {
- if (!FltTransformRecord::build_record(writer)) {
- return false;
- }
-
- writer.set_opcode(FO_put);
- Datagram &datagram = writer.update_datagram();
-
- datagram.pad_bytes(4); // Undocumented additional padding.
-
- datagram.add_be_float64(_center[0]);
- datagram.add_be_float64(_center[1]);
- datagram.add_be_float64(_center[2]);
- datagram.add_be_float64(_reference_point[0]);
- datagram.add_be_float64(_reference_point[1]);
- datagram.add_be_float64(_reference_point[2]);
- datagram.add_be_float64(_to_point[0]);
- datagram.add_be_float64(_to_point[1]);
- datagram.add_be_float64(_to_point[2]);
- datagram.add_be_float32(_overall_scale);
- datagram.add_be_float32(_axis_scale);
- datagram.add_be_float32(_angle);
-
- datagram.pad_bytes(4); // Undocumented additional padding.
-
- return true;
-}
diff --git a/pandatool/src/flt/fltTransformRotateScale.h b/pandatool/src/flt/fltTransformRotateScale.h
deleted file mode 100644
index 29b72ddd..00000000
--- a/pandatool/src/flt/fltTransformRotateScale.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltTransformRotateScale.h
- * @author drose
- * @date 2000-08-30
- */
-
-#ifndef FLTTRANSFORMROTATESCALE_H
-#define FLTTRANSFORMROTATESCALE_H
-
-#include "pandatoolbase.h"
-
-#include "fltTransformRecord.h"
-
-/**
- * A combination rotation and scale. This is sometimes called "Rotate To
- * Point" within MultiGen.
- */
-class FltTransformRotateScale : public FltTransformRecord {
-public:
- FltTransformRotateScale(FltHeader *header);
-
- void set(const LPoint3d ¢er, const LPoint3d &reference_point,
- const LPoint3d &to_point, bool axis_scale);
-
- const LPoint3d &get_center() const;
- const LPoint3d &get_reference_point() const;
- const LPoint3d &get_to_point() const;
- PN_stdfloat get_overall_scale() const;
- PN_stdfloat get_axis_scale() const;
- PN_stdfloat get_angle() const;
-
-private:
- void recompute_matrix();
-
- LPoint3d _center;
- LPoint3d _reference_point;
- LPoint3d _to_point;
- PN_stdfloat _overall_scale;
- PN_stdfloat _axis_scale;
- PN_stdfloat _angle;
-
-protected:
- virtual bool extract_record(FltRecordReader &reader);
- virtual bool build_record(FltRecordWriter &writer) const;
-
-public:
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- FltTransformRecord::init_type();
- register_type(_type_handle, "FltTransformRotateScale",
- FltTransformRecord::get_class_type());
- }
-
-private:
- static TypeHandle _type_handle;
-};
-
-#endif
diff --git a/pandatool/src/flt/fltTransformScale.cxx b/pandatool/src/flt/fltTransformScale.cxx
deleted file mode 100644
index 69ae6f4c..00000000
--- a/pandatool/src/flt/fltTransformScale.cxx
+++ /dev/null
@@ -1,142 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltTransformScale.cxx
- * @author drose
- * @date 2000-08-30
- */
-
-#include "fltTransformScale.h"
-#include "fltRecordReader.h"
-#include "fltRecordWriter.h"
-
-TypeHandle FltTransformScale::_type_handle;
-
-/**
- *
- */
-FltTransformScale::
-FltTransformScale(FltHeader *header) : FltTransformRecord(header) {
- _center.set(0.0, 0.0, 0.0);
- _scale.set(1.0, 1.0, 1.0);
-}
-
-/**
- * Defines the scale.
- */
-void FltTransformScale::
-set(const LPoint3d ¢er, const LVecBase3 &scale) {
- _center = center;
- _scale = scale;
-
- recompute_matrix();
-}
-
-/**
- * Returns true if the center is specified, false if it is not. For some
- * reason, MultiGen stores large negative numbers in for the center if it is
- * not specified. It is unclear what the purpose of this is.
- */
-bool FltTransformScale::
-has_center() const {
- return
- _center[0] > -1e+08 &&
- _center[1] > -1e+08 &&
- _center[2] > -1e+08;
-}
-
-/**
- *
- */
-const LPoint3d &FltTransformScale::
-get_center() const {
- return _center;
-}
-
-/**
- *
- */
-const LVecBase3 &FltTransformScale::
-get_scale() const {
- return _scale;
-}
-
-/**
- *
- */
-void FltTransformScale::
-recompute_matrix() {
- if (has_center()) {
- _matrix =
- LMatrix4d::translate_mat(-_center) *
- LMatrix4d::scale_mat(LCAST(double, _scale)) *
- LMatrix4d::translate_mat(_center);
- } else {
- _matrix =
- LMatrix4d::scale_mat(LCAST(double, _scale));
- }
-}
-
-/**
- * Fills in the information in this record based on the information given in
- * the indicated datagram, whose opcode has already been read. Returns true
- * on success, false if the datagram is invalid.
- */
-bool FltTransformScale::
-extract_record(FltRecordReader &reader) {
- if (!FltTransformRecord::extract_record(reader)) {
- return false;
- }
-
- nassertr(reader.get_opcode() == FO_scale, false);
- DatagramIterator &iterator = reader.get_iterator();
-
- iterator.skip_bytes(4);
-
- _center[0] = iterator.get_be_float64();
- _center[1] = iterator.get_be_float64();
- _center[2] = iterator.get_be_float64();
- _scale[0] = iterator.get_be_float32();
- _scale[1] = iterator.get_be_float32();
- _scale[2] = iterator.get_be_float32();
-
- iterator.skip_bytes(4); // Undocumented additional padding.
-
- recompute_matrix();
-
- check_remaining_size(iterator);
- return true;
-}
-
-/**
- * Fills up the current record on the FltRecordWriter with data for this
- * record, but does not advance the writer. Returns true on success, false if
- * there is some error.
- */
-bool FltTransformScale::
-build_record(FltRecordWriter &writer) const {
- if (!FltTransformRecord::build_record(writer)) {
- return false;
- }
-
- writer.set_opcode(FO_scale);
- Datagram &datagram = writer.update_datagram();
-
- datagram.pad_bytes(4); // Undocumented additional padding.
-
- datagram.add_be_float64(_center[0]);
- datagram.add_be_float64(_center[1]);
- datagram.add_be_float64(_center[2]);
- datagram.add_be_float32(_scale[0]);
- datagram.add_be_float32(_scale[1]);
- datagram.add_be_float32(_scale[2]);
-
- datagram.pad_bytes(4); // Undocumented additional padding.
-
- return true;
-}
diff --git a/pandatool/src/flt/fltTransformScale.h b/pandatool/src/flt/fltTransformScale.h
deleted file mode 100644
index 01bc6296..00000000
--- a/pandatool/src/flt/fltTransformScale.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltTransformScale.h
- * @author drose
- * @date 2000-08-30
- */
-
-#ifndef FLTTRANSFORMSCALE_H
-#define FLTTRANSFORMSCALE_H
-
-#include "pandatoolbase.h"
-
-#include "fltTransformRecord.h"
-
-/**
- * A transformation that applies a (possibly nonuniform) scale.
- */
-class FltTransformScale : public FltTransformRecord {
-public:
- FltTransformScale(FltHeader *header);
-
- void set(const LPoint3d ¢er, const LVecBase3 &scale);
-
- bool has_center() const;
- const LPoint3d &get_center() const;
- const LVecBase3 &get_scale() const;
-
-private:
- void recompute_matrix();
-
- LPoint3d _center;
- LVecBase3 _scale;
-
-protected:
- virtual bool extract_record(FltRecordReader &reader);
- virtual bool build_record(FltRecordWriter &writer) const;
-
-public:
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- FltTransformRecord::init_type();
- register_type(_type_handle, "FltTransformScale",
- FltTransformRecord::get_class_type());
- }
-
-private:
- static TypeHandle _type_handle;
-};
-
-#endif
diff --git a/pandatool/src/flt/fltTransformTranslate.cxx b/pandatool/src/flt/fltTransformTranslate.cxx
deleted file mode 100644
index 1a06d761..00000000
--- a/pandatool/src/flt/fltTransformTranslate.cxx
+++ /dev/null
@@ -1,122 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltTransformTranslate.cxx
- * @author drose
- * @date 2000-08-30
- */
-
-#include "fltTransformTranslate.h"
-#include "fltRecordReader.h"
-#include "fltRecordWriter.h"
-
-TypeHandle FltTransformTranslate::_type_handle;
-
-/**
- *
- */
-FltTransformTranslate::
-FltTransformTranslate(FltHeader *header) : FltTransformRecord(header) {
- _from.set(0.0, 0.0, 0.0);
- _delta.set(0.0, 0.0, 0.0);
-}
-
-/**
- * Defines the translation. The "from" point seems to be pretty much ignored.
- */
-void FltTransformTranslate::
-set(const LPoint3d &from, const LVector3d &delta) {
- _from = from;
- _delta = delta;
-
- recompute_matrix();
-}
-
-/**
- * Returns the reference point of the translation. This is largely
- * meaningless.
- */
-const LPoint3d &FltTransformTranslate::
-get_from() const {
- return _from;
-}
-
-/**
- *
- */
-const LVector3d &FltTransformTranslate::
-get_delta() const {
- return _delta;
-}
-
-/**
- *
- */
-void FltTransformTranslate::
-recompute_matrix() {
- _matrix = LMatrix4d::translate_mat(_delta);
-}
-
-/**
- * Fills in the information in this record based on the information given in
- * the indicated datagram, whose opcode has already been read. Returns true
- * on success, false if the datagram is invalid.
- */
-bool FltTransformTranslate::
-extract_record(FltRecordReader &reader) {
- if (!FltTransformRecord::extract_record(reader)) {
- return false;
- }
-
- nassertr(reader.get_opcode() == FO_translate, false);
- DatagramIterator &iterator = reader.get_iterator();
-
- iterator.skip_bytes(4); // Undocumented additional padding.
-
- _from[0] = iterator.get_be_float64();
- _from[1] = iterator.get_be_float64();
- _from[2] = iterator.get_be_float64();
- _delta[0] = iterator.get_be_float64();
- _delta[1] = iterator.get_be_float64();
- _delta[2] = iterator.get_be_float64();
-
- // iterator.skip_bytes(4); Undocumented additional padding.
-
- recompute_matrix();
-
- check_remaining_size(iterator);
- return true;
-}
-
-/**
- * Fills up the current record on the FltRecordWriter with data for this
- * record, but does not advance the writer. Returns true on success, false if
- * there is some error.
- */
-bool FltTransformTranslate::
-build_record(FltRecordWriter &writer) const {
- if (!FltTransformRecord::build_record(writer)) {
- return false;
- }
-
- writer.set_opcode(FO_translate);
- Datagram &datagram = writer.update_datagram();
-
- datagram.pad_bytes(4); // Undocumented additional padding.
-
- datagram.add_be_float64(_from[0]);
- datagram.add_be_float64(_from[1]);
- datagram.add_be_float64(_from[2]);
- datagram.add_be_float64(_delta[0]);
- datagram.add_be_float64(_delta[1]);
- datagram.add_be_float64(_delta[2]);
-
- // datagram.pad_bytes(4); Undocumented additional padding.
-
- return true;
-}
diff --git a/pandatool/src/flt/fltTransformTranslate.h b/pandatool/src/flt/fltTransformTranslate.h
deleted file mode 100644
index c9a0c879..00000000
--- a/pandatool/src/flt/fltTransformTranslate.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltTransformTranslate.h
- * @author drose
- * @date 2000-08-30
- */
-
-#ifndef FLTTRANSFORMTRANSLATE_H
-#define FLTTRANSFORMTRANSLATE_H
-
-#include "pandatoolbase.h"
-
-#include "fltTransformRecord.h"
-
-/**
- * A transformation that applies a translation.
- */
-class FltTransformTranslate : public FltTransformRecord {
-public:
- FltTransformTranslate(FltHeader *header);
-
- void set(const LPoint3d &from, const LVector3d &delta);
-
- const LPoint3d &get_from() const;
- const LVector3d &get_delta() const;
-
-private:
- void recompute_matrix();
-
- LPoint3d _from;
- LVector3d _delta;
-
-protected:
- virtual bool extract_record(FltRecordReader &reader);
- virtual bool build_record(FltRecordWriter &writer) const;
-
-public:
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- FltTransformRecord::init_type();
- register_type(_type_handle, "FltTransformTranslate",
- FltTransformRecord::get_class_type());
- }
-
-private:
- static TypeHandle _type_handle;
-};
-
-#endif
diff --git a/pandatool/src/flt/fltUnsupportedRecord.cxx b/pandatool/src/flt/fltUnsupportedRecord.cxx
deleted file mode 100644
index 7a6e67aa..00000000
--- a/pandatool/src/flt/fltUnsupportedRecord.cxx
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltUnsupportedRecord.cxx
- * @author drose
- * @date 2000-08-24
- */
-
-#include "fltUnsupportedRecord.h"
-#include "fltRecordReader.h"
-#include "fltRecordWriter.h"
-
-TypeHandle FltUnsupportedRecord::_type_handle;
-
-/**
- *
- */
-FltUnsupportedRecord::
-FltUnsupportedRecord(FltHeader *header) : FltRecord(header) {
- _opcode = FO_none;
-}
-
-/**
- * Writes a quick one-line description of the bead, but not its children.
- * This is a human-readable description, primarily for debugging; to write a
- * flt file, use FltHeader::write_flt().
- */
-void FltUnsupportedRecord::
-output(std::ostream &out) const {
- out << "Unsupported(" << _opcode << ")";
-}
-
-/**
- * Fills in the information in this bead based on the information given in the
- * indicated datagram, whose opcode has already been read. Returns true on
- * success, false if the datagram is invalid.
- */
-bool FltUnsupportedRecord::
-extract_record(FltRecordReader &reader) {
- _opcode = reader.get_opcode();
- _datagram = reader.get_datagram();
-
- return true;
-}
-
-/**
- * Fills up the current record on the FltRecordWriter with data for this
- * record, but does not advance the writer. Returns true on success, false if
- * there is some error.
- */
-bool FltUnsupportedRecord::
-build_record(FltRecordWriter &writer) const {
- writer.set_opcode(_opcode);
- writer.set_datagram(_datagram);
- return true;
-}
diff --git a/pandatool/src/flt/fltUnsupportedRecord.h b/pandatool/src/flt/fltUnsupportedRecord.h
deleted file mode 100644
index a358577d..00000000
--- a/pandatool/src/flt/fltUnsupportedRecord.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltUnsupportedRecord.h
- * @author drose
- * @date 2000-08-24
- */
-
-#ifndef FLTUNSUPPORTEDRECORD_H
-#define FLTUNSUPPORTEDRECORD_H
-
-#include "pandatoolbase.h"
-
-#include "fltRecord.h"
-
-#include "datagram.h"
-
-/**
- *
- */
-class FltUnsupportedRecord : public FltRecord {
-public:
- FltUnsupportedRecord(FltHeader *header);
-
- virtual void output(std::ostream &out) const;
-
-protected:
- virtual bool extract_record(FltRecordReader &reader);
- virtual bool build_record(FltRecordWriter &writer) const;
-
-private:
- FltOpcode _opcode;
- Datagram _datagram;
-
-public:
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- FltRecord::init_type();
- register_type(_type_handle, "FltUnsupportedRecord",
- FltRecord::get_class_type());
- }
-
-private:
- static TypeHandle _type_handle;
-
- friend class FltHeader;
-};
-
-#endif
diff --git a/pandatool/src/flt/fltVectorRecord.cxx b/pandatool/src/flt/fltVectorRecord.cxx
deleted file mode 100644
index dbe23a63..00000000
--- a/pandatool/src/flt/fltVectorRecord.cxx
+++ /dev/null
@@ -1,77 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltVectorRecord.cxx
- * @author drose
- * @date 2002-08-30
- */
-
-#include "fltVectorRecord.h"
-#include "fltRecordReader.h"
-#include "fltRecordWriter.h"
-
-TypeHandle FltVectorRecord::_type_handle;
-
-/**
- *
- */
-FltVectorRecord::
-FltVectorRecord(FltHeader *header) : FltRecord(header) {
- _vector.set(0.0f, 0.0f, 0.0f);
-}
-
-/**
- * Returns the vector value.
- */
-const LVector3 &FltVectorRecord::
-get_vector() const {
- return _vector;
-}
-
-/**
- * Fills in the information in this record based on the information given in
- * the indicated datagram, whose opcode has already been read. Returns true
- * on success, false if the datagram is invalid.
- */
-bool FltVectorRecord::
-extract_record(FltRecordReader &reader) {
- if (!FltRecord::extract_record(reader)) {
- return false;
- }
-
- nassertr(reader.get_opcode() == FO_vector, false);
- DatagramIterator &iterator = reader.get_iterator();
-
- _vector[0] = iterator.get_be_float32();
- _vector[1] = iterator.get_be_float32();
- _vector[2] = iterator.get_be_float32();
-
- check_remaining_size(iterator);
- return true;
-}
-
-/**
- * Fills up the current record on the FltRecordWriter with data for this
- * record, but does not advance the writer. Returns true on success, false if
- * there is some error.
- */
-bool FltVectorRecord::
-build_record(FltRecordWriter &writer) const {
- if (!FltRecord::build_record(writer)) {
- return false;
- }
-
- writer.set_opcode(FO_vector);
- Datagram &datagram = writer.update_datagram();
-
- datagram.add_be_float32(_vector[0]);
- datagram.add_be_float32(_vector[1]);
- datagram.add_be_float32(_vector[2]);
-
- return true;
-}
diff --git a/pandatool/src/flt/fltVectorRecord.h b/pandatool/src/flt/fltVectorRecord.h
deleted file mode 100644
index e099652e..00000000
--- a/pandatool/src/flt/fltVectorRecord.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltVectorRecord.h
- * @author drose
- * @date 2002-08-30
- */
-
-#ifndef FLTVECTORRECORD_H
-#define FLTVECTORRECORD_H
-
-#include "pandatoolbase.h"
-
-#include "fltRecord.h"
-
-#include "luse.h"
-
-/**
- * This is an ancillary record of the old (pre-15.4) face node. Its only use
- * is to provide the direction vector for unidirectional and bidirectional
- * light point faces.
- */
-class FltVectorRecord : public FltRecord {
-public:
- FltVectorRecord(FltHeader *header);
-
- const LVector3 &get_vector() const;
-
-protected:
- LVector3 _vector;
-
-protected:
- virtual bool extract_record(FltRecordReader &reader);
- virtual bool build_record(FltRecordWriter &writer) const;
-
-public:
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- FltRecord::init_type();
- register_type(_type_handle, "FltVectorRecord",
- FltRecord::get_class_type());
- }
-
-private:
- static TypeHandle _type_handle;
-
- friend class FltBead;
-};
-
-#endif
diff --git a/pandatool/src/flt/fltVertex.I b/pandatool/src/flt/fltVertex.I
deleted file mode 100644
index 2f7717af..00000000
--- a/pandatool/src/flt/fltVertex.I
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltVertex.I
- * @author drose
- * @date 2000-08-30
- */
-
-/**
- * Returns true if the vertex has a primary color indicated, false otherwise.
- */
-INLINE bool FltVertex::
-has_color() const {
- // Even if the no_color bit is not set, if the color_index is -1, the vertex
- // doesn't have a color (unless we've got packed color).
- return ((_flags & F_no_color) == 0 &&
- (_color_index != -1 || ((_flags & F_packed_color) != 0)));
-}
-
-/**
- * Sets the color of the vertex, using the packed color convention. The alpha
- * component is ignored.
- */
-INLINE void FltVertex::
-set_color(const LColor &color) {
- set_rgb(LRGBColor(color[0], color[1], color[2]));
-}
diff --git a/pandatool/src/flt/fltVertex.cxx b/pandatool/src/flt/fltVertex.cxx
deleted file mode 100644
index 77cac997..00000000
--- a/pandatool/src/flt/fltVertex.cxx
+++ /dev/null
@@ -1,259 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltVertex.cxx
- * @author drose
- * @date 2000-08-25
- */
-
-#include "fltVertex.h"
-#include "fltRecordReader.h"
-#include "fltRecordWriter.h"
-#include "fltHeader.h"
-
-TypeHandle FltVertex::_type_handle;
-
-/**
- *
- */
-FltVertex::
-FltVertex(FltHeader *header) : FltRecord(header) {
- _color_name_index = 0;
- _flags = F_no_color;
- _pos.set(0.0, 0.0, 0.0);
- _normal.set(0.0, 0.0, 0.0);
- _uv.set(0.0, 0.0);
- _color_index = 0;
-
- _has_normal = false;
- _has_uv = false;
-}
-
-/**
- * Returns the opcode that this record will be written as.
- */
-FltOpcode FltVertex::
-get_opcode() const {
- if (_has_normal) {
- if (_has_uv) {
- return FO_vertex_cnu;
- } else {
- return FO_vertex_cn;
- }
- } else {
- if (_has_uv) {
- return FO_vertex_cu;
- } else {
- return FO_vertex_c;
- }
- }
-}
-
-/**
- * Returns the length of this record in bytes as it will be written to the flt
- * file.
- */
-int FltVertex::
-get_record_length() const {
- if (_header->get_flt_version() < 1520) {
- // Version 14.2
- switch (get_opcode()) {
- case FO_vertex_c:
- return 36;
-
- case FO_vertex_cn:
- return 48;
-
- case FO_vertex_cnu:
- return 56;
-
- case FO_vertex_cu:
- return 44;
-
- default:
- nassertr(false, 0);
- }
-
- } else {
- // Version 15.2 and higher
- switch (get_opcode()) {
- case FO_vertex_c:
- return 40;
-
- case FO_vertex_cn:
- return 56;
-
- case FO_vertex_cnu:
- return 64;
-
- case FO_vertex_cu:
- return 48;
-
- default:
- nassertr(false, 0);
- }
- }
-
- return 0;
-}
-
-/**
- * If has_color() indicates true, returns the color of the vertex, as a four-
- * component value. In the case of a vertex, the alpha channel will always be
- * 1.0, as MultiGen does not store transparency per-vertex.
- */
-LColor FltVertex::
-get_color() const {
- nassertr(has_color(), LColor(0.0, 0.0, 0.0, 0.0));
-
- return _header->get_color(_color_index, (_flags & F_packed_color) != 0,
- _packed_color, 0);
-}
-
-/**
- * If has_color() indicates true, returns the color of the vertex, as a three-
- * component value.
- */
-LRGBColor FltVertex::
-get_rgb() const {
- nassertr(has_color(), LRGBColor(0.0, 0.0, 0.0));
-
- return _header->get_rgb(_color_index, (_flags & F_packed_color) != 0,
- _packed_color);
-}
-
-/**
- * Sets the color of the vertex, using the packed color convention.
- */
-void FltVertex::
-set_rgb(const LRGBColor &rgb) {
- _packed_color.set_rgb(rgb);
- _flags = ((_flags & ~F_no_color) | F_packed_color);
-}
-
-/**
- * Fills in the information in this record based on the information given in
- * the indicated datagram, whose opcode has already been read. Returns true
- * on success, false if the datagram is invalid.
- */
-bool FltVertex::
-extract_record(FltRecordReader &reader) {
- if (!FltRecord::extract_record(reader)) {
- return false;
- }
-
- switch (reader.get_opcode()) {
- case FO_vertex_c:
- _has_normal = false;
- _has_uv = false;
- break;
-
- case FO_vertex_cn:
- _has_normal = true;
- _has_uv = false;
- break;
-
- case FO_vertex_cnu:
- _has_normal = true;
- _has_uv = true;
- break;
-
- case FO_vertex_cu:
- _has_normal = false;
- _has_uv = true;
- break;
-
- default:
- nassertr(false, false);
- }
-
- DatagramIterator &iterator = reader.get_iterator();
-
- _color_name_index = iterator.get_be_int16();
- _flags = iterator.get_be_uint16();
- _pos[0] = iterator.get_be_float64();
- _pos[1] = iterator.get_be_float64();
- _pos[2] = iterator.get_be_float64();
-
- if (_has_normal) {
- _normal[0] = iterator.get_be_float32();
- _normal[1] = iterator.get_be_float32();
- _normal[2] = iterator.get_be_float32();
- }
- if (_has_uv) {
- _uv[0] = iterator.get_be_float32();
- _uv[1] = iterator.get_be_float32();
- }
-
- if (iterator.get_remaining_size() > 0) {
- if (!_packed_color.extract_record(reader)) {
- return false;
- }
- if (_header->get_flt_version() >= 1520) {
- _color_index = iterator.get_be_int32();
-
- if (_has_normal && iterator.get_remaining_size() > 0) {
- // If we extracted a normal, our double-word alignment is off; now we
- // have a few extra bytes to ignore.
- iterator.skip_bytes(4);
- }
- }
- }
-
- check_remaining_size(iterator);
- return true;
-}
-
-/**
- * Fills up the current record on the FltRecordWriter with data for this
- * record, but does not advance the writer. Returns true on success, false if
- * there is some error.
- */
-bool FltVertex::
-build_record(FltRecordWriter &writer) const {
- if (!FltRecord::build_record(writer)) {
- return false;
- }
-
- writer.set_opcode(get_opcode());
- Datagram &datagram = writer.update_datagram();
-
- datagram.add_be_int16(_color_name_index);
- datagram.add_be_uint16(_flags);
- datagram.add_be_float64(_pos[0]);
- datagram.add_be_float64(_pos[1]);
- datagram.add_be_float64(_pos[2]);
-
- if (_has_normal) {
- datagram.add_be_float32(_normal[0]);
- datagram.add_be_float32(_normal[1]);
- datagram.add_be_float32(_normal[2]);
- }
- if (_has_uv) {
- datagram.add_be_float32(_uv[0]);
- datagram.add_be_float32(_uv[1]);
- }
-
- if (!_packed_color.build_record(writer)) {
- return false;
- }
-
- if (_header->get_flt_version() >= 1520) {
- // New with 15.2
- datagram.add_be_uint32(_color_index);
-
- if (_has_normal) {
- // If we added a normal, our double-word alignment is off; now we have a
- // few extra bytes to add.
- datagram.pad_bytes(4);
- }
- }
-
- nassertr((int)datagram.get_length() == get_record_length() - 4, true);
- return true;
-}
diff --git a/pandatool/src/flt/fltVertex.h b/pandatool/src/flt/fltVertex.h
deleted file mode 100644
index 9c02c372..00000000
--- a/pandatool/src/flt/fltVertex.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltVertex.h
- * @author drose
- * @date 2000-08-25
- */
-
-#ifndef FLTVERTEX_H
-#define FLTVERTEX_H
-
-#include "pandatoolbase.h"
-
-#include "fltRecord.h"
-#include "fltPackedColor.h"
-
-#include "luse.h"
-
-/**
- * Represents a single vertex in the vertex palette. Flt files index vertices
- * by their byte offset in the vertex palette; within this library, we map
- * those byte offsets to pointers automatically.
- *
- * This may represent a vertex with or without a normal or texture
- * coordinates.
- */
-class FltVertex : public FltRecord {
-public:
- FltVertex(FltHeader *header);
-
- FltOpcode get_opcode() const;
- int get_record_length() const;
-
- enum Flags {
- F_hard_edge = 0x8000,
- F_normal_frozen = 0x4000,
- F_no_color = 0x2000,
- F_packed_color = 0x1000
- };
-
- int _color_name_index;
- unsigned int _flags;
- LPoint3d _pos;
- LPoint3 _normal;
- LPoint2 _uv;
- FltPackedColor _packed_color;
- int _color_index;
-
- bool _has_normal;
- bool _has_uv;
-
-public:
- INLINE bool has_color() const;
- LColor get_color() const;
- INLINE void set_color(const LColor &color);
- LRGBColor get_rgb() const;
- void set_rgb(const LRGBColor &rgb);
-
-
-protected:
- virtual bool extract_record(FltRecordReader &reader);
- virtual bool build_record(FltRecordWriter &writer) const;
-
-public:
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- FltRecord::init_type();
- register_type(_type_handle, "FltVertex",
- FltRecord::get_class_type());
- }
-
-private:
- static TypeHandle _type_handle;
-
- friend class FltHeader;
-};
-
-#include "fltVertex.I"
-
-#endif
diff --git a/pandatool/src/flt/fltVertexList.cxx b/pandatool/src/flt/fltVertexList.cxx
deleted file mode 100644
index 65da9b59..00000000
--- a/pandatool/src/flt/fltVertexList.cxx
+++ /dev/null
@@ -1,116 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltVertexList.cxx
- * @author drose
- * @date 2000-08-25
- */
-
-#include "fltVertexList.h"
-#include "fltRecordReader.h"
-#include "fltRecordWriter.h"
-#include "fltHeader.h"
-
-TypeHandle FltVertexList::_type_handle;
-
-/**
- *
- */
-FltVertexList::
-FltVertexList(FltHeader *header) : FltRecord(header) {
-}
-
-/**
- * Returns the number of vertices in this vertex list.
- */
-int FltVertexList::
-get_num_vertices() const {
- return _vertices.size();
-}
-
-/**
- * Returns the nth vertex of this vertex list.
- */
-FltVertex *FltVertexList::
-get_vertex(int n) const {
- nassertr(n >= 0 && n < (int)_vertices.size(), nullptr);
- return _vertices[n];
-}
-
-/**
- * Removes all vertices from this vertex list.
- */
-void FltVertexList::
-clear_vertices() {
- _vertices.clear();
-}
-
-/**
- * Adds a new vertex to the end of the vertex list.
- */
-void FltVertexList::
-add_vertex(FltVertex *vertex) {
- _header->add_vertex(vertex);
- _vertices.push_back(vertex);
-}
-
-/**
- * Writes a quick one-line description of the record, but not its children.
- * This is a human-readable description, primarily for debugging; to write a
- * flt file, use FltHeader::write_flt().
- */
-void FltVertexList::
-output(std::ostream &out) const {
- out << _vertices.size() << " vertices";
-}
-
-/**
- * Fills in the information in this bead based on the information given in the
- * indicated datagram, whose opcode has already been read. Returns true on
- * success, false if the datagram is invalid.
- */
-bool FltVertexList::
-extract_record(FltRecordReader &reader) {
- if (!FltRecord::extract_record(reader)) {
- return false;
- }
-
- nassertr(reader.get_opcode() == FO_vertex_list, false);
- DatagramIterator &iterator = reader.get_iterator();
-
- _vertices.clear();
- while (iterator.get_remaining_size() >= 4) {
- int vertex_offset = iterator.get_be_int32();
- _vertices.push_back(_header->get_vertex_by_offset(vertex_offset));
- }
-
- check_remaining_size(iterator);
- return true;
-}
-
-/**
- * Fills up the current record on the FltRecordWriter with data for this
- * record, but does not advance the writer. Returns true on success, false if
- * there is some error.
- */
-bool FltVertexList::
-build_record(FltRecordWriter &writer) const {
- if (!FltRecord::build_record(writer)) {
- return false;
- }
-
- writer.set_opcode(FO_vertex_list);
- Datagram &datagram = writer.update_datagram();
-
- Vertices::const_iterator vi;
- for (vi = _vertices.begin(); vi != _vertices.end(); ++vi) {
- datagram.add_be_uint32(_header->get_offset_by_vertex(*vi));
- }
-
- return true;
-}
diff --git a/pandatool/src/flt/fltVertexList.h b/pandatool/src/flt/fltVertexList.h
deleted file mode 100644
index 5fd53ad8..00000000
--- a/pandatool/src/flt/fltVertexList.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltVertexList.h
- * @author drose
- * @date 2000-08-25
- */
-
-#ifndef FLTVERTEXLIST_H
-#define FLTVERTEXLIST_H
-
-#include "pandatoolbase.h"
-
-#include "fltRecord.h"
-#include "fltPackedColor.h"
-#include "fltVertex.h"
-
-#include "pointerTo.h"
-
-/**
- * A list of vertices, typically added as a child of a face bead.
- */
-class FltVertexList : public FltRecord {
-public:
- FltVertexList(FltHeader *header);
-
- int get_num_vertices() const;
- FltVertex *get_vertex(int n) const;
- void clear_vertices();
- void add_vertex(FltVertex *vertex);
-
- virtual void output(std::ostream &out) const;
-
-protected:
- virtual bool extract_record(FltRecordReader &reader);
- virtual bool build_record(FltRecordWriter &writer) const;
-
-private:
- typedef pvector Vertices;
- Vertices _vertices;
-
-public:
- virtual TypeHandle get_type() const {
- return get_class_type();
- }
- virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
- static TypeHandle get_class_type() {
- return _type_handle;
- }
- static void init_type() {
- FltRecord::init_type();
- register_type(_type_handle, "FltVertexList",
- FltRecord::get_class_type());
- }
-
-private:
- static TypeHandle _type_handle;
-};
-
-#endif
diff --git a/pandatool/src/flt/p3flt_composite1.cxx b/pandatool/src/flt/p3flt_composite1.cxx
deleted file mode 100644
index 8c9f9fd2..00000000
--- a/pandatool/src/flt/p3flt_composite1.cxx
+++ /dev/null
@@ -1,41 +0,0 @@
-
-#include "config_flt.cxx"
-#include "fltBead.cxx"
-#include "fltBeadID.cxx"
-#include "fltCurve.cxx"
-#include "fltError.cxx"
-#include "fltExternalReference.cxx"
-#include "fltEyepoint.cxx"
-#include "fltFace.cxx"
-#include "fltGeometry.cxx"
-#include "fltGroup.cxx"
-#include "fltHeader.cxx"
-#include "fltInstanceDefinition.cxx"
-#include "fltInstanceRef.cxx"
-#include "fltLOD.cxx"
-#include "fltLightSourceDefinition.cxx"
-#include "fltLocalVertexPool.cxx"
-#include "fltMaterial.cxx"
-#include "fltMesh.cxx"
-#include "fltMeshPrimitive.cxx"
-#include "fltObject.cxx"
-#include "fltOpcode.cxx"
-#include "fltPackedColor.cxx"
-#include "fltRecord.cxx"
-#include "fltRecordReader.cxx"
-#include "fltRecordWriter.cxx"
-#include "fltTexture.cxx"
-#include "fltTrackplane.cxx"
-#include "fltTransformGeneralMatrix.cxx"
-#include "fltTransformPut.cxx"
-#include "fltTransformRecord.cxx"
-#include "fltTransformRotateAboutEdge.cxx"
-#include "fltTransformRotateAboutPoint.cxx"
-#include "fltTransformRotateScale.cxx"
-#include "fltTransformScale.cxx"
-#include "fltTransformTranslate.cxx"
-#include "fltUnsupportedRecord.cxx"
-#include "fltVectorRecord.cxx"
-#include "fltVertex.cxx"
-#include "fltVertexList.cxx"
-
diff --git a/pandatool/src/fltegg/CMakeLists.txt b/pandatool/src/fltegg/CMakeLists.txt
deleted file mode 100644
index 5a61e47a..00000000
--- a/pandatool/src/fltegg/CMakeLists.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-if(NOT HAVE_EGG)
- return()
-endif()
-
-set(P3FLTEGG_HEADERS
- fltToEggConverter.h fltToEggConverter.I
- fltToEggLevelState.h fltToEggLevelState.I
-)
-
-set(P3FLTEGG_SOURCES
- fltToEggConverter.cxx
- fltToEggLevelState.cxx
-)
-
-add_library(p3fltegg STATIC ${P3FLTEGG_HEADERS} ${P3FLTEGG_SOURCES})
-target_link_libraries(p3fltegg p3flt p3eggbase)
-
-# This is only needed for binaries in the pandatool package. It is not useful
-# for user applications, so it is not installed.
diff --git a/pandatool/src/fltegg/fltToEggConverter.I b/pandatool/src/fltegg/fltToEggConverter.I
deleted file mode 100644
index 1168eb64..00000000
--- a/pandatool/src/fltegg/fltToEggConverter.I
+++ /dev/null
@@ -1,12 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltToEggConverter.I
- * @author drose
- * @date 2001-04-17
- */
diff --git a/pandatool/src/fltegg/fltToEggConverter.cxx b/pandatool/src/fltegg/fltToEggConverter.cxx
deleted file mode 100644
index 98b01938..00000000
--- a/pandatool/src/fltegg/fltToEggConverter.cxx
+++ /dev/null
@@ -1,839 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltToEggConverter.cxx
- * @author drose
- * @date 2001-04-17
- */
-
-#include "fltToEggConverter.h"
-
-#include "fltRecord.h"
-#include "fltLOD.h"
-#include "fltGroup.h"
-#include "fltObject.h"
-#include "fltBeadID.h"
-#include "fltBead.h"
-#include "fltFace.h"
-#include "fltVertex.h"
-#include "fltVertexList.h"
-#include "fltExternalReference.h"
-#include "dcast.h"
-#include "eggData.h"
-#include "eggGroup.h"
-#include "eggSwitchCondition.h"
-#include "eggPrimitive.h"
-#include "eggPolygon.h"
-#include "eggPoint.h"
-#include "eggVertex.h"
-#include "eggVertexPool.h"
-#include "eggExternalReference.h"
-#include "string_utils.h"
-
-using std::string;
-
-
-/**
- *
- */
-FltToEggConverter::
-FltToEggConverter() {
- _compose_transforms = false;
- _flt_units = DU_invalid;
-}
-
-/**
- *
- */
-FltToEggConverter::
-FltToEggConverter(const FltToEggConverter ©) :
- SomethingToEggConverter(copy),
- _compose_transforms(copy._compose_transforms)
-{
-}
-
-/**
- *
- */
-FltToEggConverter::
-~FltToEggConverter() {
- cleanup();
-}
-
-/**
- * Allocates and returns a new copy of the converter.
- */
-SomethingToEggConverter *FltToEggConverter::
-make_copy() {
- return new FltToEggConverter(*this);
-}
-
-
-/**
- * Returns the English name of the file type this converter supports.
- */
-string FltToEggConverter::
-get_name() const {
- return "MultiGen";
-}
-
-/**
- * Returns the common extension of the file type this converter supports.
- */
-string FltToEggConverter::
-get_extension() const {
- return "flt";
-}
-
-/**
- * Returns true if this file type can transparently load compressed files
- * (with a .pz extension), false otherwise.
- */
-bool FltToEggConverter::
-supports_compressed() const {
- return true;
-}
-
-/**
- * Handles the reading of the input file and converting it to egg. Returns
- * true if successful, false otherwise.
- *
- * This is designed to be as generic as possible, generally in support of run-
- * time loading. Command-line converters may choose to use convert_flt()
- * instead, as it provides more control.
- */
-bool FltToEggConverter::
-convert_file(const Filename &filename) {
- PT(FltHeader) header = new FltHeader(_path_replace);
-
- nout << "Reading " << filename << "\n";
- FltError result = header->read_flt(filename);
- if (result != FE_ok) {
- nout << "Unable to read: " << result << "\n";
- return false;
- }
-
- header->check_version();
-
- _flt_units = header->get_units();
-
- return convert_flt(header);
-}
-
-/**
- * This may be called after convert_file() has been called and returned true,
- * indicating a successful conversion. It will return the distance units
- * represented by the converted egg file, if known, or DU_invalid if not
- * known.
- */
-DistanceUnit FltToEggConverter::
-get_input_units() {
- return _flt_units;
-}
-
-/**
- * Fills up the egg_data structure according to the indicated lwo structure.
- */
-bool FltToEggConverter::
-convert_flt(const FltHeader *flt_header) {
- if (_egg_data->get_coordinate_system() == CS_default) {
- _egg_data->set_coordinate_system(CS_zup_right);
- }
-
- clear_error();
- _flt_header = flt_header;
-
- // Generate a default vertex pool.
- _main_egg_vpool = new EggVertexPool("vpool");
- _egg_data->add_child(_main_egg_vpool.p());
-
- // We could populate the vertex pool right away, but it's better to defer
- // each vertex until we encounter it, since some of the vertices may need to
- // be adjusted to match the particular polygon they're assigned to (for
- // instance, to apply a transparency or something).
-
- FltToEggLevelState state(this);
- state._egg_parent = _egg_data;
- convert_record(_flt_header, state);
-
- if (_main_egg_vpool->empty()) {
- // If we didn't get any global vertices, remove the vertex pool just for
- // cleanliness.
- _egg_data->remove_child(_main_egg_vpool.p());
- }
-
- cleanup();
-
- return !had_error();
-}
-
-/**
- * Frees all the internal data structures after we're done converting, and
- * resets the converter to its initial state.
- */
-void FltToEggConverter::
-cleanup() {
- _flt_header.clear();
- _main_egg_vpool.clear();
- _textures.clear();
-}
-
-/**
- * Converts the record and all of its children.
- */
-void FltToEggConverter::
-convert_record(const FltRecord *flt_record, FltToEggLevelState &state) {
- int num_children = flt_record->get_num_children();
-
- for (int i = 0; i < num_children; i++) {
- const FltRecord *child = flt_record->get_child(i);
- dispatch_record(child, state);
- }
-}
-
-/**
- * Determines what kind of record this is and calls the appropriate convert
- * function.
- */
-void FltToEggConverter::
-dispatch_record(const FltRecord *flt_record, FltToEggLevelState &state) {
- if (flt_record->is_of_type(FltLOD::get_class_type())) {
- convert_lod(DCAST(FltLOD, flt_record), state);
-
- } else if (flt_record->is_of_type(FltGroup::get_class_type())) {
- convert_group(DCAST(FltGroup, flt_record), state);
-
- } else if (flt_record->is_of_type(FltObject::get_class_type())) {
- convert_object(DCAST(FltObject, flt_record), state);
-
- } else if (flt_record->is_of_type(FltFace::get_class_type())) {
- convert_face(DCAST(FltFace, flt_record), state);
-
- } else if (flt_record->is_of_type(FltExternalReference::get_class_type())) {
- convert_ext_ref(DCAST(FltExternalReference, flt_record), state);
-
- // Fallbacks.
- } else if (flt_record->is_of_type(FltBeadID::get_class_type())) {
- convert_bead_id(DCAST(FltBeadID, flt_record), state);
-
- } else if (flt_record->is_of_type(FltBead::get_class_type())) {
- convert_bead(DCAST(FltBead, flt_record), state);
-
- } else {
- convert_record(flt_record, state);
- }
-}
-
-/**
- * Converts the LOD bead and all of its children.
- */
-void FltToEggConverter::
-convert_lod(const FltLOD *flt_lod, FltToEggLevelState &state) {
- EggGroup *egg_group = new EggGroup(flt_lod->get_id());
- state._egg_parent->add_child(egg_group);
-
- EggSwitchConditionDistance lod
- (flt_lod->_switch_in, flt_lod->_switch_out,
- LPoint3d(flt_lod->_center_x, flt_lod->_center_y, flt_lod->_center_z),
- flt_lod->_transition_range);
- egg_group->set_lod(lod);
-
- state.set_transform(flt_lod, egg_group);
- parse_comment(flt_lod, egg_group);
-
- FltToEggLevelState next_state(state);
- next_state._egg_parent = egg_group;
- convert_record(flt_lod, next_state);
-}
-
-/**
- * Converts the group and all of its children.
- */
-void FltToEggConverter::
-convert_group(const FltGroup *flt_group, FltToEggLevelState &state) {
- EggGroup *egg_group = new EggGroup(flt_group->get_id());
- state._egg_parent->add_child(egg_group);
-
- if ((flt_group->_flags & FltGroup::F_forward_animation) != 0) {
- // It's a sequence animation.
- egg_group->set_switch_flag(true);
- egg_group->set_switch_fps(24.0);
- }
-
- state.set_transform(flt_group, egg_group);
- parse_comment(flt_group, egg_group);
-
- // *** replicate count.
-
- FltToEggLevelState next_state(state);
- next_state._egg_parent = egg_group;
- convert_record(flt_group, next_state);
-}
-
-/**
- * Converts the object and all of its children.
- */
-void FltToEggConverter::
-convert_object(const FltObject *flt_object, FltToEggLevelState &state) {
- EggGroup *egg_group = new EggGroup(flt_object->get_id());
- state._egg_parent->add_child(egg_group);
-
- state.set_transform(flt_object, egg_group);
- parse_comment(flt_object, egg_group);
-
- FltToEggLevelState next_state(state);
- next_state._flt_object = flt_object;
- next_state._egg_parent = egg_group;
- convert_record(flt_object, next_state);
-}
-
-/**
- * Converts the generic bead (with ID) and all of its children.
- */
-void FltToEggConverter::
-convert_bead_id(const FltBeadID *flt_bead, FltToEggLevelState &state) {
- nout << "Don't know how to convert beads of type " << flt_bead->get_type()
- << "\n";
- EggGroup *egg_group = new EggGroup(flt_bead->get_id());
- state._egg_parent->add_child(egg_group);
-
- state.set_transform(flt_bead, egg_group);
- parse_comment(flt_bead, egg_group);
-
- FltToEggLevelState next_state(state);
- next_state._egg_parent = egg_group;
- convert_record(flt_bead, next_state);
-}
-
-/**
- * Converts the generic bead (without ID) and all of its children.
- */
-void FltToEggConverter::
-convert_bead(const FltBead *flt_bead, FltToEggLevelState &state) {
- nout << "Don't know how to convert beads of type " << flt_bead->get_type()
- << "\n";
- EggGroup *egg_group = new EggGroup;
- state._egg_parent->add_child(egg_group);
-
- state.set_transform(flt_bead, egg_group);
- parse_comment(flt_bead, egg_group);
-
- FltToEggLevelState next_state(state);
- next_state._egg_parent = egg_group;
- convert_record(flt_bead, next_state);
-}
-
-/**
- * Converts the face and all of its children.
- */
-void FltToEggConverter::
-convert_face(const FltFace *flt_face, FltToEggLevelState &state) {
- bool is_light;
- switch (flt_face->_draw_type) {
- case FltGeometry::DT_omni_light:
- case FltGeometry::DT_uni_light:
- case FltGeometry::DT_bi_light:
- is_light = true;
- break;
-
- default:
- is_light = false;
- }
-
- PT(EggPrimitive) egg_prim;
- if (is_light) {
- egg_prim = new EggPoint;
- } else {
- egg_prim = new EggPolygon;
- }
-
- // Collect the vertices for this primitive.
- pvector< PT_EggVertex > vertices;
-
- const FltVertexList *vlist = nullptr;
- int num_children = flt_face->get_num_children();
- for (int i = 0; i < num_children && vlist == nullptr; i++) {
- const FltRecord *child = flt_face->get_child(i);
- if (child->is_of_type(FltVertexList::get_class_type())) {
- vlist = DCAST(FltVertexList, child);
- }
- }
-
- if (vlist != nullptr) {
- int num_vertices = vlist->get_num_vertices();
- for (int i = 0; i < num_vertices; i++) {
- FltVertex *flt_vertex = vlist->get_vertex(i);
- vertices.push_back(make_egg_vertex(flt_vertex));
- }
- }
-
- setup_geometry(flt_face, state, egg_prim, _main_egg_vpool, vertices);
-}
-
-/**
- * Converts the external reference node.
- */
-void FltToEggConverter::
-convert_ext_ref(const FltExternalReference *flt_ext, FltToEggLevelState &state) {
- // Get a group node to put the reference into.
- EggGroupNode *egg_parent =
- state.get_synthetic_group("", flt_ext);
-
- handle_external_reference(egg_parent, flt_ext->get_ref_filename());
-}
-
-/**
- * Applies the state indicated in the FltGeometry record to the indicated
- * EggPrimitive and all of its indicated vertices, and then officially adds
- * the vertices to the vertex pool and to the primitive, and adds the
- * primitive to its appropriate parent.
- */
-void FltToEggConverter::
-setup_geometry(const FltGeometry *flt_geom, FltToEggLevelState &state,
- EggPrimitive *egg_prim, EggVertexPool *egg_vpool,
- const FltToEggConverter::EggVertices &vertices) {
-
- // Determine what the appropriate parent will be.
- EggGroupNode *egg_parent =
- state.get_synthetic_group(flt_geom->get_id(), flt_geom,
- flt_geom->_billboard_type);
-
- // Create a new state to reflect the new parent.
- FltToEggLevelState next_state(state);
- next_state._egg_parent = egg_parent;
-
- // Check for decals onto the primitive.
- convert_subfaces(flt_geom, next_state);
-
- // Add the primitive to its new home.
- next_state._egg_parent->add_child(egg_prim);
-
- // Now examine the vertices.
- EggVertices::const_iterator vi;
-
- bool use_vertex_color = true;
- bool keep_normals = true;
- switch (flt_geom->_light_mode) {
- case FltGeometry::LM_face_no_normal:
- use_vertex_color = false;
- keep_normals = false;
- break;
-
- case FltGeometry::LM_vertex_no_normal:
- use_vertex_color = true;
- keep_normals = false;
- break;
-
- case FltGeometry::LM_face_with_normal:
- use_vertex_color = false;
- keep_normals = true;
- break;
-
- case FltGeometry::LM_vertex_with_normal:
- use_vertex_color = true;
- keep_normals = true;
- break;
- }
-
- LColor face_color = flt_geom->get_color();
-
- if (state._flt_object != nullptr) {
- // If we have a FltObject above us, it might also specify a transparency.
- // This combines with our existing transparency.
- PN_stdfloat alpha = 1.0 - (state._flt_object->_transparency / 65535.0);
- face_color[3] *= alpha;
- }
-
- egg_prim->set_color(face_color);
-
- if (flt_geom->has_texture()) {
- // If the geometry has a texture, apply it.
- egg_prim->set_texture(make_egg_texture(flt_geom->get_texture()));
-
- if (flt_geom->_texwhite) {
- // If the geometry should be colored white under the texture, then
- // eliminate vertex colors.
- use_vertex_color = false;
- }
- }
-
- if (use_vertex_color) {
- // If we're to use vertex color instead of the face color, remove the face
- // color to eliminate any ambiguity.
- egg_prim->clear_color();
-
- // Also, make sure the transparency is set correctly across all vertices.
- for (vi = vertices.begin(); vi != vertices.end(); ++vi) {
- EggVertex *vertex = (*vi);
- if (vertex->has_color()) {
- LColor vertex_color = vertex->get_color();
- vertex_color[3] = face_color[3];
- vertex->set_color(vertex_color);
- } else {
- if (flt_geom->has_color()) {
- // If a vertex doesn't have a color but the face does, set the
- // vertex to use the face color.
- vertex->set_color(face_color);
- }
- }
- }
-
- } else {
- // If we're to use face color instead of vertex color, remove the vertex
- // color to eliminate any ambiguity.
- for (vi = vertices.begin(); vi != vertices.end(); ++vi) {
- (*vi)->clear_color();
- }
- }
-
- if (!keep_normals) {
- // If we're not to use the normals, then eliminate them.
- for (vi = vertices.begin(); vi != vertices.end(); ++vi) {
- (*vi)->clear_normal();
- }
- }
-
- if (flt_geom->_draw_type == FltGeometry::DT_solid_no_cull) {
- // A double-sided polygon.
- egg_prim->set_bface_flag(true);
- }
-
- for (vi = vertices.begin(); vi != vertices.end(); ++vi) {
- EggVertex *egg_vertex = egg_vpool->create_unique_vertex(*(*vi));
- egg_prim->add_vertex(egg_vertex);
- }
-
- parse_comment(flt_geom, egg_prim);
-}
-
-/**
- * Records all of the subfaces of the indicated group as coplanar polygons
- * (i.e. decals) of the group.
- *
- * If coplanar polygons exist, the state is modified so that _egg_parent is
- * the new group to which the base polygons should be added. Therefore,
- * subfaces should be defined before the ordinary children are processed.
- */
-void FltToEggConverter::
-convert_subfaces(const FltRecord *flt_record, FltToEggLevelState &state) {
- int num_subfaces = flt_record->get_num_subfaces();
- if (num_subfaces == 0) {
- // No subfaces.
- return;
- }
-
- // Create a new group to contain the base polygons.
- EggGroup *egg_group = new EggGroup("decal_base");
- state._egg_parent->add_child(egg_group);
- state._egg_parent = egg_group;
-
- egg_group->set_decal_flag(true);
-
- // Now create a nested group to hold the decals.
- EggGroup *decal_group = new EggGroup("decals");
- egg_group->add_child(decal_group);
- egg_group = decal_group;
-
- FltToEggLevelState next_state(state);
- next_state._egg_parent = decal_group;
-
- for (int i = 0; i < num_subfaces; i++) {
- const FltRecord *subface = flt_record->get_subface(i);
- dispatch_record(subface, next_state);
- }
-}
-
-/**
- * Scans the comment on this record for " { ... }" and parses the
- * enclosed string as if it appeared in the egg file. Returns true on
- * success, false on syntax error (in which case _error is also set to true).
- */
-bool FltToEggConverter::
-parse_comment(const FltBeadID *flt_bead, EggNode *egg_node) {
- return parse_comment(flt_bead->get_comment(), flt_bead->get_id(), egg_node);
-}
-
-/**
- * Scans the comment on this record for " { ... }" and parses the
- * enclosed string as if it appeared in the egg file. Returns true on
- * success, false on syntax error (in which case _error is also set to true).
- */
-bool FltToEggConverter::
-parse_comment(const FltBead *flt_bead, EggNode *egg_node) {
- return parse_comment(flt_bead->get_comment(), "anonymous", egg_node);
-}
-
-/**
- * Scans the comment on this record for " { ... }" and parses the
- * enclosed string as if it appeared in the egg file. Returns true on
- * success, false on syntax error (in which case _error is also set to true).
- */
-bool FltToEggConverter::
-parse_comment(const FltTexture *flt_texture, EggNode *egg_node) {
- return parse_comment(flt_texture->get_comment(),
- flt_texture->get_texture_filename(), egg_node);
-}
-
-/**
- * Scans the comment on this record for " { ... }" and parses the
- * enclosed string as if it appeared in the egg file. Returns true on
- * success, false on syntax error (in which case _error is also set to true).
- */
-bool FltToEggConverter::
-parse_comment(const string &comment, const string &name,
- EggNode *egg_node) {
- if (comment.empty()) {
- // No comment.
- return true;
- }
-
- // Scan for .
- static const string egg_str = "";
-
- size_t p;
- p = 0;
- while (p < comment.length() &&
- cmp_nocase(comment.substr(p, 5), egg_str) != 0) {
- p++;
- }
-
- if (p >= comment.length()) {
- // No "" in the comment.
- return true;
- }
-
- p += 5;
- // Now scan past whitespace for the open curly brace.
- while (p < comment.length() && isspace(comment[p])) {
- ++p;
- }
- if (p >= comment.length() || comment[p] != '{') {
- nout << "No opening brace in comment for "
- << name << "\n\n";
- _error = true;
- return false;
- }
-
- // Here's the beginning of the string after " {". Now lop off the
- // closing brace at the end.
- ++p;
- size_t q = comment.length() - 1;
- while (q > p && comment[q] != '}') {
- --q;
- }
- if (q == p) {
- nout << "No closing brace in comment for "
- << name << "\n\n";
- _error = true;
- return false;
- }
-
- string egg_syntax = comment.substr(p, q - p);
-
- if (!egg_node->parse_egg(egg_syntax)) {
- nout << "Syntax error in comment for "
- << name << "\n\n";
- _error = true;
- return false;
- }
-
- // Correctly parsed!
- return true;
-}
-
-/**
- * Makes a new EggVertex for the indicated FltVertex. The vertex is not
- * automatically added to the vertex pool.
- */
-PT_EggVertex FltToEggConverter::
-make_egg_vertex(const FltVertex *flt_vertex) {
- PT_EggVertex egg_vertex = new EggVertex;
- egg_vertex->set_pos(flt_vertex->_pos);
-
- if (flt_vertex->_has_normal) {
- egg_vertex->set_normal(LCAST(double, flt_vertex->_normal));
- }
-
- if (flt_vertex->_has_uv) {
- egg_vertex->set_uv(LCAST(double, flt_vertex->_uv));
- }
-
- if (flt_vertex->has_color()) {
- egg_vertex->set_color(flt_vertex->get_color());
- }
-
- return egg_vertex;
-}
-
-/**
- * Makes a new EggTexture for the indicated FltTexture, or returns a pointer
- * to one previously made for the same FltTexture.
- */
-PT_EggTexture FltToEggConverter::
-make_egg_texture(const FltTexture *flt_texture) {
- Textures::const_iterator ti;
- ti = _textures.find(flt_texture);
- if (ti != _textures.end()) {
- // There's one previously created.
- return (*ti).second;
- }
-
- // Create a new one.
- string tref_name = format_string(flt_texture->_pattern_index);
- Filename filename = flt_texture->get_texture_filename();
-
- PT_EggTexture egg_texture = new EggTexture(tref_name, filename);
-
- _textures.insert(Textures::value_type(flt_texture, egg_texture));
-
- // Set up the texture properties.
-
- switch (flt_texture->_min_filter) {
- case FltTexture::MN_point:
- egg_texture->set_minfilter(EggTexture::FT_nearest);
- break;
-
- case FltTexture::MN_bilinear:
- egg_texture->set_minfilter(EggTexture::FT_linear);
- break;
-
- case FltTexture::MN_mipmap_point:
- egg_texture->set_minfilter(EggTexture::FT_nearest_mipmap_nearest);
- break;
-
- case FltTexture::MN_mipmap_linear:
- egg_texture->set_minfilter(EggTexture::FT_nearest_mipmap_linear);
- break;
-
- case FltTexture::MN_mipmap_bilinear:
- egg_texture->set_minfilter(EggTexture::FT_linear_mipmap_nearest);
- break;
-
- case FltTexture::MN_mipmap_trilinear:
- case FltTexture::MN_OB_mipmap:
- egg_texture->set_minfilter(EggTexture::FT_linear_mipmap_linear);
- break;
-
- case FltTexture::MN_bicubic:
- case FltTexture::MN_bilinear_gequal:
- case FltTexture::MN_bilinear_lequal:
- case FltTexture::MN_bicubic_gequal:
- case FltTexture::MN_bicubic_lequal:
- // Not supported.
- break;
- }
-
- switch (flt_texture->_mag_filter) {
- case FltTexture::MG_point:
- egg_texture->set_magfilter(EggTexture::FT_nearest);
- break;
-
- case FltTexture::MG_bilinear:
- egg_texture->set_magfilter(EggTexture::FT_linear);
- break;
-
- case FltTexture::MG_bicubic:
- case FltTexture::MG_sharpen:
- case FltTexture::MG_add_detail:
- case FltTexture::MG_modulate_detail:
- case FltTexture::MG_bilinear_gequal:
- case FltTexture::MG_bilinear_lequal:
- case FltTexture::MG_bicubic_gequal:
- case FltTexture::MG_bicubic_lequal:
- // Not supported.
- break;
- }
-
- switch (flt_texture->_repeat) {
- case FltTexture::RT_repeat:
- egg_texture->set_wrap_mode(EggTexture::WM_repeat);
- break;
-
- case FltTexture::RT_clamp:
- egg_texture->set_wrap_mode(EggTexture::WM_clamp);
- break;
- }
-
- switch (flt_texture->_repeat_u) {
- case FltTexture::RT_repeat:
- egg_texture->set_wrap_u(EggTexture::WM_repeat);
- break;
-
- case FltTexture::RT_clamp:
- egg_texture->set_wrap_u(EggTexture::WM_clamp);
- break;
- }
-
- switch (flt_texture->_repeat_v) {
- case FltTexture::RT_repeat:
- egg_texture->set_wrap_v(EggTexture::WM_repeat);
- break;
-
- case FltTexture::RT_clamp:
- egg_texture->set_wrap_v(EggTexture::WM_clamp);
- break;
- }
-
- switch (flt_texture->_env_type) {
- case FltTexture::ET_modulate:
- egg_texture->set_env_type(EggTexture::ET_modulate);
- break;
-
- case FltTexture::ET_decal:
- egg_texture->set_env_type(EggTexture::ET_decal);
- break;
-
- case FltTexture::ET_blend:
- case FltTexture::ET_color:
- // Not supported.
- break;
- }
-
- switch (flt_texture->_internal_format) {
- case FltTexture::IF_default:
- break;
-
- case FltTexture::IF_i_12a_4:
- case FltTexture::IF_ia_12:
- case FltTexture::IF_ia_8:
- egg_texture->set_format(EggTexture::F_luminance_alpha);
- break;
-
- case FltTexture::IF_rgb_5:
- egg_texture->set_format(EggTexture::F_rgb5);
- break;
-
- case FltTexture::IF_rgba_4:
- egg_texture->set_format(EggTexture::F_rgba4);
- break;
-
-
- case FltTexture::IF_rgba_8:
- egg_texture->set_format(EggTexture::F_rgba8);
- break;
-
- case FltTexture::IF_rgba_12:
- egg_texture->set_format(EggTexture::F_rgba12);
- break;
-
- case FltTexture::IF_i_16:
- if (flt_texture->_intensity_is_alpha) {
- egg_texture->set_format(EggTexture::F_alpha);
- } else {
- egg_texture->set_format(EggTexture::F_luminance);
- }
- break;
-
- case FltTexture::IF_rgb_12:
- egg_texture->set_format(EggTexture::F_rgb12);
- break;
- }
-
- parse_comment(flt_texture, egg_texture);
- return egg_texture;
-}
diff --git a/pandatool/src/fltegg/fltToEggConverter.h b/pandatool/src/fltegg/fltToEggConverter.h
deleted file mode 100644
index c9e8cc61..00000000
--- a/pandatool/src/fltegg/fltToEggConverter.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltToEggConverter.h
- * @author drose
- * @date 2001-04-17
- */
-
-#ifndef FLTTOEGGCONVERTER_H
-#define FLTTOEGGCONVERTER_H
-
-#include "pandatoolbase.h"
-
-#include "fltToEggLevelState.h"
-#include "somethingToEggConverter.h"
-#include "fltHeader.h"
-#include "eggVertex.h"
-#include "eggVertexPool.h"
-#include "eggTexture.h"
-#include "pt_EggTexture.h"
-#include "pt_EggVertex.h"
-#include "pointerTo.h"
-#include "distanceUnit.h"
-
-class FltRecord;
-class FltLOD;
-class FltGroup;
-class FltObject;
-class FltBeadID;
-class FltBead;
-class FltVertex;
-class FltGeometry;
-class FltFace;
-class FltExternalReference;
-class FltTexture;
-class EggGroupNode;
-class EggPrimitive;
-
-/**
- * This class supervises the construction of an EggData structure from the
- * data represented by the FltHeader. Reading and writing the egg and flt
- * structures is left to the user.
- */
-class FltToEggConverter : public SomethingToEggConverter {
-public:
- FltToEggConverter();
- FltToEggConverter(const FltToEggConverter ©);
- ~FltToEggConverter();
-
- virtual SomethingToEggConverter *make_copy();
-
- virtual std::string get_name() const;
- virtual std::string get_extension() const;
- virtual bool supports_compressed() const;
-
- virtual bool convert_file(const Filename &filename);
- virtual DistanceUnit get_input_units();
- bool convert_flt(const FltHeader *flt_header);
-
- // Set this true to store transforms in egg files as the fully composed
- // matrix, or false (the default) to keep them decomposed into elemental
- // operations.
- bool _compose_transforms;
-
-private:
- void cleanup();
-
- typedef pvector< PT_EggVertex > EggVertices;
-
- void convert_record(const FltRecord *flt_record, FltToEggLevelState &state);
- void dispatch_record(const FltRecord *flt_record, FltToEggLevelState &state);
- void convert_lod(const FltLOD *flt_lod, FltToEggLevelState &state);
- void convert_group(const FltGroup *flt_group, FltToEggLevelState &state);
- void convert_object(const FltObject *flt_object, FltToEggLevelState &state);
- void convert_bead_id(const FltBeadID *flt_bead, FltToEggLevelState &state);
- void convert_bead(const FltBead *flt_bead, FltToEggLevelState &state);
- void convert_face(const FltFace *flt_face, FltToEggLevelState &state);
- void convert_ext_ref(const FltExternalReference *flt_ext, FltToEggLevelState &state);
-
- void setup_geometry(const FltGeometry *flt_geom, FltToEggLevelState &state,
- EggPrimitive *egg_prim, EggVertexPool *egg_vpool,
- const EggVertices &vertices);
-
- void convert_subfaces(const FltRecord *flt_record, FltToEggLevelState &state);
-
- bool parse_comment(const FltBeadID *flt_bead, EggNode *egg_node);
- bool parse_comment(const FltBead *flt_bead, EggNode *egg_node);
- bool parse_comment(const FltTexture *flt_texture, EggNode *egg_node);
- bool parse_comment(const std::string &comment, const std::string &name,
- EggNode *egg_node);
-
- PT_EggVertex make_egg_vertex(const FltVertex *flt_vertex);
- PT_EggTexture make_egg_texture(const FltTexture *flt_texture);
-
- CPT(FltHeader) _flt_header;
- DistanceUnit _flt_units;
-
- PT(EggVertexPool) _main_egg_vpool;
-
- typedef pmap Textures;
- Textures _textures;
-};
-
-#include "fltToEggConverter.I"
-
-#endif
diff --git a/pandatool/src/fltegg/fltToEggLevelState.I b/pandatool/src/fltegg/fltToEggLevelState.I
deleted file mode 100644
index e5460717..00000000
--- a/pandatool/src/fltegg/fltToEggLevelState.I
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltToEggLevelState.I
- * @author drose
- * @date 2001-04-18
- */
-
-/**
- *
- */
-INLINE FltToEggLevelState::
-FltToEggLevelState(FltToEggConverter *converter) :
- _converter(converter)
-{
- _flt_object = nullptr;
- _egg_parent = nullptr;
-}
-
-/**
- *
- */
-INLINE FltToEggLevelState::
-FltToEggLevelState(const FltToEggLevelState ©) :
- _flt_object(copy._flt_object),
- _egg_parent(copy._egg_parent),
- _converter(copy._converter)
-{
- // We don't bother to copy the _parents map.
-}
-
-/**
- *
- */
-INLINE void FltToEggLevelState::
-operator = (const FltToEggLevelState ©) {
- _flt_object = copy._flt_object;
- _egg_parent = copy._egg_parent;
- _converter = copy._converter;
- // We don't bother to copy the _parents map.
-}
diff --git a/pandatool/src/fltegg/fltToEggLevelState.cxx b/pandatool/src/fltegg/fltToEggLevelState.cxx
deleted file mode 100644
index ef396fd8..00000000
--- a/pandatool/src/fltegg/fltToEggLevelState.cxx
+++ /dev/null
@@ -1,229 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltToEggLevelState.cxx
- * @author drose
- * @date 2001-04-18
- */
-
-#include "fltToEggLevelState.h"
-#include "fltToEggConverter.h"
-#include "fltTransformTranslate.h"
-#include "fltTransformRotateAboutPoint.h"
-#include "fltTransformRotateAboutEdge.h"
-#include "fltTransformScale.h"
-#include "fltTransformPut.h"
-#include "eggGroup.h"
-#include "dcast.h"
-#include "look_at.h"
-
-
-/**
- *
- */
-FltToEggLevelState::
-~FltToEggLevelState() {
- Parents::iterator pi;
- for (pi = _parents.begin(); pi != _parents.end(); ++pi) {
- delete (*pi).second;
- }
-}
-
-/**
- *
- */
-FltToEggLevelState::ParentNodes::
-ParentNodes() {
- _axial_billboard = nullptr;
- _point_billboard = nullptr;
- _plain = nullptr;
-}
-
-/**
- * Sometimes it is necessary to synthesize a group within a particular
- * EggGroup, for instance to insert a transform or billboard flag. This
- * function will synthesize a group as needed, or return an existing group (if
- * the group need not be synthesized, or if a matching group was previously
- * synthesized).
- *
- * This collects together polygons that share the same billboard axis and/or
- * transform space into the same group, rather than wastefully creating a
- * group per polygon.
- */
-EggGroupNode *FltToEggLevelState::
-get_synthetic_group(const std::string &name,
- const FltBead *transform_bead,
- FltGeometry::BillboardType type) {
- LMatrix4d transform = transform_bead->get_transform();
- bool is_identity = transform.almost_equal(LMatrix4d::ident_mat());
- if (is_identity &&
- (type != FltGeometry::BT_axial &&
- type != FltGeometry::BT_point)) {
- // Trivial case: the primitive belongs directly in its parent group node.
- return _egg_parent;
- }
-
- // For other cases, we may have to create a subgroup to put the primitive
- // into.
- Parents::iterator pi;
- pi = _parents.find(transform);
- ParentNodes *nodes;
- if (pi != _parents.end()) {
- nodes = (*pi).second;
- } else {
- nodes = new ParentNodes;
- _parents.insert(Parents::value_type(transform, nodes));
- }
-
- switch (type) {
- case FltGeometry::BT_axial:
- if (nodes->_axial_billboard == nullptr) {
- nodes->_axial_billboard = new EggGroup(name);
- _egg_parent->add_child(nodes->_axial_billboard);
- nodes->_axial_billboard->set_billboard_type(EggGroup::BT_axis);
- if (!is_identity) {
- set_transform(transform_bead, nodes->_axial_billboard);
- nodes->_axial_billboard->set_group_type(EggGroup::GT_instance);
- }
- }
- return nodes->_axial_billboard;
-
- case FltGeometry::BT_point:
- if (nodes->_point_billboard == nullptr) {
- nodes->_point_billboard = new EggGroup(name);
- _egg_parent->add_child(nodes->_point_billboard);
- nodes->_point_billboard->set_billboard_type(EggGroup::BT_point_world_relative);
- if (!is_identity) {
- set_transform(transform_bead, nodes->_point_billboard);
- nodes->_point_billboard->set_group_type(EggGroup::GT_instance);
- }
- }
- return nodes->_point_billboard;
-
- default: // Normally, BT_none, although we've occasionally seen a
- // value of 3 come in here, whatever that's supposed to mean.
- if (nodes->_plain == nullptr) {
- nodes->_plain = new EggGroup(name);
- _egg_parent->add_child(nodes->_plain);
- if (!is_identity) {
- set_transform(transform_bead, nodes->_plain);
- nodes->_plain->set_group_type(EggGroup::GT_instance);
- }
- }
- return nodes->_plain;
- }
-}
-
-/**
- * Sets up the group to reflect the transform indicated by the given record,
- * if any.
- */
-void FltToEggLevelState::
-set_transform(const FltBead *flt_bead, EggGroup *egg_group) {
- if (flt_bead->has_transform()) {
- egg_group->set_group_type(EggGroup::GT_instance);
-
- int num_steps = flt_bead->get_num_transform_steps();
- bool componentwise_ok = !_converter->_compose_transforms;
-
- if (num_steps == 0) {
- componentwise_ok = false;
- } else {
- // Walk through each transform step and store the individual components
- // in the egg file. If we come across a step we don't know how to
- // interpret, just store the whole transform matrix in the egg file.
- egg_group->clear_transform();
- for (int i = num_steps -1; i >= 0 && componentwise_ok; i--) {
- const FltTransformRecord *step = flt_bead->get_transform_step(i);
- if (step->is_exact_type(FltTransformTranslate::get_class_type())) {
- const FltTransformTranslate *trans;
- DCAST_INTO_V(trans, step);
- if (!trans->get_delta().almost_equal(LVector3d::zero())) {
- egg_group->add_translate3d(trans->get_delta());
- }
-
- } else if (step->is_exact_type(FltTransformRotateAboutPoint::get_class_type())) {
- const FltTransformRotateAboutPoint *rap;
- DCAST_INTO_V(rap, step);
- if (!IS_NEARLY_ZERO(rap->get_angle())) {
- if (!rap->get_center().almost_equal(LVector3d::zero())) {
- egg_group->add_translate3d(-rap->get_center());
- }
- LVector3d axis = LCAST(double, rap->get_axis());
- egg_group->add_rotate3d(rap->get_angle(), axis);
- if (!rap->get_center().almost_equal(LVector3d::zero())) {
- egg_group->add_translate3d(rap->get_center());
- }
- }
-
- } else if (step->is_exact_type(FltTransformRotateAboutEdge::get_class_type())) {
- const FltTransformRotateAboutEdge *rae;
- DCAST_INTO_V(rae, step);
- if (!IS_NEARLY_ZERO(rae->get_angle())) {
- if (!rae->get_point_a().almost_equal(LVector3d::zero())) {
- egg_group->add_translate3d(-rae->get_point_a());
- }
- LVector3d axis = rae->get_point_b() - rae->get_point_a();
- egg_group->add_rotate3d(rae->get_angle(), axis);
- if (!rae->get_point_a().almost_equal(LVector3d::zero())) {
- egg_group->add_translate3d(rae->get_point_a());
- }
- }
-
- } else if (step->is_exact_type(FltTransformScale::get_class_type())) {
- const FltTransformScale *scale;
- DCAST_INTO_V(scale, step);
- if (!scale->get_scale().almost_equal(LVecBase3(1.0f, 1.0f, 1.0f))) {
- if (scale->has_center() &&
- !scale->get_center().almost_equal(LVector3d::zero())) {
- egg_group->add_translate3d(-scale->get_center());
- }
- egg_group->add_scale3d(LCAST(double, scale->get_scale()));
- if (scale->has_center() &&
- !scale->get_center().almost_equal(LVector3d::zero())) {
- egg_group->add_translate3d(scale->get_center());
- }
- }
-
- } else if (step->is_exact_type(FltTransformPut::get_class_type())) {
- const FltTransformPut *put;
- DCAST_INTO_V(put, step);
-
- if (!put->get_from_origin().almost_equal(LVector3d::zero())) {
- egg_group->add_translate3d(-put->get_from_origin());
- }
- LQuaterniond q1, q2;
- look_at(q1, put->get_from_align() - put->get_from_origin(),
- put->get_from_track() - put->get_from_origin(),
- CS_zup_right);
- look_at(q2, put->get_to_align() - put->get_to_origin(),
- put->get_to_track() - put->get_to_origin(),
- CS_zup_right);
-
- LQuaterniond q = invert(q1) * q2;
-
- if (!q.is_identity()) {
- egg_group->add_rotate3d(q);
- }
- if (!put->get_to_origin().almost_equal(LVector3d::zero())) {
- egg_group->add_translate3d(put->get_to_origin());
- }
-
- } else {
- // Here's a transform component we haven't implemented here. Give
- // up on storing the componentwise transform.
- componentwise_ok = false;
- }
- }
- }
-
- if (!componentwise_ok) {
- egg_group->set_transform3d(flt_bead->get_transform());
- }
- }
-}
diff --git a/pandatool/src/fltegg/fltToEggLevelState.h b/pandatool/src/fltegg/fltToEggLevelState.h
deleted file mode 100644
index 91877e23..00000000
--- a/pandatool/src/fltegg/fltToEggLevelState.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file fltToEggLevelState.h
- * @author drose
- * @date 2001-04-18
- */
-
-#ifndef FLTTOEGGLEVELSTATE_H
-#define FLTTOEGGLEVELSTATE_H
-
-#include "pandatoolbase.h"
-#include "fltGeometry.h"
-
-class FltObject;
-class FltBead;
-class EggGroupNode;
-class EggGroup;
-class FltToEggConverter;
-
-/**
- * This keeps track of relevant things about the traversal as we walk through
- * the flt hierarchy.
- */
-class FltToEggLevelState {
-public:
- INLINE FltToEggLevelState(FltToEggConverter *converter);
- INLINE FltToEggLevelState(const FltToEggLevelState ©);
- INLINE void operator = (const FltToEggLevelState ©);
- ~FltToEggLevelState();
-
- EggGroupNode *get_synthetic_group(const std::string &name,
- const FltBead *transform_bead,
- FltGeometry::BillboardType type = FltGeometry::BT_none);
-
- void set_transform(const FltBead *flt_bead, EggGroup *egg_group);
-
- const FltObject *_flt_object;
- EggGroupNode *_egg_parent;
-
-private:
- class ParentNodes {
- public:
- ParentNodes();
-
- EggGroup *_axial_billboard;
- EggGroup *_point_billboard;
- EggGroup *_plain;
- };
-
- typedef pmap Parents;
- Parents _parents;
-
- FltToEggConverter *_converter;
-};
-
-#include "fltToEggLevelState.I"
-
-#endif
diff --git a/pandatool/src/fltprogs/CMakeLists.txt b/pandatool/src/fltprogs/CMakeLists.txt
deleted file mode 100644
index 0ceebcf6..00000000
--- a/pandatool/src/fltprogs/CMakeLists.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-if(NOT BUILD_TOOLS)
- return()
-endif()
-
-add_executable(flt-info fltInfo.cxx fltInfo.h)
-target_link_libraries(flt-info p3progbase p3flt)
-install(TARGETS flt-info EXPORT Tools COMPONENT Tools DESTINATION ${CMAKE_INSTALL_BINDIR})
-
-add_executable(flt-trans fltTrans.cxx fltTrans.h)
-target_link_libraries(flt-trans p3progbase p3flt)
-install(TARGETS flt-trans EXPORT Tools COMPONENT Tools DESTINATION ${CMAKE_INSTALL_BINDIR})
-
-if(HAVE_EGG)
-
- add_executable(egg2flt eggToFlt.cxx eggToFlt.h)
- target_link_libraries(egg2flt p3fltegg p3eggbase p3progbase)
- install(TARGETS egg2flt EXPORT Tools COMPONENT Tools DESTINATION ${CMAKE_INSTALL_BINDIR})
-
- add_executable(flt2egg fltToEgg.cxx fltToEgg.h)
- target_link_libraries(flt2egg p3fltegg p3eggbase p3progbase)
- install(TARGETS flt2egg EXPORT Tools COMPONENT Tools DESTINATION ${CMAKE_INSTALL_BINDIR})
-
-endif()
diff --git a/pandatool/src/fltprogs/eggToFlt.cxx b/pandatool/src/fltprogs/eggToFlt.cxx
deleted file mode 100644
index f6cbc9d2..00000000
--- a/pandatool/src/fltprogs/eggToFlt.cxx
+++ /dev/null
@@ -1,672 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file eggToFlt.cxx
- * @author drose
- * @date 2003-10-01
- */
-
-#include "eggToFlt.h"
-#include "fltHeader.h"
-#include "fltBead.h"
-#include "fltGroup.h"
-#include "fltFace.h"
-#include "fltVertexList.h"
-#include "fltVertex.h"
-#include "fltTexture.h"
-#include "fltTransformTranslate.h"
-#include "fltTransformRotateAboutEdge.h"
-#include "fltTransformScale.h"
-#include "fltTransformGeneralMatrix.h"
-#include "eggPolygon.h"
-#include "eggPoint.h"
-#include "eggPrimitive.h"
-#include "eggExternalReference.h"
-#include "eggGroup.h"
-#include "eggGroupNode.h"
-#include "eggTexture.h"
-#include "eggTransform.h"
-#include "dcast.h"
-#include "string_utils.h"
-#include "vector_string.h"
-
-/**
- *
- */
-EggToFlt::
-EggToFlt() :
- EggToSomething("MultiGen", ".flt", true, false)
-{
- set_binary_output(true);
- set_program_brief("convert files from .egg format to MultiGen .flt");
- set_program_description
- ("egg2lt converts files from egg format to MultiGen .flt "
- "format. It attempts to be as robust as possible, and matches "
- "the capabilities of flt2egg. Generally, converting a model "
- "from egg2lt and then back via flt2egg will result in essentially "
- "the same egg file, within the limitations of what can be "
- "represented in flt.");
-
- add_option
- ("attr", "none/new/all", 0,
- "Specifies whether to write (or rewrite) .attr files for each "
- "texture image. MultiGen stores texture properties like mipmapping "
- "in a separate .attr file for each different texture image. "
- "If this parameter is \"none\", these files will not be generated; "
- "if this is \"new\", these files will only be generated if they "
- "do not already exist (even if the properties have changed). "
- "Specifying \"all\" causes these to be rewritten every time.",
- &EggToFlt::dispatch_attr, nullptr, &_auto_attr_update);
-
- // Flt files are always in the z-up coordinate system. Don't confuse the
- // user with this meaningless option.
- remove_option("cs");
- _coordinate_system = CS_zup_right;
- _got_coordinate_system = true;
- _auto_attr_update = FltHeader::AU_if_missing;
-}
-
-/**
- *
- */
-void EggToFlt::
-run() {
- _flt_header = new FltHeader(_path_replace);
- _flt_header->set_auto_attr_update(_auto_attr_update);
-
- traverse(_data, _flt_header, FltGeometry::BT_none);
-
- // Finally, write the resulting file out.
- FltError result = _flt_header->write_flt(get_output());
- if (result != FE_ok) {
- nout << "Cannot write " << get_output_filename() << "\n";
- exit(1);
- }
-}
-
-/**
- * Dispatch function for the -attr parameter.
- */
-bool EggToFlt::
-dispatch_attr(const std::string &opt, const std::string &arg, void *var) {
- FltHeader::AttrUpdate *ip = (FltHeader::AttrUpdate *)var;
-
- if (cmp_nocase(arg, "none") == 0) {
- *ip = FltHeader::AU_none;
-
- } else if (cmp_nocase(arg, "new") == 0) {
- *ip = FltHeader::AU_if_missing;
-
- } else if (cmp_nocase(arg, "all") == 0) {
- *ip = FltHeader::AU_always;
-
- } else {
- nout << "-" << opt
- << " requires either \"none\", \"new\", or \"all\".\n";
- return false;
- }
-
- return true;
-}
-
-/**
- *
- */
-void EggToFlt::
-traverse(EggNode *egg_node, FltBead *flt_node,
- FltGeometry::BillboardType billboard) {
- if (egg_node->is_of_type(EggPolygon::get_class_type()) ||
- egg_node->is_of_type(EggPoint::get_class_type())) {
- // It's a polygon or point light.
- EggPrimitive *egg_primitive = DCAST(EggPrimitive, egg_node);
- convert_primitive(egg_primitive, flt_node, billboard);
-
- } else if (egg_node->is_of_type(EggExternalReference::get_class_type())) {
- // Convert external references.
-
- } else if (egg_node->is_of_type(EggGroup::get_class_type())) {
- // An EggGroup creates a fltBead, and recurses.
- EggGroup *egg_group = DCAST(EggGroup, egg_node);
-
- if (egg_group->get_group_type() == EggGroup::GT_joint) {
- // Ignore joints and their children.
- return;
- }
-
- convert_group(egg_group, flt_node, billboard);
-
- } else if (egg_node->is_of_type(EggGroupNode::get_class_type())) {
- // Some kind of grouping node other than an EggGroup. Just recurse.
- EggGroupNode *egg_group = DCAST(EggGroupNode, egg_node);
- EggGroupNode::iterator ci;
- for (ci = egg_group->begin(); ci != egg_group->end(); ++ci) {
- traverse(*ci, flt_node, billboard);
- }
- }
-}
-
-/**
- * Converts an egg polygon or series of light points to the corresponding Flt
- * geometry, and adds it to the indicated flt_node.
- */
-void EggToFlt::
-convert_primitive(EggPrimitive *egg_primitive, FltBead *flt_node,
- FltGeometry::BillboardType billboard) {
- FltFace *flt_face = new FltFace(_flt_header);
- flt_node->add_child(flt_face);
-
- flt_face->_billboard_type = billboard;
-
- if (egg_primitive->has_color()) {
- flt_face->set_color(egg_primitive->get_color());
- }
-
- if (egg_primitive->is_of_type(EggPoint::get_class_type())) {
- // A series of points, instead of a polygon.
- flt_face->_draw_type = FltFace::DT_omni_light;
-
- } else if (egg_primitive->get_bface_flag()) {
- // A polygon whose backface is visible.
- flt_face->_draw_type = FltFace::DT_solid_no_cull;
-
- } else {
- // A normal polygon.
- flt_face->_draw_type = FltFace::DT_solid_cull_backface;
- }
-
- if (egg_primitive->has_texture()) {
- EggTexture *egg_texture = egg_primitive->get_texture();
- FltTexture *flt_texture = get_flt_texture(egg_texture);
- flt_face->set_texture(flt_texture);
- }
-
- // Create a vertex list representing the vertices in the primitive, and add
- // it as a child of the face bead. This is how Flt files associate vertices
- // with faces.
- FltVertexList *flt_vertices = new FltVertexList(_flt_header);
- flt_face->add_child(flt_vertices);
-
- EggPrimitive::iterator vi;
- bool all_verts_have_color = true;
- bool all_verts_have_normal = true;
- for (vi = egg_primitive->begin(); vi != egg_primitive->end(); ++vi) {
- EggVertex *egg_vertex = (*vi);
- FltVertex *flt_vertex = get_flt_vertex(egg_vertex, egg_primitive);
- flt_vertices->add_vertex(flt_vertex);
-
- if (!egg_vertex->has_color()) {
- all_verts_have_color = false;
- }
- if (!egg_vertex->has_normal()) {
- all_verts_have_normal = false;
- }
- }
- if (all_verts_have_color) {
- // If all the vertices of the face have a color specification, then we
- // specify per-vertex color on the face.
- if (all_verts_have_normal) {
- // And similarly with the normals.
- flt_face->_light_mode = FltFace::LM_vertex_with_normal;
- } else {
- flt_face->_light_mode = FltFace::LM_vertex_no_normal;
- }
- } else {
- if (all_verts_have_normal) {
- flt_face->_light_mode = FltFace::LM_face_with_normal;
- } else {
- flt_face->_light_mode = FltFace::LM_face_no_normal;
- }
- }
-}
-
-/**
- * Converts an egg group to the corresponding flt group, and adds it to the
- * indicated parent node. Also recurses on the children of the egg group.
- */
-void EggToFlt::
-convert_group(EggGroup *egg_group, FltBead *flt_node,
- FltGeometry::BillboardType billboard) {
- std::ostringstream egg_syntax;
-
- FltGroup *flt_group = new FltGroup(_flt_header);
- flt_node->add_child(flt_group);
-
- flt_group->set_id(egg_group->get_name());
-
- switch (egg_group->get_billboard_type()) {
- // MultiGen represents billboarding at the polygon level, so we have to
- // remember this flag for later.
- case EggGroup::BT_axis:
- billboard = FltGeometry::BT_axial;
- break;
-
- case EggGroup::BT_point_world_relative:
- billboard = FltGeometry::BT_point;
- break;
-
- case EggGroup::BT_point_camera_relative:
- // Not sure if this is the right flag for MultiGen.
- billboard = FltGeometry::BT_fixed;
- break;
-
- default:
- break;
- }
-
- if (egg_group->has_transform()) {
- apply_transform(egg_group, flt_group);
- }
-
- if (egg_group->get_switch_flag()) {
- if (egg_group->get_switch_fps() != 0.0) {
- // A sequence animation.
- flt_group->_flags |= FltGroup::F_forward_animation;
- egg_syntax
- << "