irrlicht learning notes - from getting started to giving up

irrlicht learning notes - from getting started to giving up

This is a game engine developer irrlicht's learning notes

Written at the end

Spent a day, through the rough study of irrlicht.

Know the basic usage, how to load resources, create nodes, how to load maps, GUI, collision detection, built-in effects, programmable rendering pipeline, pixel by pixel lighting, terrain rendering, rendering to texture, split screen, lighting management, xml file reading and writing, custom Mesh, occlusion query, font use and creation, etc.

However, some problems have been found. irrlicht does not have advanced programming ideas, but only provides some basic rendering engine functions, which is not easy to expand. Cannot support Chinese characters. From the perspective of supported platforms and features, it is an ancient product, and the technology has been eliminated.

In terms of performance, only occlusion query optimization.

It's OK to make a small demo.

You can give up

learning process

  1. download irrlicht Irrlicht Engine - A free open source 3D engine (sourceforge.io)

  2. compile

    (1) Open irrlicht/examples/BuildAllExamples_vc12.sln

    (2) Run samples

  3. Related documents Irrlicht 3D Engine: Irrlicht Engine 1.8 API documentation (sourceforge.io)

  4. Open the irrlicht folder using vscode

    Analyze the file structure, including bin, Doc, examples, include, lib, media, source, tools, changes.txt and readme.txt

  5. Read readme.txt

    (1) 1. Overview of document structure

    • bin: the compiled library Irrlicht.dll and some compiled demo and sample applications. Just start them to view the operation of the Irrlicht engine. Windows only.
    • doc: document
    • Examples: examples and tutorials for C + +
    • include: the header file of the engine
    • lib: library file of the engine
    • Media: graphics and audio files for examples
    • source: the resource file of the engine
    • Tools: useful tools

    (2) Other

  6. Open the include folder

    Find some. h files starting with C, E, I and S. open a few at random and find

    • I starts with a pure virtual interface class
    • The interface implementation class starts with C
    • E is the enumeration value
    • S is the structure
    • Some other data structures, such as vector2d, vector3d, etc
  7. Open the source folder

    • source/irrlicht
    • Found some folders and some files
    • Aesgladman: AES encryption algorithm
    • Bzip2: zip related (compressed)
    • JPEG lib: JPEG related
    • Libpng: PNG related
    • lzma: compression algorithm
    • Zlib: zlib related (compressed)
    • Mac OS X: Mac OS specific
    • A pile of files starting with C. open several files and find that they are the implementation of the interface in include and other functions
  8. Open the tools folder

    • FileToHeader
    • GUIEditor
    • IrrEdit
    • IrrFontTool
    • MeshConverter
  9. Go back to the include folder

    Open a file beginning with I, find that it inherits from IReferenceCounted, open IReferenceCounted. H, and get the reference counting class from the name and content. The basic memory management mechanism is reference counting.

    Look at all the file names in this folder,

    Roughly include

    IndexBuffer, vertex buffer, mesh, scene, file, scene, light, particle, animation, texture, material, vertex2d, vertex3d, map, rect, quaternion, position2d, plane3d, matrix4, line, skybox, etc

    From these files, it can be concluded that these are the code related to the rendering part of the game engine.

    It is preliminarily concluded that irrlicht is a rendering engine.

  10. Open the source folder

    Roughly browse the files inside and find that they are basically the implementation in include.

    Some new files to D3D8, D3D9, OpenGL, SoftDriver, xxxLoader, DeviceWin32,DeviceWinCE, DeviceLinux

    It supports D3D8, D3D9, OpenGL and softdriver

    Support MacOS, Windows, Linux, STL, FB(framebuffer)

    It can be seen from the supported APIs d3d8, D3D9 and SoftDriver that this is an ancient product.

  11. Run Samples

* 01.HelloWorld

(1) Window title: Hello world- Irrlicht Engine Demo

(2) There is a line of text: Hello World! This is the Irrlicht Software renderer!

(3) There is a dynamic model

