Beispiel #1
0
// CreateBeam - creates a square prism oriented along the vector
func CreateBeam(width float32, vector mgl32.Vec3) *Geometry {
	direction := vector.Normalize()
	geo := CreateBoxWithOffset(width, width, -width*0.5, -width*0.5)
	geo2 := CreateBoxWithOffset(width, width, -width*0.5, -width*0.5)
	facingTx := util.Mat4From(mgl32.Vec3{1, 1, 1}, mgl32.Vec3{}, util.FacingOrientation(0, direction, mgl32.Vec3{0, 0, 1}, mgl32.Vec3{1, 0, 0}))
	geo.Transform(facingTx)
	facingTx = util.Mat4From(mgl32.Vec3{1, 1, 1}, vector, util.FacingOrientation(0, direction, mgl32.Vec3{0, 0, -1}, mgl32.Vec3{1, 0, 0}))
	geo2.Optimize(geo, facingTx)
	geo.Indicies = append(geo.Indicies, 0, 1, 4, 4, 5, 0) //top
	geo.Indicies = append(geo.Indicies, 1, 2, 7, 7, 4, 1) //side
	geo.Indicies = append(geo.Indicies, 2, 3, 6, 6, 7, 2) //bottom
	geo.Indicies = append(geo.Indicies, 3, 0, 5, 5, 6, 3) //side
	return geo
}
Beispiel #2
0
func (ps *ParticleSystem) loadParticle(p *Particle) {
	//set color
	p.geometry.SetColor(p.Color)
	//set flipbook uv
	BoxFlipbook(p.geometry, p.Frame, ps.Settings.FramesX, ps.Settings.FramesY)
	//rotate and move
	particleTransform := util.Mat4From(p.Scale, p.Translation, p.Orientation)
	//add geometry to particle system
	p.geometry.Optimize(ps.geometry, particleTransform)
}
Beispiel #3
0
func (node *Node) SetRotation(angle float32, axis mgl32.Vec3) {
	node.Orientation = mgl32.QuatRotate(angle, axis)
	node.Transform = util.Mat4From(node.Scale, node.Translation, node.Orientation)
}
Beispiel #4
0
func (node *Node) SetOrientation(orientation mgl32.Quat) {
	node.Orientation = orientation
	node.Transform = util.Mat4From(node.Scale, node.Translation, node.Orientation)
}
Beispiel #5
0
func (node *Node) SetTranslation(translation mgl32.Vec3) {
	node.Translation = translation
	node.Transform = util.Mat4From(node.Scale, node.Translation, node.Orientation)
}
Beispiel #6
0
func (node *Node) SetScale(scale mgl32.Vec3) {
	node.Scale = scale
	node.Transform = util.Mat4From(node.Scale, node.Translation, node.Orientation)
}