It is currently Sat Aug 19, 2017 4:22 am

All times are UTC - 5 hours




 Page 1 of 1 [ 4 posts ] 
Author Message
 Post subject: XML library
PostPosted: Tue Feb 13, 2007 7:01 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1105
Location: Ontario Canada
Tutorial showing how to create a vertex and triangle class. These two classes are used to render objects on the screen.


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 4 - Vertex and Triangle Classes
PostPosted: Tue Jun 19, 2007 12:26 am 

Joined: Tue May 01, 2007 2:55 pm
Posts: 96
Location: Behind you
In the triangle class you have three vertices as member variables, but often triangles often share their vertices,so I wonder, wouldn't it save space to have vertex pointers instead?



Of course this does need some extra programming skill later on... but I do not like to use more memory than necessary :D


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 4 - Vertex and Triangle Classes
PostPosted: Tue Jun 19, 2007 5:54 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1105
Location: Ontario Canada
Yes that is true. You will notice that we actually stop using the triangle class and delete it from the project a little later on in the video series. There is a far better way to handle 3D data by creating custom 3d objects (like the house) or by loading in 3d data from a modeling software package (like trueSpace).


Offline
 Profile  
 
 Post subject:
PostPosted: Sun Aug 24, 2008 5:16 am 

Joined: Wed Aug 06, 2008 7:53 pm
Posts: 182
Location: Russia
-- a general note: most of methods should be made inline, which give to comppiler an oportunity to incorporate their bodies just in the code from where they were called and not to spend CPU cycles on invocation. To inline a function its body must be placed in header file etc.
-- initialization to zero (in default ctor) is not to be always good. The reason is that you spend CPU time on initialization but most likely you will never use those default values. Besides, remember tempory objects issue. That's not my advice but what they say on MS GameDev conference.

class Vertex
{
public:
    Vertex() { }
    Vertex(float x_, float y_, float z_) : x(x_), y(y_), z(z_) { }
//  virtual ~Vertex() { }
public:
    float x, y, z;
};

class Triangle
{
public:
    Triangle(const Vertex & _1, const Vertex & _2, const Vertex & _3, float angle_)
    :   v1(_1), v2(_2), v3(_3), angle(angle_)
    { }

    // virtual ~Triangle() { }

    void Update(float angle_) { angle += angle_; }

public:
    Vertex v1, v2, v3;
    float angle;
};

:roll:


Offline
 Profile  
 
Display posts from previous:  Sort by  
 Page 1 of 1 [ 4 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  

cron