FoliageCellItem
Package: Libraries.Game.Graphics.Worlds · Inherits from: Libraries.Interface.Item3D, Libraries.Interface.Item, Libraries.Language.Object
A FoliageCellItem draws the copies in one FoliageCell. It draws them all with one model that has copies (Model:SetCopies), so the renderer draws every copy in one instanced draw: the asset's model, or for a card asset, one upright two-sided picture, copied once per plane of each copy. A TerrainItem makes one per cell and holds them as children, hides the cells farther from the camera than their asset's draw distance or outside its view, and tells the shown ones how far away they are (UpdateForDistance), which picks the level of detail and thins the copies near the draw distance. Each model is a FoliageCellDrawing. Besides the level drawn, a cell may draw the next level for a growing share of its copies near that level's distance, so it changes a little at a time, and a simpler level only into the shadows in place of a detailed level's shadow. The item stands at the origin, so each copy's place is its world place. The model shares its file's blueprint, so the file is loaded once however many cells use it.
Example Code
use Libraries.Game.Graphics.Worlds.FoliageCellItem
use Libraries.Game.Graphics.Worlds.FoliageCell
use Libraries.Game.Graphics.Worlds.FoliageAsset
use Libraries.System.File
FoliageCell cell
cell:Set(0, 0, 0, 32)
cell:Add(4, 0, 6, 0, 1, 1)
FoliageAsset rock
rock:SetModelPath("Models/Rock.glb")
File modelFile
modelFile:SetPath("Models/Rock.glb")
FoliageCellItem item
item:Set(cell, rock, modelFile)
item:Build()
Actions
Build()
This action makes the item's models again from its cell's copies, after copies were added, removed or moved, or the asset changed. The old models are taken out and disposed.
Clear()
This action takes out and disposes the models.
GetAsset()
This action returns the cell's asset.
Returns
Libraries.Game.Graphics.Worlds.FoliageAsset: The asset.
GetCell()
This action returns the cell the item draws.
Returns
Libraries.Game.Graphics.Worlds.FoliageCell: The cell.
GetCellMiddleX()
This action returns the cell's middle along x, in world units.
Returns
number: The x.
GetCellMiddleZ()
This action returns the cell's middle along z, in world units.
Returns
number: The z.
GetDrawnCopyCount()
This action returns how many copies are drawn after thinning, at the level drawn and the level faded into. A card's planes count as one copy each.
Returns
integer: The count.
GetLevel()
This action returns the level of detail drawn: 0 for the asset's own mesh.
Returns
integer: The level.
GetModel()
This action returns the model drawing the copies at the level drawn.
Returns
Libraries.Game.Graphics.Model: The model, or undefined before Build.
GetReach()
This action returns how tall the tallest copy reaches above where it stands, in world units, once built.
Returns
number: The height.
GetRenderBounds(Libraries.Game.BoundingBox local)
This action fills in the box around every copy, in world units, from the cell's lowest and highest copies and the tallest copy's reach.
Parameters
localLibraries.Game.BoundingBox: The box to fill in.
Returns
boolean: True, or false if the cell is empty.
IsNearCamera()
This action returns whether the cell is within its asset's draw distance of the camera.
Returns
boolean: True if it is near enough to draw.
PlaceAgain()
This action moves the copies up or down to their heights, after they followed the ground. It is quicker than Build, since nothing is loaded again; it works out the copies again, so copies added or removed are right too.
Set(Libraries.Game.Graphics.Worlds.FoliageCell foliageCell, Libraries.Game.Graphics.Worlds.FoliageAsset foliageAsset, Libraries.System.File file)
This action sets the cell to draw, its asset, and the asset's model or card picture file. Levels of detail are given with SetLevelSource.
Parameters
foliageCellLibraries.Game.Graphics.Worlds.FoliageCell: The cell.foliageAssetLibraries.Game.Graphics.Worlds.FoliageAsset: The cell's asset.fileLibraries.System.File: The asset's model file, or its card picture.
SetCardTexture(Libraries.Game.Graphics.Texture texture)
This action sets the picture every card of the asset shares, so it is loaded once. Without it, Build loads the picture itself.
Parameters
textureLibraries.Game.Graphics.Texture: The card picture.
SetGround(Libraries.Game.Graphics.Worlds.TerrainData data)
This action sets the terrain's heights, so copies of an asset that leans with the slope can find it.
Parameters
dataLibraries.Game.Graphics.Worlds.TerrainData: The terrain's heights, or undefined.
SetInView(boolean visible)
This action sets whether the cell is inside the camera's view. The cell shows when it is near and in view.
Parameters
visibleboolean: True if any of the cell is in view.
SetLevelSource(integer levelNumber, Libraries.System.File file, Libraries.Game.Graphics.Texture cardTexture)
This action sets a level of detail's file: its model, or for a card level, its picture, with the picture's texture if it is already loaded.
Parameters
levelNumberinteger: The level, from 1 to 3.fileLibraries.System.File: The model or picture file, or undefined for none.cardTextureLibraries.Game.Graphics.Texture: The card's picture, or undefined to load it when needed.
SetNearCamera(boolean near)
This action sets whether the cell is within its asset's draw distance of the camera. The cell shows when it is near and in view.
Parameters
nearboolean: True if the cell is near enough to draw.
UpdateForDistance(number distance)
This action tells the item how far the camera is from the cell's nearest side. It picks the level of detail for that distance, how much the copies thin out near the draw distance, and how far they have faded into the next level, and draws them again only if any of these changed, so calling it a few times a second costs little.
Parameters
distancenumber: How far the camera is, in world units.
Returns
boolean: True if what is drawn changed.
Inherited Actions
64 actions from Libraries.Interface.Item
- AddBehavior(Libraries.Interface.Behaviors.Behavior behavior)
- AddFocusListener(Libraries.Interface.Events.FocusListener listener)
- AddGestureListener(Libraries.Interface.Events.GestureListener listener)
- AddMouseListener(Libraries.Interface.Events.MouseListener listener)
- AddMouseMovementListener(Libraries.Interface.Events.MouseMovementListener listener)
- AddMouseWheelListener(Libraries.Interface.Events.MouseWheelListener listener)
- AddTouchListener(Libraries.Interface.Events.TouchListener listener)
- BeginCollision(Libraries.Interface.Item item)
- CancelBehaviors()
- Dispose()
- DisposeAll()
- DisposeChildren()
- EmptyAll()
- EmptyChildren()
- FinishCollision(Libraries.Interface.Item item)
- Focus()
- GainedFocus(Libraries.Interface.Events.FocusEvent event)
- GetAccessibilityCode()
- GetAccessibilityRoleDescription()
- GetAccessibilityType()
- GetActiveDescendant()
- GetDescription()
- GetFocusListeners()
- GetGestureListeners()
- GetInputGroup()
- GetInputTable()
- GetMouseListeners()
- GetMouseMovementListeners()
- GetMouseWheelListeners()
- GetName()
- GetNextFocus()
- GetPreviousFocus()
- GetPropertiesSize()
- GetProperty(text key)
- GetPropertyKeyIterator()
- GetTouchListeners()
- HasProperties()
- HasProperty(text key)
- Hide()
- IsAcceptingMouseInput()
- IsAccessibleParent()
- IsFocusable()
- IsFocused()
- IsShowing()
- LostFocus(Libraries.Interface.Events.FocusEvent event)
- RemoveFocusListener(Libraries.Interface.Events.FocusListener listener)
- RemoveGestureListener(Libraries.Interface.Events.GestureListener listener)
- RemoveMouseListener(Libraries.Interface.Events.MouseListener listener)
- RemoveMouseMovementListener(Libraries.Interface.Events.MouseMovementListener listener)
- RemoveMouseWheelListener(Libraries.Interface.Events.MouseWheelListener listener)
- RemoveTouchListener(Libraries.Interface.Events.TouchListener listener)
- SetAcceptsMouseInput(boolean accepts)
- SetAccessibilityCode(integer newAccessibilityCode)
- SetAccessibilityRoleDescription(text newRoleDescription)
- SetDescription(text newDescription)
- SetFocusable(boolean focus)
- SetInputGroup(text group)
- SetName(text newName)
- SetNextFocus(Libraries.Interface.Item next)
- SetPreviousFocus(Libraries.Interface.Item previous)
- SetProperty(text key, Libraries.Data.Formats.JavaScriptObjectNotation value)
- Show()
- Update(number secondsSinceUpdate)
- UpdateAll(number secondsSinceUpdate)
215 actions from Libraries.Interface.Item3D
- Add(Libraries.Interface.Item3D newItem)
- Add(integer index, Libraries.Interface.Item3D newItem)
- AddShadowLight(integer bit, integer frame)
- ApplyAngularImpulse(Libraries.Compute.Vector3 impulse)
- ApplyDamping(number seconds)
- ApplyForce(Libraries.Compute.Vector3 force, Libraries.Compute.Vector3 point)
- ApplyForceToCenter(Libraries.Compute.Vector3 force)
- ApplyImpulse(Libraries.Compute.Vector3 impulse, Libraries.Compute.Vector3 localPositionToApply)
- ApplyLinearImpulse(Libraries.Compute.Vector3 impulse, Libraries.Compute.Vector3 point)
- ApplyLinearImpulseToCenter(Libraries.Compute.Vector3 impulse)
- ApplyTorque(Libraries.Compute.Vector3 torque)
- ApplyTorqueImpulse(Libraries.Compute.Vector3 torque)
- CanRotate(boolean flag)
- CollideWithChildren()
- ComputeAngularImpulseDenominator(Libraries.Compute.Vector3 axis)
- ComputeImpulseDenominator(Libraries.Compute.Vector3 position, Libraries.Compute.Vector3 normal)
- CreateNodes(Libraries.Game.Collision.BroadphaseCollision3D broadphase, Libraries.Game.Collision.PhysicsPosition3D transform)
- DestroyNodes(Libraries.Game.Collision.BroadphaseCollision3D broadphase)
- Draw(Libraries.Game.Graphics.Painter3D painter)
- Empty()
- EnablePhysics(boolean flag)
- FastMoving(boolean flag)
- GetAccessibilityCursor()
- GetAccessibleParent()
- GetAngularDamping()
- GetAngularFactor()
- GetAngularVelocity()
- GetBoundingBox(integer childIndex)
- GetCenterOfMassPosition()
- GetCenterOfMassTransform()
- GetCollisionGroupFlag()
- GetCollisionGroupIndex()
- GetCollisionList()
- GetCollisionTransform()
- GetCollisionTransform0()
- GetDepth()
- GetDimensions()
- GetDrawnTransform()
- GetForce()
- GetFriction()
- GetGlobalPosition()
- GetGlobalX()
- GetGlobalY()
- GetGlobalZ()
- GetHeight()
- GetInterpolatedAngularVelocity()
- GetInterpolatedLinearVelocity()
- GetInterpolationTransform()
- GetInterpolationWorldTransform()
- GetInverseInertiaLocal()
- GetInverseInertiaWorld()
- GetInverseMass()
- GetItem(integer index)
- GetItemCount()
- GetItems()
- GetJointList()
- GetLayer()
- GetLights(Libraries.Containers.Array<Libraries.Game.Graphics.Light> array)
- GetLights()
- GetLinearDamping()
- GetLinearVelocity()
- GetLinearVelocityAtLocalPoint(Libraries.Compute.Vector3 relativePosition)
- GetMass()
- GetNode(integer index)
- GetNodeCount()
- GetNodes()
- GetOffsetX()
- GetOffsetY()
- GetOffsetZ()
- GetOrientation()
- GetParent()
- GetPhysicsProperties()
- GetPitch()
- GetPosition()
- GetPushVelocity()
- GetResponsiveness()
- GetRestitution()
- GetRoll()
- GetRotationTransform()
- GetScaleX()
- GetScaleY()
- GetScaleZ()
- GetScreenBounds()
- GetScreenBoundsOfBox(Libraries.Game.BoundingBox box)
- GetScreenX()
- GetScreenY()
- GetShadowLightMask(integer frame)
- GetShape()
- GetShapeOffset()
- GetShapeTransform()
- GetShapeType()
- GetSleepTime()
- GetTimeOfImpact()
- GetTorque()
- GetTransform()
- GetTurnVelocity()
- GetWidth()
- GetX()
- GetY()
- GetYaw()
- GetZ()
- HasMoved()
- HasReportedMove()
- HasShapeOffset()
- IntegrateVelocities(number seconds)
- InternalApplyImpulse(Libraries.Compute.Vector3 linearComponent, Libraries.Compute.Vector3 angularComponent, number impulseMagnitude)
- IsCollidable()
- IsEmpty()
- IsFastMoving()
- IsNonResponsive()
- IsOnLayer()
- IsPhysicsEnabled()
- IsResponsive()
- IsRotationAllowed()
- IsSimulated()
- IsSimulationRequired()
- IsUnmovable()
- Move(Libraries.Compute.Vector3 vector)
- Move(number xAmount, number yAmount, number zAmount)
- MoveX(number xAmount)
- MoveY(number yAmount)
- MoveZ(number zAmount)
- NotifyMoved()
- PredictIntegratedTransform(number seconds, Libraries.Game.Collision.PhysicsPosition3D predictedTransform)
- ProceedToTransform(Libraries.Game.Collision.PhysicsPosition3D transform)
- ProcessGestureEvent(Libraries.Interface.Events.GestureEvent event)
- ProcessMouseEvent(Libraries.Interface.Events.MouseEvent event)
- ProcessTouchEvent(Libraries.Interface.Events.TouchEvent event)
- Remove(integer index)
- Remove(Libraries.Interface.Item3D removed)
- RequireSimulation(boolean flag)
- ResetMass()
- Rotate(Libraries.Compute.Vector3 vector, number degrees, boolean rotateChildren)
- Rotate(Libraries.Compute.Vector3 vector, number degrees)
- Rotate(number rotateX, number rotateY, number rotateZ, number degrees)
- Rotate(number rotateX, number rotateY, number rotateZ, number degrees, boolean rotateChildren)
- RotateAround(Libraries.Compute.Vector3 point, Libraries.Compute.Vector3 axis, number degrees)
- RotateAround(Libraries.Compute.Vector3 point, Libraries.Compute.Vector3 axis, number degrees, boolean rotateChildren)
- RotateChildren(number rotateX, number rotateY, number rotateZ, number degrees)
- RotateChildren(Libraries.Compute.Vector3 vector, number degrees)
- SaveKinematicState(number time)
- Scale(Libraries.Compute.Vector3 vector)
- Scale(Libraries.Compute.Vector3 vector, boolean scaleChildren)
- Scale(number scaleX, number scaleY, number scaleZ, boolean scaleChildren)
- Scale(number scaleX, number scaleY, number scaleZ)
- SetAngularDamping(number angularDamping)
- SetAngularVelocity(Libraries.Compute.Vector3 angularVelocity)
- SetCenterOfMassTransform(Libraries.Game.Collision.PhysicsPosition3D transform)
- SetCollidable(boolean flag)
- SetCollideWithChildren(boolean flag)
- SetCollisionGroupFlag(boolean flag)
- SetCollisionGroupIndex(integer index)
- SetCollisionList(Libraries.Game.Collision.CollisionEdge3D list)
- SetCollisionTransform(Libraries.Game.Collision.PhysicsPosition3D transform)
- SetCollisionTransform0(Libraries.Game.Collision.PhysicsPosition3D transform)
- SetDepth(number setDepth)
- SetDimensions(number setWidth, number setHeight, number setDepth)
- SetDimensions(Libraries.Compute.Vector3 vector)
- SetDrawnTransform(Libraries.Game.Collision.PhysicsPosition3D transform)
- SetForce(Libraries.Compute.Vector3 force)
- SetFriction(number friction)
- SetHasMoved(boolean flag)
- SetHeight(number setHeight)
- SetInterpolatedAngularVelocity(Libraries.Compute.Vector3 velocity)
- SetInterpolatedLinearVelocity(Libraries.Compute.Vector3 velocity)
- SetInterpolationTransform(Libraries.Game.Collision.PhysicsPosition3D transform)
- SetItem(integer index, Libraries.Interface.Item3D newItem)
- SetJointList(Libraries.Game.Physics.Joints.JointEdge3D list)
- SetLayer(Libraries.Game.Layer3D parentLayer)
- SetLinearDamping(number linearDamping)
- SetLinearVelocity(Libraries.Compute.Vector3 linearVelocity)
- SetLinearVelocityX(number linearVelocityX)
- SetLinearVelocityY(number linearVelocityY)
- SetLinearVelocityZ(number linearVelocityZ)
- SetMass(number mass)
- SetNonResponsive()
- SetOffset(Libraries.Compute.Vector3 vector)
- SetOffset(number xAmount, number yAmount, number zAmount)
- SetOffsetX(number xAmount)
- SetOffsetY(number yAmount)
- SetOffsetZ(number zAmount)
- SetParent(Libraries.Interface.Item3D newItem)
- SetPhysicsProperties(Libraries.Game.Physics.PhysicsProperties3D properties)
- SetPosition(Libraries.Compute.Vector3 vector)
- SetPosition(number setX, number setY, number setZ)
- SetReportedMove(boolean value)
- SetResponsive()
- SetResponsiveness(integer type)
- SetRestitution(number restitution)
- SetRotationTransform(Libraries.Compute.Matrix4 source)
- SetScale(number scaleX, number scaleY, number scaleZ)
- SetScale(number scaleX, number scaleY, number scaleZ, boolean scaleChildren)
- SetScaleX(number scale)
- SetScaleX(number scale, boolean scaleChildren)
- SetScaleY(number scale, boolean scaleChildren)
- SetScaleY(number scale)
- SetScaleZ(number scale, boolean scaleChildren)
- SetScaleZ(number scale)
- SetScreenPositionFromPhysicsPosition()
- SetShape(Libraries.Game.Collision.Shapes.CollisionShape3D shape)
- SetShapeOffset(number x, number y, number z)
- SetSleepTime(number time)
- SetTimeOfImpact(number timeOfImpact)
- SetTorque(Libraries.Compute.Vector3 torque)
- SetUnmovable()
- SetWidth(number setWidth)
- SetX(number setX)
- SetY(number setY)
- SetYawPitchRoll(number yaw, number pitch, number roll)
- SetZ(number setZ)
- ShouldCollide(Libraries.Interface.Item3D otherItem)
- Simulate(boolean flag)
- SimulationChanged()
- SynchronizeNodes()
- UpdateInertia()