Ejemplo n.º 1
0
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()

}
Ejemplo n.º 2
0
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()
}
Ejemplo n.º 3
0
func (self *Wolf) Draw(center Vectorf, selectedBlockFace *BlockFace) {
	gl.PushMatrix()
	gl.Translatef(float32(self.position[XAXIS]), float32(self.position[YAXIS]), float32(self.position[ZAXIS]))
	gl.Rotated(self.Heading(), 0.0, 1.0, 0.0)
	WolfModel.GLDraw()
	gl.PopMatrix()
}
Ejemplo n.º 4
0
func (x spinner) Render(w, h, d float64) {
	gl.PushMatrix()
	t := time.Now().Sub(x.start).Seconds()
	gl.Rotated(120*surge(t), w, h, d)
	x.child.Render(w, h, d)
	gl.PopMatrix()
}
Ejemplo n.º 5
0
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()
}
Ejemplo n.º 6
0
func (self *Picker) DrawPlayerItems(t int64, drawQuantities bool) {

	gl.PushMatrix()
	gl.LoadIdentity()

	for i := 0; i < 5; i++ {

		itemid := ThePlayer.equippedItems[i]
		if itemid != ITEM_NONE {
			angle := -(float64(i) + 1.5) * math.Pi / 4
			gl.LoadIdentity()
			x := self.x - self.actionItemRadius*float32(math.Sin(angle))
			y := self.y + self.actionItemRadius*float32(math.Cos(angle))
			gl.Translatef(x, y, 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(BLOCK_SCALE, BLOCK_SCALE, BLOCK_SCALE)
			gGuiBuffer.Reset()
			if itemid < 256 {
				TerrainCube(gGuiBuffer, 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(gGuiBuffer, Vectori{}, BlockId(itemid))
			}
			gGuiBuffer.RenderDirect(false)

			if drawQuantities {
				gl.LoadIdentity()
				gl.Translatef(x-17*PIXEL_SCALE, y-19*PIXEL_SCALE, 20)
				consoleFont.Print(fmt.Sprintf("%d", ThePlayer.inventory[itemid]))
			}

		}
	}
	gl.PopMatrix()

}
Ejemplo n.º 7
0
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
		}
	}
}
Ejemplo n.º 8
0
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
		}
	}
}
Ejemplo n.º 9
0
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
	}

	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)

	//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_WOLF_TORSO_FRONT], textures[TEXTURE_WOLF_TORSO_BACK], textures[TEXTURE_WOLF_TORSO_SIDE], textures[TEXTURE_WOLF_TORSO_SIDE], textures[TEXTURE_WOLF_TORSO_TOP], textures[TEXTURE_WOLF_TORSO_TOP], FACE_NONE)

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

	// Translate to centre of head
	gl.Translated(torsoDepth/2+headDepth*0.5, 0.0, 0.0)
	pos[XAXIS] += torsoDepth/2 + headDepth*0.5
	pos[YAXIS] += 0.0

	gl.Rotated(-headAngle, 0.0, 0.0, 1.0)
	Cuboid(pos, headWidth, headHeight, headDepth, textures[TEXTURE_WOLF_HEAD_FRONT], textures[TEXTURE_WOLF_HEAD_BACK], textures[TEXTURE_WOLF_HEAD_SIDE], textures[TEXTURE_WOLF_HEAD_SIDE], textures[TEXTURE_WOLF_HEAD_TOP], textures[TEXTURE_WOLF_HEAD_BOTTOM], FACE_NONE)

	gl.PopMatrix()

}
Ejemplo n.º 10
0
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)
	pos[YAXIS] += armHeight / 2
	pos[ZAXIS] += torsoWidth/2 + armWidth/2
	gl.Rotated(-rightArmAngle, 0.0, 0.0, 1.0)

	// Translate to centre of head
	gl.Translated(0.0, neckHeight+headHeight/2, 0.0)
	pos[YAXIS] += neckHeight + headHeight/2

	if selectedBlockFace != nil {
		blockPos := selectedBlockFace.pos.Vectorf()
		headPos := player.position.Add(Vectorf{0, headHeight * 9, 0})

		blockDir := blockPos.Minus(headPos)
		if player.Facing(blockDir) {
			yrot := (math.Atan2(blockDir[XAXIS], blockDir[ZAXIS]) - math.Pi/2) * 180 / math.Pi
			zrot, xrot := -12.0, -12.0
			gl.Rotated(-player.Heading(), 0.0, 1.0, 0.0)
			gl.Rotated(yrot, 0.0, 1.0, 0.0)
			gl.Rotated(zrot, 0.0, 0.0, 1.0)
			gl.Rotated(xrot, 1.0, 0.0, 0.0)
		}
	}

	Cuboid(pos, headHeight, headHeight, headHeight, textures[TEXTURE_HEAD_FRONT], textures[TEXTURE_HEAD_BACK], textures[TEXTURE_HEAD_LEFT], textures[TEXTURE_HEAD_RIGHT], nil, textures[TEXTURE_HEAD_BOTTOM], FACE_NONE)

	// Translate to hat brim
	gl.Translated(0.0, headHeight/2+brimHeight/2, 0.0)
	pos[YAXIS] += headHeight/2 + brimHeight/2
	Cuboid(pos, brimWidth, brimHeight, brimDepth, textures[TEXTURE_BRIM], textures[TEXTURE_BRIM], textures[TEXTURE_BRIM], textures[TEXTURE_BRIM], textures[TEXTURE_BRIM], textures[TEXTURE_BRIM], FACE_NONE)

	gl.Translated(0.0, brimHeight/2+hatHeight/2, 0.0)
	pos[YAXIS] += headHeight/2 + brimHeight/2
	Cuboid(pos, hatHeight, hatHeight, hatHeight, textures[TEXTURE_HAT_FRONT], textures[TEXTURE_HAT_BACK], textures[TEXTURE_HAT_LEFT], textures[TEXTURE_HAT_RIGHT], textures[TEXTURE_HAT_TOP], nil, FACE_NONE)

	gl.PopMatrix()
}
Ejemplo n.º 11
0
func (y downY) Render(w, h, d float64) {
	gl.PushMatrix()
	gl.Rotated(1, 1, 1, 2.0*math.Pi/3.0)
	gl.PopMatrix()
}
Ejemplo n.º 12
0
func testPlot(dimension, order int) {
	var (
		iterations float64   = 0
		start_t              = time.Now()
		split      time.Time = start_t
		total      time.Duration
		fps        float64 = 1.0

		new_attractor, redraw bool = true, true
		npoints               int  = 1e5

		coeffs []float64
		//offsets, offset_coeffs []float64
		start Matrix = MakeMatrix(1, int(math.Max(3, float64(dimension))))
		points, points2/*, points3*/ Matrix

	//attractor = gl.GenLists(1);
	)

	//offsets = make([]float64, ncoeffs(order))
	//offset_coeffs = make([]float64, ncoeffs(order))
	//coeffs = make([]float64, dimension + nCoeffs(order, dimension) * dimension)

	//for i := range offsets { offsets[i] += rand.Float64() }

	for handleEvents(&new_attractor, &redraw, &npoints) {

		xoff += xvel / fps
		yoff += yvel / fps
		zoff += zvel / fps
		xrot += xrotvel / fps
		yrot += yrotvel / fps
		zrot += zrotvel / fps
		scale += svel / fps

		if new_attractor {
			coeffs, start = find_map_with_L(dimension, order, 0.1, 0.4)
			redraw = true
			new_attractor = false
		}
		if redraw {
			points = MakePointMatrix(makeMapFn(dimension, order, coeffs), start, 500, npoints)
			points2 = MakeMatrix(npoints, points.Height())
			//points3 = MakeMatrix(npoints, points.Height())
			redraw = false
			fmt.Println("Redraw", npoints, "points")
		}

		//points2 = points
		//RotationXW(xwrot).Apply(points, points2)
		//RotationYW(xwrot + 0.25).Apply(points2, points3)
		//RotationZW(xwrot + 0.50).Apply(points3, points2)

		if dimension == 4 {
			RotationZW(xwrot).Apply(points, points2)
			xwrot += 0.05
			ApplyW(points2, points2)
		} else {
			points2 = points
		}

		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.Color4d(1, 1, 1, 0.25)

		gl.EnableClientState(gl.VERTEX_ARRAY)
		if dimension > 3 {
			gl.VertexPointer(3, (dimension-3)*32, points2.FlatCols())
		} else {
			gl.VertexPointer(3, 0, points2.FlatCols())
		}
		gl.DrawArrays(gl.POINTS, 0, points2.Width())
		gl.DisableClientState(gl.VERTEX_ARRAY)

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

		iterations++
		if time.Since(split).Seconds() > 1.0 {
			total = time.Since(start_t)
			fps = iterations / total.Seconds()
			fmt.Println(iterations, "iterations in", total.Seconds(), "gives",
				fps, "fps")
			split = time.Now()
		}
	}
}