Reader small image

You're reading from  Game Physics Cookbook

Product typeBook
Published inMar 2017
Reading LevelIntermediate
PublisherPackt
ISBN-139781787123663
Edition1st Edition
Languages
Tools
Concepts
Right arrow
Author (1)
Gabor Szauer
Gabor Szauer
author image
Gabor Szauer

Gabor Szauer has been making games since 2010. He graduated from Full Sail University in 2010 with a bachelor's degree in game development. Gabor maintains an active Twitter presence, and maintains a programming-oriented game development blog. Gabor's previously published books are Game Physics Programming Cookbook and Lua Quick Start Guide, both published by Packt.
Read more about Gabor Szauer

Right arrow

Physics System Modification


In the last section of this chapter, we will build a stable Cloth class. This class contains a set of particles and three spring systems. For the cloth to actually work, we have to call its physics simulation functions every frame. In this section, we will add cloth support to the PhysicsSystem.

Getting ready

In this section, we will make several modifications to the PhysicsSystem class to add support for cloth simulation.

How to do it…

Perform the following steps to add cloth support to our physics system:

  1. Include the Cloth.h header file in PhysicsSystem.h. Add a vector of Cloth pointers to the PhysicsSystem class. Add a function to register a new cloth into the vector and a function to clear the vector:

    // Start of file unchanced
    #include "Cloth.h"
    
    class PhysicsSystem {
    protected:
        // Previous member variable declarations unchanged
        std::vector<Cloth*> cloths;
    public:
        // Previous member functions unchanged
        void AddCloth(Cloth* cloth);
        void...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Game Physics Cookbook
Published in: Mar 2017Publisher: PacktISBN-13: 9781787123663

Author (1)

author image
Gabor Szauer

Gabor Szauer has been making games since 2010. He graduated from Full Sail University in 2010 with a bachelor's degree in game development. Gabor maintains an active Twitter presence, and maintains a programming-oriented game development blog. Gabor's previously published books are Game Physics Programming Cookbook and Lua Quick Start Guide, both published by Packt.
Read more about Gabor Szauer