Libraries.Game.Graphics.Model Documentation
The Model class represents a 3D model to be drawn on the screen by the Game engine. The Model can load data from .obj, .g3db, or .g3dj files, or can be set to some primitive shapes (such as boxes or cylinders).
Example Code
use Libraries.Game.Game
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color
class Main is Game
Model cube
action Main
StartGame()
end
action CreateGame
Color cyan
cyan:SetColor(0, 0.75, 1, 1)
cube:LoadBox(2, 2, 2, cyan)
Add(cube)
end
action Update(number seconds)
cube:Rotate(0, 1, 0, 45 * seconds)
end
end
Inherits from: Libraries.Interface.Item3D, Libraries.Interface.Item, Libraries.Language.Object
Actions Documentation
Add(Libraries.Interface.Item3D newItem)
This action adds a different Item3D into this one. This makes a few things happen. 1. The added item will get this item as its parent. 2. The added item's x, y, and z coordinates will become relative to this Item. 3. Most actions on this Item will also affect the added Item.
Parameters
- Libraries.Interface.Item3D: The item to add as a child to this Item3D.
Example
use Libraries.Interface.Item3D
Item3D parentItem
Item3D child
parentItem:Add(child)
Add(integer index, Libraries.Interface.Item3D newItem)
This action adds a different Item3D into this one, storing the added Item3D at a specific index in the internal array.
Parameters
- integer index: The index to store the child item at.
- Libraries.Interface.Item3D: The item to add as a child to this Item3D.
Example
use Libraries.Interface.Item3D
Item3D parentItem
Item3D child
parentItem:Add(0, child)
AddBehavior(Libraries.Interface.Behaviors.Behavior behavior)
AddFocusListener(Libraries.Interface.Events.FocusListener listener)
This action adds a FocusListener to the Item. When the Item receives a FocusEvent due to either gaining or losing the focus, the listener will be notified.
Parameters
Example
use Libraries.Interface.Item
use Libraries.Interface.Events.FocusListener
Item myItem
FocusListener listener
myItem:AddFocusListener(listener)
AddGestureListener(Libraries.Interface.Events.GestureListener listener)
This action adds a GestureListener to the Item. If the Item ever receives a GestureEvent, the listener will be notified.
Parameters
Example
use Libraries.Interface.Item
use Libraries.Interface.Events.GestureListener
Item myItem
GestureListener listener
myItem:AddGestureListener(listener)
AddMouseListener(Libraries.Interface.Events.MouseListener listener)
This action adds a MouseListener to the Item. If the Item ever receives a MouseEvent due to a mouse click, the mouse listener will be notified.
Parameters
Example
use Libraries.Interface.Item
use Libraries.Interface.Events.MouseListener
Item myItem
MouseListener listener
myItem:AddMouseListener(listener)
AddMouseMovementListener(Libraries.Interface.Events.MouseMovementListener listener)
This action adds a MouseMovementListener to the Item. If the Item ever receives a MouseEvent due to mouse movement, the listener will be notified.
Parameters
Example
use Libraries.Interface.Item
use Libraries.Interface.Events.MouseMovementListener
Item myItem
MouseMovementListener listener
myItem:AddMouseMovementListener(listener)
AddMouseWheelListener(Libraries.Interface.Events.MouseWheelListener listener)
This action adds a MouseWheelListener to the Item. If the Item ever receives a MouseEvent due to the mouse wheel being scrolled, the listener will be notified.
Parameters
Example
use Libraries.Interface.Item
use Libraries.Interface.Events.MouseWheelListener
Item myItem
MouseWheelListener listener
myItem:AddMouseWheelListener(listener)
AddTouchListener(Libraries.Interface.Events.TouchListener listener)
This action adds a TouchListener to the Item. If the Item ever receives a TouchEvent, the listener will be notified.
Parameters
Example
use Libraries.Interface.Item
use Libraries.Interface.Events.TouchListener
Item myItem
TouchListener listener
myItem:AddTouchListener(listener)
ApplyAngularImpulse(Libraries.Compute.Vector3 impulse)
This action will increase the y-coordinate of this Item by the given amount.
Parameters
Example
use Libraries.Interface.Item3D
Item3D myItem
myItem:SetY(50)
myItem:MoveY(25)
ApplyDamping(number seconds)
Parameters
- number seconds
ApplyForce(Libraries.Compute.Vector3 force, Libraries.Compute.Vector3 point)
transform:Translate(xAmount, yAmount, -zAmount)
Parameters
ApplyForceToCenter(Libraries.Compute.Vector3 force)
This action will increase the x, y, and z coordinates of this Item by the given amounts.
Parameters
Example
use Libraries.Interface.Item3D
Item3D myItem
myItem:SetPosition(50, 25, 80)
myItem:Move(25, 15, -20)
ApplyImpulse(Libraries.Compute.Vector3 impulse, Libraries.Compute.Vector3 localPositionToApply)
ApplyLinearImpulse(Libraries.Compute.Vector3 impulse, Libraries.Compute.Vector3 point)
This action will increase the z-coordinate of this Item by the given amount.
Parameters
Example
use Libraries.Interface.Item3D
Item3D myItem
myItem:SetZ(50)
myItem:MoveZ(25)