Y-Wing Video

To show a little example, here is a video, which shows a flying Y-Wing (3D model from Al Meerow on www.scifi3d.com).

Video

Extracts from the Source Code

Full source code, see here.

Joystick Binding

createMover is joyName acName axName value movef = do
	action <- createAnalogAxisAction is (-1.0) 1.0 acName
	isJoy <- isJoystickAvailable is joyName
	if isJoy then do
		bindJoystickAxis action joyName axName
		return (Mover value action movef)
		else return (Mover value action movef)

Set Camera Position

setNewCameraPosition vs ywing newhist = do
 
		wingpos <- getPosition ywing
		let (pos, quat) = newhist !! 70
		-- this points towards nose
		let vdir = rotateVQ zv quat
		let newcampos = (scaleV3  (-70.0) vdir) + wingpos + (vector3 0.0 20.0 0.0)
 
		setCameraPos vs newcampos
		setCameraLookAt vs wingpos
		return ()
 

Create Gates (Blue Rectangles)

createGates es thickness freespace depth cubeT r = do
 
	-- parameters horizontal bars
	let hl = freespace + thickness  -- length horizontal bar
	let hw = thickness/2.0		    -- width horizontal bar
	let hpt = vector3 0.0 (freespace + thickness/2.0) 0.0 -- horizontal bar, position top
	let hpb = vector3 0.0 (-1.0 * (freespace + thickness/2.0)) 0.0 -- horizontal bar, position bottom
 
	-- create top and bottom cube
	top <-  createMesh es cubeT
	bottom <-  createMesh es cubeT
	setScale top (vector3 hl hw depth)
	setScale bottom (vector3 hl hw depth)
	setPosition top hpt
	setPosition bottom hpb
 
	-- parameters vertical bars
	let vl = freespace						-- vertical bar, length
	let vw = thickness/2.0						-- vertical bar, width
	let vpr = vector3 (freespace + thickness/2.0) 0.0 0.0    -- vertical bar, position right
	let vpl = vector3 (-1.0 * (freespace + thickness/2.0)) 0.0 0.0
 
	-- create left and right cube
	left <-  createMesh es cubeT
	right <-  createMesh es cubeT
	setScale left (vector3 vw vl depth)
	setScale right (vector3 vw vl depth)
	setPosition left vpl
	setPosition right vpr
 
	gate <- combineGraphicsObjects es [top, bottom, left, right]
	translate gate (vector3 0.0 0.0 r) TsParent
 
	return gate

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.