示例#1
0
文件: main.go 项目: GlenKelley/carsim
func (r *Receiver) Init(window *glfw.Window) {
	r.Window = window
	r.LoadConfiguration("gameconf.json")
	gtk.Bind(&r.Data)
	r.Shaders = gtk.NewShaderLibrary()
	r.Shaders.LoadProgram(ProgramScene, "scene.v.glsl", "scene.f.glsl")
	r.Shaders.BindProgramLocations(ProgramScene, &r.SceneLoc)
	gtk.PanicOnError()

	r.Data.Projection = glm.Ident4d()
	r.Data.Cameraview = glm.Ident4d()

	r.Data.Scene = gtk.EmptyModel("root")
	model, err := gtk.LoadSceneAsModel("drivetrain.dae")
	if err != nil {
		panic(err)
	}
	r.Data.Scene.AddChild(model)
	r.Data.Car, _ = model.FindModelWithName("Car")
	grid := gtk.EmptyModel("Grid")
	grid.AddGeometry(gtk.Grid(100))
	r.Data.Scene.AddChild(grid)

	r.Car = sim.NewCar()
	r.ResetKeyBindingDefaults()

	r.UIState = UIState{
		sim.Controls{},
		glm.Vec4d{0, 1, 0, 0},
		glm.Vec4d{1, 0, 0, 0},
		glm.QuatIdentd(),
		10,
	}
}
示例#2
0
文件: main.go 项目: GlenKelley/portal
func (r *Receiver) Init(window *glfw.Window) {
	r.Window = window
	r.LoadConfiguration("gameconf.json")
	r.Invalid = true
	gtk.Bind(&r.Data)
	// var err error
	// err = gtk.LoadTexture(r.Data.Tex0, "tex4.png")
	// panicOnErr(err)
	// err = gtk.LoadTexture(r.Data.Tex1, "tex3.png")
	// panicOnErr(err)

	r.Shaders = gtk.NewShaderLibrary()
	r.Shaders.LoadProgram(PROGRAM_SCENE, "scene.v.glsl", "scene.f.glsl")
	r.Shaders.LoadProgram(PROGRAM_FILL, "fill.v.glsl", "fill.f.glsl")
	r.Shaders.BindProgramLocations(PROGRAM_SCENE, &r.SceneLoc)
	r.Shaders.BindProgramLocations(PROGRAM_FILL, &r.FillLoc)
	gtk.PanicOnError()

	r.Data.Projection = glm.Ident4d()
	r.Data.Cameraview = glm.Ident4d()
	r.Data.Inception = glm.Ident4d()

	r.Data.Scene = gtk.EmptyModel("root")
	r.LoadScene("portal.dae")

	quadElements := gtk.MakeElements(portal.QuadElements)
	r.Data.Scene.AddGeometry(NewPlane("plane1", portal.Quad{
		glm.Vec4d{0, 0, 0, 1},
		glm.Vec4d{0, 1, 0, 0},
		glm.Vec4d{1, 0, 0, 0},
		glm.Vec4d{10, 10, 1, 0},
	},
		quadElements,
	))
	r.Data.Fill = NewPlane("plane1", portal.Quad{
		glm.Vec4d{0, 0, 0, 1},
		glm.Vec4d{0, 0, 1, 0},
		glm.Vec4d{1, 0, 0, 0},
		glm.Vec4d{1, 1, 1, 0},
	},
		quadElements,
	)

	// r.Portals = append(r.Portals, CreatePortals()...)
	r.Data.Portal = gtk.EmptyModel("portals")
	for i, p := range r.Portals {
		r.Data.Portal.AddGeometry(NewPlane(fmt.Sprintf("portal_%d", i), p.EventHorizon, quadElements))
	}
	r.Player = Player{
		glm.Vec4d{0, 1, 0, 1},
		glm.Vec4d{0, 0, 0, 0},
		glm.Vec4d{0, 1, 0, 0},
		glm.Vec4d{1, 0, 0, 0},
		glm.QuatIdentd(),
		glm.QuatIdentd(),
	}
}