code

    IrrlichtDevice *device =
		createDevice(video::EDT_SOFTWARE,  // Maya software 
        dimension2d<u32>(640, 480), // Window size 640x480
        16, // 16 bit pixels, not full screen, ignored
        false, // Non full screen
        false, // No template cache
        false, // No vertical synchronization
        0 // No event receiver
    );
    
    device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo");
    // Set window title
	IVideoDriver* driver = device->getVideoDriver();
    // Obtain the video driver and the SOFTWARE specified above
	ISceneManager* smgr = device->getSceneManager();
    // Get scene manager
	IGUIEnvironment* guienv = device->getGUIEnvironment();
    // Get GUI environment

From this, we can get some information,
Videodriver, SceneManager and guienvironment belong to internal objects, which will be created when creating devices. Other internal objects may be created.

    // Add a static text box
	guienv->addStaticText(L"Hello World! This is the Irrlicht Software renderer!",
		rect<s32>(10,10,260,22), true);
		
    // Using the scene explorer, load Mesh
    IAnimatedMesh* mesh = smgr->getMesh("../../media/sydney.md2");
// Use the scene explorer to add an animated Mesh
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
	if (node)
	{
		node->setMaterialFlag(EMF_LIGHTING, false);// Add materials to the animation without lighting.
		
		node->setMD2Animation(scene::EMAT_STAND);// Animate standing
		
		ITexture* texture = driver->getTexture("../../media/sydney.bmp");// Load texture
		
		node->setMaterialTexture( 0, texture);// Set material texture
		
	}
// Add a camera
	smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
	
	while(device->run())
	{
		
		driver->beginScene(true, true, SColor(255,100,101,140));// Scene start
        
		smgr->drawAll(); // Render Scene 
		
		guienv->drawAll(); // Rendering GUI

		driver->endScene(); // End of scene
	}
	
    device->drop(); // Release device

According to HelloWorld, the basic code sequence,

  1. createdevice
  2. getVideoDriver, ...
  3. sceneManager->addxxxNode()
  4. while(device->run())
  5. videoDriver->beginScene(...)
  6. sceneManager->drawAll()
  7. guienv->drawAll()
  8. videoDriver->endScene()
  • Some problems found
  1. VideoDriver->beginScene(bool backBuffer, bool zBuffer, SColor color)

    As you can guess from the parameters, this is emptying the cache,

    So the actual function of this function may be beginDrawScene,

    But there is guienv - > drawall between beginScene and endScene,

    Guess from the scene manager and GUI environment separately that the UI should not belong to the scene,

    So beginScene should actually be beginDraw

    endScene should be endDraw

  2. It is found from the contents of the running loop that they are all drawing functions,

    videoDriver->beginScene

    sceneManager->drawAll

    guienv->drawAll

    videoDriver->endScene

    Guess that the update operation of scene / UI / animation should be in device - > run().

    Through debugging, it is found that the update operation is not involved in run().

    So, guess that the scene / UI update should be inside drawAll

    Debugging found that the sceneManager::drawAll function has a lot of code, so we give up going deep.

* 02.Quake3Map

Load map from quake3

Discover new things by looking at the code

  • device->getFileSystem()->addFileArchive("")

    Through the comments, it is found that this is to add the file cache function. The next time you read the same file, you can read it from the cache to speed up the reading speed.

  • smgr->addOctreeSceneNode

    It can be concluded that the scene uses octree management

  • smgr->addCameraSceneNodeFPS()

    FPS statistical function

  • device->getCursorControl()->setVisible(false);

    hide cursor

  • device->isWindowActive()

    Is the window active

  • device->yield()

    Window inactive, waiting, Pause

* 03.CustomSceneNode

Custom scene node

From class csamplescenode, we can know that the user-defined node has an aab collision box, vertices and materials.

// Register node rendering
	virtual void OnRegisterSceneNode()
	{
		if (IsVisible)
			SceneManager->registerNodeForRendering(this);

		ISceneNode::OnRegisterSceneNode();
	}

If you need to render nodes, you need to register the nodes in the scene manager

Register when isVisible?

