Design your own 3D image engine (4): Wuguiengine model, special effects, texturing

Source: Internet
Author: User
Tags resource

1. Foreword

Say that there is a period of time has not been updated, this period of time to play a bit, but also to write a point of the program, the octree scene management wrote, but also optimized a little resources loaded some content. It's not clear how much of DirectX has been done before, and there's at least a lot more to know about these places. Send out today's finished octree scene management, inside the model with the DirectX sample Tiger, here is not very clear--;

 

Today I'm going to talk about the models, effects, and textures of my engine, at least make the most of the meaning. If there is no understanding of where to contact me.

2. Model, special effects, mapping of resource reuse

We can also see that the above picture of the tiger more than one, when the number of the same model to a certain extent (for example, 10,000), it is necessary to consider a certain optimization, if every time innocently from the file to read out the model, save for a ID3DXMesh, That is not only slow loading time is unbearable, but also the memory consumption is huge. In Wuguiengine, I used a simpler way to solve this problem.

The central idea of design mode is to modify the closed, open to expand, central idea is "change", but very embarrassed to say, I d3d, in many times not even clear "change" will appear in where, so I use the method, very simple, now use it very clear, However, if the subsequent extension support is not good or there is a better architectural approach is also looking for guidance. The purpose of this series of articles is to initiate a novel.

I used a simple map to do these things. The definition of Resource Manager (ResourceManager) is given below

1:class graphicsdevice
2:
3://resource type
4:enum resourcetype
5: {
6:rttexture = 0,
7: Rtmesh = 1,
8:rteffect = 2,
9:};
Ten:
11://Description of a resource
12://PreSource by pointer of type resourcetype,void*, reference us Ecount consists of
13:typedef struct Structres
: {
15:public:
16:structres (void* pRes, resourcetype type)
{
18:presource = pRes
19:usecount = 1;
20:resourcetype = type;
:}
22:re SourceType ResourceType;
23:void* PreSource;
24:int Usecount; 
25:} Structres;
:
27://Resource Manager
28:class ResourceManager
: {
30:public:
31:static resourcemanager* Getinst Ance ();
:
33://Get resource file based on filename
34:void* getd3dresource (string filename,
35:graphicsdevice* pdevice,
36:resourcetype type);
38://Uninstall resource file based on filename
39:void disposed3dresource (string filename);
40:protected:
41:resource Manager ();
42:
43:map<string, structres*> resourcetable
44:static resourcemanager* pinstance;
:};

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.