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

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

Fix camera reset for nanovis. Includes refactoring of vector/matrix classes
in nanovis to consolidate into vrmath library. Also add preliminary canonical
view control to clients for testing.

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