-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSampleParticle.cpp
More file actions
122 lines (99 loc) · 2.26 KB
/
Copy pathSampleParticle.cpp
File metadata and controls
122 lines (99 loc) · 2.26 KB
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
121
122
#include "SampleParticle.h"
SampleParticle::SampleParticle( const std::string& name ):
BaseSystem( name ),
m_sx( 1.0f ),
m_sy( 1.0f ),
m_sz( 1.0f )
{
setVector( m_pos, 0, 0, 0 );
} // SampleParticle
void SampleParticle::getState( double* p )
{
VecCopy( p, m_pos );
} // SampleParticle::getState
void SampleParticle::setState( double *p )
{
VecCopy(m_pos,p);
} // SampleParticle::setState
void SampleParticle::reset( double time )
{
setVector( m_pos, 0, 0, 0 );
} // SampleParticle::Reset
int SampleParticle::command(int argc, myCONST_SPEC char **argv)
{
if( argc < 1 )
{
animTcl::OutputMessage("system %s: wrong number of params.", m_name.c_str()) ;
return TCL_ERROR ;
}
else if( strcmp(argv[0], "read") == 0 )
{
if( argc == 2 )
{
m_model.ReadOBJ(argv[1]) ;
glmFacetNormals(&m_model) ;
glmVertexNormals(&m_model, 90) ;
return TCL_OK ;
}
else
{
animTcl::OutputMessage("Usage: read <file_name>") ;
return TCL_ERROR ;
}
}
else if( strcmp(argv[0], "scale") == 0 )
{
if( argc == 4 )
{
m_sx = (float)atof(argv[1]) ;
m_sy = (float)atof(argv[2]) ;
m_sz = (float)atof(argv[3]) ;
}
else
{
animTcl::OutputMessage("Usage: scale <sx> <sy> <sz> ") ;
return TCL_ERROR ;
}
}
else if( strcmp(argv[0], "pos") == 0 )
{
if( argc == 4 )
{
m_pos[0] = atof(argv[1]) ;
m_pos[1] = atof(argv[2]) ;
m_pos[2] = atof(argv[3]) ;
}
else
{
animTcl::OutputMessage("Usage: pos <x> <y> <z> ") ;
return TCL_ERROR ;
}
}
else if( strcmp(argv[0], "flipNormals") == 0 )
{
flipNormals() ;
return TCL_OK ;
}
else if( strcmp(argv[0], "reset") == 0)
{
double p[3] = {0,0,0} ;
setState(p) ;
}
glutPostRedisplay() ;
return TCL_OK ;
} // SampleParticle::command
void SampleParticle::display( GLenum mode )
{
/*glEnable(GL_LIGHTING) ;
glMatrixMode(GL_MODELVIEW) ;
glPushMatrix() ;
glPushAttrib(GL_ALL_ATTRIB_BITS);
glTranslated(m_pos[0],m_pos[1],m_pos[2]) ;
glScalef(m_sx,m_sy,m_sz) ;
if( m_model.numvertices > 0 )
glmDraw(&m_model, GLM_SMOOTH | GLM_MATERIAL);
else
glutSolidSphere(1.0,20,20) ;
glPopMatrix();
glPopAttrib();*/
} // SampleParticle::display