Thread: Really Hope I'm not Overposting (Object passing)

  1. #1
    Absent Minded Programmer
    Join Date
    May 2005
    Posts
    968

    Really Hope I'm not Overposting (Object passing) (RESOLVED)

    So heres my World Class in .CPP Form

    Code:
    #include "World.h"
    
    std::vector<Object*> Scene_Objects;
    std::vector<Object*>::iterator Iter;
    
    
    void World::AddObjectToWorld()
    {
    	Scene_Objects.push_back(new Object);
    }
    
    void World::RemoveObjectFromWorld()
    {
    	for (Iter = Scene_Objects.begin(); Iter!=Scene_Objects.end();)
    {
        if ((*Iter)->MarkedForDeletion)
        {
            delete *Iter;
            Iter = Scene_Objects.erase(Iter);
        }
        else
        {
            ++Iter;
        }
    }
    
    };
    
    void World::RemoveAllObjectsFromWorld()
    {
    	for ( size_t i = 0; i < Scene_Objects.size( ); ++i )
    	{ 
    		delete Scene_Objects[i];
    		Scene_Objects.clear();
    	}
    };
    Just a couple functions to manage my Scene_Objects vector, (which will ultimately be sent to the render for final rendering)

    Here is my Object Class, its quite simple, but It needs something else, I'm quite sure of it...

    Code:
    #include "MS3D.h"
    
    #ifndef OBJECT_H
    #define OBJECT_H
    
    class Object
    {
    public:
    
    	bool MarkedForDeletion;
    
    	struct Location
    	{
    		float locx;
    		float locy;
    		float locz;
    	};
    
    };
    #endif
    And here is the final object (inherits the object class)

    Code:
    #ifndef C_CROSS_H
    #define C_CROSS_H
    
    
    #include "Object.h"
    
    class Cross : public Object
    {
    public:
    
    	MS3DModel *Model1;
    
    };
    
    #endif
    Now, back up there in the um, World class, I have an AddObjectToScene function, that creates a new object, is there any way I can set Cross = to Object, or do I have to switch a few parameters to make this work?
    Last edited by Shamino; 12-14-2005 at 08:35 PM.
    Sometimes I forget what I am doing when I enter a room, actually, quite often.

  2. #2
    Absent Minded Programmer
    Join Date
    May 2005
    Posts
    968
    Sometimes I forget what I am doing when I enter a room, actually, quite often.

  3. #3

    Join Date
    May 2005
    Posts
    1,042
    no offense but then stop posting here.

    I have a job.
    I'm not immature, I'm refined in the opposite direction.

  4. #4
    Absent Minded Programmer
    Join Date
    May 2005
    Posts
    968
    I didn't mean any harsh words, and I definately wasn't downing on you guys for being slow.
    Sometimes I forget what I am doing when I enter a room, actually, quite often.

  5. #5
    ---
    Join Date
    May 2004
    Posts
    1,379
    Before you came this forum was really quiet

  6. #6
    Absent Minded Programmer
    Join Date
    May 2005
    Posts
    968
    Well then I'll view myself as doing a good deed to these forums!
    Sometimes I forget what I am doing when I enter a room, actually, quite often.

  7. #7

    Join Date
    May 2005
    Posts
    1,042
    I said no offense because I didn't mean any, but it seems silly to post here a lot and in every single post say 'gamedev beat you to it!.' Be pragmatic and just post at gamedev.
    I'm not immature, I'm refined in the opposite direction.

  8. #8
    Absent Minded Programmer
    Join Date
    May 2005
    Posts
    968
    If it makes you feel better I'll just say "Resolved" instead of being comedic about it.....
    Sometimes I forget what I am doing when I enter a room, actually, quite often.

  9. #9
    ---
    Join Date
    May 2004
    Posts
    1,379
    Gamedev is quick because the amount of online users is HUGE

  10. #10
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Really Hope I'm not Overposting (Object passing) (RESOLVED)
    You are.


    You've gotten to the point in your research that we probably can no longer help you with specifics w/o knowing the underlying implementation.

    It's good that you are researching and so far it shows quite well. However you must remember the methods you see on the internet are just that, methods on the internet that worked well for one person. Very soon you will derive your own methods from those.

    My method is different from Bob's method and his mine. However they both solve the same problem so neither one is better or worse, right or wrong. Resource management is probably the most important part of game programming and thousands and thousands of noobs simply overlook it, as well as some game companies much to their chagrin.

    Good research, good enthusiasm, keep it up.
    Last edited by VirtualAce; 12-15-2005 at 11:56 PM.

  11. #11
    Absent Minded Programmer
    Join Date
    May 2005
    Posts
    968
    Well thanks Bubba, it really means alot
    Sometimes I forget what I am doing when I enter a room, actually, quite often.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Passing an array of a class object into a function
    By maoqiu in forum C++ Programming
    Replies: 3
    Last Post: 10-25-2007, 08:42 AM
  2. Creating a database
    By Shamino in forum Game Programming
    Replies: 19
    Last Post: 06-10-2007, 01:09 PM
  3. Finding object code
    By kidburla in forum C Programming
    Replies: 3
    Last Post: 11-29-2005, 01:09 PM
  4. const at the end of a sub routine?
    By Kleid-0 in forum C++ Programming
    Replies: 14
    Last Post: 10-23-2005, 06:44 PM
  5. Object Arrays and Inheritance
    By AceHigh in forum C++ Programming
    Replies: 7
    Last Post: 07-28-2002, 04:08 AM