Skip to content

Getting Started (WIP)

Daniel Salvadori edited this page Aug 18, 2018 · 5 revisions

This guide is a work in-progress.

Creating an application

G3N ships with an Application class which handles a lot of boilerplate code and includes many helpful functionalities.

	app, _ := application.Create(application.Options{
		Title:  "Hello G3N",
		Width:  800,
		Height: 600,
	})

Creating a geometry

	geom := geometry.NewTorus(1, .4, 12, 32, math32.Pi*2)

Creating a material

	mat := material.NewPhong(math32.NewColor("DarkBlue"))

Creating a mesh

	torusMesh := graphic.NewMesh(geom, mat)

Adding a node to the scene

	app.Scene().Add(torusMesh)

Lighting

	// Add lights to the scene
	ambientLight := light.NewAmbient(&math32.Color{1.0, 1.0, 1.0}, 0.8)
	app.Scene().Add(ambientLight)
	pointLight := light.NewPoint(&math32.Color{1, 1, 1}, 5.0)
	pointLight.SetPosition(1, 0, 2)
	app.Scene().Add(pointLight)

Axis helpers

	// Add an axis helper to the scene
	axis := graphic.NewAxisHelper(0.5)
	app.Scene().Add(axis)

Perspective camera

	app.CameraPersp().SetPosition(0, 0, 3)

Running the applicatioon

	app.Run()

Next steps → Read through the Guides and Tutorials.