File: box.h

package info (click to toggle)
python-visual 3.2.9-4.1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 2,796 kB
  • ctags: 2,664
  • sloc: cpp: 11,958; sh: 8,185; python: 3,709; ansic: 480; makefile: 311
file content (67 lines) | stat: -rw-r--r-- 1,401 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef VISUAL_BOX_H
#define VISUAL_BOX_H

// Copyright (c) 2000, 2001, 2002, 2003 by David Scherer and others.
// See the file license.txt for complete license terms.
// See the file authors.txt for a complete list of contributors.

#include "prim.h"
#include "exceptions.h"

namespace visual {

class box : public Primitive
{
 private:
	double width, height;
	
 public:
	inline box() : width(1.0), height(1.0) {}
	box( const box& other) 
		: Primitive( other), width( other.width), height( other.height) 
	{}

	inline double get_width()
	{ return width; }

	inline void set_width( double w)
	{ write_lock L( mtx); width = w; }

	inline double get_height()
	{return height; }

	inline void set_height( double h)
	{ write_lock L( mtx); height = h; }

	inline double get_length()
	{ return axis.mag(); }
	
	inline void set_length( double l)
	{
		if (!axis)
			throw python::ZeroDivisionError("Degenerate primitive");
		axis = axis * (l / axis.mag());
	}

	inline vector get_size()
	{ return getScale(); }

	inline void set_size( vector v)
	{	
		axis = axis.norm() * v.x;
		write_lock L( mtx);
		height = v.y;
		width = v.z;
	}

	inline void set_size_t( boost::python::object t) { this->set_size( vector(t)); }

	virtual vector getScale();
	virtual double rayIntersect( const vector& camera, const vector& ray);
	virtual void glRender( rView& view);
};


} // !namespace visual

#endif // !VISUAL_BOX_H