open_toontown_panda3d/panda/src/grutil/cardMaker.I

181 lines
6.5 KiB
Plaintext

// Filename: cardMaker.I
// Created by: drose (16Mar02)
//
////////////////////////////////////////////////////////////////////
//
// 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: CardMaker::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE CardMaker::
CardMaker(const string &name) : Namable(name) {
reset();
}
////////////////////////////////////////////////////////////////////
// Function: CardMaker::Destructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE CardMaker::
~CardMaker() {
}
////////////////////////////////////////////////////////////////////
// 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_has_3d_uvs
// Access: Public
// Description: Sets the flag indicating whether vertices will be
// generated with 3-component UVW's (true) or
// 2-component UV's (the default, false). Normally,
// this will be implicitly set by setting the uv_range.
////////////////////////////////////////////////////////////////////
INLINE void CardMaker::
set_has_3d_uvs(bool flag) {
_has_3d_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) {
_ll_pos.set(left, 0.0f, bottom);
_lr_pos.set(right, 0.0f, bottom);
_ur_pos.set(right, 0.0f, top);
_ul_pos.set(left, 0.0f, top);
}
////////////////////////////////////////////////////////////////////
// Function: CardMaker::set_frame
// Access: Public
// Description: Sets the size of the card.
////////////////////////////////////////////////////////////////////
INLINE void CardMaker::
set_frame(const LVecBase4f &frame) {
set_frame(frame[0], frame[1], frame[2], frame[3]);
}
////////////////////////////////////////////////////////////////////
// Function: CardMaker::set_frame
// Access: Public
// Description: Sets the size of the card.
////////////////////////////////////////////////////////////////////
INLINE void CardMaker::
set_frame(const Vertexf &ll, const Vertexf &lr, const Vertexf &ur, const Vertexf &ul)
{
_ll_pos = ll;
_lr_pos = lr;
_ur_pos = ur;
_ul_pos = ul;
}
////////////////////////////////////////////////////////////////////
// Function: CardMaker::set_frame_fullscreen_quad
// Access: Public
// Description: Sets the card to (-1,1,-1,1), which is appropriate
// if you plan to parent it to render2d and use it
// as a fullscreen quad.
////////////////////////////////////////////////////////////////////
INLINE void CardMaker::
set_frame_fullscreen_quad()
{
set_frame(-1,1,-1,1);
}
////////////////////////////////////////////////////////////////////
// Function: CardMaker::set_color
// Access: Public
// Description: Sets the color of the card.
////////////////////////////////////////////////////////////////////
INLINE void CardMaker::
set_color(float r, float g, float b, float a) {
set_color(LVecBase4f(r, g, b, a));
}
////////////////////////////////////////////////////////////////////
// Function: CardMaker::set_color
// Access: Public
// Description: Sets the color of the card.
////////////////////////////////////////////////////////////////////
INLINE void CardMaker::
set_color(const LVecBase4f &color) {
_color = color;
_has_color = true;
}
////////////////////////////////////////////////////////////////////
// Function: CardMaker::set_has_normals
// Access: Public
// Description: Sets the flag indicating whether vertices will be
// generated with normals or not. Normals are required
// if you intend to enable lighting on the card, but are
// just wasted space and bandwidth otherwise, so there
// is a (slight) optimization for disabling them. If
// enabled, the normals will be generated perpendicular
// to the card's face.
////////////////////////////////////////////////////////////////////
INLINE void CardMaker::
set_has_normals(bool flag) {
_has_normals = flag;
}
////////////////////////////////////////////////////////////////////
// Function: CardMaker::set_source_geometry
// Access: Published
// Description: Sets a node that will be copied (and scaled and
// translated) to generate the frame, instead of
// generating a new polygon. The node may contain
// arbitrary geometry that describes a flat polygon
// contained within the indicated left, right, bottom,
// top frame.
//
// When generate() is called, the geometry in this node
// will be scaled and translated appropriately to give
// it the size and aspect ratio specified by
// set_frame().
////////////////////////////////////////////////////////////////////
INLINE void CardMaker::
set_source_geometry(PandaNode *node, const LVecBase4f &frame) {
_source_geometry = node;
_source_frame = frame;
}
////////////////////////////////////////////////////////////////////
// Function: CardMaker::clear_source_geometry
// Access: Published
// Description: Removes the node specified by an earlier call to
// set_source_geometry().
////////////////////////////////////////////////////////////////////
INLINE void CardMaker::
clear_source_geometry() {
_source_geometry = (PandaNode *)NULL;
}