本文整理汇总了Golang中github.com/go-gl/mathgl/mgl32.Ident4函数的典型用法代码示例。如果您正苦于以下问题:Golang Ident4函数的具体用法?Golang Ident4怎么用?Golang Ident4使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Ident4函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
}
示例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,
}
}
示例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")
}
}
示例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)
}
示例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)
}
示例6: TestStackNew
func TestStackNew(t *testing.T) {
stack := NewTransformStack()
if !(*stack)[0].ApproxEqual(mgl32.Ident4()) {
t.Errorf("Cannot construct stack correctly")
}
}
示例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
}
示例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
}
示例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
}
}
示例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
}
}
示例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
}
示例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
}
示例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
}
}
示例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)
}
}
示例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)
}
}