Irrlicht and Macromedia Director (or Authorware

A forum to store posts deemed exceptionally wise and useful
Post Reply
wolfsb
Posts: 26
Joined: Sun Dec 26, 2004 1:51 pm
Location: Berlin, Germany

Irrlicht and Macromedia Director (or Authorware

Post by wolfsb »

Just in case, someone out there is interested:

Niko's engine can be used to perfection with Macromedias Director (or Authorware). This way
you can make use of all Irrlicht-features and Director-features in combination. An
interesting way to create games... You have to use the Buddy API with Macromedia's
Director (or Authorware)

Here is how it works :

Just design (to start with) 2 buttons: Open, Close. <Open> will open a
window that contains your Irrlicht-Application, <Close> will close that window.
Add the following LINGO-Functions to your Director-application:

// path to your Irrlicht_Project
on D3_FindApplication
set D3Exe = the moviePath & "Irrlicht_Project.exe"
return D3Exe
end

// refers to Caption-Text of Irrlicht-Window (to set in C++ Source)- i.e. device->setWindowCaption(L"ProjektWin");
// you can also refer to the ClassName (if given) - then it is the first param that should be used
on D3_FindWindow
set D3Win = baFindWindow("", "IrrlichtWin")
return D3Win
end

// attach the following behaviour-function to your <OPEN>-(Director)-button

on D3_OpenFile

set result = false
set D3Exe = D3_FindApplication()
set D3Win = D3_FindWindow()

if baRunProgram(D3Exe, "normal", FALSE) > 32 then
baWaitForWindow(baWinHandle(),"active",0)
baWindowToFront(D3Win)
baMoveWindow(D3Win,0,0,640,480,true)
end if
else
( your Error-Routine )
end if
return result
end

// attach the following behaviour to your <CLOSE>-(Director)-button
on D3_CloseFile

set D3Win = D3_FindWindow()
baWindowToBack(D3Win)
baCloseWindow(D3Win)
end

That's all to it. For best results you show change the Irrlicht-Device-Window-Style
to WS_POPUP (frameless, no caption) (can be change for instance in CIrrDevice32.cpp -> look out for
"style"). This way your window can be perfectly embedded in combination with
every background your using for your Director-Application. You can even entertain
people with your Director-application while the Irrlicht-Window is loading in the
background (i.e. bring it to front no earlier than all meshes and textures are
completely loaded). For interaction between your Irrlicht-App and your Director-App
write text files out and read them in again with either App...

Regards, Wolf from Berlin, GY
wolfsb
Posts: 26
Joined: Sun Dec 26, 2004 1:51 pm
Location: Berlin, Germany

Post by wolfsb »

by the number of views I can tell, there seems to be interest, so here in more detail:

create a scene, using the Irrlicht 3D engine. set the movie height and width
(for example) to 800 x 600. create a Director movie, set the projector to
fullscreen, (for example) 1024 x 768. start the Director movie. let us assume,
your Irrlicht scene is "sample.exe". use LINGO as follows:

// trace the application
on Irrlicht_FindApplication
set IrrlichtEXE = the moviePath & "sample.exe"
return IrrlichtEXE
end

// trace the window
on Irrlicht_FindWindow
set IrrWin = baFindWindow("CIrrDeviceWin32", "Caption-Text")
return IrrWin
end

// open the application, but make Director-window stay on top
// until the Irrlicht-Scene is completely loaded

on Irrlicht_OpenApp

set IrrlichtEXE = Irrlicht_FindApplication()
if IrrlichtEXE = "" then
baMsgBox("Application not found", "File error", "Exclamation", "OK", 1)
return result
end if
baSetWindowState(baWinHandle(), "StayOnTop"
if baRunProgram(IrrlichtEXE, "normal", FALSE) > 32 then
set D3Win = baNextActiveWindow(0)
set result = true
else
baMsgBox("Could not open file", "file error", "Exclamation", "OK", 1)
end if
return result
end

// now that the Irrlicht-Scene is completely loaded bring the Irrlicht-Window
// to the front - interactivity is now allowed on the Director level (remember:
// you DirWin is 1024x 768, so there is plenty of room for graphics or
// switches) as well as in the IrrlichtWin (800 x 600, framelessly embedded
// in the Director-background, and with its own controls)

on IrrlichtWin_BringToFront left, top,width, height

set D3Win = Irrlicht_FindWindow()
if D3Win<>0 then
baSetWindowState(baWinHandle(), "DontStay")
baMoveWindow(D3Win, the stageLeft+left, the stageTop+top,width,height,false
end if
end

// use this in the frame of your choice like -> IrrlichtWin_BringToFront 16,16,800,600

// give control back to the Director application, but have the IrrlichtWin
// waiting in the background ... (to come back to front, if needed)

on IrrlichtWin_BringToBack
set D3Win = Irrlicht_FindWindow()
if D3Win <> 0 then
ok = baWindowToBack(D3Win)
end if
end

// to close the IrrlichtWindow/Application use

on IrrlichtWin_Close
set D3Win = Irrlicht_FindWindow()
if D3Win <> 0 then
ok = baCloseWindow(D3Win)
end if
end

I applied this technique while working on my high resolution solar system simulation project.
the irrlicht device is used to travel in orbit, flying around and exploring. director is used to provide
tons of information pulled from a V12-database. whenever I do not need realtime I switch to
shockwave 3D. the background music is audiere, provided by the Irrlicht window.

Communication between the two windows (applications) is done by using XML. I write XML by
creating a XML writer (Irrlicht) and parsing it, loading it into the Director-Projector and vice versa.

IXMLWriter* xmlWriter = device->getFileSystem()->createXMLWriter("../tut_media/XML/planets.xml");
.. you know how that works, I take it.

and read it (for example), using LINGO:

property pXMLObj
global gPlanets

on beginSprite me
pXMLObj = new(xtra "XMLParser")
pXMLObj.parseURL(the moviePath & "../tut_media/xml/planets.xml")
end

on endSprite me
pXMLObj = 0
end

on exitFrame me
if pXMLObj.doneParsing() then
gPlanets = pXMLObj.makeList()
pXMLObj = 0
else
go to the frame
end if
end


That's all to it. Works like charm and without any problems, so far. By the way: use
OPENGL with Irrlicht and set the Director-Shockwave-Renderer also to OPENGL (or
set them both to DIRECTX, if you prefer)

regards, wolfsb from Germany and thank you, thank you JOX for bringing
in your LMTSLoader - Update. that really helped a lot
Guest

Post by Guest »

demo/example plz
Post Reply