bam 5.0, new Geom implementation is now official
This commit is contained in:
parent
ea4792ebc5
commit
bc0d509090
|
|
@ -6,7 +6,6 @@
|
|||
#define INSTALL_SCRIPTS $[INSTALL_SCRIPTS] genPyCode.bat
|
||||
#else
|
||||
#define INSTALL_SCRIPTS $[INSTALL_SCRIPTS] genPyCode
|
||||
#define INSTALL_SCRIPTS $[INSTALL_SCRIPTS] genPyCodeNative
|
||||
#endif
|
||||
|
||||
#include $[THISDIRPREFIX]genPyCode.pp
|
||||
|
|
|
|||
|
|
@ -1,4 +0,0 @@
|
|||
#! /bin/sh
|
||||
|
||||
echo "genPyCodeNative is now deprecated; just use genPyCode."
|
||||
exit 1
|
||||
|
|
@ -102,10 +102,6 @@
|
|||
|
||||
// #define INSTALL_LIB_DIR /usr/lib/python2.2/site-packages
|
||||
|
||||
// If you want to use python 2.2 or earlier, you may need this defined:
|
||||
// (Later versions of Python handle signed and unsigned integers differently).
|
||||
// #define USE_PYTHON_2_2_OR_EARLIER
|
||||
|
||||
|
||||
// The character used to separate components of an OS-specific
|
||||
// directory name depends on the platform (it is '/' on Unix, '\' on
|
||||
|
|
@ -813,8 +809,8 @@
|
|||
// a running program without crashing the running instance. However,
|
||||
// it doesn't understanding installing a program from a subdirectory,
|
||||
// so we have to cd into the source directory first.
|
||||
#defer INSTALL $[if $[ne $[dir $[local]], ./],cd ./$[dir $[local]] &&] install -m $[INSTALL_UMASK_DATA] $[notdir $[local]] $[dest]/
|
||||
#defer INSTALL_PROG $[if $[ne $[dir $[local]], ./],cd ./$[dir $[local]] &&] install -m $[INSTALL_UMASK_PROG] $[notdir $[local]] $[dest]/
|
||||
#defer INSTALL $[if $[ne $[dir $[local]], ./],cd ./$[dir $[local]] &&] install -m $[INSTALL_UMASK_DATA] -p $[notdir $[local]] $[dest]/
|
||||
#defer INSTALL_PROG $[if $[ne $[dir $[local]], ./],cd ./$[dir $[local]] &&] install -m $[INSTALL_UMASK_PROG] -p $[notdir $[local]] $[dest]/
|
||||
|
||||
// Variable definitions for building with the Irix MIPSPro compiler.
|
||||
#if $[eq $[USE_COMPILER], MIPS]
|
||||
|
|
|
|||
|
|
@ -448,7 +448,4 @@ $[cdefine VC6_STYLE_ALLOCATOR]
|
|||
$[cdefine MODERN_STYLE_ALLOCATOR]
|
||||
$[cdefine NO_STYLE_ALLOCATOR]
|
||||
|
||||
/* Define if you want to use Python before 2.3. */
|
||||
$[cdefine USE_PYTHON_2_2_OR_EARLIER]
|
||||
|
||||
#end dtool_config.h
|
||||
|
|
|
|||
|
|
@ -427,19 +427,19 @@ $[TAB] rm -f $[sort $[installed_files]]
|
|||
$[install_lib_dir]/$[get_dllname $[TARGET]].$[dlllib] : $[ODIR]/$[get_dllname $[TARGET]].$[dlllib]
|
||||
#define local $[get_dllname $[TARGET]].$[dlllib]
|
||||
#define dest $[install_lib_dir]
|
||||
$[TAB] cp -f $[ODIR]/$[local] $[dest]/
|
||||
$[TAB] cp -p -f $[ODIR]/$[local] $[dest]/
|
||||
#endif
|
||||
|
||||
$[install_lib_dir]/$[get_dllname $[TARGET]].lib : $[ODIR]/$[get_dllname $[TARGET]].lib
|
||||
#define local $[get_dllname $[TARGET]].lib
|
||||
#define dest $[install_lib_dir]
|
||||
$[TAB] cp -f $[ODIR]/$[local] $[dest]/
|
||||
$[TAB] cp -p -f $[ODIR]/$[local] $[dest]/
|
||||
|
||||
#if $[and $[build_dlls],$[build_pdbs]]
|
||||
$[install_lib_dir]/$[get_dllname $[TARGET]].pdb : $[ODIR]/$[get_dllname $[TARGET]].pdb
|
||||
#define local $[get_dllname $[TARGET]].pdb
|
||||
#define dest $[install_lib_dir]
|
||||
$[TAB] cp -f $[ODIR]/$[local] $[dest]/
|
||||
$[TAB] cp -p -f $[ODIR]/$[local] $[dest]/
|
||||
#endif
|
||||
|
||||
#if $[igatescan]
|
||||
|
|
@ -458,7 +458,7 @@ $[TAB] cp -f $[ODIR]/$[local] $[dest]/
|
|||
$[igatedb:$[ODIR]/%=$[install_igatedb_dir]/%] : $[igatedb]
|
||||
#define local $[igatedb]
|
||||
#define dest $[install_igatedb_dir]
|
||||
$[TAB] cp -f $[local] $[dest]/
|
||||
$[TAB] cp -p -f $[local] $[dest]/
|
||||
|
||||
// We have to split this out as a separate rule to properly support
|
||||
// parallel make.
|
||||
|
|
@ -610,7 +610,7 @@ $[TAB] rm -f $[sort $[installed_files]]
|
|||
$[install_lib_dir]/$[get_dllname $[TARGET]].lib : $[ODIR]/$[get_dllname $[TARGET]].lib
|
||||
#define local $[get_dllname $[TARGET]].lib
|
||||
#define dest $[install_lib_dir]
|
||||
$[TAB] cp -f $[ODIR]/$[local] $[dest]/
|
||||
$[TAB] cp -p -f $[ODIR]/$[local] $[dest]/
|
||||
|
||||
#end static_lib_target ss_lib_target
|
||||
|
||||
|
|
@ -645,7 +645,7 @@ $[TAB] rm -f $[sort $[installed_files]]
|
|||
#define local $[TARGET]
|
||||
#define dest $[install_bin_dir]
|
||||
$[install_bin_dir]/$[TARGET] : $[ODIR]/$[TARGET]
|
||||
$[TAB] cp -f $[ODIR]/$[local] $[dest]/
|
||||
$[TAB] cp -p -f $[ODIR]/$[local] $[dest]/
|
||||
|
||||
#end sed_bin_target
|
||||
|
||||
|
|
@ -699,13 +699,13 @@ $[TAB] rm -f $[sort $[installed_files]]
|
|||
$[install_bin_dir]/$[TARGET].exe : $[ODIR]/$[TARGET].exe
|
||||
#define local $[TARGET].exe
|
||||
#define dest $[install_bin_dir]
|
||||
$[TAB] cp -f $[ODIR]/$[local] $[dest]/
|
||||
$[TAB] cp -p -f $[ODIR]/$[local] $[dest]/
|
||||
|
||||
#if $[build_pdbs]
|
||||
$[install_bin_dir]/$[TARGET].pdb : $[ODIR]/$[TARGET].pdb
|
||||
#define local $[TARGET].pdb
|
||||
#define dest $[install_bin_dir]
|
||||
$[TAB] cp -f $[ODIR]/$[local] $[dest]/
|
||||
$[TAB] cp -p -f $[ODIR]/$[local] $[dest]/
|
||||
#endif
|
||||
|
||||
#if $[bin_postprocess_target]
|
||||
|
|
@ -717,7 +717,7 @@ $[TAB] rm -f $[output_exe]
|
|||
$[TAB] $[bin_postprocess_cmd] $[bin_postprocess_arg1] $[input_exe] $[bin_postprocess_arg2] $[output_exe]
|
||||
|
||||
$[install_bin_dir]/$[bin_postprocess_target].exe : $[output_exe]
|
||||
$[TAB] cp -f $[output_exe] $[install_bin_dir]/
|
||||
$[TAB] cp -p -f $[output_exe] $[install_bin_dir]/
|
||||
#endif
|
||||
|
||||
#end bin_target
|
||||
|
|
@ -850,14 +850,14 @@ $[TAB] $[COMPILE_C++]
|
|||
$[install_bin_dir]/$[file] : $[file]
|
||||
#define local $[file]
|
||||
#define dest $[install_bin_dir]
|
||||
$[TAB] chmod +x $[local]; cp -f $[local] $[dest]/
|
||||
$[TAB] chmod +x $[local]; cp -p -f $[local] $[dest]/
|
||||
#end file
|
||||
|
||||
#foreach file $[install_headers]
|
||||
$[install_headers_dir]/$[file] : $[file]
|
||||
#define local $[file]
|
||||
#define dest $[install_headers_dir]
|
||||
$[TAB] cp -f $[local] $[dest]/
|
||||
$[TAB] cp -p -f $[local] $[dest]/
|
||||
#end file
|
||||
|
||||
#foreach file $[install_parser_inc]
|
||||
|
|
@ -866,12 +866,12 @@ $[install_parser_inc_dir]/$[file] : $[notdir $[file]]
|
|||
#define local $[notdir $[file]]
|
||||
#define dest $[install_parser_inc_dir]/$[dir $[file]]
|
||||
$[TAB] mkdir -p $[install_parser_inc_dir]/$[dir $[file]] || echo
|
||||
$[TAB] cp -f $[local] $[dest]
|
||||
$[TAB] cp -p -f $[local] $[dest]
|
||||
#else
|
||||
$[install_parser_inc_dir]/$[file] : $[file]
|
||||
#define local $[file]
|
||||
#define dest $[install_parser_inc_dir]
|
||||
$[TAB] cp -f $[local] $[dest]/
|
||||
$[TAB] cp -p -f $[local] $[dest]/
|
||||
#endif
|
||||
#end file
|
||||
|
||||
|
|
@ -879,21 +879,21 @@ $[TAB] cp -f $[local] $[dest]/
|
|||
$[install_data_dir]/$[file] : $[file]
|
||||
#define local $[file]
|
||||
#define dest $[install_data_dir]
|
||||
$[TAB] cp -f $[local] $[dest]/
|
||||
$[TAB] cp -p -f $[local] $[dest]/
|
||||
#end file
|
||||
|
||||
#foreach file $[install_config]
|
||||
$[install_config_dir]/$[file] : $[file]
|
||||
#define local $[file]
|
||||
#define dest $[install_config_dir]
|
||||
$[TAB] cp -f $[local] $[dest]/
|
||||
$[TAB] cp -p -f $[local] $[dest]/
|
||||
#end file
|
||||
|
||||
#foreach file $[install_py]
|
||||
$[install_py_dir]/$[file] : $[file]
|
||||
#define local $[file]
|
||||
#define dest $[install_py_dir]
|
||||
$[TAB] cp -f $[local] $[dest]/
|
||||
$[TAB] cp -p -f $[local] $[dest]/
|
||||
#end file
|
||||
|
||||
#if $[install_py]
|
||||
|
|
@ -1049,7 +1049,7 @@ $[TAB] @test -d $[install_headers_dir] || mkdir -p $[install_headers_dir]
|
|||
$[install_headers_dir]/$[CONFIG_HEADER] : $[CONFIG_HEADER]
|
||||
#define local $[CONFIG_HEADER]
|
||||
#define dest $[install_headers_dir]
|
||||
$[TAB] cp -f $[local] $[dest]/
|
||||
$[TAB] cp -p -f $[local] $[dest]/
|
||||
#endif
|
||||
|
||||
// Finally, the rules to freshen the Makefile itself.
|
||||
|
|
|
|||
|
|
@ -394,12 +394,15 @@ write_function_instance(ostream &out, int indent_level,
|
|||
extra_cleanup += " Py_XDECREF(" + param_name + "_long);";
|
||||
expected_params += "long";
|
||||
|
||||
#ifndef USE_PYTHON_2_2_OR_EARLIER
|
||||
} else if (TypeManager::is_unsigned_integer(type)) {
|
||||
out << "unsigned int " << param_name;
|
||||
format_specifiers += "I"; // This requires Python 2.3 or better
|
||||
out << "PyObject *" << param_name;
|
||||
format_specifiers += "O";
|
||||
parameter_list += ", &" + param_name;
|
||||
#endif
|
||||
extra_convert += " PyObject *" + param_name + "_uint = PyNumber_Long(" + param_name + ");";
|
||||
extra_param_check += "|| (" + param_name + "_uint == NULL)";
|
||||
pexpr_string = "(unsigned int)PyLong_AsUnsignedLong(" + param_name + "_uint)";
|
||||
extra_cleanup += " Py_XDECREF(" + param_name + "_uint);";
|
||||
expected_params += "unsigned int";
|
||||
|
||||
} else if (TypeManager::is_integer(type)) {
|
||||
out << "int " << param_name;
|
||||
|
|
@ -571,11 +574,9 @@ pack_return_value(ostream &out, int indent_level,
|
|||
indent(out, indent_level)
|
||||
<< "return PyLong_FromLongLong(" << return_expr << ");\n";
|
||||
|
||||
#ifndef USE_PYTHON_2_2_OR_EARLIER
|
||||
} else if (TypeManager::is_unsigned_integer(type)) {
|
||||
indent(out, indent_level)
|
||||
<< "return PyLong_FromUnsignedLong(" << return_expr << ");\n";
|
||||
#endif
|
||||
|
||||
} else if (TypeManager::is_integer(type)) {
|
||||
indent(out, indent_level)
|
||||
|
|
|
|||
|
|
@ -303,12 +303,14 @@ void InterfaceMakerPythonSimple::write_function_instance(ostream &out, Interface
|
|||
pexpr_string = "PyLong_AsLongLong(" + param_name + "_long)";
|
||||
extra_cleanup += " Py_XDECREF(" + param_name + "_long);";
|
||||
|
||||
#ifndef USE_PYTHON_2_2_OR_EARLIER
|
||||
} else if (TypeManager::is_unsigned_integer(type)) {
|
||||
out << "unsigned int " << param_name;
|
||||
format_specifiers += "I"; // This requires Python 2.3 or better
|
||||
out << "PyObject *" << param_name;
|
||||
format_specifiers += "O";
|
||||
parameter_list += ", &" + param_name;
|
||||
#endif
|
||||
extra_convert += " PyObject *" + param_name + "_uint = PyNumber_Long(" + param_name + ");";
|
||||
extra_param_check += "|| (" + param_name + "_uint == NULL)";
|
||||
pexpr_string = "(unsigned int)PyLong_AsUnsignedLong(" + param_name + "_uint)";
|
||||
extra_cleanup += " Py_XDECREF(" + param_name + "_uint);";
|
||||
|
||||
} else if (TypeManager::is_integer(type)) {
|
||||
out << "int " << param_name;
|
||||
|
|
@ -463,11 +465,9 @@ pack_return_value(ostream &out, int indent_level,
|
|||
indent(out, indent_level)
|
||||
<< "return PyLong_FromLongLong(" << return_expr << ");\n";
|
||||
|
||||
#ifndef USE_PYTHON_2_2_OR_EARLIER
|
||||
} else if (TypeManager::is_unsigned_integer(type)) {
|
||||
indent(out, indent_level)
|
||||
<< "return PyLong_FromUnsignedLong(" << return_expr << ");\n";
|
||||
#endif
|
||||
|
||||
} else if (TypeManager::is_integer(type)) {
|
||||
indent(out, indent_level)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
#define BUILD_DIRECTORY $[HAVE_DX]
|
||||
// DX7 build is temporarily disabled until we bring it up-to-date with
|
||||
// the new Geom rewrite.
|
||||
#define BUILD_DIRECTORY
|
||||
//#define BUILD_DIRECTORY $[HAVE_DX]
|
||||
|
||||
// DIR_TYPE "metalib" indicates we are building a shared library that
|
||||
// consists mostly of references to other shared libraries. Under
|
||||
|
|
|
|||
|
|
@ -7,6 +7,12 @@
|
|||
|
||||
#include "config_dxgsg7.h"
|
||||
|
||||
// By including checkPandaVersion.h, we guarantee that runtime
|
||||
// attempts to load libpandadx7.dll will fail if they
|
||||
// inadvertently link with the wrong version of libdtool.dll.
|
||||
|
||||
#include "checkPandaVersion.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: init_libpandadx7
|
||||
// Description: Initializes the library. This must be called at
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
#define BUILD_DIRECTORY $[HAVE_DX]
|
||||
// DX9 build is temporarily disabled until we bring it up-to-date with
|
||||
// the new Geom rewrite.
|
||||
#define BUILD_DIRECTORY
|
||||
//#define BUILD_DIRECTORY $[HAVE_DX]
|
||||
|
||||
// DIR_TYPE "metalib" indicates we are building a shared library that
|
||||
// consists mostly of references to other shared libraries. Under
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#include "config_dxgsg9.h"
|
||||
|
||||
// By including checkPandaVersion.h, we guarantee that runtime
|
||||
// attempts to load libpandadx8.dll will fail if they
|
||||
// attempts to load libpandadx9.dll will fail if they
|
||||
// inadvertently link with the wrong version of libdtool.dll.
|
||||
|
||||
#include "checkPandaVersion.h"
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#define BUILDING_DLL BUILDING_PANDAEGG
|
||||
|
||||
#define COMPONENT_LIBS \
|
||||
egg2pg egg2sg egg builder
|
||||
egg2pg egg2sg egg
|
||||
|
||||
#define LOCAL_LIBS putil express
|
||||
#define OTHER_LIBS interrogatedb:c dconfig:c dtoolconfig:m \
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
#include "pandaegg.h"
|
||||
|
||||
#include "config_egg.h"
|
||||
#include "config_builder.h"
|
||||
#include "config_egg2pg.h"
|
||||
|
||||
// By including checkPandaVersion.h, we guarantee that runtime
|
||||
|
|
@ -26,6 +25,5 @@
|
|||
void
|
||||
init_libpandaegg() {
|
||||
init_libegg();
|
||||
init_libbuilder();
|
||||
init_libegg2pg();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,58 +0,0 @@
|
|||
#define OTHER_LIBS interrogatedb:c dconfig:c dtoolconfig:m \
|
||||
dtoolutil:c dtoolbase:c dtool:m
|
||||
|
||||
#begin lib_target
|
||||
#define TARGET builder
|
||||
#define LOCAL_LIBS \
|
||||
pgraph linmath gobj putil gsgbase mathutil pnmimage \
|
||||
pandabase
|
||||
|
||||
#define COMBINED_SOURCES $[TARGET]_composite1.cxx $[TARGET]_composite2.cxx
|
||||
|
||||
#define SOURCES \
|
||||
builder.I builder.h \
|
||||
builder_compare.I builder_compare.h \
|
||||
builderAttrib.I builderAttrib.h \
|
||||
builderAttribTempl.I builderAttribTempl.h builderBucket.I \
|
||||
builderBucket.h builderBucketNode.I builderBucketNode.h \
|
||||
builderFuncs.I builderFuncs.h builderMisc.h \
|
||||
builderNormalVisualizer.I builderNormalVisualizer.h \
|
||||
builderPrim.I builderPrim.h builderPrimTempl.I \
|
||||
builderPrimTempl.h builderProperties.h builderTypes.h \
|
||||
builderVertex.I builderVertex.h builderVertexTempl.I \
|
||||
builderVertexTempl.h config_builder.h mesher.h \
|
||||
mesherConfig.h mesherEdge.I mesherEdge.h mesherFanMaker.I \
|
||||
mesherFanMaker.h mesherStrip.I mesherStrip.h mesherTempl.I \
|
||||
mesherTempl.h
|
||||
|
||||
#define INCLUDED_SOURCES \
|
||||
builder.cxx builderAttrib.cxx builderBucket.cxx \
|
||||
builderBucketNode.cxx builderMisc.cxx \
|
||||
builderNormalVisualizer.cxx builderPrim.cxx \
|
||||
builderProperties.cxx builderTypes.cxx builderVertex.cxx \
|
||||
config_builder.cxx mesher.cxx
|
||||
|
||||
#define INSTALL_HEADERS \
|
||||
builder.I builder.h \
|
||||
builder_compare.I builder_compare.h \
|
||||
builderAttrib.I builderAttrib.h \
|
||||
builderAttribTempl.I builderAttribTempl.h builderBucket.I \
|
||||
builderBucket.h builderBucketNode.I builderBucketNode.h \
|
||||
builderNormalVisualizer.I builderNormalVisualizer.h \
|
||||
builderPrim.I builderPrim.h \
|
||||
builderPrimTempl.I builderPrimTempl.h builderProperties.h \
|
||||
builderTypes.h builderVertex.I builderVertex.h builderVertexTempl.I \
|
||||
builderVertexTempl.h config_builder.h
|
||||
|
||||
#end lib_target
|
||||
|
||||
#begin test_bin_target
|
||||
#define TARGET test_builder
|
||||
#define LOCAL_LIBS \
|
||||
builder
|
||||
|
||||
#define SOURCES \
|
||||
test_builder.cxx test_builder_data.cxx
|
||||
|
||||
#end test_bin_target
|
||||
|
||||
|
|
@ -1,82 +0,0 @@
|
|||
// Filename: builder.I
|
||||
// Created by: drose (09Sep97)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Builder::add_prim
|
||||
// Access: Public
|
||||
// Description: Adds the indicated nonindexed primitive, along with
|
||||
// its associated bucket, to the builder's internal
|
||||
// structures. This copies all relevant information
|
||||
// into the builder.
|
||||
//
|
||||
// Returns true if the primitive was successfully added,
|
||||
// false if it was invalid for some reason (for
|
||||
// instance, a polygon with two vertices).
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool Builder::
|
||||
add_prim(const BuilderBucket &bucket,
|
||||
const BuilderPrim &prim) {
|
||||
add_bucket(bucket);
|
||||
return ((BuilderBucketNode &)(*_bi)).add_prim(prim);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Builder::add_prim
|
||||
// Access: Public
|
||||
// Description: Adds the indicated indexed primitive, along with
|
||||
// its associated bucket, to the builder's internal
|
||||
// structures. This copies all relevant information
|
||||
// into the builder.
|
||||
//
|
||||
// Returns true if the primitive was successfully added,
|
||||
// false if it was invalid for some reason (for
|
||||
// instance, a polygon with two vertices).
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool Builder::
|
||||
add_prim(const BuilderBucket &bucket,
|
||||
const BuilderPrimI &prim) {
|
||||
add_bucket(bucket);
|
||||
return ((BuilderBucketNode &)(*_bi)).add_prim(prim);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Builder::add_prim_nonindexed
|
||||
// Access: Public
|
||||
// Description: Adds the specified indexed primitive as if it were
|
||||
// nonindexed. This simply looks up each coordinate
|
||||
// value on the prim in its associated array and stores
|
||||
// a nonindexed primitive with the actual coordinate
|
||||
// values, instead of the index numbers.
|
||||
//
|
||||
// This is handy for having code that calls the builder
|
||||
// and might want to build either indexed or nonindexed
|
||||
// geometry, as selected by the user at run-time.
|
||||
// Simply build indexed geometry in all cases, then call
|
||||
// either add_prim or add_prim_nonindexed, according to
|
||||
// the user's selection.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool Builder::
|
||||
add_prim_nonindexed(const BuilderBucket &bucket,
|
||||
const BuilderPrimI &prim) {
|
||||
add_bucket(bucket);
|
||||
return ((BuilderBucketNode &)(*_bi)).add_prim_nonindexed(prim);
|
||||
}
|
||||
|
|
@ -1,247 +0,0 @@
|
|||
// Filename: builder.cxx
|
||||
// Created by: drose (09Sep97)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "builderFuncs.h"
|
||||
#include "builderMisc.h"
|
||||
#include "notify.h"
|
||||
#include "pmap.h"
|
||||
#include "builder.h"
|
||||
#include "pandaNode.h"
|
||||
#include "geomNode.h"
|
||||
#include "dcast.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Builder::Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
Builder::
|
||||
Builder() {
|
||||
_bi = _buckets.end();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Builder::Destructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
Builder::
|
||||
~Builder() {
|
||||
// Free all the buckets we allocated. We allocated 'em, we free
|
||||
// 'em.
|
||||
Buckets::iterator bi;
|
||||
for (bi = _buckets.begin();
|
||||
bi != _buckets.end();
|
||||
++bi) {
|
||||
BuilderBucket *bucket = (*bi).get_bucket();
|
||||
delete bucket;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// We use the NodeMap class to build up a map of Nodes to GeomNodes.
|
||||
// There may be several buckets that point to the same Node; these
|
||||
// should all be given the same GeomNode, when possible.
|
||||
|
||||
// However, if two buckets have different sets of scene graph
|
||||
// properties--in particular, the _hidden member is different--they
|
||||
// must be given separate GeomNodes.
|
||||
|
||||
// Furthermore, it's possible to name each bucket. If two buckets
|
||||
// with the same Node pointer have different names, then they should
|
||||
// be given two different GeomNodes.
|
||||
|
||||
class NodeMap : public Namable {
|
||||
public:
|
||||
NodeMap(PandaNode *node, const BuilderBucket *bucket)
|
||||
: _node(node), _bucket(bucket) { }
|
||||
|
||||
bool operator < (const NodeMap &other) const {
|
||||
if (_node != other._node) {
|
||||
return _node < other._node;
|
||||
}
|
||||
if (_bucket->_hidden != other._bucket->_hidden) {
|
||||
return _bucket->_hidden < other._bucket->_hidden;
|
||||
}
|
||||
if (_bucket->get_name() != other._bucket->get_name()) {
|
||||
return _bucket->get_name() < other._bucket->get_name();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
PandaNode *_node;
|
||||
|
||||
// Although a bucket pointer is stored here in the NodeMap class,
|
||||
// you should not use it except to extract the name and/or the
|
||||
// _trans member. Remember, this bucket pointer stands for any of
|
||||
// possibly several bucket pointers, all different, except that they
|
||||
// share the same name.
|
||||
const BuilderBucket *_bucket;
|
||||
};
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Builder::build
|
||||
// Access: Public
|
||||
// Description: Creates Geoms for all the primitives added to all
|
||||
// buckets, and adds them where appropriate to place
|
||||
// them in the scene graph under their respective
|
||||
// parents, and/or returns a single GeomNode that
|
||||
// contains all geometry whose bucket did not reference
|
||||
// a particular scene graph node to parent them to.
|
||||
//
|
||||
// If a bucket's _node pointer was a GeomNode, the
|
||||
// geometry will be added directly to that node. If the
|
||||
// _node pointer was any other kind of node, a GeomNode
|
||||
// will be created and parented to that node, and its
|
||||
// name will be the name of the bucket. In this case,
|
||||
// the name of the bucket can also be used to
|
||||
// differentiate nodes: if two buckets reference the
|
||||
// same node, but have different names, then two
|
||||
// different GeomNodes are created, one with each name.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
GeomNode *Builder::
|
||||
build(const string &default_name) {
|
||||
typedef pmap<NodeMap, GeomNode *> GeomNodeMap;
|
||||
GeomNodeMap geom_nodes;
|
||||
|
||||
// First, build all the Geoms and create GeomNodes for them. Each
|
||||
// unique Node gets its own GeomNode. If the Node is itself a
|
||||
// GeomNode, that GeomNode is used directly.
|
||||
Buckets::iterator i;
|
||||
for (i = _buckets.begin();
|
||||
i != _buckets.end();
|
||||
++i) {
|
||||
BuilderBucket *bucket = (*i).get_bucket();
|
||||
PandaNode *node = bucket->_node;
|
||||
GeomNode *geom_node = NULL;
|
||||
|
||||
if (node != (PandaNode *)NULL &&
|
||||
node->is_of_type(GeomNode::get_class_type())) {
|
||||
// The node is a GeomNode. In this case, we simply use that
|
||||
// node. We can't separate them out by name in this case; we'll
|
||||
// just assign to it the first nonempty name we encounter.
|
||||
geom_node = DCAST(GeomNode, node);
|
||||
|
||||
// Since the caller already created this GeomNode and passed it
|
||||
// in, we'll leave it up to the caller to name the node and set
|
||||
// up the state transitions leading into it.
|
||||
|
||||
} else {
|
||||
// The node is not a GeomNode, so look it up in the map.
|
||||
GeomNodeMap::iterator f = geom_nodes.find(NodeMap(node, bucket));
|
||||
if (f != geom_nodes.end()) {
|
||||
geom_node = (*f).second;
|
||||
|
||||
} else {
|
||||
// No such node/name combination. Create a new one.
|
||||
geom_node = bucket->make_geom_node();
|
||||
if (geom_node != NULL) {
|
||||
geom_nodes[NodeMap(node, bucket)] = geom_node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (geom_node != NULL) {
|
||||
(*i).build(geom_node);
|
||||
}
|
||||
}
|
||||
|
||||
// Now go through and parent the geom_nodes under their respective
|
||||
// group nodes. Save out the geom_node associated with a NULL Node;
|
||||
// this one is returned from this function.
|
||||
|
||||
GeomNode *base_geom_node = NULL;
|
||||
|
||||
GeomNodeMap::iterator gi;
|
||||
|
||||
for (gi = geom_nodes.begin();
|
||||
gi != geom_nodes.end();
|
||||
++gi) {
|
||||
const NodeMap &nm = (*gi).first;
|
||||
GeomNode *geom_node = (*gi).second;
|
||||
|
||||
PandaNode *node = nm._node;
|
||||
const string &name = nm._bucket->get_name();
|
||||
|
||||
// Assign the name to the geom, if it doesn't have one already.
|
||||
if (!geom_node->has_name()) {
|
||||
if (!name.empty()) {
|
||||
geom_node->set_name(name);
|
||||
|
||||
} else if (!default_name.empty()) {
|
||||
geom_node->set_name(default_name);
|
||||
}
|
||||
}
|
||||
|
||||
// Only reparent the geom_node if it has no parent already.
|
||||
int num_parents = geom_node->get_num_parents();
|
||||
if (num_parents == 0) {
|
||||
if (geom_node->get_num_geoms() == 0) {
|
||||
// If there was nothing added, never mind.
|
||||
delete geom_node;
|
||||
|
||||
} else if (node==NULL) {
|
||||
nassertr(base_geom_node == NULL, NULL);
|
||||
if (!nm._bucket->_hidden) {
|
||||
base_geom_node = geom_node;
|
||||
}
|
||||
|
||||
} else {
|
||||
if (nm._bucket->_hidden) {
|
||||
// If the contents of the bucket are supposed to be hidden,
|
||||
// add the GeomNode as a stashed child.
|
||||
node->add_stashed(geom_node);
|
||||
} else {
|
||||
// Otherwise, in the normal case, the GeomNode is a normal,
|
||||
// visible child of its parent.
|
||||
node->add_child(geom_node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return base_geom_node;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Builder::add_bucket
|
||||
// Access: Protected
|
||||
// Description: Adds a new BuilderBucket just like the given one to
|
||||
// the set of all used BuilderBuckets, and makes it the
|
||||
// current bucket. Future primitives will be added to
|
||||
// this bucket.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void Builder::
|
||||
add_bucket(const BuilderBucket &bucket) {
|
||||
// Optimization: maybe it's the same bucket we used last time.
|
||||
if (_bi != _buckets.end() &&
|
||||
(*_bi) == BuilderBucketNode((BuilderBucket *)&bucket)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Nope. Look again.
|
||||
_bi = _buckets.find((BuilderBucket *)&bucket);
|
||||
if (_bi == _buckets.end()) {
|
||||
BuilderBucket *new_bucket = bucket.make_copy();
|
||||
_bi = _buckets.insert(new_bucket).first;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,211 +0,0 @@
|
|||
// Filename: builder.h
|
||||
// Created by: drose (09Sep97)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef BUILDER_H
|
||||
#define BUILDER_H
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Builder
|
||||
//
|
||||
// The builder accepts as input a loose collection of polygons with
|
||||
// various attributes, sizes, and shapes, and does all the work of
|
||||
// grouping relating polygons and creating triangle strips, etc.,
|
||||
// ultimately storing the resulting optimized geometry into one or
|
||||
// more GeomNodes.
|
||||
//
|
||||
// It is intended that the builder should be the single entry point
|
||||
// for all code wishing to create geometry in the scene graph. The
|
||||
// builder can know about the kinds of geometry that are optimal for a
|
||||
// particular platform, or even about the kinds of geometry that are
|
||||
// available for a given platform. (For instance, perhaps on some
|
||||
// bizarre platform, triangle strips do not exist, but quadstrips are
|
||||
// really fast. User code should not create triangle strips
|
||||
// directly.)
|
||||
//
|
||||
// Actually, there are two fairly separate pieces in this package.
|
||||
// The first is the builder itself, which handles the interface to
|
||||
// user code, and is responsible for collecting polygons from the
|
||||
// caller, sorting them according to their attributes, and creating
|
||||
// Geoms that represent the resulting geometry. The second piece is
|
||||
// the mesher, which receives geometry from the builder and tries to
|
||||
// create optimal triangle strips (or whichever kind of higher-level
|
||||
// structure is most appropriate) from them, which it hands back to
|
||||
// the builder.
|
||||
//
|
||||
// It is possible to use the builder without invoking the mesher, in
|
||||
// which case the builder will create Geoms with the individual prims
|
||||
// exactly as the user passed them in. It is not possible to use the
|
||||
// mesher without first going through the builder.
|
||||
//
|
||||
//
|
||||
// The general system of using the builder is as follows:
|
||||
//
|
||||
// (a) Create a Builder object.
|
||||
//
|
||||
// (b) Iterate through the polygons. For each polygon:
|
||||
//
|
||||
// (c) Create a BuilderBucket object and assign to it the
|
||||
// scene-graph level attributes, such as texture, lighting,
|
||||
// etc. for your polygon. If several polygons share the same
|
||||
// attributes, they can of course use the same bucket. But
|
||||
// there's no reason to be afraid of creating a new bucket
|
||||
// object each time, if that's more convenient.
|
||||
//
|
||||
// (d) Create a BuilderPrim object to describe the polygon. If
|
||||
// the polygon is to have a polygon color or polygon normal,
|
||||
// set these on the BuilderPrim.
|
||||
//
|
||||
// (e) Iterate through the polygon vertices, in counterclockwise
|
||||
// order when viewed from the front of the polygon. For each
|
||||
// vertex:
|
||||
//
|
||||
// (f) Create a BuilderVertex object. If the vertex has a
|
||||
// texture coordinate, normal, or color, set this on the
|
||||
// BuilderVertex.
|
||||
//
|
||||
// (g) Add the BuilderVertex to the BuilderPrim.
|
||||
//
|
||||
// (h) Add the BuilderPrim to the Builder.
|
||||
//
|
||||
// (i) Call Builder::build() and receive your new geometry!
|
||||
//
|
||||
// All of these objects--BuilderBucket, BuilderPrim, and
|
||||
// BuilderVertex--can, and probably should, be ordinary local
|
||||
// variables. When they are added into their respective data
|
||||
// structures they are copied, not referenced, so there's no need to
|
||||
// try to keep them around after that.
|
||||
//
|
||||
// The BuilderBucket is the builder's system for grouping polygons
|
||||
// that share similar characteristings. Polygons that were added to
|
||||
// the builder with equivalent (though not necessarily identical)
|
||||
// buckets may be candidates for joining together into triangle strips
|
||||
// when possible.
|
||||
//
|
||||
//
|
||||
// That's the basic operation. There are lots of fancy features on
|
||||
// top of that.
|
||||
//
|
||||
// * Other kinds of geometry than polygons are supported. Presently,
|
||||
// these are light points and line segments. To add these kinds of
|
||||
// geometry, call set_type() on your BuilderPrim with either
|
||||
// BPT_point or BPT_line.
|
||||
//
|
||||
// * Indexed geometry is supported as well as nonindexed. Indexed
|
||||
// geometry means that the vertices, UV's, etc. are referenced
|
||||
// indirectly; an index number into a table is stored instead of
|
||||
// the actual coordinate values. Indexed geometry may be freely
|
||||
// mixed in with nonindexed geometry; the builder will sort them
|
||||
// out (although each polygon must be either entirely indexed or
|
||||
// entirely nonindexed). To create indexed geometry, use a
|
||||
// BuilderPrimI object, and assign to it a number of BuilderVertexI
|
||||
// vertices. The coordinate values you will assign are ushort
|
||||
// array index numbers. Store the array pointers these refer to in
|
||||
// the BuilderBucket, via set_coords(), set_normals(), etc.
|
||||
//
|
||||
// * The builder is to a certain extent scene-graph aware. In the
|
||||
// normal usage, you give it a bunch of polygons which are all
|
||||
// lumped together, and when you call build() it allocates and
|
||||
// returns a GeomNode which has all of your geometry in it.
|
||||
// However, you can also ask it to distribute the geometry
|
||||
// throughout a pre-existing scene graph. To do this, assign the
|
||||
// _node pointer of your BuilderBucket to point to the node each
|
||||
// polygon belongs under, as you create the polygons. Now when you
|
||||
// call build(), the builder will create all the polygons under the
|
||||
// nodes you indicated, creating new GeomNodes whenever necessary.
|
||||
// The advantage to this method is that you don't have to process
|
||||
// your polygons in scene-graph order; the builder can sort them
|
||||
// out for you. Another advantage is it allows the builder to set
|
||||
// up the state for you, see the next point:
|
||||
//
|
||||
// * It is only when you are taking advantage of the scene-graph
|
||||
// awareness of the builder that the builder can assign the state
|
||||
// transitions (like texturing, etc.) you specify to the geometry
|
||||
// it builds. This is because the state transitions are stored on
|
||||
// the arcs of the scene graph, and in non-scene graph mode there
|
||||
// are no arcs!
|
||||
//
|
||||
// * You can fine-tune the mesher behavior via a number of parameters
|
||||
// on the BuilderBucket. Look in builderProperties.h for these
|
||||
// parameters (BuilderBucket inherits from BuilderProperties).
|
||||
// This is also where you turn the mesher off if you don't want it.
|
||||
//
|
||||
// * You can set global properties on all buckets easily either by
|
||||
// creating your own default BuilderBucket that you use to
|
||||
// initialize each individual BuilderBucket you create, or by
|
||||
// changing the parameters stored in the bucket pointed to by
|
||||
// BuilderBucket::get_default_bucket(), which is what is used to
|
||||
// initialize any BuilderBucket created with a default constructor.
|
||||
// It is suggested that the get_default_bucket() pointer be used to
|
||||
// define global defaults at applications start-up, while a local
|
||||
// default BuilderBucket should be used for local defaults.
|
||||
//
|
||||
// * You can also control the binning behavior, if you have some
|
||||
// particular user-specific parameters you want your geometry to be
|
||||
// grouped on. To do this, subclass from BuilderBucket and
|
||||
// redefine the comparison operator (it's a virtual function), as
|
||||
// well as the make_copy() function.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#include "pandabase.h"
|
||||
|
||||
#include "builderAttrib.h"
|
||||
#include "builderBucketNode.h"
|
||||
|
||||
#include "pointerTo.h"
|
||||
|
||||
#include "pset.h"
|
||||
|
||||
|
||||
class GeomNode;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : Builder
|
||||
// Description : The main driver class to the builder package. See
|
||||
// the comments above.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_PANDAEGG Builder {
|
||||
public:
|
||||
Builder();
|
||||
~Builder();
|
||||
|
||||
INLINE bool add_prim(const BuilderBucket &bucket,
|
||||
const BuilderPrim &prim);
|
||||
INLINE bool add_prim(const BuilderBucket &bucket,
|
||||
const BuilderPrimI &prim);
|
||||
INLINE bool add_prim_nonindexed(const BuilderBucket &bucket,
|
||||
const BuilderPrimI &prim);
|
||||
|
||||
GeomNode *build(const string &default_name = "");
|
||||
|
||||
protected:
|
||||
void add_bucket(const BuilderBucket &bucket);
|
||||
|
||||
typedef pset<BuilderBucketNode> Buckets;
|
||||
|
||||
Buckets _buckets;
|
||||
Buckets::iterator _bi;
|
||||
};
|
||||
|
||||
#include "builder.I"
|
||||
|
||||
#endif
|
||||
|
|
@ -1,82 +0,0 @@
|
|||
// Filename: builderAttrib.I
|
||||
// Created by: drose (22Jan99)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderAttrib::set_normal_value
|
||||
// Access: Public
|
||||
// Description: Reassigns the normal, without knowing whether the
|
||||
// attribute is indexed or nonindexed. A nonindexed
|
||||
// attribute will look up the index in the array and
|
||||
// store the resulting value, while an indexed attribute
|
||||
// will just store the index number (which assumes the
|
||||
// array is the same one it's indexing on).
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void BuilderAttrib::
|
||||
set_normal_value(const BuilderN *array, ushort index) {
|
||||
set_normal(array[index]);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderAttrib::set_color_value
|
||||
// Access: Public
|
||||
// Description: Reassigns the color, without knowing whether the
|
||||
// attribute is indexed or nonindexed. A nonindexed
|
||||
// attribute will look up the index in the array and
|
||||
// store the resulting value, while an indexed attribute
|
||||
// will just store the index number (which assumes the
|
||||
// array is the same one it's indexing on).
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void BuilderAttrib::
|
||||
set_color_value(const BuilderC *array, ushort index) {
|
||||
set_color(array[index]);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderAttribI::set_normal_value
|
||||
// Access: Public
|
||||
// Description: Reassigns the normal, without knowing whether the
|
||||
// attribute is indexed or nonindexed. A nonindexed
|
||||
// attribute will look up the index in the array and
|
||||
// store the resulting value, while an indexed attribute
|
||||
// will just store the index number (which assumes the
|
||||
// array is the same one it's indexing on).
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void BuilderAttribI::
|
||||
set_normal_value(const BuilderN *, ushort index) {
|
||||
set_normal(index);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderAttribI::set_color_value
|
||||
// Access: Public
|
||||
// Description: Reassigns the color, without knowing whether the
|
||||
// attribute is indexed or nonindexed. A nonindexed
|
||||
// attribute will look up the index in the array and
|
||||
// store the resulting value, while an indexed attribute
|
||||
// will just store the index number (which assumes the
|
||||
// array is the same one it's indexing on).
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void BuilderAttribI::
|
||||
set_color_value(const BuilderC *, ushort index) {
|
||||
set_color(index);
|
||||
}
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
// Filename: builderAttrib.cxx
|
||||
// Created by: drose (11May00)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "builderAttrib.h"
|
||||
|
||||
// Tell GCC that we'll take care of the instantiation explicitly here.
|
||||
#ifdef __GNUC__
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
// Filename: builderAttrib.h
|
||||
// Created by: drose (22Jan99)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef BUILDERATTRIB_H
|
||||
#define BUILDERATTRIB_H
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// BuilderAttrib, BuilderAttribI
|
||||
//
|
||||
// This is the parent class of both BuilderVertex and BuilderPrim, and
|
||||
// contains the attribute values which may be set on either of them:
|
||||
// specifically, normal, color, and pixel size. (Pixel size is the
|
||||
// thickness of the lines, for a polygon or a line, or the size of the
|
||||
// point, in pixels.)
|
||||
//
|
||||
// Like BuilderPrim and BuilderVertex, the two classes BuilderAttrib
|
||||
// and BuilderAttribI are actually both instantiations of the same
|
||||
// template class, BuilderAttribTempl.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "pandabase.h"
|
||||
|
||||
#include "builderAttribTempl.h"
|
||||
|
||||
#define BUILDERATTRIBTEMPL_BUILDERV BuilderAttribTempl<BuilderV, BuilderN, BuilderTC, BuilderC>
|
||||
EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, BUILDERATTRIBTEMPL_BUILDERV);
|
||||
#define BUILDERATTRIBTEMPL_USHORT BuilderAttribTempl<ushort, ushort, ushort, ushort>
|
||||
EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, BUILDERATTRIBTEMPL_USHORT);
|
||||
|
||||
class EXPCL_PANDAEGG BuilderAttrib
|
||||
: public BuilderAttribTempl<BuilderV, BuilderN, BuilderTC, BuilderC> {
|
||||
public:
|
||||
BuilderAttrib() {}
|
||||
|
||||
INLINE void set_normal_value(const BuilderN *array, ushort index);
|
||||
INLINE void set_color_value(const BuilderC *array, ushort index);
|
||||
};
|
||||
|
||||
class EXPCL_PANDAEGG BuilderAttribI
|
||||
: public BuilderAttribTempl<ushort, ushort, ushort, ushort> {
|
||||
public:
|
||||
BuilderAttribI() {}
|
||||
|
||||
INLINE void set_normal_value(const BuilderN *array, ushort index);
|
||||
INLINE void set_color_value(const BuilderC *array, ushort index);
|
||||
};
|
||||
|
||||
#include "builderAttrib.I"
|
||||
|
||||
// Tell GCC that we'll take care of the instantiation explicitly here.
|
||||
#ifdef __GNUC__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,323 +0,0 @@
|
|||
// Filename: builderAttribTempl.I
|
||||
// Created by: drose (17Sep97)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderAttribTempl::Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE BuilderAttribTempl<VT, NT, TT, CT>::
|
||||
BuilderAttribTempl() {
|
||||
_flags = 0;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderAttribTempl::Copy constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE BuilderAttribTempl<VT, NT, TT, CT>::
|
||||
BuilderAttribTempl(const BuilderAttribTempl ©) {
|
||||
(*this) = copy;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderAttribTempl::Copy assignment operator
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE BuilderAttribTempl<VT, NT, TT, CT> &BuilderAttribTempl<VT, NT, TT, CT>::
|
||||
operator = (const BuilderAttribTempl<VT, NT, TT, CT> ©) {
|
||||
_normal = copy._normal;
|
||||
_color = copy._color;
|
||||
_pixel_size = copy._pixel_size;
|
||||
_flags = copy._flags;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderAttribTempl::clear
|
||||
// Access: Public
|
||||
// Description: Resets the attribute flags to their original, empty
|
||||
// state--where no attributes have been applied.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE BuilderAttribTempl<VT, NT, TT, CT> &BuilderAttribTempl<VT, NT, TT, CT>::
|
||||
clear() {
|
||||
_flags = 0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderAttribTempl::has_normal
|
||||
// Access: Public
|
||||
// Description: Returns true if the attribute has a normal.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE bool BuilderAttribTempl<VT, NT, TT, CT>::
|
||||
has_normal() const {
|
||||
return (_flags & BAF_normal)!=0;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderAttribTempl::get_normal
|
||||
// Access: Public
|
||||
// Description: Returns the attribute's normal. It is an error to
|
||||
// call this without first verifying that has_normal() is
|
||||
// true.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE TYPENAME BuilderAttribTempl<VT, NT, TT, CT>::NType BuilderAttribTempl<VT, NT, TT, CT>::
|
||||
get_normal() const {
|
||||
nassertr(has_normal(), _normal);
|
||||
return _normal;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderAttribTempl::set_normal
|
||||
// Access: Public
|
||||
// Description: Resets the attribute's normal.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE BuilderAttribTempl<VT, NT, TT, CT> &BuilderAttribTempl<VT, NT, TT, CT>::
|
||||
set_normal(const NType &n) {
|
||||
_flags |= BAF_normal;
|
||||
_normal = n;
|
||||
return *this;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderAttribTempl::clear_normal
|
||||
// Access: Public
|
||||
// Description: Removes the attribute's normal.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE BuilderAttribTempl<VT, NT, TT, CT> &BuilderAttribTempl<VT, NT, TT, CT>::
|
||||
clear_normal() {
|
||||
_flags &= ~BAF_normal;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderAttribTempl::has_color
|
||||
// Access: Public
|
||||
// Description: Returns true if the attribute has a color.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE bool BuilderAttribTempl<VT, NT, TT, CT>::
|
||||
has_color() const {
|
||||
return (_flags & BAF_color)!=0;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderAttribTempl::get_color
|
||||
// Access: Public
|
||||
// Description: Returns the attribute's color. It is an error to
|
||||
// call this without first verifying that has_color() is
|
||||
// true.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE TYPENAME BuilderAttribTempl<VT, NT, TT, CT>::CType BuilderAttribTempl<VT, NT, TT, CT>::
|
||||
get_color() const {
|
||||
nassertr(has_color(), _color);
|
||||
return _color;
|
||||
}
|
||||
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderAttribTempl::set_color
|
||||
// Access: Public
|
||||
// Description: Resets the attribute's color.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE BuilderAttribTempl<VT, NT, TT, CT> &BuilderAttribTempl<VT, NT, TT, CT>::
|
||||
set_color(const CType &c) {
|
||||
_flags |= BAF_color;
|
||||
_color = c;
|
||||
return *this;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderAttribTempl::clear_color
|
||||
// Access: Public
|
||||
// Description: Removes the attribute's color.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE BuilderAttribTempl<VT, NT, TT, CT> &BuilderAttribTempl<VT, NT, TT, CT>::
|
||||
clear_color() {
|
||||
_flags &= ~BAF_color;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderAttribTempl::has_pixel_size
|
||||
// Access: Public
|
||||
// Description: Returns true if the attribute has a pixel_size.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE bool BuilderAttribTempl<VT, NT, TT, CT>::
|
||||
has_pixel_size() const {
|
||||
return (_flags & BAF_pixel_size)!=0;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderAttribTempl::get_pixel_size
|
||||
// Access: Public
|
||||
// Description: Returns the attribute's pixel_size. It is an error to
|
||||
// call this without first verifying that has_pixel_size() is
|
||||
// true.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE float BuilderAttribTempl<VT, NT, TT, CT>::
|
||||
get_pixel_size() const {
|
||||
nassertr(has_pixel_size(), _pixel_size);
|
||||
return _pixel_size;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderAttribTempl::set_pixel_size
|
||||
// Access: Public
|
||||
// Description: Resets the attribute's pixel_size.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE BuilderAttribTempl<VT, NT, TT, CT> &BuilderAttribTempl<VT, NT, TT, CT>::
|
||||
set_pixel_size(float s) {
|
||||
_flags |= BAF_pixel_size;
|
||||
_pixel_size = s;
|
||||
return *this;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderAttribTempl::clear_pixel_size
|
||||
// Access: Public
|
||||
// Description: Removes the attribute's pixel_size.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE BuilderAttribTempl<VT, NT, TT, CT> &BuilderAttribTempl<VT, NT, TT, CT>::
|
||||
clear_pixel_size() {
|
||||
_flags &= ~BAF_pixel_size;
|
||||
return *this;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderAttribTempl::operator ==
|
||||
// Access: Public
|
||||
// Description: Assigns an ordering to the vertices. This is used by
|
||||
// the Mesher to group identical vertices. This assumes
|
||||
// that all vertices in the locus of consideration will
|
||||
// share the same state: with or without normals,
|
||||
// texcoords, etc.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE bool BuilderAttribTempl<VT, NT, TT, CT>::
|
||||
operator == (const BuilderAttribTempl<VT, NT, TT, CT> &other) const {
|
||||
return compare_to(other) == 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderAttribTempl::operator !=
|
||||
// Access: Public
|
||||
// Description: Assigns an ordering to the vertices. This is used by
|
||||
// the Mesher to group identical vertices. This assumes
|
||||
// that all vertices in the locus of consideration will
|
||||
// share the same state: with or without normals,
|
||||
// texcoords, etc.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE bool BuilderAttribTempl<VT, NT, TT, CT>::
|
||||
operator != (const BuilderAttribTempl<VT, NT, TT, CT> &other) const {
|
||||
return !operator == (other);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderAttribTempl::operator <
|
||||
// Access: Public
|
||||
// Description: Assigns an ordering to the vertices. This is used by
|
||||
// the Mesher to group identical vertices. This assumes
|
||||
// that all vertices in the locus of consideration will
|
||||
// share the same state: with or without normals,
|
||||
// texcoords, etc.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE bool BuilderAttribTempl<VT, NT, TT, CT>::
|
||||
operator < (const BuilderAttribTempl<VT, NT, TT, CT> &other) const {
|
||||
return compare_to(other) < 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderAttribTempl::compare_to
|
||||
// Access: Public
|
||||
// Description: Returns a number less than zero if this object sorts
|
||||
// before the indicated object, greater than zero if it
|
||||
// sorts after, and zero if the objects are equivalent.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
int BuilderAttribTempl<VT, NT, TT, CT>::
|
||||
compare_to(const BuilderAttribTempl<VT, NT, TT, CT> &other) const {
|
||||
if (has_normal()) {
|
||||
int normal_compare = builder_compare(_normal, other._normal);
|
||||
if (normal_compare != 0) {
|
||||
return normal_compare;
|
||||
}
|
||||
}
|
||||
|
||||
if (has_color()) {
|
||||
int color_compare = builder_compare(_color, other._color);
|
||||
if (color_compare != 0) {
|
||||
return color_compare;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderAttribTempl::output
|
||||
// Access: Public
|
||||
// Description: Formats the attribs for output in some sensible way.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
ostream &BuilderAttribTempl<VT, NT, TT, CT>::
|
||||
output(ostream &out) const {
|
||||
if (this!=NULL) {
|
||||
if (has_normal()) {
|
||||
out << " normal " << get_normal();
|
||||
}
|
||||
|
||||
if (has_color()) {
|
||||
out << " color " << get_color();
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
|
@ -1,88 +0,0 @@
|
|||
// Filename: builderAttribTempl.h
|
||||
// Created by: drose (17Sep97)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
#ifndef BUILDERATTRIBTEMPL_H
|
||||
#define BUILDERATTRIBTEMPL_H
|
||||
|
||||
#include "pandabase.h"
|
||||
|
||||
#include "builderTypes.h"
|
||||
|
||||
#include "pvector.h"
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : BuilderAttribTempl
|
||||
// Description : The main body of BuilderAttrib and BuilderAttribI,
|
||||
// and the base class for BuilderVertexTempl and
|
||||
// BuilderPrimTempl, this class defines the attributes
|
||||
// that may be specified for either vertices or
|
||||
// primitives.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
class BuilderAttribTempl {
|
||||
public:
|
||||
typedef VT VType;
|
||||
typedef NT NType;
|
||||
typedef TT TType;
|
||||
typedef CT CType;
|
||||
|
||||
INLINE BuilderAttribTempl();
|
||||
INLINE BuilderAttribTempl(const BuilderAttribTempl ©);
|
||||
INLINE BuilderAttribTempl &operator = (const BuilderAttribTempl ©);
|
||||
|
||||
INLINE BuilderAttribTempl &clear();
|
||||
|
||||
INLINE bool has_normal() const;
|
||||
INLINE NType get_normal() const;
|
||||
INLINE BuilderAttribTempl &set_normal(const NType &n);
|
||||
INLINE BuilderAttribTempl &clear_normal();
|
||||
|
||||
INLINE bool has_color() const;
|
||||
INLINE CType get_color() const;
|
||||
INLINE BuilderAttribTempl &set_color(const CType &c);
|
||||
INLINE BuilderAttribTempl &clear_color();
|
||||
|
||||
INLINE bool has_pixel_size() const;
|
||||
INLINE float get_pixel_size() const;
|
||||
INLINE BuilderAttribTempl &set_pixel_size(float s);
|
||||
INLINE BuilderAttribTempl &clear_pixel_size();
|
||||
|
||||
INLINE bool operator == (const BuilderAttribTempl &other) const;
|
||||
INLINE bool operator != (const BuilderAttribTempl &other) const;
|
||||
INLINE bool operator < (const BuilderAttribTempl &other) const;
|
||||
int compare_to(const BuilderAttribTempl &other) const;
|
||||
|
||||
ostream &output(ostream &out) const;
|
||||
|
||||
protected:
|
||||
NType _normal;
|
||||
CType _color;
|
||||
float _pixel_size;
|
||||
int _flags;
|
||||
};
|
||||
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE ostream &operator << (ostream &out,
|
||||
const BuilderAttribTempl<VT, NT, TT, CT> &attrib) {
|
||||
return attrib.output(out);
|
||||
}
|
||||
|
||||
#include "builderAttribTempl.I"
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -1,134 +0,0 @@
|
|||
// Filename: builderBucket.I
|
||||
// Created by: drose (09Sep97)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderBucket::set_coords
|
||||
// Access: Public
|
||||
// Description: Sets the array that will be used to define the
|
||||
// vertices for any indexed geometry that is associated
|
||||
// with this bucket.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void BuilderBucket::
|
||||
set_coords(const PTA_Vertexf &coords) {
|
||||
_coords = coords;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderBucket::get_coords
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE PTA_Vertexf BuilderBucket::
|
||||
get_coords() const {
|
||||
return _coords;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderBucket::set_normals
|
||||
// Access: Public
|
||||
// Description: Sets the array that will be used to define the
|
||||
// normals for any indexed geometry that is associated
|
||||
// with this bucket.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void BuilderBucket::
|
||||
set_normals(const PTA_Normalf &normals) {
|
||||
_normals = normals;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderBucket::get_normals
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE PTA_Normalf BuilderBucket::
|
||||
get_normals() const {
|
||||
return _normals;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderBucket::set_texcoords
|
||||
// Access: Public
|
||||
// Description: Sets the array that will be used to define the
|
||||
// texture coordinates for any indexed geometry that is
|
||||
// associated with this bucket.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void BuilderBucket::
|
||||
set_texcoords(const InternalName *name, const PTA_TexCoordf &texcoords) {
|
||||
_texcoords[name] = texcoords;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderBucket::get_texcoords
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE PTA_TexCoordf BuilderBucket::
|
||||
get_texcoords(const InternalName *name) const {
|
||||
TexCoords::const_iterator ti = _texcoords.find(name);
|
||||
if (ti != _texcoords.end()) {
|
||||
return (*ti).second;
|
||||
}
|
||||
return PTA_TexCoordf();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderBucket::set_colors
|
||||
// Access: Public
|
||||
// Description: Sets the array that will be used to define the
|
||||
// colors for any indexed geometry that is associated
|
||||
// with this bucket.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void BuilderBucket::
|
||||
set_colors(const PTA_Colorf &colors) {
|
||||
_colors = colors;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderBucket::get_colors
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE PTA_Colorf BuilderBucket::
|
||||
get_colors() const {
|
||||
return _colors;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderBucket::get_default_bucket
|
||||
// Access: Public, Static
|
||||
// Description: Returns a pointer to the BuilderBucket that is used
|
||||
// to initialize any BuilderBuckets created with a
|
||||
// default constructor. This is just a convenient way
|
||||
// to set some global parameters.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE BuilderBucket *BuilderBucket::
|
||||
get_default_bucket() {
|
||||
if (_default_bucket==NULL) {
|
||||
_default_bucket = new BuilderBucket(true);
|
||||
}
|
||||
return _default_bucket;
|
||||
}
|
||||
|
|
@ -1,285 +0,0 @@
|
|||
// Filename: builderBucket.cxx
|
||||
// Created by: drose (10Sep97)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#include "builderAttrib.h"
|
||||
#include "builderBucket.h"
|
||||
#include "builderFuncs.h"
|
||||
#include "builderMisc.h"
|
||||
#include "geomNode.h"
|
||||
|
||||
|
||||
BuilderBucket *BuilderBucket::_default_bucket = NULL;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderBucket::Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
BuilderBucket::
|
||||
BuilderBucket() {
|
||||
_node = NULL;
|
||||
(*this) = (*get_default_bucket());
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderBucket::Copy constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
BuilderBucket::
|
||||
BuilderBucket(const BuilderBucket ©) {
|
||||
(*this) = copy;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderBucket::Copy assignment operator
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
BuilderBucket &BuilderBucket::
|
||||
operator = (const BuilderBucket ©) {
|
||||
((BuilderProperties &)*this) = (BuilderProperties &)copy;
|
||||
|
||||
set_name(copy.get_name());
|
||||
set_coords(copy._coords);
|
||||
set_normals(copy._normals);
|
||||
set_colors(copy._colors);
|
||||
|
||||
_texcoords = copy._texcoords;
|
||||
|
||||
_node = copy._node;
|
||||
_hidden = copy._hidden;
|
||||
_state = copy._state;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderBucket::Destructor
|
||||
// Access: Public, Virtual
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
BuilderBucket::
|
||||
~BuilderBucket() {
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderBucket::make_copy
|
||||
// Access: Public, Virtual
|
||||
// Description: Allocates and returns a new copy of this object. If
|
||||
// you are subclassing from BuilderBucket, you must
|
||||
// redefine this to return an instance of your new
|
||||
// subclass, because the Builder will call this function
|
||||
// to get its own copy.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
BuilderBucket *BuilderBucket::
|
||||
make_copy() const {
|
||||
return new BuilderBucket(*this);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderBucket::make_geom_node
|
||||
// Access: Public, Virtual
|
||||
// Description: Called by the builder when it is time to create a new
|
||||
// GeomNode. This function should allocate and return a
|
||||
// new GeomNode suitable for adding geometry to. You
|
||||
// may redefine it to return a subclass of GeomNode, or
|
||||
// to do some initialization to the node.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
GeomNode *BuilderBucket::
|
||||
make_geom_node() {
|
||||
return new GeomNode("");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderBucket::done_geom
|
||||
// Access: Public, Virtual
|
||||
// Description: Called after all the geometry has been added to the
|
||||
// Geom. This is just a hook for the user to redefine
|
||||
// to do any post-processing that may be desired on the
|
||||
// geometry. It may deallocate it and return a new
|
||||
// copy. If it returns NULL, the geom is discarded.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
Geom *BuilderBucket::
|
||||
done_geom(Geom *geom) {
|
||||
return geom;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderBucket::add_attrib
|
||||
// Access: Public
|
||||
// Description: A convenience function to add the indicated render
|
||||
// attribute to the bucket's state.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void BuilderBucket::
|
||||
add_attrib(const RenderAttrib *attrib) {
|
||||
_state = _state->add_attrib(attrib);
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderBucket::Ordering operator
|
||||
// Access: Public, Virtual
|
||||
// Description: Defines an arbitrary ordering among different
|
||||
// buckets, and groups identical buckets together.
|
||||
// (Buckets a and b are identical if !(a < b) and !(b <
|
||||
// a).)
|
||||
//
|
||||
// The actual order between different buckets is
|
||||
// arbitrary and largely irrelevant, so long as it is
|
||||
// consistent. That is, if (a < b) and (b < c), it must
|
||||
// also be true that (a < c). Also, if (a < b), it
|
||||
// cannot be true that (b < a).
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool BuilderBucket::
|
||||
operator < (const BuilderBucket &other) const {
|
||||
if (get_name() != other.get_name()) {
|
||||
return get_name() < other.get_name();
|
||||
}
|
||||
|
||||
if (_node != other._node) {
|
||||
return _node < other._node;
|
||||
}
|
||||
|
||||
if (_hidden != other._hidden) {
|
||||
return _hidden < other._hidden;
|
||||
}
|
||||
|
||||
if (_coords != other._coords)
|
||||
return _coords < other._coords;
|
||||
if (_normals != other._normals)
|
||||
return _normals < other._normals;
|
||||
if (_colors != other._colors)
|
||||
return _colors < other._colors;
|
||||
|
||||
TexCoords::const_iterator ai, bi;
|
||||
ai = _texcoords.begin();
|
||||
bi = other._texcoords.begin();
|
||||
while (ai != _texcoords.end() && bi != other._texcoords.end()) {
|
||||
if ((*ai).first < (*bi).first) {
|
||||
return true;
|
||||
} else if ((*bi).first < (*ai).first) {
|
||||
return false;
|
||||
} else {
|
||||
if ((*ai).second != (*bi).second) {
|
||||
return (*ai).second < (*bi).second;
|
||||
}
|
||||
}
|
||||
|
||||
++ai;
|
||||
++bi;
|
||||
}
|
||||
|
||||
if (bi != other._texcoords.end()) {
|
||||
return true;
|
||||
}
|
||||
if (ai != _texcoords.end()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_state != other._state) {
|
||||
return _state < other._state;
|
||||
}
|
||||
|
||||
return BuilderProperties::operator < (other);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderBucket::output
|
||||
// Access: Public, Virtual
|
||||
// Description: Formats the bucket for output in some sensible way.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void BuilderBucket::
|
||||
output(ostream &out) const {
|
||||
out << "Bucket \"" << get_name() << "\"";
|
||||
|
||||
if (_node != (PandaNode *)NULL) {
|
||||
out << " attached to " << *_node << "\n";
|
||||
}
|
||||
out << "\n";
|
||||
|
||||
if (_hidden) {
|
||||
out << "_hidden\n";
|
||||
}
|
||||
|
||||
if (_coords != (Vertexf *)NULL) {
|
||||
out << "_coords = " << (void *)_coords << "\n";
|
||||
}
|
||||
|
||||
if (_normals != (Normalf *)NULL) {
|
||||
out << "_normals = " << (void *)_normals << "\n";
|
||||
}
|
||||
|
||||
TexCoords::const_iterator ti;
|
||||
for (ti = _texcoords.begin(); ti != _texcoords.end(); ++ti) {
|
||||
out << "_texcoords[\"" << (*ti).first->get_name() << "\"] = "
|
||||
<< (void *)(*ti).second << "\n";
|
||||
}
|
||||
|
||||
if (_colors != (Colorf *)NULL) {
|
||||
out << "_colors = " << (void *)_colors << "\n";
|
||||
}
|
||||
|
||||
if (!_state->is_empty()) {
|
||||
out << *_state << "\n";
|
||||
}
|
||||
|
||||
BuilderProperties::output(out);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderBucket::private Constructor
|
||||
// Access: Private
|
||||
// Description: This special constructor is used only to initialize
|
||||
// the _default_bucket pointer. It sets up the initial
|
||||
// defaults. The normal constructor copies from this
|
||||
// instance.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
BuilderBucket::
|
||||
BuilderBucket(int) {
|
||||
_node = NULL;
|
||||
_hidden = false;
|
||||
|
||||
// From BuilderProperties
|
||||
_mesh = true;
|
||||
_retesselate_coplanar = true;
|
||||
_show_tstrips = false;
|
||||
_show_qsheets = false;
|
||||
_show_quads = false;
|
||||
_show_normals = false;
|
||||
_normal_color.set(1.0, 0.0, 0.0, 1.0);
|
||||
_normal_scale = 1.0;
|
||||
_subdivide_polys = true;
|
||||
_coplanar_threshold = 0.01;
|
||||
|
||||
_unroll_fans = true;
|
||||
_consider_fans = true;
|
||||
_max_tfan_angle = 40.0;
|
||||
_min_tfan_tris = 0;
|
||||
|
||||
_state = RenderState::make_empty();
|
||||
}
|
||||
|
|
@ -1,116 +0,0 @@
|
|||
// Filename: builderBucket.h
|
||||
// Created by: drose (09Sep97)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef BUILDERBUCKET_H
|
||||
#define BUILDERBUCKET_H
|
||||
|
||||
#include "pandabase.h"
|
||||
|
||||
#include "builderProperties.h"
|
||||
|
||||
#include "namable.h"
|
||||
#include "pointerToArray.h"
|
||||
#include "luse.h"
|
||||
#include "pta_Vertexf.h"
|
||||
#include "pta_Normalf.h"
|
||||
#include "pta_Colorf.h"
|
||||
#include "pta_TexCoordf.h"
|
||||
#include "internalName.h"
|
||||
#include "renderState.h"
|
||||
|
||||
#include "stdlib.h"
|
||||
|
||||
class Geom;
|
||||
class PandaNode;
|
||||
class GeomNode;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : BuilderBucket
|
||||
// Description : The main grouping tool for BuilderPrims. See the
|
||||
// comments at the beginning of builder.h.
|
||||
//
|
||||
// As each primitive is added to the builder, it is
|
||||
// associated with a bucket. The bucket stores the
|
||||
// scene-graph properties of the primitive, and is used
|
||||
// to identify primitives that have the same properties
|
||||
// and thus may be joined into a common triangle strip.
|
||||
//
|
||||
// This grouping is done via the ordering operator, <,
|
||||
// which defines an arbitrary ordering for buckets and
|
||||
// identifies those buckets which are equivalent to each
|
||||
// other. By subclassing off of BuilderBucket and
|
||||
// redefining this operator, you can change the grouping
|
||||
// behavior to suit your needs, if necessary.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_PANDAEGG BuilderBucket : public BuilderProperties, public Namable {
|
||||
public:
|
||||
BuilderBucket();
|
||||
BuilderBucket(const BuilderBucket ©);
|
||||
BuilderBucket &operator = (const BuilderBucket ©);
|
||||
virtual ~BuilderBucket();
|
||||
|
||||
virtual BuilderBucket *make_copy() const;
|
||||
virtual GeomNode *make_geom_node();
|
||||
virtual Geom *done_geom(Geom *geom);
|
||||
void add_attrib(const RenderAttrib *attrib);
|
||||
|
||||
virtual bool operator < (const BuilderBucket &other) const;
|
||||
|
||||
INLINE void set_coords(const PTA_Vertexf &coords);
|
||||
INLINE PTA_Vertexf get_coords() const;
|
||||
|
||||
INLINE void set_normals(const PTA_Normalf &normals);
|
||||
INLINE PTA_Normalf get_normals() const;
|
||||
|
||||
INLINE void set_texcoords(const InternalName *name, const PTA_TexCoordf &texcoords);
|
||||
INLINE PTA_TexCoordf get_texcoords(const InternalName *name) const;
|
||||
|
||||
INLINE void set_colors(const PTA_Colorf &colors);
|
||||
INLINE PTA_Colorf get_colors() const;
|
||||
|
||||
INLINE static BuilderBucket *get_default_bucket();
|
||||
|
||||
virtual void output(ostream &out) const;
|
||||
|
||||
PandaNode *_node;
|
||||
CPT(RenderState) _state;
|
||||
bool _hidden;
|
||||
|
||||
protected:
|
||||
PTA_Vertexf _coords;
|
||||
PTA_Normalf _normals;
|
||||
PTA_Colorf _colors;
|
||||
|
||||
typedef pmap<CPT(InternalName), PTA_TexCoordf> TexCoords;
|
||||
TexCoords _texcoords;
|
||||
|
||||
static BuilderBucket *_default_bucket;
|
||||
|
||||
private:
|
||||
BuilderBucket(int);
|
||||
};
|
||||
|
||||
INLINE ostream &operator << (ostream &out, const BuilderBucket &bucket) {
|
||||
bucket.output(out);
|
||||
return out;
|
||||
}
|
||||
|
||||
#include "builderBucket.I"
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -1,115 +0,0 @@
|
|||
// Filename: builderBucketNode.I
|
||||
// Created by: drose (10Sep97)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderBucketNode::Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE BuilderBucketNode::
|
||||
BuilderBucketNode(BuilderBucket *bucket) : _bucket(bucket) {
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderBucketNode::Copy constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE BuilderBucketNode::
|
||||
BuilderBucketNode(const BuilderBucketNode ©) {
|
||||
(*this) = copy;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderBucketNode::Copy assignment operator
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void BuilderBucketNode::
|
||||
operator = (const BuilderBucketNode ©) {
|
||||
_bucket = copy._bucket;
|
||||
_prims = copy._prims;
|
||||
_iprims = copy._iprims;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderBucketNode::add_prim_nonindexed
|
||||
// Access: Public
|
||||
// Description: Adds the indicated indexed primitive to the bucket as
|
||||
// if it were nonindexed, and returns true if the
|
||||
// primitive was valid. Intended to be called from
|
||||
// Builder::add_prim_nonindexed().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool BuilderBucketNode::
|
||||
add_prim_nonindexed(const BuilderPrimI &prim) {
|
||||
BuilderPrim nonindexed;
|
||||
nonindexed.nonindexed_copy(prim, *_bucket);
|
||||
return add_prim(nonindexed);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderBucketNode::get_bucket
|
||||
// Access: Public
|
||||
// Description: Returns the BuilderBucket object associated with this
|
||||
// node.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE BuilderBucket *BuilderBucketNode::
|
||||
get_bucket() const {
|
||||
return _bucket;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderBucketNode::Ordering operator
|
||||
// Access: Public
|
||||
// Description: Returns true if this bucket precedes the indicated
|
||||
// one in ordering. This function is used by the STL
|
||||
// set in the Builder object to sort buckets into order,
|
||||
// and to collect similar buckets together.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool BuilderBucketNode::
|
||||
operator < (const BuilderBucketNode &other) const {
|
||||
return (*_bucket) < (*other._bucket);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderBucketNode::Equivalence operator
|
||||
// Access: Public
|
||||
// Description: Returns true if the two buckets are equivalent, based
|
||||
// on the ordering operator, above.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool BuilderBucketNode::
|
||||
operator == (const BuilderBucketNode &other) const {
|
||||
return !((*_bucket) < (*other._bucket) ||
|
||||
(*other._bucket) < (*_bucket));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderBucketNode::Nonequivalence operator
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool BuilderBucketNode::
|
||||
operator != (const BuilderBucketNode &other) const {
|
||||
return !operator == (other);
|
||||
}
|
||||
|
|
@ -1,102 +0,0 @@
|
|||
// Filename: builderBucketNode.cxx
|
||||
// Created by: drose (10Sep97)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "builderFuncs.h"
|
||||
#include "builderBucketNode.h"
|
||||
|
||||
#include "geomNode.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderBucketNode::add_prim
|
||||
// Access: Public
|
||||
// Description: Adds the indicated indexed primitive to the
|
||||
// bucket, and returns true if the primitive was valid.
|
||||
// Intended to be called from Builder::add_prim().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool BuilderBucketNode::
|
||||
add_prim(BuilderPrim prim) {
|
||||
prim.flatten_vertex_properties();
|
||||
bool result = expand(prim, *_bucket, inserter(_prims, _prims.begin()));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderBucketNode::add_prim
|
||||
// Access: Public
|
||||
// Description: Adds the indicated nonindexed primitive to the
|
||||
// bucket, and returns true if the primitive was valid.
|
||||
// Intended to be called from Builder::add_prim().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool BuilderBucketNode::
|
||||
add_prim(const BuilderPrimI &prim) {
|
||||
bool result = expand(prim, *_bucket, inserter(_iprims, _iprims.begin()));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderBucketNode::build
|
||||
// Access: Public
|
||||
// Description: Builds all the geometry assigned to this particular
|
||||
// bucket, and assigns it to the indicated GeomNode.
|
||||
// Returns the number of Geoms created.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
int BuilderBucketNode::
|
||||
build(GeomNode *geom_node) const {
|
||||
int count = 0;
|
||||
|
||||
{
|
||||
// First, the nonindexed.
|
||||
Prims::const_iterator pi, last_pi;
|
||||
last_pi = _prims.begin();
|
||||
|
||||
for (pi = _prims.begin();
|
||||
pi != _prims.end();
|
||||
++pi) {
|
||||
if ((*last_pi) < (*pi)) {
|
||||
count += mesh_and_build(last_pi, pi, *_bucket, geom_node,
|
||||
(BuilderPrim *)0);
|
||||
last_pi = pi;
|
||||
}
|
||||
}
|
||||
count += mesh_and_build(last_pi, pi, *_bucket, geom_node,
|
||||
(BuilderPrim *)0);
|
||||
}
|
||||
|
||||
{
|
||||
// Then, the indexed.
|
||||
IPrims::const_iterator pi, last_pi;
|
||||
last_pi = _iprims.begin();
|
||||
|
||||
for (pi = _iprims.begin();
|
||||
pi != _iprims.end();
|
||||
++pi) {
|
||||
if ((*last_pi) < (*pi)) {
|
||||
count += mesh_and_build(last_pi, pi, *_bucket, geom_node,
|
||||
(BuilderPrimI *)0);
|
||||
last_pi = pi;
|
||||
}
|
||||
}
|
||||
count += mesh_and_build(last_pi, pi, *_bucket, geom_node,
|
||||
(BuilderPrimI *)0);
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
|
@ -1,73 +0,0 @@
|
|||
// Filename: builderBucketNode.h
|
||||
// Created by: drose (10Sep97)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef BUILDERBUCKETNODE_H
|
||||
#define BUILDERBUCKETNODE_H
|
||||
|
||||
#include "pandabase.h"
|
||||
|
||||
#include "builderPrim.h"
|
||||
#include "builderBucket.h"
|
||||
|
||||
#include "pset.h"
|
||||
|
||||
class GeomNode;
|
||||
class GeomNode;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : BuilderBucketNode
|
||||
// Description : This is a wrapper class around BuilderBucket, used by
|
||||
// the Builder class. It stores a pointer to a
|
||||
// BuilderBucket object, as well as lists of the
|
||||
// primitives that have been added to it.
|
||||
//
|
||||
// There are no functions in this class that are
|
||||
// intended to be called directly by user code; instead,
|
||||
// use the interface provided by Builder.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_PANDAEGG BuilderBucketNode {
|
||||
public:
|
||||
INLINE BuilderBucketNode(BuilderBucket *bucket);
|
||||
INLINE BuilderBucketNode(const BuilderBucketNode ©);
|
||||
INLINE void operator = (const BuilderBucketNode ©);
|
||||
|
||||
bool add_prim(BuilderPrim prim);
|
||||
bool add_prim(const BuilderPrimI &prim);
|
||||
INLINE bool add_prim_nonindexed(const BuilderPrimI &prim);
|
||||
|
||||
INLINE BuilderBucket *get_bucket() const;
|
||||
|
||||
INLINE bool operator < (const BuilderBucketNode &other) const;
|
||||
INLINE bool operator == (const BuilderBucketNode &other) const;
|
||||
INLINE bool operator != (const BuilderBucketNode &other) const;
|
||||
|
||||
int build(GeomNode *geom_node) const;
|
||||
|
||||
protected:
|
||||
typedef pmultiset<BuilderPrim, less<BuilderPrim> > Prims;
|
||||
typedef pmultiset<BuilderPrimI, less<BuilderPrimI> > IPrims;
|
||||
|
||||
BuilderBucket *_bucket;
|
||||
Prims _prims;
|
||||
IPrims _iprims;
|
||||
};
|
||||
|
||||
#include "builderBucketNode.I"
|
||||
|
||||
#endif
|
||||
|
|
@ -1,950 +0,0 @@
|
|||
// Filename: builderFuncs.I
|
||||
// Created by: drose (09Sep97)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "builderPrim.h"
|
||||
#include "mesherTempl.h"
|
||||
#include "builderNormalVisualizer.h"
|
||||
#include "config_builder.h"
|
||||
#include "geom.h"
|
||||
#include "geomprimitives.h"
|
||||
#include "geomNode.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
struct DecompVtx {
|
||||
int index;
|
||||
BuilderV coord;
|
||||
struct DecompVtx *next;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: decomp_concave
|
||||
// Description: Decomposes a concave polygon into triangles. Returns
|
||||
// true if successful, false if the polygon is
|
||||
// self-intersecting.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class PrimType, class OutputIterator>
|
||||
static bool
|
||||
decomp_concave(const PrimType &prim, BuilderBucket &bucket,
|
||||
OutputIterator result,
|
||||
int asum, int x, int y) {
|
||||
#define VX(p, c) p->coord[c]
|
||||
|
||||
pvector<PrimType> output_prims;
|
||||
|
||||
DecompVtx *p0, *p1, *p2, *t0, *vert;
|
||||
DecompVtx *m[3];
|
||||
float xmin, xmax, ymin, ymax;
|
||||
int i, init, csum, chek;
|
||||
float a[3], b[3], c[3], s[3];
|
||||
|
||||
int num_verts = prim.get_num_verts();
|
||||
nassertr(num_verts >= 3, false);
|
||||
|
||||
/* Make linked list of verts */
|
||||
vert = (DecompVtx *) alloca(sizeof(DecompVtx));
|
||||
vert->index = 0;
|
||||
vert->coord = prim.get_vertex(0).get_coord_value(bucket);
|
||||
p1 = vert;
|
||||
|
||||
for (i = 1; i < num_verts; i++) {
|
||||
p0 = (DecompVtx *) alloca(sizeof(DecompVtx));
|
||||
p0->index = i;
|
||||
p0->coord = prim.get_vertex(i).get_coord_value(bucket);
|
||||
// There shouldn't be two consecutive identical vertices. If
|
||||
// there are, skip one.
|
||||
if (!(p0->coord == p1->coord)) {
|
||||
p1->next = p0;
|
||||
p1 = p0;
|
||||
}
|
||||
}
|
||||
p1->next = vert;
|
||||
|
||||
p0 = vert;
|
||||
p1 = p0->next;
|
||||
p2 = p1->next;
|
||||
m[0] = p0;
|
||||
m[1] = p1;
|
||||
m[2] = p2;
|
||||
chek = 0;
|
||||
|
||||
while (p0 != p2->next) {
|
||||
/* Polygon is self-intersecting so punt */
|
||||
if (chek &&
|
||||
m[0] == p0 &&
|
||||
m[1] == p1 &&
|
||||
m[2] == p2) {
|
||||
|
||||
// builder_cat.info() << "Could not decompose concave polygon!";
|
||||
return false;
|
||||
}
|
||||
|
||||
chek = 1;
|
||||
|
||||
a[0] = VX(p1, y) - VX(p2, y);
|
||||
b[0] = VX(p2, x) - VX(p1, x);
|
||||
a[2] = VX(p0, y) - VX(p1, y);
|
||||
b[2] = VX(p1, x) - VX(p0, x);
|
||||
|
||||
csum = ((b[0] * a[2] - b[2] * a[0] >= 0.0) ? 1 : 0);
|
||||
|
||||
if (csum ^ asum) {
|
||||
/* current angle is concave */
|
||||
p0 = p1;
|
||||
p1 = p2;
|
||||
p2 = p2->next;
|
||||
|
||||
} else {
|
||||
/* current angle is convex */
|
||||
xmin = (VX(p0, x) < VX(p1, x)) ? VX(p0, x) : VX(p1, x);
|
||||
if (xmin > VX(p2, x))
|
||||
xmin = VX(p2, x);
|
||||
|
||||
xmax = (VX(p0, x) > VX(p1, x)) ? VX(p0, x) : VX(p1, x);
|
||||
if (xmax < VX(p2, x))
|
||||
xmax = VX(p2, x);
|
||||
|
||||
ymin = (VX(p0, y) < VX(p1, y)) ? VX(p0, y) : VX(p1, y);
|
||||
if (ymin > VX(p2, y))
|
||||
ymin = VX(p2, y);
|
||||
|
||||
ymax = (VX(p0, y) > VX(p1, y)) ? VX(p0, y) : VX(p1, y);
|
||||
if (ymax < VX(p2, y))
|
||||
ymax = VX(p2, y);
|
||||
|
||||
for (init = 1, t0 = p2->next; t0 != p0; t0 = t0->next) {
|
||||
if (VX(t0, x) >= xmin && VX(t0, x) <= xmax &&
|
||||
VX(t0, y) >= ymin && VX(t0, y) <= ymax) {
|
||||
if (init) {
|
||||
a[1] = VX(p2, y) - VX(p0, y);
|
||||
b[1] = VX(p0, x) - VX(p2, x);
|
||||
init = 0;
|
||||
c[0] = VX(p1, x) * VX(p2, y) - VX(p2, x) * VX(p1, y);
|
||||
c[1] = VX(p2, x) * VX(p0, y) - VX(p0, x) * VX(p2, y);
|
||||
c[2] = VX(p0, x) * VX(p1, y) - VX(p1, x) * VX(p0, y);
|
||||
}
|
||||
|
||||
s[0] = a[0] * VX(t0, x) + b[0] * VX(t0, y) + c[0];
|
||||
s[1] = a[1] * VX(t0, x) + b[1] * VX(t0, y) + c[1];
|
||||
s[2] = a[2] * VX(t0, x) + b[2] * VX(t0, y) + c[2];
|
||||
|
||||
if (asum) {
|
||||
if (s[0] >= 0.0 && s[1] >= 0.0 && s[2] >= 0.0)
|
||||
break;
|
||||
} else {
|
||||
if (s[0] <= 0.0 && s[1] <= 0.0 && s[2] <= 0.0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (t0 != p0) {
|
||||
p0 = p1;
|
||||
p1 = p2;
|
||||
p2 = p2->next;
|
||||
} else {
|
||||
PrimType new_prim(prim);
|
||||
new_prim.set_type(BPT_tri);
|
||||
new_prim.clear_vertices();
|
||||
new_prim.add_vertex(prim.get_vertex(p0->index));
|
||||
new_prim.add_vertex(prim.get_vertex(p1->index));
|
||||
new_prim.add_vertex(prim.get_vertex(p2->index));
|
||||
output_prims.push_back(new_prim);
|
||||
|
||||
p0->next = p1->next;
|
||||
p1 = p2;
|
||||
p2 = p2->next;
|
||||
|
||||
m[0] = p0;
|
||||
m[1] = p1;
|
||||
m[2] = p2;
|
||||
chek = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PrimType new_prim(prim);
|
||||
new_prim.set_type(BPT_tri);
|
||||
new_prim.clear_vertices();
|
||||
new_prim.add_vertex(prim.get_vertex(p0->index));
|
||||
new_prim.add_vertex(prim.get_vertex(p1->index));
|
||||
new_prim.add_vertex(prim.get_vertex(p2->index));
|
||||
output_prims.push_back(new_prim);
|
||||
|
||||
copy(output_prims.begin(), output_prims.end(), result);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: triangulate_poly
|
||||
// Description: Breaks a (possibly concave) higher-order polygon into
|
||||
// a series of constituent triangles.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class PrimType, class OutputIterator>
|
||||
static bool
|
||||
triangulate_poly(const PrimType &prim, BuilderBucket &bucket,
|
||||
OutputIterator result) {
|
||||
BuilderV p0, p1, as;
|
||||
float dx1, dy1, dx2, dy2, max;
|
||||
int i, flag, asum, csum, index, x, y, v0, v1, v, even;
|
||||
|
||||
// First see if the polygon is just a triangle
|
||||
int num_verts = prim.get_num_verts();
|
||||
if (num_verts == 3) {
|
||||
PrimType new_prim(prim);
|
||||
new_prim.set_type(BPT_tri);
|
||||
*result++ = new_prim;
|
||||
|
||||
return true;
|
||||
|
||||
} else if (num_verts < 3) {
|
||||
// Or if it's a degenerate polygon.
|
||||
return false;
|
||||
}
|
||||
|
||||
// calculate signed areas
|
||||
as[0] = 0.0;
|
||||
as[1] = 0.0;
|
||||
as[2] = 0.0;
|
||||
|
||||
for (i = 0; i < num_verts; i++) {
|
||||
p0 = prim.get_vertex(i).get_coord_value(bucket);
|
||||
p1 = prim.get_vertex((i + 1) % num_verts).get_coord_value(bucket);
|
||||
as[0] += p0[0] * p1[1] - p0[1] * p1[0];
|
||||
as[1] += p0[0] * p1[2] - p0[2] * p1[0];
|
||||
as[2] += p0[1] * p1[2] - p0[2] * p1[1];
|
||||
}
|
||||
|
||||
/* select largest signed area */
|
||||
max = 0.0;
|
||||
index = 0;
|
||||
flag = 0;
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (as[i] >= 0.0) {
|
||||
if (as[i] > max) {
|
||||
max = as[i];
|
||||
index = i;
|
||||
flag = 1;
|
||||
}
|
||||
} else {
|
||||
as[i] = -as[i];
|
||||
if (as[i] > max) {
|
||||
max = as[i];
|
||||
index = i;
|
||||
flag = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* pointer offsets */
|
||||
switch (index) {
|
||||
case 0:
|
||||
x = 0;
|
||||
y = 1;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
x = 0;
|
||||
y = 2;
|
||||
break;
|
||||
|
||||
default: // case 2
|
||||
x = 1;
|
||||
y = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
/* concave check */
|
||||
p0 = prim.get_vertex(0).get_coord_value(bucket);
|
||||
p1 = prim.get_vertex(1).get_coord_value(bucket);
|
||||
dx1 = p1[x] - p0[x];
|
||||
dy1 = p1[y] - p0[y];
|
||||
p0 = p1;
|
||||
p1 = prim.get_vertex(2).get_coord_value(bucket);
|
||||
|
||||
dx2 = p1[x] - p0[x];
|
||||
dy2 = p1[y] - p0[y];
|
||||
asum = ((dx1 * dy2 - dx2 * dy1 >= 0.0) ? 1 : 0);
|
||||
|
||||
for (i = 0; i < num_verts - 1; i++) {
|
||||
p0 = p1;
|
||||
p1 = prim.get_vertex((i+3) % num_verts).get_coord_value(bucket);
|
||||
|
||||
dx1 = dx2;
|
||||
dy1 = dy2;
|
||||
dx2 = p1[x] - p0[x];
|
||||
dy2 = p1[y] - p0[y];
|
||||
csum = ((dx1 * dy2 - dx2 * dy1 >= 0.0) ? 1 : 0);
|
||||
|
||||
if (csum ^ asum) {
|
||||
return decomp_concave(prim, bucket, result, flag, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
v0 = 0;
|
||||
v1 = 1;
|
||||
v = num_verts - 1;
|
||||
|
||||
even = 1;
|
||||
|
||||
/*
|
||||
* Convert to triangles only. Do not fan out from a single vertex
|
||||
* but zigzag into triangle strip.
|
||||
*/
|
||||
for (i = 0; i < num_verts - 2; i++) {
|
||||
if (even) {
|
||||
PrimType new_prim(prim);
|
||||
new_prim.set_type(BPT_tri);
|
||||
new_prim.clear_vertices();
|
||||
new_prim.add_vertex(prim.get_vertex(v0));
|
||||
new_prim.add_vertex(prim.get_vertex(v1));
|
||||
new_prim.add_vertex(prim.get_vertex(v));
|
||||
*result++ = new_prim;
|
||||
v0 = v1;
|
||||
v1 = v;
|
||||
v = v0 + 1;
|
||||
} else {
|
||||
PrimType new_prim(prim);
|
||||
new_prim.set_type(BPT_tri);
|
||||
new_prim.clear_vertices();
|
||||
new_prim.add_vertex(prim.get_vertex(v1));
|
||||
new_prim.add_vertex(prim.get_vertex(v0));
|
||||
new_prim.add_vertex(prim.get_vertex(v));
|
||||
*result++ = new_prim;
|
||||
v0 = v1;
|
||||
v1 = v;
|
||||
v = v0 - 1;
|
||||
}
|
||||
|
||||
even = !even;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: expand_polys
|
||||
// Description: Identifies a single polygon as a triangle, quad, or
|
||||
// higher-order polygon, and writes it into the result
|
||||
// list.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class PrimType, class OutputIterator>
|
||||
static bool
|
||||
expand_polys(PrimType &prim, BuilderBucket &,
|
||||
OutputIterator result) {
|
||||
switch (prim.get_num_verts()) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
return false;
|
||||
|
||||
case 3:
|
||||
prim.set_type(BPT_tri);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
prim.set_type(BPT_quad);
|
||||
break;
|
||||
|
||||
default:
|
||||
prim.set_type(BPT_poly);
|
||||
}
|
||||
|
||||
*result++ = prim;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: expand_points
|
||||
// Description: Expands a light points primitive into its individual
|
||||
// component points, with one point per primitive.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class PrimType, class OutputIterator>
|
||||
static bool
|
||||
expand_points(const PrimType &prim, BuilderBucket &,
|
||||
OutputIterator result) {
|
||||
// Each vertex goes in its own primitive.
|
||||
|
||||
int num_verts = prim.get_num_verts();
|
||||
for (int i = 0; i < num_verts; i++) {
|
||||
PrimType new_prim(prim);
|
||||
new_prim.clear_vertices();
|
||||
new_prim.add_vertex(prim.get_vertex(i));
|
||||
*result++ = new_prim;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: expand_lines
|
||||
// Description: Expands a linestrip primitive into its component line
|
||||
// primitives.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class PrimType, class OutputIterator>
|
||||
static bool
|
||||
expand_lines(PrimType &prim, BuilderBucket &,
|
||||
OutputIterator result) {
|
||||
// Actually, we don't have support for meshing linestrips right now,
|
||||
// so let's not break up the linestrips we're supplied with.
|
||||
/*
|
||||
if (bucket._subdivide_polys) {
|
||||
// If we're subdividing, each line segment goes in its own
|
||||
// primitive. This breaks up the linestrips already defined;
|
||||
// we'll re-strip them later if the generate-tstrips flag is
|
||||
// enabled.
|
||||
prim.set_type(BPT_line);
|
||||
|
||||
int num_verts = prim.get_num_verts();
|
||||
for (int i = 1; i < num_verts; i++) {
|
||||
PrimType new_prim(prim);
|
||||
new_prim.clear_vertices();
|
||||
new_prim.add_vertex(prim.get_vertex(i-1));
|
||||
new_prim.add_vertex(prim.get_vertex(i));
|
||||
*result++ = new_prim;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
|
||||
// If we're not to subdivide the polys, then just pass them through
|
||||
// as they are. Two vertices is a BPT_line; more than that is a
|
||||
// BPT_linestrip.
|
||||
if (prim.get_num_verts() > 2) {
|
||||
prim.set_type(BPT_linestrip);
|
||||
} else {
|
||||
prim.set_type(BPT_line);
|
||||
}
|
||||
*result++ = prim;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: expand
|
||||
// Description: Receives a single primitive as a BuilderPrim or
|
||||
// BuilderPrimI object, as input by the user. Does some
|
||||
// initial processing on the primitive to verify
|
||||
// internal consistency (for instance, that a quad has
|
||||
// four vertices), and returns a new BuilderPrim or
|
||||
// series of BuilderPrim objects, suitable for building
|
||||
// with.
|
||||
//
|
||||
// More than one primitive might be returned because
|
||||
// higher-order polygons may be broken up into
|
||||
// triangles, and linestrips and points are broken into
|
||||
// their component pieces. The output primitives are
|
||||
// written into the STL container defined by result.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class PrimType, class OutputIterator>
|
||||
bool
|
||||
expand(const PrimType &prim, BuilderBucket &bucket, OutputIterator result) {
|
||||
// Make a copy of the prim so we can fiddle with it.
|
||||
PrimType new_prim = prim;
|
||||
|
||||
switch (new_prim.get_type()) {
|
||||
case BPT_poly:
|
||||
case BPT_tri:
|
||||
case BPT_quad:
|
||||
// These three types are all treated the same, as polygons. We
|
||||
// don't entirely trust the user to match the polygon type with
|
||||
// the number of verts, so we'll do it ourselves later.
|
||||
new_prim.remove_doubled_verts(true);
|
||||
|
||||
if (!bucket._subdivide_polys ||
|
||||
(bucket._mesh && new_prim.get_num_verts() <= 4)) {
|
||||
// If we're meshing, we'd like to send quads through without
|
||||
// subdividing. The mesher can take advantage of the extra
|
||||
// information (and will eventually produce tris anyway).
|
||||
return expand_polys(new_prim, bucket, result);
|
||||
} else {
|
||||
// If we're not meshing, we'll break them into tris now.
|
||||
return triangulate_poly(new_prim, bucket, result);
|
||||
}
|
||||
|
||||
case BPT_point:
|
||||
new_prim.remove_doubled_verts(false);
|
||||
return expand_points(new_prim, bucket, result);
|
||||
|
||||
case BPT_line:
|
||||
case BPT_linestrip:
|
||||
new_prim.remove_doubled_verts(false);
|
||||
return expand_lines(new_prim, bucket, result);
|
||||
|
||||
default:
|
||||
builder_cat.error() << "Unknown prim type\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: build_geoms
|
||||
// Description: Accepts a list of BuilderPrim or BuilderPrimI
|
||||
// objects, defined by the iterators first and last, and
|
||||
// creates corresponding geometry for them in the
|
||||
// indicated GeomNode.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class InputIterator, class PrimType>
|
||||
static int
|
||||
build_geoms(InputIterator first, InputIterator last,
|
||||
BuilderBucket &bucket, GeomNode *geom_node,
|
||||
PrimType *) {
|
||||
if (first==last) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// By the time we get here, we have a list of primitives that all have
|
||||
// the same properties:
|
||||
|
||||
// 1. The BuilderBucket.
|
||||
// 2. The indexed/nonindexed type.
|
||||
// 3. The primitive type (polygon, line, point).
|
||||
// 4. The pixel size.
|
||||
|
||||
// The binding of normals, colors, or texcoords: per-vertex,
|
||||
// per-prim, or per-component, will generally be the same across all
|
||||
// primitives, but it might not always be the same, because in
|
||||
// certain special cases the mesher might have changed these
|
||||
// properties when it built tristrips.
|
||||
|
||||
typedef TYPENAME PrimType::VType VType;
|
||||
typedef TYPENAME PrimType::NType NType;
|
||||
typedef TYPENAME PrimType::TType TType;
|
||||
typedef TYPENAME PrimType::CType CType;
|
||||
|
||||
// We need to determine the common binding type for all primitives.
|
||||
// For a given attribute, say normals, there are at most five cases,
|
||||
// in the order of priority:
|
||||
//
|
||||
// 1. If at least one primitive in the list does not have normals,
|
||||
// the binding will be G_OFF.
|
||||
//
|
||||
// 2. If at least one primitive has per-vertex normals, the binding
|
||||
// will be G_PER_VERTEX.
|
||||
//
|
||||
// 3. If at least one primitive has per-component normals, the
|
||||
// binding will be G_PER_COMPONENT.
|
||||
//
|
||||
// 4. If none of the first three apply, it follows that all
|
||||
// primitives have an overall normal. If any primitive's
|
||||
// overall normal differs from any other, the binding will be
|
||||
// G_PER_PRIM.
|
||||
//
|
||||
// 5. If none of the above apply, the binding will be G_OVERALL.
|
||||
//
|
||||
// Texcoords are an exception to the above, since they are either
|
||||
// per vertex or not at all, and since there may be a different set
|
||||
// of texcoords for each of a number of InternalName objects.
|
||||
|
||||
GeomBindType bind_normals = G_OVERALL;
|
||||
GeomBindType bind_colors = G_OVERALL;
|
||||
|
||||
typedef pset<const InternalName *> InternalNames;
|
||||
InternalNames texcoord_names;
|
||||
|
||||
NType overall_normal(0);
|
||||
CType overall_color(0);
|
||||
bool first_normal = true;
|
||||
bool first_color = true;
|
||||
|
||||
InputIterator i;
|
||||
for (i = first; i != last; ++i) {
|
||||
// Normals.
|
||||
|
||||
// Test rule 1.
|
||||
if (!(*i).has_any_normal()) {
|
||||
bind_normals = G_OFF;
|
||||
} else if (bind_normals != G_OFF) {
|
||||
// Test rule 2.
|
||||
if ((*i).has_vertex_normal()) {
|
||||
bind_normals = G_PER_VERTEX;
|
||||
} else if (bind_normals != G_PER_VERTEX) {
|
||||
// Test rule 3.
|
||||
if ((*i).has_component_normal()) {
|
||||
bind_normals = G_PER_COMPONENT;
|
||||
} else if (bind_normals != G_PER_COMPONENT) {
|
||||
// Test rule 4.
|
||||
nassertr((*i).has_overall_normal(), 0);
|
||||
if (first_normal) {
|
||||
overall_normal = (*i).get_normal();
|
||||
first_normal = false;
|
||||
} else if ( !((*i).get_normal() == overall_normal)) {
|
||||
bind_normals = G_PER_PRIM;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Colors.
|
||||
|
||||
// Test rule 1.
|
||||
if (!(*i).has_any_color()) {
|
||||
bind_colors = G_OFF;
|
||||
} else if (bind_colors != G_OFF) {
|
||||
// Test rule 2.
|
||||
if ((*i).has_vertex_color()) {
|
||||
bind_colors = G_PER_VERTEX;
|
||||
} else if (bind_colors != G_PER_VERTEX) {
|
||||
// Test rule 3.
|
||||
if ((*i).has_component_color()) {
|
||||
bind_colors = G_PER_COMPONENT;
|
||||
} else if (bind_colors != G_PER_COMPONENT) {
|
||||
// Test rule 4.
|
||||
nassertr((*i).has_overall_color(), 0);
|
||||
if (first_color) {
|
||||
overall_color = (*i).get_color();
|
||||
first_color = false;
|
||||
} else if ( !((*i).get_color() == overall_color)) {
|
||||
bind_colors = G_PER_PRIM;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Texcoords. Get the union of all InternalNames defined on the
|
||||
// prims.
|
||||
TYPENAME PrimType::tcn_const_iterator tni;
|
||||
for (tni = (*i).tcn_begin(); tni != (*i).tcn_end(); ++tni) {
|
||||
const InternalName *name = (*tni);
|
||||
texcoord_names.insert(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Determine the primitive type and build the lengths array, if needed.
|
||||
PTA_int lengths;
|
||||
bool want_lengths = false;
|
||||
int j;
|
||||
|
||||
Geom *geom = NULL;
|
||||
BuilderPrimType type = (*first).get_type();
|
||||
|
||||
switch (type) {
|
||||
case BPT_poly:
|
||||
geom = new GeomPolygon;
|
||||
want_lengths = true;
|
||||
break;
|
||||
|
||||
case BPT_tristrip:
|
||||
geom = new GeomTristrip;
|
||||
want_lengths = true;
|
||||
break;
|
||||
|
||||
case BPT_trifan:
|
||||
geom = new GeomTrifan;
|
||||
want_lengths = true;
|
||||
break;
|
||||
|
||||
case BPT_line:
|
||||
geom = new GeomLine;
|
||||
break;
|
||||
|
||||
case BPT_linestrip:
|
||||
geom = new GeomLinestrip;
|
||||
want_lengths = true;
|
||||
break;
|
||||
|
||||
case BPT_point:
|
||||
geom = new GeomPoint;
|
||||
break;
|
||||
|
||||
case BPT_tri:
|
||||
geom = new GeomTri;
|
||||
break;
|
||||
|
||||
case BPT_quad:
|
||||
geom = new GeomQuad;
|
||||
break;
|
||||
|
||||
default:
|
||||
builder_cat.fatal() << "Invalid primitive type.\n";
|
||||
abort();
|
||||
}
|
||||
|
||||
if (geom == NULL) {
|
||||
builder_cat.error() << "Unsupported primitive type " << type << "\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Count up the number of prims we're actually building.
|
||||
int num_prims = 0;
|
||||
for (i = first; i != last; ++i) {
|
||||
if ((*i).is_valid()) {
|
||||
num_prims++;
|
||||
}
|
||||
}
|
||||
|
||||
if (num_prims==0) {
|
||||
builder_cat.error() << "All primitives were invalid!\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (want_lengths) {
|
||||
lengths = PTA_int::empty_array(num_prims);
|
||||
j = 0;
|
||||
for (i = first; i != last; ++i) {
|
||||
if ((*i).is_valid()) {
|
||||
lengths[j++] = (*i).get_num_verts();
|
||||
}
|
||||
}
|
||||
nassertr(j == num_prims, 0);
|
||||
}
|
||||
|
||||
// Now build up some arrays.
|
||||
PTA(VType) coords = PTA(VType)::empty_array(0);
|
||||
PTA(NType) normals = PTA(NType)::empty_array(0);
|
||||
PTA(CType) colors = PTA(CType)::empty_array(0);
|
||||
|
||||
typedef TYPENAME PrimType::TexCoordFill TexCoordFill;
|
||||
TexCoordFill texcoords;
|
||||
InternalNames::const_iterator tni;
|
||||
for (tni = texcoord_names.begin(); tni != texcoord_names.end(); ++tni) {
|
||||
texcoords[*tni] = PTA(TType)::empty_array(0);
|
||||
}
|
||||
|
||||
int total_verts = 0;
|
||||
int total_components = 0;
|
||||
|
||||
int v, num_verts;
|
||||
int c, num_components;
|
||||
for (i = first; i != last; ++i) {
|
||||
if ((*i).is_valid()) {
|
||||
num_verts = (*i).get_num_verts();
|
||||
total_verts += num_verts;
|
||||
for (v = 0; v < num_verts; v++) {
|
||||
coords.push_back((*i).get_vertex(v).get_coord());
|
||||
|
||||
if (bind_normals == G_PER_VERTEX) {
|
||||
normals.push_back((*i).get_vertex(v).get_normal());
|
||||
}
|
||||
if (bind_colors == G_PER_VERTEX) {
|
||||
colors.push_back((*i).get_vertex(v).get_color());
|
||||
}
|
||||
TYPENAME TexCoordFill::iterator tci;
|
||||
for (tci = texcoords.begin(); tci != texcoords.end(); ++tci) {
|
||||
const InternalName *name = (*tci).first;
|
||||
if ((*i).get_vertex(v).has_texcoord(name)) {
|
||||
(*tci).second.push_back((*i).get_vertex(v).get_texcoord(name));
|
||||
} else {
|
||||
(*tci).second.push_back(TType());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
num_components = (*i).get_num_components();
|
||||
total_components += num_components;
|
||||
for (c = 0; c < num_components; c++) {
|
||||
if (bind_normals == G_PER_COMPONENT) {
|
||||
normals.push_back((*i).get_component(c).get_normal());
|
||||
}
|
||||
if (bind_colors == G_PER_COMPONENT) {
|
||||
colors.push_back((*i).get_component(c).get_color());
|
||||
}
|
||||
}
|
||||
|
||||
if (bind_normals == G_PER_PRIM) {
|
||||
normals.push_back((*i).get_normal());
|
||||
}
|
||||
if (bind_colors == G_PER_PRIM) {
|
||||
colors.push_back((*i).get_color());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bind_normals == G_OVERALL) {
|
||||
normals.push_back(overall_normal);
|
||||
}
|
||||
if (bind_colors == G_OVERALL) {
|
||||
colors.push_back(overall_color);
|
||||
}
|
||||
|
||||
// Now add all the stuff to our Geom.
|
||||
|
||||
geom->set_num_prims(num_prims);
|
||||
|
||||
if (lengths != (int *)NULL) {
|
||||
geom->set_lengths(lengths);
|
||||
}
|
||||
|
||||
PrimType::fill_geom(geom, coords,
|
||||
bind_normals, normals,
|
||||
bind_colors, colors,
|
||||
texcoords,
|
||||
bucket, num_prims,
|
||||
total_components, total_verts);
|
||||
|
||||
/*
|
||||
if ((*first).has_pixel_size()) {
|
||||
// Again, we only have to test the first one in the list for a
|
||||
// pixel_size attribute. If this one has it, then they all have
|
||||
// the same value.
|
||||
geom->setPntSize((*first).get_pixel_size());
|
||||
geom->setLineWidth((*first).get_pixel_size());
|
||||
}
|
||||
*/
|
||||
|
||||
// geom->setDrawBin(bucket._drawBin);
|
||||
// geom->setDrawOrder(bucket._drawOrder);
|
||||
|
||||
Geom *new_geom = bucket.done_geom(geom);
|
||||
if (new_geom != (Geom *)NULL) {
|
||||
geom_node->add_geom(new_geom, bucket._state);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
// Class : PrimByType
|
||||
// Description : An STL function object to sort primitives in order by
|
||||
// type.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class PrimType>
|
||||
class PrimByType {
|
||||
public:
|
||||
int operator () (const PrimType &p1, const PrimType &p2) const {
|
||||
return p1.get_type() < p2.get_type();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: __mesh_and_build
|
||||
// Description: The implementation of mesh_and_build(), below. This
|
||||
// extra function call is just to allow mesh_and_build()
|
||||
// to infer the PrimType (BuilderPrim or BuilderPrimI)
|
||||
// from the iterator's value type, and template on that.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class InputIterator, class PrimType>
|
||||
static int
|
||||
__mesh_and_build(InputIterator first, InputIterator last,
|
||||
BuilderBucket &bucket, GeomNode *geom_node,
|
||||
PrimType *) {
|
||||
if (first==last) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
typedef pvector<PrimType> Prims;
|
||||
Prims prims;
|
||||
BuilderBucket *local_bucket = NULL;
|
||||
BuilderBucket *bucket_ptr = &bucket;
|
||||
|
||||
if (bucket._mesh) {
|
||||
// Send all the prims through the mesher. First, make a copy of
|
||||
// the bucket so the mesher can modify it if it wants.
|
||||
local_bucket = bucket.make_copy();
|
||||
bucket_ptr = local_bucket;
|
||||
MesherTempl<PrimType> mesher(local_bucket);
|
||||
|
||||
for (InputIterator ii = first; ii != last; ++ii) {
|
||||
mesher.add_prim(*ii);
|
||||
}
|
||||
mesher.mesh();
|
||||
PrimType prim;
|
||||
prim = mesher.getPrim();
|
||||
while (prim.get_num_verts() > 0) {
|
||||
prims.push_back(prim);
|
||||
prim = mesher.getPrim();
|
||||
}
|
||||
|
||||
} else {
|
||||
// Send the prims through without meshing.
|
||||
copy(first, last, back_inserter(prims));
|
||||
}
|
||||
|
||||
// Now we have an array of prims which all share the same
|
||||
// properties, except possibly type. Sort them by type and send
|
||||
// them to build_geoms.
|
||||
sort(prims.begin(), prims.end(), PrimByType<PrimType>());
|
||||
|
||||
int count = 0;
|
||||
if (!prims.empty()) {
|
||||
TYPENAME Prims::iterator pi, last_pi;
|
||||
pi = prims.begin();
|
||||
last_pi = pi;
|
||||
for (++pi; pi != prims.end(); ++pi) {
|
||||
if ((*pi).get_type() != (*last_pi).get_type()) {
|
||||
count += build_geoms(last_pi, pi, *bucket_ptr, geom_node, (PrimType*)0);
|
||||
last_pi = pi;
|
||||
}
|
||||
}
|
||||
count += build_geoms(last_pi, pi, *bucket_ptr, geom_node, (PrimType*)0);
|
||||
}
|
||||
|
||||
if (local_bucket!=NULL) {
|
||||
delete local_bucket;
|
||||
}
|
||||
|
||||
// Finally, if the user so requested, create some visualization for
|
||||
// the normals.
|
||||
#ifdef SUPPORT_SHOW_NORMALS
|
||||
if (bucket._show_normals) {
|
||||
BuilderNormalVisualizer bnv(bucket);
|
||||
for (InputIterator ii = first; ii != last; ++ii) {
|
||||
bnv.add_prim(*ii);
|
||||
}
|
||||
bnv.show_normals(geom_node);
|
||||
}
|
||||
#endif
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: mesh_and_build
|
||||
// Description: Accepts a list of BuilderPrim or BuilderPrimI
|
||||
// objects, defined by the iterators first and list,
|
||||
// runs them through the mesher if specified by the
|
||||
// bucket, and builds them into the indicated GeomNode.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class InputIterator, class value_type>
|
||||
int
|
||||
mesh_and_build(InputIterator first, InputIterator last,
|
||||
BuilderBucket &bucket, GeomNode *geom_node,
|
||||
value_type *value_type_ptr) {
|
||||
return __mesh_and_build(first, last, bucket, geom_node, value_type_ptr);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: split
|
||||
// Description: Splits an STL list into two other lists, according to
|
||||
// the return value from pred.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class InputIterator, class OutputIterator, class Predicate>
|
||||
OutputIterator split(InputIterator first, InputIterator last,
|
||||
OutputIterator true_result, OutputIterator false_result,
|
||||
Predicate pred) {
|
||||
while (first != last) {
|
||||
if (pred(*first)) {
|
||||
*true_result++ = *first++;
|
||||
} else {
|
||||
*false_result++ = *first++;
|
||||
}
|
||||
}
|
||||
return true_result;
|
||||
}
|
||||
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
// Filename: builderFuncs.h
|
||||
// Created by: drose (09Sep97)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
#ifndef BUILDERFUNCS_H
|
||||
#define BUILDERFUNCS_H
|
||||
|
||||
#include "pandabase.h"
|
||||
#include "pvector.h"
|
||||
|
||||
class BuilderBucket;
|
||||
class GeomNode;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: expand
|
||||
// Description: Receives a single primitive as a BuilderPrim or
|
||||
// BuilderPrimI object, as input by the user. Does some
|
||||
// initial processing on the primitive to verify
|
||||
// internal consistency (for instance, that a quad has
|
||||
// four vertices), and returns a new BuilderPrim or
|
||||
// series of BuilderPrim objects, suitable for building
|
||||
// with.
|
||||
//
|
||||
// More than one primitive might be returned because
|
||||
// higher-order polygons may be broken up into
|
||||
// triangles, and linestrips and points are broken into
|
||||
// their component pieces. The output primitives are
|
||||
// written into the STL container defined by result.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class PrimType, class OutputIterator>
|
||||
bool
|
||||
expand(const PrimType &prim, BuilderBucket &bucket,
|
||||
OutputIterator result);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: mesh_and_build
|
||||
// Description: Accepts a list of BuilderPrim or BuilderPrimI
|
||||
// objects, defined by the iterators first and list,
|
||||
// runs them through the mesher if specified by the
|
||||
// bucket, and builds them into the indicated GeomNode.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class InputIterator>
|
||||
int
|
||||
mesh_and_build(InputIterator first, InputIterator last,
|
||||
BuilderBucket &bucket, GeomNode *geom_node);
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: split
|
||||
// Description: Splits an STL list into two other lists, according to
|
||||
// the return value from pred.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class InputIterator, class OutputIterator, class Predicate>
|
||||
OutputIterator split(InputIterator first, InputIterator last,
|
||||
OutputIterator true_result, OutputIterator false_result,
|
||||
Predicate pred);
|
||||
|
||||
#include "builderFuncs.I"
|
||||
|
||||
#endif
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
// Filename: builderMisc.cxx
|
||||
// Created by: drose (18Sep97)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "builderMisc.h"
|
||||
#include "builderTypes.h"
|
||||
|
||||
#include "luse.h"
|
||||
#include <stdlib.h>
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: make_random_color
|
||||
// Description: Chooses a reasonable random color.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
make_random_color(Colorf &color) {
|
||||
LVector3f rgb;
|
||||
float len;
|
||||
do {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
rgb[i] = (double)rand() / (double)RAND_MAX;
|
||||
}
|
||||
len = length(rgb);
|
||||
|
||||
// Repeat until we have a color that's not too dark or too light.
|
||||
} while (len < .1 || len > 1.5);
|
||||
|
||||
#ifdef WIN32_VC
|
||||
color.set(rgb[0], rgb[1], rgb[2],
|
||||
0.25 + 0.75 * (double)rand() / (double)RAND_MAX);
|
||||
#else
|
||||
color.set(rgb[0], rgb[1], rgb[2],
|
||||
0.25 + 0.75 * (double)random() / (double)RAND_MAX);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
// Filename: builderMisc.h
|
||||
// Created by: drose (18Sep97)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
#ifndef BUILDERMISC_H
|
||||
#define BUILDERMISC_H
|
||||
|
||||
#include "pandabase.h"
|
||||
|
||||
#include "luse.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: make_random_color
|
||||
// Description: Chooses a reasonable random color.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void make_random_color(Colorf &color);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
// Filename: builderNormalVisualizer.I
|
||||
// Created by: drose (08Sep99)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
INLINE BuilderNormalVisualizer::
|
||||
BuilderNormalVisualizer(BuilderBucket &bucket) : _bucket(bucket) {
|
||||
_num_vertices = 0;
|
||||
_net_vertex.set(0.0, 0.0, 0.0);
|
||||
}
|
||||
|
||||
|
|
@ -1,79 +0,0 @@
|
|||
// Filename: builderNormalVisualizer.cxx
|
||||
// Created by: drose (08Sep99)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "builderFuncs.h"
|
||||
#include "builderNormalVisualizer.h"
|
||||
#include "geomNode.h"
|
||||
|
||||
#ifdef SUPPORT_SHOW_NORMALS
|
||||
|
||||
void BuilderNormalVisualizer::
|
||||
add_prim(const BuilderPrim &prim) {
|
||||
if (prim.has_overall_normal()) {
|
||||
// Average up all the vertex values to get the primitive center.
|
||||
BuilderV net_vertex;
|
||||
net_vertex.set(0.0, 0.0, 0.0);
|
||||
int num_verts = prim.get_num_verts();
|
||||
for (int i = 0; i < num_verts; i++) {
|
||||
net_vertex += prim.get_vertex(i).get_coord();
|
||||
}
|
||||
net_vertex /= num_verts;
|
||||
add_normal(net_vertex, prim.get_normal());
|
||||
|
||||
} else if (prim.has_vertex_normal()) {
|
||||
// Each vertex gets its own normal.
|
||||
int num_verts = prim.get_num_verts();
|
||||
for (int i = 0; i < num_verts; i++) {
|
||||
add_normal(prim.get_vertex(i).get_coord(), prim.get_vertex(i).get_normal());
|
||||
}
|
||||
} else if (prim.has_component_normal()) {
|
||||
// Each component gets its own normal. We don't presently handle
|
||||
// this, as it should only happen when the user passes
|
||||
// already-meshed tristrips into the builder, an unusual
|
||||
// situation.
|
||||
}
|
||||
}
|
||||
|
||||
void BuilderNormalVisualizer::
|
||||
add_prim(const BuilderPrimI &prim) {
|
||||
BuilderPrim prim_ni;
|
||||
prim_ni.nonindexed_copy(prim, _bucket);
|
||||
add_prim(prim_ni);
|
||||
}
|
||||
|
||||
void BuilderNormalVisualizer::
|
||||
show_normals(GeomNode *node) {
|
||||
// Ok, now we've got a bunch of normals saved up; create some geometry.
|
||||
mesh_and_build(_lines.begin(), _lines.end(), _bucket, node, (BuilderPrim *)0);
|
||||
}
|
||||
|
||||
void BuilderNormalVisualizer::
|
||||
add_normal(const BuilderV ¢er, const BuilderN &normal) {
|
||||
BuilderV to = center + normal * _bucket._normal_scale;
|
||||
|
||||
BuilderPrim line;
|
||||
line.set_type(BPT_line);
|
||||
line.set_color(_bucket._normal_color);
|
||||
line.add_vertex(BuilderVertex(center));
|
||||
line.add_vertex(BuilderVertex(to));
|
||||
|
||||
_lines.push_back(line);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
// Filename: builderNormalVisualizer.h
|
||||
// Created by: drose (08Sep99)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef BUILDERNORMALVISUALIZER_H
|
||||
#define BUILDERNORMALVISUALIZER_H
|
||||
|
||||
#include "pandabase.h"
|
||||
|
||||
#include "mesherConfig.h"
|
||||
|
||||
#ifdef SUPPORT_SHOW_NORMALS
|
||||
|
||||
#include "builderBucket.h"
|
||||
#include "builderAttrib.h"
|
||||
#include "builderVertex.h"
|
||||
#include "builderPrim.h"
|
||||
|
||||
#include "pvector.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : BuilderNormalVisualizer
|
||||
// Description : A useful class for collecting information about
|
||||
// vertices and their associated normals as geometry is
|
||||
// built, so that its normals may be visualized via
|
||||
// renderable geometry. This is activated by the
|
||||
// _show_normals flag in the BuilderProperties.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_PANDAEGG BuilderNormalVisualizer {
|
||||
public:
|
||||
INLINE BuilderNormalVisualizer(BuilderBucket &bucket);
|
||||
|
||||
void add_prim(const BuilderPrim &prim);
|
||||
void add_prim(const BuilderPrimI &prim);
|
||||
|
||||
void show_normals(GeomNode *node);
|
||||
|
||||
private:
|
||||
void add_normal(const BuilderV ¢er, const BuilderN &normal);
|
||||
|
||||
BuilderBucket &_bucket;
|
||||
|
||||
BuilderV _net_vertex;
|
||||
int _num_vertices;
|
||||
pvector<BuilderPrim> _lines;
|
||||
};
|
||||
|
||||
#include "builderNormalVisualizer.I"
|
||||
|
||||
#endif // SUPPORT_SHOW_NORMALS
|
||||
|
||||
#endif
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
// Filename: builderPrim.I
|
||||
// Created by: drose (11Jan01)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderPrim::Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE BuilderPrim::
|
||||
BuilderPrim() {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderPrim::Copy Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE BuilderPrim::
|
||||
BuilderPrim(const BuilderPrim ©) :
|
||||
BuilderPrimTempl<BuilderVertex>(copy) {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderPrim::Copy Assignment
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE BuilderPrim &BuilderPrim::
|
||||
operator = (const BuilderPrim ©) {
|
||||
BuilderPrimTempl<BuilderVertex>::operator = (copy);
|
||||
return *this;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderPrimI::Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE BuilderPrimI::
|
||||
BuilderPrimI() {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderPrimI::Copy Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE BuilderPrimI::
|
||||
BuilderPrimI(const BuilderPrimI ©) :
|
||||
BuilderPrimTempl<BuilderVertexI>(copy) {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderPrimI::Copy Assignment
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE BuilderPrimI &BuilderPrimI::
|
||||
operator = (const BuilderPrimI ©) {
|
||||
BuilderPrimTempl<BuilderVertexI>::operator = (copy);
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -1,273 +0,0 @@
|
|||
// Filename: builderPrim.cxx
|
||||
// Created by: drose (10Sep97)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "builderPrim.h"
|
||||
#include "notify.h"
|
||||
// Tell GCC that we'll take care of the instantiation explicitly here.
|
||||
#ifdef __GNUC__
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderPrim::nonindexed_copy
|
||||
// Access: Public
|
||||
// Description: Makes a nonindexed copy of the given indexed prim, by
|
||||
// looking up the current values of the indexed
|
||||
// coordinates in the given bucket.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
BuilderPrim &BuilderPrim::
|
||||
nonindexed_copy(const BuilderPrimTempl<BuilderVertexI> ©,
|
||||
const BuilderBucket &bucket) {
|
||||
clear();
|
||||
|
||||
set_type(copy.get_type());
|
||||
|
||||
if (copy.has_normal()) {
|
||||
nassertr(bucket.get_normals() != (Normalf *)NULL, *this);
|
||||
set_normal(bucket.get_normals()[copy.get_normal()]);
|
||||
}
|
||||
if (copy.has_color()) {
|
||||
nassertr(bucket.get_colors() != (Colorf *)NULL, *this);
|
||||
set_color(bucket.get_colors()[copy.get_color()]);
|
||||
}
|
||||
if (copy.has_pixel_size()) {
|
||||
set_pixel_size(copy.get_pixel_size());
|
||||
}
|
||||
|
||||
int num_verts = copy.get_num_verts();
|
||||
int i;
|
||||
for (i = 0; i < num_verts; i++) {
|
||||
const BuilderVertexI &cv = copy.get_vertex(i);
|
||||
BuilderVertex v;
|
||||
if (cv.has_coord()) {
|
||||
v.set_coord(cv.get_coord_value(bucket));
|
||||
}
|
||||
|
||||
if (cv.has_normal()) {
|
||||
v.set_normal(cv.get_normal_value(bucket));
|
||||
}
|
||||
|
||||
if (cv.has_color()) {
|
||||
v.set_color(cv.get_color_value(bucket));
|
||||
}
|
||||
|
||||
BuilderVertexI::tc_const_iterator tci;
|
||||
for (tci = cv.tc_begin(); tci != cv.tc_end(); ++tci) {
|
||||
const InternalName *name = (*tci).first;
|
||||
v.set_texcoord(name, cv.get_texcoord_value(name, bucket));
|
||||
}
|
||||
|
||||
if (cv.has_pixel_size()) {
|
||||
v.set_pixel_size(cv.get_pixel_size());
|
||||
}
|
||||
add_vertex(v);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderPrim::flatten_vertex_properties
|
||||
// Access: Public
|
||||
// Description: If all the vertices of the primitive have the same
|
||||
// normal, color, etc., removes those properties from
|
||||
// the vertices and assigns them to the primitive
|
||||
// instead.
|
||||
//
|
||||
// This can provide better meshing by removing
|
||||
// properties from otherwise shared vertices.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void BuilderPrim::
|
||||
flatten_vertex_properties() {
|
||||
int num_verts = get_num_verts();
|
||||
int i;
|
||||
|
||||
if (has_overall_normal()) {
|
||||
set_normal(get_normal());
|
||||
|
||||
for (i = 0; i < num_verts; i++) {
|
||||
get_vertex(i).clear_normal();
|
||||
}
|
||||
}
|
||||
|
||||
if (has_overall_color()) {
|
||||
set_color(get_color());
|
||||
|
||||
for (i = 0; i < num_verts; i++) {
|
||||
get_vertex(i).clear_color();
|
||||
}
|
||||
}
|
||||
|
||||
if (has_overall_pixel_size()) {
|
||||
set_pixel_size(get_pixel_size());
|
||||
|
||||
for (i = 0; i < num_verts; i++) {
|
||||
get_vertex(i).clear_pixel_size();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderPrim::fill_geom
|
||||
// Access: Public
|
||||
// Description: Fills up the attribute values of a Geom with the
|
||||
// indicated arrays. This creates a nonindexed Geom.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void BuilderPrim::
|
||||
fill_geom(Geom *geom, const PTA_BuilderV &v_array,
|
||||
GeomBindType n_attr, const PTA_BuilderN &n_array,
|
||||
GeomBindType c_attr, const PTA_BuilderC &c_array,
|
||||
const BuilderPrim::TexCoordFill &texcoords,
|
||||
const BuilderBucket &, int, int, int) {
|
||||
|
||||
// WARNING! This is questionable practice. We have a
|
||||
// PTA_BuilderV etc.; since a BuilderV is just a proxy
|
||||
// to a Vertexf, we can get away with casting this to a
|
||||
// PTA_Vertexf.
|
||||
|
||||
geom->set_coords((PTA_Vertexf &)v_array);
|
||||
|
||||
if (n_attr != G_OFF) {
|
||||
geom->set_normals((PTA_Normalf &)n_array, n_attr);
|
||||
}
|
||||
|
||||
if (c_attr != G_OFF) {
|
||||
geom->set_colors((PTA_Colorf &)c_array, c_attr);
|
||||
}
|
||||
|
||||
TexCoordFill::const_iterator tci;
|
||||
for (tci = texcoords.begin(); tci != texcoords.end(); ++tci) {
|
||||
const InternalName *name = (*tci).first;
|
||||
geom->set_texcoords(name, (*tci).second);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderPrimI::flatten_vertex_properties
|
||||
// Access: Public
|
||||
// Description: If all the vertices of the primitive have the same
|
||||
// normal, color, etc., removes those properties from
|
||||
// the vertices and assigns them to the primitive
|
||||
// instead.
|
||||
//
|
||||
// This can do nothing in the case of an indexed
|
||||
// primitive, because we can't monkey with the vertex
|
||||
// properties in this case.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void BuilderPrimI::
|
||||
flatten_vertex_properties() {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderPrimI::fill_geom
|
||||
// Access: Public
|
||||
// Description: Fills up the attribute values of a Geom with the
|
||||
// indicated arrays. This creates an indexed Geom.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void BuilderPrimI::
|
||||
fill_geom(Geom *geom, const PTA_ushort &v_array,
|
||||
GeomBindType n_attr, PTA_ushort n_array,
|
||||
GeomBindType c_attr, PTA_ushort c_array,
|
||||
const BuilderPrimI::TexCoordFill &texcoords,
|
||||
const BuilderBucket &bucket,
|
||||
int num_prims, int num_components, int num_verts) {
|
||||
PTA_Vertexf v_data = bucket.get_coords();
|
||||
PTA_Normalf n_data = bucket.get_normals();
|
||||
PTA_Colorf c_data = bucket.get_colors();
|
||||
|
||||
// Make sure the data pointers are NULL if the attribute is off.
|
||||
if (n_attr == G_OFF) {
|
||||
n_data = NULL;
|
||||
n_array = NULL;
|
||||
}
|
||||
if (c_attr == G_OFF) {
|
||||
c_data = NULL;
|
||||
c_array = NULL;
|
||||
}
|
||||
|
||||
int n_len =
|
||||
(n_attr==G_PER_VERTEX) ? num_verts :
|
||||
(n_attr==G_PER_COMPONENT) ? num_components :
|
||||
(n_attr==G_PER_PRIM) ? num_prims :
|
||||
(n_attr==G_OVERALL) ? 1 : 0;
|
||||
int c_len =
|
||||
(c_attr==G_PER_VERTEX) ? num_verts :
|
||||
(c_attr==G_PER_COMPONENT) ? num_components :
|
||||
(c_attr==G_PER_PRIM) ? num_prims :
|
||||
(c_attr==G_OVERALL) ? 1 : 0;
|
||||
|
||||
// See if we can share some of the index lists.
|
||||
if (n_attr != G_OFF &&
|
||||
memcmp(v_array, n_array, sizeof(ushort) * n_len)==0) {
|
||||
n_array = v_array;
|
||||
}
|
||||
if (c_attr != G_OFF) {
|
||||
if (memcmp(v_array, c_array, sizeof(ushort) * c_len)==0) {
|
||||
c_array = v_array;
|
||||
} else if (c_len <= n_len &&
|
||||
memcmp(n_array, c_array, sizeof(ushort) * c_len)==0) {
|
||||
c_array = n_array;
|
||||
}
|
||||
}
|
||||
|
||||
geom->set_coords(v_data, v_array);
|
||||
|
||||
if (n_attr != G_OFF) {
|
||||
geom->set_normals(n_data, n_attr, n_array);
|
||||
}
|
||||
|
||||
if (c_attr != G_OFF) {
|
||||
geom->set_colors(c_data, c_attr, c_array);
|
||||
}
|
||||
|
||||
TexCoordFill::const_iterator tci;
|
||||
for (tci = texcoords.begin(); tci != texcoords.end(); ++tci) {
|
||||
const InternalName *name = (*tci).first;
|
||||
PTA_ushort t_array = (*tci).second;
|
||||
|
||||
PTA_TexCoordf t_data = bucket.get_texcoords(name);
|
||||
if (t_data != (TexCoordf *)NULL) {
|
||||
int t_len = num_verts;
|
||||
|
||||
// Can we share the index list with some other property?
|
||||
if (memcmp(v_array, t_array, sizeof(ushort) * t_len)==0) {
|
||||
t_array = v_array;
|
||||
} else if (t_len <= n_len &&
|
||||
memcmp(n_array, t_array, sizeof(ushort) * t_len)==0) {
|
||||
t_array = n_array;
|
||||
} else if (t_len <= c_len &&
|
||||
memcmp(c_array, t_array, sizeof(ushort) * t_len)==0) {
|
||||
t_array = c_array;
|
||||
|
||||
} else {
|
||||
TexCoordFill::const_iterator tci2;
|
||||
for (tci2 = texcoords.begin(); tci2 != tci; ++tci2) {
|
||||
PTA_ushort t_array2 = (*tci).second;
|
||||
if (memcmp(t_array2, t_array, sizeof(ushort) * t_len)==0) {
|
||||
t_array = t_array2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
geom->set_texcoords(name, t_data, t_array);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,135 +0,0 @@
|
|||
// Filename: builderPrim.h
|
||||
// Created by: drose (09Sep97)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef BUILDERPRIM_H
|
||||
#define BUILDERPRIM_H
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// BuilderPrim, BuilderPrimI
|
||||
//
|
||||
// The basic class for passing primitives (polygons, etc.) to the
|
||||
// builder. See the comments at the beginning of builder.h and
|
||||
// builderVertex.h.
|
||||
//
|
||||
// A BuilderPrim has a few attributes of its own--color and
|
||||
// normal--which are defined in builderAttrib.h (which it inherits
|
||||
// from). It also has a collection of vertices, represented as
|
||||
// BuilderVertex objects, each of which can have its own attributes as
|
||||
// well. Any additional attributes, such as texture, lighting, etc.,
|
||||
// are considered to be external to the primitive, and are defined in
|
||||
// the BuilderBucket object.
|
||||
//
|
||||
// BuilderPrimI is exactly like BuilderPrim, except that it represents
|
||||
// an indexed primitive. A BuilderPrimI keeps its collection of
|
||||
// vertices as BuilderVertexI's, which store their values as index
|
||||
// numbers into an array rather than as actual coordinate values. The
|
||||
// arrays themselves are stored in the BuilderBucket.
|
||||
//
|
||||
// In fact, BuilderPrim and BuilderPrimI are both instantiations of
|
||||
// the same template object, BuilderPrimTempl, with different vertex
|
||||
// types (BuilderVertex and BuilderVertexI, respectively).
|
||||
//
|
||||
// It is this templating that drives most of the code in this package.
|
||||
// A lot of stuff in the builder tool, and everything in the mesher
|
||||
// tool, is templated on the BuilderPrim type, so the same code is
|
||||
// used to support both indexed and nonindexed primitives.
|
||||
//
|
||||
//
|
||||
// In addition to storing the primitives--individual polygons,
|
||||
// generally--as passed in by user code, BuilderPrim objects can store
|
||||
// the compound primitives that might have been generated by the
|
||||
// mesher, like triangle strips. In this case, in addition to an
|
||||
// array of vertices, it has an array of component attributes, which
|
||||
// store the attributes specific to each individual component
|
||||
// (e.g. the normal of each triangle in a triangle strip).
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "pandabase.h"
|
||||
#include "builderPrimTempl.h"
|
||||
#include "builderBucket.h"
|
||||
#include "builderTypes.h"
|
||||
#include "pta_ushort.h"
|
||||
#include "geom.h"
|
||||
|
||||
EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, BuilderPrimTempl<BuilderVertex>);
|
||||
EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, BuilderPrimTempl<BuilderVertexI>);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
// Class : BuilderPrim
|
||||
// Description : The basic class for passing nonindexed primitives
|
||||
// to the builder. See the comments at the the head of
|
||||
// this file, and in builder.h.
|
||||
//
|
||||
// Look in builderPrimTempl.h and builderAttribTempl.h
|
||||
// for most of the interface to BuilderPrim.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_PANDAEGG BuilderPrim : public BuilderPrimTempl<BuilderVertex> {
|
||||
public:
|
||||
INLINE BuilderPrim();
|
||||
INLINE BuilderPrim(const BuilderPrim ©);
|
||||
INLINE BuilderPrim &operator = (const BuilderPrim ©);
|
||||
|
||||
BuilderPrim &nonindexed_copy(const BuilderPrimTempl<BuilderVertexI> ©,
|
||||
const BuilderBucket &bucket);
|
||||
|
||||
void flatten_vertex_properties();
|
||||
|
||||
static void fill_geom(Geom *geom, const PTA_BuilderV &v_array,
|
||||
GeomBindType n_attr, const PTA_BuilderN &n_array,
|
||||
GeomBindType c_attr, const PTA_BuilderC &c_array,
|
||||
const TexCoordFill &texcoords,
|
||||
const BuilderBucket &bucket,
|
||||
int num_prims, int num_components, int num_verts);
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : BuilderPrimI
|
||||
// Description : The basic class for passing indexed primitives
|
||||
// to the builder.
|
||||
//
|
||||
// Look in builderPrimTempl.h and builderAttribTempl.h
|
||||
// for most of the interface to BuilderPrimI.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_PANDAEGG BuilderPrimI : public BuilderPrimTempl<BuilderVertexI> {
|
||||
public:
|
||||
INLINE BuilderPrimI();
|
||||
INLINE BuilderPrimI(const BuilderPrimI ©);
|
||||
INLINE BuilderPrimI &operator = (const BuilderPrimI ©);
|
||||
|
||||
void flatten_vertex_properties();
|
||||
|
||||
static void fill_geom(Geom *geom, const PTA_ushort &v_array,
|
||||
GeomBindType n_attr, PTA_ushort n_array,
|
||||
GeomBindType c_attr, PTA_ushort c_array,
|
||||
const TexCoordFill &texcoords,
|
||||
const BuilderBucket &bucket,
|
||||
int num_prims, int num_components, int num_verts);
|
||||
};
|
||||
|
||||
#include "builderPrim.I"
|
||||
|
||||
|
||||
// Tell GCC that we'll take care of the instantiation explicitly here.
|
||||
#ifdef __GNUC__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,168 +0,0 @@
|
|||
// Filename: builderPrimTempl.h
|
||||
// Created by: drose (11Sep97)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef BUILDERPRIMTEMPL_H
|
||||
#define BUILDERPRIMTEMPL_H
|
||||
|
||||
#include "pandabase.h"
|
||||
|
||||
#include "builderVertex.h"
|
||||
#include "builderAttrib.h"
|
||||
#include "builderTypes.h"
|
||||
|
||||
#include "pvector.h"
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
// Class : BuilderPrimTempl
|
||||
// Description : The main body of BuilderPrim and BuilderPrimI. This
|
||||
// is a template class on vertex type, which must be
|
||||
// either BuilderVertex or BuilderVertexI; these classes
|
||||
// are themselves template classes on vertex type,
|
||||
// texcoord type, color type, etc.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VTX>
|
||||
class BuilderPrimTempl : public VTX::Attrib {
|
||||
public:
|
||||
typedef VTX Vertex;
|
||||
typedef TYPENAME VTX::VType VType;
|
||||
typedef TYPENAME VTX::NType NType;
|
||||
typedef TYPENAME VTX::TType TType;
|
||||
typedef TYPENAME VTX::CType CType;
|
||||
typedef TYPENAME VTX::Attrib DAttrib;
|
||||
typedef pset<const InternalName *> InternalNames;
|
||||
typedef InternalNames::const_iterator tcn_const_iterator;
|
||||
typedef InternalNames::size_type tcn_size_type;
|
||||
|
||||
// This type is passed to fill_geom() for the texcoords.
|
||||
typedef pmap<const InternalName *, PTA(TType) > TexCoordFill;
|
||||
|
||||
INLINE BuilderPrimTempl();
|
||||
INLINE BuilderPrimTempl(const BuilderPrimTempl ©);
|
||||
INLINE BuilderPrimTempl &operator = (const BuilderPrimTempl ©);
|
||||
|
||||
void remove_doubled_verts(int closed);
|
||||
bool is_valid() const;
|
||||
|
||||
// has_normal() etc. is true if the primitive has a normal, as
|
||||
// assigned by the user. This is unrelated to the vertices or
|
||||
// component primitives that may or may not also have normals.
|
||||
INLINE bool has_normal() const;
|
||||
INLINE bool has_color() const;
|
||||
INLINE bool has_pixel_size() const;
|
||||
|
||||
// The following has_* functions are based on information derived
|
||||
// from examining the vertices and the component primitives that
|
||||
// make up this primitive.
|
||||
|
||||
// has_overall_normal() etc. is true if the primitive has a single,
|
||||
// overall normal shared among all vertices and all component
|
||||
// primitives, or if its normal was assigned directly via
|
||||
// set_normal(). For a polygon, this is the polygon normal. For a
|
||||
// tristrip, this means all triangles share the same normal.
|
||||
INLINE bool has_overall_normal() const;
|
||||
INLINE bool has_overall_color() const;
|
||||
INLINE bool has_overall_pixel_size() const;
|
||||
|
||||
// has_vertex_normal() etc. is true if each vertex in the primitive
|
||||
// has its own normal. It is not true if any vertex does not have a
|
||||
// normal.
|
||||
INLINE bool has_vertex_normal() const;
|
||||
INLINE bool has_vertex_color() const;
|
||||
INLINE bool has_vertex_pixel_size() const;
|
||||
|
||||
// has_component_normal() can only be true for aggregate primitive
|
||||
// types like tristrips. In that case, it is true if each
|
||||
// individual component (e.g. each triangle of the tristrip) has its
|
||||
// own normal.
|
||||
INLINE bool has_component_normal() const;
|
||||
INLINE bool has_component_color() const;
|
||||
INLINE bool has_component_pixel_size() const;
|
||||
|
||||
// In the above, only one of has_overall_normal(),
|
||||
// has_vertex_normal(), and has_component_normal() can be true for a
|
||||
// given primitive. For convenience, the following functions return
|
||||
// true if any of the above is true:
|
||||
|
||||
INLINE bool has_any_normal() const;
|
||||
INLINE bool has_any_color() const;
|
||||
INLINE bool has_any_pixel_size() const;
|
||||
|
||||
// The following methods iterate through the list of texture
|
||||
// coordinate names that all vertices in the primitive have in
|
||||
// common.
|
||||
INLINE tcn_const_iterator tcn_begin() const;
|
||||
INLINE tcn_const_iterator tcn_end() const;
|
||||
INLINE tcn_size_type tcn_size() const;
|
||||
|
||||
INLINE BuilderPrimTempl &clear();
|
||||
INLINE BuilderPrimTempl &clear_vertices();
|
||||
|
||||
INLINE BuilderPrimTempl &set_attrib(const DAttrib &attrib);
|
||||
|
||||
INLINE BuilderPrimType get_type() const;
|
||||
INLINE BuilderPrimTempl &set_type(BuilderPrimType t);
|
||||
|
||||
INLINE NType get_normal() const;
|
||||
INLINE BuilderPrimTempl &set_normal(const NType &n);
|
||||
|
||||
INLINE CType get_color() const;
|
||||
INLINE BuilderPrimTempl &set_color(const CType &c);
|
||||
|
||||
INLINE float get_pixel_size() const;
|
||||
INLINE BuilderPrimTempl &set_pixel_size(float s);
|
||||
|
||||
INLINE BuilderPrimTempl &add_vertex(const Vertex &v);
|
||||
|
||||
INLINE int get_num_verts() const;
|
||||
INLINE Vertex &get_vertex(int n);
|
||||
INLINE const Vertex &get_vertex(int n) const;
|
||||
|
||||
INLINE BuilderPrimTempl &add_component(const DAttrib &attrib);
|
||||
INLINE int get_num_components() const;
|
||||
INLINE DAttrib &get_component(int n);
|
||||
INLINE const DAttrib &get_component(int n) const;
|
||||
|
||||
INLINE bool operator < (const BuilderPrimTempl &other) const;
|
||||
|
||||
ostream &output(ostream &out) const;
|
||||
|
||||
protected:
|
||||
INLINE int sort_value() const;
|
||||
void update_overall_attrib();
|
||||
|
||||
typedef pvector<Vertex> Verts;
|
||||
typedef pvector<DAttrib> Components;
|
||||
|
||||
Verts _verts;
|
||||
Components _components;
|
||||
InternalNames _texcoord_names;
|
||||
BuilderPrimType _type;
|
||||
int _overall;
|
||||
};
|
||||
|
||||
template <class VTX>
|
||||
INLINE ostream &operator << (ostream &out,
|
||||
const BuilderPrimTempl<VTX> &prim) {
|
||||
return prim.output(out);
|
||||
}
|
||||
|
||||
|
||||
#include "builderPrimTempl.I"
|
||||
|
||||
#endif
|
||||
|
|
@ -1,128 +0,0 @@
|
|||
// Filename: builderProperties.cxx
|
||||
// Created by: drose (17Sep97)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "builderProperties.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderProperties::Ordering operator
|
||||
// Access: Public
|
||||
// Description: Defines an arbitrary ordering among different
|
||||
// properties, and groups identical sets of properties
|
||||
// together. This operator is used for the more
|
||||
// important task of grouping BuilderBuckets together;
|
||||
// see the comments for the similar function in
|
||||
// builderBucket.cxx.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool BuilderProperties::
|
||||
operator < (const BuilderProperties &other) const {
|
||||
int sv1 = sort_value();
|
||||
int sv2 = other.sort_value();
|
||||
|
||||
if (sv1 != sv2) {
|
||||
return sv1 < sv2;
|
||||
}
|
||||
|
||||
if (_coplanar_threshold != other._coplanar_threshold) {
|
||||
return _coplanar_threshold < other._coplanar_threshold;
|
||||
}
|
||||
|
||||
if (_max_tfan_angle != other._max_tfan_angle) {
|
||||
return _max_tfan_angle < other._max_tfan_angle;
|
||||
}
|
||||
|
||||
if (_min_tfan_tris != other._min_tfan_tris) {
|
||||
return _min_tfan_tris < other._min_tfan_tris;
|
||||
}
|
||||
|
||||
if (_show_normals) {
|
||||
if (_normal_scale != other._normal_scale) {
|
||||
return _normal_scale < other._normal_scale;
|
||||
}
|
||||
if (_normal_color != other._normal_color) {
|
||||
return _normal_color < other._normal_color;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderPrimTempl::output
|
||||
// Access: Public
|
||||
// Description: Outputs the properties meaningfully.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void BuilderProperties::
|
||||
output(ostream &out) const {
|
||||
if (_mesh) {
|
||||
out << "T-Mesh using Mesher\n";
|
||||
|
||||
if (_show_tstrips) {
|
||||
out << "Color individual tristrips\n";
|
||||
} else if (_show_qsheets) {
|
||||
out << "Color individual quadsheets\n";
|
||||
} else if (_show_quads) {
|
||||
out << "Color individual quads\n";
|
||||
}
|
||||
if (_retesselate_coplanar) {
|
||||
out << "Retesselate coplanar triangles when needed; threshold = "
|
||||
<< _coplanar_threshold << "\n";
|
||||
}
|
||||
}
|
||||
if (_subdivide_polys) {
|
||||
out << "Subdivide polygons into tris.\n";
|
||||
}
|
||||
if (_consider_fans) {
|
||||
out << "Look for possible triangle fans with max per-triangle angle of "
|
||||
<< _max_tfan_angle << " degrees.\n";
|
||||
if (_min_tfan_tris==0) {
|
||||
out << "Do not create tfans";
|
||||
} else {
|
||||
out << "Do not create tfans smaller than " << _min_tfan_tris << " tris";
|
||||
}
|
||||
if (_unroll_fans) {
|
||||
out << "; retesselate to tstrips.\n";
|
||||
} else {
|
||||
out << ".\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderPrimTempl::sort_value
|
||||
// Access: Protected
|
||||
// Description: Returns a number for grouping properties. This is
|
||||
// used as a helper function to the ordering operator,
|
||||
// above. It simply collects all the booleans together
|
||||
// into a single number.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
int BuilderProperties::
|
||||
sort_value() const {
|
||||
return
|
||||
((_mesh!=0) << 8) |
|
||||
((_show_tstrips!=0) << 7) |
|
||||
((_show_qsheets!=0) << 6) |
|
||||
((_show_quads!=0) << 5) |
|
||||
((_show_normals!=0) << 4) |
|
||||
((_retesselate_coplanar!=0) << 3) |
|
||||
((_unroll_fans!=0) << 2) |
|
||||
((_subdivide_polys!=0) << 1) |
|
||||
((_consider_fans!=0) << 0);
|
||||
}
|
||||
|
|
@ -1,130 +0,0 @@
|
|||
// Filename: builderProperties.h
|
||||
// Created by: drose (17Sep97)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
#ifndef BUILDERPROPERTIES_H
|
||||
#define BUILDERPROPERTIES_H
|
||||
|
||||
#include "pandabase.h"
|
||||
|
||||
#include "builderTypes.h"
|
||||
|
||||
#ifndef HAVE_IOSTREAM
|
||||
// We assume if your C++ library defines <iostream.h>, then it also
|
||||
// defines <stl_config.h>.
|
||||
#include <stl_config.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : BuilderProperties
|
||||
// Description : A class which defines several parameters used to
|
||||
// control specific behavior of the builder and mesher.
|
||||
// BuilderBucket inherits from this class, so each of
|
||||
// these properties may be set directly on a
|
||||
// BuilderBucket to control the geometry made with just
|
||||
// that bucket. There may in this way be several
|
||||
// different sets of properties in effect at a given
|
||||
// time.
|
||||
//
|
||||
// The initial values for these are set in the private
|
||||
// constructor to BuilderBucket, at the bottom of
|
||||
// builderBucket.cxx.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_PANDAEGG BuilderProperties {
|
||||
public:
|
||||
bool operator < (const BuilderProperties &other) const;
|
||||
void output(ostream &out) const;
|
||||
|
||||
// If this is true, the mesher will be invoked to break up large
|
||||
// polygons and build triangles into tristrips wherever possible.
|
||||
bool _mesh;
|
||||
|
||||
// If this is true, a pair of adjacent coplanar triangles that form
|
||||
// a quad may be replaced with a pair of triangles forming the same
|
||||
// quad but with the opposite diagonal, if this will help the
|
||||
// building of tristrips.
|
||||
bool _retesselate_coplanar;
|
||||
|
||||
// If this is true, a coplanar fan may be treated as a single large
|
||||
// polygon, and then subdivided into a single tristrip, instead of
|
||||
// treating it as a fan. This can sometimes help form longer
|
||||
// continuous tristrips.
|
||||
bool _unroll_fans;
|
||||
|
||||
// The following three flags serve to illustrate the mesher's
|
||||
// effectiveness by coloring geometry.
|
||||
|
||||
// This colors each created triangle strip with a random color. The
|
||||
// first triangle of each strip is a little darker than the rest of
|
||||
// the strip.
|
||||
bool _show_tstrips;
|
||||
|
||||
// This colors each rectangular group of quads--called a quadsheet
|
||||
// by the mesher--with a random color. The mesher always creates
|
||||
// linear tristrips across whatever quadsheets it can identify.
|
||||
bool _show_qsheets;
|
||||
|
||||
// This colors quads blue, and doesn't mesh them further. Since a
|
||||
// large part of the mesher's algorithm is reassembling adjacent
|
||||
// triangles into quads, it's sometimes helpful to see where it
|
||||
// thinks the best quads lie.
|
||||
bool _show_quads;
|
||||
|
||||
// This shows normals created by creating little colored line
|
||||
// segments to represent each normal.
|
||||
bool _show_normals;
|
||||
double _normal_scale;
|
||||
BuilderC _normal_color;
|
||||
|
||||
// If this is true, large polygons will be subdivided into
|
||||
// triangles. Otherwise, they will remain large polygons.
|
||||
bool _subdivide_polys;
|
||||
|
||||
// This is the flatness tolerance below which two polygons will be
|
||||
// considered coplanar. Making it larger makes it easier for the
|
||||
// mesher to reverse triangle diagonals to achieve a good mesh, at
|
||||
// the expense of precision of the surface.
|
||||
double _coplanar_threshold;
|
||||
|
||||
// True if fans are to be considered at all. Sometimes making fans
|
||||
// is more trouble than they're worth, since they tend to get in the
|
||||
// way of long tristrips.
|
||||
bool _consider_fans;
|
||||
|
||||
// The maximum average angle of the apex of each triangle involved
|
||||
// in a fan. If the triangles are more loosely packed than this,
|
||||
// don't consider putting them into a fan.
|
||||
double _max_tfan_angle;
|
||||
|
||||
// The minimum number of triangles to be involved in a fan. Setting
|
||||
// this number lower results in more fans, probably at the expense
|
||||
// of tristrips. However, setting it to zero means no tfans will be
|
||||
// built (although fans may still be unrolled into tstrips if
|
||||
// _unroll_fans is true).
|
||||
int _min_tfan_tris;
|
||||
|
||||
protected:
|
||||
int sort_value() const;
|
||||
};
|
||||
|
||||
INLINE ostream &operator << (ostream &out, const BuilderProperties &props) {
|
||||
props.output(out);
|
||||
return out;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,108 +0,0 @@
|
|||
// Filename: builderTypes.cxx
|
||||
// Created by: drose (11Sep97)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "builderTypes.h"
|
||||
#include "notify.h"
|
||||
|
||||
ostream &operator << (ostream &out, BuilderAttribFlags baf) {
|
||||
const char *space = "";
|
||||
if (baf & BAF_coord) {
|
||||
out << space << "coord";
|
||||
space = " ";
|
||||
}
|
||||
if (baf & BAF_normal) {
|
||||
out << space << "normal";
|
||||
space = " ";
|
||||
}
|
||||
if (baf & BAF_color) {
|
||||
out << space << "color";
|
||||
space = " ";
|
||||
}
|
||||
if (baf & BAF_pixel_size) {
|
||||
out << space << "pixel_size";
|
||||
space = " ";
|
||||
}
|
||||
if (baf & BAF_overall_updated) {
|
||||
out << space << "overall_updated";
|
||||
space = " ";
|
||||
}
|
||||
if (baf & BAF_overall_normal) {
|
||||
out << space << "overall_normal";
|
||||
space = " ";
|
||||
}
|
||||
if (baf & BAF_overall_color) {
|
||||
out << space << "overall_color";
|
||||
space = " ";
|
||||
}
|
||||
if (baf & BAF_overall_pixel_size) {
|
||||
out << space << "overall_pixel_size";
|
||||
space = " ";
|
||||
}
|
||||
if (baf & BAF_vertex_normal) {
|
||||
out << space << "vertex_normal";
|
||||
space = " ";
|
||||
}
|
||||
if (baf & BAF_vertex_color) {
|
||||
out << space << "vertex_color";
|
||||
space = " ";
|
||||
}
|
||||
if (baf & BAF_vertex_pixel_size) {
|
||||
out << space << "vertex_pixel_size";
|
||||
space = " ";
|
||||
}
|
||||
if (baf & BAF_component_normal) {
|
||||
out << space << "component_normal";
|
||||
space = " ";
|
||||
}
|
||||
if (baf & BAF_component_color) {
|
||||
out << space << "component_color";
|
||||
space = " ";
|
||||
}
|
||||
if (baf & BAF_component_pixel_size) {
|
||||
out << space << "component_pixel_size";
|
||||
space = " ";
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
ostream &operator << (ostream &out, BuilderPrimType bpt) {
|
||||
switch (bpt) {
|
||||
case BPT_poly:
|
||||
return out << "poly";
|
||||
case BPT_point:
|
||||
return out << "point";
|
||||
case BPT_line:
|
||||
return out << "line";
|
||||
case BPT_tri:
|
||||
return out << "tri";
|
||||
case BPT_tristrip:
|
||||
return out << "tristrip";
|
||||
case BPT_trifan:
|
||||
return out << "trifan";
|
||||
case BPT_quad:
|
||||
return out << "quad";
|
||||
case BPT_quadstrip:
|
||||
return out << "quadstrip";
|
||||
case BPT_linestrip:
|
||||
return out << "linestrip";
|
||||
}
|
||||
nassertr(false, out);
|
||||
return out << "(**invalid**)";
|
||||
}
|
||||
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
// Filename: builderTypes.h
|
||||
// Created by: drose (11Sep97)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
#ifndef BUILDERTYPES_H
|
||||
#define BUILDERTYPES_H
|
||||
|
||||
#include "pandabase.h"
|
||||
|
||||
#include "luse.h"
|
||||
#include "pta_TexCoordf.h"
|
||||
#include "pta_Vertexf.h"
|
||||
#include "pta_Normalf.h"
|
||||
#include "pta_Colorf.h"
|
||||
|
||||
typedef TexCoordf BuilderTC;
|
||||
typedef Vertexf BuilderV;
|
||||
typedef Normalf BuilderN;
|
||||
typedef Colorf BuilderC;
|
||||
|
||||
typedef PTA_TexCoordf PTA_BuilderTC;
|
||||
typedef PTA_Vertexf PTA_BuilderV;
|
||||
typedef PTA_Normalf PTA_BuilderN;
|
||||
typedef PTA_Colorf PTA_BuilderC;
|
||||
|
||||
enum BuilderAttribFlags {
|
||||
BAF_coord = 0x00001,
|
||||
BAF_normal = 0x00002,
|
||||
//BAF_texcoord = 0x00004, No longer used.
|
||||
BAF_color = 0x00008,
|
||||
BAF_pixel_size = 0x00010,
|
||||
|
||||
BAF_overall_updated = 0x00100,
|
||||
BAF_overall_normal = 0x00200,
|
||||
BAF_overall_color = 0x00400,
|
||||
BAF_overall_pixel_size = 0x00800,
|
||||
|
||||
BAF_vertex_normal = 0x01000,
|
||||
//BAF_vertex_texcoord = 0x02000, No longer used.
|
||||
BAF_vertex_color = 0x04000,
|
||||
BAF_vertex_pixel_size = 0x08000,
|
||||
|
||||
BAF_component_normal = 0x10000,
|
||||
BAF_component_color = 0x20000,
|
||||
BAF_component_pixel_size = 0x04000,
|
||||
};
|
||||
|
||||
ostream &operator << (ostream &out, BuilderAttribFlags baf);
|
||||
|
||||
enum BuilderPrimType {
|
||||
BPT_poly,
|
||||
BPT_point,
|
||||
BPT_line,
|
||||
|
||||
// The following types are generated internally by the builder and
|
||||
// mesher. Normally they will not be seen by the user.
|
||||
BPT_tri,
|
||||
BPT_tristrip,
|
||||
BPT_trifan,
|
||||
BPT_quad,
|
||||
BPT_quadstrip,
|
||||
BPT_linestrip,
|
||||
};
|
||||
|
||||
ostream &operator << (ostream &out, BuilderPrimType bpt);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,278 +0,0 @@
|
|||
// Filename: builderVertex.I
|
||||
// Created by: drose (18Sep97)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "notify.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertex::set_coord_value
|
||||
// Access: Public
|
||||
// Description: Reassigns the vertex coordinate, without knowing
|
||||
// whether the vertex is indexed or nonindexed. A
|
||||
// nonindexed vertex will look up the index in the array
|
||||
// and store the resulting value, while an indexed
|
||||
// vertex will just store the index number (which
|
||||
// assumes the array is the same one it's indexing on).
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void BuilderVertex::
|
||||
set_coord_value(const BuilderV *array, ushort index) {
|
||||
set_coord(array[index]);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertex::set_normal_value
|
||||
// Access: Public
|
||||
// Description: Reassigns the vertex normal, without knowing whether
|
||||
// the vertex is indexed or nonindexed. A nonindexed
|
||||
// vertex will look up the index in the array and store
|
||||
// the resulting value, while an indexed vertex will
|
||||
// just store the index number (which assumes the array
|
||||
// is the same one it's indexing on).
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void BuilderVertex::
|
||||
set_normal_value(const BuilderN *array, ushort index) {
|
||||
set_normal(array[index]);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertex::set_texcoord_value
|
||||
// Access: Public
|
||||
// Description: Reassigns the vertex texture coordinate, without
|
||||
// knowing whether the vertex is indexed or nonindexed.
|
||||
// A nonindexed vertex will look up the index in the
|
||||
// array and store the resulting value, while an indexed
|
||||
// vertex will just store the index number (which
|
||||
// assumes the array is the same one it's indexing on).
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void BuilderVertex::
|
||||
set_texcoord_value(const InternalName *name, const BuilderTC *array, ushort index) {
|
||||
set_texcoord(name, array[index]);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertex::set_color_value
|
||||
// Access: Public
|
||||
// Description: Reassigns the vertex color, without knowing whether
|
||||
// the vertex is indexed or nonindexed. A nonindexed
|
||||
// vertex will look up the index in the array and store
|
||||
// the resulting value, while an indexed vertex will
|
||||
// just store the index number (which assumes the array
|
||||
// is the same one it's indexing on).
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void BuilderVertex::
|
||||
set_color_value(const BuilderC *array, ushort index) {
|
||||
set_color(array[index]);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertex::get_coord_value
|
||||
// Access: Public
|
||||
// Description: Returns the actual coordinate value of the vertex,
|
||||
// whether it is indexed or nonindexed. Normally, the
|
||||
// value returned by get_coord(), which will be either a
|
||||
// BuilderV or a ushort, is sufficient, but there are
|
||||
// occasional times when it is necessary to get the
|
||||
// actual location in space of the vertex position (for
|
||||
// instance, to subdivide a concave polygon).
|
||||
//
|
||||
// This function returns the actual coordinate value.
|
||||
// For a nonindexed vertex, its return value is the same
|
||||
// as get_coord(); for an indexed vertex, it looks up
|
||||
// the vertex's index in the bucket's coord array, and
|
||||
// returns that value.
|
||||
//
|
||||
// Note that this makes some perhaps unwarranted
|
||||
// assumptions about indexed geometry; specifically,
|
||||
// that its value is valid at creation time, and that it
|
||||
// won't change too drastically during runtime.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE BuilderV BuilderVertex::
|
||||
get_coord_value(const BuilderBucket &) const {
|
||||
return get_coord();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertex::get_normal_value
|
||||
// Access: Public
|
||||
// Description: Returns the actual normal value of the vertex,
|
||||
// whether it is indexed or nonindexed. See
|
||||
// get_coord_value().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE BuilderN BuilderVertex::
|
||||
get_normal_value(const BuilderBucket &) const {
|
||||
return get_normal();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertex::get_texcoord_value
|
||||
// Access: Public
|
||||
// Description: Returns the actual texture coordinate value of the
|
||||
// vertex, whether it is indexed or nonindexed. See
|
||||
// get_coord_value().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE BuilderTC BuilderVertex::
|
||||
get_texcoord_value(const InternalName *name, const BuilderBucket &) const {
|
||||
return get_texcoord(name);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertex::get_color_value
|
||||
// Access: Public
|
||||
// Description: Returns the actual color value of the vertex,
|
||||
// whether it is indexed or nonindexed. See
|
||||
// get_coord_value().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE BuilderC BuilderVertex::
|
||||
get_color_value(const BuilderBucket &) const {
|
||||
return get_color();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertex::set_coord_value
|
||||
// Access: Public
|
||||
// Description: Reassigns the vertex coordinate, without knowing
|
||||
// whether the vertex is indexed or nonindexed. A
|
||||
// nonindexed vertex will look up the index in the array
|
||||
// and store the resulting value, while an indexed
|
||||
// vertex will just store the index number (which
|
||||
// assumes the array is the same one it's indexing on).
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void BuilderVertexI::
|
||||
set_coord_value(const BuilderV *, ushort index) {
|
||||
set_coord(index);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertex::set_normal_value
|
||||
// Access: Public
|
||||
// Description: Reassigns the vertex normal, without knowing whether
|
||||
// the vertex is indexed or nonindexed. A nonindexed
|
||||
// vertex will look up the index in the array and store
|
||||
// the resulting value, while an indexed vertex will
|
||||
// just store the index number (which assumes the array
|
||||
// is the same one it's indexing on).
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void BuilderVertexI::
|
||||
set_normal_value(const BuilderN *, ushort index) {
|
||||
set_normal(index);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertex::set_texcoord_value
|
||||
// Access: Public
|
||||
// Description: Reassigns the vertex texture coordinate, without
|
||||
// knowing whether the vertex is indexed or nonindexed.
|
||||
// A nonindexed vertex will look up the index in the
|
||||
// array and store the resulting value, while an indexed
|
||||
// vertex will just store the index number (which
|
||||
// assumes the array is the same one it's indexing on).
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void BuilderVertexI::
|
||||
set_texcoord_value(const InternalName *name,const BuilderTC *, ushort index) {
|
||||
set_texcoord(name, index);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertex::set_color_value
|
||||
// Access: Public
|
||||
// Description: Reassigns the vertex color, without knowing whether
|
||||
// the vertex is indexed or nonindexed. A nonindexed
|
||||
// vertex will look up the index in the array and store
|
||||
// the resulting value, while an indexed vertex will
|
||||
// just store the index number (which assumes the array
|
||||
// is the same one it's indexing on).
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void BuilderVertexI::
|
||||
set_color_value(const BuilderC *, ushort index) {
|
||||
set_color(index);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertex::get_coord_value
|
||||
// Access: Public
|
||||
// Description: Returns the actual coordinate value of the vertex,
|
||||
// whether it is indexed or nonindexed. Normally, the
|
||||
// value returned by get_coord(), which will be either a
|
||||
// BuilderV or a ushort, is sufficient, but there are
|
||||
// occasional times when it is necessary to get the
|
||||
// actual location in space of the vertex position (for
|
||||
// instance, to subdivide a concave polygon).
|
||||
//
|
||||
// This function returns the actual coordinate value.
|
||||
// For a nonindexed vertex, its return value is the same
|
||||
// as get_coord(); for an indexed vertex, it looks up
|
||||
// the vertex's index in the bucket's coord array, and
|
||||
// returns that value.
|
||||
//
|
||||
// Note that this makes some perhaps unwarranted
|
||||
// assumptions about indexed geometry; specifically,
|
||||
// that its value is valid at creation time, and that it
|
||||
// won't change too drastically during runtime.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE BuilderV BuilderVertexI::
|
||||
get_coord_value(const BuilderBucket &bucket) const {
|
||||
nassertr(bucket.get_coords() != (Vertexf *)NULL, BuilderV());
|
||||
return bucket.get_coords()[get_coord()];
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertex::get_normal_value
|
||||
// Access: Public
|
||||
// Description: Returns the actual normal value of the vertex,
|
||||
// whether it is indexed or nonindexed. See
|
||||
// get_coord_value().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE BuilderN BuilderVertexI::
|
||||
get_normal_value(const BuilderBucket &bucket) const {
|
||||
nassertr(bucket.get_normals() != (Normalf *)NULL, BuilderN());
|
||||
return bucket.get_normals()[get_normal()];
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertex::get_texcoord_value
|
||||
// Access: Public
|
||||
// Description: Returns the actual texture coordinate value of the
|
||||
// vertex, whether it is indexed or nonindexed. See
|
||||
// get_coord_value().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE BuilderTC BuilderVertexI::
|
||||
get_texcoord_value(const InternalName *name, const BuilderBucket &bucket) const {
|
||||
nassertr(bucket.get_texcoords(name) != (TexCoordf *)NULL, BuilderTC());
|
||||
return bucket.get_texcoords(name)[get_texcoord(name)];
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertex::get_color_value
|
||||
// Access: Public
|
||||
// Description: Returns the actual color value of the vertex,
|
||||
// whether it is indexed or nonindexed. See
|
||||
// get_coord_value().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE BuilderC BuilderVertexI::
|
||||
get_color_value(const BuilderBucket &bucket) const {
|
||||
nassertr(bucket.get_colors() != (Colorf *)NULL, BuilderC());
|
||||
return bucket.get_colors()[get_color()];
|
||||
}
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
// Filename: builderVertex.cxx
|
||||
// Created by: drose (11May00)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "builderAttrib.h"
|
||||
#include "builderVertex.h"
|
||||
// Tell GCC that we'll take care of the instantiation explicitly here.
|
||||
#ifdef __GNUC__
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
|
@ -1,132 +0,0 @@
|
|||
// Filename: builderVertex.h
|
||||
// Created by: drose (18Sep97)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef BUILDERVERTEX_H
|
||||
#define BUILDERVERTEX_H
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// BuilderVertex, BuilderVertexI
|
||||
//
|
||||
// The basic class for passing vertex values to the builder. See the
|
||||
// comments at the beginning of builder.h and builderPrim.h.
|
||||
//
|
||||
// Like BuilderPrim, the BuilderVertex and BuilderVertexI classes are
|
||||
// actually two different instantiations of the same template class,
|
||||
// BuilderVertexTempl. The difference is in the types of the
|
||||
// attribute values for the four kinds of attributes: vertices
|
||||
// (coords), normals, texture coordinates, and colors. BuilderVertex
|
||||
// specifies Coordf, Normalf, TexCoordf, and Colorf for each of these
|
||||
// (actually, it's BuilderV, BuilderN, BuilderTC, and BuilderC, which
|
||||
// are simply wrappers around the above types), while BuilderVertexI
|
||||
// specifies ushort for all of them.
|
||||
//
|
||||
// It is this templating that drives the whole indexed/nonindexed
|
||||
// support in this package and in the mesher. The two kinds of
|
||||
// BuilderVertex are designed to present largely the same interface,
|
||||
// regardless of whether its component values are actual vector
|
||||
// values, or simply index numbers. Lots of things, therefore, can
|
||||
// template on the BuilderPrim type (which in turn termplates on the
|
||||
// BuilderVertex type) and thus easily support both indexed and
|
||||
// nonindexed geometry.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "pandabase.h"
|
||||
|
||||
#include "builderAttrib.h"
|
||||
#include "builderVertexTempl.h"
|
||||
#include "builderBucket.h"
|
||||
|
||||
// We need to define this temporary macro so we can pass a parameter
|
||||
// containing a comma through the macro.
|
||||
#define BUILDERVERTEXTEMPL_BUILDERV BuilderVertexTempl<BuilderV, BuilderN, BuilderTC, BuilderC>
|
||||
EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, BUILDERVERTEXTEMPL_BUILDERV);
|
||||
#define BUILDERVERTEXTEMPL_USHORT BuilderVertexTempl<ushort, ushort, ushort, ushort>
|
||||
EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, BUILDERVERTEXTEMPL_USHORT);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
// Class : BuilderVertex
|
||||
// Description : The basic class for passing nonindexed vertices to
|
||||
// the builder. See the comments at the the head of
|
||||
// this file, and in builder.h.
|
||||
//
|
||||
// Look in builderVertexTempl.h and builderAttribTempl.h
|
||||
// for most of the interface to BuilderVertex.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_PANDAEGG BuilderVertex
|
||||
: public BuilderVertexTempl<BuilderV, BuilderN, BuilderTC, BuilderC> {
|
||||
public:
|
||||
typedef BuilderAttrib Attrib;
|
||||
|
||||
BuilderVertex() {}
|
||||
BuilderVertex(const BuilderV &c) :
|
||||
BuilderVertexTempl<BuilderV, BuilderN, BuilderTC, BuilderC>(c) {}
|
||||
|
||||
INLINE void set_coord_value(const BuilderV *array, ushort index);
|
||||
INLINE void set_normal_value(const BuilderN *array, ushort index);
|
||||
INLINE void set_texcoord_value(const InternalName *name, const BuilderTC *array, ushort index);
|
||||
INLINE void set_color_value(const BuilderC *array, ushort index);
|
||||
|
||||
INLINE BuilderV get_coord_value(const BuilderBucket &bucket) const;
|
||||
INLINE BuilderN get_normal_value(const BuilderBucket &bucket) const;
|
||||
INLINE BuilderTC get_texcoord_value(const InternalName *name, const BuilderBucket &bucket) const;
|
||||
INLINE BuilderC get_color_value(const BuilderBucket &bucket) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
// Class : BuilderVertexI
|
||||
// Description : The basic class for passing indexed vertices to the
|
||||
// builder. See the comments at the the head of this
|
||||
// file, and in builder.h.
|
||||
//
|
||||
// Look in builderVertexTempl.h and builderAttribTempl.h
|
||||
// for most of the interface to BuilderVertex.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_PANDAEGG BuilderVertexI
|
||||
: public BuilderVertexTempl<ushort, ushort, ushort, ushort> {
|
||||
public:
|
||||
typedef BuilderAttribI Attrib;
|
||||
|
||||
BuilderVertexI() {}
|
||||
BuilderVertexI(ushort c) :
|
||||
BuilderVertexTempl<ushort, ushort, ushort, ushort>(c) {}
|
||||
|
||||
INLINE void set_coord_value(const BuilderV *array, ushort index);
|
||||
INLINE void set_normal_value(const BuilderN *array, ushort index);
|
||||
INLINE void set_texcoord_value(const InternalName *name, const BuilderTC *array, ushort index);
|
||||
INLINE void set_color_value(const BuilderC *array, ushort index);
|
||||
|
||||
INLINE BuilderV get_coord_value(const BuilderBucket &bucket) const;
|
||||
INLINE BuilderN get_normal_value(const BuilderBucket &bucket) const;
|
||||
INLINE BuilderTC get_texcoord_value(const InternalName *name, const BuilderBucket &bucket) const;
|
||||
INLINE BuilderC get_color_value(const BuilderBucket &bucket) const;
|
||||
};
|
||||
|
||||
#include "builderVertex.I"
|
||||
|
||||
// Tell GCC that we'll take care of the instantiation explicitly here.
|
||||
#ifdef __GNUC__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -1,434 +0,0 @@
|
|||
// Filename: builderVertexTempl.I
|
||||
// Created by: drose (11Sep97)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertexTempl::Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE BuilderVertexTempl<VT, NT, TT, CT>::
|
||||
BuilderVertexTempl() {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertexTempl::Constructor (with VType)
|
||||
// Access: Public
|
||||
// Description: Initializes the vertex coordinate with an initial
|
||||
// value. A handy constructor.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE BuilderVertexTempl<VT, NT, TT, CT>::
|
||||
BuilderVertexTempl(const VType &c) {
|
||||
set_coord(c);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertexTempl::Copy constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE BuilderVertexTempl<VT, NT, TT, CT>::
|
||||
BuilderVertexTempl(const BuilderVertexTempl ©) {
|
||||
(*this) = copy;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertexTempl::Copy assignment operator
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE BuilderVertexTempl<VT, NT, TT, CT> &BuilderVertexTempl<VT, NT, TT, CT>::
|
||||
operator = (const BuilderVertexTempl<VT, NT, TT, CT> ©) {
|
||||
BuilderAttribTempl<VT, NT, TT, CT>::operator = (copy);
|
||||
this->_coord = copy._coord;
|
||||
this->_texcoords = copy._texcoords;
|
||||
this->_pixel_size = copy._pixel_size;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertexTempl::is_valid
|
||||
// Access: Public
|
||||
// Description: Returns true if the vertex is valid, i.e. if it has a
|
||||
// vertex coordinate.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE bool BuilderVertexTempl<VT, NT, TT, CT>::
|
||||
is_valid() const {
|
||||
return has_coord();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertexTempl::clear
|
||||
// Access: Public
|
||||
// Description: Resets the vertex to its initial, empty state.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE BuilderVertexTempl<VT, NT, TT, CT> &BuilderVertexTempl<VT, NT, TT, CT>::
|
||||
clear() {
|
||||
BuilderAttribTempl<VT, NT, TT, CT>::clear();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertexTempl::has_coord
|
||||
// Access: Public
|
||||
// Description: Returns true if the vertex has a vertex coordinate.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE bool BuilderVertexTempl<VT, NT, TT, CT>::
|
||||
has_coord() const {
|
||||
return (this->_flags) & BAF_coord;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertexTempl::get_coord
|
||||
// Access: Public
|
||||
// Description: Returns the vertex's coordinate. It is an error to
|
||||
// call this without first verifying that has_coord() is
|
||||
// true.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE TYPENAME BuilderVertexTempl<VT, NT, TT, CT>::VType BuilderVertexTempl<VT, NT, TT, CT>::
|
||||
get_coord() const {
|
||||
nassertr(has_coord(), _coord);
|
||||
return _coord;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertexTempl::set_coord
|
||||
// Access: Public
|
||||
// Description: Resets the vertex's coordinate.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE BuilderVertexTempl<VT, NT, TT, CT> &BuilderVertexTempl<VT, NT, TT, CT>::
|
||||
set_coord(const VType &c) {
|
||||
this->_flags |= BAF_coord;
|
||||
this->_coord = c;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertexTempl::set_normal
|
||||
// Access: Public
|
||||
// Description: Resets the vertex's normal. This is overridden from
|
||||
// BuilderAttrib just so we can typecast the return
|
||||
// value to BuilderVertex. The other functions,
|
||||
// has_normal() and get_normal(), are inherited
|
||||
// untouched from BuilderAttrib.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE BuilderVertexTempl<VT, NT, TT, CT> &BuilderVertexTempl<VT, NT, TT, CT>::
|
||||
set_normal(const NType &n) {
|
||||
BuilderAttribTempl<VT, NT, TT, CT>::set_normal(n);
|
||||
return *this;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertexTempl::clear_normal
|
||||
// Access: Public
|
||||
// Description: Removes the vertex's normal.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE BuilderVertexTempl<VT, NT, TT, CT> &BuilderVertexTempl<VT, NT, TT, CT>::
|
||||
clear_normal() {
|
||||
BuilderAttribTempl<VT, NT, TT, CT>::clear_normal();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertexTempl::has_texcoord
|
||||
// Access: Public
|
||||
// Description: Returns true if the vertex has a texture coordinate.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE bool BuilderVertexTempl<VT, NT, TT, CT>::
|
||||
has_texcoord(const InternalName *name) const {
|
||||
TYPENAME TexCoords::const_iterator ti = _texcoords.find(name);
|
||||
return (ti != _texcoords.end());
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertexTempl::get_texcoord
|
||||
// Access: Public
|
||||
// Description: Returns the vertex's texture coordinate. It is an
|
||||
// error to call this without first verifying that
|
||||
// has_texcoord() is true.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE TYPENAME BuilderVertexTempl<VT, NT, TT, CT>::TType BuilderVertexTempl<VT, NT, TT, CT>::
|
||||
get_texcoord(const InternalName *name) const {
|
||||
TYPENAME TexCoords::const_iterator ti = _texcoords.find(name);
|
||||
nassertr(ti != _texcoords.end(), (*ti).second);
|
||||
return (*ti).second;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertexTempl::set_texcoord
|
||||
// Access: Public
|
||||
// Description: Resets the vertex's texture coordinate.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE BuilderVertexTempl<VT, NT, TT, CT> &BuilderVertexTempl<VT, NT, TT, CT>::
|
||||
set_texcoord(const InternalName *name, const TType &t) {
|
||||
_texcoords[name] = t;
|
||||
return *this;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertexTempl::clear_texcoord
|
||||
// Access: Public
|
||||
// Description: Removes the vertex's texcoord.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE BuilderVertexTempl<VT, NT, TT, CT> &BuilderVertexTempl<VT, NT, TT, CT>::
|
||||
clear_texcoord(const InternalName *name) {
|
||||
_texcoords.erase(name);
|
||||
return *this;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertexTempl::tc_begin
|
||||
// Access: Public
|
||||
// Description: Returns an iterator that can be used to walk through
|
||||
// the set of TexCoord names and their definitions.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE TYPENAME BuilderVertexTempl<VT, NT, TT, CT>::tc_const_iterator BuilderVertexTempl<VT, NT, TT, CT>::
|
||||
tc_begin() const {
|
||||
return _texcoords.begin();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertexTempl::tc_end
|
||||
// Access: Public
|
||||
// Description: Returns an iterator that can be used to walk through
|
||||
// the set of TexCoord names and their definitions.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE TYPENAME BuilderVertexTempl<VT, NT, TT, CT>::tc_const_iterator BuilderVertexTempl<VT, NT, TT, CT>::
|
||||
tc_end() const {
|
||||
return _texcoords.end();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertexTempl::tc_size
|
||||
// Access: Public
|
||||
// Description: Returns the number of TexCoord definitions.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE TYPENAME BuilderVertexTempl<VT, NT, TT, CT>::tc_size_type BuilderVertexTempl<VT, NT, TT, CT>::
|
||||
tc_size() const {
|
||||
return _texcoords.size();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertexTempl::set_color
|
||||
// Access: Public
|
||||
// Description: Resets the vertex's color. This is overridden from
|
||||
// BuilderAttrib just so we can typecast the return
|
||||
// value to BuilderVertex. The other functions,
|
||||
// has_color() and get_color(), are inherited
|
||||
// untouched from BuilderAttrib.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE BuilderVertexTempl<VT, NT, TT, CT> &BuilderVertexTempl<VT, NT, TT, CT>::
|
||||
set_color(const CType &c) {
|
||||
BuilderAttribTempl<VT, NT, TT, CT>::set_color(c);
|
||||
return *this;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertexTempl::clear_color
|
||||
// Access: Public
|
||||
// Description: Removes the vertex's color.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE BuilderVertexTempl<VT, NT, TT, CT> &BuilderVertexTempl<VT, NT, TT, CT>::
|
||||
clear_color() {
|
||||
BuilderAttribTempl<VT, NT, TT, CT>::clear_color();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertexTempl::set_pixel_size
|
||||
// Access: Public
|
||||
// Description: Resets the vertex's pixel_size. This is overridden
|
||||
// from BuilderAttrib just so we can typecast the return
|
||||
// value to BuilderVertex. The other functions,
|
||||
// has_pixel_size() and get_pixel_size(), are inherited
|
||||
// untouched from BuilderAttrib.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE BuilderVertexTempl<VT, NT, TT, CT> &BuilderVertexTempl<VT, NT, TT, CT>::
|
||||
set_pixel_size(float s) {
|
||||
BuilderAttribTempl<VT, NT, TT, CT>::set_pixel_size(s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertexTempl::clear_pixel_size
|
||||
// Access: Public
|
||||
// Description: Removes the vertex's pixel_size.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE BuilderVertexTempl<VT, NT, TT, CT> &BuilderVertexTempl<VT, NT, TT, CT>::
|
||||
clear_pixel_size() {
|
||||
BuilderAttribTempl<VT, NT, TT, CT>::clear_pixel_size();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertexTempl::operator ==
|
||||
// Access: Public
|
||||
// Description: Assigns an ordering to the vertices. This is used by
|
||||
// the Mesher to group identical vertices. This assumes
|
||||
// that all vertices in the locus of consideration will
|
||||
// share the same state: with or without normals,
|
||||
// texcoords, etc.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE bool BuilderVertexTempl<VT, NT, TT, CT>::
|
||||
operator == (const BuilderVertexTempl<VT, NT, TT, CT> &other) const {
|
||||
return compare_to(other) == 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertexTempl::operator !=
|
||||
// Access: Public
|
||||
// Description: Assigns an ordering to the vertices. This is used by
|
||||
// the Mesher to group identical vertices. This assumes
|
||||
// that all vertices in the locus of consideration will
|
||||
// share the same state: with or without normals,
|
||||
// texcoords, etc.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE bool BuilderVertexTempl<VT, NT, TT, CT>::
|
||||
operator != (const BuilderVertexTempl<VT, NT, TT, CT> &other) const {
|
||||
return !operator == (other);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertexTempl::operator <
|
||||
// Access: Public
|
||||
// Description: Assigns an ordering to the vertices. This is used by
|
||||
// the Mesher to group identical vertices. This assumes
|
||||
// that all vertices to be meshed together must share
|
||||
// the same state: with or without normals, texcoords,
|
||||
// etc.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE bool BuilderVertexTempl<VT, NT, TT, CT>::
|
||||
operator < (const BuilderVertexTempl<VT, NT, TT, CT> &other) const {
|
||||
return compare_to(other) < 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertexTempl::compare_to
|
||||
// Access: Public
|
||||
// Description: Returns a number less than zero if this vertex sorts
|
||||
// before the indicated vertex, greater than zero if it
|
||||
// sorts after, and zero if the vertices are equivalent.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
int BuilderVertexTempl<VT, NT, TT, CT>::
|
||||
compare_to(const BuilderVertexTempl<VT, NT, TT, CT> &other) const {
|
||||
if (has_coord()) {
|
||||
int coord_compare = builder_compare(_coord, other._coord);
|
||||
if (coord_compare != 0) {
|
||||
return coord_compare;
|
||||
}
|
||||
}
|
||||
|
||||
TYPENAME TexCoords::const_iterator ai, bi;
|
||||
ai = _texcoords.begin();
|
||||
bi = other._texcoords.begin();
|
||||
while (ai != _texcoords.end() && bi != other._texcoords.end()) {
|
||||
if ((*ai).first < (*bi).first) {
|
||||
return -1;
|
||||
} else if ((*bi).first < (*ai).first) {
|
||||
return 1;
|
||||
} else {
|
||||
int texcoord_compare = builder_compare((*ai).second, (*bi).second);
|
||||
if (texcoord_compare != 0) {
|
||||
return texcoord_compare;
|
||||
}
|
||||
}
|
||||
++ai;
|
||||
++bi;
|
||||
}
|
||||
if (bi != other._texcoords.end()) {
|
||||
return -1;
|
||||
}
|
||||
if (ai != _texcoords.end()) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return BuilderAttribTempl<VT, NT, TT, CT>::compare_to(other);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: BuilderVertexTempl::output
|
||||
// Access: Public
|
||||
// Description: Formats the vertex for output in some sensible way.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
ostream &BuilderVertexTempl<VT, NT, TT, CT>::
|
||||
output(ostream &out) const {
|
||||
if (this!=NULL) {
|
||||
if (this->has_coord()) {
|
||||
out << this->get_coord();
|
||||
}
|
||||
|
||||
if (this->has_normal()) {
|
||||
out << " normal " << this->get_normal();
|
||||
}
|
||||
|
||||
if (this->has_color()) {
|
||||
out << " color " << this->get_color();
|
||||
}
|
||||
|
||||
TYPENAME TexCoords::const_iterator ti;
|
||||
for (ti = _texcoords.begin(); ti != _texcoords.end(); ++ti) {
|
||||
const InternalName *name = (*ti).first;
|
||||
out << " texcoord \"" << name->get_name() << "\" " << (*ti).second;
|
||||
}
|
||||
|
||||
if (this->has_pixel_size()) {
|
||||
out << " pixel_size " << this->get_pixel_size();
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
|
@ -1,102 +0,0 @@
|
|||
// Filename: builderVertexTempl.h
|
||||
// Created by: drose (09Sep97)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef BUILDERVERTEXTEMPL_H
|
||||
#define BUILDERVERTEXTEMPL_H
|
||||
|
||||
#include "pandabase.h"
|
||||
|
||||
#include "builderTypes.h"
|
||||
#include "builderAttribTempl.h"
|
||||
#include "builder_compare.h"
|
||||
#include "internalName.h"
|
||||
#include "pointerTo.h"
|
||||
|
||||
#include "notify.h"
|
||||
#include "pvector.h"
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
// Class : BuilderVertexTempl
|
||||
// Description : The main body of BuilderVertex and BuilderVertexI.
|
||||
// This is a template class on each of the four
|
||||
// attribute types: vertex coordinates, normal, texture
|
||||
// coordinates, and color. See builderVertex.h.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
class BuilderVertexTempl : public BuilderAttribTempl<VT, NT, TT, CT> {
|
||||
public:
|
||||
typedef VT VType;
|
||||
typedef NT NType;
|
||||
typedef TT TType;
|
||||
typedef CT CType;
|
||||
typedef pmap<CPT(InternalName), TType> TexCoords;
|
||||
typedef TYPENAME TexCoords::const_iterator tc_const_iterator;
|
||||
typedef TYPENAME TexCoords::size_type tc_size_type;
|
||||
|
||||
INLINE BuilderVertexTempl();
|
||||
INLINE BuilderVertexTempl(const VType &c);
|
||||
INLINE BuilderVertexTempl(const BuilderVertexTempl ©);
|
||||
INLINE BuilderVertexTempl &operator = (const BuilderVertexTempl ©);
|
||||
|
||||
INLINE bool is_valid() const;
|
||||
INLINE BuilderVertexTempl &clear();
|
||||
|
||||
INLINE bool has_coord() const;
|
||||
INLINE VType get_coord() const;
|
||||
INLINE BuilderVertexTempl &set_coord(const VType &c);
|
||||
|
||||
INLINE BuilderVertexTempl &set_normal(const NType &c);
|
||||
INLINE BuilderVertexTempl &clear_normal();
|
||||
|
||||
INLINE bool has_texcoord(const InternalName *name) const;
|
||||
INLINE TType get_texcoord(const InternalName *name) const;
|
||||
INLINE BuilderVertexTempl &set_texcoord(const InternalName *name, const TType &t);
|
||||
INLINE BuilderVertexTempl &clear_texcoord(const InternalName *name);
|
||||
INLINE tc_const_iterator tc_begin() const;
|
||||
INLINE tc_const_iterator tc_end() const;
|
||||
INLINE tc_size_type tc_size() const;
|
||||
|
||||
INLINE BuilderVertexTempl &set_color(const CType &c);
|
||||
INLINE BuilderVertexTempl &clear_color();
|
||||
|
||||
INLINE BuilderVertexTempl &set_pixel_size(float s);
|
||||
INLINE BuilderVertexTempl &clear_pixel_size();
|
||||
|
||||
INLINE bool operator == (const BuilderVertexTempl &other) const;
|
||||
INLINE bool operator != (const BuilderVertexTempl &other) const;
|
||||
INLINE bool operator < (const BuilderVertexTempl &other) const;
|
||||
int compare_to(const BuilderVertexTempl &other) const;
|
||||
|
||||
ostream &output(ostream &out) const;
|
||||
|
||||
protected:
|
||||
VType _coord;
|
||||
TexCoords _texcoords;
|
||||
};
|
||||
|
||||
template <class VT, class NT, class TT, class CT>
|
||||
INLINE ostream &operator << (ostream &out,
|
||||
const BuilderVertexTempl<VT, NT, TT, CT> &vertex) {
|
||||
return vertex.output(out);
|
||||
}
|
||||
|
||||
|
||||
#include "builderVertexTempl.I"
|
||||
|
||||
#endif
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
// Filename: builder_compare.I
|
||||
// Created by: drose (31Jul01)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
INLINE int
|
||||
builder_compare(const LVecBase2f &a, const LVecBase2f &b) {
|
||||
return a.compare_to(b);
|
||||
}
|
||||
|
||||
INLINE int
|
||||
builder_compare(const LVecBase3f &a, const LVecBase3f &b) {
|
||||
return a.compare_to(b);
|
||||
}
|
||||
|
||||
INLINE int
|
||||
builder_compare(const LVecBase4f &a, const LVecBase4f &b) {
|
||||
return a.compare_to(b);
|
||||
}
|
||||
|
||||
INLINE int
|
||||
builder_compare(ushort a, ushort b) {
|
||||
return (int)a - (int)b;
|
||||
}
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
// Filename: builder_compare.h
|
||||
// Created by: drose (31Jul01)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef BUILDERCOMPARE_H
|
||||
#define BUILDERCOMPARE_H
|
||||
|
||||
#include "pandabase.h"
|
||||
|
||||
#include "luse.h"
|
||||
|
||||
|
||||
// This file defines some trivial functions that return strcmp-style
|
||||
// comparisonresults for the major types of our vertices. This allows
|
||||
// us to write type-independent template code to compare vertex
|
||||
// values for equivalence or order relationships.
|
||||
|
||||
INLINE int builder_compare(const LVecBase2f &a, const LVecBase2f &b);
|
||||
INLINE int builder_compare(const LVecBase3f &a, const LVecBase3f &b);
|
||||
INLINE int builder_compare(const LVecBase4f &a, const LVecBase4f &b);
|
||||
INLINE int builder_compare(ushort a, ushort b);
|
||||
|
||||
#include "builder_compare.I"
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
|
||||
#include "config_builder.cxx"
|
||||
#include "builderTypes.cxx"
|
||||
#include "builderMisc.cxx"
|
||||
#include "builder.cxx"
|
||||
#include "builderAttrib.cxx"
|
||||
#include "builderBucket.cxx"
|
||||
#include "builderBucketNode.cxx"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
|
||||
#include "builderNormalVisualizer.cxx"
|
||||
#include "builderPrim.cxx"
|
||||
#include "builderProperties.cxx"
|
||||
#include "builderVertex.cxx"
|
||||
#include "mesher.cxx"
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
// Filename: xxx_headers.h
|
||||
// Created by: georges (30May01)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "geom.h"
|
||||
#include "geomNode.h"
|
||||
#include "plist.h"
|
||||
#include "luse.h"
|
||||
#include "pmap.h"
|
||||
#include <math.h>
|
||||
#include "namedNode.h"
|
||||
#include "notify.h"
|
||||
#include "pandabase.h"
|
||||
#include "pta_Colorf.h"
|
||||
#include "pta_Normalf.h"
|
||||
#include "pta_TexCoordf.h"
|
||||
#include "pta_Vertexf.h"
|
||||
#include "pset.h"
|
||||
#include <stdlib.h>
|
||||
#include "pvector.h"
|
||||
|
||||
#include "builderAttrib.h"
|
||||
#include "builderAttribTempl.h"
|
||||
#include "builderBucket.h"
|
||||
#include "builderFuncs.h"
|
||||
#include "builderMisc.h"
|
||||
#include "builderPrim.h"
|
||||
#include "builderProperties.h"
|
||||
#include "builderTypes.h"
|
||||
#include "builderVertex.h"
|
||||
#include "mesher.h"
|
||||
#include "mesherConfig.h"
|
||||
#include "mesherEdge.h"
|
||||
#include "mesherStrip.h"
|
||||
|
||||
#pragma hdrstop
|
||||
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
// Filename: config_builder.cxx
|
||||
// Created by: drose (29Feb00)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "config_builder.h"
|
||||
#include "dconfig.h"
|
||||
|
||||
Configure(config_builder);
|
||||
NotifyCategoryDef(builder, "");
|
||||
|
||||
ConfigureFn(config_builder) {
|
||||
init_libbuilder();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: init_libbuilder
|
||||
// Description: 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_libbuilder() {
|
||||
static bool initialized = false;
|
||||
if (initialized) {
|
||||
return;
|
||||
}
|
||||
initialized = true;
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
// Filename: config_builder.h
|
||||
// Created by: drose (29Feb00)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef CONFIG_BUILDER_H
|
||||
#define CONFIG_BUILDER_H
|
||||
|
||||
#include "pandabase.h"
|
||||
#include "notifyCategoryProxy.h"
|
||||
|
||||
NotifyCategoryDecl(builder, EXPCL_PANDAEGG, EXPTP_PANDAEGG);
|
||||
|
||||
extern EXPCL_PANDAEGG void init_libbuilder();
|
||||
|
||||
#endif
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
// Filename: mesher.cxx
|
||||
// Created by: drose (11May00)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#include "mesher.h"
|
||||
|
||||
// Tell GCC that we'll take care of the instantiation explicitly here.
|
||||
#ifdef __GNUC__
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
// Filename: mesher.h
|
||||
// Created by: drose (17Sep97)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
#ifndef MESHER_H
|
||||
#define MESHER_H
|
||||
|
||||
#include "pandabase.h"
|
||||
|
||||
#include "mesherConfig.h"
|
||||
#include "mesherFanMaker.h"
|
||||
#include "mesherEdge.h"
|
||||
#include "mesherStrip.h"
|
||||
#include "mesherTempl.h"
|
||||
#include "builderPrim.h"
|
||||
|
||||
|
||||
#ifdef SUPPORT_FANS
|
||||
EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, MesherFanMaker<BuilderPrim>);
|
||||
EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, MesherFanMaker<BuilderPrimI>);
|
||||
#endif
|
||||
|
||||
EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, MesherEdge<BuilderPrim>);
|
||||
EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, MesherStrip<BuilderPrim>);
|
||||
EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, MesherTempl<BuilderPrim>);
|
||||
|
||||
EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, MesherEdge<BuilderPrimI>);
|
||||
EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, MesherStrip<BuilderPrimI>);
|
||||
EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, MesherTempl<BuilderPrimI>);
|
||||
|
||||
class EXPCL_PANDAEGG Mesher : public MesherTempl<BuilderPrim> {
|
||||
public:
|
||||
Mesher(BuilderBucket *bucket) : MesherTempl<BuilderPrim>(bucket) {}
|
||||
};
|
||||
|
||||
class EXPCL_PANDAEGG MesherI : public MesherTempl<BuilderPrimI> {
|
||||
public:
|
||||
MesherI(BuilderBucket *bucket) : MesherTempl<BuilderPrimI>(bucket) {}
|
||||
};
|
||||
|
||||
// Tell GCC that we'll take care of the instantiation explicitly here.
|
||||
#ifdef __GNUC__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
// Filename: mesherConfig.h
|
||||
// Created by: drose (27Oct00)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
#ifndef MESHERCONFIG_H
|
||||
#define MESHERCONFIG_H
|
||||
|
||||
#include "pandabase.h"
|
||||
|
||||
// This is just a file to declare a definition or two global to the
|
||||
// mesher compilation.
|
||||
|
||||
// Define this to support making triangle fans in addition to triangle
|
||||
// strips. Fans may improve the grouping in certain models, although
|
||||
// in most real cases the don't seem to help very much (and can
|
||||
// actually hurt, by bitching the heuristic).
|
||||
#define SUPPORT_FANS
|
||||
|
||||
// Define this to enable code to visualize the normals when generating
|
||||
// primitives. This creates line segment geometry to show each normal
|
||||
// as the primitives are created.
|
||||
#define SUPPORT_SHOW_NORMALS
|
||||
|
||||
#endif
|
||||
|
|
@ -1,162 +0,0 @@
|
|||
// Filename: mesherEdge.I
|
||||
// Created by: drose (15Sep97)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
template <class PrimType>
|
||||
INLINE MesherEdge<PrimType>::
|
||||
MesherEdge(const Vertex *a, const Vertex *b) : _a(a), _b(b) {
|
||||
_opposite = NULL;
|
||||
}
|
||||
|
||||
template <class PrimType>
|
||||
INLINE MesherEdge<PrimType>::
|
||||
MesherEdge(const MesherEdge ©) :
|
||||
_a(copy._a),
|
||||
_b(copy._b),
|
||||
_strips(copy._strips),
|
||||
_opposite(copy._opposite)
|
||||
{
|
||||
}
|
||||
|
||||
template <class PrimType>
|
||||
INLINE bool MesherEdge<PrimType>::
|
||||
contains_vertex(const Vertex *v) const {
|
||||
return (_a==v || _b==v);
|
||||
}
|
||||
|
||||
|
||||
template <class PrimType>
|
||||
INLINE bool MesherEdge<PrimType>::
|
||||
matches(const MesherEdge &other) const {
|
||||
return (_a == other._a && _b == other._b) ||
|
||||
(_b == other._a && _a == other._b);
|
||||
}
|
||||
|
||||
template <class PrimType>
|
||||
INLINE MesherEdge<PrimType> *MesherEdge<PrimType>::
|
||||
common_ptr() {
|
||||
return min(this, _opposite);
|
||||
}
|
||||
|
||||
template <class PrimType>
|
||||
INLINE bool MesherEdge<PrimType>::
|
||||
operator == (const MesherEdge &other) const {
|
||||
return _a == other._a && _b == other._b;
|
||||
}
|
||||
|
||||
template <class PrimType>
|
||||
INLINE bool MesherEdge<PrimType>::
|
||||
operator != (const MesherEdge &other) const {
|
||||
return !operator == (other);
|
||||
}
|
||||
|
||||
template <class PrimType>
|
||||
INLINE bool MesherEdge<PrimType>::
|
||||
operator < (const MesherEdge &other) const {
|
||||
return _a < other._a || (_a == other._a && _b < other._b);
|
||||
}
|
||||
|
||||
template <class PrimType>
|
||||
INLINE float MesherEdge<PrimType>::
|
||||
compute_length(const BuilderBucket &bucket) const {
|
||||
LVector3f v = ((const Vertexf &)_a->get_coord_value(bucket) -
|
||||
(const Vertexf &)_b->get_coord_value(bucket));
|
||||
return length(v);
|
||||
}
|
||||
|
||||
template <class PrimType>
|
||||
INLINE Vertexf MesherEdge<PrimType>::
|
||||
compute_box(const BuilderBucket &bucket) const {
|
||||
LVector3f v = ((const Vertexf &)_a->get_coord_value(bucket) -
|
||||
(const Vertexf &)_b->get_coord_value(bucket));
|
||||
return Vertexf(fabs(v[0]), fabs(v[1]), fabs(v[2]));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MesherEdge::remove
|
||||
// Access: Public
|
||||
// Description: Removes an edge from a particular strip.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class PrimType>
|
||||
void MesherEdge<PrimType>::
|
||||
remove(Strip *strip) {
|
||||
strip->_edges.remove(this);
|
||||
strip->_edges.remove(_opposite);
|
||||
|
||||
_strips.remove(strip);
|
||||
_opposite->_strips.remove(strip);
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MesherEdge::change_strip
|
||||
// Access: Public
|
||||
// Description: Reparents the edge from strip "from" to strip "to".
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class PrimType>
|
||||
void MesherEdge<PrimType>::
|
||||
change_strip(Strip *from, Strip *to) {
|
||||
TYPENAME Strips::iterator si;
|
||||
|
||||
for (si = _strips.begin(); si != _strips.end(); ++si) {
|
||||
if (*si == from) {
|
||||
*si = to;
|
||||
}
|
||||
}
|
||||
|
||||
for (si = _opposite->_strips.begin();
|
||||
si != _opposite->_strips.end();
|
||||
++si) {
|
||||
if (*si == from) {
|
||||
*si = to;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MesherEdge::output
|
||||
// Access: Public
|
||||
// Description: Formats the edge for output in some sensible way.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class PrimType>
|
||||
ostream &MesherEdge<PrimType>::
|
||||
output(ostream &out) const {
|
||||
out << "Edge [" << *_a << " to " << *_b << "], "
|
||||
<< _strips.size() << " strips:";
|
||||
|
||||
TYPENAME Strips::const_iterator si;
|
||||
for (si = _strips.begin(); si != _strips.end(); ++si) {
|
||||
out << " " << (*si)->_index;
|
||||
}
|
||||
|
||||
if (_opposite!=NULL) {
|
||||
out << " opposite "
|
||||
<< _opposite->_strips.size() << " strips:";
|
||||
|
||||
for (si = _opposite->_strips.begin();
|
||||
si != _opposite->_strips.end();
|
||||
++si) {
|
||||
out << " " << (*si)->_index;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
// Filename: mesherEdge.h
|
||||
// Created by: drose (15Sep97)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef MESHEREDGE_H
|
||||
#define MESHEREDGE_H
|
||||
|
||||
#include "pandabase.h"
|
||||
|
||||
#include "mesherConfig.h"
|
||||
#include "builderBucket.h"
|
||||
|
||||
#include "plist.h"
|
||||
#include <math.h>
|
||||
|
||||
|
||||
template <class PrimType>
|
||||
class MesherStrip;
|
||||
|
||||
template <class PrimType>
|
||||
class MesherEdge {
|
||||
public:
|
||||
typedef PrimType Prim;
|
||||
typedef TYPENAME PrimType::Vertex Vertex;
|
||||
typedef MesherStrip<PrimType> Strip;
|
||||
|
||||
INLINE MesherEdge(const Vertex *a, const Vertex *b);
|
||||
INLINE MesherEdge(const MesherEdge ©);
|
||||
|
||||
void remove(Strip *strip);
|
||||
void change_strip(Strip *from, Strip *to);
|
||||
|
||||
INLINE bool contains_vertex(const Vertex *v) const;
|
||||
|
||||
INLINE bool matches(const MesherEdge &other) const;
|
||||
|
||||
INLINE MesherEdge *common_ptr();
|
||||
|
||||
INLINE bool operator == (const MesherEdge &other) const;
|
||||
INLINE bool operator != (const MesherEdge &other) const;
|
||||
INLINE bool operator < (const MesherEdge &other) const;
|
||||
|
||||
INLINE float compute_length(const BuilderBucket &bucket) const;
|
||||
INLINE Vertexf compute_box(const BuilderBucket &bucket) const;
|
||||
|
||||
ostream &output(ostream &out) const;
|
||||
|
||||
const Vertex *_a, *_b;
|
||||
|
||||
typedef plist<Strip *> Strips;
|
||||
Strips _strips;
|
||||
MesherEdge *_opposite;
|
||||
};
|
||||
|
||||
template <class PrimType>
|
||||
INLINE ostream &operator << (ostream &out,
|
||||
const MesherEdge<PrimType> &edge) {
|
||||
return edge.output(out);
|
||||
}
|
||||
|
||||
#include "mesherEdge.I"
|
||||
|
||||
#endif
|
||||
|
|
@ -1,394 +0,0 @@
|
|||
// Filename: mesherFanMaker.I
|
||||
// Created by: drose (21Sep97)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
/* okcircular */
|
||||
#include "builderFuncs.h"
|
||||
|
||||
#include "notify.h"
|
||||
#include "mathNumbers.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MesherFanMaker::Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class PrimType>
|
||||
MesherFanMaker<PrimType>::
|
||||
MesherFanMaker(const Vertex *vertex, Strip *tri, Mesher *mesher) {
|
||||
_vertex = vertex;
|
||||
const Edge *edge = tri->find_opposite_edge(vertex);
|
||||
if (edge != (const Edge *)NULL) {
|
||||
_edges.push_back(edge);
|
||||
}
|
||||
_strips.push_back(tri);
|
||||
_planar = tri->_planar;
|
||||
_mesher = mesher;
|
||||
_bucket = _mesher->_bucket;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MesherFanMaker::Copy Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class PrimType>
|
||||
MesherFanMaker<PrimType>::
|
||||
MesherFanMaker(const MesherFanMaker<PrimType> ©) :
|
||||
_vertex(copy._vertex),
|
||||
_edges(copy._edges),
|
||||
_strips(copy._strips),
|
||||
_planar(copy._planar),
|
||||
_bucket(copy._bucket),
|
||||
_mesher(copy._mesher)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MesherFanMaker::Copy Assignment Operator
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class PrimType>
|
||||
void MesherFanMaker<PrimType>::
|
||||
operator = (const MesherFanMaker<PrimType> ©) {
|
||||
_vertex = copy._vertex;
|
||||
_edges = copy._edges;
|
||||
_strips = copy._strips;
|
||||
_planar = copy._planar;
|
||||
_bucket = copy._bucket;
|
||||
_mesher = copy._mesher;
|
||||
}
|
||||
|
||||
template <class PrimType>
|
||||
INLINE bool MesherFanMaker<PrimType>::
|
||||
operator < (const MesherFanMaker &other) const {
|
||||
nassertr(!_edges.empty() && !other._edges.empty(), false);
|
||||
return _edges.front() < other._edges.front();
|
||||
}
|
||||
|
||||
template <class PrimType>
|
||||
INLINE bool MesherFanMaker<PrimType>::
|
||||
operator != (const MesherFanMaker &other) const {
|
||||
return !operator == (other);
|
||||
}
|
||||
|
||||
template <class PrimType>
|
||||
INLINE bool MesherFanMaker<PrimType>::
|
||||
operator == (const MesherFanMaker &other) const {
|
||||
return _edges.front() == other._edges.front();
|
||||
}
|
||||
|
||||
template <class PrimType>
|
||||
INLINE bool MesherFanMaker<PrimType>::
|
||||
is_empty() const {
|
||||
return (_edges.empty());
|
||||
}
|
||||
|
||||
template <class PrimType>
|
||||
INLINE bool MesherFanMaker<PrimType>::
|
||||
is_valid() const {
|
||||
return (_edges.size() > 2);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MesherFanMaker::is_coplanar_with
|
||||
// Access: Public
|
||||
// Description: Returns true if the strip and the other strip are
|
||||
// coplanar.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class PrimType>
|
||||
INLINE bool MesherFanMaker<PrimType>::
|
||||
is_coplanar_with(const MesherFanMaker &other) const {
|
||||
return _planar && other._planar &&
|
||||
_strips.front()->is_coplanar_with(*other._strips.front(),
|
||||
_bucket->_coplanar_threshold);
|
||||
}
|
||||
|
||||
template <class PrimType>
|
||||
bool MesherFanMaker<PrimType>::
|
||||
join(MesherFanMaker &other) {
|
||||
nassertr(_vertex == other._vertex, false);
|
||||
nassertr(_mesher == other._mesher, false);
|
||||
nassertr(_bucket == other._bucket, false);
|
||||
|
||||
nassertr(!_edges.empty() && !other._edges.empty(), false);
|
||||
|
||||
const Edge *my_back = _edges.back();
|
||||
const Edge *other_front = other._edges.front();
|
||||
nassertr(my_back != (Edge *)NULL && other_front != (Edge *)NULL, false);
|
||||
|
||||
const Vertex *my_back_b = my_back->_b;
|
||||
const Vertex *other_front_a = other_front->_a;
|
||||
|
||||
if (my_back_b == other_front_a) {
|
||||
_planar = is_coplanar_with(other);
|
||||
_edges.splice(_edges.end(), other._edges);
|
||||
_strips.splice(_strips.end(), other._strips);
|
||||
return true;
|
||||
}
|
||||
|
||||
const Edge *my_front = _edges.front();
|
||||
const Edge *other_back = other._edges.back();
|
||||
nassertr(my_front != (Edge *)NULL && other_back != (Edge *)NULL, false);
|
||||
|
||||
const Vertex *my_front_a = my_front->_a;
|
||||
const Vertex *other_back_b = other_back->_b;
|
||||
|
||||
if (my_front_a == other_back_b) {
|
||||
_planar = is_coplanar_with(other);
|
||||
_edges.splice(_edges.begin(), other._edges);
|
||||
_strips.splice(_strips.begin(), other._strips);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
template <class PrimType>
|
||||
float MesherFanMaker<PrimType>::
|
||||
compute_angle() const {
|
||||
// We sum up the angles of each triangle. This is more correct than
|
||||
// taking the net angle from the first edge to the last (since we
|
||||
// may not be in a plane).
|
||||
nassertr(is_valid(), 0.0);
|
||||
|
||||
double angle = 0.0;
|
||||
Vertexf v0 = _vertex->get_coord_value(*_bucket);
|
||||
|
||||
TYPENAME Edges::const_iterator ei;
|
||||
for (ei = _edges.begin(); ei != _edges.end(); ++ei) {
|
||||
Normalf v1 = (*ei)->_a->get_coord_value(*_bucket) - v0;
|
||||
Normalf v2 = (*ei)->_b->get_coord_value(*_bucket) - v0;
|
||||
|
||||
v1 = normalize(v1);
|
||||
v2 = normalize(v2);
|
||||
angle += acos(dot(v1, v2));
|
||||
}
|
||||
|
||||
return rad_2_deg(angle);
|
||||
}
|
||||
|
||||
template <class PrimType>
|
||||
int MesherFanMaker<PrimType>::
|
||||
build(pvector<Prim> &unrolled_tris) {
|
||||
nassertr(_edges.size() == _strips.size(), 0);
|
||||
|
||||
int num_tris = _edges.size();
|
||||
float net_angle = compute_angle();
|
||||
float avg_angle = net_angle / num_tris;
|
||||
|
||||
if (avg_angle > _bucket->_max_tfan_angle) {
|
||||
// The triangles are too loose to justify making a fan; it'll
|
||||
// probably make a better quadsheet.
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (_bucket->_min_tfan_tris==0 || num_tris < _bucket->_min_tfan_tris) {
|
||||
// Oops, not enough triangles to justify a fan.
|
||||
if (!_bucket->_unroll_fans) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// However, we could (maybe) make it a few tristrips!
|
||||
|
||||
// Each section of the fan which is made up of coplanar tris with
|
||||
// identical properties may be retesselated into a tristrip. What
|
||||
// a sneaky trick! To do this, we must first identify each such
|
||||
// qualifying section.
|
||||
|
||||
// We define a seam as the edge between any two tris which are
|
||||
// noncoplanar or which do not share identical properties. Then
|
||||
// we can send each piece between the seams to unroll().
|
||||
|
||||
TYPENAME Strips::iterator si, last_si;
|
||||
TYPENAME Edges::iterator ei, last_ei;
|
||||
|
||||
// First, rotate the fan so it begins at a seam. We do this so we
|
||||
// won't be left out with part of one piece at the beginning and
|
||||
// also at the end.
|
||||
si = _strips.begin();
|
||||
last_si = si;
|
||||
ei = _edges.begin();
|
||||
last_ei = ei;
|
||||
int found_seam = false;
|
||||
|
||||
for (++si, ++ei; si != _strips.end() && !found_seam; ++si, ++ei) {
|
||||
nassertr(ei != _edges.end(), 0);
|
||||
if ( !((*si)->_prims.front() == (*last_si)->_prims.front()) ||
|
||||
!(*si)->is_coplanar_with(*(*last_si), _bucket->_coplanar_threshold)) {
|
||||
// Here's a seam. Break the fan here.
|
||||
found_seam = true;
|
||||
_edges.splice(_edges.begin(), _edges, ei, _edges.end());
|
||||
_strips.splice(_strips.begin(), _strips, si, _strips.end());
|
||||
}
|
||||
}
|
||||
|
||||
// Now break the fan up along its seams and unroll each piece
|
||||
// separately.
|
||||
si = _strips.begin();
|
||||
last_si = si;
|
||||
ei = _edges.begin();
|
||||
last_ei = ei;
|
||||
|
||||
int count = 0;
|
||||
for (++si, ++ei; si != _strips.end(); ++si, ++ei) {
|
||||
nassertr(ei != _edges.end(), 0);
|
||||
if ( !((*si)->_prims.front() == (*last_si)->_prims.front()) ||
|
||||
!(*si)->is_coplanar_with(*(*last_si), _bucket->_coplanar_threshold)) {
|
||||
// Here's the end of a run of matching pieces.
|
||||
count += unroll(last_si, si, last_ei, ei, unrolled_tris);
|
||||
last_si = si;
|
||||
last_ei = ei;
|
||||
}
|
||||
}
|
||||
count += unroll(last_si, si, last_ei, ei, unrolled_tris);
|
||||
|
||||
return count;
|
||||
|
||||
} else {
|
||||
Strip new_fan;
|
||||
new_fan._type = BPT_trifan;
|
||||
new_fan._verts.push_back(_vertex);
|
||||
|
||||
new_fan._verts.push_back(_edges.front()->_a);
|
||||
TYPENAME Edges::iterator ei;
|
||||
for (ei = _edges.begin(); ei != _edges.end(); ++ei) {
|
||||
new_fan._verts.push_back((*ei)->_b);
|
||||
}
|
||||
|
||||
TYPENAME Strips::iterator si;
|
||||
for (si = _strips.begin(); si != _strips.end(); ++si) {
|
||||
new_fan._prims.splice(new_fan._prims.end(), (*si)->_prims);
|
||||
(*si)->remove_all_edges();
|
||||
(*si)->_verts.clear();
|
||||
(*si)->_status = MS_dead;
|
||||
}
|
||||
|
||||
// If we'd built our list of edges and strips right, this sum should
|
||||
// come out so that there are two more vertices than triangles in
|
||||
// the new fan.
|
||||
nassertr(new_fan._verts.size() == new_fan._prims.size() + 2, 0);
|
||||
|
||||
// Now we've built a fan, and it won't be able to mate with
|
||||
// anything else, so add it to the done list.
|
||||
_mesher->_done.push_back(new_fan);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <class PrimType>
|
||||
int MesherFanMaker<PrimType>::
|
||||
unroll(TYPENAME Strips::iterator strip_begin, TYPENAME Strips::iterator strip_end,
|
||||
TYPENAME Edges::iterator edge_begin, TYPENAME Edges::iterator edge_end,
|
||||
pvector<Prim> &unrolled_tris) {
|
||||
TYPENAME Edges::iterator ei;
|
||||
TYPENAME Strips::iterator si;
|
||||
|
||||
int num_tris = 0;
|
||||
for (ei = edge_begin; ei != edge_end; ++ei) {
|
||||
num_tris++;
|
||||
}
|
||||
|
||||
if (num_tris < 3) {
|
||||
// Don't even bother.
|
||||
return 0;
|
||||
}
|
||||
|
||||
Prim poly;
|
||||
|
||||
// Now we build an n-sided polygon. We'll decompose it into tris
|
||||
// in a second.
|
||||
poly.set_type(BPT_poly);
|
||||
poly.set_attrib((*strip_begin)->_prims.front());
|
||||
|
||||
ei = edge_end;
|
||||
--ei;
|
||||
if ( !((*ei)->_b == (*edge_begin)->_a)) {
|
||||
// If the fan is less than a full circle, we need to keep the
|
||||
// hub vertex and initial vertex in the poly. Otherwise, we'll
|
||||
// discard them.
|
||||
poly.add_vertex(*_vertex);
|
||||
poly.add_vertex(*(*edge_begin)->_a);
|
||||
}
|
||||
|
||||
for (ei = edge_begin; ei != edge_end; ++ei) {
|
||||
poly.add_vertex(*(*ei)->_b);
|
||||
}
|
||||
|
||||
int result = true;
|
||||
|
||||
if (_bucket->_show_quads) {
|
||||
// If we're showing quads, also show retesselated triangles.
|
||||
|
||||
// We can't add it directly to the mesher, that's unsafe; instead,
|
||||
// we'll just add it to the end of the unrolled_tris list. This
|
||||
// does mean we won't be able to color it a fancy color, but too
|
||||
// bad.
|
||||
//_mesher->add_prim(poly, MO_fanpoly);
|
||||
unrolled_tris.push_back(poly);
|
||||
|
||||
} else {
|
||||
// Now decompose the new polygon into triangles.
|
||||
pvector<Prim> tris;
|
||||
result = expand(poly, *_bucket, back_inserter(tris));
|
||||
|
||||
if (result) {
|
||||
unrolled_tris.insert(unrolled_tris.end(),
|
||||
tris.begin(), tris.end());
|
||||
}
|
||||
}
|
||||
|
||||
if (result) {
|
||||
// Now that we've created a new poly, kill off all the old ones.
|
||||
for (si = strip_begin; si != strip_end; ++si) {
|
||||
(*si)->remove_all_edges();
|
||||
(*si)->_verts.clear();
|
||||
(*si)->_prims.clear();
|
||||
(*si)->_status = MS_dead;
|
||||
}
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
template <class PrimType>
|
||||
ostream &MesherFanMaker<PrimType>::
|
||||
output(ostream &out) const {
|
||||
out << *_vertex << ":[";
|
||||
if (!_edges.empty()) {
|
||||
TYPENAME Edges::const_iterator ei;
|
||||
for (ei = _edges.begin(); ei != _edges.end(); ++ei) {
|
||||
out << " " << *(*ei)->_a;
|
||||
}
|
||||
out << " " << *_edges.back()->_b;
|
||||
}
|
||||
out << " ]";
|
||||
|
||||
if (_planar) {
|
||||
out << " (planar)";
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
|
@ -1,94 +0,0 @@
|
|||
// Filename: mesherFanMaker.h
|
||||
// Created by: drose (21Sep97)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef MESHERFANMAKER_H
|
||||
#define MESHERFANMAKER_H
|
||||
|
||||
#ifdef SUPPORT_FANS
|
||||
|
||||
#include "pandabase.h"
|
||||
|
||||
#include "mesherConfig.h"
|
||||
#include "builderAttrib.h"
|
||||
#include "builderVertex.h"
|
||||
#include "builderBucket.h"
|
||||
#include "mesherEdge.h"
|
||||
#include "mesherStrip.h"
|
||||
|
||||
#include "plist.h"
|
||||
#include "pvector.h"
|
||||
|
||||
|
||||
template <class PrimType>
|
||||
class MesherTempl;
|
||||
|
||||
template <class PrimType>
|
||||
class MesherFanMaker {
|
||||
public:
|
||||
typedef PrimType Prim;
|
||||
typedef TYPENAME PrimType::Vertex Vertex;
|
||||
typedef TYPENAME PrimType::DAttrib FAttrib;
|
||||
typedef MesherEdge<PrimType> Edge;
|
||||
typedef MesherStrip<PrimType> Strip;
|
||||
typedef MesherTempl<PrimType> Mesher;
|
||||
|
||||
typedef plist<const Edge *> Edges;
|
||||
typedef plist<Strip *> Strips;
|
||||
|
||||
MesherFanMaker() {}
|
||||
MesherFanMaker(const Vertex *vertex, Strip *tri, Mesher *mesher);
|
||||
MesherFanMaker(const MesherFanMaker<PrimType> ©);
|
||||
void operator = (const MesherFanMaker<PrimType> ©);
|
||||
|
||||
INLINE bool operator < (const MesherFanMaker &other) const;
|
||||
INLINE bool operator != (const MesherFanMaker &other) const;
|
||||
INLINE bool operator == (const MesherFanMaker &other) const;
|
||||
|
||||
INLINE bool is_empty() const;
|
||||
INLINE bool is_valid() const;
|
||||
INLINE bool is_coplanar_with(const MesherFanMaker &other) const;
|
||||
|
||||
bool join(MesherFanMaker &other);
|
||||
float compute_angle() const;
|
||||
|
||||
int build(pvector<Prim> &unrolled_tris);
|
||||
int unroll(TYPENAME Strips::iterator strip_begin, TYPENAME Strips::iterator strip_end,
|
||||
TYPENAME Edges::iterator edge_begin, TYPENAME Edges::iterator edge_end,
|
||||
pvector<Prim> &unrolled_tris);
|
||||
|
||||
ostream &output(ostream &out) const;
|
||||
|
||||
|
||||
const Vertex *_vertex;
|
||||
Edges _edges;
|
||||
Strips _strips;
|
||||
int _planar;
|
||||
BuilderBucket *_bucket;
|
||||
Mesher *_mesher;
|
||||
};
|
||||
|
||||
template <class PrimType>
|
||||
ostream &operator << (ostream &out, const MesherFanMaker<PrimType> &fe) {
|
||||
return fe.output(out);
|
||||
}
|
||||
|
||||
#include "mesherFanMaker.I"
|
||||
|
||||
#endif // SUPPORT_FANS
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,149 +0,0 @@
|
|||
// Filename: mesherStrip.h
|
||||
// Created by: drose (16Sep97)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef MESHERSTRIP_H
|
||||
#define MESHERSTRIP_H
|
||||
|
||||
#include "pandabase.h"
|
||||
|
||||
#include "mesherConfig.h"
|
||||
#include "builderTypes.h"
|
||||
#include "builderBucket.h"
|
||||
#include "config_builder.h"
|
||||
|
||||
#include "plist.h"
|
||||
#include <math.h>
|
||||
|
||||
|
||||
template <class PrimType>
|
||||
class MesherEdge;
|
||||
|
||||
template <class PrimType>
|
||||
class MesherTempl;
|
||||
|
||||
enum MesherStripStatus {
|
||||
MS_alive, MS_dead, MS_done, MS_paired
|
||||
};
|
||||
|
||||
enum MesherStripOrigin {
|
||||
MO_unknown, MO_user, MO_firstquad, MO_fanpoly, MO_mate
|
||||
};
|
||||
|
||||
template <class PrimType>
|
||||
class MesherStrip {
|
||||
public:
|
||||
typedef PrimType Prim;
|
||||
typedef TYPENAME PrimType::Vertex Vertex;
|
||||
typedef TYPENAME PrimType::DAttrib SAttrib;
|
||||
typedef MesherEdge<PrimType> Edge;
|
||||
|
||||
MesherStrip() {}
|
||||
MesherStrip(const PrimType &prim, int index, const BuilderBucket &bucket);
|
||||
INLINE MesherStrip(const MesherStrip ©);
|
||||
|
||||
Prim make_prim(const BuilderBucket &bucket);
|
||||
|
||||
void measure_sheet(const Edge *edge, int new_row,
|
||||
int &num_prims, int &num_rows,
|
||||
int first_row_id, int this_row_id,
|
||||
int this_row_distance);
|
||||
void cut_sheet(int first_row_id, int do_mate,
|
||||
const BuilderBucket &bucket);
|
||||
|
||||
bool mate(const BuilderBucket &bucket);
|
||||
bool find_ideal_mate(MesherStrip *&mate, Edge *&common_edge,
|
||||
const BuilderBucket &bucket);
|
||||
static bool mate_pieces(Edge *common_edge, MesherStrip &front,
|
||||
MesherStrip &back, const BuilderBucket &bucket);
|
||||
static bool mate_strips(Edge *common_edge, MesherStrip &front,
|
||||
MesherStrip &back, BuilderPrimType type);
|
||||
static bool must_invert(const MesherStrip &front, const MesherStrip &back,
|
||||
bool will_reverse_back, BuilderPrimType type);
|
||||
static bool convex_quad(Edge *common_edge, MesherStrip &front,
|
||||
MesherStrip &back, const BuilderBucket &bucket);
|
||||
|
||||
int count_neighbors() const;
|
||||
ostream &show_neighbors(ostream &out) const;
|
||||
|
||||
INLINE bool is_coplanar_with(const MesherStrip &other, float threshold) const;
|
||||
INLINE float coplanarity(const MesherStrip &other) const;
|
||||
INLINE int type_category() const;
|
||||
|
||||
const Vertex *find_uncommon_vertex(const Edge *edge) const;
|
||||
const Edge *find_opposite_edge(const Vertex *vertex) const;
|
||||
const Edge *find_opposite_edge(const Edge *edge) const;
|
||||
const Edge *find_adjacent_edge(const Edge *edge) const;
|
||||
|
||||
INLINE void rotate_forward();
|
||||
INLINE void rotate_back();
|
||||
void rotate_to_front(const Edge *edge);
|
||||
void rotate_to_back(const Edge *edge);
|
||||
bool can_invert() const;
|
||||
bool invert();
|
||||
|
||||
INLINE Edge get_head_edge() const;
|
||||
INLINE Edge get_tail_edge() const;
|
||||
|
||||
bool is_odd() const;
|
||||
bool would_reverse_tail(BuilderPrimType wantType) const;
|
||||
void convert_to_type(BuilderPrimType wantType);
|
||||
|
||||
void combine_edges(MesherStrip<PrimType> &other, int removeSides);
|
||||
void remove_all_edges();
|
||||
|
||||
// ptr equality
|
||||
INLINE bool operator == (const MesherStrip &other) const;
|
||||
INLINE bool operator != (const MesherStrip &other) const;
|
||||
|
||||
bool pick_mate(const MesherStrip &a_strip, const MesherStrip &b_strip,
|
||||
const Edge &a_edge, const Edge &b_edge,
|
||||
const BuilderBucket &bucket) const;
|
||||
|
||||
bool pick_sheet_mate(const MesherStrip &a_strip,
|
||||
const MesherStrip &b_strip) const;
|
||||
|
||||
ostream &output(ostream &out) const;
|
||||
|
||||
typedef plist<SAttrib> Prims;
|
||||
typedef plist<Edge *> Edges;
|
||||
typedef plist<const Vertex *> Verts;
|
||||
|
||||
Prims _prims;
|
||||
Edges _edges;
|
||||
Verts _verts;
|
||||
|
||||
BuilderPrimType _type;
|
||||
int _index;
|
||||
MesherStripStatus _status;
|
||||
|
||||
int _planar;
|
||||
LVector3f _plane_normal;
|
||||
float _plane_offset;
|
||||
int _row_id, _row_distance;
|
||||
int _origin;
|
||||
};
|
||||
|
||||
template <class PrimType>
|
||||
INLINE ostream &operator << (ostream &out,
|
||||
const MesherStrip<PrimType> &strip) {
|
||||
return strip.output(out);
|
||||
}
|
||||
|
||||
#include "mesherStrip.I"
|
||||
|
||||
#endif
|
||||
|
|
@ -1,692 +0,0 @@
|
|||
// Filename: mesherTempl.I
|
||||
// Created by: drose (15Sep97)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "builderMisc.h"
|
||||
#include "mesherStrip.h"
|
||||
#include "mesherFanMaker.h"
|
||||
#include "config_builder.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
template <class PrimType>
|
||||
MesherTempl<PrimType>::
|
||||
MesherTempl(BuilderBucket *bucket) {
|
||||
_bucket = bucket;
|
||||
_stripIndex = 0;
|
||||
_next_strip = _done.end();
|
||||
}
|
||||
|
||||
template <class PrimType>
|
||||
int MesherTempl<PrimType>::
|
||||
add_prim(const Prim &prim, MesherStripOrigin origin) {
|
||||
if (!prim.is_valid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Define an initial strip (probably of length 1) for the prim.
|
||||
Strip temp_strip(prim, _stripIndex++, *_bucket);
|
||||
Strips &list = choose_strip_list(temp_strip);
|
||||
list.push_back(temp_strip);
|
||||
Strip &strip = list.back();
|
||||
strip._origin = origin;
|
||||
|
||||
int i;
|
||||
int num_verts = prim.get_num_verts();
|
||||
|
||||
const Vertex **vptrs = (const Vertex **)alloca(num_verts * sizeof(Vertex *));
|
||||
EdgePtrs **eptrs = (EdgePtrs **)alloca(num_verts * sizeof(EdgePtrs *));
|
||||
|
||||
// Get the common vertex pointers for the primitive's vertices.
|
||||
for (i = 0; i < num_verts; i++) {
|
||||
TYPENAME Verts::value_type v(prim.get_vertex(i), EdgePtrs());
|
||||
TYPENAME Verts::iterator n = _verts.insert(v).first;
|
||||
|
||||
vptrs[i] = &(*n).first;
|
||||
eptrs[i] = &(*n).second;
|
||||
|
||||
strip._verts.push_back(vptrs[i]);
|
||||
}
|
||||
|
||||
// Now identify the common edges.
|
||||
if (prim.get_type() == BPT_tri || prim.get_type() == BPT_quad) {
|
||||
// Polygons of arbitrary size don't get meshed, and so therefore
|
||||
// don't have any edges in common with anything else. Only tris
|
||||
// and quads can be meshed. (The builder normally breaks up
|
||||
// larger polygons into tris, though the user can choose to defeat
|
||||
// this.)
|
||||
|
||||
for (i = 0; i < num_verts; i++) {
|
||||
// Define an inner and outer edge. A polygon shares an edge with a
|
||||
// neighbor only when one of its inner edges matches a neighbor's
|
||||
// outer edge (and vice-versa).
|
||||
Edge inner(vptrs[i], vptrs[(i+1) % num_verts]);
|
||||
Edge outer(vptrs[(i+1) % num_verts], vptrs[i]);
|
||||
|
||||
// Add it to the list and get its common pointer.
|
||||
Edge &inner_ref = (Edge &)*_edges.insert(inner).first;
|
||||
Edge &outer_ref = (Edge &)*_edges.insert(outer).first;
|
||||
|
||||
// Tell the edges about each other.
|
||||
inner_ref._opposite = &outer_ref;
|
||||
outer_ref._opposite = &inner_ref;
|
||||
|
||||
// Associate the common edge to the strip.
|
||||
strip._edges.push_back(&inner_ref);
|
||||
|
||||
// Associate the strip, as well as the original prim, to the edge.
|
||||
outer_ref._strips.push_back(&strip);
|
||||
|
||||
// Associate the common edge with the vertices that share it.
|
||||
// Edge *edge_ptr = inner_ref.common_ptr();
|
||||
eptrs[i]->insert(&outer_ref);
|
||||
eptrs[(i+1) % num_verts]->insert(&outer_ref);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
template <class PrimType>
|
||||
void MesherTempl<PrimType>::
|
||||
mesh() {
|
||||
if (_bucket->_consider_fans) {
|
||||
find_fans();
|
||||
}
|
||||
|
||||
// First, we try to make all the best quads we can.
|
||||
if (_bucket->_retesselate_coplanar) {
|
||||
make_quads();
|
||||
}
|
||||
|
||||
// Then, we do the rest of the tris.
|
||||
meshList(_tris);
|
||||
|
||||
if (_bucket->_show_quads) {
|
||||
// If we're showing quads, we shouldn't do any more meshing.
|
||||
TYPENAME Strips::iterator si;
|
||||
for (si = _quads.begin(); si != _quads.end(); ++si) {
|
||||
if ((*si)._status == MS_alive) {
|
||||
(*si)._status = MS_done;
|
||||
}
|
||||
}
|
||||
for (si = _strips.begin(); si != _strips.end(); ++si) {
|
||||
if ((*si)._status == MS_alive) {
|
||||
(*si)._status = MS_done;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Then, build quads into sheets where possible.
|
||||
build_sheets();
|
||||
|
||||
// Pick up any quads that might have been left behind.
|
||||
meshList(_quads);
|
||||
|
||||
// Finally, do the longer strips.
|
||||
meshList(_strips);
|
||||
|
||||
// Get ready to walk through the results.
|
||||
_next_strip = _done.begin();
|
||||
}
|
||||
|
||||
|
||||
template <class PrimType>
|
||||
PrimType MesherTempl<PrimType>::
|
||||
getPrim() {
|
||||
if (_next_strip == _done.end()) {
|
||||
// End of the list, return a primitive with no vertices.
|
||||
finalize();
|
||||
return Prim();
|
||||
}
|
||||
|
||||
Strip &strip = (*_next_strip++);
|
||||
BuilderPrimType orig_type = strip._type;
|
||||
Prim prim = strip.make_prim(*_bucket);
|
||||
|
||||
if (_bucket->_show_tstrips) {
|
||||
// If we have _show_tstrips enabled, it means we need to color
|
||||
// every primitive according to which, if any, tristrip it is in.
|
||||
|
||||
// We use the _colors array--and later make a copy in shared
|
||||
// memory for the bucket to point to--in case the primitives are
|
||||
// indexed. If the primitives are nonindexed, we'll still
|
||||
// allocate the _colors array and its copy in shared memory, but
|
||||
// it will be deleted when the bucket destructs.
|
||||
|
||||
if (_colors.empty()) {
|
||||
// We need one entry for not-a-tristrip, indicated by white.
|
||||
_colors.push_back(Colorf(0.85, 0.85, 0.85, 1.0));
|
||||
}
|
||||
|
||||
ushort i1, i2;
|
||||
Colorf color1, color2;;
|
||||
|
||||
switch (prim.get_type()) {
|
||||
case BPT_tristrip:
|
||||
case BPT_trifan:
|
||||
make_random_color(color2);
|
||||
color1 = (color2 * 0.8); // somewhat darker.
|
||||
i1 = _colors.size();
|
||||
i2 = i1+1;
|
||||
_colors.push_back(color1);
|
||||
_colors.push_back(color2);
|
||||
break;
|
||||
|
||||
default:
|
||||
// not-a-tristrip.
|
||||
i1 = i2 = 0;
|
||||
}
|
||||
|
||||
// Now i1 and i2 index into the colors array to indicate the color
|
||||
// for the first triangle and the rest of the primitive,
|
||||
// respectively.
|
||||
int num_components = prim.get_num_components();
|
||||
if (num_components > 0) {
|
||||
prim.get_component(0).set_color_value(&_colors[0], i1);
|
||||
for (int i = 1; i < num_components; i++) {
|
||||
prim.get_component(i).set_color_value(&_colors[0], i2);
|
||||
}
|
||||
} else {
|
||||
prim.set_color_value(&_colors[0], i1);
|
||||
}
|
||||
|
||||
} else if (_bucket->_show_qsheets) {
|
||||
// _show_qsheets means to color every primitive according to
|
||||
// which, if any, quadsheet it is in. This is a bit easier,
|
||||
// because the entire primitive gets the same color.
|
||||
|
||||
if (_colors.empty()) {
|
||||
// We need one entry for not-a-qsheet, indicated by white.
|
||||
_colors.push_back(Colorf(0.85, 0.85, 0.85, 1.0));
|
||||
}
|
||||
|
||||
// Is this a quadsheet?
|
||||
ushort i1 = 0;
|
||||
if (strip._row_id < 0) {
|
||||
// Yep! Assign a new color, if it doesn't already have one.
|
||||
ColorSheetMap::iterator ci = _color_sheets.find(strip._row_id);
|
||||
|
||||
if (ci == _color_sheets.end()) {
|
||||
Colorf color1;
|
||||
make_random_color(color1);
|
||||
i1 = _colors.size();
|
||||
_colors.push_back(color1);
|
||||
_color_sheets[strip._row_id] = i1;
|
||||
} else {
|
||||
i1 = (*ci).second;
|
||||
}
|
||||
}
|
||||
|
||||
// Now i1 is the color we want to assign to the whole primitive.
|
||||
// Just set all vertices to the same color.
|
||||
int num_verts = prim.get_num_verts();
|
||||
for (int i = 0; i < num_verts; i++) {
|
||||
prim.get_vertex(i).set_color_value(&_colors[0], i1);
|
||||
}
|
||||
|
||||
} else if (_bucket->_show_quads) {
|
||||
// _show_quads means to show the assembling of tris into quads and fans.
|
||||
|
||||
// We use the following color convention:
|
||||
|
||||
// white: unchanged; as supplied by user.
|
||||
// dark blue: quads made in the initial pass. These are more certain.
|
||||
// light blue: quads made in the second pass. These are less certain.
|
||||
// very light blue: quadstrips. These are unlikely to appear.
|
||||
// random shades of red: triangles and tristrips.
|
||||
// green: fans and retesselated fan polygons.
|
||||
|
||||
if (_colors.empty()) {
|
||||
// We need a handful of entries.
|
||||
_colors.push_back(Colorf(0.85, 0.85, 0.85, 1.0)); // default: white
|
||||
_colors.push_back(Colorf(0.0, 0.0, 0.75, 1.0)); // dark blue
|
||||
_colors.push_back(Colorf(0.4, 0.4, 0.8, 1.0)); // light blue
|
||||
_colors.push_back(Colorf(0.6, 0.6, 1.0, 1.0)); // very light blue
|
||||
_colors.push_back(Colorf(0.2, 0.8, 0.2, 1.0)); // green
|
||||
}
|
||||
|
||||
ushort i1;
|
||||
Colorf color1;
|
||||
if (strip._origin == MO_user) {
|
||||
i1 = 0;
|
||||
} else if (strip._origin == MO_firstquad) {
|
||||
i1 = 1;
|
||||
} else if (strip._origin == MO_fanpoly) {
|
||||
i1 = 4;
|
||||
} else {
|
||||
switch (orig_type) {
|
||||
case BPT_quad:
|
||||
i1 = 2;
|
||||
break;
|
||||
|
||||
case BPT_quadstrip:
|
||||
i1 = 3;
|
||||
break;
|
||||
|
||||
case BPT_tristrip:
|
||||
make_random_color(color1);
|
||||
// Make it a shade of red.
|
||||
if (color1[0] < color1[1]) {
|
||||
float t = color1[0];
|
||||
color1[0] = color1[1];
|
||||
color1[1] = t;
|
||||
}
|
||||
color1[2] = color1[1];
|
||||
i1 = _colors.size();
|
||||
_colors.push_back(color1);
|
||||
break;
|
||||
|
||||
case BPT_trifan:
|
||||
make_random_color(color1);
|
||||
// Make it a shade of green.
|
||||
if (color1[0] > color1[1]) {
|
||||
float t = color1[0];
|
||||
color1[0] = color1[1];
|
||||
color1[1] = t;
|
||||
}
|
||||
color1[2] = color1[0];
|
||||
i1 = _colors.size();
|
||||
_colors.push_back(color1);
|
||||
break;
|
||||
|
||||
default:
|
||||
i1 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Now i1 is the color we want to assign to the whole primitive.
|
||||
// Just set all vertices to the same color.
|
||||
int num_verts = prim.get_num_verts();
|
||||
for (int i = 0; i < num_verts; i++) {
|
||||
prim.get_vertex(i).set_color_value(&_colors[0], i1);
|
||||
}
|
||||
}
|
||||
|
||||
return prim;
|
||||
}
|
||||
|
||||
|
||||
template <class PrimType>
|
||||
void MesherTempl<PrimType>::
|
||||
finalize() {
|
||||
if (!_colors.empty()) {
|
||||
// Create an array in the bucket we might use to add to geoms.
|
||||
PTA_Colorf colors=PTA_Colorf::empty_array(_colors.size());
|
||||
for (int i = 0; i < (int)_colors.size(); i++) {
|
||||
colors[i] = _colors[i];
|
||||
}
|
||||
_bucket->set_colors(colors);
|
||||
|
||||
_colors.clear();
|
||||
_color_sheets.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <class PrimType>
|
||||
void MesherTempl<PrimType>::
|
||||
show(ostream &out) {
|
||||
/*
|
||||
out << _edges.size() << " edges:\n";
|
||||
copy(_edges.begin(), _edges.end(), ostream_iterator<Edge>(out, "\n"));
|
||||
*/
|
||||
|
||||
out << _verts.size() << " verts:\n";
|
||||
TYPENAME Verts::const_iterator vi;
|
||||
|
||||
for (vi = _verts.begin(); vi != _verts.end(); ++vi) {
|
||||
const Vertex &v = (*vi).first;
|
||||
const EdgePtrs &edges = (*vi).second;
|
||||
out << v << " shares " << count_vert_edges(edges) << " edges:\n";
|
||||
TYPENAME EdgePtrs::const_iterator ei;
|
||||
for (ei = edges.begin(); ei != edges.end(); ++ei) {
|
||||
if (!(*ei)->_strips.empty() || !(*ei)->_opposite->_strips.empty()) {
|
||||
out << " " << **ei << "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TYPENAME Strips::const_iterator si;
|
||||
out << _tris.size() << " tris:\n";
|
||||
for (si = _tris.begin(); si != _tris.end(); ++si) {
|
||||
out << (*si) << "\n";
|
||||
}
|
||||
|
||||
out << _quads.size() << " quads:\n";
|
||||
for (si = _quads.begin(); si != _quads.end(); ++si) {
|
||||
out << (*si) << "\n";
|
||||
}
|
||||
|
||||
out << _strips.size() << " strips:\n";
|
||||
for (si = _strips.begin(); si != _strips.end(); ++si) {
|
||||
out << (*si) << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <class PrimType>
|
||||
int MesherTempl<PrimType>::
|
||||
count_vert_edges(const EdgePtrs &edges) const {
|
||||
int count = 0;
|
||||
TYPENAME EdgePtrs::const_iterator ei;
|
||||
for (ei = edges.begin(); ei != edges.end(); ++ei) {
|
||||
count += (!(*ei)->_strips.empty() || !(*ei)->_opposite->_strips.empty());
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
template <class PrimType>
|
||||
plist<TYPENAME MesherTempl<PrimType>::Strip> &MesherTempl<PrimType>::
|
||||
choose_strip_list(const Strip &strip) {
|
||||
switch (strip._status) {
|
||||
case MS_done:
|
||||
return _done;
|
||||
|
||||
case MS_dead:
|
||||
return _dead;
|
||||
|
||||
case MS_alive:
|
||||
switch (strip._type) {
|
||||
case BPT_tri:
|
||||
return _tris;
|
||||
|
||||
case BPT_quad:
|
||||
return _quads;
|
||||
|
||||
default:
|
||||
return _strips;
|
||||
}
|
||||
|
||||
default:
|
||||
builder_cat.fatal() << "Invalid strip status!\n";
|
||||
abort();
|
||||
}
|
||||
|
||||
return _strips; // Unreachable; this is just to make the compiler happy.
|
||||
}
|
||||
|
||||
|
||||
template <class PrimType>
|
||||
void MesherTempl<PrimType>::
|
||||
build_sheets() {
|
||||
int first_row_id = 1;
|
||||
|
||||
// First, move all the quads to our own internal list.
|
||||
Strips pre_sheeted;
|
||||
pre_sheeted.splice(pre_sheeted.end(), _quads);
|
||||
|
||||
while (!pre_sheeted.empty()) {
|
||||
// Pick the first quad on the list.
|
||||
|
||||
TYPENAME Strips::iterator best = pre_sheeted.begin();
|
||||
|
||||
// If the row_id is negative, we've already built a sheet out of
|
||||
// this quad. Leave it alone. We also need to leave it be if it
|
||||
// has no available edges.
|
||||
if ((*best)._row_id >= 0 &&
|
||||
(*best)._status == MS_alive &&
|
||||
!(*best)._edges.empty()) {
|
||||
// There are two possible sheets we could make from this quad,
|
||||
// in two different orientations. Measure them both and figure
|
||||
// out which one is best.
|
||||
|
||||
const Edge *edge_a = (*best)._edges.front();
|
||||
const Edge *edge_b = (*best).find_adjacent_edge(edge_a);
|
||||
|
||||
int num_prims_a = 0;
|
||||
int num_rows_a = 0;
|
||||
int first_row_id_a = first_row_id;
|
||||
(*best).measure_sheet(edge_a, true, num_prims_a, num_rows_a,
|
||||
first_row_id_a, 0, 0);
|
||||
first_row_id += num_rows_a;
|
||||
double avg_length_a = (double)num_prims_a / (double)num_rows_a;
|
||||
|
||||
int num_prims_b = 0;
|
||||
int num_rows_b = 0;
|
||||
int first_row_id_b = first_row_id;
|
||||
double avg_length_b;
|
||||
if (edge_b != NULL) {
|
||||
(*best).measure_sheet(edge_b, true, num_prims_b, num_rows_b,
|
||||
first_row_id_b, 0, 0);
|
||||
first_row_id += num_rows_b;
|
||||
avg_length_b = (double)num_prims_b / (double)num_rows_b;
|
||||
}
|
||||
|
||||
// Which sheet is better?
|
||||
if (edge_b != NULL && avg_length_b >= avg_length_a) {
|
||||
// Sheet b. That's easy.
|
||||
(*best).cut_sheet(first_row_id_b, true, *_bucket);
|
||||
|
||||
} else {
|
||||
// Nope, sheet a is better. This is a bit of a nuisance
|
||||
// because we've unfortunately wiped out the information we
|
||||
// stored when we measured sheet a. We'll have to do it
|
||||
// again.
|
||||
|
||||
num_prims_a = 0;
|
||||
num_rows_a = 0;
|
||||
first_row_id_a = first_row_id;
|
||||
(*best).measure_sheet(edge_a, true, num_prims_a, num_rows_a,
|
||||
first_row_id_a, 0, 0);
|
||||
first_row_id += num_rows_a;
|
||||
|
||||
// Now we can cut it.
|
||||
(*best).cut_sheet(first_row_id_a, true, *_bucket);
|
||||
}
|
||||
}
|
||||
|
||||
// Now put it somewhere. We'll never see this quad again in
|
||||
// build_sheets().
|
||||
Strips &list = choose_strip_list(*best);
|
||||
list.splice(list.end(), pre_sheeted, best);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <class PrimType>
|
||||
void MesherTempl<PrimType>::
|
||||
find_fans() {
|
||||
#ifdef SUPPORT_FANS
|
||||
pvector<Prim> unrolled_tris;
|
||||
|
||||
// Consider all vertices. Any vertex with over a certain number of
|
||||
// edges connected to it is eligible to become a fan.
|
||||
|
||||
TYPENAME Verts::iterator vi;
|
||||
|
||||
for (vi = _verts.begin(); vi != _verts.end(); ++vi) {
|
||||
EdgePtrs &edges = (*vi).second;
|
||||
|
||||
// 14 is the magic number of edges. 12 edges or fewer are likely
|
||||
// to be found on nearly every vertex in a quadsheet (six edges
|
||||
// times two, one each way). We don't want to waste time fanning
|
||||
// out each vertex of a quadsheet, and we don't want to break up
|
||||
// the quadsheets anyway. We bump this up to 14 because some
|
||||
// quadsheets are defined with triangles flipped here and there.
|
||||
if (edges.size() > 6) {
|
||||
const Vertex &v = (*vi).first;
|
||||
|
||||
// Build up a list of far fan edges.
|
||||
typedef pvector<FanMaker> FanMakers;
|
||||
|
||||
FanMakers fans;
|
||||
|
||||
TYPENAME EdgePtrs::iterator ei;
|
||||
TYPENAME Edge::Strips::iterator si;
|
||||
for (ei = edges.begin(); ei != edges.end(); ++ei) {
|
||||
for (si = (*ei)->_strips.begin();
|
||||
si != (*ei)->_strips.end();
|
||||
++si) {
|
||||
Strip *strip = *si;
|
||||
if (strip->_type == BPT_tri) {
|
||||
FanMaker fan(&v, strip, this);
|
||||
if (!fan._edges.empty()) {
|
||||
fans.push_back(fan);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sort the fans list by edge pointers, and remove duplicates.
|
||||
sort(fans.begin(), fans.end());
|
||||
fans.erase(unique(fans.begin(), fans.end()),
|
||||
fans.end());
|
||||
|
||||
TYPENAME FanMakers::iterator fi, fi2;
|
||||
|
||||
// Now pull out connected edges.
|
||||
int joined_any;
|
||||
do {
|
||||
joined_any = false;
|
||||
for (fi = fans.begin(); fi != fans.end(); ++fi) {
|
||||
if (!(*fi).is_empty()) {
|
||||
fi2 = fi;
|
||||
for (++fi2; fi2 != fans.end(); ++fi2) {
|
||||
if (!(*fi2).is_empty()) {
|
||||
joined_any = (*fi).join(*fi2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (joined_any);
|
||||
|
||||
for (fi = fans.begin(); fi != fans.end(); ++fi) {
|
||||
if ((*fi).is_valid()) {
|
||||
(*fi).build(unrolled_tris);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Finally, add back in the triangles we might have produced by
|
||||
// unrolling some of the fans. We can't add these back in safely
|
||||
// until we're done traversing all the vertices and primitives we
|
||||
// had in the first place (since adding them will affect the edge
|
||||
// lists).
|
||||
TYPENAME pvector<Prim>::iterator ti;
|
||||
for (ti = unrolled_tris.begin(); ti != unrolled_tris.end(); ++ti) {
|
||||
add_prim(*ti);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MesherTempl::make_quads
|
||||
// Access: Public
|
||||
// Description: Attempts to join up all the single tris to its
|
||||
// neighbor and reconstruct a pattern of quads, suitable
|
||||
// for making into quadsheets or at least quadstrips.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class PrimType>
|
||||
void MesherTempl<PrimType>::
|
||||
make_quads() {
|
||||
// Ideally, we want to match tris across their hypotenuse to make a
|
||||
// pattern of quads. (This assumes that we are working with a
|
||||
// triangulated mesh pattern, of course. If we have some other
|
||||
// pattern of tris, all bets are off and it doesn't really matter
|
||||
// anyway.)
|
||||
|
||||
// First, we'll find all the tris that have no doubt about their
|
||||
// ideal mate, and pair them up right away. The others we'll get to
|
||||
// later. This way, the uncertain matches won't pollute the quad
|
||||
// alignment for everyone else.
|
||||
|
||||
typedef pair<Strip *, Strip *> Pair;
|
||||
typedef pair<Pair, Edge *> Matched;
|
||||
typedef pvector<Matched> SoulMates;
|
||||
|
||||
SoulMates soulmates;
|
||||
|
||||
Strip *tri, *mate, *mate2;
|
||||
Edge *common_edge, *common_edge2;
|
||||
|
||||
TYPENAME Strips::iterator si;
|
||||
for (si = _tris.begin(); si != _tris.end(); ++si) {
|
||||
tri = &(*si);
|
||||
|
||||
if (tri->_status == MS_alive) {
|
||||
if (tri->find_ideal_mate(mate, common_edge, *_bucket)) {
|
||||
// Does our chosen mate want us too?
|
||||
if (mate->_type == BPT_tri && mate->_status == MS_alive &&
|
||||
mate->find_ideal_mate(mate2, common_edge2, *_bucket) &&
|
||||
mate2 == tri) {
|
||||
// Hooray!
|
||||
soulmates.push_back(Matched(Pair(tri, mate), common_edge));
|
||||
// We'll temporarily mark the two tris as paired.
|
||||
tri->_status = MS_paired;
|
||||
mate->_status = MS_paired;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now that we've found all the tris that are sure about each other,
|
||||
// mate them.
|
||||
TYPENAME SoulMates::iterator mi;
|
||||
for (mi = soulmates.begin(); mi != soulmates.end(); ++mi) {
|
||||
tri = (*mi).first.first;
|
||||
mate = (*mi).first.second;
|
||||
common_edge = (*mi).second;
|
||||
|
||||
nassertv(tri->_status == MS_paired);
|
||||
nassertv(mate->_status == MS_paired);
|
||||
tri->_status = MS_alive;
|
||||
mate->_status = MS_alive;
|
||||
|
||||
Strip::mate_pieces(common_edge, *tri, *mate, *_bucket);
|
||||
tri->_origin = MO_firstquad;
|
||||
}
|
||||
|
||||
// Now move all the strips off the tri list that no longer belong.
|
||||
TYPENAME Strips::iterator next;
|
||||
si = _tris.begin();
|
||||
while (si != _tris.end()) {
|
||||
next = si;
|
||||
++next;
|
||||
|
||||
Strips &list = choose_strip_list(*si);
|
||||
if (&list != &_tris) {
|
||||
list.splice(list.end(), _tris, si);
|
||||
}
|
||||
|
||||
si = next;
|
||||
}
|
||||
}
|
||||
|
||||
template <class PrimType>
|
||||
void MesherTempl<PrimType>::
|
||||
meshList(Strips &strips) {
|
||||
while (!strips.empty()) {
|
||||
// Pick the first strip on the list.
|
||||
|
||||
TYPENAME Strips::iterator best = strips.begin();
|
||||
|
||||
if ((*best)._status == MS_alive) {
|
||||
(*best).mate(*_bucket);
|
||||
}
|
||||
|
||||
// Put the strip back on the end of whichever list it wants. This
|
||||
// might be the same list, if the strip is still alive, or it
|
||||
// might be _done or _dead.
|
||||
Strips &list = choose_strip_list(*best);
|
||||
list.splice(list.end(), strips, best);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,91 +0,0 @@
|
|||
// Filename: mesherTempl.h
|
||||
// Created by: drose (15Sep97)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
#ifndef MESHERTEMPL_H
|
||||
#define MESHERTEMPL_H
|
||||
|
||||
#include "pandabase.h"
|
||||
|
||||
#include "mesherConfig.h"
|
||||
#include "builderBucket.h"
|
||||
#include "mesherEdge.h"
|
||||
#include "mesherStrip.h"
|
||||
|
||||
#include "pvector.h"
|
||||
#include "plist.h"
|
||||
#include "pset.h"
|
||||
#include "pmap.h"
|
||||
|
||||
template <class PrimType>
|
||||
class MesherFanMaker;
|
||||
|
||||
template <class PrimType>
|
||||
class MesherTempl {
|
||||
public:
|
||||
typedef PrimType Prim;
|
||||
typedef TYPENAME PrimType::Vertex Vertex;
|
||||
typedef TYPENAME PrimType::DAttrib MAttrib;
|
||||
typedef MesherEdge<PrimType> Edge;
|
||||
typedef MesherStrip<PrimType> Strip;
|
||||
typedef MesherFanMaker<PrimType> FanMaker;
|
||||
|
||||
MesherTempl(BuilderBucket *bucket);
|
||||
|
||||
int add_prim(const Prim &prim, MesherStripOrigin origin = MO_user);
|
||||
void mesh();
|
||||
Prim getPrim();
|
||||
|
||||
void finalize();
|
||||
|
||||
void show(ostream &out);
|
||||
|
||||
protected:
|
||||
typedef plist<Strip> Strips;
|
||||
typedef pset<Edge, less<Edge> > Edges;
|
||||
typedef pset<Edge *, less<Edge *> > EdgePtrs;
|
||||
typedef pmap<Vertex, EdgePtrs, less<Vertex> > Verts;
|
||||
|
||||
// This is used for show-tstrips.
|
||||
typedef pvector<BuilderC> Colors;
|
||||
// And this is used for show-qsheets.
|
||||
typedef pmap<int, int, less<int> > ColorSheetMap;
|
||||
|
||||
int count_vert_edges(const EdgePtrs &edges) const;
|
||||
plist<Strip> &choose_strip_list(const Strip &strip);
|
||||
|
||||
void build_sheets();
|
||||
void find_fans();
|
||||
void make_quads();
|
||||
void meshList(Strips &strips);
|
||||
|
||||
Strips _tris, _quads, _strips;
|
||||
Strips _dead, _done;
|
||||
Verts _verts;
|
||||
Edges _edges;
|
||||
int _stripIndex;
|
||||
BuilderBucket *_bucket;
|
||||
TYPENAME Strips::iterator _next_strip;
|
||||
Colors _colors;
|
||||
ColorSheetMap _color_sheets;
|
||||
|
||||
friend class MesherStrip<PrimType>;
|
||||
friend class MesherFanMaker<PrimType>;
|
||||
};
|
||||
|
||||
#include "mesherTempl.I"
|
||||
|
||||
#endif
|
||||
|
|
@ -1,211 +0,0 @@
|
|||
// Filename: test_builder.cxx
|
||||
// Created by: drose (09Sep97)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "builder.h"
|
||||
#include "builderPrim.h"
|
||||
#include "mesher.h"
|
||||
|
||||
#include "notify.h"
|
||||
#include "geom.h"
|
||||
#include "geomNode.h"
|
||||
#include "namedNode.h"
|
||||
#include "dftraverser.h"
|
||||
#include "traverserVisitor.h"
|
||||
#include "renderRelation.h"
|
||||
#include "nullTransitionWrapper.h"
|
||||
#include "nullLevelState.h"
|
||||
#include "pta_Vertexf.h"
|
||||
#include "pta_Normalf.h"
|
||||
#include "pta_Colorf.h"
|
||||
#include "pta_TexCoordf.h"
|
||||
|
||||
class polygon : public BuilderPrimI {
|
||||
public:
|
||||
};
|
||||
|
||||
extern int hedface_vt_len;
|
||||
extern Vertexf hedface_vt[];
|
||||
extern polygon polys[];
|
||||
extern int num_polys;
|
||||
|
||||
|
||||
class ReportGeoms :
|
||||
public TraverserVisitor<NullTransitionWrapper, NullLevelState> {
|
||||
public:
|
||||
bool reached_node(Node *node, const NullTransitionWrapper &, NullLevelState &);
|
||||
};
|
||||
|
||||
bool ReportGeoms::
|
||||
reached_node(Node *node, const NullTransitionWrapper &, NullLevelState &) {
|
||||
if (node->is_of_type(GeomNode::get_class_type())) {
|
||||
GeomNode *geomNode = (GeomNode *)node;
|
||||
nout << "\n" << *geomNode << ", " << geomNode->get_num_geoms()
|
||||
<< " geoms:\n";
|
||||
int num_geoms = geomNode->get_num_geoms();
|
||||
for (int i = 0; i < num_geoms; i++) {
|
||||
dDrawable *draw = geomNode->get_geom(i);
|
||||
Geom *geom = DCAST(Geom, draw);
|
||||
nout << *geom << ":\n";
|
||||
geom->output_verbose(nout);
|
||||
}
|
||||
|
||||
} else {
|
||||
nout << *node << "\n";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int
|
||||
main(void) {
|
||||
|
||||
#if 1
|
||||
NamedNode *root = new NamedNode("root");
|
||||
|
||||
Builder builder;
|
||||
|
||||
PTA_Vertexf v_array(hedface_vt_len);
|
||||
int i;
|
||||
for (i = 0; i < hedface_vt_len; i++) {
|
||||
v_array[i] = hedface_vt[i];
|
||||
}
|
||||
PTA_Colorf c_array(num_polys);
|
||||
for (i = 0; i < num_polys; i++) {
|
||||
c_array[i].set(1.0, 1.0, 1.0, 1.0);
|
||||
}
|
||||
|
||||
BuilderBucket bucket;
|
||||
bucket._node = root;
|
||||
bucket.set_coords(v_array);
|
||||
bucket.set_colors(c_array);
|
||||
bucket._mesh = true;
|
||||
|
||||
for (i = 0; i < num_polys; i++) {
|
||||
polys[i].set_color(i);
|
||||
// nout << "Adding polygon " << i << ": " << polys[i] << "\n";
|
||||
builder.add_prim_nonindexed(bucket, polys[i]);
|
||||
}
|
||||
|
||||
ReportGeoms rg;
|
||||
|
||||
GeomNode *gn = builder.build();
|
||||
nout << "Built " << (void *)gn << "\n";
|
||||
if (gn != NULL) {
|
||||
NullLevelState level_state;
|
||||
rg.reached_node(gn, NullTransitionWrapper(), level_state);
|
||||
}
|
||||
|
||||
nout << "\nTraversing root:\n";
|
||||
df_traverse(root, rg, NullTransitionWrapper(), NullLevelState(),
|
||||
RenderRelation::get_class_type());
|
||||
|
||||
#else
|
||||
Builder builder;
|
||||
BuilderPrimI prim;
|
||||
|
||||
BuilderBucket bucket;
|
||||
|
||||
ushort p = 0;
|
||||
int xi, yi;
|
||||
xi = 4;
|
||||
yi = xi;
|
||||
|
||||
int x, y;
|
||||
PTA_Vertexf coords(xi * yi);
|
||||
PTA_Normalf normals(xi * yi);
|
||||
PTA_Colorf colors(3);
|
||||
|
||||
double xv, yv, zv;
|
||||
for (y = 0; y < yi; y++) {
|
||||
for (x = 0; x < xi; x++) {
|
||||
xv = (double)x / (double)(xi-1) - 0.5;
|
||||
yv = (double)y / (double)(yi-1) - 0.5;
|
||||
|
||||
//zv = (y <= x) ? 0.0 : ((float)(y-x)*(y-x) / (float)(yi));
|
||||
//zv = sqrt(1.0 - (xv*xv + yv*yv));
|
||||
//zv = sqrt(1.0 - (xv*xv + yv*yv));
|
||||
//zv = sqrt(max(0.25 - (xv*xv + yv*yv), 0.0));
|
||||
zv = 0.0;
|
||||
|
||||
p = y*xi + x;
|
||||
coords[p].set(xv, yv, zv);
|
||||
}
|
||||
}
|
||||
|
||||
for (y = 0; y < yi-1; y++) {
|
||||
for (x = 0; x < xi-1; x++) {
|
||||
p = y*xi + x;
|
||||
pfVec3 p1 = coords[p+xi];
|
||||
pfVec3 p2 = coords[p];
|
||||
pfVec3 p3 = coords[p+1];
|
||||
normals[p] = normalize(cross(p1-p2, p2-p3));
|
||||
}
|
||||
}
|
||||
|
||||
colors[0].set(1.0, 1.0, 1.0, 1.0);
|
||||
colors[1].set(1.0, 0.0, 0.0, 1.0);
|
||||
colors[2].set(0.0, 0.0, 1.0, 1.0);
|
||||
|
||||
bucket.set_coords(coords);
|
||||
bucket.set_normals(normals);
|
||||
bucket.set_colors(colors);
|
||||
|
||||
bucket.setAttr(PFSTATE_FRONTMTL, new pfMaterial);
|
||||
bucket.setMode(PFSTATE_ENLIGHTING, PF_ON);
|
||||
|
||||
bucket._mesh = true;
|
||||
bucket._max_tfan_angle = 60;
|
||||
bucket._show_tstrips = true;
|
||||
bucket._retesselate_coplanar = true;
|
||||
builder.add_bucket(bucket);
|
||||
|
||||
nout << "Adding polygons.\n";
|
||||
for (y = 0; y < yi-1; y++) {
|
||||
for (x = 0; x < xi-1; x++) {
|
||||
p = y*xi + x;
|
||||
BuilderVertexI bv0(p), bv1(p+1), bv4(p+xi), bv5(p+xi+1);
|
||||
if (p==0) {
|
||||
builder.add_prim(BuilderPrimI(bv0, bv5, bv4).set_color(1));
|
||||
builder.add_prim(BuilderPrimI(bv1, bv5, bv0).set_color(1));
|
||||
} else if (p==5) {
|
||||
builder.add_prim(BuilderPrimI(bv0, bv5, bv4).set_color(1));
|
||||
builder.add_prim(BuilderPrimI(bv1, bv5, bv0).set_color(1));
|
||||
} else if (p==1 || p==4) {
|
||||
builder.add_prim(BuilderPrimI(bv0, bv1, bv4).set_color(1));
|
||||
builder.add_prim(BuilderPrimI(bv1, bv5, bv4).set_color(1));
|
||||
} else {
|
||||
builder.add_prim(BuilderPrimI(bv0, bv5, bv4).set_color(0));
|
||||
builder.add_prim(BuilderPrimI(bv1, bv5, bv0).set_color(0));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
nout << "Building.\n";
|
||||
pfNode *root = builder.build_all_buckets();
|
||||
|
||||
if (root!=NULL) {
|
||||
report_geosets(root);
|
||||
}
|
||||
|
||||
pfdStoreFile(root, "builder.pfa");
|
||||
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1,718 +0,0 @@
|
|||
// Filename: test_builder_data.cxx
|
||||
// Created by: drose (11Sep97)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "builderPrim.h"
|
||||
|
||||
int hedface_vt_len = 337;
|
||||
Vertexf hedface_vt[337] = {
|
||||
Vertexf(),
|
||||
Vertexf(0.045221, 6.59701, 0.374149),
|
||||
Vertexf(0.051493, 6.53504, 0.41213),
|
||||
Vertexf(-0.004945, 6.54228, 0.460135),
|
||||
Vertexf(-0.006027, 6.59713, 0.428656),
|
||||
Vertexf(-0.163023, 6.4847, 0.375736),
|
||||
Vertexf(-0.204045, 6.4752, 0.347943),
|
||||
Vertexf(-0.18025, 6.50566, 0.329401),
|
||||
Vertexf(-0.159739, 6.51041, 0.343297),
|
||||
Vertexf(-0.041928, 6.54233, 0.460079),
|
||||
Vertexf(-0.040616, 6.59717, 0.428604),
|
||||
Vertexf(0.116272, 6.4844, 0.376158),
|
||||
Vertexf(0.119393, 6.45869, 0.408606),
|
||||
Vertexf(0.057765, 6.47306, 0.45011),
|
||||
Vertexf(-0.003863, 6.48744, 0.491613),
|
||||
Vertexf(0.157357, 6.47482, 0.348488),
|
||||
Vertexf(0.181021, 6.44431, 0.367102),
|
||||
Vertexf(-0.098236, 6.5352, 0.411904),
|
||||
Vertexf(-0.091699, 6.59716, 0.373943),
|
||||
Vertexf(0.113151, 6.51012, 0.343709),
|
||||
Vertexf(0.05625, 6.68185, 0.38825),
|
||||
Vertexf(0.052935, 6.65809, 0.388478),
|
||||
Vertexf(0.038183, 6.65814, 0.391172),
|
||||
Vertexf(0.038209, 6.68243, 0.390851),
|
||||
Vertexf(-0.08114, 6.70556, 0.357325),
|
||||
Vertexf(-0.074757, 6.70668, 0.327237),
|
||||
Vertexf(-0.06435, 6.75423, 0.318492),
|
||||
Vertexf(-0.076311, 6.74108, 0.348446),
|
||||
Vertexf(0.056607, 6.65772, 0.361073),
|
||||
Vertexf(0.056632, 6.68102, 0.360765),
|
||||
Vertexf(0.050611, 6.65837, 0.333519),
|
||||
Vertexf(-0.105274, 6.67711, 0.384106),
|
||||
Vertexf(-0.102005, 6.6582, 0.384442),
|
||||
Vertexf(-0.10409, 6.65786, 0.358346),
|
||||
Vertexf(-0.104068, 6.6782, 0.358076),
|
||||
Vertexf(0.133694, 6.50533, 0.329875),
|
||||
Vertexf(-0.056482, 6.84607, 0.309156),
|
||||
Vertexf(-0.053944, 6.80178, 0.309746),
|
||||
Vertexf(-0.088991, 6.83803, 0.302363),
|
||||
Vertexf(-0.07393, 6.90532, 0.300343),
|
||||
Vertexf(0.028345, 6.90521, 0.300498),
|
||||
Vertexf(0.043257, 6.83789, 0.302563),
|
||||
Vertexf(0.008112, 6.80171, 0.30984),
|
||||
Vertexf(0.010745, 6.846, 0.309258),
|
||||
Vertexf(-0.094717, 6.80544, 0.300714),
|
||||
Vertexf(-0.194166, 6.81436, 0.278684),
|
||||
Vertexf(-0.162377, 6.84458, 0.287335),
|
||||
Vertexf(-0.103944, 6.82835, 0.296707),
|
||||
Vertexf(-0.204143, 6.94657, 0.295928),
|
||||
Vertexf(-0.201354, 6.95975, 0.298222),
|
||||
Vertexf(-0.169019, 6.95635, 0.305305),
|
||||
Vertexf(-0.178088, 6.94025, 0.302407),
|
||||
Vertexf(-0.087574, 6.65823, 0.388024),
|
||||
Vertexf(-0.087552, 6.67872, 0.387753),
|
||||
Vertexf(-0.039303, 6.65201, 0.397128),
|
||||
Vertexf(0.051495, 6.70678, 0.35635),
|
||||
Vertexf(0.033453, 6.70736, 0.358952),
|
||||
Vertexf(-0.036388, 6.44535, 0.478493),
|
||||
Vertexf(-0.023597, 6.43031, 0.477217),
|
||||
Vertexf(-0.098546, 6.43648, 0.44227),
|
||||
Vertexf(-0.100206, 6.44582, 0.442143),
|
||||
Vertexf(-0.164024, 6.44429, 0.404327),
|
||||
Vertexf(-0.163195, 6.43863, 0.404403),
|
||||
Vertexf(-0.227839, 6.44475, 0.366484),
|
||||
Vertexf(0.11709, 6.44598, 0.404725),
|
||||
Vertexf(0.13215, 6.4488, 0.39385),
|
||||
Vertexf(0.168279, 6.44653, 0.364598),
|
||||
Vertexf(0.038949, 6.65899, 0.336169),
|
||||
Vertexf(-0.007109, 6.65198, 0.397178),
|
||||
Vertexf(0.046712, 6.70598, 0.324792),
|
||||
Vertexf(0.036091, 6.73257, 0.383482),
|
||||
Vertexf(0.027241, 6.74335, 0.351049),
|
||||
Vertexf(-0.024001, 6.23599, 0.606704),
|
||||
Vertexf(-0.024029, 6.21889, 0.613174),
|
||||
Vertexf(-0.046614, 6.21572, 0.610968),
|
||||
Vertexf(-0.051099, 6.234, 0.60249),
|
||||
Vertexf(0.003109, 6.23394, 0.602571),
|
||||
Vertexf(-0.001441, 6.21567, 0.611036),
|
||||
Vertexf(-0.042134, 6.20409, 0.627544),
|
||||
Vertexf(-0.039909, 6.2022, 0.648599),
|
||||
Vertexf(-0.024097, 6.19903, 0.644253),
|
||||
Vertexf(-0.024073, 6.19793, 0.627118),
|
||||
Vertexf(-0.024129, 6.18605, 0.656217),
|
||||
Vertexf(-0.010583, 6.1849, 0.660713),
|
||||
Vertexf(-0.008288, 6.20216, 0.648647),
|
||||
Vertexf(-0.02414, 6.18435, 0.662939),
|
||||
Vertexf(-0.024101, 6.20376, 0.650817),
|
||||
Vertexf(-0.085163, 6.65912, 0.335982),
|
||||
Vertexf(-0.024152, 6.1629, 0.656118),
|
||||
Vertexf(-0.035442, 6.16465, 0.655261),
|
||||
Vertexf(-0.037687, 6.18493, 0.660672),
|
||||
Vertexf(-0.024131, 6.15434, 0.63571),
|
||||
Vertexf(-0.033164, 6.15576, 0.63633),
|
||||
Vertexf(-0.012855, 6.16463, 0.655295),
|
||||
Vertexf(-0.015095, 6.15574, 0.636358),
|
||||
Vertexf(-0.02403, 6.20933, 0.606675),
|
||||
Vertexf(-0.005995, 6.20405, 0.627598),
|
||||
Vertexf(-0.024063, 6.20715, 0.627798),
|
||||
Vertexf(-0.024144, 6.1681, 0.653605),
|
||||
Vertexf(-0.003116, 6.4359, 0.174903),
|
||||
Vertexf(-0.043102, 6.43593, 0.174842),
|
||||
Vertexf(-0.043515, 6.48837, 0.174148),
|
||||
Vertexf(-0.002372, 6.48835, 0.174209),
|
||||
Vertexf(0.115485, 6.41793, 0.441265),
|
||||
Vertexf(0.049948, 6.38957, 0.515453),
|
||||
Vertexf(0.051474, 6.43632, 0.442496),
|
||||
Vertexf(0.11625, 6.44229, 0.404773),
|
||||
Vertexf(0.11793, 6.44966, 0.404678),
|
||||
Vertexf(0.054838, 6.455, 0.442254),
|
||||
Vertexf(0.053156, 6.44566, 0.442375),
|
||||
Vertexf(-0.215724, 6.44831, 0.36377),
|
||||
Vertexf(-0.178985, 6.44921, 0.393528),
|
||||
Vertexf(0.132116, 6.43478, 0.376846),
|
||||
Vertexf(0.081514, 6.43627, 0.276983),
|
||||
Vertexf(0.125673, 6.433, 0.277093),
|
||||
Vertexf(-0.023729, 6.39172, 0.536235),
|
||||
Vertexf(-0.16259, 6.41625, 0.440871),
|
||||
Vertexf(0.081667, 6.43492, 0.175042),
|
||||
Vertexf(0.042326, 6.43548, 0.174976),
|
||||
Vertexf(0.042875, 6.48598, 0.174308),
|
||||
Vertexf(0.082021, 6.48349, 0.1744),
|
||||
Vertexf(-0.010775, 6.44532, 0.478531),
|
||||
Vertexf(-0.179019, 6.43519, 0.376525),
|
||||
Vertexf(-0.128071, 6.43656, 0.276666),
|
||||
Vertexf(-0.088566, 6.43707, 0.276718),
|
||||
Vertexf(-0.120423, 6.43613, 0.41066),
|
||||
Vertexf(-0.179061, 6.48408, 0.349586),
|
||||
Vertexf(-0.128102, 6.48581, 0.276014),
|
||||
Vertexf(-0.166981, 6.48194, 0.276007),
|
||||
Vertexf(0.073698, 6.44983, 0.427624),
|
||||
Vertexf(0.073664, 6.43581, 0.410621),
|
||||
Vertexf(0.13215, 6.4488, 0.39385),
|
||||
Vertexf(-0.053819, 6.48884, 0.416828),
|
||||
Vertexf(-0.043668, 6.48972, 0.276088),
|
||||
Vertexf(-0.088788, 6.48758, 0.276049),
|
||||
Vertexf(-0.12075, 6.48629, 0.383705),
|
||||
Vertexf(0.007052, 6.45585, 0.460591),
|
||||
Vertexf(0.00726, 6.48879, 0.416675),
|
||||
Vertexf(-0.054026, 6.45591, 0.460743),
|
||||
Vertexf(0.132646, 6.483, 0.349918),
|
||||
Vertexf(0.081868, 6.48484, 0.276341),
|
||||
Vertexf(0.042723, 6.48733, 0.276249),
|
||||
Vertexf(0.074482, 6.48596, 0.383667),
|
||||
Vertexf(0.120223, 6.48035, 0.276458),
|
||||
Vertexf(0.168279, 6.44653, 0.364598),
|
||||
Vertexf(-0.053173, 6.45076, 0.460301),
|
||||
Vertexf(-0.053207, 6.43674, 0.443297),
|
||||
Vertexf(0.006154, 6.43669, 0.443142),
|
||||
Vertexf(0.006188, 6.45071, 0.460146),
|
||||
Vertexf(-0.088413, 6.43573, 0.174777),
|
||||
Vertexf(-0.043255, 6.43728, 0.276783),
|
||||
Vertexf(-0.002525, 6.4897, 0.27615),
|
||||
Vertexf(0.11279, 6.41322, 0.399904),
|
||||
Vertexf(0.181156, 6.44226, 0.277053),
|
||||
Vertexf(0.112895, 6.40928, 0.325903),
|
||||
Vertexf(-0.091652, 6.37645, 0.374546),
|
||||
Vertexf(-0.159678, 6.40957, 0.325491),
|
||||
Vertexf(-0.159784, 6.41351, 0.399492),
|
||||
Vertexf(-0.091728, 6.38228, 0.4325),
|
||||
Vertexf(0.042174, 6.43683, 0.276917),
|
||||
Vertexf(-0.008253, 6.46035, 0.47983),
|
||||
Vertexf(0.007052, 6.45585, 0.460591),
|
||||
Vertexf(-0.054026, 6.45591, 0.460743),
|
||||
Vertexf(-0.038879, 6.46038, 0.479784),
|
||||
Vertexf(-0.04324, 6.48748, 0.491554),
|
||||
Vertexf(0.006188, 6.45071, 0.460146),
|
||||
Vertexf(0.073698, 6.44983, 0.427624),
|
||||
Vertexf(-0.120389, 6.45015, 0.427664),
|
||||
Vertexf(-0.053173, 6.45076, 0.460301),
|
||||
Vertexf(-0.140225, 7.00983, 0.321446),
|
||||
Vertexf(-0.123119, 7.01151, 0.328341),
|
||||
Vertexf(-0.134749, 6.97962, 0.323871),
|
||||
Vertexf(-0.142948, 6.98128, 0.319329),
|
||||
Vertexf(0.18119, 6.42198, 0.240696),
|
||||
Vertexf(0.112929, 6.389, 0.289545),
|
||||
Vertexf(-0.023958, 6.27715, 0.605697),
|
||||
Vertexf(-0.023963, 6.25473, 0.593607),
|
||||
Vertexf(0.007645, 6.2539, 0.604398),
|
||||
Vertexf(0.012162, 6.27018, 0.615932),
|
||||
Vertexf(0.044667, 6.35602, 0.338395),
|
||||
Vertexf(-0.023594, 6.32304, 0.387244),
|
||||
Vertexf(-0.023627, 6.34332, 0.423602),
|
||||
Vertexf(0.044634, 6.3763, 0.374752),
|
||||
Vertexf(-0.101866, 6.45517, 0.442017),
|
||||
Vertexf(-0.120958, 6.45335, 0.427621),
|
||||
Vertexf(-0.179269, 6.45115, 0.393502),
|
||||
Vertexf(-0.164852, 6.44996, 0.404251),
|
||||
Vertexf(-0.127919, 6.43522, 0.174725),
|
||||
Vertexf(-0.172614, 6.43334, 0.174683),
|
||||
Vertexf(-0.166828, 6.4806, 0.174066),
|
||||
Vertexf(-0.12795, 6.48446, 0.174073),
|
||||
Vertexf(-0.172766, 6.43469, 0.276624),
|
||||
Vertexf(-0.023673, 6.35105, 0.465508),
|
||||
Vertexf(0.044558, 6.38213, 0.432706),
|
||||
Vertexf(-0.166306, 6.45899, 0.408174),
|
||||
Vertexf(0.114721, 6.39357, 0.477756),
|
||||
Vertexf(-0.068907, 6.93005, 0.3295),
|
||||
Vertexf(-0.081264, 6.91456, 0.321684),
|
||||
Vertexf(0.021212, 6.29084, 0.620743),
|
||||
Vertexf(-0.02399, 6.26675, 0.620987),
|
||||
Vertexf(-0.023978, 6.28932, 0.628239),
|
||||
Vertexf(-0.060115, 6.27026, 0.615822),
|
||||
Vertexf(-0.069134, 6.29094, 0.620607),
|
||||
Vertexf(-0.023865, 6.32255, 0.574454),
|
||||
Vertexf(0.048421, 6.34283, 0.588411),
|
||||
Vertexf(0.074274, 6.45303, 0.427583),
|
||||
Vertexf(-0.161986, 6.39386, 0.477338),
|
||||
Vertexf(-0.096133, 6.34298, 0.588192),
|
||||
Vertexf(-0.178985, 6.44921, 0.393528),
|
||||
Vertexf(-0.120389, 6.45015, 0.427664),
|
||||
Vertexf(-0.091619, 6.35617, 0.338189),
|
||||
Vertexf(0.077674, 7.01129, 0.328644),
|
||||
Vertexf(0.08925, 6.97938, 0.324209),
|
||||
Vertexf(0.035634, 6.91444, 0.32186),
|
||||
Vertexf(0.023287, 6.92995, 0.329639),
|
||||
Vertexf(-0.088636, 6.48623, 0.174108),
|
||||
Vertexf(0.010745, 6.846, 0.309258),
|
||||
Vertexf(0.015997, 6.92072, 0.308277),
|
||||
Vertexf(0.094448, 7.01026, 0.32246),
|
||||
Vertexf(0.15589, 6.95937, 0.298762),
|
||||
Vertexf(0.123526, 6.95604, 0.305746),
|
||||
Vertexf(0.097137, 6.98214, 0.319113),
|
||||
Vertexf(0.030275, 6.31191, 0.617283),
|
||||
Vertexf(-0.023949, 6.3137, 0.626308),
|
||||
Vertexf(-0.02394, 6.29401, 0.605607),
|
||||
Vertexf(-0.023916, 6.30851, 0.599061),
|
||||
Vertexf(-0.003269, 6.43725, 0.276843),
|
||||
Vertexf(0.091554, 6.96985, 0.299337),
|
||||
Vertexf(0.08196, 6.97015, 0.302846),
|
||||
Vertexf(-0.078141, 6.31202, 0.61712),
|
||||
Vertexf(0.070384, 7.00207, 0.307281),
|
||||
Vertexf(-0.227704, 6.44269, 0.276436),
|
||||
Vertexf(-0.156456, 6.53612, 0.310859),
|
||||
Vertexf(0.11003, 6.53584, 0.311261),
|
||||
Vertexf(0.132438, 6.45006, 0.393834),
|
||||
Vertexf(-0.097339, 6.38973, 0.515231),
|
||||
Vertexf(0.132438, 6.45006, 0.393834),
|
||||
Vertexf(0.074274, 6.45303, 0.427583),
|
||||
Vertexf(0.120375, 6.479, 0.174517),
|
||||
Vertexf(0.125825, 6.43165, 0.175152),
|
||||
Vertexf(0.028345, 6.90521, 0.300498),
|
||||
Vertexf(-0.159645, 6.38929, 0.289133),
|
||||
Vertexf(-0.104773, 6.47324, 0.449864),
|
||||
Vertexf(-0.215724, 6.44831, 0.36377),
|
||||
Vertexf(-0.131591, 6.96754, 0.300267),
|
||||
Vertexf(-0.161684, 6.94711, 0.283964),
|
||||
Vertexf(-0.129814, 6.99298, 0.301599),
|
||||
Vertexf(-0.115784, 7.00226, 0.307),
|
||||
Vertexf(-0.061573, 6.9208, 0.30816),
|
||||
Vertexf(-0.167969, 6.93295, 0.282982),
|
||||
Vertexf(-0.040067, 6.66458, 0.505563),
|
||||
Vertexf(-0.039454, 6.62437, 0.477676),
|
||||
Vertexf(-0.087687, 6.65527, 0.461334),
|
||||
Vertexf(-0.088272, 6.72793, 0.378401),
|
||||
Vertexf(-0.088393, 6.70869, 0.445015),
|
||||
Vertexf(-0.098863, 6.70395, 0.353678),
|
||||
Vertexf(-0.056482, 6.84607, 0.309156),
|
||||
Vertexf(-0.041096, 6.73064, 0.482186),
|
||||
Vertexf(0.038076, 6.65896, 0.462433),
|
||||
Vertexf(0.035976, 6.71327, 0.446101),
|
||||
Vertexf(0.08381, 6.99315, 0.302152),
|
||||
Vertexf(0.1486, 6.95015, 0.277399),
|
||||
Vertexf(-0.00726, 6.62434, 0.477725),
|
||||
Vertexf(-0.008959, 6.66524, 0.505601),
|
||||
Vertexf(0.02867, 6.70656, 0.327393),
|
||||
Vertexf(-0.179269, 6.45115, 0.393502),
|
||||
Vertexf(0.134358, 6.93999, 0.302389),
|
||||
Vertexf(0.159456, 6.94608, 0.296165),
|
||||
Vertexf(0.018391, 6.75414, 0.318617),
|
||||
Vertexf(-0.22767, 6.42241, 0.240078),
|
||||
Vertexf(-0.069554, 7.00945, 0.310645),
|
||||
Vertexf(-0.115784, 7.00226, 0.307),
|
||||
Vertexf(0.163425, 6.80702, 0.199637),
|
||||
Vertexf(-0.023861, 6.35313, 0.595253),
|
||||
Vertexf(-0.161684, 6.94711, 0.283964),
|
||||
Vertexf(-0.131591, 6.96754, 0.300267),
|
||||
Vertexf(-0.127415, 6.97038, 0.30253),
|
||||
Vertexf(-0.127415, 6.97038, 0.30253),
|
||||
Vertexf(-0.07393, 6.90532, 0.300343),
|
||||
Vertexf(0.148469, 6.8287, 0.279006),
|
||||
Vertexf(0.124864, 6.92982, 0.283536),
|
||||
Vertexf(-0.208912, 6.80741, 0.199075),
|
||||
Vertexf(-0.147148, 6.64856, 0.281136),
|
||||
Vertexf(-0.14701, 6.64735, 0.189092),
|
||||
Vertexf(-0.02399, 6.22995, 0.594216),
|
||||
Vertexf(-0.061573, 6.9208, 0.30816),
|
||||
Vertexf(-0.046619, 6.90315, 0.320843),
|
||||
Vertexf(-0.041466, 6.79966, 0.369073),
|
||||
Vertexf(-0.013462, 6.80239, 0.375073),
|
||||
Vertexf(0.023846, 7.00935, 0.310786),
|
||||
Vertexf(0.070384, 7.00207, 0.307281),
|
||||
Vertexf(-0.194019, 6.95051, 0.276882),
|
||||
Vertexf(-0.011997, 6.73258, 0.482204),
|
||||
Vertexf(-0.096505, 6.65755, 0.332384),
|
||||
Vertexf(-0.092479, 6.70507, 0.32359),
|
||||
Vertexf(0.055599, 6.80587, 0.299473),
|
||||
Vertexf(0.059185, 6.82536, 0.29725),
|
||||
Vertexf(-0.194037, 6.93438, 0.277095),
|
||||
Vertexf(-0.194019, 6.95051, 0.276882),
|
||||
Vertexf(-0.167969, 6.93295, 0.282982),
|
||||
Vertexf(-0.19415, 6.82906, 0.278489),
|
||||
Vertexf(-0.156387, 6.53551, 0.264837),
|
||||
Vertexf(-0.024129, 6.15856, 0.637607),
|
||||
Vertexf(0.1486, 6.95015, 0.277399),
|
||||
Vertexf(-0.194037, 6.93438, 0.277095),
|
||||
Vertexf(-0.120958, 6.45335, 0.427621),
|
||||
Vertexf(0.148583, 6.93434, 0.277608),
|
||||
Vertexf(-0.013559, 6.78726, 0.428727),
|
||||
Vertexf(-0.041572, 6.78462, 0.42872),
|
||||
Vertexf(-0.156318, 6.5349, 0.218815),
|
||||
Vertexf(0.148453, 6.81399, 0.279201),
|
||||
Vertexf(0.101077, 6.6483, 0.281511),
|
||||
Vertexf(0.101215, 6.64708, 0.189467),
|
||||
Vertexf(0.110099, 6.53523, 0.26524),
|
||||
Vertexf(0.110168, 6.53462, 0.219218),
|
||||
Vertexf(0.08196, 6.97015, 0.302846),
|
||||
Vertexf(0.091554, 6.96985, 0.299337),
|
||||
Vertexf(0.116237, 6.94682, 0.284384),
|
||||
Vertexf(0.116702, 6.84429, 0.287756),
|
||||
Vertexf(0.124864, 6.92982, 0.283536),
|
||||
Vertexf(0.148469, 6.8287, 0.279006),
|
||||
Vertexf(0.015997, 6.92072, 0.308277),
|
||||
Vertexf(0.000968, 6.9031, 0.320915),
|
||||
Vertexf(-0.022854, 7.0094, 0.310715),
|
||||
Vertexf(-0.023987, 6.25354, 0.609743),
|
||||
Vertexf(-0.023889, 6.31842, 0.587859),
|
||||
Vertexf(0.039346, 6.33018, 0.605966),
|
||||
Vertexf(-0.023908, 6.33618, 0.614913),
|
||||
Vertexf(-0.096133, 6.34298, 0.588192),
|
||||
Vertexf(-0.087138, 6.33031, 0.605775),
|
||||
Vertexf(-0.023865, 6.32255, 0.574454),
|
||||
Vertexf(0.048421, 6.34283, 0.588411),
|
||||
Vertexf(-0.023861, 6.35313, 0.595253),
|
||||
Vertexf(0.148583, 6.93434, 0.277608),
|
||||
Vertexf(-0.055597, 6.25397, 0.604303),
|
||||
Vertexf(0.116237, 6.94682, 0.284384),
|
||||
Vertexf(-0.19415, 6.82906, 0.278489),
|
||||
};
|
||||
|
||||
//#define VVAL(i) hedface_vt[i]
|
||||
#define VVAL(i) i
|
||||
|
||||
class polygon : public BuilderPrimI {
|
||||
public:
|
||||
polygon(int i, int j, int k) {
|
||||
add_vertex(VVAL(i));
|
||||
add_vertex(VVAL(j));
|
||||
add_vertex(VVAL(k));
|
||||
}
|
||||
polygon(int i, int j, int k, int l) {
|
||||
add_vertex(VVAL(i));
|
||||
add_vertex(VVAL(j));
|
||||
add_vertex(VVAL(k));
|
||||
add_vertex(VVAL(l));
|
||||
}
|
||||
polygon(int i, int j, int k, int l, int m) {
|
||||
add_vertex(VVAL(i));
|
||||
add_vertex(VVAL(j));
|
||||
add_vertex(VVAL(k));
|
||||
add_vertex(VVAL(l));
|
||||
add_vertex(VVAL(m));
|
||||
}
|
||||
polygon(int i, int j, int k, int l, int m, int n) {
|
||||
add_vertex(VVAL(i));
|
||||
add_vertex(VVAL(j));
|
||||
add_vertex(VVAL(k));
|
||||
add_vertex(VVAL(l));
|
||||
add_vertex(VVAL(m));
|
||||
add_vertex(VVAL(n));
|
||||
}
|
||||
polygon(int i, int j, int k, int l, int m, int n, int o) {
|
||||
add_vertex(VVAL(i));
|
||||
add_vertex(VVAL(j));
|
||||
add_vertex(VVAL(k));
|
||||
add_vertex(VVAL(l));
|
||||
add_vertex(VVAL(m));
|
||||
add_vertex(VVAL(n));
|
||||
add_vertex(VVAL(o));
|
||||
}
|
||||
};
|
||||
|
||||
polygon polys[] = {
|
||||
polygon(4, 3, 2, 1),
|
||||
polygon(8, 7, 6, 5),
|
||||
polygon(10, 9, 3, 4),
|
||||
polygon(2, 13, 12, 11),
|
||||
polygon(3, 14, 13, 2),
|
||||
polygon(11, 12, 16, 15),
|
||||
polygon(18, 17, 9, 10),
|
||||
polygon(8, 5, 17, 18),
|
||||
polygon(1, 2, 11, 19),
|
||||
polygon(23, 22, 21, 20),
|
||||
polygon(27, 26, 25, 24),
|
||||
polygon(30, 29, 28),
|
||||
polygon(20, 21, 28, 29),
|
||||
polygon(34, 33, 32, 31),
|
||||
polygon(19, 11, 15, 35),
|
||||
polygon(39, 38, 37, 36),
|
||||
polygon(43, 42, 41, 40),
|
||||
polygon(47, 46, 45, 44),
|
||||
polygon(51, 50, 49, 48),
|
||||
polygon(54, 53, 52),
|
||||
polygon(31, 32, 52, 53),
|
||||
polygon(56, 23, 20, 55),
|
||||
polygon(55, 20, 29),
|
||||
/*
|
||||
polygon(60, 59, 58, 57),
|
||||
polygon(63, 62, 61),
|
||||
polygon(16, 66, 65, 64),
|
||||
polygon(68, 67, 22),
|
||||
polygon(30, 69, 55, 29),
|
||||
polygon(71, 70, 23, 56),
|
||||
polygon(75, 74, 73, 72),
|
||||
polygon(72, 73, 77, 76),
|
||||
polygon(81, 80, 79, 78),
|
||||
polygon(84, 83, 82, 80),
|
||||
polygon(86, 85, 83, 84),
|
||||
polygon(52, 87, 54),
|
||||
polygon(90, 89, 88, 85),
|
||||
polygon(89, 92, 91, 88),
|
||||
polygon(88, 91, 94, 93),
|
||||
polygon(77, 96, 81, 95),
|
||||
polygon(78, 79, 86, 97),
|
||||
polygon(80, 82, 90, 79),
|
||||
polygon(82, 98, 89, 90),
|
||||
polygon(102, 101, 100, 99),
|
||||
polygon(106, 105, 104, 103),
|
||||
polygon(108, 107, 12, 13),
|
||||
polygon(1, 67, 68, 4),
|
||||
polygon(109, 105, 106, 64),
|
||||
polygon(61, 111, 110, 63),
|
||||
polygon(114, 113, 112),
|
||||
polygon(104, 105, 58, 115),
|
||||
polygon(62, 63, 116),
|
||||
polygon(120, 119, 118, 117),
|
||||
polygon(121, 58, 105, 109),
|
||||
polygon(125, 124, 123, 122),
|
||||
polygon(128, 127, 126),
|
||||
polygon(65, 112, 130, 129),
|
||||
polygon(135, 134, 133, 132),
|
||||
polygon(138, 132, 137, 136),
|
||||
polygon(142, 141, 140, 139),
|
||||
polygon(66, 143, 114),
|
||||
polygon(148, 147, 146, 145),
|
||||
polygon(150, 100, 149, 124),
|
||||
polygon(133, 101, 102, 151),
|
||||
polygon(154, 153, 16, 152),
|
||||
polygon(158, 157, 156, 155),
|
||||
polygon(113, 117, 118, 159),
|
||||
polygon(163, 138, 136, 160),
|
||||
polygon(73, 97, 96, 77),
|
||||
polygon(96, 84, 80, 81),
|
||||
polygon(61, 62, 59, 60),
|
||||
polygon(22, 23, 68),
|
||||
polygon(9, 164, 14, 3),
|
||||
polygon(109, 129, 148, 121),
|
||||
polygon(57, 145, 167, 60),
|
||||
polygon(172, 171, 170, 169),
|
||||
polygon(174, 173, 153, 154),
|
||||
polygon(178, 177, 176, 175),
|
||||
polygon(182, 181, 180, 179),
|
||||
polygon(186, 185, 184, 183),
|
||||
polygon(190, 189, 188, 187),
|
||||
polygon(122, 123, 191),
|
||||
polygon(139, 140, 143),
|
||||
polygon(193, 192, 181, 182),
|
||||
polygon(183, 184, 138, 163),
|
||||
polygon(126, 127, 134, 135),
|
||||
polygon(194, 63, 186),
|
||||
polygon(60, 167, 111, 61),
|
||||
polygon(151, 102, 119, 141),
|
||||
polygon(152, 16, 195),
|
||||
polygon(66, 114, 112, 65),
|
||||
polygon(141, 119, 120, 140),
|
||||
polygon(170, 171, 197, 196),
|
||||
polygon(200, 199, 178, 198),
|
||||
polygon(202, 201, 199, 200),
|
||||
polygon(204, 203, 192, 193),
|
||||
polygon(136, 137, 142, 205),
|
||||
polygon(207, 206, 157, 158),
|
||||
polygon(167, 125, 122, 111),
|
||||
polygon(191, 188, 189, 128),
|
||||
polygon(128, 189, 190, 127),
|
||||
polygon(210, 180, 181, 155),
|
||||
polygon(214, 213, 212, 211),
|
||||
polygon(206, 63, 157),
|
||||
polygon(124, 149, 187, 123),
|
||||
polygon(134, 215, 101, 133),
|
||||
polygon(127, 190, 215, 134),
|
||||
polygon(214, 217, 43),
|
||||
polygon(221, 220, 219, 218),
|
||||
polygon(223, 200, 198, 222),
|
||||
polygon(224, 175, 201, 202),
|
||||
polygon(222, 198, 224, 225),
|
||||
polygon(159, 118, 99, 226),
|
||||
polygon(226, 99, 100, 150),
|
||||
polygon(123, 187, 188, 191),
|
||||
polygon(221, 212, 228, 227),
|
||||
polygon(229, 202, 200, 223),
|
||||
polygon(158, 192, 203, 207),
|
||||
polygon(198, 178, 175, 224),
|
||||
polygon(217, 214, 211, 230),
|
||||
polygon(157, 63, 231, 156),
|
||||
polygon(225, 224, 202, 229),
|
||||
polygon(63, 110, 185, 186),
|
||||
polygon(121, 148, 145, 57),
|
||||
polygon(64, 65, 129, 109),
|
||||
polygon(13, 14, 160, 108),
|
||||
polygon(8, 232, 7),
|
||||
polygon(19, 233, 67, 1),
|
||||
polygon(234, 66, 16),
|
||||
polygon(62, 116, 235, 59),
|
||||
polygon(149, 100, 101, 215),
|
||||
polygon(205, 142, 139, 234),
|
||||
polygon(145, 146, 125, 167),
|
||||
polygon(160, 136, 205, 108),
|
||||
polygon(108, 205, 234, 107),
|
||||
polygon(117, 239, 238, 120),
|
||||
polygon(103, 16, 106),
|
||||
polygon(234, 139, 143, 66),
|
||||
polygon(114, 239, 117, 113),
|
||||
polygon(228, 212, 213, 40),
|
||||
polygon(241, 210, 155, 156),
|
||||
polygon(186, 183, 242, 194),
|
||||
polygon(18, 87, 232, 8),
|
||||
polygon(64, 106, 16),
|
||||
polygon(57, 58, 121),
|
||||
polygon(143, 238, 239, 114),
|
||||
polygon(40, 213, 43),
|
||||
polygon(111, 122, 191, 110),
|
||||
polygon(129, 130, 147, 148),
|
||||
polygon(112, 113, 159, 130),
|
||||
polygon(147, 226, 150, 146),
|
||||
polygon(146, 150, 124, 125),
|
||||
polygon(172, 50, 245, 244),
|
||||
polygon(169, 170, 247, 246),
|
||||
polygon(247, 170, 196, 248),
|
||||
polygon(249, 245, 50, 51),
|
||||
polygon(252, 251, 250),
|
||||
polygon(24, 53, 253, 27),
|
||||
polygon(253, 53, 252, 254),
|
||||
polygon(34, 31, 255),
|
||||
polygon(36, 196, 197),
|
||||
polygon(67, 30, 28, 21, 22),
|
||||
polygon(250, 257, 254, 252),
|
||||
polygon(128, 110, 191),
|
||||
polygon(23, 70, 259, 258),
|
||||
polygon(130, 159, 226, 147),
|
||||
polygon(218, 219, 261, 260),
|
||||
polygon(248, 196, 36),
|
||||
polygon(263, 262, 258),
|
||||
polygon(264, 69, 30, 67),
|
||||
polygon(110, 128, 126, 185),
|
||||
polygon(68, 262, 251, 54),
|
||||
polygon(63, 206, 116),
|
||||
polygon(267, 219, 220, 266),
|
||||
polygon(53, 54, 251, 252),
|
||||
polygon(258, 262, 68, 23),
|
||||
polygon(264, 268, 71, 56),
|
||||
polygon(104, 204, 195, 103),
|
||||
polygon(107, 16, 12),
|
||||
polygon(115, 273, 204, 104),
|
||||
polygon(276, 244, 245, 46, 47, 38, 39),
|
||||
polygon(39, 197, 171, 276),
|
||||
polygon(235, 207, 273, 115),
|
||||
polygon(280, 279, 266),
|
||||
polygon(283, 282, 45, 281),
|
||||
polygon(177, 76, 284, 176),
|
||||
polygon(16, 107, 234),
|
||||
polygon(153, 233, 35, 15),
|
||||
polygon(282, 87, 25),
|
||||
polygon(287, 286, 248, 36),
|
||||
polygon(215, 190, 187, 149),
|
||||
polygon(288, 42, 43),
|
||||
polygon(250, 263, 292, 257),
|
||||
polygon(255, 294, 293, 34),
|
||||
polygon(24, 25, 294, 255),
|
||||
polygon(296, 41, 42, 295),
|
||||
polygon(258, 259, 292, 263),
|
||||
polygon(56, 55, 69, 264),
|
||||
polygon(43, 213, 214),
|
||||
polygon(48, 49, 291, 297),
|
||||
polygon(300, 45, 46, 245, 249),
|
||||
polygon(140, 120, 238, 143),
|
||||
polygon(301, 232, 87),
|
||||
polygon(287, 37, 26),
|
||||
polygon(83, 93, 98, 82),
|
||||
polygon(79, 90, 85, 86),
|
||||
polygon(98, 302, 92, 89),
|
||||
polygon(87, 293, 294, 25),
|
||||
polygon(255, 31, 53, 24),
|
||||
polygon(281, 45, 300, 297, 291),
|
||||
polygon(95, 81, 78, 74),
|
||||
polygon(185, 126, 135, 184),
|
||||
polygon(241, 269, 210),
|
||||
polygon(248, 286, 270, 247),
|
||||
polygon(267, 279, 306),
|
||||
polygon(17, 242, 164, 9),
|
||||
polygon(5, 194, 242, 17),
|
||||
polygon(26, 37, 44, 45, 282, 25),
|
||||
polygon(301, 87, 282),
|
||||
polygon(287, 308, 307, 288),
|
||||
polygon(283, 269, 309),
|
||||
polygon(311, 310, 295, 42, 268, 264),
|
||||
polygon(268, 42, 288),
|
||||
polygon(173, 174, 179),
|
||||
polygon(231, 63, 6),
|
||||
polygon(272, 310, 311, 312),
|
||||
polygon(314, 313, 233, 153, 173),
|
||||
polygon(164, 163, 160, 14),
|
||||
polygon(40, 41, 296, 318, 317, 227, 228),
|
||||
polygon(314, 173, 312),
|
||||
polygon(197, 39, 36),
|
||||
polygon(132, 133, 151, 137),
|
||||
polygon(74, 78, 97, 73),
|
||||
polygon(33, 34, 293),
|
||||
polygon(317, 318, 310, 279, 280),
|
||||
polygon(85, 88, 93, 83),
|
||||
polygon(97, 86, 84, 96),
|
||||
polygon(308, 257, 292, 307),
|
||||
polygon(35, 233, 19),
|
||||
polygon(259, 307, 292),
|
||||
polygon(33, 293, 87, 52, 32),
|
||||
polygon(184, 135, 132, 138),
|
||||
polygon(93, 94, 302, 98),
|
||||
polygon(156, 231, 269, 241),
|
||||
polygon(269, 231, 232, 301, 309),
|
||||
polygon(230, 289, 322, 217),
|
||||
polygon(70, 288, 307, 259),
|
||||
polygon(137, 151, 141, 142),
|
||||
polygon(264, 67, 311),
|
||||
polygon(286, 322, 289, 323, 270),
|
||||
polygon(291, 246, 247),
|
||||
polygon(262, 263, 250, 251),
|
||||
polygon(230, 260, 261),
|
||||
polygon(257, 308, 254),
|
||||
polygon(154, 152, 193, 182),
|
||||
polygon(313, 314, 312, 311),
|
||||
polygon(155, 181, 192, 158),
|
||||
polygon(115, 58, 59, 235),
|
||||
polygon(174, 154, 182, 179),
|
||||
polygon(287, 288, 322, 286),
|
||||
polygon(231, 6, 7, 232),
|
||||
polygon(6, 63, 194, 5),
|
||||
polygon(103, 195, 16),
|
||||
polygon(254, 308, 287, 253),
|
||||
polygon(116, 206, 207, 235),
|
||||
polygon(67, 233, 313),
|
||||
polygon(4, 68, 54, 10),
|
||||
polygon(99, 118, 119, 102),
|
||||
polygon(322, 288, 43, 217),
|
||||
polygon(36, 37, 287),
|
||||
polygon(199, 324, 177, 178),
|
||||
polygon(326, 222, 225, 325),
|
||||
polygon(302, 94, 91, 92),
|
||||
polygon(183, 163, 164, 242),
|
||||
polygon(327, 223, 222, 326),
|
||||
polygon(203, 325, 329, 207),
|
||||
polygon(152, 195, 204, 193),
|
||||
polygon(204, 326, 325, 203),
|
||||
polygon(284, 95, 74, 75),
|
||||
polygon(15, 16, 153),
|
||||
polygon(329, 229, 223, 327),
|
||||
polygon(76, 77, 95, 284),
|
||||
polygon(313, 311, 67),
|
||||
polygon(282, 283, 309, 301),
|
||||
polygon(207, 329, 327, 273),
|
||||
polygon(273, 327, 326, 204),
|
||||
polygon(261, 306, 279, 310, 272),
|
||||
polygon(334, 75, 72, 324),
|
||||
polygon(324, 72, 76, 177),
|
||||
polygon(175, 176, 334, 201),
|
||||
polygon(325, 225, 229, 329),
|
||||
polygon(201, 334, 324, 199),
|
||||
polygon(176, 284, 75, 334),
|
||||
polygon(71, 268, 288, 70),
|
||||
polygon(27, 253, 287, 26),
|
||||
polygon(10, 54, 87, 18),
|
||||
polygon(230, 211, 218, 260),
|
||||
polygon(211, 212, 221, 218),
|
||||
polygon(317, 220, 221, 227),
|
||||
polygon(220, 317, 280, 266),
|
||||
polygon(279, 267, 266),
|
||||
polygon(261, 219, 267, 306),
|
||||
polygon(310, 318, 296, 295),
|
||||
polygon(291, 49, 169, 246),
|
||||
polygon(49, 50, 172, 169),
|
||||
polygon(276, 171, 172, 244),
|
||||
polygon(300, 48, 297),
|
||||
polygon(300, 51, 48),
|
||||
polygon(300, 249, 51),
|
||||
polygon(37, 38, 47, 44),
|
||||
*/
|
||||
};
|
||||
|
||||
int num_polys = sizeof(polys) / sizeof(polygon);
|
||||
|
|
@ -28,21 +28,6 @@ is_valid_id(char table_id) {
|
|||
return get_table_index(table_id) >= 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AnimChannelMatrixXfmTable::has_table
|
||||
// Access: Public
|
||||
// Description: Returns true if the indicated subtable has been
|
||||
// assigned.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool AnimChannelMatrixXfmTable::
|
||||
has_table(char table_id) const {
|
||||
int table_index = get_table_index(table_id);
|
||||
if (table_index < 0) {
|
||||
return false;
|
||||
}
|
||||
return !(_tables[table_index] == (const float *)NULL);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AnimChannelMatrixXfmTable::get_table
|
||||
// Access: Public
|
||||
|
|
@ -58,9 +43,24 @@ get_table(char table_id) const {
|
|||
return _tables[table_index];
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AnimChannelMatrixXfmTable::has_table
|
||||
// Access: Published
|
||||
// Description: Returns true if the indicated subtable has been
|
||||
// assigned.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool AnimChannelMatrixXfmTable::
|
||||
has_table(char table_id) const {
|
||||
int table_index = get_table_index(table_id);
|
||||
if (table_index < 0) {
|
||||
return false;
|
||||
}
|
||||
return !(_tables[table_index] == (const float *)NULL);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AnimChannelMatrixXfmTable::clear_table
|
||||
// Access: Public
|
||||
// Access: Published
|
||||
// Description: Removes the indicated table from the definition.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void AnimChannelMatrixXfmTable::
|
||||
|
|
|
|||
|
|
@ -145,20 +145,6 @@ get_scale(int frame, float scale[3]) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AnimChannelMatrixXfmTable::clear_all_tables
|
||||
// Access: Public
|
||||
// Description: Removes all the tables from the channel, and resets
|
||||
// it to its initial state.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void AnimChannelMatrixXfmTable::
|
||||
clear_all_tables() {
|
||||
for (int i = 0; i < num_matrix_components; i++) {
|
||||
_tables[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AnimChannelMatrixXfmTable::set_table
|
||||
// Access: Public
|
||||
|
|
@ -185,6 +171,20 @@ set_table(char table_id, const CPTA_float &table) {
|
|||
_tables[i] = table;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AnimChannelMatrixXfmTable::clear_all_tables
|
||||
// Access: Published
|
||||
// Description: Removes all the tables from the channel, and resets
|
||||
// it to its initial state.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void AnimChannelMatrixXfmTable::
|
||||
clear_all_tables() {
|
||||
for (int i = 0; i < num_matrix_components; i++) {
|
||||
_tables[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AnimChannelMatrixXfmTable::write
|
||||
// Access: Public, Virtual
|
||||
|
|
@ -313,30 +313,18 @@ fillin(DatagramIterator &scan, BamReader *manager) {
|
|||
|
||||
bool wrote_compressed = scan.get_bool();
|
||||
|
||||
bool new_hpr = false;
|
||||
if (manager->get_file_minor_ver() >= 14) {
|
||||
// Beginning in bam 4.14, we encode a bool to indicate whether
|
||||
// we used the old hpr or the new hpr calculation. Previously,
|
||||
// we assume all bams used the old hpr calculation.
|
||||
new_hpr = scan.get_bool();
|
||||
}
|
||||
bool new_hpr = scan.get_bool();
|
||||
|
||||
if (!wrote_compressed) {
|
||||
// Regular floats.
|
||||
|
||||
for (int i = 0; i < num_matrix_components; i++) {
|
||||
if (manager->get_file_minor_ver() < 6 && i >= 3 && i < 6) {
|
||||
// Old bam files didn't store a shear component.
|
||||
_tables[i].clear();
|
||||
|
||||
} else {
|
||||
int size = scan.get_uint16();
|
||||
PTA_float ind_table;
|
||||
for (int j = 0; j < size; j++) {
|
||||
ind_table.push_back(scan.get_float32());
|
||||
}
|
||||
_tables[i] = ind_table;
|
||||
int size = scan.get_uint16();
|
||||
PTA_float ind_table;
|
||||
for (int j = 0; j < size; j++) {
|
||||
ind_table.push_back(scan.get_float32());
|
||||
}
|
||||
_tables[i] = ind_table;
|
||||
}
|
||||
|
||||
if ((!new_hpr && temp_hpr_fix) || (new_hpr && !temp_hpr_fix)) {
|
||||
|
|
@ -398,18 +386,10 @@ fillin(DatagramIterator &scan, BamReader *manager) {
|
|||
compressor.read_reals(scan, ind_table.v());
|
||||
_tables[i] = ind_table;
|
||||
}
|
||||
if (manager->get_file_minor_ver() < 6) {
|
||||
// Old bam files didn't store a shear.
|
||||
_tables[3].clear();
|
||||
_tables[4].clear();
|
||||
_tables[5].clear();
|
||||
|
||||
} else {
|
||||
for (i = 3; i < 6; i++) {
|
||||
PTA_float ind_table = PTA_float::empty_array(0);
|
||||
compressor.read_reals(scan, ind_table.v());
|
||||
_tables[i] = ind_table;
|
||||
}
|
||||
for (i = 3; i < 6; i++) {
|
||||
PTA_float ind_table = PTA_float::empty_array(0);
|
||||
compressor.read_reals(scan, ind_table.v());
|
||||
_tables[i] = ind_table;
|
||||
}
|
||||
|
||||
// Read in the HPR array and store it back in the joint angles.
|
||||
|
|
|
|||
|
|
@ -52,11 +52,12 @@ public:
|
|||
|
||||
static INLINE bool is_valid_id(char table_id);
|
||||
|
||||
void set_table(char table_id, const CPTA_float &table);
|
||||
INLINE CPTA_float get_table(char table_id) const;
|
||||
|
||||
PUBLISHED:
|
||||
void clear_all_tables();
|
||||
void set_table(char table_id, const CPTA_float &table);
|
||||
INLINE bool has_table(char table_id) const;
|
||||
INLINE CPTA_float get_table(char table_id) const;
|
||||
INLINE void clear_table(char table_id);
|
||||
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AnimChannelScalarTable::has_table
|
||||
// Access: Public
|
||||
// Access: Published
|
||||
// Description: Returns true if the data table has been assigned.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool AnimChannelScalarTable::
|
||||
|
|
@ -30,7 +30,7 @@ has_table() const {
|
|||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AnimChannelScalarTable::clear_table
|
||||
// Access: Public
|
||||
// Access: Published
|
||||
// Description: Empties the data table.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void AnimChannelScalarTable::
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
forcetype ConstPointerToArray< float >
|
||||
forcetype PointerToArray< float >
|
||||
forcetype PointerToBase< RefCountObj< pvector < float >>>
|
||||
|
|
@ -39,8 +39,9 @@ public:
|
|||
virtual bool has_changed(int last_frame, int this_frame);
|
||||
virtual void get_value(int frame, float &value);
|
||||
|
||||
PUBLISHED:
|
||||
void set_table(const CPTA_float &table);
|
||||
|
||||
PUBLISHED:
|
||||
INLINE bool has_table() const;
|
||||
INLINE void clear_table();
|
||||
|
||||
|
|
|
|||
|
|
@ -14,9 +14,7 @@
|
|||
characterJoint.h characterJointBundle.I \
|
||||
characterJointBundle.h characterSlider.h \
|
||||
characterVertexSlider.I characterVertexSlider.h \
|
||||
computedVertices.I \
|
||||
computedVertices.h computedVerticesMorph.I \
|
||||
computedVerticesMorph.h config_char.h dynamicVertices.h \
|
||||
config_char.h \
|
||||
jointVertexTransform.I jointVertexTransform.h
|
||||
|
||||
#define INCLUDED_SOURCES \
|
||||
|
|
@ -24,9 +22,7 @@
|
|||
characterJoint.cxx characterJointBundle.cxx \
|
||||
characterSlider.cxx \
|
||||
characterVertexSlider.cxx \
|
||||
computedVertices.cxx \
|
||||
computedVerticesMorph.cxx config_char.cxx \
|
||||
dynamicVertices.cxx \
|
||||
config_char.cxx \
|
||||
jointVertexTransform.cxx
|
||||
|
||||
#define INSTALL_HEADERS \
|
||||
|
|
@ -34,9 +30,7 @@
|
|||
characterJoint.h characterJointBundle.I \
|
||||
characterJointBundle.h characterSlider.h \
|
||||
characterVertexSlider.I characterVertexSlider.h \
|
||||
computedVertices.I \
|
||||
computedVertices.h computedVerticesMorph.I computedVerticesMorph.h \
|
||||
config_char.h dynamicVertices.h \
|
||||
config_char.h \
|
||||
jointVertexTransform.I jointVertexTransform.h
|
||||
|
||||
#define IGATESCAN all
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
|
||||
#include "characterSlider.cxx"
|
||||
#include "characterVertexSlider.cxx"
|
||||
#include "computedVertices.cxx"
|
||||
#include "computedVerticesMorph.cxx"
|
||||
#include "dynamicVertices.cxx"
|
||||
#include "jointVertexTransform.cxx"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,37 +0,0 @@
|
|||
// Filename: char_headers.h
|
||||
// Created by: georges (30May01)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "datagram.h"
|
||||
#include "datagramIterator.h"
|
||||
#include "bamReader.h"
|
||||
#include "bamWriter.h"
|
||||
#include "compose_matrix.h"
|
||||
#include "transformTransition.h"
|
||||
#include "ioPtaDatagramLinMath.h"
|
||||
|
||||
#include "character.h"
|
||||
#include "computedVertices.h"
|
||||
#include "computedVerticesMorph.h"
|
||||
#include "characterJoint.h"
|
||||
#include "characterJointBundle.h"
|
||||
#include "characterSlider.h"
|
||||
#include "dynamicVertices.h"
|
||||
#include "config_char.h"
|
||||
|
||||
#pragma hdrstop
|
||||
|
||||
|
|
@ -28,17 +28,6 @@ get_bundle() const {
|
|||
return DCAST(CharacterJointBundle, PartBundleNode::get_bundle());
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Character::get_computed_vertices
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE ComputedVertices *Character::
|
||||
get_computed_vertices() const {
|
||||
return _computed_vertices;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Character::get_num_parts
|
||||
// Access: Published
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
#include "character.h"
|
||||
#include "characterJoint.h"
|
||||
#include "computedVertices.h"
|
||||
#include "config_char.h"
|
||||
|
||||
#include "geomNode.h"
|
||||
|
|
@ -43,8 +42,6 @@ PStatCollector Character::_animation_pcollector("*:Animation");
|
|||
Character::
|
||||
Character(const Character ©) :
|
||||
PartBundleNode(copy, new CharacterJointBundle(copy.get_bundle()->get_name())),
|
||||
_cv(DynamicVertices::deep_copy(copy._cv)),
|
||||
_computed_vertices(copy._computed_vertices),
|
||||
_parts(copy._parts),
|
||||
_joints_pcollector(copy._joints_pcollector),
|
||||
_skinning_pcollector(copy._skinning_pcollector)
|
||||
|
|
@ -221,14 +218,8 @@ force_update() {
|
|||
// Statistics
|
||||
PStatTimer timer(_joints_pcollector);
|
||||
|
||||
// First, update all the joints and sliders.
|
||||
// Update all the joints and sliders.
|
||||
get_bundle()->force_update();
|
||||
|
||||
// Now update the vertices.
|
||||
if (_computed_vertices != (ComputedVertices *)NULL) {
|
||||
PStatTimer timer2(_skinning_pcollector);
|
||||
_computed_vertices->update(this);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -239,21 +230,11 @@ force_update() {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void Character::
|
||||
do_update() {
|
||||
// First, update all the joints and sliders.
|
||||
bool any_changed;
|
||||
// Update all the joints and sliders.
|
||||
if (even_animation) {
|
||||
any_changed = get_bundle()->force_update();
|
||||
get_bundle()->force_update();
|
||||
} else {
|
||||
any_changed = get_bundle()->update();
|
||||
}
|
||||
|
||||
// Now update the vertices, if we need to. This is likely to be a
|
||||
// slow operation.
|
||||
if (any_changed || even_animation) {
|
||||
if (_computed_vertices != (ComputedVertices *)NULL) {
|
||||
PStatTimer timer2(_skinning_pcollector);
|
||||
_computed_vertices->update(this);
|
||||
}
|
||||
get_bundle()->update();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -383,68 +364,20 @@ r_copy_char(PandaNode *dest, const PandaNode *source,
|
|||
PT(Geom) Character::
|
||||
copy_geom(const Geom *source, const Character *from,
|
||||
Character::JointMap &joint_map, Character::SliderMap &slider_map) {
|
||||
if (source->is_qpgeom()) {
|
||||
CPT(qpGeom) qpsource = DCAST(qpGeom, source);
|
||||
CPT(qpGeomVertexFormat) format = qpsource->get_vertex_data()->get_format();
|
||||
if (format->get_animation().get_animation_type() == qpGeom::AT_none) {
|
||||
// Not animated, so never mind.
|
||||
return (Geom *)source;
|
||||
}
|
||||
|
||||
PT(qpGeom) dest = new qpGeom(*qpsource);
|
||||
PT(qpGeomVertexData) vdata = dest->modify_vertex_data();
|
||||
|
||||
vdata->set_transform_table(redirect_transform_table(vdata->get_transform_table(), joint_map));
|
||||
vdata->set_transform_blend_table(redirect_transform_blend_table(vdata->get_transform_blend_table(), joint_map));
|
||||
vdata->set_slider_table(redirect_slider_table(vdata->get_slider_table(), slider_map));
|
||||
|
||||
return dest.p();
|
||||
|
||||
} else {
|
||||
GeomBindType bind;
|
||||
PTA_ushort index;
|
||||
|
||||
PTA_Vertexf coords;
|
||||
PTA_Normalf norms;
|
||||
PTA_Colorf colors;
|
||||
PTA_TexCoordf texcoords;
|
||||
|
||||
PT(Geom) dest = (Geom *)source;
|
||||
|
||||
source->get_coords(coords, index);
|
||||
if ((coords != (void *)NULL) && (coords == (from->_cv._coords))) {
|
||||
if (dest == source) {
|
||||
dest = source->make_copy();
|
||||
}
|
||||
dest->set_coords(_cv._coords, index);
|
||||
}
|
||||
|
||||
source->get_normals(norms, bind, index);
|
||||
if (bind != G_OFF && norms == from->_cv._norms) {
|
||||
if (dest == source) {
|
||||
dest = source->make_copy();
|
||||
}
|
||||
dest->set_normals(_cv._norms, bind, index);
|
||||
}
|
||||
|
||||
source->get_colors(colors, bind, index);
|
||||
if (bind != G_OFF && colors == from->_cv._colors) {
|
||||
if (dest == source) {
|
||||
dest = source->make_copy();
|
||||
}
|
||||
dest->set_colors(_cv._colors, bind, index);
|
||||
}
|
||||
|
||||
source->get_texcoords(texcoords, bind, index);
|
||||
if (bind != G_OFF && texcoords == from->_cv._texcoords) {
|
||||
if (dest == source) {
|
||||
dest = source->make_copy();
|
||||
}
|
||||
dest->set_texcoords(_cv._texcoords, bind, index);
|
||||
}
|
||||
|
||||
return dest;
|
||||
CPT(GeomVertexFormat) format = source->get_vertex_data()->get_format();
|
||||
if (format->get_animation().get_animation_type() == Geom::AT_none) {
|
||||
// Not animated, so never mind.
|
||||
return (Geom *)source;
|
||||
}
|
||||
|
||||
PT(Geom) dest = new Geom(*source);
|
||||
PT(GeomVertexData) vdata = dest->modify_vertex_data();
|
||||
|
||||
vdata->set_transform_table(redirect_transform_table(vdata->get_transform_table(), joint_map));
|
||||
vdata->set_transform_blend_table(redirect_transform_blend_table(vdata->get_transform_blend_table(), joint_map));
|
||||
vdata->set_slider_table(redirect_slider_table(vdata->get_slider_table(), slider_map));
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -672,8 +605,6 @@ register_with_read_factory() {
|
|||
void Character::
|
||||
write_datagram(BamWriter *manager, Datagram &dg) {
|
||||
PartBundleNode::write_datagram(manager, dg);
|
||||
_cv.write_datagram(manager, dg);
|
||||
manager->write_pointer(dg, _computed_vertices);
|
||||
|
||||
dg.add_uint16(_parts.size());
|
||||
Parts::const_iterator pi;
|
||||
|
|
@ -692,7 +623,6 @@ write_datagram(BamWriter *manager, Datagram &dg) {
|
|||
int Character::
|
||||
complete_pointers(TypedWritable **p_list, BamReader *manager) {
|
||||
int pi = PartBundleNode::complete_pointers(p_list, manager);
|
||||
_computed_vertices = DCAST(ComputedVertices, p_list[pi++]);
|
||||
|
||||
int num_parts = _parts.size();
|
||||
for (int i = 0; i < num_parts; i++) {
|
||||
|
|
@ -732,8 +662,6 @@ make_from_bam(const FactoryParams ¶ms) {
|
|||
void Character::
|
||||
fillin(DatagramIterator &scan, BamReader *manager) {
|
||||
PartBundleNode::fillin(scan, manager);
|
||||
_cv.fillin(scan, manager);
|
||||
manager->read_pointer(scan);
|
||||
|
||||
// Read the number of parts to expect in the _parts list, and then
|
||||
// fill the array up with NULLs. We'll fill in the actual values in
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
#include "pandabase.h"
|
||||
|
||||
#include "computedVertices.h"
|
||||
#include "characterJoint.h"
|
||||
#include "characterSlider.h"
|
||||
#include "characterVertexSlider.h"
|
||||
|
|
@ -61,7 +60,6 @@ public:
|
|||
PUBLISHED:
|
||||
INLINE CharacterJointBundle *get_bundle() const;
|
||||
|
||||
INLINE ComputedVertices *get_computed_vertices() const;
|
||||
INLINE int get_num_parts() const;
|
||||
INLINE PartGroup *get_part(int n) const;
|
||||
|
||||
|
|
@ -100,17 +98,6 @@ private:
|
|||
PT(JointVertexTransform) redirect_joint(const VertexTransform *vt, JointMap &joint_map);
|
||||
PT(CharacterVertexSlider) redirect_slider(const VertexSlider *vs, SliderMap &slider_map);
|
||||
|
||||
// These are the actual dynamic vertex pools for this Character's
|
||||
// ComputedVertices--the vertices that it will recompute each frame
|
||||
// based on the soft-skinning and morphing requirements. Note that
|
||||
// we store this concretely, instead of as a pointer, just because
|
||||
// we don't really need to make it a pointer.
|
||||
DynamicVertices _cv;
|
||||
|
||||
// And this is the object that animates them. It *is* a pointer, so
|
||||
// it can be shared between multiple instances of this Character.
|
||||
PT(ComputedVertices) _computed_vertices;
|
||||
|
||||
// This vector is used by the ComputedVertices object to index back
|
||||
// into our joints and sliders.
|
||||
typedef vector_PartGroupStar Parts;
|
||||
|
|
|
|||
|
|
@ -29,8 +29,6 @@
|
|||
// Description : This is a specialization on VertexSlider that
|
||||
// returns the slider value associated with a particular
|
||||
// CharacterSlider object.
|
||||
//
|
||||
// This is part of the experimental Geom rewrite.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_PANDA CharacterVertexSlider : public VertexSlider {
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -1,52 +0,0 @@
|
|||
// Filename: computedVertices.I
|
||||
// Created by: drose (01Mar99)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ComputedVertices::VertexTransform::Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE ComputedVertices::VertexTransform::
|
||||
VertexTransform() {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ComputedVertices::Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE ComputedVertices::
|
||||
ComputedVertices() {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ComputedVertices::VertexTransform::Ordering operator
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool ComputedVertices::VertexTransform::
|
||||
operator < (const ComputedVertices::VertexTransform &other) const {
|
||||
if (_joint_index != other._joint_index) {
|
||||
return _joint_index < other._joint_index;
|
||||
}
|
||||
return _effect < other._effect;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,465 +0,0 @@
|
|||
// Filename: computedVertices.cxx
|
||||
// Created by: drose (01Mar99)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#include "computedVertices.h"
|
||||
#include "characterJoint.h"
|
||||
#include "character.h"
|
||||
#include "config_char.h"
|
||||
|
||||
#include "datagram.h"
|
||||
#include "datagramIterator.h"
|
||||
#include "bamReader.h"
|
||||
#include "bamWriter.h"
|
||||
#include "ioPtaDatagramLinMath.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
TypeHandle ComputedVertices::_type_handle;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ComputedVertices::VertexTransform::Copy Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
ComputedVertices::VertexTransform::
|
||||
VertexTransform(const VertexTransform ©) :
|
||||
_joint_index(copy._joint_index),
|
||||
_effect(copy._effect),
|
||||
_vindex(copy._vindex),
|
||||
_nindex(copy._nindex)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: compute_morphs
|
||||
// Description: This is a utility function called by update(), below.
|
||||
// It applies each of the supplied morphs to the
|
||||
// vertices in the table, according to the values of the
|
||||
// relevant slider.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class ValueType, class MorphType>
|
||||
static void
|
||||
compute_morphs(ValueType *table, const pvector<MorphType> &morph_list,
|
||||
Character *character) {
|
||||
TYPENAME pvector<MorphType>::const_iterator mli;
|
||||
for (mli = morph_list.begin(); mli != morph_list.end(); ++mli) {
|
||||
const MorphType &morph = (*mli);
|
||||
const CharacterSlider *slider;
|
||||
DCAST_INTO_V(slider, character->get_part(morph._slider_index));
|
||||
|
||||
float slider_value = slider->_value;
|
||||
|
||||
if (slider_value != 0.0f) {
|
||||
typedef TYPENAME MorphType::Morphs Morphs;
|
||||
typedef TYPENAME MorphType::MorphValue MorphValue;
|
||||
TYPENAME Morphs::const_iterator mi;
|
||||
for (mi = morph._morphs.begin(); mi != morph._morphs.end(); ++mi) {
|
||||
typedef TYPENAME MorphValue::VecType VecType;
|
||||
ushort index = (*mi)._index;
|
||||
const VecType &v = (*mi)._vector;
|
||||
|
||||
table[index] += v * slider_value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: VertexTransform::write_datagram
|
||||
// Access: Public
|
||||
// Description: Function to write the important information in
|
||||
// the particular object to a Datagram
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void ComputedVertices::VertexTransform::
|
||||
write_datagram(Datagram &dest)
|
||||
{
|
||||
int i;
|
||||
dest.add_int16(_joint_index);
|
||||
dest.add_float32(_effect);
|
||||
dest.add_uint16(_vindex.size());
|
||||
for(i = 0; i < (int)_vindex.size(); i++)
|
||||
{
|
||||
dest.add_uint16(_vindex[i]);
|
||||
}
|
||||
dest.add_uint16(_nindex.size());
|
||||
for(i = 0; i < (int)_nindex.size(); i++)
|
||||
{
|
||||
dest.add_uint16(_nindex[i]);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: VertexTransform::read_datagram
|
||||
// Access: Protected
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void ComputedVertices::VertexTransform::
|
||||
read_datagram(DatagramIterator &source)
|
||||
{
|
||||
int i;
|
||||
_joint_index = source.get_int16();
|
||||
_effect = source.get_float32();
|
||||
int vsize = source.get_uint16();
|
||||
for(i = 0; i < vsize; i++)
|
||||
{
|
||||
_vindex.push_back(source.get_uint16());
|
||||
}
|
||||
int nsize = source.get_uint16();
|
||||
for(i = 0; i < nsize; i++)
|
||||
{
|
||||
_nindex.push_back(source.get_uint16());
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ComputedVertices::update
|
||||
// Access: Public
|
||||
// Description: Recomputes all of the _coords, _norms, etc. values
|
||||
// based on the values in _orig_coords, _orig_norms,
|
||||
// etc., and the current positions of all of the joints.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void ComputedVertices::
|
||||
update(Character *character) {
|
||||
nassertv(character != (Character *)NULL);
|
||||
nassertv(character->_cv._coords.size() == _orig_coords.size());
|
||||
nassertv(character->_cv._norms.size() == _orig_norms.size());
|
||||
nassertv(character->_cv._texcoords.size() == _orig_texcoords.size());
|
||||
nassertv(character->_cv._colors.size() == _orig_colors.size());
|
||||
|
||||
const Vertexf *orig_coords = _orig_coords;
|
||||
const Normalf *orig_norms = _orig_norms;
|
||||
|
||||
memset(character->_cv._coords, 0, sizeof(Vertexf) * character->_cv._coords.size());
|
||||
memset(character->_cv._norms, 0, sizeof(Normalf) * character->_cv._norms.size());
|
||||
|
||||
if (!_vertex_morphs.empty()) {
|
||||
// We have some vertex morphs. Compute them first.
|
||||
int table_size = sizeof(Vertexf) * _orig_coords.size();
|
||||
Vertexf *morphed_coords = (Vertexf *)alloca(table_size);
|
||||
memcpy(morphed_coords, _orig_coords, table_size);
|
||||
|
||||
compute_morphs(morphed_coords, _vertex_morphs, character);
|
||||
orig_coords = morphed_coords;
|
||||
}
|
||||
|
||||
if (!_normal_morphs.empty()) {
|
||||
// We also have some normal morphs. Compute them too.
|
||||
int table_size = sizeof(Normalf) * _orig_norms.size();
|
||||
Normalf *morphed_norms = (Normalf *)alloca(table_size);
|
||||
memcpy(morphed_norms, _orig_norms, table_size);
|
||||
|
||||
compute_morphs(morphed_norms, _normal_morphs, character);
|
||||
orig_norms = morphed_norms;
|
||||
}
|
||||
|
||||
if (!_texcoord_morphs.empty()) {
|
||||
// We have some uv morphs. These don't particularly need to be
|
||||
// done before the joints are computed, but do them now anyway.
|
||||
int table_size = sizeof(TexCoordf) * _orig_texcoords.size();
|
||||
|
||||
// **** Is this right? Test it!
|
||||
// TexCoordf *morphed_texcoords = (TexCoordf *)alloca(table_size);
|
||||
memcpy(character->_cv._texcoords, _orig_texcoords, table_size);
|
||||
|
||||
compute_morphs(character->_cv._texcoords.p(), _texcoord_morphs, character);
|
||||
}
|
||||
|
||||
if (!_color_morphs.empty()) {
|
||||
// We have some color morphs. Do these now too.
|
||||
int table_size = sizeof(Colorf) * _orig_colors.size();
|
||||
|
||||
// **** Is this right? Test it!
|
||||
// Colorf *morphed_colors = (Colorf *)alloca(table_size);
|
||||
memcpy(character->_cv._colors, _orig_colors, table_size);
|
||||
|
||||
compute_morphs(character->_cv._colors.p(), _color_morphs, character);
|
||||
}
|
||||
|
||||
// Now that we've computed all the morphs, it's safe to transform
|
||||
// vertices into their proper coordinate space, according to the
|
||||
// current positions of all the joints.
|
||||
|
||||
LMatrix4f mat = LMatrix4f::ident_mat();
|
||||
int last_joint_index = -1;
|
||||
|
||||
VertexTransforms::const_iterator vti;
|
||||
for (vti = _transforms.begin(); vti != _transforms.end(); ++vti) {
|
||||
const VertexTransform &vt = (*vti);
|
||||
|
||||
// We cache the matrix from the last joint, because we are likely
|
||||
// to encounter the same joint several times in a row.
|
||||
if (vt._joint_index != last_joint_index) {
|
||||
last_joint_index = vt._joint_index;
|
||||
|
||||
// We won't encounter -1 after the first few joints.
|
||||
nassertv(vt._joint_index >= 0);
|
||||
CharacterJoint *joint;
|
||||
DCAST_INTO_V(joint, character->get_part(vt._joint_index));
|
||||
|
||||
mat =
|
||||
joint->_initial_net_transform_inverse *
|
||||
joint->_net_transform;
|
||||
}
|
||||
|
||||
Vertices::const_iterator vi;
|
||||
for (vi = vt._vindex.begin(); vi != vt._vindex.end(); ++vi) {
|
||||
int i = (*vi);
|
||||
character->_cv._coords[i] += (orig_coords[i] * mat) * vt._effect;
|
||||
}
|
||||
for (vi = vt._nindex.begin(); vi != vt._nindex.end(); ++vi) {
|
||||
int i = (*vi);
|
||||
character->_cv._norms[i] += (orig_norms[i] * mat) * vt._effect;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ComputedVertices::make_orig
|
||||
// Access: Public
|
||||
// Description: Copies all the values loaded in the _coords, _norms,
|
||||
// etc. arrays into the corresponding _orig_coords,
|
||||
// etc. arrays.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void ComputedVertices::
|
||||
make_orig(Character *character) {
|
||||
nassertv(character != (Character *)NULL);
|
||||
|
||||
if (character->_cv._coords.empty()) {
|
||||
_orig_coords.clear();
|
||||
} else {
|
||||
_orig_coords = PTA_Vertexf::empty_array(0);
|
||||
_orig_coords.v() = character->_cv._coords.v();
|
||||
}
|
||||
|
||||
if (character->_cv._norms.empty()) {
|
||||
_orig_norms.clear();
|
||||
} else {
|
||||
_orig_norms = PTA_Normalf::empty_array(0);
|
||||
_orig_norms.v() = character->_cv._norms.v();
|
||||
}
|
||||
|
||||
if (character->_cv._colors.empty()) {
|
||||
_orig_colors.clear();
|
||||
} else {
|
||||
_orig_colors = PTA_Colorf::empty_array(0);
|
||||
_orig_colors.v() = character->_cv._colors.v();
|
||||
}
|
||||
|
||||
if (character->_cv._texcoords.empty()) {
|
||||
_orig_texcoords.clear();
|
||||
} else {
|
||||
_orig_texcoords = PTA_TexCoordf::empty_array(0);
|
||||
_orig_texcoords.v() = character->_cv._texcoords.v();
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ComputedVertices::write
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void ComputedVertices::
|
||||
write(ostream &out, Character *character) const {
|
||||
VertexTransforms::const_iterator vti;
|
||||
|
||||
out << "ComputedVertices:\n";
|
||||
for (vti = _transforms.begin(); vti != _transforms.end(); ++vti) {
|
||||
const VertexTransform &vt = (*vti);
|
||||
string name;
|
||||
if (vt._joint_index >= 0) {
|
||||
name = character->get_part(vt._joint_index)->get_name();
|
||||
} else {
|
||||
name = "(root)";
|
||||
}
|
||||
|
||||
out << " " << name << " * " << vt._effect << " : "
|
||||
<< vt._vindex.size() << " vertices and "
|
||||
<< vt._nindex.size() << " normals\n";
|
||||
}
|
||||
|
||||
VertexMorphs::const_iterator vmi;
|
||||
for (vmi = _vertex_morphs.begin(); vmi != _vertex_morphs.end(); ++vmi) {
|
||||
out << " vertex " << (*vmi) << "\n";
|
||||
}
|
||||
|
||||
NormalMorphs::const_iterator nmi;
|
||||
for (nmi = _normal_morphs.begin(); nmi != _normal_morphs.end(); ++nmi) {
|
||||
out << " normal " << (*nmi) << "\n";
|
||||
}
|
||||
|
||||
TexCoordMorphs::const_iterator tmi;
|
||||
for (tmi = _texcoord_morphs.begin(); tmi != _texcoord_morphs.end(); ++tmi) {
|
||||
out << " uv " << (*tmi) << "\n";
|
||||
}
|
||||
|
||||
ColorMorphs::const_iterator cmi;
|
||||
for (cmi = _color_morphs.begin(); cmi != _color_morphs.end(); ++cmi) {
|
||||
out << " color " << (*cmi) << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ComputedVertices::write_datagram
|
||||
// Access: Public
|
||||
// Description: Function to write the important information in
|
||||
// the particular object to a Datagram
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void ComputedVertices::
|
||||
write_datagram(BamWriter *manager, Datagram &me) {
|
||||
int i;
|
||||
|
||||
me.add_uint32(_transforms.size());
|
||||
for(i = 0; i < (int)_transforms.size(); i++){
|
||||
_transforms[i].write_datagram(me);
|
||||
}
|
||||
|
||||
me.add_uint32(_vertex_morphs.size());
|
||||
for(i = 0; i < (int)_vertex_morphs.size(); i++){
|
||||
_vertex_morphs[i].write_datagram(me);
|
||||
}
|
||||
|
||||
me.add_uint32(_normal_morphs.size());
|
||||
for(i = 0; i < (int)_normal_morphs.size(); i++){
|
||||
_normal_morphs[i].write_datagram(me);
|
||||
}
|
||||
|
||||
me.add_uint32(_texcoord_morphs.size());
|
||||
for(i = 0; i < (int)_texcoord_morphs.size(); i++){
|
||||
_texcoord_morphs[i].write_datagram(me);
|
||||
}
|
||||
|
||||
me.add_uint32(_color_morphs.size());
|
||||
for(i = 0; i < (int)_color_morphs.size(); i++){
|
||||
_color_morphs[i].write_datagram(me);
|
||||
}
|
||||
|
||||
//Original Coordinates for vertices, colors, normals and textures
|
||||
WRITE_PTA(manager, me, IPD_Vertexf::write_datagram, _orig_coords)
|
||||
WRITE_PTA(manager, me, IPD_Normalf::write_datagram, _orig_norms)
|
||||
WRITE_PTA(manager, me, IPD_Colorf::write_datagram, _orig_colors)
|
||||
WRITE_PTA(manager, me, IPD_TexCoordf::write_datagram, _orig_texcoords)
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ComputedVertices::fillin
|
||||
// Access: Protected
|
||||
// Description: Function that reads out of the datagram (or asks
|
||||
// manager to read) all of the data that is needed to
|
||||
// re-create this object and stores it in the appropiate
|
||||
// place
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void ComputedVertices::
|
||||
fillin(DatagramIterator &scan, BamReader *manager) {
|
||||
int i, size;
|
||||
|
||||
if (manager->get_file_minor_ver() < 10) {
|
||||
size = scan.get_uint16();
|
||||
} else {
|
||||
size = scan.get_uint32();
|
||||
}
|
||||
for(i = 0; i < size; i++){
|
||||
VertexTransform vt;
|
||||
vt.read_datagram(scan);
|
||||
_transforms.push_back(vt);
|
||||
}
|
||||
|
||||
if (manager->get_file_minor_ver() < 10) {
|
||||
size = scan.get_uint16();
|
||||
} else {
|
||||
size = scan.get_uint32();
|
||||
}
|
||||
for(i = 0; i < size; i++){
|
||||
ComputedVerticesMorphVertex vm;
|
||||
vm.read_datagram(scan);
|
||||
_vertex_morphs.push_back(vm);
|
||||
}
|
||||
|
||||
if (manager->get_file_minor_ver() < 10) {
|
||||
size = scan.get_uint16();
|
||||
} else {
|
||||
size = scan.get_uint32();
|
||||
}
|
||||
for(i = 0; i < size; i++){
|
||||
ComputedVerticesMorphNormal nm;
|
||||
nm.read_datagram(scan);
|
||||
_normal_morphs.push_back(nm);
|
||||
}
|
||||
|
||||
if (manager->get_file_minor_ver() < 10) {
|
||||
size = scan.get_uint16();
|
||||
} else {
|
||||
size = scan.get_uint32();
|
||||
}
|
||||
for(i = 0; i < size; i++){
|
||||
ComputedVerticesMorphTexCoord tm;
|
||||
tm.read_datagram(scan);
|
||||
_texcoord_morphs.push_back(tm);
|
||||
}
|
||||
|
||||
if (manager->get_file_minor_ver() < 10) {
|
||||
size = scan.get_uint16();
|
||||
} else {
|
||||
size = scan.get_uint32();
|
||||
}
|
||||
for(i = 0; i < size; i++){
|
||||
ComputedVerticesMorphColor cm;
|
||||
cm.read_datagram(scan);
|
||||
_color_morphs.push_back(cm);
|
||||
}
|
||||
|
||||
//Original Coordinates for vertices, colors, normals and textures
|
||||
READ_PTA(manager, scan, IPD_Vertexf::read_datagram, _orig_coords)
|
||||
READ_PTA(manager, scan, IPD_Normalf::read_datagram, _orig_norms)
|
||||
READ_PTA(manager, scan, IPD_Colorf::read_datagram, _orig_colors)
|
||||
READ_PTA(manager, scan, IPD_TexCoordf::read_datagram, _orig_texcoords)
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ComputedVertices::make_ComputedVertices
|
||||
// Access: Protected
|
||||
// Description: Factory method to generate a ComputedVertices object
|
||||
////////////////////////////////////////////////////////////////////
|
||||
TypedWritable* ComputedVertices::
|
||||
make_ComputedVertices(const FactoryParams ¶ms)
|
||||
{
|
||||
ComputedVertices *me = new ComputedVertices;
|
||||
DatagramIterator scan;
|
||||
BamReader *manager;
|
||||
|
||||
parse_params(params, scan, manager);
|
||||
me->fillin(scan, manager);
|
||||
return me;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ComputedVertices::register_with_factory
|
||||
// Access: Public, Static
|
||||
// Description: Factory method to generate a ComputedVertices object
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void ComputedVertices::
|
||||
register_with_read_factory(void)
|
||||
{
|
||||
BamReader::get_factory()->register_factory(get_class_type(), make_ComputedVertices);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,115 +0,0 @@
|
|||
// Filename: computedVertices.h
|
||||
// Created by: drose (01Mar99)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef COMPUTEDVERTICES_H
|
||||
#define COMPUTEDVERTICES_H
|
||||
|
||||
#include "pandabase.h"
|
||||
|
||||
#include "dynamicVertices.h"
|
||||
#include "computedVerticesMorph.h"
|
||||
|
||||
#include "vector_ushort.h"
|
||||
#include "typedWritableReferenceCount.h"
|
||||
|
||||
class Character;
|
||||
class CharacterJoint;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : ComputedVertices
|
||||
// Description : These are the vertices that must be animated as part
|
||||
// of the normal character animation. This includes
|
||||
// vertices animated into one or more joints, as well as
|
||||
// morph vertices.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_PANDA ComputedVertices : public TypedWritableReferenceCount {
|
||||
public:
|
||||
INLINE ComputedVertices();
|
||||
|
||||
void update(Character *character);
|
||||
void make_orig(Character *character);
|
||||
|
||||
void write(ostream &out, Character *character) const;
|
||||
|
||||
private:
|
||||
typedef vector_ushort Vertices;
|
||||
|
||||
class EXPCL_PANDA VertexTransform {
|
||||
public:
|
||||
INLINE VertexTransform();
|
||||
VertexTransform(const VertexTransform ©);
|
||||
|
||||
short _joint_index;
|
||||
float _effect;
|
||||
Vertices _vindex;
|
||||
Vertices _nindex;
|
||||
INLINE bool operator < (const VertexTransform &other) const;
|
||||
public:
|
||||
void write_datagram(Datagram &dest);
|
||||
void read_datagram(DatagramIterator &source);
|
||||
};
|
||||
|
||||
typedef pvector<VertexTransform> VertexTransforms;
|
||||
|
||||
VertexTransforms _transforms;
|
||||
|
||||
typedef pvector<ComputedVerticesMorphVertex> VertexMorphs;
|
||||
typedef pvector<ComputedVerticesMorphNormal> NormalMorphs;
|
||||
typedef pvector<ComputedVerticesMorphTexCoord> TexCoordMorphs;
|
||||
typedef pvector<ComputedVerticesMorphColor> ColorMorphs;
|
||||
VertexMorphs _vertex_morphs;
|
||||
NormalMorphs _normal_morphs;
|
||||
TexCoordMorphs _texcoord_morphs;
|
||||
ColorMorphs _color_morphs;
|
||||
|
||||
PTA_Vertexf _orig_coords;
|
||||
PTA_Normalf _orig_norms;
|
||||
PTA_Colorf _orig_colors;
|
||||
PTA_TexCoordf _orig_texcoords;
|
||||
|
||||
public:
|
||||
static void register_with_read_factory(void);
|
||||
virtual void write_datagram(BamWriter* manager, Datagram &me);
|
||||
|
||||
static TypedWritable *make_ComputedVertices(const FactoryParams ¶ms);
|
||||
|
||||
protected:
|
||||
void fillin(DatagramIterator& scan, BamReader* manager);
|
||||
|
||||
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() {
|
||||
TypedWritableReferenceCount::init_type();
|
||||
register_type(_type_handle, "ComputedVertices",
|
||||
TypedWritableReferenceCount::get_class_type());
|
||||
}
|
||||
|
||||
private:
|
||||
static TypeHandle _type_handle;
|
||||
friend class ComputedVerticesMaker;
|
||||
};
|
||||
|
||||
#include "computedVertices.I"
|
||||
|
||||
#endif
|
||||
|
|
@ -1,150 +0,0 @@
|
|||
// Filename: computedVerticesMorph.I
|
||||
// Created by: drose (03Mar99)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "characterSlider.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ComputedVerticesMorphValue2::Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE ComputedVerticesMorphValue2::
|
||||
ComputedVerticesMorphValue2(int index, const VecType &mvector)
|
||||
: _index(index), _vector(mvector) {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ComputedVerticesMorphValue2::Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE ComputedVerticesMorphValue2::
|
||||
ComputedVerticesMorphValue2(void){
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ComputedVerticesMorphValue3::Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE ComputedVerticesMorphValue3::
|
||||
ComputedVerticesMorphValue3(int index, const VecType &mvector)
|
||||
: _index(index), _vector(mvector) {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ComputedVerticesMorphValue3::Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE ComputedVerticesMorphValue3::
|
||||
ComputedVerticesMorphValue3(void){
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ComputedVerticesMorphValue4::Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE ComputedVerticesMorphValue4::
|
||||
ComputedVerticesMorphValue4(int index, const VecType &mvector)
|
||||
: _index(index), _vector(mvector) {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ComputedVerticesMorphValue4::Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE ComputedVerticesMorphValue4::
|
||||
ComputedVerticesMorphValue4(void){
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ComputedVerticesMorph::Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class ValueType, class MorphValueType>
|
||||
ComputedVerticesMorph<ValueType, MorphValueType>::
|
||||
ComputedVerticesMorph() {
|
||||
_slider_index = -1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ComputedVerticesMorph::Copy Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class ValueType, class MorphValueType>
|
||||
ComputedVerticesMorph<ValueType, MorphValueType>::
|
||||
ComputedVerticesMorph(const ComputedVerticesMorph<ValueType, MorphValueType> ©) :
|
||||
_slider_index(copy._slider_index),
|
||||
_morphs(copy._morphs)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ComputedVerticesMorph::output
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class ValueType, class MorphValueType>
|
||||
void ComputedVerticesMorph<ValueType, MorphValueType>::
|
||||
output(ostream &out) const {
|
||||
out << "morph index " << _slider_index << ": "
|
||||
<< _morphs.size() << " points.";
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ComputedVerticesMorph::write_datagram
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class ValueType, class MorphValueType>
|
||||
void ComputedVerticesMorph<ValueType, MorphValueType>::
|
||||
write_datagram(Datagram &dest)
|
||||
{
|
||||
dest.add_int16(_slider_index);
|
||||
dest.add_uint16(_morphs.size());
|
||||
for(int i = 0; i < (int)_morphs.size(); i++)
|
||||
{
|
||||
_morphs[i].write_datagram(dest);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ComputedVerticesMorph::read_datagram
|
||||
// Access: Protected
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class ValueType, class MorphValueType>
|
||||
void ComputedVerticesMorph<ValueType, MorphValueType>::
|
||||
read_datagram(DatagramIterator& source)
|
||||
{
|
||||
_slider_index = source.get_int16();
|
||||
int size = source.get_uint16();
|
||||
for(int i = 0; i < size; i++)
|
||||
{
|
||||
MorphValue mv;
|
||||
mv.read_datagram(source);
|
||||
_morphs.push_back(mv);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,107 +0,0 @@
|
|||
// Filename: computedVerticesMorph.cxx
|
||||
// Created by: jason (23Jun00)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#include "computedVerticesMorph.h"
|
||||
|
||||
#include "datagram.h"
|
||||
#include "datagramIterator.h"
|
||||
#include "bamReader.h"
|
||||
#include "bamWriter.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ComputedVerticesMorphValue2::write_datagram
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void ComputedVerticesMorphValue2::
|
||||
write_datagram(Datagram &dest)
|
||||
{
|
||||
dest.add_uint16(_index);
|
||||
_vector.write_datagram(dest);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ComputedVerticesMorphValue2::read_datagram
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void ComputedVerticesMorphValue2::
|
||||
read_datagram(DatagramIterator &source)
|
||||
{
|
||||
_index = source.get_uint16();
|
||||
_vector.read_datagram(source);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ComputedVerticesMorphValue3::write_datagram
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void ComputedVerticesMorphValue3::
|
||||
write_datagram(Datagram &dest)
|
||||
{
|
||||
dest.add_uint16(_index);
|
||||
_vector.write_datagram(dest);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ComputedVerticesMorphValue3::read_datagram
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void ComputedVerticesMorphValue3::
|
||||
read_datagram(DatagramIterator &source)
|
||||
{
|
||||
_index = source.get_uint16();
|
||||
_vector.read_datagram(source);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ComputedVerticesMorphValue4::write_datagram
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void ComputedVerticesMorphValue4::
|
||||
write_datagram(Datagram &dest)
|
||||
{
|
||||
dest.add_uint16(_index);
|
||||
_vector.write_datagram(dest);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ComputedVerticesMorphValue4::read_datagram
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void ComputedVerticesMorphValue4::
|
||||
read_datagram(DatagramIterator &source)
|
||||
{
|
||||
_index = source.get_uint16();
|
||||
_vector.read_datagram(source);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,136 +0,0 @@
|
|||
// Filename: computedVerticesMorph.h
|
||||
// Created by: drose (03Mar99)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef COMPUTEDVERTICESMORPH_H
|
||||
#define COMPUTEDVERTICESMORPH_H
|
||||
|
||||
#include "pandabase.h"
|
||||
#include "vector_typedWritable.h"
|
||||
|
||||
#include "luse.h"
|
||||
|
||||
class CharacterSlider;
|
||||
class BamReader;
|
||||
class BamWriter;
|
||||
class Datagram;
|
||||
class DatagramIterator;
|
||||
class TypedWritable;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : ComputedVerticesMorphValue2
|
||||
// Description : This is a single vertex morph offset value. This is
|
||||
// the amount by which the given vertex will be offset
|
||||
// when the morph is full on.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_PANDA ComputedVerticesMorphValue2 {
|
||||
public:
|
||||
typedef LVector2f VecType;
|
||||
|
||||
INLINE ComputedVerticesMorphValue2(int index, const VecType &mvector);
|
||||
INLINE ComputedVerticesMorphValue2();
|
||||
|
||||
ushort _index;
|
||||
VecType _vector;
|
||||
|
||||
public:
|
||||
void write_datagram(Datagram &dest);
|
||||
void read_datagram(DatagramIterator &source);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : ComputedVerticesMorphValue3
|
||||
// Description : This is a single vertex morph offset value. This is
|
||||
// the amount by which the given vertex will be offset
|
||||
// when the morph is full on.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_PANDA ComputedVerticesMorphValue3 {
|
||||
public:
|
||||
typedef LVector3f VecType;
|
||||
|
||||
INLINE ComputedVerticesMorphValue3(int index, const VecType &mvector);
|
||||
INLINE ComputedVerticesMorphValue3();
|
||||
|
||||
ushort _index;
|
||||
VecType _vector;
|
||||
|
||||
public:
|
||||
void write_datagram(Datagram &dest);
|
||||
void read_datagram(DatagramIterator &source);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : ComputedVerticesMorphValue4
|
||||
// Description : This is a single vertex morph offset value. This is
|
||||
// the amount by which the given vertex will be offset
|
||||
// when the morph is full on.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_PANDA ComputedVerticesMorphValue4 {
|
||||
public:
|
||||
typedef LVector4f VecType;
|
||||
|
||||
INLINE ComputedVerticesMorphValue4(int index, const VecType &mvector);
|
||||
INLINE ComputedVerticesMorphValue4();
|
||||
|
||||
ushort _index;
|
||||
VecType _vector;
|
||||
|
||||
public:
|
||||
void write_datagram(Datagram &dest);
|
||||
void read_datagram(DatagramIterator &source);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : ComputedVerticesMorph
|
||||
// Description : A list of MorphValues, this represents the complete
|
||||
// effect of a given morph target on a particular class
|
||||
// of vertex values.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class ValueType, class MorphValueType>
|
||||
class ComputedVerticesMorph {
|
||||
public:
|
||||
INLINE ComputedVerticesMorph();
|
||||
INLINE ComputedVerticesMorph(const ComputedVerticesMorph ©);
|
||||
|
||||
typedef MorphValueType MorphValue;
|
||||
typedef pvector<MorphValue> Morphs;
|
||||
|
||||
void output(ostream &out) const;
|
||||
|
||||
short _slider_index;
|
||||
Morphs _morphs;
|
||||
|
||||
public:
|
||||
void write_datagram(Datagram &dest);
|
||||
void read_datagram(DatagramIterator &source);
|
||||
};
|
||||
|
||||
template<class ValueType, class MorphValueType>
|
||||
inline ostream &operator << (ostream &out, const ComputedVerticesMorph<ValueType, MorphValueType> &morph) {
|
||||
morph.output(out);
|
||||
return out;
|
||||
}
|
||||
|
||||
typedef ComputedVerticesMorph<Vertexf, ComputedVerticesMorphValue3> ComputedVerticesMorphVertex;
|
||||
typedef ComputedVerticesMorph<Normalf, ComputedVerticesMorphValue3> ComputedVerticesMorphNormal;
|
||||
typedef ComputedVerticesMorph<TexCoordf, ComputedVerticesMorphValue2> ComputedVerticesMorphTexCoord;
|
||||
typedef ComputedVerticesMorph<Colorf, ComputedVerticesMorphValue4> ComputedVerticesMorphColor;
|
||||
|
||||
#include "computedVerticesMorph.I"
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -23,8 +23,6 @@
|
|||
#include "characterJointBundle.h"
|
||||
#include "characterSlider.h"
|
||||
#include "characterVertexSlider.h"
|
||||
#include "computedVertices.h"
|
||||
#include "dynamicVertices.h"
|
||||
#include "jointVertexTransform.h"
|
||||
#include "dconfig.h"
|
||||
#include "lmatrix4.h"
|
||||
|
|
@ -66,8 +64,6 @@ init_libchar() {
|
|||
CharacterJointBundle::init_type();
|
||||
CharacterSlider::init_type();
|
||||
CharacterVertexSlider::init_type();
|
||||
ComputedVertices::init_type();
|
||||
DynamicVertices::init_type();
|
||||
JointVertexTransform::init_type();
|
||||
|
||||
// This isn't defined in this package, but it *is* essential that it
|
||||
|
|
@ -83,7 +79,6 @@ init_libchar() {
|
|||
CharacterJointBundle::register_with_read_factory();
|
||||
CharacterSlider::register_with_read_factory();
|
||||
CharacterVertexSlider::register_with_read_factory();
|
||||
ComputedVertices::register_with_read_factory();
|
||||
JointVertexTransform::register_with_read_factory();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,113 +0,0 @@
|
|||
// Filename: dynamicVertices.cxx
|
||||
// Created by: drose (01Mar99)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "dynamicVertices.h"
|
||||
#include "config_char.h"
|
||||
#include "bamReader.h"
|
||||
#include "bamWriter.h"
|
||||
#include "datagram.h"
|
||||
#include "datagramIterator.h"
|
||||
#include "ioPtaDatagramLinMath.h"
|
||||
|
||||
TypeHandle DynamicVertices::_type_handle;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DynamicVertices::Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
DynamicVertices::
|
||||
DynamicVertices() {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DynamicVertices::Copy Constructor
|
||||
// Access: Public
|
||||
// Description: Makes a copy of the DynamicVertices object by
|
||||
// reference: the new copy shares the same pointers as
|
||||
// the original.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
DynamicVertices::
|
||||
DynamicVertices(const DynamicVertices ©) :
|
||||
_coords(copy._coords),
|
||||
_norms(copy._norms),
|
||||
_colors(copy._colors),
|
||||
_texcoords(copy._texcoords)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DynamicVertices::named deep_copy Constructor
|
||||
// Access: Public
|
||||
// Description: Makes a complete copy of the indicated
|
||||
// DynamicVertices object, including copying all of its
|
||||
// arrays.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
DynamicVertices DynamicVertices::
|
||||
deep_copy(const DynamicVertices ©) {
|
||||
DynamicVertices dv;
|
||||
if (!copy._coords.empty()) {
|
||||
dv._coords = PTA_Vertexf::empty_array(0);
|
||||
dv._coords.v() = copy._coords.v();
|
||||
}
|
||||
if (!copy._norms.empty()) {
|
||||
dv._norms = PTA_Normalf::empty_array(0);
|
||||
dv._norms.v() = copy._norms.v();
|
||||
}
|
||||
if (!copy._colors.empty()) {
|
||||
dv._colors = PTA_Colorf::empty_array(0);
|
||||
dv._colors.v() = copy._colors.v();
|
||||
}
|
||||
if (!copy._texcoords.empty()) {
|
||||
dv._texcoords = PTA_TexCoordf::empty_array(0);
|
||||
dv._texcoords.v() = copy._texcoords.v();
|
||||
}
|
||||
return dv;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DynamicVertices::write_datagram
|
||||
// Access: Public
|
||||
// Description: Function to write the important information in
|
||||
// the particular object to a Datagram
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void DynamicVertices::
|
||||
write_datagram(BamWriter *manager, Datagram &me)
|
||||
{
|
||||
WRITE_PTA(manager, me, IPD_Vertexf::write_datagram, _coords)
|
||||
WRITE_PTA(manager, me, IPD_Normalf::write_datagram, _norms)
|
||||
WRITE_PTA(manager, me, IPD_Colorf::write_datagram, _colors)
|
||||
WRITE_PTA(manager, me, IPD_TexCoordf::write_datagram, _texcoords)
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DynamicVertices::fillin
|
||||
// Access: Public
|
||||
// Description: Function that reads out of the datagram (or asks
|
||||
// manager to read) all of the data that is needed to
|
||||
// re-create this object and stores it in the appropiate
|
||||
// place
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void DynamicVertices::
|
||||
fillin(DatagramIterator& scan, BamReader* manager)
|
||||
{
|
||||
READ_PTA(manager, scan, IPD_Vertexf::read_datagram, _coords)
|
||||
READ_PTA(manager, scan, IPD_Normalf::read_datagram, _norms)
|
||||
READ_PTA(manager, scan, IPD_Colorf::read_datagram, _colors)
|
||||
READ_PTA(manager, scan, IPD_TexCoordf::read_datagram, _texcoords)
|
||||
}
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
// Filename: dynamicVertices.h
|
||||
// Created by: drose (01Mar99)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef DYNAMICVERTICES_H
|
||||
#define DYNAMICVERTICES_H
|
||||
|
||||
#include "pandabase.h"
|
||||
|
||||
#include "pointerToArray.h"
|
||||
#include "typedObject.h"
|
||||
#include "luse.h"
|
||||
#include "pta_Vertexf.h"
|
||||
#include "pta_Normalf.h"
|
||||
#include "pta_Colorf.h"
|
||||
#include "pta_TexCoordf.h"
|
||||
#include "typedWritable.h"
|
||||
|
||||
class BamReader;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : DynamicVertices
|
||||
// Description : A table of vertices associated with a Character that
|
||||
// must be computed dynamically each frame. This is the
|
||||
// actual table of vertices; see ComputedVertices for
|
||||
// the code to compute their values.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_PANDA DynamicVertices : public TypedWritable {
|
||||
public:
|
||||
DynamicVertices();
|
||||
DynamicVertices(const DynamicVertices ©);
|
||||
static DynamicVertices deep_copy(const DynamicVertices ©);
|
||||
|
||||
PTA_Vertexf _coords;
|
||||
PTA_Normalf _norms;
|
||||
PTA_Colorf _colors;
|
||||
PTA_TexCoordf _texcoords;
|
||||
|
||||
public:
|
||||
virtual void write_datagram(BamWriter* manager, Datagram &me);
|
||||
void fillin(DatagramIterator& scan, BamReader* manager);
|
||||
|
||||
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() {
|
||||
TypedWritable::init_type();
|
||||
register_type(_type_handle, "DynamicVertices",
|
||||
TypedWritable::get_class_type());
|
||||
}
|
||||
|
||||
private:
|
||||
static TypeHandle _type_handle;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -37,8 +37,6 @@
|
|||
// Multiple combinations of these with different weights
|
||||
// are used to implement soft-skinned vertices for an
|
||||
// animated character.
|
||||
//
|
||||
// This is part of the experimental Geom rewrite.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_PANDA JointVertexTransform : public VertexTransform {
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -29,11 +29,10 @@
|
|||
#include "datagramIterator.h"
|
||||
#include "bamReader.h"
|
||||
#include "bamWriter.h"
|
||||
#include "geomTristrip.h"
|
||||
#include "nearly_zero.h"
|
||||
#include "qpgeom.h"
|
||||
#include "qpgeomTristrips.h"
|
||||
#include "qpgeomVertexWriter.h"
|
||||
#include "geom.h"
|
||||
#include "geomTristrips.h"
|
||||
#include "geomVertexWriter.h"
|
||||
|
||||
TypeHandle CollisionInvSphere::_type_handle;
|
||||
|
||||
|
|
@ -308,61 +307,32 @@ fill_viz_geom() {
|
|||
static const int num_slices = 16;
|
||||
static const int num_stacks = 8;
|
||||
|
||||
if (use_qpgeom) {
|
||||
PT(qpGeomVertexData) vdata = new qpGeomVertexData
|
||||
("collision", qpGeomVertexFormat::get_v3(),
|
||||
qpGeom::UH_static);
|
||||
qpGeomVertexWriter vertex(vdata, InternalName::get_vertex());
|
||||
|
||||
PT(qpGeomTristrips) strip = new qpGeomTristrips(qpGeom::UH_static);
|
||||
for (int sl = 0; sl < num_slices; ++sl) {
|
||||
float longitude0 = (float)sl / (float)num_slices;
|
||||
float longitude1 = (float)(sl + 1) / (float)num_slices;
|
||||
vertex.add_data3f(compute_point(0.0, longitude0));
|
||||
for (int st = 1; st < num_stacks; ++st) {
|
||||
float latitude = (float)st / (float)num_stacks;
|
||||
vertex.add_data3f(compute_point(latitude, longitude1));
|
||||
vertex.add_data3f(compute_point(latitude, longitude0));
|
||||
}
|
||||
vertex.add_data3f(compute_point(1.0, longitude0));
|
||||
|
||||
strip->add_next_vertices(num_stacks * 2);
|
||||
strip->close_primitive();
|
||||
PT(GeomVertexData) vdata = new GeomVertexData
|
||||
("collision", GeomVertexFormat::get_v3(),
|
||||
Geom::UH_static);
|
||||
GeomVertexWriter vertex(vdata, InternalName::get_vertex());
|
||||
|
||||
PT(GeomTristrips) strip = new GeomTristrips(Geom::UH_static);
|
||||
for (int sl = 0; sl < num_slices; ++sl) {
|
||||
float longitude0 = (float)sl / (float)num_slices;
|
||||
float longitude1 = (float)(sl + 1) / (float)num_slices;
|
||||
vertex.add_data3f(compute_point(0.0, longitude0));
|
||||
for (int st = 1; st < num_stacks; ++st) {
|
||||
float latitude = (float)st / (float)num_stacks;
|
||||
vertex.add_data3f(compute_point(latitude, longitude1));
|
||||
vertex.add_data3f(compute_point(latitude, longitude0));
|
||||
}
|
||||
|
||||
PT(qpGeom) geom = new qpGeom;
|
||||
geom->set_vertex_data(vdata);
|
||||
geom->add_primitive(strip);
|
||||
|
||||
_viz_geom->add_geom(geom, get_solid_viz_state());
|
||||
|
||||
} else {
|
||||
GeomTristrip *sphere = new GeomTristrip;
|
||||
PTA_Vertexf verts;
|
||||
PTA_int lengths;
|
||||
verts.reserve((num_stacks * 2) * num_slices);
|
||||
lengths.reserve(num_slices);
|
||||
vertex.add_data3f(compute_point(1.0, longitude0));
|
||||
|
||||
for (int sl = 0; sl < num_slices; sl++) {
|
||||
float longitude0 = (float)sl / (float)num_slices;
|
||||
float longitude1 = (float)(sl + 1) / (float)num_slices;
|
||||
verts.push_back(compute_point(0.0, longitude0));
|
||||
for (int st = 1; st < num_stacks; st++) {
|
||||
float latitude = (float)st / (float)num_stacks;
|
||||
verts.push_back(compute_point(latitude, longitude1));
|
||||
verts.push_back(compute_point(latitude, longitude0));
|
||||
}
|
||||
verts.push_back(compute_point(1.0, longitude0));
|
||||
|
||||
lengths.push_back(num_stacks * 2);
|
||||
}
|
||||
|
||||
sphere->set_coords(verts);
|
||||
sphere->set_lengths(lengths);
|
||||
sphere->set_num_prims(num_slices);
|
||||
|
||||
_viz_geom->add_geom(sphere, get_solid_viz_state());
|
||||
strip->add_next_vertices(num_stacks * 2);
|
||||
strip->close_primitive();
|
||||
}
|
||||
|
||||
PT(Geom) geom = new Geom;
|
||||
geom->set_vertex_data(vdata);
|
||||
geom->add_primitive(strip);
|
||||
|
||||
_viz_geom->add_geom(geom, get_solid_viz_state());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
#include "config_collide.h"
|
||||
#include "geom.h"
|
||||
#include "geomNode.h"
|
||||
#include "geomLinestrip.h"
|
||||
#include "boundingLine.h"
|
||||
#include "lensNode.h"
|
||||
#include "lens.h"
|
||||
|
|
@ -30,9 +29,9 @@
|
|||
#include "datagramIterator.h"
|
||||
#include "bamReader.h"
|
||||
#include "bamWriter.h"
|
||||
#include "qpgeom.h"
|
||||
#include "qpgeomLinestrips.h"
|
||||
#include "qpgeomVertexWriter.h"
|
||||
#include "geom.h"
|
||||
#include "geomLinestrips.h"
|
||||
#include "geomVertexWriter.h"
|
||||
|
||||
TypeHandle CollisionLine::_type_handle;
|
||||
|
||||
|
|
@ -83,59 +82,30 @@ fill_viz_geom() {
|
|||
static const int num_points = 100;
|
||||
static const double scale = 100.0;
|
||||
|
||||
if (use_qpgeom) {
|
||||
PT(qpGeomVertexData) vdata = new qpGeomVertexData
|
||||
("collision", qpGeomVertexFormat::get_v3cp(),
|
||||
qpGeom::UH_static);
|
||||
qpGeomVertexWriter vertex(vdata, InternalName::get_vertex());
|
||||
qpGeomVertexWriter color(vdata, InternalName::get_color());
|
||||
PT(GeomVertexData) vdata = new GeomVertexData
|
||||
("collision", GeomVertexFormat::get_v3cp(),
|
||||
Geom::UH_static);
|
||||
GeomVertexWriter vertex(vdata, InternalName::get_vertex());
|
||||
GeomVertexWriter color(vdata, InternalName::get_color());
|
||||
|
||||
for (int i = 0; i < num_points; i++) {
|
||||
double t = ((double)i / (double)num_points - 0.5) * 2.0;
|
||||
vertex.add_data3f(get_origin() + t * scale * get_direction());
|
||||
|
||||
for (int i = 0; i < num_points; i++) {
|
||||
double t = ((double)i / (double)num_points - 0.5) * 2.0;
|
||||
vertex.add_data3f(get_origin() + t * scale * get_direction());
|
||||
|
||||
color.add_data4f(Colorf(1.0f, 1.0f, 1.0f, 1.0f) +
|
||||
fabs(t) * Colorf(0.0f, 0.0f, 0.0f, -1.0f));
|
||||
}
|
||||
|
||||
PT(qpGeomLinestrips) line = new qpGeomLinestrips(qpGeom::UH_static);
|
||||
line->add_next_vertices(num_points);
|
||||
line->close_primitive();
|
||||
|
||||
PT(qpGeom) geom = new qpGeom;
|
||||
geom->set_vertex_data(vdata);
|
||||
geom->add_primitive(line);
|
||||
|
||||
_viz_geom->add_geom(geom, get_other_viz_state());
|
||||
_bounds_viz_geom->add_geom(geom, get_other_bounds_viz_state());
|
||||
|
||||
} else {
|
||||
GeomLinestrip *line = new GeomLinestrip;
|
||||
PTA_Vertexf verts;
|
||||
PTA_Colorf colors;
|
||||
PTA_int lengths;
|
||||
|
||||
verts.reserve(num_points);
|
||||
colors.reserve(num_points);
|
||||
|
||||
for (int i = 0; i < num_points; i++) {
|
||||
double t = ((double)i / (double)num_points - 0.5) * 2.0;
|
||||
verts.push_back(get_origin() + t * scale * get_direction());
|
||||
|
||||
colors.push_back(Colorf(1.0f, 1.0f, 1.0f, 1.0f) +
|
||||
fabs(t) * Colorf(0.0f, 0.0f, 0.0f, -1.0f));
|
||||
}
|
||||
line->set_coords(verts);
|
||||
line->set_colors(colors, G_PER_VERTEX);
|
||||
|
||||
lengths.push_back(num_points-1);
|
||||
line->set_lengths(lengths);
|
||||
|
||||
line->set_num_prims(1);
|
||||
|
||||
_viz_geom->add_geom(line, get_other_viz_state());
|
||||
_bounds_viz_geom->add_geom(line, get_other_bounds_viz_state());
|
||||
color.add_data4f(Colorf(1.0f, 1.0f, 1.0f, 1.0f) +
|
||||
fabs(t) * Colorf(0.0f, 0.0f, 0.0f, -1.0f));
|
||||
}
|
||||
|
||||
PT(GeomLinestrips) line = new GeomLinestrips(Geom::UH_static);
|
||||
line->add_next_vertices(num_points);
|
||||
line->close_primitive();
|
||||
|
||||
PT(Geom) geom = new Geom;
|
||||
geom->set_vertex_data(vdata);
|
||||
geom->add_primitive(line);
|
||||
|
||||
_viz_geom->add_geom(geom, get_other_viz_state());
|
||||
_bounds_viz_geom->add_geom(geom, get_other_bounds_viz_state());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -505,24 +505,4 @@ fillin(DatagramIterator &scan, BamReader *manager) {
|
|||
}
|
||||
|
||||
_from_collide_mask.set_word(scan.get_uint32());
|
||||
if (manager->get_file_minor_ver() < 12) {
|
||||
// Bam files prior to 4.12 stored the into_collide_mask here.
|
||||
// (4.12 and later store this in the PandaNode base class
|
||||
// instead.)
|
||||
CollideMask into_collide_mask;
|
||||
into_collide_mask.set_word(scan.get_uint32());
|
||||
|
||||
// We also introduced the concept of the CollisionNode-reserved
|
||||
// bits and the GeomNode-reserved bits with version 4.12. Prior
|
||||
// to that, CollisionNodes tended to have all bits set. Assume
|
||||
// they didn't mean to have the GeomNode bits set.
|
||||
into_collide_mask &= ~GeomNode::get_default_collide_mask();
|
||||
_from_collide_mask &= ~GeomNode::get_default_collide_mask();
|
||||
|
||||
set_into_collide_mask(into_collide_mask);
|
||||
|
||||
// Bam files prior to 4.12 also had a _flags member, which is no
|
||||
// longer supported.
|
||||
scan.get_uint8();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,11 +33,10 @@
|
|||
#include "bamReader.h"
|
||||
#include "bamWriter.h"
|
||||
#include "omniBoundingVolume.h"
|
||||
#include "geomQuad.h"
|
||||
#include "qpgeom.h"
|
||||
#include "qpgeomTrifans.h"
|
||||
#include "qpgeomLinestrips.h"
|
||||
#include "qpgeomVertexWriter.h"
|
||||
#include "geom.h"
|
||||
#include "geomTrifans.h"
|
||||
#include "geomLinestrips.h"
|
||||
#include "geomVertexWriter.h"
|
||||
|
||||
TypeHandle CollisionPlane::_type_handle;
|
||||
|
||||
|
|
@ -325,56 +324,38 @@ fill_viz_geom() {
|
|||
|
||||
static const double plane_scale = 10.0;
|
||||
|
||||
if (use_qpgeom) {
|
||||
PT(qpGeomVertexData) vdata = new qpGeomVertexData
|
||||
("collision", qpGeomVertexFormat::get_v3(),
|
||||
qpGeom::UH_static);
|
||||
qpGeomVertexWriter vertex(vdata, InternalName::get_vertex());
|
||||
|
||||
vertex.add_data3f(cp + p1 * plane_scale);
|
||||
vertex.add_data3f(cp + p2 * plane_scale);
|
||||
vertex.add_data3f(cp + p3 * plane_scale);
|
||||
vertex.add_data3f(cp + p4 * plane_scale);
|
||||
|
||||
PT(qpGeomTrifans) body = new qpGeomTrifans(qpGeom::UH_static);
|
||||
body->add_consecutive_vertices(0, 4);
|
||||
body->close_primitive();
|
||||
|
||||
PT(qpGeomLinestrips) border = new qpGeomLinestrips(qpGeom::UH_static);
|
||||
border->add_consecutive_vertices(0, 4);
|
||||
border->add_vertex(0);
|
||||
border->close_primitive();
|
||||
|
||||
PT(qpGeom) geom1 = new qpGeom;
|
||||
geom1->set_vertex_data(vdata);
|
||||
geom1->add_primitive(body);
|
||||
|
||||
PT(qpGeom) geom2 = new qpGeom;
|
||||
geom2->set_vertex_data(vdata);
|
||||
geom2->add_primitive(border);
|
||||
|
||||
_viz_geom->add_geom(geom1, get_solid_viz_state());
|
||||
_viz_geom->add_geom(geom2, get_wireframe_viz_state());
|
||||
|
||||
_bounds_viz_geom->add_geom(geom1, get_solid_bounds_viz_state());
|
||||
_bounds_viz_geom->add_geom(geom2, get_wireframe_bounds_viz_state());
|
||||
|
||||
} else {
|
||||
PTA_Vertexf verts;
|
||||
verts.push_back(cp + p1 * plane_scale);
|
||||
verts.push_back(cp + p2 * plane_scale);
|
||||
verts.push_back(cp + p3 * plane_scale);
|
||||
verts.push_back(cp + p4 * plane_scale);
|
||||
|
||||
GeomQuad *quad = new GeomQuad;
|
||||
quad->set_coords(verts);
|
||||
quad->set_num_prims(1);
|
||||
|
||||
_viz_geom->add_geom(quad, get_solid_viz_state());
|
||||
_viz_geom->add_geom(quad, get_wireframe_viz_state());
|
||||
_bounds_viz_geom->add_geom(quad, get_solid_bounds_viz_state());
|
||||
_bounds_viz_geom->add_geom(quad, get_wireframe_bounds_viz_state());
|
||||
}
|
||||
PT(GeomVertexData) vdata = new GeomVertexData
|
||||
("collision", GeomVertexFormat::get_v3(),
|
||||
Geom::UH_static);
|
||||
GeomVertexWriter vertex(vdata, InternalName::get_vertex());
|
||||
|
||||
vertex.add_data3f(cp + p1 * plane_scale);
|
||||
vertex.add_data3f(cp + p2 * plane_scale);
|
||||
vertex.add_data3f(cp + p3 * plane_scale);
|
||||
vertex.add_data3f(cp + p4 * plane_scale);
|
||||
|
||||
PT(GeomTrifans) body = new GeomTrifans(Geom::UH_static);
|
||||
body->add_consecutive_vertices(0, 4);
|
||||
body->close_primitive();
|
||||
|
||||
PT(GeomLinestrips) border = new GeomLinestrips(Geom::UH_static);
|
||||
border->add_consecutive_vertices(0, 4);
|
||||
border->add_vertex(0);
|
||||
border->close_primitive();
|
||||
|
||||
PT(Geom) geom1 = new Geom;
|
||||
geom1->set_vertex_data(vdata);
|
||||
geom1->add_primitive(body);
|
||||
|
||||
PT(Geom) geom2 = new Geom;
|
||||
geom2->set_vertex_data(vdata);
|
||||
geom2->add_primitive(border);
|
||||
|
||||
_viz_geom->add_geom(geom1, get_solid_viz_state());
|
||||
_viz_geom->add_geom(geom2, get_wireframe_viz_state());
|
||||
|
||||
_bounds_viz_geom->add_geom(geom1, get_solid_bounds_viz_state());
|
||||
_bounds_viz_geom->add_geom(geom2, get_wireframe_bounds_viz_state());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -33,14 +33,13 @@
|
|||
#include "datagramIterator.h"
|
||||
#include "bamReader.h"
|
||||
#include "bamWriter.h"
|
||||
#include "geomPolygon.h"
|
||||
#include "transformState.h"
|
||||
#include "clipPlaneAttrib.h"
|
||||
#include "nearly_zero.h"
|
||||
#include "qpgeom.h"
|
||||
#include "qpgeomTrifans.h"
|
||||
#include "qpgeomLinestrips.h"
|
||||
#include "qpgeomVertexWriter.h"
|
||||
#include "geom.h"
|
||||
#include "geomTrifans.h"
|
||||
#include "geomLinestrips.h"
|
||||
#include "geomVertexWriter.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
|
@ -351,14 +350,9 @@ write(ostream &out, int indent_level) const {
|
|||
LMatrix4f to_3d_mat;
|
||||
rederive_to_3d_mat(to_3d_mat);
|
||||
out << "In 3-d space:\n";
|
||||
PTA_Vertexf verts;
|
||||
for (pi = _points.begin(); pi != _points.end(); ++pi) {
|
||||
verts.push_back(to_3d((*pi)._p, to_3d_mat));
|
||||
}
|
||||
|
||||
PTA_Vertexf::const_iterator vi;
|
||||
for (vi = verts.begin(); vi != verts.end(); ++vi) {
|
||||
indent(out, indent_level + 2) << (*vi) << "\n";
|
||||
Vertexf vert = to_3d((*pi)._p, to_3d_mat);
|
||||
indent(out, indent_level + 2) << vert << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -818,61 +812,38 @@ draw_polygon(GeomNode *viz_geom_node, GeomNode *bounds_viz_geom_node,
|
|||
LMatrix4f to_3d_mat;
|
||||
rederive_to_3d_mat(to_3d_mat);
|
||||
|
||||
if (use_qpgeom) {
|
||||
PT(qpGeomVertexData) vdata = new qpGeomVertexData
|
||||
("collision", qpGeomVertexFormat::get_v3(),
|
||||
qpGeom::UH_static);
|
||||
qpGeomVertexWriter vertex(vdata, InternalName::get_vertex());
|
||||
|
||||
Points::const_iterator pi;
|
||||
for (pi = points.begin(); pi != points.end(); ++pi) {
|
||||
vertex.add_data3f(to_3d((*pi)._p, to_3d_mat));
|
||||
}
|
||||
|
||||
PT(qpGeomTrifans) body = new qpGeomTrifans(qpGeom::UH_static);
|
||||
body->add_consecutive_vertices(0, points.size());
|
||||
body->close_primitive();
|
||||
|
||||
PT(qpGeomLinestrips) border = new qpGeomLinestrips(qpGeom::UH_static);
|
||||
border->add_consecutive_vertices(0, points.size());
|
||||
border->add_vertex(0);
|
||||
border->close_primitive();
|
||||
|
||||
PT(qpGeom) geom1 = new qpGeom;
|
||||
geom1->set_vertex_data(vdata);
|
||||
geom1->add_primitive(body);
|
||||
|
||||
PT(qpGeom) geom2 = new qpGeom;
|
||||
geom2->set_vertex_data(vdata);
|
||||
geom2->add_primitive(border);
|
||||
|
||||
viz_geom_node->add_geom(geom1, ((CollisionPolygon *)this)->get_solid_viz_state());
|
||||
viz_geom_node->add_geom(geom2, ((CollisionPolygon *)this)->get_wireframe_viz_state());
|
||||
|
||||
bounds_viz_geom_node->add_geom(geom1, ((CollisionPolygon *)this)->get_solid_bounds_viz_state());
|
||||
bounds_viz_geom_node->add_geom(geom2, ((CollisionPolygon *)this)->get_wireframe_bounds_viz_state());
|
||||
|
||||
} else {
|
||||
PTA_Vertexf verts;
|
||||
Points::const_iterator pi;
|
||||
for (pi = points.begin(); pi != points.end(); ++pi) {
|
||||
verts.push_back(to_3d((*pi)._p, to_3d_mat));
|
||||
}
|
||||
|
||||
PTA_int lengths;
|
||||
lengths.push_back(points.size());
|
||||
|
||||
GeomPolygon *polygon = new GeomPolygon;
|
||||
polygon->set_coords(verts);
|
||||
polygon->set_num_prims(1);
|
||||
polygon->set_lengths(lengths);
|
||||
|
||||
viz_geom_node->add_geom(polygon, ((CollisionPolygon *)this)->get_solid_viz_state());
|
||||
viz_geom_node->add_geom(polygon, ((CollisionPolygon *)this)->get_wireframe_viz_state());
|
||||
|
||||
bounds_viz_geom_node->add_geom(polygon, ((CollisionPolygon *)this)->get_solid_bounds_viz_state());
|
||||
bounds_viz_geom_node->add_geom(polygon, ((CollisionPolygon *)this)->get_wireframe_bounds_viz_state());
|
||||
PT(GeomVertexData) vdata = new GeomVertexData
|
||||
("collision", GeomVertexFormat::get_v3(),
|
||||
Geom::UH_static);
|
||||
GeomVertexWriter vertex(vdata, InternalName::get_vertex());
|
||||
|
||||
Points::const_iterator pi;
|
||||
for (pi = points.begin(); pi != points.end(); ++pi) {
|
||||
vertex.add_data3f(to_3d((*pi)._p, to_3d_mat));
|
||||
}
|
||||
|
||||
PT(GeomTrifans) body = new GeomTrifans(Geom::UH_static);
|
||||
body->add_consecutive_vertices(0, points.size());
|
||||
body->close_primitive();
|
||||
|
||||
PT(GeomLinestrips) border = new GeomLinestrips(Geom::UH_static);
|
||||
border->add_consecutive_vertices(0, points.size());
|
||||
border->add_vertex(0);
|
||||
border->close_primitive();
|
||||
|
||||
PT(Geom) geom1 = new Geom;
|
||||
geom1->set_vertex_data(vdata);
|
||||
geom1->add_primitive(body);
|
||||
|
||||
PT(Geom) geom2 = new Geom;
|
||||
geom2->set_vertex_data(vdata);
|
||||
geom2->add_primitive(border);
|
||||
|
||||
viz_geom_node->add_geom(geom1, ((CollisionPolygon *)this)->get_solid_viz_state());
|
||||
viz_geom_node->add_geom(geom2, ((CollisionPolygon *)this)->get_wireframe_viz_state());
|
||||
|
||||
bounds_viz_geom_node->add_geom(geom1, ((CollisionPolygon *)this)->get_solid_bounds_viz_state());
|
||||
bounds_viz_geom_node->add_geom(geom2, ((CollisionPolygon *)this)->get_wireframe_bounds_viz_state());
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1227,49 +1198,16 @@ write_datagram(BamWriter *manager, Datagram &me) {
|
|||
void CollisionPolygon::
|
||||
fillin(DatagramIterator &scan, BamReader *manager) {
|
||||
CollisionPlane::fillin(scan, manager);
|
||||
if (manager->get_file_minor_ver() < 9) {
|
||||
// Decode old-style collision polygon.
|
||||
|
||||
Points points;
|
||||
size_t size = scan.get_uint16();
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
LPoint2f p;
|
||||
p.read_datagram(scan);
|
||||
|
||||
points.push_back(PointDef(p[0], p[1]));
|
||||
}
|
||||
LPoint2f median;
|
||||
median.read_datagram(scan);
|
||||
|
||||
int axis = scan.get_uint8();
|
||||
bool reversed = (scan.get_uint8() != 0);
|
||||
|
||||
// Now convert the above points into 3-d by the old-style rules.
|
||||
pvector<LPoint3f> verts;
|
||||
Points::const_iterator pi;
|
||||
for (pi = points.begin(); pi != points.end(); ++pi) {
|
||||
verts.push_back(legacy_to_3d((*pi)._p, axis));
|
||||
}
|
||||
if (reversed) {
|
||||
reverse(verts.begin(), verts.end());
|
||||
}
|
||||
|
||||
const LPoint3f *verts_begin = &verts[0];
|
||||
const LPoint3f *verts_end = verts_begin + verts.size();
|
||||
setup_points(verts_begin, verts_end);
|
||||
|
||||
} else {
|
||||
// Load new-style collision polygon.
|
||||
size_t size = scan.get_uint16();
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
LPoint2f p;
|
||||
LVector2f v;
|
||||
p.read_datagram(scan);
|
||||
v.read_datagram(scan);
|
||||
_points.push_back(PointDef(p, v));
|
||||
}
|
||||
_to_2d_mat.read_datagram(scan);
|
||||
size_t size = scan.get_uint16();
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
LPoint2f p;
|
||||
LVector2f v;
|
||||
p.read_datagram(scan);
|
||||
v.read_datagram(scan);
|
||||
_points.push_back(PointDef(p, v));
|
||||
}
|
||||
_to_2d_mat.read_datagram(scan);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
#include "config_collide.h"
|
||||
#include "geom.h"
|
||||
#include "geomNode.h"
|
||||
#include "geomLinestrip.h"
|
||||
#include "boundingLine.h"
|
||||
#include "lensNode.h"
|
||||
#include "lens.h"
|
||||
|
|
@ -30,9 +29,9 @@
|
|||
#include "datagramIterator.h"
|
||||
#include "bamReader.h"
|
||||
#include "bamWriter.h"
|
||||
#include "qpgeom.h"
|
||||
#include "qpgeomLinestrips.h"
|
||||
#include "qpgeomVertexWriter.h"
|
||||
#include "geom.h"
|
||||
#include "geomLinestrips.h"
|
||||
#include "geomVertexWriter.h"
|
||||
|
||||
TypeHandle CollisionRay::_type_handle;
|
||||
|
||||
|
|
@ -155,59 +154,30 @@ fill_viz_geom() {
|
|||
static const int num_points = 100;
|
||||
static const double scale = 100.0;
|
||||
|
||||
if (use_qpgeom) {
|
||||
PT(qpGeomVertexData) vdata = new qpGeomVertexData
|
||||
("collision", qpGeomVertexFormat::get_v3cp(),
|
||||
qpGeom::UH_static);
|
||||
qpGeomVertexWriter vertex(vdata, InternalName::get_vertex());
|
||||
qpGeomVertexWriter color(vdata, InternalName::get_color());
|
||||
PT(GeomVertexData) vdata = new GeomVertexData
|
||||
("collision", GeomVertexFormat::get_v3cp(),
|
||||
Geom::UH_static);
|
||||
GeomVertexWriter vertex(vdata, InternalName::get_vertex());
|
||||
GeomVertexWriter color(vdata, InternalName::get_color());
|
||||
|
||||
for (int i = 0; i < num_points; i++) {
|
||||
double t = ((double)i / (double)num_points);
|
||||
vertex.add_data3f(get_origin() + t * scale * get_direction());
|
||||
|
||||
for (int i = 0; i < num_points; i++) {
|
||||
double t = ((double)i / (double)num_points);
|
||||
vertex.add_data3f(get_origin() + t * scale * get_direction());
|
||||
|
||||
color.add_data4f(Colorf(1.0f, 1.0f, 1.0f, 1.0f) +
|
||||
t * Colorf(0.0f, 0.0f, 0.0f, -1.0f));
|
||||
}
|
||||
|
||||
PT(qpGeomLinestrips) line = new qpGeomLinestrips(qpGeom::UH_static);
|
||||
line->add_next_vertices(num_points);
|
||||
line->close_primitive();
|
||||
|
||||
PT(qpGeom) geom = new qpGeom;
|
||||
geom->set_vertex_data(vdata);
|
||||
geom->add_primitive(line);
|
||||
|
||||
_viz_geom->add_geom(geom, get_other_viz_state());
|
||||
_bounds_viz_geom->add_geom(geom, get_other_bounds_viz_state());
|
||||
|
||||
} else {
|
||||
GeomLinestrip *line = new GeomLinestrip;
|
||||
PTA_Vertexf verts;
|
||||
PTA_Colorf colors;
|
||||
PTA_int lengths;
|
||||
|
||||
verts.reserve(num_points);
|
||||
colors.reserve(num_points);
|
||||
|
||||
for (int i = 0; i < num_points; i++) {
|
||||
double t = ((double)i / (double)num_points);
|
||||
verts.push_back(get_origin() + t * scale * get_direction());
|
||||
|
||||
colors.push_back(Colorf(1.0f, 1.0f, 1.0f, 1.0f) +
|
||||
t * Colorf(0.0f, 0.0f, 0.0f, -1.0f));
|
||||
}
|
||||
line->set_coords(verts);
|
||||
line->set_colors(colors, G_PER_VERTEX);
|
||||
|
||||
lengths.push_back(num_points-1);
|
||||
line->set_lengths(lengths);
|
||||
|
||||
line->set_num_prims(1);
|
||||
|
||||
_viz_geom->add_geom(line, get_other_viz_state());
|
||||
_bounds_viz_geom->add_geom(line, get_other_bounds_viz_state());
|
||||
color.add_data4f(Colorf(1.0f, 1.0f, 1.0f, 1.0f) +
|
||||
t * Colorf(0.0f, 0.0f, 0.0f, -1.0f));
|
||||
}
|
||||
|
||||
PT(GeomLinestrips) line = new GeomLinestrips(Geom::UH_static);
|
||||
line->add_next_vertices(num_points);
|
||||
line->close_primitive();
|
||||
|
||||
PT(Geom) geom = new Geom;
|
||||
geom->set_vertex_data(vdata);
|
||||
geom->add_primitive(line);
|
||||
|
||||
_viz_geom->add_geom(geom, get_other_viz_state());
|
||||
_bounds_viz_geom->add_geom(geom, get_other_bounds_viz_state());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -25,15 +25,14 @@
|
|||
#include "lensNode.h"
|
||||
#include "geomNode.h"
|
||||
#include "lens.h"
|
||||
#include "geomLine.h"
|
||||
#include "geometricBoundingVolume.h"
|
||||
#include "datagram.h"
|
||||
#include "datagramIterator.h"
|
||||
#include "bamReader.h"
|
||||
#include "bamWriter.h"
|
||||
#include "qpgeom.h"
|
||||
#include "qpgeomLines.h"
|
||||
#include "qpgeomVertexWriter.h"
|
||||
#include "geom.h"
|
||||
#include "geomLines.h"
|
||||
#include "geomVertexWriter.h"
|
||||
|
||||
TypeHandle CollisionSegment::_type_handle;
|
||||
|
||||
|
|
@ -159,41 +158,24 @@ fill_viz_geom() {
|
|||
<< "Recomputing viz for " << *this << "\n";
|
||||
}
|
||||
|
||||
if (use_qpgeom) {
|
||||
PT(qpGeomVertexData) vdata = new qpGeomVertexData
|
||||
("collision", qpGeomVertexFormat::get_v3cp(),
|
||||
qpGeom::UH_static);
|
||||
qpGeomVertexWriter vertex(vdata, InternalName::get_vertex());
|
||||
|
||||
vertex.add_data3f(_a);
|
||||
vertex.add_data3f(_b);
|
||||
|
||||
PT(qpGeomLines) line = new qpGeomLines(qpGeom::UH_static);
|
||||
line->add_next_vertices(2);
|
||||
line->close_primitive();
|
||||
|
||||
PT(qpGeom) geom = new qpGeom;
|
||||
geom->set_vertex_data(vdata);
|
||||
geom->add_primitive(line);
|
||||
|
||||
_viz_geom->add_geom(geom, get_other_viz_state());
|
||||
_bounds_viz_geom->add_geom(geom, get_other_bounds_viz_state());
|
||||
|
||||
} else {
|
||||
GeomLine *segment = new GeomLine;
|
||||
PTA_Vertexf verts;
|
||||
PTA_Colorf colors;
|
||||
verts.push_back(_a);
|
||||
verts.push_back(_b);
|
||||
colors.push_back(Colorf(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
segment->set_coords(verts);
|
||||
segment->set_colors(colors, G_OVERALL);
|
||||
|
||||
segment->set_num_prims(1);
|
||||
|
||||
_viz_geom->add_geom(segment, get_other_viz_state());
|
||||
_bounds_viz_geom->add_geom(segment, get_other_bounds_viz_state());
|
||||
}
|
||||
PT(GeomVertexData) vdata = new GeomVertexData
|
||||
("collision", GeomVertexFormat::get_v3cp(),
|
||||
Geom::UH_static);
|
||||
GeomVertexWriter vertex(vdata, InternalName::get_vertex());
|
||||
|
||||
vertex.add_data3f(_a);
|
||||
vertex.add_data3f(_b);
|
||||
|
||||
PT(GeomLines) line = new GeomLines(Geom::UH_static);
|
||||
line->add_next_vertices(2);
|
||||
line->close_primitive();
|
||||
|
||||
PT(Geom) geom = new Geom;
|
||||
geom->set_vertex_data(vdata);
|
||||
geom->add_primitive(line);
|
||||
|
||||
_viz_geom->add_geom(geom, get_other_viz_state());
|
||||
_bounds_viz_geom->add_geom(geom, get_other_bounds_viz_state());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -301,16 +301,9 @@ write_datagram(BamWriter *, Datagram &me) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void CollisionSolid::
|
||||
fillin(DatagramIterator &scan, BamReader *manager) {
|
||||
if (manager->get_file_minor_ver() < 7) {
|
||||
bool tangible = scan.get_bool();
|
||||
if (!tangible) {
|
||||
_flags &= ~F_tangible;
|
||||
}
|
||||
} else {
|
||||
_flags = scan.get_uint8();
|
||||
if ((_flags & F_effective_normal) != 0) {
|
||||
_effective_normal.read_datagram(scan);
|
||||
}
|
||||
_flags = scan.get_uint8();
|
||||
if ((_flags & F_effective_normal) != 0) {
|
||||
_effective_normal.read_datagram(scan);
|
||||
}
|
||||
|
||||
// The viz is always stale after reading from a bam file.
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue