• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang gl.Translated函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/banthar/gl.Translated函数的典型用法代码示例。如果您正苦于以下问题:Golang Translated函数的具体用法?Golang Translated怎么用?Golang Translated使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Translated函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: DrawItem

func (self *Inventory) DrawItem(t int64, quantity uint16, itemid ItemId, x float64, y float64) {
	gl.PushMatrix()
	gl.LoadIdentity()

	// angle := -90.0
	const blocksize = float32(0.3)

	gl.Translated(x, y, 0)

	//gl.Rotated(angle, 1.0, 0.0, 0.0)
	gl.Rotated(90, 1.0, 0.0, 0.0)
	gl.Rotated(30*math.Sin(float64(t)/1e9+float64(itemid)/2), 0.0, 1.0, 0.0)
	gl.Scalef(blocksize, blocksize, blocksize)
	self.drawBuffer.Reset()

	if itemid < 256 {
		TerrainCube(self.drawBuffer, Vectori{}, [18]BlockId{BLOCK_DIRT, BLOCK_DIRT, BLOCK_DIRT, BLOCK_DIRT, BLOCK_AIR, BLOCK_DIRT, BLOCK_AIR, BLOCK_AIR, BLOCK_AIR, BLOCK_AIR, BLOCK_AIR, BLOCK_AIR, BLOCK_AIR, BLOCK_AIR, BLOCK_AIR, BLOCK_AIR, BLOCK_AIR}, NewBlockDefault(BlockId(itemid)), FACE_NONE)
	} else {
		RenderItemFlat(self.drawBuffer, Vectori{}, BlockId(itemid))
	}
	self.drawBuffer.RenderDirect(false)

	gl.LoadIdentity()
	gl.Translated(x+2*PIXEL_SCALE-48*PIXEL_SCALE*float64(blocksize), y-7*PIXEL_SCALE-48*PIXEL_SCALE*float64(blocksize), 0)
	inventoryItemFont.Print(fmt.Sprintf("%d", quantity))

	gl.PopMatrix()

}
开发者ID:codygman,项目名称:amberfell,代码行数:29,代码来源:inventory.go


示例2: Render

func (vbox vbox) Render(w, h, d float64) {
	l := len(vbox.renderers)
	dh := h / float64(l)
	gl.Translated(0, h, 0)
	for _, a := range vbox.renderers {
		gl.Translated(0, -dh, 0)
		a.Render(w, dh, d)
	}
}
开发者ID:glenn-brown,项目名称:vu,代码行数:9,代码来源:layout.go


示例3: renderPortrait

func renderPortrait(r Renderer, w, h, d float64) {
	gl.PushMatrix()
	ww := h / math.Phi
	if ww <= w {
		gl.Translated((w-ww)/2.0, 0, 0)
		r.Render(ww, h, d)
	} else {
		hh := w * math.Phi
		gl.Translated(0, (h-hh)/2.0, 0)
		r.Render(w, hh, d)
	}
	gl.PopMatrix()
}
开发者ID:glenn-brown,项目名称:vu,代码行数:13,代码来源:layout.go


示例4: renderLandscape

func renderLandscape(r Renderer, w, h, d float64) {
	gl.PushMatrix()
	hh := w / math.Phi
	if hh <= h {
		gl.Translated(0, (h-hh)/2.0, 0)
		r.Render(w, hh, d)
	} else {
		ww := h * math.Phi
		gl.Translated((w-ww)/2.0, 0, 0)
		r.Render(ww, h, d)
	}
	gl.PopMatrix()
}
开发者ID:glenn-brown,项目名称:vu,代码行数:13,代码来源:layout.go


示例5: Draw

func (self *Pause) Draw(t int64) {
	gl.MatrixMode(gl.MODELVIEW)
	gl.PushMatrix()
	gl.LoadIdentity()

	gl.Disable(gl.DEPTH_TEST)
	gl.Disable(gl.LIGHTING)
	gl.Disable(gl.LIGHT0)
	gl.Disable(gl.LIGHT1)

	gl.Color4ub(0, 0, 0, 240)

	gl.Begin(gl.QUADS)
	gl.Vertex2f(float32(viewport.lplane), float32(viewport.bplane))
	gl.Vertex2f(float32(viewport.rplane), float32(viewport.bplane))
	gl.Vertex2f(float32(viewport.rplane), float32(viewport.tplane))
	gl.Vertex2f(float32(viewport.lplane), float32(viewport.tplane))
	gl.End()

	str := "paused"
	h, w := pauseFont.Measure(str)

	// x := (viewport.rplane - viewport.lplane - w) / 2
	// y := (viewport.tplane - viewport.bplane - h) / 2
	gl.Translated(-w/2, -h/2, 0)
	pauseFont.Print(str)

	gl.PopMatrix()

}
开发者ID:codygman,项目名称:amberfell,代码行数:30,代码来源:pause.go


示例6: Draw

func Draw() {
	gl.Clear(gl.COLOR_BUFFER_BIT)

	gl.PushMatrix()
	defer gl.PopMatrix()

	gl.Color4f(0, 1, 0, .5)
	DrawCircle(vect.Vect{ScreenSize.X / 2, ScreenSize.Y / 2}, ScreenSize.Y/2.0-5.0, false)

	if Settings.Paused {
		gl.Color3f(1, 1, 1)
		RenderFontAt("Paused", 20, 30)
	}

	//draw collision objects

	gl.PushMatrix()

	gl.Translated(ScreenSize.X/2, ScreenSize.Y/2, 0)
	gl.Scaled(Settings.Scale, Settings.Scale, 1)

	DrawDebugData(space)

	gl.PopMatrix()
}
开发者ID:githubnemo,项目名称:mater,代码行数:25,代码来源:render.go


示例7: positionCamera

func positionCamera() {
	gl.LoadIdentity()
	x, y, z := player.Position()
	gl.Translated(-x, -y+4, -z)

	gl.Lightfv(gl.LIGHT1, gl.POSITION, []float32{float32(x), float32(y), float32(z) + 0.5, 1})
}
开发者ID:Nightgunner5,项目名称:mmgo,代码行数:7,代码来源:camera.go


示例8: OpenWindow

// OpenWindow opens a new window with the given size.
func OpenWindow(w, h int) error {
	glfw.OpenWindowHint(glfw.WindowNoResize, 1)

	r, g, b := 0, 0, 0 // defaults
	a := 8             // 8-bit alpha channel
	d, s := 0, 0       // no depth or stencil buffers
	m := glfw.Windowed
	if err := glfw.OpenWindow(w, h, r, g, b, a, d, s, m); err != nil {
		return err
	}

	if gl.Init() != 0 {
		return errors.New("Failed to initialize OpenGL")
	}

	gl.Enable(gl.TEXTURE_2D)
	gl.Enable(gl.BLEND)
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
	gl.ClearColor(0.0, 0.0, 0.0, 0.0)
	gl.MatrixMode(gl.PROJECTION)
	gl.LoadIdentity()
	gl.Ortho(0, float64(w), 0, float64(-h), -1, 1)
	gl.MatrixMode(gl.MODELVIEW)
	gl.LoadIdentity()
	gl.Translated(0, float64(-h), 0)
	return nil
}
开发者ID:vivounicorn,项目名称:eaburns,代码行数:28,代码来源:ui.go


示例9: reshape

// Handle the window being resized.
func reshape(width int, height int) {
	// Render into the entire window.
	gl.Viewport(0, 0, width, height)
	gl.MatrixMode(gl.PROJECTION)
	gl.LoadIdentity()

	// Configure the Frustrum so the front face of the rendering
	// volume fills the screen.

	w := float64(width)
	h := float64(height)
	depth := (w + h) / 2
	near := depth / 2.0
	right := w / 4.0
	top := h / 4.0
	far := 4 * depth
	gl.Frustum(-right, right, -top, top, near, far)

	gl.MatrixMode(gl.MODELVIEW)
	gl.LoadIdentity()

	// Center the rendering volume in the viewport.  Its origin
	// is at the far lower left corner.

	gl.Translated(-w/2, -h/2, -2*depth)
}
开发者ID:glenn-brown,项目名称:vu,代码行数:27,代码来源:window.go


示例10: draw

func draw() {

	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

	gl.PushMatrix()
	gl.Rotated(view_rotx, 1.0, 0.0, 0.0)
	gl.Rotated(view_roty, 0.0, 1.0, 0.0)
	gl.Rotated(view_rotz, 0.0, 0.0, 1.0)

	gl.PushMatrix()
	gl.Translated(-3.0, -2.0, 0.0)
	gl.Rotated(angle, 0.0, 0.0, 1.0)
	gl.CallList(gear1)
	gl.PopMatrix()

	gl.PushMatrix()
	gl.Translated(3.1, -2.0, 0.0)
	gl.Rotated(-2.0*angle-9.0, 0.0, 0.0, 1.0)
	gl.CallList(gear2)
	gl.PopMatrix()

	gl.PushMatrix()
	gl.Translated(-3.1, 4.2, 0.0)
	gl.Rotated(-2.0*angle-25.0, 0.0, 0.0, 1.0)
	gl.CallList(gear3)
	gl.PopMatrix()

	gl.PopMatrix()

	sdl.GL_SwapBuffers()

	Frames++
	{
		t := sdl.GetTicks()
		if t-T0 >= 5000 {
			seconds := (t - T0) / 1000.0
			fps := Frames / seconds
			print(Frames, " frames in ", seconds, " seconds = ", fps, " FPS\n")
			T0 = t
			Frames = 0
		}
	}
}
开发者ID:nkostelnik,项目名称:gl,代码行数:43,代码来源:sdlgears.go


示例11: draw

func draw() {

	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

	gl.PushMatrix()
	gl.Rotated(view_rotx, 1.0, 0.0, 0.0)
	gl.Rotated(view_roty, 0.0, 1.0, 0.0)
	gl.Rotated(view_rotz, 0.0, 0.0, 1.0)

	gl.PushMatrix()
	gl.Translated(-3.0, -2.0, 0.0)
	gl.Rotated(angle, 0.0, 0.0, 1.0)
	gl.CallList(gear1)
	gl.PopMatrix()

	gl.PushMatrix()
	gl.Translated(3.1, -2.0, 0.0)
	gl.Rotated(-2.0*angle-9.0, 0.0, 0.0, 1.0)
	gl.CallList(gear2)
	gl.PopMatrix()

	gl.PushMatrix()
	gl.Translated(-3.1, 4.2, 0.0)
	gl.Rotated(-2.0*angle-25.0, 0.0, 0.0, 1.0)
	gl.CallList(gear3)
	gl.PopMatrix()

	gl.PopMatrix()

	glfw.SwapBuffers()

	Frames++
	{
		t := glfw.Time()
		if t-T0 >= 5 {
			seconds := (t - T0)
			fps := float64(Frames) / seconds
			print(Frames, " frames in ", int(seconds), " seconds = ", int(fps), " FPS\n")
			T0 = t
			Frames = 0
		}
	}
}
开发者ID:nkostelnik,项目名称:gl,代码行数:43,代码来源:glfwgears.go


示例12: drawCircle

func drawCircle(s CircleShape) {
	center := s.Center()
	radius := s.Radius()
	angle := s.Body().Angle()

	gl.VertexPointer(2, 0, circleVerts)
	gl.PushMatrix()
	gl.Translated(center.X, center.Y, 0.0)
	gl.Rotated(angle*180.0/math.Pi, 0.0, 0.0, 1.0)
	gl.Scaled(radius, radius, 1.0)
	gl.DrawArrays(gl.LINE_STRIP, 0, len(circleVerts)/2)
	gl.PopMatrix()
}
开发者ID:ftrvxmtrx,项目名称:gochipmunk,代码行数:13,代码来源:main.go


示例13: DrawItem

func (self *Inventory) DrawItem(t int64, quantity uint16, blockid uint16, r Rect) {
	gl.PushMatrix()
	gl.LoadIdentity()

	const blocksize = float32(0.3)

	i := 1
	gl.Translated(r.x+r.sizex/2, r.y+r.sizey/2+4*PIXEL_SCALE, 0)

	gl.Rotatef(360*float32(math.Sin(float64(t)/1e10+float64(i))), 1.0, 0.0, 0.0)
	gl.Rotatef(360*float32(math.Cos(float64(t)/1e10+float64(i))), 0.0, 1.0, 0.0)
	gl.Rotatef(360*float32(math.Sin(float64(t)/1e10+float64(i))), 0.0, 0.0, 1.0)
	gl.Scalef(blocksize, blocksize, blocksize)
	gVertexBuffer.Reset()
	TerrainCube(gVertexBuffer, Vectori{}, [18]uint16{}, blockid, FACE_NONE)
	gVertexBuffer.RenderDirect(false)

	gl.LoadIdentity()
	gl.Translated(r.x+5*PIXEL_SCALE, r.y+2*PIXEL_SCALE, 0)
	inventoryItemFont.Print(fmt.Sprintf("%d", quantity))

	gl.PopMatrix()

}
开发者ID:uriel,项目名称:amberfell,代码行数:24,代码来源:inventory.go


