File: shape.cc

package info (click to toggle)
miaviewit 1.0.5-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 3,120 kB
  • sloc: cpp: 16,811; sh: 4,004; ansic: 379; makefile: 165
file content (120 lines) | stat: -rw-r--r-- 2,191 bytes parent folder | download | duplicates (4)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/* -*- mia-c++ -*-
 *
 * This file is part of viewitgui - a library and program for the
 * visualization of 3D data sets. 
 *
 * Copyright (c) Leipzig, Madrid 1999-2013 Mirco Hellmann, Gert Wollny
 *
 * viewitgui is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * viewitgui is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with viewitgui; if not, see <http://www.gnu.org/licenses/>.
 */


#include <GL/gl.h>
#include <GL/glu.h>

#include <stdexcept>
#include <iostream>

#include <viewit/glerror.hh>

#include <viewit/shape.hh>



void CShape::pre_draw()
{
}

void CShape::gl_attach()
{
}
	
void CShape::gl_detach()
{
}
	

CSphereShape::CSphereShape(float radius):
	m_radius(radius)
{
}


void CSphereShape::pre_draw()
{
	glScalef(m_radius, m_radius, m_radius);
}



void CDeformedShape::pre_draw()
{
	make_gl_op();
}
	
	
void CDeformedShape::gl_attach()
{
}

void CDeformedShape::gl_detach()
{
}


CEllipsoidShape::CEllipsoidShape(const  C3DFVector& scale, const C3DFVector& rot):
	m_scale(scale),
	m_rot(rot)
{
}
	
void CEllipsoidShape::make_gl_op()
{
	glScalef(m_scale.x, m_scale.y, m_scale.z);
	glRotatef(m_rot.x, 1.0,0.0,0.0);
	glRotatef(m_rot.y, 0.0,1.0,0.0);
	glRotatef(m_rot.z, 0.0,0.0,1.0);
}


CFreeShape::CFreeShape(const C3DFMatrix& defo)
{
	memset(m_defo,0,sizeof(m_defo));
	float *pdefo = m_defo;
	
	m_defo[0] = defo.x.x; 
	m_defo[1] = defo.x.y; 
	m_defo[2] = defo.x.z; 
	m_defo[3] = 0.0f; 

	m_defo[4] = defo.y.x; 
	m_defo[5] = defo.y.y; 
	m_defo[6] = defo.y.z; 
	m_defo[7] = 0.0f; 

	m_defo[8] = defo.z.x; 
	m_defo[9] = defo.z.y; 
	m_defo[10] = defo.z.z; 
	m_defo[11] = 0.0f; 
	
	m_defo[12] = 0.0f; 
	m_defo[13] = 0.0f; 
	m_defo[14] = 0.0f; 
	m_defo[15]= 1.0f;
}

void CFreeShape::make_gl_op()
{
	glMultMatrixf(m_defo);
}