simple struct pointing

This is a discussion on simple struct pointing within the C Programming forums, part of the General Programming Boards category; Hi! This is for a 3d engine, my skills as C coder is abit limited since there has been so ...

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    5

    simple struct pointing

    Hi!

    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! =)

    -Seid.

  2. #2
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    > 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: http://www.nist.gov/dads/ 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
    Location
    Seattle
    Posts
    603
    I believe that a struct called Scene that contained a structure Objects array, like so:

    Code:
    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, 10:42 AM
  2. newbie needs help with code
    By compudude86 in forum C Programming
    Replies: 6
    Last Post: 07-23-2006, 09:54 PM
  3. Help please im stuck
    By ItsMeHere in forum C Programming
    Replies: 7
    Last Post: 06-15-2006, 05: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21