Level Music
-
- Posts: 31
- Joined: Mon Dec 15, 2003 5:49 pm
- Location: Ireland
- Contact:
Level Music
I have used the Collision tutorial to load my own level in with collision detection. What code do I have to add in and where do i have to add it to let the level have background music, a file called back.mp3?
http://www.gameplayzone.com/forum
Join the gameplayzone forums today!
http://www.gameplayzone.com
All the latest gaming news and advancements
Join the gameplayzone forums today!
http://www.gameplayzone.com
All the latest gaming news and advancements
-
- Posts: 31
- Joined: Mon Dec 15, 2003 5:49 pm
- Location: Ireland
- Contact:
I have been looking at it, but I dont really undertsand, as it uses lots more things like the Ball sound and explosions. I just want a simple piece of code I can use to put level music into the Collisions demo, then bit by bit work up to being able to make the tech demo.
http://www.gameplayzone.com/forum
Join the gameplayzone forums today!
http://www.gameplayzone.com
All the latest gaming news and advancements
Join the gameplayzone forums today!
http://www.gameplayzone.com
All the latest gaming news and advancements
You would need to add in Audiere, fmod, or any of the numerous sound libraries.
Irrlicht itself does not do sound.
http://irrlicht.sourceforge.net/phpBB2/ ... c.php?t=97
Irrlicht itself does not do sound.
http://irrlicht.sourceforge.net/phpBB2/ ... c.php?t=97
Crud, how do I do this again?
-
- Posts: 31
- Joined: Mon Dec 15, 2003 5:49 pm
- Location: Ireland
- Contact:
I know i have to use Audiere. Im posting in Beginner forum because I dont know HOW to use it. I need someone to show me what code to add into the collision example to call audiere and play music.
http://www.gameplayzone.com/forum
Join the gameplayzone forums today!
http://www.gameplayzone.com
All the latest gaming news and advancements
Join the gameplayzone forums today!
http://www.gameplayzone.com
All the latest gaming news and advancements
Just take a look at the audiere documentation. I think you would have needed only about 1-2 minutes to get the code. But anyway, here it is:
Code: Select all
AudioDevicePtr audiereDevice;
OutputStreamPtr stream;
audiereDevice = OpenDevice();
stream = OpenSound(audiereDevice.get(), "back.mp3", true);
stream->setRepeat(true);
stream->play();
-
- Posts: 31
- Joined: Mon Dec 15, 2003 5:49 pm
- Location: Ireland
- Contact:
I have looked at the documentation, Ive examined the tech demo code, but I dont know where abouts in the code you put that. Do I just stick it at the very top? The bottom?
http://www.gameplayzone.com/forum
Join the gameplayzone forums today!
http://www.gameplayzone.com
All the latest gaming news and advancements
Join the gameplayzone forums today!
http://www.gameplayzone.com
All the latest gaming news and advancements
-
- Posts: 31
- Joined: Mon Dec 15, 2003 5:49 pm
- Location: Ireland
- Contact:
Ah rite I didnt realise you had to download audiere separetely. Ive got the header file and all the other files now. Though I still dont know where abouts to add the coe. When I just add it in, I got a pile of errors.
http://www.gameplayzone.com/forum
Join the gameplayzone forums today!
http://www.gameplayzone.com
All the latest gaming news and advancements
Join the gameplayzone forums today!
http://www.gameplayzone.com
All the latest gaming news and advancements
-
- Posts: 31
- Joined: Mon Dec 15, 2003 5:49 pm
- Location: Ireland
- Contact:
OK this is the Audiere code the documentation gives and Niko gave:
This is the collision demo, where abouts do I add the above code to get a music file to play?
Code: Select all
AudioDevicePtr audiereDevice;
OutputStreamPtr stream;
audiereDevice = OpenDevice();
stream = OpenSound(audiereDevice.get(), "back.mp3", true);
stream->setRepeat(true);
stream->play();
Code: Select all
#include <irrlicht.h>
using namespace irr;
#pragma comment(lib, "Irrlicht.lib")
scene::ICameraSceneNode* camera = 0;
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(SEvent event)
{
if (camera)
return camera->OnEvent(event);
return false;
}
};
int main()
{
MyEventReceiver receiver;
IrrlichtDevice *device =
createDevice(video::DT_DIRECTX8, core::dimension2d<s32>(800, 600), 32, true, false, &receiver);
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
device->getFileSystem()->addZipFileArchive("files/map-20kdm2.pk3");
scene::IAnimatedMesh* q3levelmesh = smgr->getMesh("20kdm2.bsp");
scene::ISceneNode* q3node = 0;
if (q3levelmesh)
q3node = smgr->addOctTreeSceneNode(q3levelmesh->getMesh(0));
scene::ITriangleSelector* selector = 0;
if (q3node)
{
q3node->setPosition(core::vector3df(-1370,-130,-1400));
selector = smgr->createOctTreeTriangleSelector(q3levelmesh->getMesh(0), q3node, 128);
q3node->setTriangleSelector(selector);
selector->drop();
}
camera = smgr->addCameraSceneNodeFPS(0,100.0f,300.0f);
camera->setPosition(core::vector3df(0,100,0));
scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
selector, camera, core::vector3df(30,50,30),
core::vector3df(0,-100,0), 100.0f,
core::vector3df(0,50,0));
camera->addAnimator(anim);
anim->drop();
// disable mouse cursor
device->getCursorControl()->setVisible(false);
// add billboard
scene::IBillboardSceneNode * bill = smgr->addBillboardSceneNode();
bill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR );
bill->setMaterialTexture(0, driver->getTexture("files/particle.bmp"));
bill->setMaterialFlag(video::EMF_LIGHTING, false);
bill->setSize(core::dimension2d<f32>(20.0f, 20.0f));
// add 3 animated faeries.
video::SMaterial material;
material.Texture1 = driver->getTexture("files/faerie2.bmp");
material.Lighting = true;
scene::IAnimatedMeshSceneNode* node = 0;
scene::IAnimatedMesh* faerie = smgr->getMesh("files/faerie.md2");
if (faerie)
{
node = smgr->addAnimatedMeshSceneNode(faerie);
node->setPosition(core::vector3df(-70,0,-90));
node->setMD2Animation(scene::EMAT_RUN);
node->getMaterial(0) = material;
node = smgr->addAnimatedMeshSceneNode(faerie);
node->setPosition(core::vector3df(-70,0,-30));
node->setMD2Animation(scene::EMAT_SALUTE);
node->getMaterial(0) = material;
node = smgr->addAnimatedMeshSceneNode(faerie);
node->setPosition(core::vector3df(-70,0,-60));
node->setMD2Animation(scene::EMAT_JUMP);
node->getMaterial(0) = material;
}
material.Texture1 = 0;
material.Lighting = false;
// Add a light
smgr->addLightSceneNode(0, core::vector3df(-60,100,400),
video::SColorf(1.0f,1.0f,1.0f,1.0f),
600.0f);
scene::ISceneNode* selectedSceneNode = 0;
scene::ISceneNode* lastSelectedSceneNode = 0;
int lastFPS = -1;
while(device->run())
{
driver->beginScene(true, true, 0);
smgr->drawAll();
core::line3d<f32> line;
line.start = camera->getPosition();
line.end = line.start + (camera->getTarget() - line.start).normalize() * 1000.0f;
core::vector3df intersection;
core::triangle3df tri;
if (smgr->getSceneCollisionManager()->getCollisionPoint(
line, selector, intersection, tri))
{
bill->setPosition(intersection);
driver->setTransform(video::TS_WORLD, core::matrix4());
driver->setMaterial(material);
driver->draw3DTriangle(tri, video::SColor(0,255,0,0));
}
selectedSceneNode = smgr->getSceneCollisionManager()->getSceneNodeFromCameraBB(camera);
if (lastSelectedSceneNode)
lastSelectedSceneNode->setMaterialFlag(video::EMF_LIGHTING, true);
if (selectedSceneNode == q3node || selectedSceneNode == bill)
selectedSceneNode = 0;
if (selectedSceneNode)
selectedSceneNode->setMaterialFlag(video::EMF_LIGHTING, false);
lastSelectedSceneNode = selectedSceneNode;
driver->endScene();
int fps = driver->getFPS();
if (lastFPS != fps)
{
wchar_t tmp[1024];
swprintf(tmp, 1024, L"Collision detection example - Irrlicht Engine (fps:%d) Triangles:%d",
fps, driver->getPrimitiveCountDrawn());
device->setWindowCaption(tmp);
lastFPS = fps;
}
}
device->drop();
return 0;
}
http://www.gameplayzone.com/forum
Join the gameplayzone forums today!
http://www.gameplayzone.com
All the latest gaming news and advancements
Join the gameplayzone forums today!
http://www.gameplayzone.com
All the latest gaming news and advancements
-
- Posts: 31
- Joined: Mon Dec 15, 2003 5:49 pm
- Location: Ireland
- Contact:
Thanks, it works
It wasnt working with me because I forgot about using the pragma statement
It wasnt working with me because I forgot about using the pragma statement
http://www.gameplayzone.com/forum
Join the gameplayzone forums today!
http://www.gameplayzone.com
All the latest gaming news and advancements
Join the gameplayzone forums today!
http://www.gameplayzone.com
All the latest gaming news and advancements