source: trunk/packages/vizservers/nanovis/ConvexPolygon.h @ 3611

Last change on this file since 3611 was 3611, checked in by ldelgass, 11 years ago

Use nv namespace for classes in nanovis rather than prefixing class names with
Nv (still need to convert shader classes).

  • Property svn:eol-style set to native
File size: 1.9 KB
Line 
1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 * ----------------------------------------------------------------------
4 * ConvexPolygon.h: convex polygon class
5 *
6 * ======================================================================
7 *  AUTHOR:  Wei Qiao <qiaow@purdue.edu>
8 *           Purdue Rendering and Perceptualization Lab (PURPL)
9 *
10 *  Copyright (c) 2004-2013  HUBzero Foundation, LLC
11 *
12 *  See the file "license.terms" for information on usage and
13 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
14 * ======================================================================
15 */
16#ifndef _CONVEX_POLYGON_H_
17#define _CONVEX_POLYGON_H_
18
19#include <assert.h>
20#include <vector>
21
22#include <vrmath/Vector3f.h>
23#include <vrmath/Vector4f.h>
24#include <vrmath/Matrix4x4d.h>
25
26#include "Plane.h"
27
28namespace nv {
29
30typedef std::vector<vrmath::Vector4f> VertexVector;
31typedef std::vector<vrmath::Vector4f> TexVector;
32
33class ConvexPolygon
34{
35public:
36    ConvexPolygon()
37    {}
38
39    ConvexPolygon(VertexVector vertices);
40
41    void transform(const vrmath::Matrix4x4d& mat);
42
43    void translate(const vrmath::Vector4f& shift);
44
45    // Clips the polygon, retaining the portion where ax + by + cz + d >= 0
46    bool clip(nv::Plane& clipPlane, bool copyToTexcoords);
47
48    void emit(bool useTexture);
49
50    void emit(bool useTexture, const vrmath::Vector3f& shift, const vrmath::Vector3f& scale);
51
52    void copyVerticesToTexcoords();
53
54    void setId(int id)
55    {
56        volumeId = id;
57    }
58
59    void appendVertex(const vrmath::Vector4f& vert)
60    {
61        vertices.push_back(vert);
62    }
63
64    void insertVertex(unsigned int index, const vrmath::Vector4f& vert)
65    {
66        assert(index < vertices.size());
67        vertices.insert(vertices.begin() + index, vert);
68    }
69
70    VertexVector vertices;
71    TexVector texcoords;
72    int volumeId;       //which volume this polygon slice belongs to
73};
74
75}
76
77#endif
Note: See TracBrowser for help on using the repository browser.