*** empty log message ***

This commit is contained in:
David Rose 2001-07-06 18:14:10 +00:00
parent 7febe83b3a
commit 6027a40cf9
4 changed files with 226 additions and 2 deletions

View File

@ -7,10 +7,12 @@
sgraph gobj linmath putil
#define SOURCES \
config_grutil.cxx config_grutil.h lineSegs.I lineSegs.cxx \
lineSegs.h
cardMaker.I cardMaker.cxx cardMaker.h \
config_grutil.cxx config_grutil.h \
lineSegs.I lineSegs.cxx lineSegs.h
#define INSTALL_HEADERS \
cardMaker.I cardMaker.h \
lineSegs.I lineSegs.h
#define IGATESCAN all

View File

@ -0,0 +1,83 @@
// Filename: cardMaker.I
// Created by: drose (06Jul01)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://www.panda3d.org/license.txt .
//
// To contact the maintainers of this program write to
// panda3d@yahoogroups.com .
//
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
// Function: CardMaker::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE CardMaker::
CardMaker() {
reset();
}
////////////////////////////////////////////////////////////////////
// Function: CardMaker::Destructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE CardMaker::
~CardMaker() {
}
////////////////////////////////////////////////////////////////////
// Function: CardMaker::set_uv_range
// Access: Public
// Description: Sets the range of UV's that will be applied to the
// vertices. If set_has_uvs() is true (as it is by
// default), the vertices will be generated with the
// indicated range of UV's, which will be useful if a
// texture is applied.
////////////////////////////////////////////////////////////////////
INLINE void CardMaker::
set_uv_range(const TexCoordf &ll, const TexCoordf &ur) {
_ll = ll;
_ur = ur;
}
////////////////////////////////////////////////////////////////////
// Function: CardMaker::set_has_uvs
// Access: Public
// Description: Sets the flag indicating whether vertices will be
// generated with UV's or not.
////////////////////////////////////////////////////////////////////
INLINE void CardMaker::
set_has_uvs(bool flag) {
_has_uvs = flag;
}
////////////////////////////////////////////////////////////////////
// Function: CardMaker::set_frame
// Access: Public
// Description: Sets the size of the card.
////////////////////////////////////////////////////////////////////
INLINE void CardMaker::
set_frame(float left, float right, float bottom, float top) {
set_frame(LVecBase4f(left, right, bottom, top));
}
////////////////////////////////////////////////////////////////////
// Function: CardMaker::set_frame
// Access: Public
// Description: Sets the size of the card.
////////////////////////////////////////////////////////////////////
INLINE void CardMaker::
set_frame(const LVecBase4f &frame) {
_frame = frame;
}

View File

@ -0,0 +1,83 @@
// Filename: cardMaker.cxx
// Created by: drose (06Jul01)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://www.panda3d.org/license.txt .
//
// To contact the maintainers of this program write to
// panda3d@yahoogroups.com .
//
////////////////////////////////////////////////////////////////////
#include "cardMaker.h"
#include "geomNode.h"
#include "geomTristrip.h"
////////////////////////////////////////////////////////////////////
// Function: CardMaker::reset
// Access: Public
// Description: Resets all the parameters to their initial defaults.
////////////////////////////////////////////////////////////////////
void CardMaker::
reset() {
_has_uvs = true;
_ll.set(0.0, 0.0);
_ur.set(1.0, 1.0);
_frame.set(0.0, 1.0, 0.0, 1.0);
}
////////////////////////////////////////////////////////////////////
// Function: CardMaker::generate
// Access: Public
// Description: Generates a GeomNode that renders the specified
// geometry.
////////////////////////////////////////////////////////////////////
PT_Node CardMaker::
generate() {
PT(GeomNode) gnode = new GeomNode("card");
Geom *geom = new GeomTristrip;
gnode->add_geom(geom);
float left = _frame[0];
float right = _frame[1];
float bottom = _frame[2];
float top = _frame[3];
PTA_int lengths(0);
lengths.push_back(4);
PTA_Vertexf verts;
verts.push_back(Vertexf::rfu(left, 0.0, top));
verts.push_back(Vertexf::rfu(left, 0.0, bottom));
verts.push_back(Vertexf::rfu(right, 0.0, top));
verts.push_back(Vertexf::rfu(right, 0.0, bottom));
geom->set_num_prims(1);
geom->set_lengths(lengths);
geom->set_coords(verts, G_PER_VERTEX);
PTA_Colorf colors;
colors.push_back(Colorf(1.0, 1.0, 1.0, 1.0));
geom->set_colors(colors, G_OVERALL);
if (_has_uvs) {
PTA_TexCoordf uvs;
uvs.push_back(TexCoordf(_ll[0], _ur[1]));
uvs.push_back(TexCoordf(_ll[0], _ll[1]));
uvs.push_back(TexCoordf(_ur[0], _ur[1]));
uvs.push_back(TexCoordf(_ur[0], _ll[1]));
geom->set_texcoords(uvs, G_PER_VERTEX);
}
return gnode.p();
}

View File

@ -0,0 +1,56 @@
// Filename: cardMaker.h
// Created by: drose (06Jul01)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://www.panda3d.org/license.txt .
//
// To contact the maintainers of this program write to
// panda3d@yahoogroups.com .
//
////////////////////////////////////////////////////////////////////
#ifndef CARDMAKER_H
#define CARDMAKER_H
#include "pandabase.h"
#include "luse.h"
#include "pt_Node.h"
////////////////////////////////////////////////////////////////////
// Class : CardMaker
// Description : This class generates 2-d "cards", that is,
// rectangular polygons, particularly useful for showing
// textures etc. in the 2-d scene graph.
////////////////////////////////////////////////////////////////////
class CardMaker {
PUBLISHED:
INLINE CardMaker();
INLINE ~CardMaker();
void reset();
INLINE void set_uv_range(const TexCoordf &ll, const TexCoordf &ur);
INLINE void set_has_uvs(bool flag);
INLINE void set_frame(float left, float right, float bottom, float top);
INLINE void set_frame(const LVecBase4f &frame);
PT_Node generate();
private:
bool _has_uvs;
TexCoordf _ll, _ur;
LVecBase4f _frame;
};
#include "cardMaker.I"
#endif