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

Golang mgl32.Ident4函数代码示例

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

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



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

示例1: NewModel

// NewModel creates a new model.
func NewModel(id string, shaders sm.ShaderManager, textures tm.TextureManager) *Model {
	m := Model{
		id:         id,
		shaders:    shaders,
		textures:   textures,
		angle:      0.0,
		model:      mgl32.Ident4(),
		camera:     mgl32.Ident4(),
		projection: mgl32.Ident4(),
	}

	return &m
}
开发者ID:Ariemeth,项目名称:frame-assault-2,代码行数:14,代码来源:model.go


示例2: NewTerrainWithSeed

//	Define the vertex attributes for vertex positions and normals.
//	Make these match your application and vertex shader
//	You might also want to add colours and texture coordinates
func NewTerrainWithSeed(seed int64, frequency, scale float32, colorTone mgl32.Vec4) *Terrain {
	return &Terrain{
		seed,      // Seed
		frequency, // Frequency
		scale,     // NoiseScale
		colorTone, // Color Tone

		0,   // XSize: Set to zero because we haven't created the heightField array yet
		0,   // ZSize
		4,   // PerlinOctaves
		1.0, // HeightScale

		0, // VBOVertices
		0, // VBOColors
		0, // VBONormals
		0, // VBOIndices

		[]mgl32.Vec3{}, // Vertices
		[]mgl32.Vec3{}, // Normals
		[]mgl32.Vec3{}, // Colors
		[]uint16{},     // Indices

		[]float32{}, // Noise

		mgl32.Ident4(), // Model

		"Terrain",
		DRAW_POLYGONS,
	}
}
开发者ID:YagoCarballo,项目名称:Go-GL-Assignment-2,代码行数:33,代码来源:Terrain.go


示例3: TestStackPushPopPeek

func TestStackPushPopPeek(t *testing.T) {
	stack := NewTransformStack()

	if !stack.Peek().ApproxEqual(mgl32.Ident4()) {
		t.Errorf("Peek not working")
	}

	stack.Push(mgl32.HomogRotate3DY(mgl32.DegToRad(90)))

	if !stack.Peek().ApproxEqual(mgl32.HomogRotate3DY(mgl32.DegToRad(90))) {
		t.Errorf("Peek not working")
	}

	if stack.Len() != 2 {
		t.Errorf("Peek alters stack length")
	}

	pop, err := stack.Pop()
	if err != nil || !pop.ApproxEqual(mgl32.HomogRotate3DY(mgl32.DegToRad(90))) {
		t.Errorf("Pop is unsuccessful")
	}

	if stack.Len() != 1 {
		t.Errorf("Pop does not actually shorten stack")
	}

	_, err = stack.Pop()

	if err == nil {
		t.Errorf("Popping stack with 1 element does not return error as expected")
	}
}
开发者ID:rdterner,项目名称:mathgl,代码行数:32,代码来源:transformstack_test.go


示例4: onPaint

func onPaint(glctx gl.Context, sz size.Event) {

	glctx.Viewport(0, 0, sz.WidthPx, sz.HeightPx)
	glctx.ClearColor(0.5, 0.5, 0.5, 1)
	glctx.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

	glctx.UseProgram(program)

	projectionMtx = mgl32.Perspective(45, float32(width)/float32(height), 0.1, 100)

	arcBallMtx := arcball.getMtx()

	glctx.UniformMatrix4fv(projection, projectionMtx[:])

	glctx.UniformMatrix4fv(view, arcBallMtx[:])

	glctx.BindBuffer(gl.ARRAY_BUFFER, triBuf)
	glctx.EnableVertexAttribArray(position)
	glctx.EnableVertexAttribArray(color)
	glctx.EnableVertexAttribArray(normals)

	vertSize := 4 * (coordsPerVertex + colorPerVertex + normalsPerVertex)

	glctx.VertexAttribPointer(position, coordsPerVertex, gl.FLOAT, false, vertSize, 0)
	glctx.VertexAttribPointer(color, colorPerVertex, gl.FLOAT, false, vertSize, 4*coordsPerVertex)
	glctx.VertexAttribPointer(normals, normalsPerVertex, gl.FLOAT, false, vertSize, 4*(coordsPerVertex+colorPerVertex))

	glctx.DepthMask(true)

	glctx.Uniform3fv(lightPos, light.Pos[:])
	glctx.Uniform3fv(lightIntensity, light.Intensities[:])

	for _, k := range piano.Keys {
		glctx.Uniform4fv(tint, k.Color[:])

		mtx := k.GetMtx()
		normMat := mtx.Mat3().Inv().Transpose()
		glctx.UniformMatrix3fv(normalMatrix, normMat[:])
		glctx.UniformMatrix4fv(model, mtx[:])
		glctx.DrawArrays(gl.TRIANGLES, 0, len(triangleData)/vertSize)
	}

	modelMtx := mgl32.Ident4()
	modelMtx = modelMtx.Mul4(mgl32.Translate3D(worldPos.X(), worldPos.Y(), worldPos.Z()))
	modelMtx = modelMtx.Mul4(mgl32.Scale3D(0.5, 0.5, 0.5))

	/*
		glctx.Uniform4fv(tint, red[:])
		// Disable depthmask so we dont get the pixel depth of the cursor cube
		glctx.DepthMask(false)
		glctx.UniformMatrix4fv(model, modelMtx[:])
		glctx.DepthMask(true)
	*/

	glctx.DisableVertexAttribArray(position)
	glctx.DisableVertexAttribArray(color)
	glctx.DisableVertexAttribArray(normals)

	fps.Draw(sz)
}
开发者ID:rakyll,项目名称:GCSolutions,代码行数:60,代码来源:main.go


