Thread: So now...

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Absent Minded Programmer
    Join Date
    May 2005
    Posts
    968
    Well, we're using inheritence hardcore throughout the project, we havn't found any uses for a virtual function though in defining our objects.. Yes all Mobiles->Objects have a speed, but those are variables, not functions, right?
    Sometimes I forget what I am doing when I enter a room, actually, quite often.

  2. #2
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034
    Quote Originally Posted by Shamino
    Well, we're using inheritence hardcore throughout the project, we havn't found any uses for a virtual function though in defining our objects.. Yes all Mobiles->Objects have a speed, but those are variables, not functions, right?
    I'm having a hard time thinking of when it would be necessary too. I haven't gotten into engine design yet so its hard to think. I'm sure all of you know what I'm talking about below, and even see how incorrect it is - which is sort of why I'm posting it. Sorry if this is a highjack, I'd like to know more about how to go about this. Its easier getting answers from gurus when you post a bunch of guesswork.

    Without a virtual function you wouldn't be able to access Object->Mobile.speed from say AddObjectsToRenderer(), because it takes Objects (for generics). Unless of course it was Object.speed, which would be pointless in design and inefficient space-wise. Then again you probably wouldn't need to access Object->Mobile.speed anyway, but Object.x/y/zCoord (normal accessor method) you would - which would have to be protected or public (for derived classes), so that doesn't even matter. Other Render methods or functions in the engine might really need that ability though. Which would mean virtual functions or possibly delegation (adds complexity) in the Ship/etc. mobiles would be useful?

    I guess if you wanted everything pointing to Ship1 to point to Jeep2 instead, it would be easier to do using an abstract (pure virtual) class. Simply changing the object of the abstract class to point to (a derived from) a Jeep2 object instead of a Ship1 object. Of course you could use a visitor design instead, or possibly void pointers.
    Warning: Have doubt in anything I post.

    GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101

  3. #3
    Absent Minded Programmer
    Join Date
    May 2005
    Posts
    968
    Ultimately what the grand scheme of things I'm trying to accomplish is this


    Objects (contains a location xyz)
    Mobiles (inherits objects, Contains physics variables common to all mobiles)
    Statics (inherits objects, more of a dummy object, doesn't move under its own power){

    Cross(inherits Mobiles, which inherits objects, holds a pointer to a model, simply put, might perform some function that will be figured out later)

    I'll take cross, and dynamically allocate it somewhere, so we can have multiple cross objects on the screen, if the user demands another cross is built, so be it, another cross is dynamically allocated..

    I don't see a use for virtual functions yet..

    I'll have a world class that determines what needs to be drawn in the world, where, when, and why...

    World sends this information to a function in the render engine that dynamically allocates all objects that world says is needed on the screen, (there will be like, an update function in Cworld, that determines what is drawn and what isnt, where, when, and why)

    which is sent to the draw function, bam, one call, whole scene is drawn..

    That is my grand master plan, it probably is stupid and buggy though...


    /////////////////////////////////////////////////////////////////////////////

    I really misunderstand what you're saying Dae, could you please try to clear it up?

    I know a few things, We will never need to access Object->x,y,z

    Inheritence makes it so we need to access Ship1->x,y,z

    I don't see why these objects would ever become unavailable for direct access like that..
    Last edited by Shamino; 12-13-2005 at 10:06 PM.
    Sometimes I forget what I am doing when I enter a room, actually, quite often.

  4. #4
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034
    Quote Originally Posted by Shamino
    I really misunderstand what you're saying Dae, could you please try to clear it up?
    Sorry if I was confusing because I'm sure you already know this.

    I know a few things, We will never need to access Object->x,y,z
    How exactly do you plan to have a Render function accepting generic Objects that can access x,y,z? Even though Ship1 derives from Object you need to have the variables/functions in the Object class, or use virtual functions to go down the heirarchy to the derived class (the one you're passing).

    I don't see why these objects would ever become unavailable for direct access like that..
    If you're making a vector of Object's for your Render class, then you would need to access Object->x,y,z. Of course Ship1 inherits that from Object if x,y,z are protected or public. If they weren't in Object, and were in Ship1, then you would not be able to access them unless you changed your Render function to accept Ship1's and not Object's.

    Inheritence makes it so we need to access Ship1->x,y,z
    You *could* access x,y,z through Ship1 because its inherits from Object and are actually stored there and could be accessed from there too (obviously).

    I don't know if I'm wrong - I could be and it wouldn't be the first time. I just wanted to get more ideas out of you guys.
    Warning: Have doubt in anything I post.

    GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101

Popular pages Recent additions subscribe to a feed