Welcome to Game 258 - Game Engines 4
ECS Entity Component System
- Topic 0: Templates in C++ and other tools
We'll do some experiments with C++ templates in this second demo.
TemplateDemo.zip
This a version of our real starting point
ComponentFramework24.0.0,
download it. We will start by incorporating the demo project into the FrameWork.
- Topic 1: The Entity (Actor or Component)
Using the Actor/Component demo code we created over the last one or two classes, begin inserting these ideas in to the framework - I will guide you, promise.
- Topic 2: The Components and Actors
Let's create some basic components and begin to flesh them out: TransformComponent, MeshComponent, Actor, and CameraActor.
- Topic 3: Using the Components
In this part we'll get and set data in and out of the added components.
- Topic 4: Using Components to render an Actor in 3D. (Finally some graphics)
Get Mario on the screen!
- Topic 5: Parenting objects
Once you have mario on the screen, I need you to make the following modification to the Actor class:
From here you could parent one actor to another. On the website I have a hammer.obj and a texture for it. Can you put
the hammer in Mario's hand and have it move with him?
-
Assignment 1: Feb 23
Making a Checkerboard with Checkers
- Topic 7: Better Memory Management - Smart Pointers
In this next section, I'll show you how smart pointers work, and in our current application, how shared_ptr can be helpful.
In this next section, we'll look at unique_ptr, weak_ptr, and why everything should at least be a shared_ptr.
- Topic 8: Better, better Memory Management - Applying smart pointers to the engine
Based on what we did last week or two, let's use the following code definition:
You'll need to #include header file at the top.
The best place to put this declaration is, near the top of Component.h
Next, we'll need to modifly the Actor.h file a bit to handle this new Ref() definition.
I can use the std::make_shared idea plus simplify the existing code to look like this:
Delete all the old AddComponent() stuff and add the new stuff to your project.
We will also need to write a overload the AddComponent() method to accept an already existing component.
This will be necessary for the implimentation of the asset manager. This overload will look very much like
the one listed above. The easiest approch is just to copy the original and make this simple modification.
Now you are going to need a new GetComponent as well
Now on to Actor.cpp, replace RemoveAllComponents() with
In GetModelMatrix() you will only need to change one line. This will be the first time you'll use
a Ref to a component.
Ref transform = GetComponent();
Get it?
-
Assignment 2: Switch from raw pointers to all Refs (shared_ptr)
-
Assignment 3: Build an Asset Manager
-
Assignment 4: Color Picking