示例5: Draw

func (s *Scene) Draw(pass string, shader *render.ShaderProgram) {
	if s.Camera == nil {
		return
	}

	p := s.Camera.Projection
	v := s.Camera.View
	m := mgl.Ident4()
	vp := p.Mul4(v)
	// mvp := vp * m

	/* DrawArgs will be copied down recursively into the scene graph.
	 * Each object adds its transformation matrix before passing
	 * it on to their children */
	args := render.DrawArgs{
		Projection: p,
		View:       v,
		VP:         vp,
		MVP:        vp,
		Transform:  m,

		Pass:   pass,
		Shader: shader,
	}

	s.DrawCall(args)
}
开发者ID:johanhenriksson,项目名称:goworld,代码行数:27,代码来源:scene.go


示例6: TestStackNew

func TestStackNew(t *testing.T) {
	stack := NewTransformStack()

	if !(*stack)[0].ApproxEqual(mgl32.Ident4()) {
		t.Errorf("Cannot construct stack correctly")
	}
}
开发者ID:rdterner,项目名称:mathgl,代码行数:7,代码来源:transformstack_test.go


示例7: NewCamera

func NewCamera(worldCenter, worldSize mgl32.Vec3, screenSize mgl32.Vec2) (c *Camera, err error) {
	c = &Camera{
		View: mgl32.Ident4(),
	}
	c.SetScreenSize(screenSize)
	err = c.SetWorldBounds(worldCenter, worldSize)
	return
}
开发者ID:kurrik,项目名称:opengl-benchmarks,代码行数:8,代码来源:camera.go


示例8: Start

func Start(windowName string) error {
	err := llgl.InitDisplay(windowName)
	if err != nil {
		return err
	}
	err = llgl.InitGL()
	if err != nil {
		return err
	}

	glstate.program, err = loadShaders("cube.vert", "cube.frag")
	if err != nil {
		return err
	}
	glstate.program.Use()

	glstate.projectionUL = glstate.program.Uniform("projection")
	glstate.cameraUL = glstate.program.Uniform("camera")
	glstate.modelUL = glstate.program.Uniform("model")
	glstate.texUL = glstate.program.Uniform("tex")

	state.camera = mgl.LookAtV(mgl.Vec3{3, 3, 3}, mgl.Vec3{0, 0, 0}, mgl.Vec3{0, 1, 0})
	state.model = mgl.Ident4()

	glstate.cameraUL.SetMat4(state.camera)
	glstate.modelUL.SetMat4(state.model)
	glstate.texUL.SetTextureSlot(0)

	glstate.program.BindFragDataLocation(0, "outputColor")

	texturePath, err := assets.Locate("code.png")
	if err != nil {
		return err
	}
	texture, err := llgl.MakeTexture(0, texturePath)
	if err != nil {
		return err
	}
	texture.Bind(0)

	// Configure the vertex data
	vao := llgl.NewVertexArray()
	vao.Bind()

	glstate.vbo = llgl.NewVertexBuffer()
	glstate.vbo.Bind()

	val := glstate.program.VertexAttrib("vert")
	val.Enable()
	val.PointerFloat32(3, 5, 0)

	valTC := glstate.program.VertexAttrib("vertTexCoord")
	valTC.Enable()
	valTC.PointerFloat32(2, 5, 3)

	fpsCounter = NewFpsCounter()
	return nil
}
开发者ID:hialin,项目名称:hialin,代码行数:58,代码来源:hlgl.go


