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

Golang mathgl.Mat4类代码示例

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

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



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

示例1: d2p

// Distance to Plane(Point?)?  WTF IS THIS!?
func d2p(tmat mathgl.Mat4, point, ray mathgl.Vec3) float32 {
	var mat mathgl.Mat4
	mat.Assign(&tmat)
	var sub mathgl.Vec3
	sub.X = mat[12]
	sub.Y = mat[13]
	sub.Z = mat[14]
	mat[12], mat[13], mat[14] = 0, 0, 0
	point.Subtract(&sub)
	point.Scale(-1)
	ray.Normalize()
	dist := point.Dot(mat.GetForwardVec3())

	var forward mathgl.Vec3
	forward.Assign(mat.GetForwardVec3())
	cos := float64(forward.Dot(&ray))
	return dist / float32(cos)
}
开发者ID:hilerchyn,项目名称:haunts,代码行数:19,代码来源:room_viewer.go


示例2: makeRoomMats

func makeRoomMats(room *roomDef, region gui.Region, focusx, focusy, angle, zoom float32) (floor, ifloor, left, ileft, right, iright mathgl.Mat4) {
	var m mathgl.Mat4
	floor.Translation(float32(region.Dx/2+region.X), float32(region.Dy/2+region.Y), 0)

	// NOTE: If we want to change 45 to *anything* else then we need to do the
	// appropriate math for rendering quads for furniture
	m.RotationZ(45 * math.Pi / 180)
	floor.Multiply(&m)
	m.RotationAxisAngle(mathgl.Vec3{X: -1, Y: 1}, -float32(angle)*math.Pi/180)
	floor.Multiply(&m)

	s := float32(zoom)
	m.Scaling(s, s, s)
	floor.Multiply(&m)

	// Move the viewer so that the focus is at the origin, and hence becomes centered
	// in the window
	m.Translation(-focusx, -focusy, 0)
	floor.Multiply(&m)

	ifloor.Assign(&floor)
	ifloor.Inverse()

	// Also make the mats for the left and right walls based on this mat
	left.Assign(&floor)
	m.RotationX(-math.Pi / 2)
	left.Multiply(&m)
	m.Translation(0, 0, float32(room.Size.Dy))
	left.Multiply(&m)
	ileft.Assign(&left)
	ileft.Inverse()

	right.Assign(&floor)
	m.RotationX(-math.Pi / 2)
	right.Multiply(&m)
	m.RotationY(-math.Pi / 2)
	right.Multiply(&m)
	m.Scaling(1, 1, 1)
	right.Multiply(&m)
	m.Translation(0, 0, -float32(room.Size.Dx))
	right.Multiply(&m)
	swap_x_y := mathgl.Mat4{
		0, 1, 0, 0,
		1, 0, 0, 0,
		0, 0, 1, 0,
		0, 0, 0, 1,
	}
	right.Multiply(&swap_x_y)
	iright.Assign(&right)
	iright.Inverse()

	return floor, ifloor, left, ileft, right, iright
}
开发者ID:hilerchyn,项目名称:haunts,代码行数:53,代码来源:room_viewer.go


示例3: RenderAdvanced

func RenderAdvanced(x, y, dx, dy, rot float64, flip bool) {
	setupTextureList()
	if textureList == 0 {
		return
	}
	var run, op mathgl.Mat4
	run.Identity()
	op.Translation(float32(x), float32(y), 0)
	run.Multiply(&op)
	op.Translation(float32(dx/2), float32(dy/2), 0)
	run.Multiply(&op)
	op.RotationZ(float32(rot))
	run.Multiply(&op)
	if flip {
		op.Translation(float32(-dx/2), float32(-dy/2), 0)
		run.Multiply(&op)
		op.Scaling(float32(dx), float32(dy), 1)
		run.Multiply(&op)
	} else {
		op.Translation(float32(dx/2), float32(-dy/2), 0)
		run.Multiply(&op)
		op.Scaling(float32(-dx), float32(dy), 1)
		run.Multiply(&op)
	}
	gl.PushMatrix()
	gl.MultMatrixf((*gl.Float)(&run[0]))
	gl.Enable(gl.TEXTURE_2D)
	gl.CallList(textureList)
	gl.PopMatrix()
}
开发者ID:runningwild,项目名称:jbot,代码行数:30,代码来源:manager.go


示例4: Render

func Render(x, y, dx, dy float64) {
	setupTextureList()
	if textureList == 0 {
		return
	}
	var run, op mathgl.Mat4
	run.Identity()
	op.Translation(float32(x), float32(y), 0)
	run.Multiply(&op)
	op.Scaling(float32(dx), float32(dy), 1)
	run.Multiply(&op)

	gl.PushMatrix()
	gl.Enable(gl.TEXTURE_2D)
	gl.MultMatrixf((*gl.Float)(&run[0]))
	gl.CallList(textureList)
	gl.PopMatrix()
}
开发者ID:runningwild,项目名称:jbot,代码行数:18,代码来源:manager.go


示例5: render