unregisterNodeForRendering not found

Guess it's to register every frame

Through debugging, it is found that this is true

// How to render nodes
	virtual void render()
	{
		u16 indices[] = {	0,2,3, 2,1,3, 1,0,3, 2,0,1	};
		video::IVideoDriver* driver = SceneManager->getVideoDriver();

		driver->setMaterial(Material);
		driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
		driver->drawVertexPrimitiveList(&Vertices[0], 4, &indices[0], 4, video::EVT_STANDARD, scene::EPT_TRIANGLES, video::EIT_16BIT);
	}
// Get aab collision box
	virtual const core::aabbox3d<f32>& getBoundingBox() const
	{
		return Box;
	}

// Get material quantity
	virtual u32 getMaterialCount() const
	{
		return 1;
	}

// Get material
	virtual video::SMaterial& getMaterial(u32 i)
	{
		return Material;
	}	
// Create a rotation animation
    	scene::ISceneNodeAnimator* anim =
		smgr->createRotationAnimator(core::vector3df(0.8f, 0, 0.8f));

	if(anim)
	{
        // Add rotation animation to custom nodes
		myNode->addAnimator(anim);
        // ...
    }

* 04.Movement

move

Create some models / animations and control them with the keys

This is an extremely pitiful scene. If pause is not judged, the application pause state is still running, and the light cursor cannot move out of the area outside the window

  • A class MyEventReceiver is created to respond to some internal events, such as key events.
    See IEventReceiver.h for specific messages

  • Create animation node

        scene::IAnimatedMeshSceneNode* anms =
    	    smgr->addAnimatedMeshSceneNode(smgr->getMesh("../../media/ninja.b3d")); // Load the model and create animation nodes
    
        anms->setFrameLoop(0, 13); // Set cycle frame
        anms->setAnimationSpeed(15); // Set animation speed
    
        anms->setScale(core::vector3df(2.f,2.f,2.f)); // Set zoom
        anms->setRotation(core::vector3df(0,-90,0)); // Set rotation
    
  • Create static Text in white

    gui::IGUIStaticText* diagnostics = device->getGUIEnvironment()->addStaticText(
    	L"", core::rect<s32>(10, 10, 400, 20));
    diagnostics->setOverrideColor(video::SColor(255, 255, 255, 0));
    
  • fix bug

    while(device->run())
    {
        // Determines whether the window is active
    	if (!device->isWindowActive())
    	{
    		device->yield();
    		continue;
    	}
        // ...
    }
    

* 05.UserInterface

Demonstrate some basic UI

  • Set ui font
    IGUISkin* skin = env->getSkin();
    IGUIFont* font = env->getFont("../../media/fonthaettenschweiler.bmp");
    if (font)
    	skin->setFont(font);
    
    skin->setFont(env->getBuiltInFont(), EGDF_TOOLTIP);
    
    

Open fonthaettenschweiler.bmp and you will find that this is an ascii font image,

Global search for truetype found no, truetype fonts are not supported.

So the support for Chinese characters is a little embarrassing.

  • Create a scrollbar and set the ID. when the scrollbar changes, it will send an event and get the event through the EventReceiver

    IGUIScrollBar* scrollbar = env->addScrollBar(true,
                rect<s32>(150, 45, 350, 60), 0, GUI_ID_TRANSPARENCY_SCROLL_BAR);
    
  • Set UI transparency as a whole

    setSkinTransparency( scrollbar->getPos(), env->getSkin());
    
    // Get all the color settings of ui skin and modify alpha
    void setSkinTransparency(s32 alpha, irr::gui::IGUISkin * skin)
    {
        for (s32 i=0; i<irr::gui::EGDC_COUNT ; ++i)
        {
            video::SColor col = skin->getColor((EGUI_DEFAULT_COLOR)i);
            col.setAlpha(alpha);
            skin->setColor((EGUI_DEFAULT_COLOR)i, col);
        }
    }
    
    

    According to setSkinTransparency, the ui is divided into different parts, and each part can be set with different colors.

* 06.2DGraphics

2D function

  • Make the pixels in the picture with the same pixel value as the specified position transparent

    video::ITexture* images = driver->getTexture("../../media/2ddemo.png");
    driver->makeColorKeyTexture(images, core::position2d<s32>(0,0));
    
    

    (function of chicken ribs)

  • Set material properties

    driver->getMaterial2D().TextureLayer[0].BilinearFilter=true;
    driver->getMaterial2D().AntiAliasing=video::EAAM_FULL_BASIC;
    

    Is antialiasing a material attribute?

  • Draw 2D pictures

    driver->draw2DImage(images, core::position2d<s32>(50,50),
        core::rect<s32>(0,0,342,224), 0,
    video::SColor(255,255,255,255), true);
    
  • Draw text

    font2->draw(L"Also mixing with 3d graphics is possible.",
    	core::rect<s32>(130,20,300,60),
    	video::SColor(255,time % 255,time % 255,255));
    
  • Drawing pictures with 2D materials

    driver->enableMaterial2D();
    driver->draw2DImage(images, core::rect<s32>(10,10,108,48),
    	core::rect<s32>(354,87,442,118));
    driver->enableMaterial2D(false);
    
  • Draw a 2D rectangle

     driver->draw2DRectangle(...)
    

* 07.Collision

collision

  • Create nodes that can be selected

    q3node = smgr->addOctreeSceneNode(q3levelmesh->getMesh(0), 0, IDFlag_IsPickable);
    
  • Create octree triangle selector

    auto selector = smgr->createOctreeTriangleSelector(q3node->getMesh(), q3node, 128);
    
    q3node->setTriangleSelector(selector);
    

    When creating a triangle selector, q3node is specified. Q3node also needs to set the selector?

    When creating, what is the specified node used for?

    To be explored!

  • Create a scene animation collision and responder and set it to the camera

    scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
    		selector, camera, core::vector3df(30,50,30),
    		core::vector3df(0,-10,0), core::vector3df(0,30,0));
    	selector->drop(); // As soon as we're done with the selector, drop it.
    	camera->addAnimator(anim);
    	anim->drop();  // And likewise, drop the animator when we're done referring to it.
    
  • Create billboard

    scene::IBillboardSceneNode * bill = smgr->addBillboardSceneNode();
    // ...
    bill->setID(ID_IsNotPickable);
    

    Set a special purpose ID?

    enum
    {
        ID_IsNotPickable = 0,
    
        IDFlag_IsPickable = 1 << 0,
    
        IDFlag_IsHighlightable = 1 << 1
    };
    
  • Get collision detector

    scene::ISceneCollisionManager* collMan = smgr->getSceneCollisionManager();
    
  • Get interactive rays

    	core::line3d<f32> ray;
      	ray.start = camera->getPosition();
      	ray.end = ray.start + (camera->getTarget() - ray.start).normalize() * 1000.0f;
    

    A ray directly in front of the camera to 1000 directly in front

  • Ray interaction

    scene::ISceneNode * selectedSceneNode =
      		collMan->getSceneNodeAndCollisionPointFromRay(
      				ray,
      				intersection, // This will be the position of the collision
      				hitTriangle, // This will be the triangle hit in the collision
      				IDFlag_IsPickable, // This ensures that only nodes that we have
      						// set up to be pickable are considered
      				0); // Check the entire scene (this is actually the implicit default)
    
    

    The fourth parameter idBitMask = IDFlag_IsPickable, which is a bitwise value, that is, the same layer with the same bit.

    That is, different interaction layers can be distinguished by the ID of the sceneNode.

* 08.SpecialFX

Built in effect

  • Planar mapping of rooms
