If delta3d is used, it may take some time (a month ?) The project does not need to be completed in a rush, but the result is more and more lazy. During the project, we found that the delta3d system was too large, such as OSG, Ode, cal3d, and cegui... All of them are together. Coupled with the fact that we were not engaged in graphics in the past, the core component was useless and crashed ing. Er, since I am an idiot in graphics, I want to learn from the overall architecture of delta3d instead of the OSG implementation. By the way, you can use this time to complete the basic knowledge of the form, from the abstraction layer and the bottom layer.
Nothing to talk about, everything starts from the source-the source of most delta3d sins dtcore: Base
There are already articles on the analysis of the base class. People like me should have read this article, but let's just talk about it first.
Dtcore: some base Interfaces
Class dt_core_export base: Public sigslot: has_slots <>, public OSG: referenced <br/>{< br/> declare_management_layer (base) <br/> public: <br/> struct dt_core_export messagedata <br/> {<br/> STD: String message; <br/> base * sender; <br/> void * userdata; <br/>}; <br/> virtual void onmessage (messagedata *) {}; <br/> void addsender (base * sender ); <br/> void removesender (base * sender); <br/> void sendmessage (const STD: string & message = "", void * Data = 0 ); <br/> PRIVATE: <br/> sigslot: signal1 <messagedata *> msendmessage; <br/>}
Here we can see that base inherits from sigslot: has_slots <> and OSG: referenced. Where
OSG: referenced is used to implement the dtcore: refptr <t> smart pointer.
Sigslot: has_slots <> implements the most basic message mechanism (this is also from an open-source project on the Internet)
About Smart pointers and semaphores (delegate, message? A lot of names can be found on the Internet. If you have time, you can take a look at the boost library. The above implementation is simply abnormal. However, I feel that it is only used for internal message transmission, and the sigslot function is sufficient. In addition, because this class inherits from OSG: referenced, you can use the smart pointer dtcore: refptr to access it. If you have read the code, you may find that the base destructor is protected. Therefore, the delete operation cannot be performed on the object on the stack. You can only use refptr to delete the object.
Declare_management_layer (base)
This is a macro, which is widely used in management-level components of delta3d mainly for object management. For details, refer to the code. Each instance is registered to a static vector <base *> during initialization, and the object is found through the corresponding interface.
Void addsender (base * sender); void removesender (base * sender );
The preceding two interfaces are used to add and delete the senders of messages accepted by the class. It is actually an encapsulation of sig_slot and disconnect of signal in sigslot.
Virtual void onmessage (messagedata *){}
Use addsender to connect sendmessage of sender with onmessage (messagedata *) of this class. Finally
Void sendmessage (const STD: string & message = "", void * Data = 0 );
This is an interface for sending messages. In fact, the base sends the following struct, that is, the parameter in onmessage (messagedata.
Struct dt_core_export messagedata <br/>{< br/> STD: String message; <br/> base * sender; <br/> void * userdata; <br/> };
From the onmessage above, we can see that delta3d has specified that there is only one parameter in its internal transmission mechanism, so the above struct uses userdata to expand the data that can be passed. The message is used to determine the name of the transmitted message.
OK. This is the introduction to dtcore: base. I didn't talk too much about details. If you are interested, you can directly look at the code.
Recently, I suddenly felt that I had no physical strength to study all night and was depressed. The weather is so bad that I am so hot!