Welcome to the new Ogre Wiki!
If you haven't done so already, be sure to visit the Wiki Portal to read about how the wiki works. Especially the Ogre Wiki Overview page.
If you haven't done so already, be sure to visit the Wiki Portal to read about how the wiki works. Especially the Ogre Wiki Overview page.
This is the source for BloodyMess Tutorial 4.
#include "ExampleApplication.h" #include <NxOgre.h> #include <NxOgreOGRE3D.h> class BloodyMessTutorial4Listener : public ExampleFrameListener { public: BloodyMessTutorial4Listener(RenderWindow *win, Camera *cam) : ExampleFrameListener(win, cam) { mTimeController = NxOgre::TimeController::getSingleton(); } bool frameStarted(const FrameEvent& evt) { mTimeController->advance(evt.timeSinceLastFrame); return ExampleFrameListener::frameStarted(evt); } protected: NxOgre::TimeController* mTimeController; }; class BloodyMessTutorial4 : public ExampleApplication, public NxOgre::Callback { protected: NxOgre::World* mWorld; NxOgre::Scene* mScene; NxOgre::TimeController* mTimeController; OGRE3DRenderSystem* mRenderSystem; OGRE3DBody* mCube; NxOgre::Volume* mVolume; void createScene() { // Set ambient light mSceneMgr->setAmbientLight(ColourValue(0.5f, 0.5f, 0.5f)); // Create a light Light* l = mSceneMgr->createLight("MainLight"); l->setPosition(20, 80, 50); // Position the camera mCamera->setPosition(0, 20, 80); mCamera->lookAt(0, 20, 0); // Create the world mWorld = NxOgre::World::createWorld(); // Create scene description NxOgre::SceneDescription sceneDesc; sceneDesc.mGravity = NxOgre::Vec3(0, -9.81f, 0); sceneDesc.mName = "DemoScene"; // Create scene mScene = mWorld->createScene(sceneDesc); // Set some physical scene values mScene->getMaterial(0)->setStaticFriction(0.5); mScene->getMaterial(0)->setDynamicFriction(0.5); mScene->getMaterial(0)->setRestitution(0.1); // Create render system mRenderSystem = new OGRE3DRenderSystem(mScene); //Create time controller mTimeController = NxOgre::TimeController::getSingleton(); // Add objects mCube = mRenderSystem->createBody(new NxOgre::Box(1, 1, 1), NxOgre::Vec3(0, 10, 0), "cube.1m.mesh"); // Create floor plane (Ogre) MovablePlane *plane = new MovablePlane("Plane"); plane->d = 0; plane->normal = Vector3::UNIT_Y; Ogre::MeshManager::getSingleton().createPlane("PlaneMesh", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, *plane, 120, 120, 1, 1, true, 1, 3, 3, Vector3::UNIT_Z); Entity *planeEnt = mSceneMgr->createEntity("PlaneEntity", "PlaneMesh"); planeEnt->setMaterialName("Examples/GrassFloor"); Ogre::SceneNode* mPlaneNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(); mPlaneNode->attachObject(planeEnt); mVolume = mScene->createVolume(new NxOgre::Box(5), NxOgre::Matrix44(NxOgre::Vec3(0, 0, 0)), this, NxOgre::Enums::VolumeCollisionType_All); } // Create a new frame listener void createFrameListener() { mFrameListener = new BloodyMessTutorial4Listener(mWindow, mCamera); mRoot->addFrameListener(mFrameListener); } void onVolumeEvent(NxOgre::Volume* volume, NxOgre::Shape* volumeShape, NxOgre::RigidBody* rigidBody, NxOgre::Shape* rigidBodyShape, unsigned int collisionEvent) { if(collisionEvent == NxOgre::Enums::VolumeCollisionType_OnEnter) { NxOgre::Actor* actor = static_cast<NxOgre::Actor*>(rigidBody); float y = (9.81 * actor->getMass()) // counteract gravity + (-actor->getLinearVelocity().y * actor->getMass()) // counteract vertical velocity + (10 - actor->getGlobalPosition().y * actor->getMass()); // Add some force to move it to the top actor->addForce(NxOgre::Vec3(0, y, 0), NxOgre::Enums::ForceMode_Impulse); } } }; #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 #define WIN32_LEAN_AND_MEAN #include "windows.h" #endif #ifdef __cplusplus extern "C" { #endif #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT) #else int main(int argc, char **argv) #endif { // Create application object BloodyMessTutorial4 app; try { app.go(); } catch(Exception& e) { #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 MessageBoxA(NULL, e.getFullDescription().c_str(), "An exception has occurred!", MB_OK | MB_ICONERROR | MB_TASKMODAL); #else std::cerr << "An exception has occurred: " << e.getFullDescription(); #endif } return 0; } #ifdef __cplusplus } #endif
Official Wiki and Website
- Forum
- Ogre Portal for NxOgre
Betajaen's Guide to creating a Bloody mess
Code snippetsbloody mess
General - Particles - Mesh Cooking - Cloths
Spacegaier's Tutorialsbloody mess
Setting up BloodyMess - First steps - Visual Debugger - Volumes & Triggers - Kinematics - Raycasting? - Resources and Meshes
Contributors to this page: jacmoe
and
Spacegaier
.
Page last modified on Wednesday 23 of December, 2009 14:08:48 UTC by jacmoe
.
The content on this page is licensed under the terms of the Creative Commons Attribution-ShareAlike License.
As an exception, any source code contributed within the content is released into the Public Domain.
Sidebar
Last changes
- Hydrax
- QtOgre
- SoC2012 Complete the DirectX 11 render system
- SoC2012 Volume Rendering with LOD aimed at terrain
- SoC2012 Improve and Demo the Terrain System
- Mogre and WPF
- SoC2012 Implementation of Off-Screen Particles
- Advanced Ogre Framework
- Ogre overlays using Qt
- Architecture and Design in Games
Search box
Online users
32
online users

