Interface InstanceRenderAPI
- All Known Implementing Classes:
AreaLight,BaseIlluminantData,BaseInstanceRenderData,BaseMIRenderData,CommonEntity,CurveEntity,DistortionEntity,FlareEntity,InfiniteLight,LinearLight,PointLight,SpotLight,SpriteEntity
-
Method Summary
Modifier and TypeMethodDescriptionbyteaddInstanceData(InstanceDataAPI instanceData) Have size limitBoxConfigs.getMaxInstanceDataSize().voidcallRefreshInstanceData(boolean refresh) When changed the instance data(Not fixed instance data), call it.voidcopyInstanceTimerOverride(InstanceRenderAPI renderData) intintintfloatintintintbooleanbooleanbooleanDefault value isfalse.booleanvoidmallocInstance(InstanceType target, int dataNum) Make sure call it before callsubmitInstance()when without valid memory.voidWhen call it, will reset data and delete related objects.voidvoidresetMemory(MemoryBlock memory) Equivalent to:voidsetAlwaysRefreshInstanceData(boolean refresh) bytesetInstanceData(List<InstanceDataAPI> instanceData) For rendering a lots of entities (such as 10k+ entities) at once.bytesetInstanceData(List<InstanceDataAPI> instanceData, float fadeIn, float full, float fadeOut) Reset global timer by manual.voidvoidsetInstanceDataRefreshIndex(int index) voidsetInstanceDataRefreshOffset(int targetIndex) voidsetInstanceDataRefreshSize(int size) voidsetInstanceTimerOverride(float alpha, byte state) Override timer of all in-vRAM instance data to this value.voidsetMappingInstanceSubmit(boolean mappingMode) NOTE: Ineffective if device was OpenGL 4.4+ supported, will force updating to persistent mapping buffer.voidvoidsetRenderingCount(int num) voidsetRenderingOffset(int index) Should reset the rendering count after that.voidsetSharedInstanceData(InstanceRenderAPI renderData) Will always computes once for the same memory range.voidUse it when you changed the instance data.
-
Method Details
-
resetInstanceData
void resetInstanceData()When call it, will reset data and delete related objects.A.K.A.
free()for instance data resources. -
getInstanceData
List<InstanceDataAPI> getInstanceData() -
setInstanceData
For rendering a lots of entities (such as 10k+ entities) at once.For all render objects, location/facing/size/color/emissive/alpha data all form
InstanceDataAPI, and overlay toRenderDataAPIimplements.Render count decided by
List.size().Have size limit, pick smallest from
BoxConfigs.getMaxInstanceDataSize().This entity attribute,
MaterialData.getColor()andMaterialData.getEmissiveColor()both apply to each instance when rendering.For model matrix, each instance is also derived from this entity.
- Parameters:
instanceData- set to 'null' or empty 'List' -> clear, or a 'List' what isn't empty.- Returns:
- returns
BoxEnum.STATE_SUCCESSwhen success, returnBoxEnum.STATE_SUCCESSwhen null list that set to empty list.
-
setInstanceData
byte setInstanceData(@Nullable List<InstanceDataAPI> instanceData, float fadeIn, float full, float fadeOut) Reset global timer by manual.Similar to
setInstanceData(List).- Returns:
- returns
BoxEnum.STATE_SUCCESSwhen success, returnBoxEnum.STATE_FAILEDwhen over limit.
-
addInstanceData
Have size limitBoxConfigs.getMaxInstanceDataSize().- Returns:
- returns
BoxEnum.STATE_SUCCESSwhen success, returnBoxEnum.STATE_FAILEDwhen over limit, returnBoxEnum.STATE_FAILED_OTHERwhen added a null object.
-
isMappingInstanceSubmit
boolean isMappingInstanceSubmit()Default value isfalse. -
setMappingInstanceSubmit
void setMappingInstanceSubmit(boolean mappingMode) NOTE: Ineffective if device was OpenGL 4.4+ supported, will force updating to persistent mapping buffer.For some very slight data, use
glBufferSubData()may faster.Besides, some devices(some ARM SoC) may slower with
glMapBufferRange(), decided by the drive how implements it.- Parameters:
mappingMode- to controls whether submit useglMapBufferRange(), else useglBufferSubData().
-
submitInstance
void submitInstance()Use it when you changed the instance data.Should have reserved size for it, memory expand is an expensive operation.
Make sure has call
mallocInstance(InstanceType, int)when without valid memory. -
mallocInstance
Make sure call it before callsubmitInstance()when without valid memory. -
isNeedRefreshInstanceData
boolean isNeedRefreshInstanceData() -
isAlwaysRefreshInstanceData
boolean isAlwaysRefreshInstanceData() -
callRefreshInstanceData
void callRefreshInstanceData(boolean refresh) When changed the instance data(Not fixed instance data), call it. -
setAlwaysRefreshInstanceData
void setAlwaysRefreshInstanceData(boolean refresh) -
haveValidInstanceData
boolean haveValidInstanceData() -
getValidInstanceDataCount
int getValidInstanceDataCount() -
getInstanceDataRefreshIndex
int getInstanceDataRefreshIndex() -
getInstanceDataRefreshOffset
int getInstanceDataRefreshOffset() -
getInstanceDataRefreshSize
int getInstanceDataRefreshSize() -
setInstanceDataRefreshIndex
void setInstanceDataRefreshIndex(int index) - Parameters:
index- will refresh instance data start from this index.
-
setInstanceDataRefreshOffset
void setInstanceDataRefreshOffset(int targetIndex) - Parameters:
targetIndex- will refresh instance data to instance data index of memory.
-
setInstanceDataRefreshSize
void setInstanceDataRefreshSize(int size) - Parameters:
size- Will refresh instance data count.
-
setInstanceDataRefreshAllFromCurrentIndex
void setInstanceDataRefreshAllFromCurrentIndex() -
getRenderingCount
int getRenderingCount() -
setRenderingCount
void setRenderingCount(int num) -
getRenderingOffset
int getRenderingOffset() -
setRenderingOffset
void setRenderingOffset(int index) Should reset the rendering count after that. -
setRenderingAllInstanceFromCurrentOffset
void setRenderingAllInstanceFromCurrentOffset() -
getInstanceDataMemory
MemoryBlock getInstanceDataMemory() -
resetMemory
Equivalent to:MemoryBlock old_mem = this->memory; if (old_mem) free(old_mem); this->memory = new_mem; -
resetMemory
void resetMemory() -
getInstanceTimerOverride
float getInstanceTimerOverride() -
setInstanceTimerOverride
void setInstanceTimerOverride(float alpha, byte state) Override timer of all in-vRAM instance data to this value.- Parameters:
alpha- set less than 0 to disable override.state- valid state:BoxEnum.TIMER_IN,BoxEnum.TIMER_FULL,BoxEnum.TIMER_OUT.
-
copyInstanceTimerOverride
-