1
-- This is the demo pocket which displays the theory from
2
-- the Visual Properties section of SceneObject tutorial
6
function onSceneStart()
7
-- Get object to be operated on
8
myObject = SceneManager.getObject("Big Cube")
10
bot = SceneManager.getObject("Bot")
12
Camera.setExactEye(vec(-3,13,5))
13
Camera.focusOnObject(myObject)
14
-- Set the Camera rotating
15
Timer.every(function() Camera.rotateLeft(0.1) end, 0)
17
GuiManager.call("gui", updateGui)
21
function replaceFromObject()
22
myObject:replaceModel(bot)
24
function replaceFromFile()
25
myObject:replaceModel("ali/wild pockets cube")
28
function setWireframe()
29
local meshes = myObject:getMeshes()
30
for i, mesh in ipairs(meshes) do
31
if not (mesh == nil) then
32
myObject:setMeshMode(mesh, "wireframe")
36
function setStandard()
37
local meshes = myObject:getMeshes()
38
for i, mesh in ipairs(meshes) do
39
if not (mesh == nil) then
40
myObject:setMeshMode(mesh, "standard")
44
function setAlphatest()
45
local meshes = myObject:getMeshes()
46
for i, mesh in ipairs(meshes) do
47
if not (mesh == nil) then
48
myObject:setMeshMode(mesh, "alphatest")
53
function replaceTextures()
54
local numTextures = myObject:getNumTextures()
55
for i = 1, numTextures do
56
myObject:setTexture("ecanaan/canon_blue-blue", i)
59
function setDefaultTextures()
60
local numTextures = myObject:getNumTextures()
61
for i = 1, numTextures do
62
myObject:setTexture(myObject:getDefaultTexture(i), i)
65
-- Shadow, lighting, highlight and stash
66
function toggleShadow()
67
if myObject:getCastsShadow() then
68
myObject:setCastsShadow(false)
70
myObject:setCastsShadow(true)
73
function toggleLighting()
74
if myObject:getLightingEnabled() then
75
myObject:setLightingEnabled(false)
77
myObject:setLightingEnabled(true)
80
function toggleStash()
81
if myObject:getStashed() then
82
myObject:setStashed(false)
84
myObject:setStashed(true)
87
function setHighlight(flag)
89
myObject:highlight(color(0,1,1,1))
91
myObject:highlight(nil)
94
function setNewColor()
95
myObject:setColor(1,0,0,0.7)
98
myObject:setColor(1,1,1,1)
100
-- Extra: SceneManager show Bones and Collisions
101
function showBonesAndCollisions(flag)
102
SceneManager.showBones(flag)
103
SceneManager.showCollisions(flag)
105
-- Gui - out of scope of this tutorial
107
local screen = Rect.screen()
108
local fromFileButton = screen:sub("file", 10, 10, 300, 30)
109
local fromObjectButton = screen:sub("object", 10, 30, 180, 50)
110
fromFileButton:drawButton(nil, GuiManager.standardSkin(), 'Replace from file: "ali/Wild Pockets Cube"', replaceFromFile)
111
fromObjectButton:drawButton(nil, GuiManager.standardSkin(), "Replace from object", replaceFromObject)
113
local wireframeButton = screen:sub("wireframe", 10, 70, 100, 90)
114
local standardButton = screen:sub("standard", 10, 90, 100, 110)
115
local alphatestButton = screen:sub("alphatest", 10, 110, 100, 130)
116
wireframeButton:drawButton(nil, GuiManager.standardSkin(), "wireframe", setWireframe)
117
standardButton:drawButton(nil, GuiManager.standardSkin(), "standard", setStandard)
118
alphatestButton:drawButton(nil, GuiManager.standardSkin(), "alphatest", setAlphatest)
120
local textureButton = screen:sub("texture", 10, 150, 140, 170)
121
local defaultTextureButton = screen:sub("default texture", 10, 170, 170, 190)
122
textureButton:drawButton(nil, GuiManager.standardSkin(), "replace textures", replaceTextures)
123
defaultTextureButton:drawButton(nil, GuiManager.standardSkin(), "set default textures", setDefaultTextures)
125
local shadowButton = screen:sub("shadow", 10, 230, 130, 250)
126
local lightingButton = screen:sub("lighting", 10, 250, 130, 270)
127
local stashButton = screen:sub("stash", 10, 270, 130, 290)
128
local setNewColorButton = screen:sub("newColor", 10, 310, 100, 330)
129
local setWhiteButton = screen:sub("white", 10, 290, 100, 310)
130
local highlightText = screen:sub("highlightText", 10, 330, 100, 350)
131
local highlightCheckbox = screen:sub("highlightText", 100, 335, 110, 345)
132
shadowButton:drawButton(nil, GuiManager.standardSkin(), "toggle shadow", toggleShadow)
133
lightingButton:drawButton(nil, GuiManager.standardSkin(), "toggle lighting", toggleLighting)
134
stashButton:drawButton(nil, GuiManager.standardSkin(), "toggle stashed", toggleStash)
135
setNewColorButton:drawButton(nil, GuiManager.standardSkin(), "new color", setNewColor)
136
setWhiteButton:drawButton(nil, GuiManager.standardSkin(), "default color", setWhite)
137
highlightText:drawText(nil, {size = 10}, "highlight:")
138
highlightCheckbox:drawCheckBox(nil, GuiManager.standardSkin(), false, function() setHighlight(highlightCheckbox:getCheckBoxValue()) end)
140
local bonesCollisionsText = screen:sub("bones text", 10, 350, 180, 370)
141
local bonesCollisionsCheckbox = screen:sub("bones checkbox", 180, 355, 190, 365)
142
bonesCollisionsText:drawText(nil, {size = 8}, "Show Bones and Collisions:")
143
bonesCollisionsCheckbox:drawCheckBox(nil, GuiManager.standardSkin(), false, function() showBonesAndCollisions(bonesCollisionsCheckbox:getCheckBoxValue()) end)
b'\\ No newline at end of file'