Exemplo n.º 1
0
func main() {
	var running bool = true

	if err := glfw.Init(); err != nil {
		fmt.Fprintf(os.Stderr, "[e] %v\n", err)
		return
	}

	defer glfw.Terminate()

	if err := glfw.OpenWindow(appWidth, appHeight, 8, 8, 8, 8,
		24, 8, glfw.Windowed); err != nil {
		fmt.Fprintf(os.Stderr, "[e] %v\n", err)
		return
	}
	defer glfw.CloseWindow()

	glfw.SetSwapInterval(1)
	glfw.SetWindowTitle(caption)

	if !horde3d.Init() {
		fmt.Println("Error starting Horde3D. Check Horde3d_log.html for details.")
		horde3d.DumpMessages()
		return
	}

	//horde3d.SetOption(horde3d.Options_DebugViewMode, 1)
	// Add resources
	//pipeline
	pipeRes = horde3d.AddResource(horde3d.ResTypes_Pipeline, "pipelines/hdr.pipeline.xml", 0)

	knightRes := horde3d.AddResource(horde3d.ResTypes_SceneGraph, "models/knight/knight.scene.xml", 0)

	//load resources paths separated by |
	horde3d.LoadResourcesFromDisk("../content")

	model := horde3d.RootNode.AddNodes(knightRes)
	model.SetTransform(0, 0, -30, 0, 0, 0, 0.1, 0.1, 0.1)

	// Add light source
	light := horde3d.RootNode.AddLightNode("Light1", 0, "LIGHTING", "SHADOWMAP")
	light.SetTransform(0, 20, 0, 0, 0, 0, 1, 1, 1)
	light.SetNodeParamF(horde3d.Light_RadiusF, 0, 50)

	//add camera
	cam = horde3d.RootNode.AddCameraNode("Camera", pipeRes)
	glfw.SetWindowSizeCallback(onResize)

	for running {

		horde3d.Render(cam)
		horde3d.FinalizeFrame()
		horde3d.DumpMessages()
		glfw.SwapBuffers()
		running = glfw.Key(glfw.KeyEsc) == 0 &&
			glfw.WindowParam(glfw.Opened) == 1
	}

	horde3d.Release()
}
Exemplo n.º 2
0
func (app *Application) release() {
	// Release engine
	horde3d.Release()
}
Exemplo n.º 3
0
func main() {
	var running bool = true
	var width int = 800
	var height int = 600
	var t float32

	if sdl.Init(sdl.INIT_VIDEO) != 0 {
		panic(sdl.GetError())
	}

	sdl.WM_SetCaption("Horde3d Go SDL Example", "")

	//set sdl video mode
	if sdl.SetVideoMode(width, height, 32, sdl.OPENGL) == nil {
		panic(sdl.GetError())
	}

	if !horde3d.Init() {
		fmt.Println("Error initializing Horde3D")
		horde3d.DumpMessages()
		return
	}

	//horde3d.SetOption(horde3d.Options_DebugViewMode, 1)
	//horde3d.SetOption(horde3d.Options_WireframeMode, 1)
	fmt.Println("Version: ", horde3d.VersionString())

	//pipeline
	pipeRes := horde3d.AddResource(horde3d.ResTypes_Pipeline, "forward.pipeline.xml", 0)
	modelRes := horde3d.AddResource(horde3d.ResTypes_SceneGraph, "platform.scene.xml", 0)

	horde3d.LoadResourcesFromDisk("../content|" +
		"../content/pipelines|" +
		"../content/models|" +
		"../content/materials|" +
		"../content/shaders|" +
		"../content/textures|" +
		"../content/animations|" +
		"../content/particles|" +
		"../content/models/platform|" +
		"../content/effects")

	//add camera
	cam := horde3d.RootNode.AddCameraNode("Camera", pipeRes)
	//Setup Camera Viewport
	cam.SetNodeParamI(horde3d.Camera_ViewportXI, 0)
	cam.SetNodeParamI(horde3d.Camera_ViewportYI, 0)
	cam.SetNodeParamI(horde3d.Camera_ViewportWidthI, width)
	cam.SetNodeParamI(horde3d.Camera_ViewportHeightI, height)

	//add model
	model := horde3d.RootNode.AddNodes(modelRes)
	model.SetTransform(0, -30, -150, 0, 0, 0, 1, 1, 1)
	//add light
	light := horde3d.RootNode.AddLightNode("Light1", 0, "LIGHTING", "SHADOWMAP")
	light.SetTransform(0, 20, 0, 0, 0, 0, 1, 1, 1)
	light.SetNodeParamF(horde3d.Light_RadiusF, 0, 150)
	light.SetNodeParamF(horde3d.Light_FovF, 0, 90)
	//horde3d.SetNodeParamI(light, horde3d.Light_ShadowMapCountI, 3)
	light.SetNodeParamF(horde3d.Light_ShadowSplitLambdaF, 0, 0.9)
	//horde3d.SetNodeParamF(light, horde3d.Light_ShadowMapBiasF, 0, 0.001)
	light.SetNodeParamF(horde3d.Light_ColorF3, 0, 1.9)
	light.SetNodeParamF(horde3d.Light_ColorF3, 1, 1.7)
	light.SetNodeParamF(horde3d.Light_ColorF3, 2, 1.75)

	for running {
		t = 0
		//increase anim time
		t = t + 10.0*(1/60)
		//process SDL events / input
		switch event := sdl.PollEvent(); event.(type) {
		case *sdl.QuitEvent:
			running = false
			break
		}
		//horde3d.SetNodeTransform(model,
		//t*10, 0, 0,
		//0, 0, 0,
		//1, 1, 1)
		horde3d.Render(cam)
		horde3d.FinalizeFrame()
		horde3d.DumpMessages()
		sdl.GL_SwapBuffers()
	}
	horde3d.Release()
	sdl.Quit()

}