smgr->getMeshManipulator()->makePlanarTextureMapping(mesh->getMesh(0), 0.004f);
  • Add terrain

     mesh = smgr->addHillPlaneMesh( "myHill",
    		core::dimension2d<f32>(20,20),
    		core::dimension2d<u32>(40,40), 0, 0,
    		core::dimension2d<f32>(0,0),
    		core::dimension2d<f32>(10,10));
      ```
    
    
    
  • Water surface effect

    node = smgr->addWaterSurfaceSceneNode(mesh->getMesh(0), 3.0f, 300.0f, 30.0f);
    
  • Particle effect

     // Create particle effect nodes
    scene::IParticleSystemSceneNode* ps =
      	smgr->addParticleSystemSceneNode(false);
    
      // Create a square emitter
      scene::IParticleEmitter* em = ps->createBoxEmitter(
      	core::aabbox3d<f32>(-7,0,-7,7,1,7), // emitter size
      	core::vector3df(0.0f,0.06f,0.0f),   // initial direction
      	80,100,                             // emit rate
      	video::SColor(0,255,255,255),       // darkest color
      	video::SColor(0,255,255,255),       // brightest color
      	800,2000,0,                         // min and max age, angle
      	core::dimension2df(10.f,10.f),         // min size
      	core::dimension2df(20.f,20.f));        // max size
    
      // Set emitter
      ps->setEmitter(em); // this grabs the emitter
    
      // Create a fade particle effect influence
      scene::IParticleAffector* paf = ps->createFadeOutParticleAffector();
    
      // Set the influencer
      ps->addAffector(paf); // same goes for the affector
    
  • Volume light node

      scene::IVolumeLightSceneNode * n = smgr->addVolumeLightSceneNode(0, -1,
      			32,                              // Subdivisions on U axis
      			32,                              // Subdivisions on V axis
      			video::SColor(0, 255, 255, 255), // foot color
      			video::SColor(0, 0, 0, 0));      // tail color
    
  • Texture animation

    scene::ISceneNodeAnimator* glow = smgr->createTextureAnimator(textures, 150);
    
  • Add shadow node

    anode->addShadowVolumeSceneNode();
    smgr->setShadowColor(video::SColor(150,0,0,0)); // Set shadow color
    

* 09.Meshviewer

  • Set COLLADA mesh loading singleton

    smgr->getParameters()->setAttribute(scene::COLLADA_CREATE_SCENE_INSTANCES, true);
    
  • Set texture creation flag

    driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);
    
  • Read xml

    Device->getFileSystem()->createXMLReader( L"config.xml");
    
  • create menu

    gui::IGUIContextMenu* menu = env->addMenu();
    
  • Add menu item

    menu->addItem(L"File", -1, true, true);
    submenu->addItem(L"Open Model File & Texture...", GUI_ID_OPEN_MODEL); // Specify CommandID
    
  • Get submenu

    submenu = menu->getSubMenu(0);
    
  • Add delimiter

    submenu->addSeparator();
    
  • Create toolbar

    gui::IGUIToolBar* bar = env->addToolBar();
    
  • add button

    bar->addButton(GUI_ID_BUTTON_OPEN_MODEL, 0, L"Open a model",image, 0, false, true); // Specify ID
    
  • Import scene

    Device->getSceneManager()->loadScene(filename);
    
  • Gets a node of the specified type in the scene

    Device->getSceneManager()->getSceneNodesFromType(scene::ESNT_ANIMATED_MESH, outNodes);
    
  • Show MessageBox

    Device->getGUIEnvironment()->addMessageBox(
      		Caption.c_str(), L"The model could not be loaded. " \
      		L"Maybe it is not a supported file format.");
    
  • Set whether Debug data is displayed

    Model->setDebugDataVisible(scene::EDS_OFF);
    
  • Get GUI by ID

    gui::IGUIContextMenu* menu = (gui::IGUIContextMenu*)Device->getGUIEnvironment()->getRootGUIElement()->getElementFromId(GUI_ID_TOGGLE_DEBUG_INFO, true);
    
  • Set whether the item is selected

    menu->setItemChecked(item, false);
    
  • Add sky box

    SkyBox = smgr->addSkyBoxSceneNode(
      	driver->getTexture("irrlicht2_up.jpg"),
      	driver->getTexture("irrlicht2_dn.jpg"),
      	driver->getTexture("irrlicht2_lf.jpg"),
      	driver->getTexture("irrlicht2_rt.jpg"),
      	driver->getTexture("irrlicht2_ft.jpg"),
      	driver->getTexture("irrlicht2_bk.jpg"));
    
  • Add a maya type camera

    Camera[0] = smgr->addCameraSceneNodeMaya();
    
  • Set how to

    img->setAlignment(EGUIA_UPPERLEFT, EGUIA_UPPERLEFT,
      		EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT);
    

* 10.Shaders

Using shader s, you can programmatically render pipelines

  • Query properties

    driver->queryFeature(video::EVDF_PIXEL_SHADER_1_1);
    driver->queryFeature(video::EVDF_VERTEX_SHADER_1_1);
    
  • Get GPU application server

    video::IGPUProgrammingServices* gpu = driver->getGPUProgrammingServices();
    
  • Load shader material

    newMaterialType1 = gpu->addHighLevelShaderMaterialFromFiles(
      			vsFileName, "vertexMain", video::EVST_VS_1_1,
      			psFileName, "pixelMain", video::EPST_PS_1_1,
      			mc, video::EMT_SOLID, 0, shadingLanguage);
    
      		newMaterialType2 = gpu->addHighLevelShaderMaterialFromFiles(
      			vsFileName, "vertexMain", video::EVST_VS_1_1,
      			psFileName, "pixelMain", video::EPST_PS_1_1,
      			mc, video::EMT_TRANSPARENT_ADD_COLOR, 0 , shadingLanguage);
    

* 11.PerPixelLighting

Per pixel illumination

  • Set atomization

    driver->setFog(video::SColor(0,138,125,81), video::EFT_FOG_LINEAR, 250, 1000, .003f, true, false);
    
  • Set normal map texture

    driver->makeNormalMapTexture(normalMap, 9.0f);
    
  • Create Mesh with tangents

    scene::IMesh* tangentMesh = smgr->getMeshManipulator()->
      			createMeshWithTangents(roomMesh->getMesh(0));
    
  • Set vertex transparency

    manipulator->setVertexColorAlpha(tangentSphereMesh, 200);
    
  • Set transform

      core::matrix4 m;
      m.setScale ( core::vector3df(50,50,50) );// Amplification matrix
      manipulator->transform( tangentSphereMesh, m ); 
    
  • Set event sink

    	MyEventReceiver receiver(room, earth, env, driver);
      device->setEventReceiver(&receiver);
    

* 12.TerrainRendering

terrain render

  • Create terrain

    scene::ITerrainSceneNode* terrain = smgr->addTerrainSceneNode(
      	"../../media/terrain-heightmap.bmp",
      	0,					// parent node
      	-1,					// node id
      	core::vector3df(0.f, 0.f, 0.f),		// position
      	core::vector3df(0.f, 0.f, 0.f),		// rotation
      	core::vector3df(40.f, 4.4f, 40.f),	// scale
      	video::SColor ( 255, 255, 255, 255 ),	// vertexColor
      	5,					// maxLOD
      	scene::ETPS_17,				// patchSize
      	4					// smoothFactor
      	);
    
  • Create / set terrain triangle selector

    	scene::ITriangleSelector* selector
      	= smgr->createTerrainTriangleSelector(terrain, 0);
      terrain->setTriangleSelector(selector);
    
  • Create a dynamic mesh and get the mesh of terrain LOD 0

    	scene::CDynamicMeshBuffer* buffer = new scene::CDynamicMeshBuffer(video::EVT_2TCOORDS, video::EIT_16BIT);
      terrain->getMeshBufferForLOD(*buffer, 0);
      video::S3DVertex2TCoords* data = (video::S3DVertex2TCoords*)buffer->getVertexBuffer().getData();
      // Work on data or get the IndexBuffer with a similar call.
      buffer->drop(); // When done drop the buffer again.
    
  • Add dome sky box

    	scene::ISceneNode* skydome=smgr->addSkyDomeSceneNode(driver->getTexture("../../media/skydome.jpg"),16,8,0.95f,2.0f);
    
    

* 13.RenderToTexture

Render to texture

  • Create a render target texture

    rt = driver->addRenderTargetTexture(core::dimension2d<u32>(256,256), "RTT1");
    
  • Set render target texture

    driver->setRenderTarget(rt, true, true, video::SColor(0,0,0,255));
    driver->setRenderTarget(0, true, true, 0);// Set default RTT
    
  • Set active camera

    smgr->setActiveCamera(fpsCamera);
    

* 14.Win32Window

Win32 multi window program

This is nothing to look at. It belongs to windows programming
Through the created HWND window handle, specify the windowID to specify which window to render to.

* 15.LoadIrrFile

  • Load scene from. irr file
    smgr->loadScene("../../media/example.irr");
    

* 16.Quake3MapShader

Import Quake 3 map

* 17.HelloWorld_Mobile

windows mobile

* 18.SplitScreen

Split screen

		if (SplitScreen)
		{
			//Activate camera1
			smgr->setActiveCamera(camera[0]);
			//Set viewpoint to the first quarter (left top)
			driver->setViewPort(rect<s32>(0,0,ResX/2,ResY/2));
			//Draw scene
			smgr->drawAll();
			//Activate camera2
			smgr->setActiveCamera(camera[1]);
			//Set viewpoint to the second quarter (right top)
			driver->setViewPort(rect<s32>(ResX/2,0,ResX,ResY/2));
			//Draw scene
			smgr->drawAll();
			//Activate camera3
			smgr->setActiveCamera(camera[2]);
			//Set viewpoint to the third quarter (left bottom)
			driver->setViewPort(rect<s32>(0,ResY/2,ResX/2,ResY));
			//Draw scene
			smgr->drawAll();
			//Set viewport the last quarter (right bottom)
			driver->setViewPort(rect<s32>(ResX/2,ResY/2,ResX,ResY));
		}
		//Activate camera4
		smgr->setActiveCamera(camera[3]);
		//Draw scene
		smgr->drawAll();

Create 4 cameras. When rendering, turn on each camera separately, specify a viewport, and then render all scenes

* 19.MouseAndJoystick

Mouse and joystick

It is obtained through onevent (const seven & event) of IEventReceiver

* 20.ManagedLights

Light management

  • Setting up the lighting Manager
    smgr->setLightManager(0);
    

Overload ieventreceiver:: OnPreRender (Core:: arrayscene:: iscenenode * & lightlist)

All lighting information can be obtained and modified at each rendering stage

* 21.Quake3Explorer

Show me how to import different Quake 3 maps

  • Load the BSP archive at run time from the menu

  • Load the map from the menu. Display screenshot

    screenshot

    Device->getVideoDriver()->createScreenShot();
    
  • Set the runtime video driver from the menu

  • Adjust gamma level at runtime

    Device->setGammaRamp
    
  • Create scene nodes for shaders

  • Load the EntityList and create an entity scene node

  • Create players with weapons and collision reactions

  • Play music

    Irrklang required: https://www.ambiera.com/irrklang/

* 22.MaterialViewer

Material settings and view the results. Only default non shader materials are used.

* 23.SMeshHandling

Create a custom Mesh

* 24.CursorControl

Cursor control

  • Set icon
    Device->getCursorControl()->changeIcon(...)
    Device->getCursorControl()->setActiveIcon( ECURSOR_ICON);
    

* 25.XmlHandling

XML file reading and writing

* 26.OcclusionQuery

Use occlusion query to speed up rendering

  • Occlusion query function
    driver->addOcclusionQuery(node, mesh); // Add occlusion query
    
    driver->runAllOcclusionQueries(false); // Run occlusion query
    driver->updateAllOcclusionQueries(); // Update status
    nodeVisible=driver->getOcclusionQueryResult(node)>0; // Get results
    

* Demo

* FontTool

Only ascii is supported

* GUIEditor

gui editor

Keywords: Computer Graphics

Added by pvraja on Sat, 27 Nov 2021 22:09:38 +0200