How to clear the 3d environment and start another
Blitz3D Forums/Blitz3D Beginners Area/How to clear the 3d environment and start another
| ||
I'm new to 3d and struggling with how to handle the logic for the next step past the most basic 3d stuff. An example - say I'm creating a racing game : I create a racing track mesh in some 3d program. In blitz3d I load my track mesh and my buildings, my cars, signposts etc,give them x,y,z coordinates and position the entities. Question 1) If you're modelling a large track, and there's lots of scenery changes etc, how do you handle loading the objects? I could create an array of types with coordinates and pointers to meshes etc but if I draw them straight away, the game will try to draw lots of objects simultaneously taking up heaps of memory, and trying to draw lots of things far out of visual range. My guess is that you'd do something similar to evaluating the distance from the player to every object each game loop, and if distance < certain value then draw it somehow. Assuming you take that approach, once you've drawn the object once, blitz will draw it automatically without you explicitly redrawing it every game loop - how do you then get rid of it? Question 2) There's the track and objects etc on the screen and the player is driving their car around. Now they're sick of it and want to go back to the menu. How would you do a rapid deletion of all the objects so UpdateWorld doesn't show them anymore? When you have a cube or two like the examples, you can easily have global pointers for each object and delete them by name - once you have tens or hundreds of objects, that approach won't work anymore (unless you want 5000000 unique global variables- and that's not sensible) Question 3) If your type (as described above) has fields like ObjectType (Car/boat/sign/plane etc) X Y Z Pointer_to_mesh How do you implement the pointer to mesh part of the type? I don't want individual meshes for each object of the same type, but if I copy the mesh it appears (from the doco) that changes to one entity will affect all the copies too. Thanks for your time Shane |
| ||
question 1.? question 2. you would use clearworld i think? then reload you menu. question 3 ? i have almost the same problems with my game. i would like to know if anyone can answer these questions too. Pete |
| ||
1. blitz handles drawing of entities, anything out of view is not drawn, anything out of camera range is not drawn etc 2.You canhave types which hold your 3d data eg type TCar field name$, id$ etc field mesh.TEntity end type type TEntity field ent field scaleX,scaleY,scaleZ etc end type then do a simple for ThisCar.TCar = each TCar if not ThisCar\mesh = null if ThisCar\mesh\ent freeentity ThisCar\mesh\ent endif delete ThisCar\mesh endif next This allows simple management of large amounts of objects. 3. You could have base entities and then copy them to the meshpointer eg type TBaseEntity field name$ field mesh% end type function Copy_BaseEntity(name$) for ThisBase.TBaseEntity = each TBaseEntity if ThisBase\name = name return copyentity(ThisBase\mesh) endif next end function You would create the base entities on startup of a map\level and then copy as needed. |
| ||
Great! Thanks very much people!!!! |
| ||
EntityAutoFade may also be useful for hiding distant objects. |