Panda3D
Loading...
Searching...
No Matches
eggVertexUV.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file eggVertexUV.h
10 * @author drose
11 * @date 2004-07-20
12 */
13
14#ifndef EGGVERTEXUV_H
15#define EGGVERTEXUV_H
16
17#include "pandabase.h"
18
19#include "eggMorphList.h"
20#include "eggNamedObject.h"
21
22#include "luse.h"
23
24/**
25 * The set of UV's that may or may not be assigned to a vertex. To support
26 * multitexturing, there may be multiple sets of UV's on a particular vertex,
27 * each with its own name.
28 */
29class EXPCL_PANDA_EGG EggVertexUV : public EggNamedObject {
30PUBLISHED:
31 explicit EggVertexUV(const std::string &name, const LTexCoordd &uv);
32 explicit EggVertexUV(const std::string &name, const LTexCoord3d &uvw);
33 EggVertexUV(const EggVertexUV &copy);
34 EggVertexUV &operator = (const EggVertexUV &copy);
35 virtual ~EggVertexUV();
36
37 INLINE static std::string filter_name(const std::string &name);
38 INLINE void set_name(const std::string &name);
39
40 INLINE int get_num_dimensions() const;
41 INLINE bool has_w() const;
42 INLINE LTexCoordd get_uv() const;
43 INLINE const LTexCoord3d &get_uvw() const;
44 INLINE void set_uv(const LTexCoordd &texCoord);
45 INLINE void set_uvw(const LTexCoord3d &texCoord);
46
47 INLINE bool has_tangent() const;
48 INLINE bool has_tangent4() const;
49 INLINE const LNormald &get_tangent() const;
50 INLINE LVecBase4d get_tangent4() const;
51 INLINE void set_tangent(const LNormald &tangent);
52 INLINE void set_tangent4(const LVecBase4d &tangent);
53 INLINE void clear_tangent();
54
55 INLINE bool has_binormal() const;
56 INLINE const LNormald &get_binormal() const;
57 INLINE void set_binormal(const LNormald &binormal);
58 INLINE void clear_binormal();
59
60 static PT(EggVertexUV) make_average(const EggVertexUV *first,
61 const EggVertexUV *second);
62
63 void transform(const LMatrix4d &mat);
64
65 void write(std::ostream &out, int indent_level) const;
66 int compare_to(const EggVertexUV &other) const;
67
68 EggMorphTexCoordList _duvs;
69
70private:
71 enum Flags {
72 F_has_tangent = 0x001,
73 F_has_binormal = 0x002,
74 F_has_w = 0x004,
75 F_has_tangent4 = 0x008,
76
77 // Only defined temporarily as we can't add a float to this class in 1.10.
78 F_flip_computed_binormal = 0x010,
79 };
80
81 int _flags;
82 LNormald _tangent;
83 LNormald _binormal;
84 LTexCoord3d _uvw;
85
86public:
87 static TypeHandle get_class_type() {
88 return _type_handle;
89 }
90 static void init_type() {
91 EggNamedObject::init_type();
92 register_type(_type_handle, "EggVertexUV",
93 EggNamedObject::get_class_type());
94 }
95 virtual TypeHandle get_type() const {
96 return get_class_type();
97 }
98 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
99
100private:
101 static TypeHandle _type_handle;
102};
103
104#include "eggVertexUV.I"
105
106#endif
void transform(const LMatrix4d &mat)
Applies the indicated transformation matrix to the UV's tangent and/or binormal.
static std::string filter_name(const std::string &name)
Returns the actual name that should be set for a given name string.
Definition eggVertexUV.I:20
LTexCoordd get_uv() const
Returns the texture coordinate pair, if get_num_dimensions() is 2.
Definition eggVertexUV.I:57
bool has_w() const
Returns true if the texture coordinate has a third, w component, false if it is just a normal 2-d tex...
Definition eggVertexUV.I:49
void set_uv(const LTexCoordd &texCoord)
Sets the texture coordinate pair.
Definition eggVertexUV.I:77
int get_num_dimensions() const
Returns the number of components of the texture coordinate set.
Definition eggVertexUV.I:40
void set_uvw(const LTexCoord3d &texCoord)
Sets the texture coordinate triple.
Definition eggVertexUV.I:87
void set_tangent4(const LVecBase4d &tangent)
Sets the tangent vector, along with a fourth parameter that is multiplied with the result of cross(no...
const LTexCoord3d & get_uvw() const
Returns the texture coordinate triple, if get_num_dimensions() is 3.
Definition eggVertexUV.I:68
int compare_to(const EggVertexUV &other) const
An ordering operator to compare two vertices for sorting order.
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...