示例9: NewCube

func NewCube(vertexPositions, vertexColours, normals *[]float32) *Cube {
	return &Cube{
		0, 0, 0, // bufferObject, normals, colours
		0,                                       // elementBuffer
		DRAW_POLYGONS,                           // drawmode
		vertexPositions, vertexColours, normals, // vertexPositions, vertexColours, normals
		mgl32.Ident4(), // model
	}
}
开发者ID:YagoCarballo,项目名称:Go-OpenGL-Lab-3,代码行数:9,代码来源:cube.go


示例10: NewSphere

func NewSphere(numLats, numLongs uint32) *Sphere {
	return &Sphere{
		0, 0, 0, // sphereBufferObject, sphereNormals, sphereColours
		0,                 // elementBuffer
		DRAW_POLYGONS,     // drawmode
		numLats, numLongs, // numLats, numLongs
		0,              // numSphereVertices
		mgl32.Ident4(), // model
	}
}
开发者ID:YagoCarballo,项目名称:Go-OpenGL-Lab-3,代码行数:10,代码来源:sphere.go


示例11: CreateTransform

/* Creates a new 3D transform */
func CreateTransform(x, y, z float32) *Transform {
	t := &Transform{
		Matrix:   mgl.Ident4(),
		Position: mgl.Vec3{x, y, z},
		Rotation: mgl.Vec3{0, 0, 0},
		Scale:    mgl.Vec3{1, 1, 1},
	}
	t.Update(0)
	return t
}
开发者ID:johanhenriksson,项目名称:goworld,代码行数:11,代码来源:transform.go


示例12: NewLimited

// NewLimited returns a new instance of a LimitedCamera.
func NewLimited(minZoom, maxZoom float32, minPos, maxPos float32) *LimitedCamera {
	cam := &LimitedCamera{
		minZoom:    minZoom,
		maxZoom:    maxZoom,
		minPos:     minPos,
		maxPos:     maxPos,
		viewMatrix: mgl.Ident4()}

	return cam
}
开发者ID:inkyblackness,项目名称:shocked-client,代码行数:11,代码来源:LimitedCamera.go


示例13: NewCube

func NewCube(name string, vertexPositions, vertexColours, normals *[]float32, shaderManager *wrapper.ShaderManager) *Cube {
	return &Cube{
		name,    // Name
		0, 0, 0, // bufferObject, normals, colours
		0,                                       // elementBuffer
		DRAW_POLYGONS,                           // drawmode
		vertexPositions, vertexColours, normals, // vertexPositions, vertexColours, normals
		mgl32.Ident4(), // model
		shaderManager,  // Pointer to the Shader Manager
	}
}
开发者ID:YagoCarballo,项目名称:Go-GL-Assignment-2,代码行数:11,代码来源:cube.go


示例14: RenderScene

func (sceneGraph *SceneGraph) RenderScene(renderer Renderer, cameraLocation mgl32.Vec3) {
	//setup buckets
	sceneGraph.transparentBucket = sceneGraph.transparentBucket[:0]
	sceneGraph.buildBuckets(sceneGraph.transparentNode)
	sceneGraph.sortBuckets(renderer, cameraLocation)
	//render buckets
	sceneGraph.opaqueNode.Draw(renderer, mgl32.Ident4())
	for _, entry := range sceneGraph.transparentBucket {
		renderEntry(entry, renderer)
	}
}
开发者ID:walesey,项目名称:go-engine,代码行数:11,代码来源:sceneGraph.go


示例15: Draw

func (m *Manager) Draw() {
	/* create draw event args */
	p := m.Viewport
	v := mgl.Ident4()
	vp := p

	args := render.DrawArgs{
		Projection: p,
		View:       v,
		VP:         vp,
		MVP:        vp,
		Transform:  mgl.Ident4(),
	}

	gl.Viewport(0, 0, int32(m.Width), int32(m.Height))

	for _, el := range m.Children {
		el.Draw(args)
	}
}
开发者ID:johanhenriksson,项目名称:goworld,代码行数:20,代码来源:manager.go


