I'm having a headache with types and functions. I've two types, one referencing the other
How can I work my functions to create the necessary objects in a function and return them into the array of objects with all sub-objects intact?
Type material Field index Field density# Field friction# Field restitution# End Type Type ODE_object Field body Field geom Field mesh Field mat.material End TypeI've an array of ODE_objects...
Dim objects.ODE_object(200) For n=0 To 200 objects(n) = New ODE_object NextAnd I've functions to fill them...
Function create_Box.ODE_object(x_pos, y_pos, z_pos, width, length, depth, x_rot, y_rot, z_rot) obj.ODE_object = New ODE_object obj\mat.material = New material blah blah Return obj End Function Function set_material(obj.ODE_object,m.material) obj\mat\index = m\index obj\mat\friction = m\friction obj\mat\density = m\density obj\mat\restitution = m\restitution End FunctionTrouble is when I try to reference objects(n)\mat I'm told the object doesnt exist (in this example at the statement i=objects(n)\mat\index)...
set_material(objects(n),mat_ice) objects(n)=create_Box(Rnd(-40,40),100+Rnd(0,600),Rnd(-40,40), x,y,z, Rnd(-30,30),Rnd(-30,30),Rnd(-30,30)) i = objects(n)\mat\indexAnd if I create the object.mat object when I create the object.ODE_object, it still doesn't work because it gets overwritten when I return the ODE_object from the creation function.
How can I work my functions to create the necessary objects in a function and return them into the array of objects with all sub-objects intact?