// Need floor, right wall, and left wall matrices to draw the details
func (room *Room) render(floor, left, right mathgl.Mat4, zoom float32, base_alpha byte, drawables []Drawable, los_tex *LosTexture, floor_drawers []FloorDrawer) {
	do_color := func(r, g, b, a byte) {
		R, G, B, A := room.Color()
		A = alphaMult(A, base_alpha)
		gl.Color4ub(alphaMult(R, r), alphaMult(G, g), alphaMult(B, b), alphaMult(A, a))
	}
	gl.Enable(gl.TEXTURE_2D)
	gl.Enable(gl.BLEND)
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
	gl.Enable(gl.STENCIL_TEST)
	gl.ClearStencil(0)
	gl.Clear(gl.STENCIL_BUFFER_BIT)

	gl.EnableClientState(gl.VERTEX_ARRAY)
	gl.EnableClientState(gl.TEXTURE_COORD_ARRAY)
	defer gl.DisableClientState(gl.VERTEX_ARRAY)
	defer gl.DisableClientState(gl.TEXTURE_COORD_ARRAY)

	var vert roomVertex

	planes := []plane{
		{room.left_buffer, room.Wall, &left},
		{room.right_buffer, room.Wall, &right},
		{room.floor_buffer, room.Floor, &floor},
	}

	gl.PushMatrix()
	defer gl.PopMatrix()

	if los_tex != nil {
		gl.LoadMatrixf(&floor[0])
		gl.ClientActiveTexture(gl.TEXTURE1)
		gl.ActiveTexture(gl.TEXTURE1)
		gl.Enable(gl.TEXTURE_2D)
		gl.EnableClientState(gl.TEXTURE_COORD_ARRAY)
		los_tex.Bind()
		gl.BindBuffer(gl.ARRAY_BUFFER, room.vbuffer)
		gl.TexCoordPointer(2, gl.FLOAT, gl.Sizei(unsafe.Sizeof(vert)), gl.Pointer(unsafe.Offsetof(vert.los_u)))
		gl.ClientActiveTexture(gl.TEXTURE0)
		gl.ActiveTexture(gl.TEXTURE0)
		base.EnableShader("los")
		base.SetUniformI("los", "tex2", 1)
	}

	var mul, run mathgl.Mat4
	for _, plane := range planes {
		gl.LoadMatrixf(&floor[0])
		run.Assign(&floor)

		// Render the doors and cut out the stencil buffer so we leave them empty
		// if they're open
		switch plane.mat {
		case &left:
			gl.StencilFunc(gl.ALWAYS, 1, 1)
			gl.StencilOp(gl.REPLACE, gl.REPLACE, gl.REPLACE)
			for _, door := range room.Doors {
				if door.Facing != FarLeft {
					continue
				}
				door.TextureData().Bind()
				R, G, B, A := door.Color()
				do_color(R, G, B, alphaMult(A, room.far_left.wall_alpha))
				gl.ClientActiveTexture(gl.TEXTURE0)
				door.TextureData().Bind()
				if door.door_glids.floor_buffer != 0 {
					gl.BindBuffer(gl.ARRAY_BUFFER, door.threshold_glids.vbuffer)
					gl.VertexPointer(3, gl.FLOAT, gl.Sizei(unsafe.Sizeof(vert)), gl.Pointer(unsafe.Offsetof(vert.x)))
					gl.BindBuffer(gl.ELEMENT_ARRAY_BUFFER, door.door_glids.floor_buffer)
					gl.TexCoordPointer(2, gl.FLOAT, gl.Sizei(unsafe.Sizeof(vert)), gl.Pointer(unsafe.Offsetof(vert.u)))
					gl.ClientActiveTexture(gl.TEXTURE1)
					gl.TexCoordPointer(2, gl.FLOAT, gl.Sizei(unsafe.Sizeof(vert)), gl.Pointer(unsafe.Offsetof(vert.los_u)))
					gl.DrawElements(gl.TRIANGLES, door.door_glids.floor_count, gl.UNSIGNED_SHORT, nil)
				}
			}
			gl.StencilFunc(gl.NOTEQUAL, 1, 1)
			gl.StencilOp(gl.KEEP, gl.KEEP, gl.KEEP)
			do_color(255, 255, 255, room.far_left.wall_alpha)

		case &right:
			gl.StencilFunc(gl.ALWAYS, 1, 1)
			gl.StencilOp(gl.REPLACE, gl.REPLACE, gl.REPLACE)
			for _, door := range room.Doors {
				if door.Facing != FarRight {
					continue
				}
				door.TextureData().Bind()
				R, G, B, A := door.Color()
				do_color(R, G, B, alphaMult(A, room.far_right.wall_alpha))
				gl.ClientActiveTexture(gl.TEXTURE0)
				door.TextureData().Bind()
				if door.door_glids.floor_buffer != 0 {
					gl.BindBuffer(gl.ARRAY_BUFFER, door.threshold_glids.vbuffer)
					gl.VertexPointer(3, gl.FLOAT, gl.Sizei(unsafe.Sizeof(vert)), gl.Pointer(unsafe.Offsetof(vert.x)))
					gl.BindBuffer(gl.ELEMENT_ARRAY_BUFFER, door.door_glids.floor_buffer)
					gl.TexCoordPointer(2, gl.FLOAT, gl.Sizei(unsafe.Sizeof(vert)), gl.Pointer(unsafe.Offsetof(vert.u)))
					gl.ClientActiveTexture(gl.TEXTURE1)
					gl.TexCoordPointer(2, gl.FLOAT, gl.Sizei(unsafe.Sizeof(vert)), gl.Pointer(unsafe.Offsetof(vert.los_u)))
					gl.DrawElements(gl.TRIANGLES, door.door_glids.floor_count, gl.UNSIGNED_SHORT, nil)
				}
//.........这里部分代码省略.........
开发者ID:RickDakan,项目名称:haunts,代码行数:101,代码来源:room.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang mathgl.Vec2类代码示例发布时间:2022-05-28
下一篇:
Golang game.Game类代码示例发布时间: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