# pymol opengl cgo盒子的画法

http://blog.csdn.net/xiajun07061225/article/details/7455283

http://game.ceeger.com/Script/GL/GL.TRIANGLE_STRIP.html

4个点的顺序是BACD,这样就能定义出上面的3角型条带。

###################################################

##################################################

gridbox.py

#######################################################

# Copyright (c) 2014 Chen Zhaoqiang DDDC SIMM
#qq 744891290 qqgroup 144539789
# A PyMOL script for drawing a CGO box by the coordinate of the center,and the size of box
#center_x,center_y,center_z,size_x,size_y,size_z,

import pymol
from pymol import cmd
from pymol.wizard import Wizard
from chempy import cpv
from pymol.cgo import *

def gridbox(center_x,center_y,center_z,size_x,size_y,size_z,name="gridbox",r1=0,g1=0,b1=1,trasp=0.2):
"""
DESCRIPTION
Create a box from the center coordinate of the box and the size of box

USAGE
run gridbox.py
1the simplest
gridbox center_x,center_y,center_z,size_x,size_y,size_z
2rename the box object
gridbox center_x,center_y,center_z,size_x,size_y,size_z,name,
3set the color of the box object
gridbox center_x,center_y,center_z,size_x,size_y,size_z,name,r1,g1,b1
4set the trasp of the box
gridbox center_x,center_y,center_z,size_x,size_y,size_z,name,r1,g1,b1,trasp

ps:the value of r1,g1,b1 trasp   range  is 0-1
trasp=1,no trasprent

"""
center_x=float(center_x)
center_y=float(center_y)
center_z=float(center_z)
size_x=float(size_x)
size_y=float(size_y)
size_z=float(size_z)
r1=float(r1)
g1=float(g1)
b1=float(b1)
trasp=float(trasp)

p1=[center_x-size_x/2,center_y-size_y/2,center_z+size_z/2]
p2=[center_x-size_x/2,center_y+size_y/2,center_z+size_z/2]
p3=[center_x+size_x/2,center_y+size_y/2,center_z+size_z/2]
p4=[center_x+size_x/2,center_y-size_y/2,center_z+size_z/2]
p5=[center_x-size_x/2,center_y-size_y/2,center_z-size_z/2]
p6=[center_x-size_x/2,center_y+size_y/2,center_z-size_z/2]
p7=[center_x+size_x/2,center_y+size_y/2,center_z-size_z/2]
p8=[center_x+size_x/2,center_y-size_y/2,center_z-size_z/2]
obj=[
ALPHA,trasp,
COLOR,r1,g1,b1,
BEGIN, TRIANGLE_STRIP,
VERTEX,p1[0],p1[1],p1[2],
VERTEX,p2[0],p2[1],p2[2],
VERTEX,p4[0],p4[1],p4[2],
VERTEX,p3[0],p3[1],p3[2],
END,

BEGIN, TRIANGLE_STRIP,
#             COLOR,1,0,0,
VERTEX,p1[0], p1[1], p1[2],
VERTEX,p5[0], p5[1], p5[2],
VERTEX,p4[0], p4[1], p4[2],
VERTEX,p8[0], p8[1], p8[2],
END,

BEGIN, TRIANGLE_STRIP,
VERTEX,p4[0],p4[1],p4[2],
VERTEX,p8[0],p8[1],p8[2],
VERTEX,p3[0],p3[1],p3[2],
VERTEX,p7[0],p7[1],p7[2],
END,

BEGIN, TRIANGLE_STRIP,
VERTEX,p7[0],p7[1],p7[2],
VERTEX,p3[0],p3[1],p3[2],
VERTEX,p6[0],p6[1],p6[2],
VERTEX,p2[0],p2[1],p2[2],
END,

BEGIN, TRIANGLE_STRIP,
#             COLOR,0,1,0,
VERTEX,p2[0],p2[1],p2[2],
VERTEX,p6[0],p6[1],p6[2],
VERTEX,p1[0],p1[1],p1[2],
VERTEX,p5[0],p5[1],p5[2],
END,

BEGIN, TRIANGLE_STRIP,
VERTEX,p1[0],p1[1],p1[2],
VERTEX,p5[0],p5[1],p5[2],
VERTEX,p4[0],p4[1],p4[2],
VERTEX,p8[0],p8[1],p8[2],
END,

BEGIN, TRIANGLE_STRIP,
VERTEX,p5[0],p5[1],p5[2],
VERTEX,p8[0],p8[1],p8[2],
VERTEX,p6[0],p6[1],p6[2],
VERTEX,p7[0],p7[1],p7[2],
END,
]

cmd.extend('gridbox', gridbox)

##################################################################################

###################口袋1###################

receptor = NLxxx.pdbqt

center_x = 8.6
center_y = -5.025
center_z = -12.576

size_x = 28.5
size_y = 24
size_z = 24

exhaustiveness = 16

###############################################

gridbox 8.6,-5.025,-12.576,28.5,24,24,"17nl",1,0,0.3,0.8

###########################口袋2#####################################

receptor = L.pdbqt

center_x = 8.6
center_y = -11.978
center_z = -12.576

size_x = 28.5
size_y = 44.25
size_z = 24

exhaustiveness = 16

###############################################################
gridbox 8.6,-11.978,-12.576,28.5,44.25,24,"17l",0,0,1.3,0.4

http://blog.sciencenet.cn/blog-950202-842412.html

## 全部精选博文导读

GMT+8, 2020-4-10 15:38