Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91263387
PointsObject.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Nov 9, 11:42
Size
2 KB
Mime Type
text/x-python
Expires
Mon, Nov 11, 11:42 (2 d)
Engine
blob
Format
Raw Data
Handle
22232361
Attached To
rGLUPS glups
PointsObject.py
View Options
from
OpenGL.GL
import
*
from
OpenGL.GLU
import
*
from
OpenGL.GLUT
import
*
from
GLObject
import
*
from
ParameterList
import
*
from
numpy
import
*
import
libgl
class
PointsObject
(
GLObject
):
def
__init__
(
self
,
nb
,
ID
=
'Points'
,
var
=
None
,
mn
=
None
,
mx
=
None
,
pal
=
None
):
self
.
ID
=
ID
self
.
ListID
=
None
self
.
nb
=
nb
self
.
mn
=
mn
self
.
mx
=
mx
self
.
var
=
var
self
.
pal
=
pal
# init parameters
self
.
param
=
ParametersList
(
self
.
ID
)
self
.
param
[
"Color_r"
]
=
1.0
self
.
param
[
"Color_g"
]
=
1.0
self
.
param
[
"Color_b"
]
=
1.0
self
.
param
[
"Color_a"
]
=
1.0
self
.
param
[
"show"
]
=
1
self
.
GenList
()
def
GenList
(
self
):
if
self
.
ListID
==
None
:
self
.
ListID
=
glGenLists
(
1
)
glNewList
(
self
.
ListID
,
GL_COMPILE
)
#glBegin(GL_POINTS)
#for i in range(self.nb.nbody):
# glVertex3f(self.nb.pos[i,0],self.nb.pos[i,1],self.nb.pos[i,2])
#
#glEnd()
# here, we do the same in C
#libgl.MakePointList(self.nb.pos)
#libgl.MakeArrowList(self.nb.pos,self.nb.vel,0.3)
if
self
.
var
!=
None
:
libgl
.
MakeColorPointList
(
self
.
nb
.
pos
,
self
.
var
,
float
(
self
.
mn
),
float
(
self
.
mx
),
self
.
pal
)
else
:
libgl
.
MakePointList
(
self
.
nb
.
pos
)
glEndList
()
def
Display
(
self
,
color
=
None
):
'''
display the object
'''
if
(
self
.
param
[
'show'
]):
if
color
==
None
:
glColor4d
(
self
.
param
[
"Color_r"
],
self
.
param
[
"Color_g"
],
self
.
param
[
"Color_b"
],
self
.
param
[
"Color_a"
])
else
:
glColor4d
(
color
[
0
],
color
[
1
],
color
[
2
],
self
.
param
[
"Color_a"
])
glCallList
(
self
.
ListID
)
def
MulAlpha
(
self
,
f
):
self
.
param
[
"Color_a"
]
=
self
.
param
[
"Color_a"
]
*
f
self
.
param
[
"Color_a"
]
=
max
(
0
,
self
.
param
[
"Color_a"
])
self
.
param
[
"Color_a"
]
=
min
(
1
,
self
.
param
[
"Color_a"
])
def
DivAlpha
(
self
,
f
):
self
.
param
[
"Color_a"
]
=
self
.
param
[
"Color_a"
]
/
f
self
.
param
[
"Color_a"
]
=
max
(
0
,
self
.
param
[
"Color_a"
])
self
.
param
[
"Color_a"
]
=
min
(
1
,
self
.
param
[
"Color_a"
])
def
SetAlpha
(
self
,
a
):
self
.
param
[
"Color_a"
]
=
a
self
.
param
[
"Color_a"
]
=
max
(
0
,
self
.
param
[
"Color_a"
])
self
.
param
[
"Color_a"
]
=
min
(
1
,
self
.
param
[
"Color_a"
])
def
GetAlpha
(
self
):
return
self
.
param
[
"Color_a"
]
def
SetColor4d
(
self
,
r
,
g
,
b
,
a
):
self
.
param
[
"Color_r"
]
=
r
self
.
param
[
"Color_g"
]
=
g
self
.
param
[
"Color_b"
]
=
b
self
.
param
[
"Color_a"
]
=
a
def
SetColor3d
(
self
,
r
,
g
,
b
):
self
.
param
[
"Color_r"
]
=
r
self
.
param
[
"Color_g"
]
=
g
self
.
param
[
"Color_b"
]
=
b
def
SetColor
(
self
,
c
):
self
.
param
[
"Color_r"
]
=
c
[
0
]
self
.
param
[
"Color_g"
]
=
c
[
1
]
self
.
param
[
"Color_b"
]
=
c
[
2
]
self
.
param
[
"Color_a"
]
=
c
[
3
]
Event Timeline
Log In to Comment