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

Golang mathgl.Vec4类代码示例

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

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



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

示例1: modelviewToBoard

func (rv *RoomViewer) modelviewToBoard(mx, my float32) (x, y, dist float32) {
	mz := d2p(rv.mat, mathgl.Vec3{mx, my, 0}, mathgl.Vec3{0, 0, 1})
	//  mz := (my - float32(rv.Render_region.Y+rv.Render_region.Dy/2)) * float32(math.Tan(float64(rv.angle*math.Pi/180)))
	v := mathgl.Vec4{X: mx, Y: my, Z: mz, W: 1}
	v.Transform(&rv.imat)
	return v.X, v.Y, mz
}
开发者ID:hilerchyn,项目名称:haunts,代码行数:7,代码来源:room_viewer.go


示例2: modelviewToRightWall

func (rv *RoomViewer) modelviewToRightWall(mx, my float32) (x, y, dist float32) {
	mz := d2p(rv.right_wall_mat, mathgl.Vec3{mx, my, 0}, mathgl.Vec3{0, 0, 1})
	v := mathgl.Vec4{X: mx, Y: my, Z: mz, W: 1}
	v.Transform(&rv.right_wall_imat)
	if v.Y > float32(rv.room.Size.Dy) {
		v.Y = float32(rv.room.Size.Dy)
	}
	return v.X + float32(rv.room.Size.Dx), v.Y, mz
}
开发者ID:hilerchyn,项目名称:haunts,代码行数:9,代码来源:room_viewer.go


示例3: boardToModelview

func (hv *HouseViewer) boardToModelview(mx, my float32) (x, y, z float32) {
	v := mathgl.Vec4{X: mx, Y: my, W: 1}
	v.Transform(&hv.floor)
	x, y, z = v.X, v.Y, v.Z
	return
}
开发者ID:RickDakan,项目名称:haunts,代码行数:6,代码来源:house_viewer.go


示例4: modelviewToBoard

func (hv *HouseViewer) modelviewToBoard(mx, my float32) (x, y, dist float32) {
	mz := d2p(hv.floor, mathgl.Vec3{mx, my, 0}, mathgl.Vec3{0, 0, 1})
	v := mathgl.Vec4{X: mx, Y: my, Z: mz, W: 1}
	v.Transform(&hv.ifloor)
	return v.X, v.Y, mz
}
开发者ID:RickDakan,项目名称:haunts,代码行数:6,代码来源:house_viewer.go


示例5: drawFurniture

