Thread: simple struct pointing

  1. #1
    Registered User
    Join Date
    Feb 2008

    simple struct pointing


    This is for a 3d engine, my skills as C coder is abit limited since there has been so many years since my last encounter with C, only oo languages.

    I got one struct called Object, this contains x-numbers of 3d objects, i need to seperate this, so i can have a struct called 'scene', which will be a list of all objects, point is, i need it to be something like this,
    scene contains obj[1-x], so a scene i defined, and i dont need to remember how many objects there are in one scene when rendering differnet scenes.

    any suggestions? a pointer from one struct to anohter? an example would be very appriciated! =)


  2. #2
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    > a pointer from one struct to anohter?
    A linked list? Could be 'slow', if you want to render in real-time that is.

    Perhaps: An array of objects, or a stack. Take your pick: For example, you might want a scene with an array of pointers to objects, that way you can use the same object in several scenes and save memory.

  3. #3
    Registered User slingerland3g's Avatar
    Join Date
    Jan 2008
    I believe that a struct called Scene that contained a structure Objects array, like so:

    typedef struct x-numbers {
             int number;
    } Objects;
    typdef struct 3d_objects {
         struct Objects [];
    } Scene;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Looking for constructive criticism
    By wd_kendrick in forum C Programming
    Replies: 16
    Last Post: 05-28-2008, 09:42 AM
  2. newbie needs help with code
    By compudude86 in forum C Programming
    Replies: 6
    Last Post: 07-23-2006, 08:54 PM
  3. Help please im stuck
    By ItsMeHere in forum C Programming
    Replies: 7
    Last Post: 06-15-2006, 04:07 AM
  4. Bi-Directional Linked Lists
    By Thantos in forum C Programming
    Replies: 6
    Last Post: 12-11-2003, 10:24 AM
  5. Replies: 5
    Last Post: 02-01-2003, 10:58 AM