Banks to hold entities memory locations

Blitz3D Forums/Blitz3D Programming/Banks to hold entities memory locations

aab(Posted 2004) [#1]
Could i use Banks to store the memory location (ie: the value of the 'entity handle') in, and then equate a variable to that banks value at that point (changing where it reads oiver time to effect different meshes) so that i can affect a different mesh by reading that variable to different stored 'entity handles'?

i'd be reading ints, right?

;-------
i dont think i phrased that very well: Basically, could i write a memory location for an entity, into a bank as an int, and then read it out in a variable, and use that variable as the entity handle.
(it can be done with images i think)


N(Posted 2004) [#2]
Yes.


aab(Posted 2004) [#3]
Thanks
-im a 3d noob and i didnt want to spend time replacing the local arrays i've set up unless i knew it should work.


Techlord(Posted 2004) [#4]
Type bank
	Field pointer%,bank%
End Type

Function bankCreate.bank(size%)
	this.bank= New bank
	this\bank%=CreateBank(size%*4)
	Return this
End Function

Function bankResize(this.bank,size%)
	ResizeBank this\bank%,size%
End Function

Function bankPush%(this.bank,value%)
	PokeInt(this\bank%,this\pointer%,value%)
	this\pointer%=this\pointer%+4
End Function

Function bankPop%(this.bank)
	this\pointer%=this\pointer%-4
	Return PeekInt(this\bank%,this\pointer%)
End Function

;Uses
mybank.bank=bankCreate(NumberOfEntities)
entity%=CreateCube()
bankPush(mybank,entity%) ;<-- put entity on bank stack
entity%=bankPop(mybank)  ;<-- get entity off bank stack
bankResize(mybank,LargerNumberOfEntities)



aab(Posted 2004) [#5]
Thanks-should be much faster than using arrays


Techlord(Posted 2004) [#6]
Thanks-should be much faster than using arrays


Not necessarily.


aab(Posted 2004) [#7]
faster access is what i meant, and what i was looking for