03-09-2005, 08:47 AM
So, I could do it like this?
Then when I want to use the new array in a sub...
Does that look right?
EDIT:
Ok, that seems to work good, but what about these?
How do I allocate a matrix in this method?
Would I just do something like this?
Then....
It's kinda hard to get used to... Is it even right?
Code:
Type ObjType
Num_Surfaces as Integer
Start_Id as Integer ptr
End_Id as Integer ptr
Surface_Id as Integer ptr
End Type
Dim Entity(1 to Total_Entities) as ObjType
Sub LoadOBJ(Entity as ObjType)
'Get Entity.Num_Surfaces from file...
Entity.Start_Id=Callocate(Entity.Num_Surfaces*Len(Entity.Start_Id))
End Sub
Then when I want to use the new array in a sub...
Code:
Sub Draw_Entity( Entity as ObjType)
For S = 1 to Entity.Num_Surfaces
For P = Entity.Start_Id[S] to Entity.End_Id[S]
Next
Next
End Sub
Does that look right?
EDIT:
Ok, that seems to work good, but what about these?
Code:
RGBA(1 to 50, 3) as Single ''heh oops!
Ambient(1 to 50, 3) as Single
Diffuse(1 to 50, 3) as Single
Specular(1 to 50, 3) as Single
Emission(1 to 50, 3) as Single
How do I allocate a matrix in this method?
Would I just do something like this?
Code:
Type Surface_Properties_Type
RGBA(3) as Single ''heh oops!
Ambient(3) as Single
Diffuse(3) as Single
Specular(3) as Single
Emission(3) as Single
End Type
Type ObjType
Num_Surfaces as Integer
Start_Id as Integer ptr
End_Id as Integer ptr
Surface_Id as Integer ptr
Surface_Properties as Surface_Properties_Type ptr
End Type
Dim Entity(1 to Total_Entities) as ObjType
Then....
Code:
Some_Sub(Entity as ObjType)
Entity.Surface_Properties = Callocate(Entity.Num_Surfaces*Len(Entity.Surface_Properties))
End Sub
Some_Other_Sub(Entity as ObjType)
Entity.Surface_Properties[S].RGBA(1) = 'Get From File
End Sub
It's kinda hard to get used to... Is it even right?