示例14: plot_list

func plot_list(list uint) {
	gl.Enable(gl.BLEND)
	gl.Enable(gl.POINT_SMOOTH)
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)

	gl.PointSize(1.0)
	gl.LoadIdentity()
	gl.Rotated(xrot, 1, 0, 0)
	gl.Rotated(yrot, 0, 1, 0)
	gl.Rotated(zrot, 0, 0, 1)
	gl.Scaled(scale, scale, scale)
	gl.Translated(xoff, yoff, zoff)
	gl.CallList(list)
	gl.Flush()
}
开发者ID:charlieb,项目名称:gostrange,代码行数:15,代码来源:main.go


示例15: onResize

func onResize(w, h int) {
	if h == 0 {
		h = 1
	}

	gl.Viewport(0, 0, w, h)

	scale := math.Min(float64(w)/640.0, float64(h)/480.0)
	hw := float64(w) * (0.5 / scale)
	hh := float64(h) * (0.5 / scale)

	gl.MatrixMode(gl.PROJECTION)
	gl.LoadIdentity()
	gl.Ortho(-hw, hw, -hh, hh, -1.0, 1.0)
	gl.Translated(0.5, 0.5, 0.0)

	Width = w
	Height = h
}
开发者ID:ftrvxmtrx,项目名称:gochipmunk,代码行数:19,代码来源:main.go


示例16: ShowTooltip

func (self *Inventory) ShowTooltip(x, y float64, str string) {
	h, w := inventoryItemFont.Measure(str)

	pad := 4 * PIXEL_SCALE
	gl.PushMatrix()

	gl.LoadIdentity()
	gl.Color4ub(0, 0, 0, 255)
	gl.Begin(gl.QUADS)
	gl.Vertex2d(x, y)
	gl.Vertex2d(x+w+pad, y)
	gl.Vertex2d(x+w+pad, y+h)
	gl.Vertex2d(x, y+h)
	gl.End()

	gl.Translated(x+pad/2, y+pad/2, 0)
	inventoryItemFont.Print(str)

	gl.PopMatrix()
}
开发者ID:uriel,项目名称:amberfell,代码行数:20,代码来源:inventory.go


示例17: Draw