示例16: NewSphere

func NewSphere(name string, numLats, numLongs uint32, shaderManager *wrapper.ShaderManager) *Sphere {
	return &Sphere{
		name,    // Name
		0, 0, 0, // sphereBufferObject, sphereNormals, sphereColours
		0,                 // elementBuffer
		DRAW_POLYGONS,     // drawmode
		numLats, numLongs, // numLats, numLongs
		0,              // numSphereVertices
		mgl32.Ident4(), // model
		mgl32.Vec4{},   // Position
		shaderManager,  // Pointer to the Shader Manager
	}
}
开发者ID:YagoCarballo,项目名称:Go-GL-Assignment-2,代码行数:13,代码来源:sphere.go


示例17: Display

func (me *test) Display(c *Core) {
	me.o1.Draw(c)
	me.o2.Draw(c)

	projection := mgl32.Perspective(mgl32.DegToRad(Fov), float32(WindowWidth)/WindowHeight, Near, Far)
	view := mgl32.LookAtV(mgl32.Vec3{3, 3, 3}, mgl32.Vec3{0, 0, 0}, mgl32.Vec3{0, 1, 0})
	model := mgl32.Ident4()
	MVP := projection.Mul4(view).Mul4(model)

	gl.UniformMatrix4fv(mvpLoc, 1, false, &MVP[0])
	gl.Uniform1i(TexLoc, 0)

}
开发者ID:Nekony,项目名称:go-gl-test,代码行数:13,代码来源:test.go


示例18: GetMtx

func (k PianoKey) GetMtx() mgl32.Mat4 {
	axis := mgl32.Vec3{1, 0, 0}
	keyLen := float32(2.0)
	if !k.white {
		keyLen = 1.0
	}
	modelMtx := mgl32.Ident4()
	modelMtx = modelMtx.Mul4(mgl32.Translate3D(k.Pos[0], k.Pos[1], k.Pos[2]-2))
	modelMtx = modelMtx.Mul4(mgl32.HomogRotate3D(k.Angle, axis))
	modelMtx = modelMtx.Mul4(mgl32.Translate3D(0, 0, keyLen))
	modelMtx = modelMtx.Mul4(mgl32.Scale3D(0.5, 0.5, keyLen))

	return modelMtx
}
开发者ID:xnattack,项目名称:GCSolutions,代码行数:14,代码来源:piano.go


示例19: NewCylinder

func NewCylinder(name string, vertices uint32, height, radius float32, shaderManager *wrapper.ShaderManager) *Cylinder {
	return &Cylinder{
		name,    // Name
		0, 0, 0, // cylinderBufferObject, cylinderNormals, cylinderColours
		0,              // elementBuffer
		DRAW_POLYGONS,  // DrawMode
		vertices,       // VerticesPerDisk
		height,         // Height
		radius,         // Radius
		mgl32.Ident4(), // Model
		0,              // numCylinderVertices
		shaderManager,  // Pointer to the Shader Manager
	}
}
开发者ID:YagoCarballo,项目名称:Go-GL-Assignment-2,代码行数:14,代码来源:cylinder.go


示例20: NewTransform

// NewTransform creates a new Transform struct with defaults.
// The given multiplier can be used to invert the matrix, e.g. camera matrix
// This value should be 1 or -1 (inverted).
//
// Position: 0,0,0
// Rotation: 0,0,0
// Scale:    1,1,1
//
// Up:       0,1,0
// Right:    1,0,0
// Forward:  0,0,-1
func NewTransform() *Transform {
	return &Transform{
		position:   mgl32.Vec3{0, 0, 0},
		rotation:   mgl32.Vec3{0, 0, 0},
		quaternion: mgl32.QuatIdent(),
		scale:      mgl32.Vec3{1, 1, 1},

		Up:      mgl32.Vec3{0, 1, 0},
		Right:   mgl32.Vec3{1, 0, 0},
		Forward: mgl32.Vec3{0, 0, -1},

		matrix: mgl32.Ident4(),
	}
}
开发者ID:nobonobo,项目名称:go-three,代码行数:25,代码来源:transform.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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