Ejemplo n.º 1
0
func (this *World) PortalTransform(pos1, pos2 mgl.Vec4) mgl.Mat4 {
	portal := this.NearestPortal(pos1)
	m := portal.View()
	pos1 = m.Mul4x1(pos1)
	pos2 = m.Mul4x1(pos2)
	n := portal.Normal

	a := n.Dot(pos1)
	b := n.Dot(pos2)

	var portalPassed bool
	if a*b < 0 {
		c := a / (a - b)
		pos3 := pos1.Mul(c).Add(pos2.Mul(1 - c))
		portalPassed = -1 < pos3[0] && pos3[0] < 1 && -1 < pos3[1] && pos3[1] < 1
	} else {
		portalPassed = false
	}

	if portalPassed {
		return portal.Transform()
	} else {
		return mgl.Ident4()
	}
}
Ejemplo n.º 2
0
func NewWorldRenderer(window *sdl.Window, w *gamestate.World) *WorldRenderer {
	width, height := window.GetSize()

	return &WorldRenderer{
		Proj:               mgl.Perspective(90, float32(width)/float32(height), 0.3, 1000),
		View:               mgl.Ident4(),
		ClippingPlane_ws:   mgl.Vec4{1, 0, 0, -1000000},
		Textures:           NewTextures(w.HeightMap),
		HeightMapRenderer:  NewHeightMapRenderer(),
		WaterRendererA:     NewSurfaceWaterRenderer(),
		WaterRendererB:     NewDebugWaterRenderer(),
		MeshRenderer:       NewMeshRenderer(),
		PortalRenderer:     NewPortalRenderer(),
		TreeRenderer:       NewTreeRenderer(),
		SkyboxRenderer:     NewSkyboxRenderer(),
		Skybox:             &Skybox{},
		ParticleSystem:     particles.NewParticleSystem(w, 10000, mgl.Vec3{32, 32, 32}, 1, 250),
		Framebuffer:        [2]*FrameBuffer{NewFrameBuffer(window.GetSize()), NewFrameBuffer(window.GetSize())},
		ScreenQuad:         &ScreenQuad{},
		ScreenQuadRenderer: NewScreenQuadRenderer(),
		DebugRenderer:      NewLineRenderer(),
		MaxRecursion:       1,
	}
}
Ejemplo n.º 3
0
func (this *HeightMap) Model() mgl.Mat4 {
	return mgl.Ident4()
}
Ejemplo n.º 4
0
func (this *Skybox) Model() mgl.Mat4 {
	return mgl.Ident4()
}
Ejemplo n.º 5
0
func (this *Water) Model() mgl.Mat4 {
	return mgl.Ident4()
}
Ejemplo n.º 6
0
func (this *ScreenQuad) Model() mgl.Mat4 {
	return mgl.Ident4()
}