func (player *Player) Draw(center Vectorf, selectedBlockFace *BlockFace) {

	pos := Vectorf{player.position[XAXIS], player.position[YAXIS], player.position[ZAXIS]}
	gl.PushMatrix()

	gl.Translatef(float32(player.position[XAXIS]), float32(player.position[YAXIS]), float32(player.position[ZAXIS]))
	//stepHeight := float32(math.Sin(player.Bounce * piover180)/10.0)
	gl.Rotated(player.Heading(), 0.0, 1.0, 0.0)

	// Translate to top of ground block
	gl.Translatef(0.0, -0.5, 0.0)
	pos[YAXIS] += -0.5

	// From http://www.realcolorwheel.com/human.htm
	headHeight := float64(0.25)
	hatHeight := headHeight
	brimHeight := 0.15 * headHeight
	brimWidth := 1.5 * headHeight
	brimDepth := 1.5 * headHeight
	neckHeight := 0.25 * headHeight
	torsoWidth := 2 * headHeight
	torsoHeight := 3.25 * headHeight
	torsoDepth := 1 * headHeight
	legHeight := 8*headHeight - torsoHeight - neckHeight - headHeight
	legWidth := (torsoWidth - 0.25*headHeight) / 2
	legDepth := legWidth
	armHeight := 2.75 * headHeight
	armWidth := 0.75 * torsoDepth
	armDepth := 0.75 * torsoDepth
	// lowerArmHeight := 1.25 * headHeight
	// handHeight := 0.75 * headHeight

	var legAngle, torsoAngle, leftArmAngle, rightArmAngle, step float64

	// if player.velocity[YAXIS] != 0 {
	// 	legAngle = 20
	// 	leftArmAngle = 120
	// 	rightArmAngle = 120
	// } else {
	legAngle = 40 * (math.Abs(player.velocity[XAXIS]) + math.Abs(player.velocity[ZAXIS])) / player.walkingSpeed * math.Sin(player.walkSequence)
	torsoAngle = -math.Abs(legAngle / 6)
	leftArmAngle = -legAngle * 1.2
	rightArmAngle = legAngle * 1.2
	step = headHeight * 0.1 * math.Pow(math.Sin(player.walkSequence), 2)
	// }

	gl.Translated(0.0, step, 0)
	pos[YAXIS] += step

	// Translate to top of leg
	gl.Translated(0.0, legHeight, 0)
	pos[YAXIS] += legHeight

	// Translate to centre of leg
	gl.Rotated(legAngle, 0.0, 0.0, 1.0)
	gl.Translated(0.0, -legHeight/2, (legWidth+0.25*headHeight)/2)
	pos[YAXIS] += -legHeight / 2
	pos[ZAXIS] += (legWidth + 0.25*headHeight) / 2
	Cuboid(pos, legWidth, legHeight, legDepth, textures[TEXTURE_LEG], textures[TEXTURE_LEG], textures[TEXTURE_LEG_SIDE], textures[TEXTURE_LEG_SIDE], textures[32], textures[32], FACE_NONE)
	gl.Translated(0.0, legHeight/2, -(legWidth+0.25*headHeight)/2)
	pos[YAXIS] += legHeight / 2
	pos[ZAXIS] += -(legWidth + 0.25*headHeight) / 2
	gl.Rotated(-legAngle, 0.0, 0.0, 1.0)

	gl.Rotated(-legAngle, 0.0, 0.0, 1.0)
	gl.Translated(0.0, -legHeight/2, -(legWidth+0.25*headHeight)/2)
	pos[YAXIS] += -legHeight / 2
	pos[ZAXIS] += -(legWidth + 0.25*headHeight) / 2
	Cuboid(pos, legWidth, legHeight, legDepth, textures[TEXTURE_LEG], textures[TEXTURE_LEG], textures[TEXTURE_LEG_SIDE], textures[TEXTURE_LEG_SIDE], textures[32], textures[32], FACE_NONE)
	gl.Translated(0.0, legHeight/2, (legWidth+0.25*headHeight)/2)
	pos[YAXIS] += legHeight / 2
	pos[ZAXIS] += (legWidth + 0.25*headHeight) / 2
	gl.Rotated(+legAngle, 0.0, 0.0, 1.0)

	gl.Rotated(torsoAngle, 0.0, 0.0, 1.0)
	// Translate to centre of torso
	gl.Translated(0.0, torsoHeight/2, 0.0)
	pos[YAXIS] += torsoHeight / 2
	Cuboid(pos, torsoWidth, torsoHeight, torsoDepth, textures[TEXTURE_TORSO_FRONT], textures[TEXTURE_TORSO_BACK], textures[TEXTURE_TORSO_LEFT], textures[TEXTURE_TORSO_RIGHT], textures[TEXTURE_TORSO_TOP], textures[TEXTURE_TORSO_TOP], FACE_NONE)

	// Translate to shoulders
	gl.Translated(0.0, torsoHeight/2, 0.0)
	pos[YAXIS] += torsoHeight / 2

	gl.Rotated(leftArmAngle, 0.0, 0.0, 1.0)
	gl.Translated(0.0, -armHeight/2, torsoWidth/2+armWidth/2)
	pos[YAXIS] += -armHeight / 2
	pos[ZAXIS] += torsoWidth/2 + armWidth/2
	Cuboid(pos, armWidth, armHeight, armDepth, textures[TEXTURE_ARM], textures[TEXTURE_ARM], textures[TEXTURE_ARM], textures[TEXTURE_ARM], textures[TEXTURE_ARM_TOP], textures[TEXTURE_HAND], FACE_NONE)
	gl.Translated(0.0, armHeight/2, -torsoWidth/2-armWidth/2)
	pos[YAXIS] += armHeight / 2
	pos[ZAXIS] += -torsoWidth/2 + armWidth/2
	gl.Rotated(-leftArmAngle, 0.0, 0.0, 1.0)

	gl.Rotated(rightArmAngle, 0.0, 0.0, 1.0)
	gl.Translated(0.0, -armHeight/2, -torsoWidth/2-armWidth/2)
	pos[YAXIS] += -armHeight / 2
	pos[ZAXIS] += -torsoWidth/2 + armWidth/2
	Cuboid(pos, armWidth, armHeight, armDepth, textures[TEXTURE_ARM], textures[TEXTURE_ARM], textures[TEXTURE_ARM], textures[TEXTURE_ARM], textures[TEXTURE_ARM_TOP], textures[TEXTURE_HAND], FACE_NONE)
	gl.Translated(0.0, armHeight/2, torsoWidth/2+armWidth/2)
//.........这里部分代码省略.........
开发者ID:Cyberdada,项目名称:amberfell,代码行数:101,代码来源:player.go


示例18: Draw

func (self *Inventory) Draw(t int64) {
	gl.MatrixMode(gl.MODELVIEW)
	gl.PushMatrix()
	gl.LoadIdentity()

	gl.Disable(gl.DEPTH_TEST)
	gl.Disable(gl.LIGHTING)
	gl.Disable(gl.LIGHT0)
	gl.Disable(gl.LIGHT1)

	gl.Color4ub(0, 0, 0, 208)

	gl.Begin(gl.QUADS)
	gl.Vertex2f(float32(viewport.lplane), float32(viewport.bplane))
	gl.Vertex2f(float32(viewport.rplane), float32(viewport.bplane))
	gl.Vertex2f(float32(viewport.rplane), float32(viewport.tplane))
	gl.Vertex2f(float32(viewport.lplane), float32(viewport.tplane))
	gl.End()

	picker.DrawItemHighlight(t, 3)
	picker.DrawItemHighlight(t, 4)
	picker.DrawItemHighlight(t, 5)
	picker.DrawItemHighlight(t, 6)
	picker.DrawItemHighlight(t, 7)
	picker.DrawPlayerItems(t, false)

	const blocksize = float64(0.3)
	const COLSIZE = 12

	slotsize := blocksize * 2.4
	slotstep := slotsize + float64(4)*PIXEL_SCALE
	slotsInRow := len(self.componentRects)

	xtools := float64(viewport.lplane) + 10.0*PIXEL_SCALE
	ytools := float64(viewport.tplane) - 10.0*PIXEL_SCALE - slotstep

	gl.PushMatrix()
	gl.LoadIdentity()
	gl.Translated(xtools, ytools+4*PIXEL_SCALE, 0)
	inventoryItemFont.Print("Inventory")
	gl.PopMatrix()
	for i := range self.inventoryRects {
		x := xtools + float64(i%slotsInRow)*slotstep
		y := ytools - float64(i/slotsInRow)*slotstep
		self.inventoryRects[i] = Rect{x, y - slotsize, slotsize, slotsize}
		self.DrawItemSlot(t, self.inventoryRects[i])
	}

	for i := range self.inventorySlots {
		if self.inventorySlots[i].item != 0 && self.inventorySlots[i].quantity > 0 {
			self.DrawItemInSlot(t, self.inventorySlots[i].quantity, self.inventorySlots[i].item, self.inventoryRects[i])
		}
	}

	xtools += slotstep * (1.0 + float64(slotsInRow))

	gl.PushMatrix()
	gl.LoadIdentity()
	gl.Translated(xtools, ytools+4*PIXEL_SCALE, 0)

	if self.currentCrafting == nil {
		inventoryItemFont.Print("Handcrafting")
	} else {
		inventoryItemFont.Print(self.currentCrafting.Label())
	}
	gl.PopMatrix()

	for i := range self.componentSlots {
		x := xtools + float64(i)*slotstep
		y := ytools
		self.componentRects[i] = Rect{x, y - slotsize, slotsize, slotsize}

		self.DrawItemSlot(t, self.componentRects[i])
	}

	for i, cs := range self.componentSlots {
		if cs.item != 0 {
			self.DrawItemInSlot(t, cs.quantity, cs.item, self.componentRects[i])
		}
	}

	ytools -= slotstep * 2
	for i := range self.productSlots {
		x := xtools + slotstep*float64(i%slotsInRow)
		y := ytools - slotstep*float64(i/slotsInRow)
		self.productRects[i] = Rect{x, y - slotsize, slotsize, slotsize}

		self.DrawItemSlot(t, self.productRects[i])
	}

	for i, ps := range self.productSlots {
		if ps != nil {
			self.DrawItemInSlot(t, ps.product.quantity, ps.product.item, self.productRects[i])
		}
	}

	ytools -= slotstep * float64(1+len(self.productRects)/slotsInRow)
	if self.currentContainer != nil {

		gl.PushMatrix()
//.........这里部分代码省略.........
开发者ID:codygman,项目名称:amberfell,代码行数:101,代码来源:inventory.go


示例19: Draw

func (self *Wolf) Draw(center Vectorf, selectedBlockFace *BlockFace) {
	pos := Vectorf{self.position[XAXIS], self.position[YAXIS], self.position[ZAXIS]}
	gl.PushMatrix()

	gl.Translated(self.position[XAXIS], self.position[YAXIS], self.position[ZAXIS])
	gl.Rotated(self.Heading(), 0.0, 1.0, 0.0)

	// Translate to top of ground block
	gl.Translatef(0.0, -0.5, 0.0)
	pos[YAXIS] += -0.5

	headHeight := 0.25
	headWidth := headHeight
	headDepth := headHeight * 2.0
	neckHeight := 0.0
	torsoWidth := 1.5 * headHeight
	torsoHeight := 1.5 * headHeight
	torsoDepth := 5 * headHeight
	legHeight := 5*headHeight - torsoHeight - neckHeight - headHeight
	legWidth := (torsoWidth - 0.25*headHeight) / 2
	legDepth := legWidth

	var legAngle, step float64

	horzSpeed := self.velocity[XAXIS]*self.velocity[XAXIS] + self.velocity[ZAXIS]*self.velocity[ZAXIS]
	legAngle = math.Sin(self.walkSequence) * (15 + 55*horzSpeed/(self.sprintSpeed*self.sprintSpeed))
	headAngle := 30.0
	// torsoAngle = -math.Abs(legAngle / 6)
	step = headHeight * 0.3 * math.Pow(math.Sin(self.walkSequence), 2)

	gl.Translated(0.0, step, 0)
	pos[YAXIS] += step

	// Translate to top of leg
	// Translate to centre of front left leg
	gl.Translated(0.0, legHeight, 0)
	pos[YAXIS] += legHeight

	legDepthOffset := torsoDepth/2 - legWidth/2
	legHeightOffset := -legHeight / 2
	legWidthOffset := (legWidth + 0.25*headHeight) / 2

	// Translate to centre of front left leg
	gl.Translated(legDepthOffset, 0, legWidthOffset)
	gl.Rotated(legAngle, 0.0, 0.0, 1.0)
	gl.Translated(0, legHeightOffset, 0)
	pos[XAXIS] += legDepthOffset
	pos[YAXIS] += legHeightOffset
	pos[ZAXIS] += legWidthOffset
	Cuboid(pos, legWidth, legHeight, legDepth, textures[TEXTURE_WOLF_LEG], textures[TEXTURE_WOLF_LEG], textures[TEXTURE_WOLF_LEG], textures[TEXTURE_WOLF_LEG], textures[TEXTURE_WOLF_LEG], textures[TEXTURE_WOLF_LEG], FACE_NONE)
	pos[XAXIS] -= legDepthOffset
	pos[YAXIS] -= legHeightOffset
	pos[ZAXIS] -= legWidthOffset
	gl.Translated(0, -legHeightOffset, 0)
	gl.Rotated(-legAngle, 0.0, 0.0, 1.0)
	gl.Translated(-legDepthOffset, 0, -legWidthOffset)

	legWidthOffset = -legWidthOffset
	if horzSpeed <= self.walkingSpeed*self.walkingSpeed {
		legAngle = -legAngle
	}

	gl.Translated(legDepthOffset, 0, legWidthOffset)
	gl.Rotated(legAngle, 0.0, 0.0, 1.0)
	gl.Translated(0, legHeightOffset, 0)
	pos[XAXIS] += legDepthOffset
	pos[YAXIS] += legHeightOffset
	pos[ZAXIS] += legWidthOffset
	Cuboid(pos, legWidth, legHeight, legDepth, textures[TEXTURE_WOLF_LEG], textures[TEXTURE_WOLF_LEG], textures[TEXTURE_WOLF_LEG], textures[TEXTURE_WOLF_LEG], textures[TEXTURE_WOLF_LEG], textures[TEXTURE_WOLF_LEG], FACE_NONE)
	pos[XAXIS] -= legDepthOffset
	pos[YAXIS] -= legHeightOffset
	pos[ZAXIS] -= legWidthOffset
	gl.Translated(0, -legHeightOffset, 0)
	gl.Rotated(-legAngle, 0.0, 0.0, 1.0)
	gl.Translated(-legDepthOffset, 0, -legWidthOffset)

	legDepthOffset = -legDepthOffset
	legWidthOffset = -legWidthOffset

	if horzSpeed > self.walkingSpeed*self.walkingSpeed {
		legAngle = -legAngle
	}

	gl.Translated(legDepthOffset, 0, legWidthOffset)
	gl.Rotated(legAngle, 0.0, 0.0, 1.0)
	gl.Translated(0, legHeightOffset, 0)
	pos[XAXIS] += legDepthOffset
	pos[YAXIS] += legHeightOffset
	pos[ZAXIS] += legWidthOffset
	Cuboid(pos, legWidth, legHeight, legDepth, textures[TEXTURE_WOLF_LEG], textures[TEXTURE_WOLF_LEG], textures[TEXTURE_WOLF_LEG], textures[TEXTURE_WOLF_LEG], textures[TEXTURE_WOLF_LEG], textures[TEXTURE_WOLF_LEG], FACE_NONE)
	pos[XAXIS] -= legDepthOffset
	pos[YAXIS] -= legHeightOffset
	pos[ZAXIS] -= legWidthOffset
	gl.Translated(0, -legHeightOffset, 0)
	gl.Rotated(-legAngle, 0.0, 0.0, 1.0)
	gl.Translated(-legDepthOffset, 0, -legWidthOffset)

	legWidthOffset = -legWidthOffset
	if horzSpeed <= self.walkingSpeed*self.walkingSpeed {
		legAngle = -legAngle
//.........这里部分代码省略.........
开发者ID:codygman,项目名称:amberfell,代码行数:101,代码来源:wolf.go


示例20: Render

func (s *Scatter) Render(w, h, d float64) {
	gl.PushMatrix()
	min, max := s.points.Bounds()
	dim := max.Sub(min)
	gl.Scaled(w/dim.X, h/dim.Y, d/dim.Z)
	gl.Translated(-min.X, -min.Y, -min.Z)

	// Draw axes: red X, green Y, blue Z.

	gl.Begin(gl.LINES)
	gl.LineWidth(1.5)
	gl.Color3ub(255, 0, 0)
	gl.Vertex3d(min.X, min.Y, min.Z)
	gl.Vertex3d(max.X, min.Y, min.Z)
	gl.Color3ub(0, 255, 0)
	gl.Vertex3d(min.X, min.Y, min.Z)
	gl.Vertex3d(min.X, max.Y, min.Z)
	gl.Color3ub(0, 0, 255)
	gl.Vertex3d(min.X, min.Y, min.Z)
	gl.Vertex3d(min.X, min.Y, max.Z)
	gl.End()

	// Draw 2d plots on the XY, YZ, and XZ planes.

	gl.PointSize(10.0)
	gl.Begin(gl.POINTS)

	// X plot
	gl.Color4ub(255, 0, 0, 31)
	for _, p := range s.points {
		gl.Vertex3d(p.X, min.Y, min.Z)
	}
	// Y plot
	gl.Color4ub(0, 255, 0, 31)
	for _, p := range s.points {
		gl.Vertex3d(min.X, p.Y, min.Z)
	}
	// Z plot
	gl.Color4ub(0, 0, 255, 31)
	for _, p := range s.points {
		gl.Vertex3d(min.X, min.Y, p.Z)
	}

	// XY plot
	gl.Color4ub(255, 255, 0, 63)
	for _, p := range s.points {
		gl.Vertex3d(p.X, p.Y, min.Z)
	}
	// YZ plot
	gl.Color4ub(0, 255, 255, 63)
	for _, p := range s.points {
		gl.Vertex3d(min.X, p.Y, p.Z)
	}
	// XZ plot
	gl.Color4ub(255, 0, 255, 63)
	for _, p := range s.points {
		gl.Vertex3d(p.X, min.Y, p.Z)
	}

	// XYZ plot
	gl.Color4ub(255, 255, 255, 128)
	for _, p := range s.points {
		gl.Vertex3d(p.X, p.Y, p.Z)
	}
	gl.End()
	gl.PopMatrix()
}
开发者ID:glenn-brown,项目名称:vu,代码行数:67,代码来源:scatter.go



注:本文中的github.com/banthar/gl.Translated函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang gl.Translatef函数代码示例发布时间:2022-05-24
下一篇:
Golang gl.ShadeModel函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap