Esempio n. 1
0
func sparkParticles() *effects.ParticleSystem {
	img, _ := assets.ImportImageCached("TestAssets/Spark.png")
	smoke := effects.CreateParticleSystem(effects.ParticleSettings{
		MaxParticles:     7,
		ParticleEmitRate: 7,
		BaseGeometry:     renderer.CreateBox(float32(1), float32(1)),
		TotalFrames:      1,
		FramesX:          1,
		FramesY:          1,
		MaxLife:          1.0,
		MinLife:          0.7,
		StartColor:       color.NRGBA{255, 220, 180, 255},
		EndColor:         color.NRGBA{255, 155, 55, 255},
		StartSize:        mgl32.Vec3{1, 1, 1}.Mul(0.008),
		EndSize:          mgl32.Vec3{1, 1, 1}.Mul(0.005),
		MinTranslation:   mgl32.Vec3{1, 1, 1}.Mul(-0.04),
		MaxTranslation:   mgl32.Vec3{1, 1, 1}.Mul(0.04),
		MinStartVelocity: mgl32.Vec3{-0.5, 0.0, -0.5},
		MaxStartVelocity: mgl32.Vec3{0.5, 1.0, 0.5},
		Acceleration:     mgl32.Vec3{0.0, -1.0, 0.0},
		OnParticleUpdate: func(p *effects.Particle) {
			p.Scale[0] = p.Scale[0] * (1 + p.Velocity.Len()*3.5)
			p.Orientation = mgl32.QuatBetweenVectors(mgl32.Vec3{1, 0, 0}, p.Velocity)
		},
	})
	smoke.Node.Material = renderer.NewMaterial(renderer.NewTexture("diffuseMap", img, false))
	return smoke
}
Esempio n. 2
0
func sparkParticles() *effects.ParticleGroup {
	img, _ := assets.ImportImageCached("resources/spark.png")
	material := renderer.NewMaterial(renderer.NewTexture("diffuseMap", img, false))
	particleSystem := effects.CreateParticleSystem(effects.ParticleSettings{
		MaxParticles:     80,
		ParticleEmitRate: 400,
		BaseGeometry:     renderer.CreateBox(float32(1), float32(1)),
		TotalFrames:      1,
		FramesX:          1,
		FramesY:          1,
		MaxLife:          3.3,
		MinLife:          1.7,
		StartColor:       color.NRGBA{254, 160, 90, 254},
		EndColor:         color.NRGBA{254, 160, 90, 254},
		StartSize:        mgl32.Vec2{2, 2}.Vec3(0),
		EndSize:          mgl32.Vec2{2, 2}.Vec3(0),
		MinTranslation:   mgl32.Vec2{-5, -5}.Vec3(0),
		MaxTranslation:   mgl32.Vec2{5, 5}.Vec3(0),
		MinStartVelocity: mgl32.Vec2{-100, -100}.Vec3(0),
		MaxStartVelocity: mgl32.Vec2{100, 100}.Vec3(0),
		Acceleration:     mgl32.Vec2{0, 400}.Vec3(0),
		OnParticleUpdate: func(p *effects.Particle) {
			p.Scale[0] = p.Scale[0] * (1 + p.Velocity.Len()*0.05)
			p.Orientation = mgl32.QuatBetweenVectors(mgl32.Vec3{1, 0, 0}, p.Velocity)
		},
	})
	particleSystem.FaceCamera = false
	particleGroup := effects.NewParticleGroup(nil, particleSystem)
	particleGroup.Node.Material = material
	return particleGroup
}
Esempio n. 3
0
//FacingOrientation - return an orientation that always faces the given direction with rotation
func FacingOrientation(rotation float32, direction, normal, tangent mgl32.Vec3) mgl32.Quat {
	betweenVectorsQ := mgl32.QuatBetweenVectors(normal, direction)
	angleQ := mgl32.QuatRotate(rotation, normal)
	orientation := betweenVectorsQ.Mul(angleQ)
	return orientation
}