Geant4:调整可视化界⾯的视⾓
刚开始赶⼯G4的作业,好不容易建好⼀个⼩⼈,塞到B1⾥⾯去发现怎么也不到⼀个合适的视⾓,⼩⼈以各种崎岖的姿势站在坐标系⾥。很头疼,后来终于到⼏条有⽤的命令。随便记⼀下。
tldr版本
⼏个指令:
这些命令可以写在vis.mac脚本⾥,也可以编译之后通过Idle输⼊
/vis/viewer/set/upVector [x] [y] [z]:
在坐标系中,设置⼀个up-vector,调整viewer使得该vector总是朝上。
三个参数分别是up-vector的三个分量,数据类型是double(我猜)
/vis/viewer/centreOn [name]:
选中⼀个volume作为target,就是让相机对准⼀个volume
这个name就是在放置logicalVolume为⼀个physicalVolume的时候写⼊的那个字符串
例如:
new G4PVPlacement(0,
G4ThreeVector(-leg_delta_x,0,leg_delta_z),
logicLeg,
"HumanLeg", // <----------------这个
logicWorld,
false,
0,
checkOverlaps);
/vis/viewer/zoomTo [n]:
就好像把镜头拉近拉远⼀样,将视野放⼤和缩⼩
参数n越⼤,视野中的像越⼤
还有⼀个相对性的缩放指令:
/vis/viewer/zoom [n],如果多次使⽤/vis/viewer/zoom 2那么视野中的像就会⼀直两倍两倍的放⼤。
/vis/viewer/set/viewpointVector [x] [y] [z]:
这是设置从target位置到镜头位置到⽅向⽮量
/vis/viewer/set/lightsVector [x] [y] [z]:
顾名思义,就是调光照⽅向
唠叨版本
怎么蒙到的?
先去翻看了B1到vis.mac,因为事先⼤概知道这个是管可视化的,然后在最后⼏⾏中发现(⼤约是102⾏开始):
# To get nice view
# Make the "World" box invisible
/vis/geometry/set/visibility World 0 false
# "Envelope" is transparent blue to represent water
/vis/geometry/set/colour Envelope 0 0 0 1 .3
/vis/viewer/set/style surface
/vis/viewer/set/hiddenMarker truerepresent的用法
/vis/viewer/set/viewpointThetaPhi 45 180 # <<------这⾥看着就很像视⾓
发现⼤约可以从/vis/viewer/set/viewpoint⼊⼿
但怎么想这个视⾓应该有三个参数才对,但上⾯那个只给出两个。
在官⽹给出的《BookForApplicationDevelopers》中查viewpoint,发现在P310: 8.4.11 Basic camera workings: /vis/viewer/ commands中有如下内容:
The target point can be changed with a /vis/viewer/set command or with the /vis/viewer/pan command
s. The up-vector and the viewpoint direction can also be changed with /vis/viewer/set commands. Care must be taken to avoid having the two vectors parallel, for in that case the view is undefined.
于是就知道了G4调整视⾓的逻辑中包含target和camera两个概念。
后来翻看UIterminal的讲解内容发现:(P42,2.9.2 A Short Description of Available Interfaces)
顺⼿在运⾏的魔改版B1⾥试⼀下:
Idle>ls /vis/viewer/set/
Command directory path : /vis/viewer/set/
Guidance :
Set view parameters of current viewer.
Sub-directories :
/vis/viewer/set/timeWindow/ Set time window parameters of current viewer.
Commands :
all * Copies view parameters.
autoRefresh * Sets auto-refresh.
auxiliaryEdge * Sets visibility of auxiliary edges
background * Set background colour and transparency (default black and opaque).
culling * Set culling options.
cutawayMode * Sets cutaway mode - add (union) or multiply (intersection).
defaultColour * Set defaultColour colour and transparency (default white and opaque).
defaultTextColour * Set defaultTextColour colour and transparency (default blue and opaque).
edge * Edges become visible/invisible in surface mode.
explodeFactor * Moves top-level drawn volumes by this factor from this centre.
globalLineWidthScale * Multiplies line widths by this factor.
globalMarkerScale * Multiplies marker sizes by this factor.
hiddenEdge * Edges become hidden/seen in wireframe or surface mode.
hiddenMarker * If true, closer objects hide markers. Otherwise, markers always show.
lightsMove * Lights move with camera or with object
lightsThetaPhi * Set direction from target to lights.
lightsVector * Set direction from target to lights.
lineSegmentsPerCircle * Set number of sides per circle for polygon/polyhedron drawing.
numberOfCloudPoints * Set number of points to be used for cloud representation of volumes.
picking * Sets picking, if available.
projection * Set projection style - o[rthogonal] or p[erspective].
If p[erspective], also set field half angle.
rotationStyle * Set style of rotation - constrainUpDirection or freeRotation.
sectionPlane * Set plane for drawing section (DCUT).
style * Set style of drawing - w[ireframe] or s[urface] or c[loud].
targetPoint * Set target point.
upThetaPhi * Set up vector.
upVector * Set up vector.
viewpointThetaPhi * Set direction from target to camera.
viewpointVector * Set direction from target to camera.
Idle>
这样可以浏览所有的commads。
Idle>help /vis/viewer/set/upVector
Command /vis/viewer/set/upVector
Guidance :
Set up vector.
Viewer will attempt always to show this direction upwards.
Parameter : x
Parameter type: d
Omittable : True
Default value : 0
Parameter : y
Parameter type: d
Omittable : True
Default value : 1
Parameter : z
Parameter type: d
Omittable : True
Default value : 0
Idle>
这样可以查看commands的⽤法!
顺⼿发现了不⽤ThetaPhi⽽⽤笛卡尔坐标系参数的命令。
美滋滋
放⼀个⼩录屏⽪⼀下
主要就是这些指令:
/vis/viewer/zoom 0.5
/vis/viewer/zoom 1
/vis/viewer/set/viewpointVector 1 0 0
/vis/viewer/set/viewpointVector 1 1 1
/vis/viewer/set/upVector 1 0 0
/
vis/viewer/set/upVector 0 0 1
/vis/viewer/set/upVector 0 1 0
/vis/viewer/zoom 4
/vis/viewer/centreOn HumanHeadNeck
/vis/viewer/centreOn Body
/vis/viewer/centreOn Leg
没法⽪了,CSDN不⽀持放视频,我也懒得做Gif……哈哈哈哈哈哈哈哈要不就放张图意思⼀下吧:
/vis/viewer/zoom 4:
/vis/viewer/set/viewpointVector 1 1 1
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论