Static types and Pointers
BlitzMax Forums/BlitzMax Beginners Area/Static types and Pointers
| ||
I've written my .X importer proggie, but I've comeup with a few problems I could do with a hand with. 1) At the mo I hold all the shape data in a static type: Type obj_data Global num_of_verts:Int Global num_of_faces:Int Field face1:Int[80] Field face2:Int[80] Field face3:Int[80] Field vertx:Float[50] Field verty:Float[50] Field vertz:Float[50] End Type Which of course is fine as long as it isnt a big object.. But, is it possible to use variable allocated space - when I read the file and find out the number of arrays I need to hold the data, can these be allocated/increased at runtime ?. 2) How can I pass a pointer to the object type, over to the function ? At the mo its hard coded - so it knows what object type to use. Some advice please ;) |
| ||
1) You can increase the size of all your arrays as you need to. 2) You can pass it like this: Function Blah(thing:Object) Not sure why you want to. |
| ||
ok.. I got the type passing to function thingy working, but can you give me a clue as to what commands I need to lookup for the extended allocating types stuff. I know I can use: Field vertx:Int[] to make the template type, but how I'd then suddenly say I want to have space for 80 vertx coords - once its allocated ???. |
| ||
I think you can just use:teapot:obj_data = new obj_data teapot.vertx = new int[80] ...or... teapot.vertx = teapot.vertx[..80] - use this to 're-dim' the array tooYou could also use a 'new' method or a 'create' function to do this as well. |
| ||
Or also look here : http://www.blitzbasic.com/Community/posts.php?topic=42756 |
| ||
Did the trick ! - Thankyou. |