source: nanovis/branches/1.1/ConvexPolygon.h @ 4906

Last change on this file since 4906 was 4889, checked in by ldelgass, 9 years ago

Merge r3611:3618 from trunk

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