本文整理汇总了Golang中github.com/gazed/vu.Pov类的典型用法代码示例。如果您正苦于以下问题:Golang Pov类的具体用法?Golang Pov怎么用?Golang Pov使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Pov类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: move
// Handle movement assuming there is a physics body associated with the camera.
// This attempts to smooth out movement by adding a higher initial velocity push
// and then capping movement once max accelleration is reached.
func (c *cam) move(bod vu.Pov, x, y, z float64, dir *lin.Q) {
if body := bod.Body(); body != nil {
boost := 40.0 // kick into high gear from stop.
maxAccel := 10.0 // limit accelleration.
sx, _, sz := body.Speed()
if x != 0 {
switch {
case sx == 0.0:
// apply push in the current direction.
dx, dy, dz := lin.MultSQ(x*boost, 0, 0, dir)
body.Push(dx, dy, dz)
case math.Abs(sx) < maxAccel && math.Abs(sz) < maxAccel:
dx, dy, dz := lin.MultSQ(x, 0, 0, dir)
body.Push(dx, dy, dz)
}
}
if z != 0 {
switch {
case sz == 0.0:
dx, dy, dz := lin.MultSQ(0, 0, z*boost, dir)
body.Push(dx, dy, dz)
case math.Abs(sx) < maxAccel && math.Abs(sz) < maxAccel:
dx, dy, dz := lin.MultSQ(0, 0, z, dir)
body.Push(dx, dy, dz)
}
}
} else {
bod.Move(x, y, z, dir)
}
}
示例2: newPlayer
// newPlayer sets the player hud location and creates the white background.
func newPlayer(root vu.Pov, screenWidth, screenHeight int) *player {
pl := &player{}
pl.cx, pl.cy = 100, 100
pl.bg = root.NewPov().SetScale(110, 110, 1).SetLocation(pl.cx, pl.cy, 0)
pl.bg.NewModel("uv").LoadMesh("icon").AddTex("hudbg")
return pl
}
示例3: newCube
// newCube's are often started with 1 corner, 2 edges, or 4 bottom side pieces.
func newCube(tr vu.Pov, x, y, z, cubeSize float64) *cube {
c := &cube{}
c.part = tr.NewPov()
c.cells = []vu.Pov{}
c.cx, c.cy, c.cz, c.csize = x, y, z, cubeSize
c.ccnt, c.cmax = 0, 8
c.mergec = func() { c.merge() }
c.trashc = func() { c.trash() }
c.addc = func() { c.addCell() }
c.remc = func() { c.removeCell() }
// calculate the cell center locations (unsorted)
qs := c.csize * 0.25
c.centers = csort{
&lin.V3{X: x - qs, Y: y - qs, Z: z - qs},
&lin.V3{X: x - qs, Y: y - qs, Z: z + qs},
&lin.V3{X: x - qs, Y: y + qs, Z: z - qs},
&lin.V3{X: x - qs, Y: y + qs, Z: z + qs},
&lin.V3{X: x + qs, Y: y - qs, Z: z - qs},
&lin.V3{X: x + qs, Y: y - qs, Z: z + qs},
&lin.V3{X: x + qs, Y: y + qs, Z: z - qs},
&lin.V3{X: x + qs, Y: y + qs, Z: z + qs},
}
return c
}
示例4: newMinimap
// newMinimap initializes the minimap. It still needs to be populated.
func newMinimap(root vu.Pov, numTroops int) *minimap {
mm := &minimap{}
mm.radius = 120
mm.scale = 5.0
mm.cores = []vu.Pov{}
mm.view = root.NewView()
mm.view.SetUI()
mm.view.SetCull(vu.NewRadiusCull(float64(mm.radius)))
mm.cam = mm.view.Cam()
mm.cam.SetTransform(vu.XZ_XY)
// create the parent for all the visible minimap pieces.
mm.part = root.NewPov().SetLocation(float64(mm.x), 0, float64(-mm.y))
// add the white background.
mm.bg = mm.part.NewPov().SetScale(110, 1, 110)
mm.bg.NewModel("uv").LoadMesh("icon_xz").AddTex("hudbg")
// create the sentinel position markers
mm.spms = []vu.Pov{}
for cnt := 0; cnt < numTroops; cnt++ {
tpm := mm.part.NewPov().SetScale(mm.scale, mm.scale, mm.scale)
tpm.NewModel("alpha").LoadMesh("square_xz").LoadMat("tred")
mm.spms = append(mm.spms, tpm)
}
// create the player marker and center map marker.
mm.cpm = mm.part.NewPov().SetScale(mm.scale, mm.scale, mm.scale)
mm.cpm.NewModel("alpha").LoadMesh("square_xz").LoadMat("blue")
mm.ppm = mm.part.NewPov().SetScale(mm.scale, mm.scale, mm.scale)
mm.ppm.NewModel("alpha").LoadMesh("tri_xz").LoadMat("tblack")
return mm
}
示例5: newText
func (rl *rltag) newText(parent vu.Pov, gap int) vu.Model {
text := parent.NewPov().SetLocation(10, 0, float64(-rl.wh+40+gap*24))
text.Spin(-90, 0, 0) // orient to the X-Z plane.
m := text.NewModel("uv").AddTex("lucidiaSu16White").LoadFont("lucidiaSu16")
m.SetPhrase(" ")
return m
}
示例6: makePlayer
// makePlayer: the player is the camera... the player-trooper is used by the hud
// to show player status and as such this trooper is part of the hud scene.
func (lvl *level) makePlayer(root vu.Pov, levelNum int) *trooper {
player := newTrooper(root.NewPov(), levelNum)
player.part.Spin(15, 0, 0)
player.part.Spin(0, 15, 0)
player.setScale(100)
player.part.SetListener()
return player
}
示例7: createCore
// createCore makes the new core model.
// Create a core image using a single multi-texture shader.
func (cc *coreControl) createCore(root vu.Pov, fade float64) vu.Pov {
core := root.NewPov().SetScale(0.25, 0.25, 0.25)
model := core.NewModel("spinball").LoadMesh("billboard")
model.AddTex("ele").AddTex("ele").AddTex("halo").AddTex("halo")
model.SetAlpha(0.6)
model.SetUniform("fd", fade)
return core
}
示例8: energyLossEffect
// energyLossEffect creates the model shown when the player gets hit
// by a sentinel.
func (hd *hud) energyLossEffect(root vu.Pov) vu.Pov {
ee := root.NewPov()
ee.SetVisible(false)
m := ee.NewModel("uvra").LoadMesh("icon").AddTex("loss")
m.SetAlpha(0.5)
m.SetUniform("fd", 1000)
m.SetUniform("spin", 2.0)
return ee
}
示例9: teleportEffect
// teleportEffect creates the model shown when the user teleports.
func (hd *hud) teleportEffect(root vu.Pov) vu.Pov {
te := root.NewPov()
te.SetVisible(false)
m := te.NewModel("uvra").LoadMesh("icon").AddTex("smoke")
m.SetAlpha(0.5)
m.SetUniform("spin", 10.0)
m.SetUniform("fd", 1000)
return te
}
示例10: makeSphere
// makeSphere creates a sphere at the given x, y, z location and with
// the given r, g, b colour.
func (rc *rctag) makeSphere(parent vu.Pov, x, y, z float64, r, g, b float32) vu.Pov {
sz := 0.5
sp := parent.NewPov()
sp.NewBody(vu.NewSphere(sz))
sp.SetLocation(x, y, z)
sp.SetScale(sz, sz, sz)
model := sp.NewModel("solid").LoadMesh("sphere")
model.SetUniform("kd", r, g, b)
return sp
}
示例11: makeSentries
// makeSentries creates some AI sentinels.
func (lvl *level) makeSentries(root vu.Pov, levelNum int) {
sentinels := []*sentinel{}
numSentinels := gameMuster[levelNum]
for cnt := 0; cnt < numSentinels; cnt++ {
sentry := newSentinel(root.NewPov(), levelNum, lvl.units, lvl.fade)
sentry.setScale(0.25)
sentinels = append(sentinels, sentry)
}
lvl.sentries = sentinels
}
示例12: newStartAnimation
// newStartAnimation creates the start screen animation.
func newStartAnimation(mp *bampf, parent vu.Pov, screenWidth, screenHeight int) *startAnimation {
sa := &startAnimation{}
sa.parent = parent
sa.scale = 200
sa.hilite = parent.NewPov()
sa.hilite.NewModel("alpha").LoadMesh("square").LoadMat("white")
sa.hilite.SetVisible(false)
sa.resize(screenWidth, screenHeight)
sa.showLevel(0)
return sa
}
示例13: newPanel
// newPanel creates a panel with no cubes. The cubes are added later using
// panel.addCube().
func newPanel(part vu.Pov, x, y, z float64, level int) *panel {
p := &panel{}
p.part = part.NewPov()
p.lvl = level
p.cubes = []*cube{}
p.cx, p.cy, p.cz = x, y, z
p.ccnt, p.cmax = 0, (level-1)*(level-1)*8
p.mergec = func() { p.merge() }
p.trashc = func() { p.trash() }
p.addc = func() { p.addCell() }
p.remc = func() { p.removeCell() }
return p
}
示例14: newElectron
// newElectron creates a new electron model.
func newElectron(root vu.Pov, band int, angle float64) *electron {
ele := &electron{}
ele.band = band
x, y := ele.initialLocation(angle)
ele.core = root.NewPov().SetLocation(x, y, 0)
// rotating image.
cimg := ele.core.NewPov().SetScale(0.25, 0.25, 0.25)
model := cimg.NewModel("spinball").LoadMesh("billboard")
model.AddTex("ele").AddTex("ele").AddTex("halo").AddTex("halo")
model.SetAlpha(0.6)
return ele
}
示例15: label
// label adds a banner to a button or updates the banner if there is
// an existing banner.
func (b *button) label(part vu.Pov, keyCode int) {
if keysym := vu.Keysym(keyCode); keysym > 0 {
texture := "lucidiaSu22Black"
if b.banner == nil {
b.banner = part.NewPov().SetLocation(float64(b.x), float64(b.y), 0)
b.banner.NewModel("uv").AddTex(texture).LoadFont("lucidiaSu22")
}
if keyCode == 0 {
keyCode = vu.K_Space
}
b.banner.Model().SetPhrase(string(keysym))
}
}