func drawFurniture(roomx, roomy int, mat mathgl.Mat4, zoom float32, furniture []*Furniture, temp_furniture *Furniture, extras []Drawable, cstack base.ColorStack, los_tex *LosTexture, los_alpha float64) {
	gl.Enable(gl.TEXTURE_2D)
	gl.Color4d(1, 1, 1, los_alpha)
	gl.PushMatrix()
	gl.LoadIdentity()

	board_to_window := func(mx, my float32) (x, y float32) {
		v := mathgl.Vec4{X: mx, Y: my, W: 1}
		v.Transform(&mat)
		x, y = v.X, v.Y
		return
	}

	g_stuff = g_stuff[0:0]
	for i := range furniture {
		g_stuff = append(g_stuff, furniture[i])
	}
	if temp_furniture != nil {
		g_stuff = append(g_stuff, temp_furniture)
	}
	for i := range extras {
		g_stuff = append(g_stuff, extras[i])
	}
	g_stuff = OrderRectObjects(g_stuff)

	for i := len(g_stuff) - 1; i >= 0; i-- {
		f := g_stuff[i]
		var near_x, near_y, dx, dy float32

		idx, idy := f.Dims()
		dx = float32(idx)
		dy = float32(idy)
		switch d := f.(type) {
		case *Furniture:
			ix, iy := d.Pos()
			near_x = float32(ix)
			near_y = float32(iy)

		case Drawable:
			fx, fy := d.FPos()
			near_x = float32(fx)
			near_y = float32(fy)
		}

		vis_tot := 1.0
		if los_tex != nil {
			vis_tot = 0.0

			// If we're looking at a piece of furniture that blocks Los then we
			// can't expect to have Los to all of it, so we will check the squares
			// around it.  Full visibility will mean that half of the surrounding
			// cells are visible.
			blocks_los := false
			// Also need to check if it is an enemy unit
			if _, ok := f.(*Furniture); ok {
				blocks_los = true
			}

			if blocks_los {
				for x := near_x - 1; x < near_x+dx+1; x++ {
					vis_tot += float64(los_tex.Pix()[int(x)+roomx][int(near_y-1)+roomy])
					vis_tot += float64(los_tex.Pix()[int(x)+roomx][int(near_y+dy+1)+roomy])
				}
				for y := near_y; y < near_y+dy; y++ {
					vis_tot += float64(los_tex.Pix()[int(near_x-1)+roomx][int(y)+roomy])
					vis_tot += float64(los_tex.Pix()[int(near_x+dx+1)+roomx][int(y)+roomy])
				}
				vis_tot /= float64((dx*2 + dy*2 + 4) * 255 / 2)
				if vis_tot > 1 {
					vis_tot = 1
				}
			} else {
				for x := near_x; x < near_x+dx; x++ {
					for y := near_y; y < near_y+dy; y++ {
						vis_tot += float64(los_tex.Pix()[int(x)+roomx][int(y)+roomy])
					}
				}
				vis_tot /= float64(dx * dy * 255)
			}
		}

		leftx, _ := board_to_window(near_x, near_y+dy)
		rightx, _ := board_to_window(near_x+dx, near_y)
		_, boty := board_to_window(near_x, near_y)
		if f == temp_furniture {
			cstack.Push(1, 0, 0, 0.4)
		} else {
			bot := (LosMinVisibility / 255.0)
			vis := (vis_tot - bot) / (1 - bot)
			vis = vis * vis
			vis = vis*(1-bot) + bot
			vis = vis * vis
			cstack.Push(vis, vis, vis, 1)
		}
		cstack.ApplyWithAlpha(los_alpha)
		cstack.Pop()
		switch d := f.(type) {
		case *Furniture:
			d.Render(mathgl.Vec2{leftx, boty}, rightx-leftx)

//.........这里部分代码省略.........
开发者ID:hilerchyn,项目名称:haunts,代码行数:101,代码来源:room_viewer.go


示例6: boardToModelview

func (rv *RoomViewer) boardToModelview(mx, my float32) (x, y, z float32) {
	v := mathgl.Vec4{X: mx, Y: my, W: 1}
	v.Transform(&rv.mat)
	x, y, z = v.X, v.Y, v.Z
	return
}
开发者ID:hilerchyn,项目名称:haunts,代码行数:6,代码来源:room_viewer.go


示例7: rightWallToModelview

func (rv *RoomViewer) rightWallToModelview(bx, by float32) (x, y, z float32) {
	v := mathgl.Vec4{X: bx - float32(rv.room.Size.Dx), Y: by, W: 1}
	v.Transform(&rv.right_wall_mat)
	return v.X, v.Y, v.Z
}
开发者ID:hilerchyn,项目名称:haunts,代码行数:5,代码来源:room_viewer.go


示例8: renderFurniture

func (room *Room) renderFurniture(floor mathgl.Mat4, base_alpha byte, drawables []Drawable, los_tex *LosTexture) {
	board_to_window := func(mx, my float32) (x, y float32) {
		v := mathgl.Vec4{X: mx, Y: my, W: 1}
		v.Transform(&floor)
		x, y = v.X, v.Y
		return
	}

	var all []RectObject
	for _, d := range drawables {
		x, y := d.Pos()
		if x < room.X {
			continue
		}
		if y < room.Y {
			continue
		}
		if x >= room.X+room.Size.Dx {
			continue
		}
		if y >= room.Y+room.Size.Dy {
			continue
		}
		all = append(all, offsetDrawable{d, -room.X, -room.Y})
	}

	// Do not include temporary objects in the ordering, since they will likely
	// overlap with other objects and make it difficult to determine the proper
	// ordering.  Just draw the temporary ones last.
	var temps []RectObject
	for _, f := range room.Furniture {
		if f.temporary {
			temps = append(temps, f)
		} else {
			all = append(all, f)
		}
	}
	all = OrderRectObjects(all)
	for i := range all {
		temps = append(temps, all[i])
	}

	for i := len(temps) - 1; i >= 0; i-- {
		d := temps[i].(Drawable)
		fx, fy := d.FPos()
		near_x, near_y := float32(fx), float32(fy)
		idx, idy := d.Dims()
		dx, dy := float32(idx), float32(idy)
		leftx, _ := board_to_window(near_x, near_y+dy)
		rightx, _ := board_to_window(near_x+dx, near_y)
		_, boty := board_to_window(near_x, near_y)
		vis := visibilityOfObject(room.X, room.Y, d, los_tex)
		r, g, b, a := d.Color()
		r = alphaMult(r, vis)
		g = alphaMult(g, vis)
		b = alphaMult(b, vis)
		a = alphaMult(a, vis)
		a = alphaMult(a, base_alpha)
		gl.Color4ub(r, g, b, a)
		d.Render(mathgl.Vec2{leftx, boty}, rightx-leftx)
	}
}
开发者ID:RickDakan,项目名称:haunts,代码行数:62,代码来源:room.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang log.Infof函数代码示例发布时间:2022-05-28
下一篇:
Golang mathgl.Vec2类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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