g3nd

command module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 18, 2019 License: BSD-2-Clause Imports: 15 Imported by: 0

README

G3ND - G3N Game Engine Demo Program

G3ND is a demo/test program for the G3N 3D game engine. It demonstrates the main features of the engine and contains some basic tests. It can be used to learn the game engine API by examining the source code of the demo programs. It's very easy to create a new demo as the main program takes care of a lot of initializations and housekeeping.

G3ND In Action

Dependencies for installation

G3ND only depends on the G3N game engine and so has the same dependencies as the engine itself. Please verify that the engine dependencies are in place before installing.

Installation

The following command will download G3ND, the engine, and third party Go packages on which it depends. It will also compile and install the packages and the g3nd binary. Make sure your GOPATH is set correctly.

go get -u github.com/g3n/g3nd

Note: G3ND comes with a data directory with media files including images, textures, models and audio files. Currently this directory has aproximately 50MB. The download and compilation may take some time. To see what is going on you can alternatively supply the verbose flag:

go get -u -v github.com/g3n/g3nd

Running

When G3ND is run without any command line parameters it shows the tree of categorized available demos at the left of its window and an empty center area to show the demo scene. Click on a category in the tree to expand it and then select a demo to show.

At the upper right corner is located the Control folder, which when clicked shows some controls which can change the parameters of the current demo. To run G3ND at fullscreen press Alt-F11 or start it using the -fullscreen command line flag.

To exit the program press ESC or close the window.

You can start G3ND to show a specific demo specifying the demo name (category plus "." plus name) in the command line such as:

>g3nd geometry.box

The G3ND window shows the current FPS rate (frames per second) of your system and the maximum potential FPS rate. The desired FPS rate can be adjusted using the command line parameters: -swapinterval and -targetfps.

Creating a new demo/test

You can use the tests/model.go file as a template for your tests. You can can change it directly or copy it to a new file such as tests/mytest.go and experiment with the engine. Your new test will appear under the |tests| category with mytest name. The contents of the tests/model.go file are shown below, documenting the common structure of all demo programs:

// This is a simple model for your tests
package tests

import (
	"github.com/g3n/engine/graphic"
	"github.com/g3n/engine/math32"
	"github.com/g3n/g3nd/app"
	"github.com/g3n/g3nd/demos"
)

// Sets the category and name of your test in the demos.Map
// The category name choosen here starts with a "|" so it shows as the
// last category in list. Change "model" to the name of your test.
func init() {
	demos.Map["|tests|.model"] = &testsModel{}
}

// This is your test object. You can store state here.
// By convention and to avoid conflict with other demo/tests name it
// using your test category and name.
type testsModel struct {
	grid *graphic.GridHelper // Pointer to a GridHelper created in 'Initialize'
}

// This method will be called once when the test is selected from the G3ND list.
// 'a' is a pointer to the G3ND application.
// It allows access to several methods such as a.Scene(), which returns the current scene,
// a.GuiPanel(), a.Camera(), a.Window() among others.
// You can build your scene adding your objects to the a.Scene()
func (t *testsModel) Initialize(a *app.App) {

	// Show axis helper
	ah := graphic.NewAxisHelper(1.0)
	a.Scene().Add(ah)

	// Creates a grid helper and saves its pointer in the test state
	t.grid = graphic.NewGridHelper(50, 1, &math32.Color{0.4, 0.4, 0.4})
	a.Scene().Add(t.grid)

	// Changes the camera position
	a.Camera().GetCamera().SetPosition(0, 4, 10)
	a.Camera().GetCamera().LookAt(&math32.Vector3{0,0,0})
}

// This method will be called at every frame
// You can animate your objects here.
func (t *testsModel) Render(a *app.App) {

	// Rotate the grid, just for show.
	rps := a.FrameDeltaSeconds() * 2 * math32.Pi
	t.grid.RotateY(rps * 0.05)
}

Contributing

If you spot a bug or create a new interesting demo you are encouraged to send pull requests.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
experimental
This is a simple model for your tests
This is a simple model for your tests

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL