Jump to content

Entity

98 records in this category

  1. Entity

    Attachments: Show TOC: False
    • 0 comments
    • 775 views
  2. Entity::AddForce

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(35,0,0);<br /> camera->Move(0,0,-6);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create the ground<br /> Model* ground = Model::Box(10,1,10);<br /> ground->SetPosition(0,0,-0.5);<br /> ground->SetColor(0,1,0,1);<br /> <br /> //Create a shape<br /> Shape* shape = Shape::Box(0,0,0, 0,0,0, 10,1,10);<br /> ground->SetShape(shape);<br /> shape->Release();<br /> <br /> //Create a model<br /> Model* model = Model::Sphere();<br /> model->SetPosition(0,5,0);<br /> model->SetColor(0,0,1,1);<br /> model->SetMass(1);<br /> model->SetRotation(0,0,85);<br /> model->AddForce(0,0,-200);<br /> <br /> //Create a shape<br /> shape = Shape::Sphere(0,0,0, 0,0,0, 1,1,1);<br /> model->SetShape(shape);<br /> shape->Release();<br /> <br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /> <br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-8)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create the ground<br /> local ground = Model:Box(10,1,10)<br /> ground:SetPosition(0,0,-0.5)<br /> ground:SetColor(0,1,0)<br /><br /> --Create a shape<br /> local shape = Shape:Box(0,0,0, 0,0,0, 10,1,10)<br /> ground:SetShape(shape)<br /> shape:Release()<br /><br /> --Create a model<br /> local model = Model:Sphere()<br /> model:SetPosition(0,5,0)<br /> model:SetColor(0,0,1)<br /> model:SetMass(1)<br /> model:SetRotation(0,0,85)<br /> model:AddForce(0,0,-200)<br /><br /> --Create a shape<br /> local shape = Shape:Sphere(0,0,0, 0,0,0, 1,1,1)<br /> model:SetShape(shape)<br /> shape:Release()<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 2,720 views
  3. Entity::AddPointForce

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(35,0,0);<br /> camera->Move(0,0,-6);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create the ground<br /> Model* ground = Model::Box(10,1,10);<br /> ground->SetPosition(0,-0.5,0);<br /> ground->SetColor(0,1,0);<br /><br /> //Create a shape<br /> Shape* shape = Shape::Box(0,0,0, 0,0,0, 10,1,10);<br /> ground->SetShape(shape);<br /> shape->Release();<br /><br /> //Create a model<br /> Model* model = Model::Box(10,1,1);<br /> model->SetPosition(0,0.5,0);<br /> model->SetColor(0,0,1);<br /> model->SetMass(1);<br /> <br /> //Create a shape<br /> shape = Shape::Box(0,0,0, 0,0,0, 10,1,1);<br /> model->SetShape(shape);<br /> shape->Release();<br /><br /> //We're going to add a force (0,0,100) at the position (5,0,0)<br /> //This will push a point on the right side of the object away from the camera<br /> model->AddPointForce(0,0,100,5,0,0);<br /><br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-8)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create the ground<br /> local ground = Model:Box(10,1,10)<br /> ground:SetPosition(0,-0.5,0)<br /> ground:SetColor(0,1,0)<br /><br /> --Create a shape<br /> local shape = Shape:Box(0,0,0, 0,0,0, 10,1,10)<br /> ground:SetShape(shape)<br /> shape:Release()<br /><br /> --Create a model<br /> local model = Model:Box(10,1,1)<br /> model:SetPosition(0,0.5,0)<br /> model:SetColor(0,0,1)<br /> model:SetMass(1)<br /> <br /> --Create a shape<br /> local shape = Shape:Box(0,0,0, 0,0,0, 10,1,1)<br /> model:SetShape(shape)<br /> shape:Release()<br /><br /> --We're going to add a force (0,0,100) at the position (5,0,0)<br /> --This will push a point on the right side of the object away from the camera<br /> model:AddPointForce(0,0,100,5,0,0)<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,417 views
  4. Entity::AddTorque

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(35,0,0);<br /> camera->Move(0,0,-6);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create a model<br /> Model* model = Model::Box(10,1,1);<br /> model->SetPosition(0,0.5,0);<br /> model->SetColor(0,0,1);<br /> model->SetMass(1);<br /> model->SetGravityMode(false);<br /><br /> //Create a shape<br /> Shape* shape = Shape::Box(0,0,0, 0,0,0, 10,1,1);<br /> model->SetShape(shape);<br /> shape->Release();<br /><br /> //Add some torque<br /> model->AddTorque(1000,0,0);<br /><br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-8)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create a model<br /> local model = Model:Box(10,1,1) <br /> model:SetPosition(0,0.5,0) <br /> model:SetColor(0,0,1) <br /> model:SetMass(1) <br /> model:SetGravityMode(false) <br /><br /> --Create a shape<br /> local shape = Shape:Box(0,0,0, 0,0,0, 10,1,1) <br /> model:SetShape(shape) <br /> shape:Release() <br /><br /> --Add some torque<br /> model:AddTorque(1000,0,0) <br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,634 views
  5. Entity::AlignToVector

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Model* model = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->Move(0,0,-6);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create a model<br /> model = Model::Box();<br /> <br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> //Get the vector between the mouse position and the center of the screen<br /> Vec3 v = window->GetMousePosition();<br /> float dx = v.x - context->GetWidth()/2.0;<br /> float dy = context->GetHeight()/2.0 - v.y;<br /> v = Vec3(dx,dy,0).Normalize();<br /><br /> //Align the model to the vector<br /> model->AlignToVector(v,2);<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-6)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create a model<br /> self.model = Model:Box()<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> --Get the vector between the mouse position and the center of the screen<br /> local v = self.window:GetMousePosition()<br /> local dx = v.x - self.context:GetWidth()/2.0<br /> local dy = self.context:GetHeight()/2.0 - v.y<br /> v = Vec3(dx,dy,0):Normalize()<br /><br /> --Align the model to the vector<br /> self.model:AlignToVector(v,2)<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 2,083 views
  6. Entity::CollisionHook

    Attachments: Show TOC: False
    • 2 comments
    • 2,461 views
  7. Entity::Copy

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(35,0,0);<br /> camera->Move(0,0,-6);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create a model<br /> Model* model1 = Model::Box();<br /> model1->SetPosition(-1,0,0);<br /> model1->SetColor(0,0,1);<br /><br /> //Create a copy<br /> Model* model2 = (Model*)model1->Copy();<br /> model2->SetPosition(1,0,0);<br /> model2->SetColor(0,1,0);<br /><br /> //Lets modify some vertices to show the copy is unique<br /> Surface* surface = model2->GetSurface(0);<br /> surface->SetVertexPosition(0,-0.5,-1,-0.5);<br /> surface->UpdateAABB();<br /> model2->UpdateAABB(Entity::LocalAABB|Entity::GlobalAABB);<br /><br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-3)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create a model<br /> local model1 = Model:Box()<br /> model1:SetPosition(-1,0,0)<br /> model1:SetColor(0,0,1)<br /><br /> --Create a copy<br /> local model2 = tolua.cast(model1:Copy(),"Model")<br /> model2:SetPosition(1,0,0)<br /> model2:SetColor(0,1,0)<br /><br /> --Lets modify some vertices to show the copy is unique<br /> local surface = model2:GetSurface(0)<br /> surface:SetVertexPosition(0,-0.5,-1,-0.5)<br /> surface:UpdateAABB()<br /> model2:UpdateAABB(Entity.LocalAABB)<br /> model2:UpdateAABB(Entity.GlobalAABB)<br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,781 views
  8. Entity::CountAnimations

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Model* model = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(35,0,0);<br /> camera->Move(0,0,-3);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Load a model<br /> model = Model::Load("Models/Characters/Barbarian/barbarian.mdl");<br /> <br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /><br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("The model contains "+String(model->CountAnimations())+" animations.",2,2);<br /><br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-3)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Load a model<br /> self.model = Model:Load("Models/Characters/Barbarian/barbarian.mdl")<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.context:SetBlendMode(Blend.Alpha)<br /> self.context:DrawText("The model contains "..self.model:CountAnimations().." animations.",2,2)<br /><br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,245 views
  9. Entity::CountChildren

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Entity* entity = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(35,0,0);<br /> camera->Move(0,0,-4);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Load a model<br /> entity = Model::Box();<br /> <br /> Entity* child = Model::Box(1,1,1,entity);<br /> child->SetColor(1.0,0.0,0.0);<br /> child->SetPosition(2,-2,0);<br /><br /> child = Model::Box(1,1,1,entity);<br /> child->SetColor(0.0,1.0,0.0);<br /> child->SetPosition(-2,-2,0);<br /><br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /><br /> entity->Turn(1.0*Time::GetSpeed(),2.0*Time::GetSpeed(),3.0*Time::GetSpeed());<br /><br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("The entity has "+String(entity->CountChildren())+" children.",2,2);<br /><br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-3)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Load a model<br /> self.entity = Model:Box()<br /> <br /> local child = Model:Box(1,1,1,self.entity)<br /> child:SetColor(1.0,0.0,0.0)<br /> child:SetPosition(2,-2,0)<br /><br /> child = Model:Box(1,1,1,self.entity)<br /> child:SetColor(0.0,1.0,0.0)<br /> child:SetPosition(-2,-2,0)<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.entity:Turn(1.0*Time:GetSpeed(),2.0*Time:GetSpeed(),3.0*Time:GetSpeed())<br /><br /> self.context:SetBlendMode(Blend.Alpha)<br /> self.context:DrawText("The entity has "..self.entity:CountChildren().." children.",2,2)<br /><br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,338 views
  10. Entity::DrawEachHook

    Attachments: Show TOC: False
    • 0 comments
    • 1,091 views
  11. Entity::DrawHook

    Attachments: Show TOC: False
    • 0 comments
    • 1,339 views
  12. Entity::EmitSound

    Attachments: Show TOC: False
    • 0 comments
    • 2,117 views
  13. Entity::FindChild

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Entity* entity = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(35,0,0);<br /> camera->Move(0,0,-4);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Load a model<br /> entity = Model::Box();<br /> <br /> Entity* child = Model::Box(1,1,1,entity);<br /> child->SetColor(1,0,0);<br /> child->SetPosition(2,-2,0);<br /> child->SetKeyValue("name","MyBox1");<br /><br /> child = Model::Box(1,1,1,entity);<br /> child->SetColor(0,1,0);<br /> child->SetPosition(-2,-2,0);<br /> child->SetKeyValue("name","MyBox2");<br /><br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /><br /> entity->Turn(1.0*Time::GetSpeed(),2.0*Time::GetSpeed(),3.0*Time::GetSpeed());<br /><br /> Entity* child = entity->FindChild("MyBox2");<br /><br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("Position: "+child->GetPosition(true).ToString(),2,2);<br /><br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-3)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Load a model<br /> self.entity = Model:Box()<br /> <br /> local child = Model:Box(1,1,1,self.entity)<br /> child:SetColor(1.0,0.0,0.0)<br /> child:SetPosition(2,-2,0)<br /> child:SetKeyValue("name","MyBox1")<br /><br /> child = Model:Box(1,1,1,self.entity)<br /> child:SetColor(0.0,1.0,0.0)<br /> child:SetPosition(-2,-2,0)<br /> child:SetKeyValue("name","MyBox2")<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.entity:Turn(1.0*Time:GetSpeed(),2.0*Time:GetSpeed(),3.0*Time:GetSpeed())<br /><br /> local child = self.entity:FindChild("MyBox2")<br /><br /> self.context:SetBlendMode(Blend.Alpha)<br /> self.context:DrawText("Position: "..child:GetPosition(true):ToString(),2,2);<br /><br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 2,047 views
  14. Entity::Follow

    Attachments: Show TOC: False
    • 2 comments
    • 2,259 views
  15. Entity::GetAABB

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Entity* entity = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(35,0,0);<br /> camera->Move(0,0,-4);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create a model<br /> entity = Model::Box();<br /> <br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /><br /> entity->SetPosition(Math::Sin(Time::GetCurrent()/100.0),0,0);<br /><br /> context->SetBlendMode(Blend::Alpha);<br /> AABB aabb = entity->GetAABB(Entity::GlobalAABB);<br /> context->DrawText("AABB: "+aabb.ToString(),2,2);<br /><br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-6)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create a model<br /> self.entity = Model:Box()<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.entity:SetPosition(Math:Sin(Time:GetCurrent()/100.0),0,0)<br /><br /> self.context:SetBlendMode(Blend.Alpha)<br /> local aabb = self.entity:GetAABB(Entity.GlobalAABB)<br /> self.context:DrawText("AABB: "..aabb:ToString(),2,2)<br /><br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,766 views
  16. Entity::GetAirborne

    Attachments: Show TOC: False
    • 0 comments
    • 1,531 views
  17. Entity::GetAnimationLength

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Entity* entity = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(35,0,0);<br /> camera->Move(0,0,-4);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Load a model<br /> entity = Model::Load("Models/Characters/Barbarian/barbarian.mdl");<br /> <br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /><br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("Animation length: "+String(entity->GetAnimationLength(0))+" frames",2,2);<br /><br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-3)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Load a model<br /> self.model = Model:Load("Models/Characters/Barbarian/barbarian.mdl")<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.context:SetBlendMode(Blend.Alpha)<br /> self.context:DrawText("Animation length: "..self.model:GetAnimationLength(0).." frames",2,2);<br /><br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,225 views
  18. Entity::GetChild

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Entity* entity = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(35,0,0);<br /> camera->Move(0,0,-4);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Load a model<br /> entity = Model::Box();<br /> <br /> Entity* child = Model::Box(1,1,1,entity);<br /> child->SetColor(1.0,0.0,0.0);<br /> child->SetPosition(2,-2,0);<br /> <br /> child = Model::Box(1,1,1,entity);<br /> child->SetColor(0.0,1.0,0.0);<br /> child->SetPosition(-2,-2,0);<br /> <br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /> <br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> <br /> entity->Turn(1.0*Time::GetSpeed(),2.0*Time::GetSpeed(),3.0*Time::GetSpeed());<br /> <br /> //Get the first child<br /> Entity* child = entity->GetChild(0);<br /> <br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("Position: "+child->GetPosition(true).ToString(),2,2);<br /> <br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-3)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Load a model<br /> self.entity = Model:Box()<br /> <br /> local child = Model:Box(1,1,1,self.entity)<br /> child:SetColor(1.0,0.0,0.0)<br /> child:SetPosition(2,-2,0)<br /><br /> child = Model:Box(1,1,1,self.entity)<br /> child:SetColor(0.0,1.0,0.0)<br /> child:SetPosition(-2,-2,0)<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.entity:Turn(1.0*Time:GetSpeed(),2.0*Time:GetSpeed(),3.0*Time:GetSpeed())<br /><br /> local child = self.entity:GetChild(0)<br /><br /> self.context:SetBlendMode(Blend.Alpha)<br /> self.context:DrawText("Position: "..child:GetPosition(true):ToString(),2,2);<br /><br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,934 views
  19. Entity::GetCollisionType

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Entity* entity1 = NULL;<br />Entity* entity2 = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(15,0,0);<br /> camera->Move(0,0,-8);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create the ground<br /> Model* ground = Model::Box(10,1,10);<br /> ground->SetColor(0.0,1.0,0.0);<br /> <br /> //Create a shape<br /> Shape* shape = Shape::Box(0,0,0, 0,0,0, 10,1,10);<br /> ground->SetShape(shape);<br /> shape->Release();<br /> <br /> //Create a model<br /> entity1 = Model::Box();<br /> entity1->SetColor(0.0,0.0,1.0);<br /> entity1->SetPosition(-2,5,0);<br /> entity1->SetMass(1);<br /> entity1->SetCollisionType(Collision::Prop);<br /> <br /> //Create a shape<br /> shape = Shape::Box();<br /> entity1->SetShape(shape);<br /> shape->Release();<br /> <br /> //Create a second model<br /> entity2 = entity1->Instance();<br /> entity2->SetPosition(2,5,0);<br /> entity2->SetCollisionType(Collision::None);<br /> <br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /> <br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> <br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("Entity 1 collision type: "+String(entity1->GetCollisionType()),2,2);<br /> context->DrawText("Entity 2 collision type: "+String(entity2->GetCollisionType()),2,22);<br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-8)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create the ground<br /> local ground = Model:Box(10,1,10) <br /> ground:SetColor(0.0,1.0,0.0) <br /> <br /> --Create a shape<br /> local shape = Shape:Box(0,0,0, 0,0,0, 10,1,10) <br /> ground:SetShape(shape) <br /> shape:Release() <br /> <br /> --Create a model<br /> self.entity1 = Model:Box() <br /> self.entity1:SetColor(0.0,0.0,1.0) <br /> self.entity1:SetPosition(-2,3,0) <br /> self.entity1:SetMass(1) <br /> self.entity1:SetCollisionType(Collision.Prop) <br /> <br /> --Create a shape<br /> shape = Shape:Box() <br /> self.entity1:SetShape(shape) <br /> shape:Release() <br /> <br /> --Create a second model<br /> self.entity2 = self.entity1:Instance() <br /> self.entity2:SetPosition(2,3,0) <br /> self.entity2:SetCollisionType(Collision.None) <br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.context:SetBlendMode(Blend.Alpha) <br /> self.context:DrawText("Entity 1 collision type: "..self.entity1:GetCollisionType(),2,2) <br /> self.context:DrawText("Entity 2 collision type: "..self.entity2:GetCollisionType(),2,22) <br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,448 views
  20. Entity::GetCrouched

    Attachments: Show TOC: False
    • 0 comments
    • 1,296 views
  21. Entity::GetDistance

    Attachments: Show TOC: False
    • 0 comments
    • 1,838 views
  22. Entity::GetGravityMode

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Entity* entity = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(35,0,0);<br /> camera->Move(0,0,-4);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create a model<br /> entity = Model::Box();<br /> entity->SetMass(1);<br /> entity->SetGravityMode(false);<br /> entity->AddTorque(0,360*10,0);<br /><br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /><br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("Gravity mode: "+String(entity->GetGravityMode()),2,2);<br /><br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-8)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create a model<br /> self.entity = Model:Box()<br /> self.entity:SetMass(1)<br /> self.entity:SetGravityMode(false) <br /> self.entity:AddTorque(0,360*10,0) <br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.context:SetBlendMode(Blend.Alpha) <br /> self.context:DrawText("Gravity mode: "..tostring(self.entity:GetGravityMode()),2,2) <br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,061 views
  23. Entity::GetIntensity

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Entity* entity = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(35,0,0);<br /> camera->Move(0,0,-4);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create a model<br /> entity = Model::Box();<br /> entity->SetColor(1,0.5,0.25);<br /><br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> <br /> entity->SetIntensity(Math::Sin(Time::GetCurrent()/10.0)+1.5);<br /><br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("Color: "+entity->GetColor().ToString(),2,2);<br /> context->DrawText("Intensity: "+String(entity->GetIntensity()),2,22);<br /><br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:Move(0,0,-3)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create a model<br /> self.entity = Model:Box()<br /> self.entity :SetColor(1.0,0.5,0.25)<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /> <br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.entity :SetIntensity(Math:Sin(Time:GetCurrent()/10.0)+1.5)<br /><br /> self.context:SetBlendMode(Blend.Alpha)<br /> self.context:DrawText("Color: "..self.entity:GetColor():ToString(),2,2)<br /> self.context:DrawText("Intensity: "..self.entity:GetIntensity(),2,22)<br /><br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,024 views
  24. Entity::GetKeyValue

    Attachments: Show TOC: False
    • 0 comments
    • 1,100 views
  25. Entity::GetKeyValue

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Model* model = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->Move(0,0,-3);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create a model<br /> model = Model::Box();<br /> model->SetKeyValue("name","Box1");<br /> model->SetColor(0.0,0.0,1.0);<br /><br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /> <br /> model->Turn(0,Time::GetSpeed(),0);<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> <br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("Name: "+model->GetKeyValue("name"), 2, 2);<br /> context->SetBlendMode(Blend::Solid);<br /> <br /> context->Sync(false);<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-3)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create a model<br /> self.model = Model:Box()<br /> self.model:SetKeyValue("name","Box1")<br /> self.model:SetColor(0.0,0.0,1.0)<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> self.model:Turn(0,Time:GetSpeed(),0)<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.context:SetBlendMode(Blend.Alpha)<br /> self.context:DrawText("Name: "..self.model:GetKeyValue("name"), 2, 2)<br /> self.context:SetBlendMode(Blend.Solid)<br /><br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 2,880 views
  26. Entity::GetMass

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Entity* entity = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(35,0,0);<br /> camera->Move(0,0,-6);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create the ground<br /> Model* ground = Model::Box(10,1,10);<br /> ground->SetPosition(0,0,-0.5);<br /> ground->SetColor(0.0,1.0,0.0);<br /><br /> //Create a shape<br /> Shape* shape = Shape::Box(0,0,0, 0,0,0, 10,1,10);<br /> ground->SetShape(shape);<br /> shape->Release();<br /><br /> //Create a model<br /> entity = Model::Box();<br /> entity->SetColor(0.0,0.0,1.0);<br /> entity->SetPosition(0,3,0);<br /> entity->SetMass(1);<br /><br /> //Create a shape<br /> shape = Shape::Box();<br /> entity->SetShape(shape);<br /> shape->Release();<br /><br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> <br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("Mass: "+String(entity->GetMass()),2,2);<br /><br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-8)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create the ground<br /> local ground = Model:Box(10,1,10) <br /> ground:SetPosition(0,0,-0.5) <br /> ground:SetColor(0.0,1.0,0.0) <br /><br /> --Create a shape<br /> local shape = Shape:Box(0,0,0, 0,0,0, 10,1,10) <br /> ground:SetShape(shape) <br /> shape:Release() <br /><br /> --Create a model<br /> self.entity = Model:Box() <br /> self.entity:SetColor(0.0,0.0,1.0) <br /> self.entity:SetPosition(0,3,0) <br /> self.entity:SetMass(1) <br /><br /> --Create a shape<br /> shape = Shape:Box() <br /> self.entity:SetShape(shape) <br /> shape:Release() <br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.context:SetBlendMode(Blend.Alpha) <br /> self.context:DrawText("Mass: "..self.entity:GetMass(),2,2) <br /><br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,058 views
  27. Entity::GetMaterial

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Entity* entity = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(35,0,0);<br /> camera->Move(0,0,-3);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create a model<br /> entity = Model::Box();<br /><br /> //Load a material<br /> Material* material = Material::Load("Materials/Brick/brickwall01a.mat");<br /><br /> //Set the entity material<br /> entity->SetMaterial(material);<br /> material->Release();<br /> <br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> <br /> //Get the entity material<br /> Material* material = entity->GetMaterial();<br /><br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("Material: "+material->GetPath(),2,2);<br /><br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-3) <br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create a model<br /> self.entity = Model:Box()<br /><br /> --Load a material<br /> local material = Material:Load("Materials/Brick/brickwall01a.mat")<br /><br /> --Set the entity material<br /> self.entity:SetMaterial(material)<br /> material:Release()<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> --Get the entity material<br /> local material = self.entity:GetMaterial()<br /><br /> self.context:SetBlendMode(Blend.Alpha)<br /> self.context:DrawText("Material: "..material:GetPath(),2,2)<br /><br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,649 views
  28. Entity::GetMatrix

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Entity* entity = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(35,0,0);<br /> camera->Move(0,0,-3);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create a model<br /> entity = Model::Box();<br /> <br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> <br /> entity->Turn(Time::GetSpeed()*0.1,Time::GetSpeed()*0.2,Time::GetSpeed()*0.3);<br /><br /> //Display the matrix on screen<br /> context->SetBlendMode(Blend::Alpha);<br /> Mat4 mat = entity->GetMatrix();<br /> context->DrawText("Row 0: "+mat[0].ToString(),2,2);<br /> context->DrawText("Row 1: "+mat[1].ToString(),2,22);<br /> context->DrawText("Row 2: "+mat[2].ToString(),2,42);<br /> context->DrawText("Row 3: "+mat[3].ToString(),2,62);<br /><br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-6)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create a model<br /> self.entity = Model:Box()<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.entity:Turn(Time:GetSpeed()*0.1,Time:GetSpeed()*0.2,Time:GetSpeed()*0.3)<br /><br /> --Display the matrix on screen<br /> self.context:SetBlendMode(Blend.Alpha)<br /> local mat = self.entity:GetMatrix()<br /> self.context:DrawText("Row 0: "..mat[0]:ToString(),2,2)<br /> self.context:DrawText("Row 1: "..mat[1]:ToString(),2,22)<br /> self.context:DrawText("Row 2: "..mat[2]:ToString(),2,42)<br /> self.context:DrawText("Row 3: "..mat[3]:ToString(),2,62)<br /><br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,334 views
  29. Entity::GetNavigationMode

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Entity* entity = NULL;<br />Entity* player = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(35,0,0);<br /> camera->Move(0,0,-8);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Enable navmesh debugging<br /> camera->SetDebugNavigationMode(true);<br /> <br /> //Create the ground<br /> Model* ground = Model::Box(10,1,10);<br /> ground->SetPosition(0,-0.5,0);<br /> ground->SetColor(0.0,0.25,0.0);<br /> <br /> //Create a shape<br /> Shape* shape = Shape::Box(0,0,0, 0,0,0, 10,1,10);<br /> ground->SetShape(shape);<br /> shape->Release();<br /> <br /> //Create a model<br /> //This is an obstacle the player will walk around<br /> entity = Model::Box(1,1,3);<br /> entity->SetColor(0.0,0.0,1.0);<br /> entity->SetPosition(0,5,0);<br /> entity->SetMass(1);<br /> <br /> //Create a shape<br /> shape = Shape::Box(0,0,0,0,0,0,1,1,3);<br /> entity->SetShape(shape);<br /> shape->Release();<br /> <br /> //Enable navigation obstacles<br /> ground->SetNavigationMode(true);<br /> entity->SetNavigationMode(true);<br /> <br /> //Create a character<br /> player = Pivot::Create();<br /> Entity* visiblecapsule = Model::Cylinder(16,player);<br /> visiblecapsule->SetScale(1,2,1);<br /> visiblecapsule->SetPosition(0,1,0);<br /> player->SetPosition(-4,0,0);<br /> player->SetMass(1);<br /> player->SetPhysicsMode(Entity::CharacterPhysics);<br /> <br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /> <br /> if (player) player->GoToPoint(4,0,0,1.4,1);<br /> <br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> <br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("NavMode: "+String(entity->GetNavigationMode()),2,2);<br /> <br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-8)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Enable navmesh debugging<br /> camera:SetDebugNavigationMode(true)<br /> <br /> --Create the ground<br /> local ground = Model:Box(10,1,10)<br /> ground:SetPosition(0,-0.5,0)<br /> ground:SetColor(0.0,0.25,0.0)<br /> <br /> --Create a shape<br /> local shape = Shape:Box(0,0,0, 0,0,0, 10,1,10)<br /> ground:SetShape(shape)<br /> shape:Release()<br /> <br /> --Create a model<br /> --This is an obstacle the player will walk around<br /> self.entity = Model:Box(1,1,3)<br /> self.entity:SetColor(0.0,0.0,1.0)<br /> self.entity:SetPosition(0,5,0)<br /> self.entity:SetMass(1)<br /> <br /> --Create a shape<br /> local shape = Shape:Box(0,0,0,0,0,0,1,1,3)<br /> self.entity:SetShape(shape)<br /> shape:Release()<br /> <br /> --Enable navigation obstacles<br /> ground:SetNavigationMode(true)<br /> self.entity:SetNavigationMode(true)<br /> <br /> --Create a character<br /> self.player = Pivot:Create()<br /> local visiblecapsule = Model:Cylinder(16,self.player)<br /> visiblecapsule:SetScale(1,2,1)<br /> visiblecapsule:SetPosition(0,1,0)<br /> self.player:SetPosition(-4,0,0)<br /> self.player:SetMass(1)<br /> self.player:SetPhysicsMode(Entity.CharacterPhysics)<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /> <br /> if (self.player) then self.player:GoToPoint(4,0,0,1.4,1) end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.context:SetBlendMode(Blend.Alpha)<br /> self.context:DrawText("NavMode: ".. tostring(self.entity:GetNavigationMode()),2,2)<br /><br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,307 views
  30. Entity::GetOcclusionCullingMode

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Model* model = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->Move(0,0,-3);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create a model to act as an occluder<br /> model = Model::Box();<br /> model->SetScale(2);<br /> model->SetColor(0.0,0.0,1.0);<br /> <br /> //Create a model to test the visibility of<br /> model = Model::Box();<br /> model->SetColor(0.0,1.0,0.0);<br /> model->SetPosition(0,0,6);<br /> <br /> //Enable individual entity occlusion culling. Normally we would not do this<br /> //because the occlusion test is as expensive as just rendering the object.<br /> //A courser occlusion culling system is always active in the world octree.<br /> model->SetOcclusionCullingMode(true);<br /> <br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /> <br /> model->SetPosition(Math::Sin(Time::GetCurrent()/20.0)*4.0,0,4);<br /> <br /> if (window->KeyHit(Key::Space))<br /> {<br /> model->SetOcclusionCullingMode(!model->GetOcclusionCullingMode());<br /> }<br /> <br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> <br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("Culled: "+String(model->GetCulled(camera)),2,2);<br /> context->DrawText("Occlusion culling mode: "+String(model->GetOcclusionCullingMode()),2,22);<br /> <br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> self.camera = Camera:Create()<br /> self.camera:Move(0,0,-3)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create a model to act as an occluder<br /> local model = Model:Box()<br /> model:SetScale(2)<br /> model:SetColor(0.0,0.0,1.0)<br /> <br /> --Create a model to test the visibility of<br /> self.model = Model:Box()<br /> self.model:SetColor(0.0,1.0,0.0)<br /> self.model:SetPosition(0,0,6)<br /> <br /> --Enable individual entity occlusion culling. Normally we would not do this<br /> --because the occlusion test is as expensive as just rendering the object.<br /> --A courser occlusion culling system is always active in the world octree.<br /> self.model:SetOcclusionCullingMode(true)<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /> <br /><br /> self.model:SetPosition(Math:Sin(Time:GetCurrent()/20.0)*4.0,0,4)<br /> <br /> if (self.window:KeyHit(Key.Space)) then<br /> <br /> self.model:SetOcclusionCullingMode(not self.model:GetOcclusionCullingMode())<br /> end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.context:SetBlendMode(Blend.Alpha)<br /> self.context:DrawText("Culled: "..tostring(self.model:GetCulled(self.camera)),2,2)<br /> self.context:DrawText("Occlusion culling mode: "..tostring(self.model:GetOcclusionCullingMode()),2,22)<br /><br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,287 views
  31. Entity::GetParent

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Entity* entity = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(35,0,0);<br /> camera->Move(0,0,-4);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create a model<br /> entity = Model::Box();<br /> <br /> Entity* child = Model::Box(1,1,1,entity);<br /> child->SetColor(1.0,0.0,0.0);<br /> child->SetPosition(2,-2,0);<br /><br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /><br /> entity->Turn(1.0*Time::GetSpeed(),2.0*Time::GetSpeed(),3.0*Time::GetSpeed());<br /><br /> //Get the entity child<br /> Entity* child = entity->GetChild(0);<br /><br /> //Confirm the child's parent is the entity<br /> Debug::Assert(child->GetParent()==entity);<br /><br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-3)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Load a model<br /> self.entity = Model:Box()<br /> <br /> local child = Model:Box(1,1,1,self.entity)<br /> child:SetColor(1.0,0.0,0.0)<br /> child:SetPosition(2,-2,0)<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.entity:Turn(1.0*Time:GetSpeed(),2.0*Time:GetSpeed(),3.0*Time:GetSpeed())<br /><br /> local child = self.entity:GetChild(0)<br /><br /> --Confirm the child's parent is the entity<br /> Debug:Assert(child:GetParent()==self.entity)<br /><br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,606 views
  32. Entity::GetPhysicsMode

    Attachments: Show TOC: False
    • 0 comments
    • 979 views
  33. Entity::GetPickMode

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->Move(0, 0, -8);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35, 35, 0);<br /><br /> //Create a model<br /> Model* model1 = Model::Box();<br /> model1->SetPosition(2, 0, 0);<br /><br /> Model* model2 = Model::Box();<br /> model2->SetPosition(-2, 0, 0);<br /> model2->SetPickMode(0);// Disable picking on the first hit entity<br /><br /> //Create a sphere to indicate where the pick hits<br /> Model* picksphere = Model::Sphere();<br /> picksphere->SetColor(1.0, 0.0, 0.0);<br /> picksphere->SetPickMode(0);<br /><br /> float pickradius = 0.5;<br /> picksphere->SetScale(pickradius*2.0);<br /><br /> world->Update();<br /> PickInfo pickinfo;<br /> if (world->Pick(-10, 0.75, 0, 10, 0.75, 0, pickinfo, pickradius, true))<br /> {<br /> picksphere->SetPosition(pickinfo.position);<br /><br /> //Make sure the pick mode equals Entity::PolygonPick<br /> Debug::Assert(pickinfo.entity->GetPickMode() == Entity::PolygonPick);<br /> }<br /> else<br /> {<br /> picksphere->Release();<br /> }<br /><br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> context->Sync();<br /><br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-8)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /><br /> --Create a model<br /> local model1 = Model:Box() <br /> model1:SetPosition(2,0,0) <br /><br /> local model2 = Model:Box() <br /> model2:SetPosition(-2,0,0) <br /> model2:SetPickMode(0) -- Disable picking on the first hit entity<br /><br /> --Create a sphere to indicate where the pick hits<br /> local picksphere = Model:Sphere() <br /> picksphere:SetColor(1.0,0.0,0.0) <br /> picksphere:SetPickMode(0) <br /><br /> local pickradius = 0.5 <br /> picksphere:SetScale(pickradius*2.0) <br /><br /> self.world:Update() <br /> local pickinfo = PickInfo() <br /> if (self.world:Pick(-10,0.75,0,10,0.75,0,pickinfo,pickradius,true)) then<br /> <br /> picksphere:SetPosition(pickinfo.position) <br /><br /> --Make sure the pick mode equals Entity:PolygonPick<br /> Debug:Assert(pickinfo.entity:GetPickMode()==Entity.PolygonPick) <br /> <br /> else<br /> <br /> picksphere:Release() <br /> end<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,254 views
  34. Entity::GetPickRadius

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->Move(0,0,-8);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> camera->SetProjectionMode(2);<br /> camera->SetZoom(50);<br /><br /> //Create a model<br /> float spherescale = 3.6;<br /> Model* model = Model::Sphere();<br /> model->SetPickMode(Entity::SpherePick);<br /> model->SetPickRadius(spherescale/2.0);<br /> model->SetScale(model->GetPickRadius()*2.0);<br /> <br /> //Create a sphere to indicate where the pick hits<br /> Model* picksphere = Model::Sphere();<br /> picksphere->SetColor(1.0,0.0,0.0);<br /> picksphere->SetPickMode(0);<br /><br /> float pickradius = 0.25;<br /> picksphere->SetScale(pickradius*2.0);<br /><br /> PickInfo pickinfo;<br /> if (world->Pick(-10,1,0,10,1,0,pickinfo,pickradius,true))<br /> {<br /> picksphere->SetPosition(pickinfo.position);<br /> }<br /> else<br /> {<br /> picksphere->Release();<br /> }<br /><br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-8)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> camera:SetProjectionMode(2) <br /> camera:SetZoom(50) <br /><br /> --Create a model<br /> local spherescale = 3.6 <br /> local model = Model:Sphere() <br /> model:SetPickMode(Entity.SpherePick) <br /> model:SetPickRadius(spherescale/2.0) <br /> model:SetScale(model:GetPickRadius()*2.0) <br /> <br /> --Create a sphere to indicate where the pick hits<br /> local picksphere = Model:Sphere() <br /> picksphere:SetColor(1.0,0.0,0.0) <br /> picksphere:SetPickMode(0) <br /><br /> local pickradius = 0.25 <br /> picksphere:SetScale(pickradius*2.0) <br /><br /> local pickinfo = PickInfo()<br /> if (self.world:Pick(Vec3(-10,1,0),Vec3(10,1,0),pickinfo,pickradius,true)) then<br /> <br /> picksphere:SetPosition(pickinfo.position) <br /> else<br /> <br /> picksphere:Release() <br /> end<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,064 views
  35. Entity::GetPosition

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Model* model = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(35,0,0);<br /> camera->Move(0,0,-4);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create a model<br /> model = Model::Box();<br /> <br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> model->SetPosition(Math::Sin(Time::GetCurrent()/10.0),0,0);<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /><br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText(model->GetPosition().ToString(),2,2);<br /><br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-6)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create a model<br /> self.model = Model:Box()<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> self.model:SetPosition(Math:Sin(Time:GetCurrent()/10.0),0,0);<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.context:SetBlendMode(Blend.Alpha)<br /> self.context:DrawText(self.model:GetPosition():ToString(),2,2)<br /><br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 2,897 views
  36. Entity::GetQuaternion

    Attachments: Show TOC: False
    • 0 comments
    • 666 views
  37. Entity::GetRotation

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Entity* entity = NULL;<br />Vec3 rotation;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(35,0,0);<br /> camera->Move(0,0,-6);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create a model<br /> entity = Model::Box();<br /> entity->SetColor(0.0,0.0,1.0);<br /> <br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /> <br /> rotation.y += Time::GetSpeed();<br /> entity->SetRotation(rotation);<br /> <br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> <br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("Rotation: "+entity->GetRotation().ToString(),2,2);<br /> <br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: rotation = Vec3()<br /><br />function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-6)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create a model<br /> self.entity = Model:Box()<br /> self.entity:SetColor(0.0,0.0,1.0)<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> rotation.y = rotation.y + Time:GetSpeed()<br /> self.entity:SetRotation(rotation);<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.context:SetBlendMode(Blend.Alpha)<br /> self.context:DrawText("Rotation: "..self.entity:GetRotation():ToString(),2,2)<br /><br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 1 comment
    • 2,115 views
  38. Entity::GetScale

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Entity* entity = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(35,0,0);<br /> camera->Move(0,0,-6);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create a model<br /> entity = Model::Box();<br /> entity->SetColor(0.0,0.0,1.0);<br /> <br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /> <br /> entity->SetScale(sin(Time::GetCurrent()/100.0)*0.5+0.75);<br /> <br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> <br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("Scale: "+entity->GetScale().ToString(),2,2);<br /> <br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-6)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create a model<br /> self.entity = Model:Box()<br /> self.entity:SetColor(0.0,0.0,1.0)<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> self.entity:SetScale(Math:Sin(Time:GetCurrent()/100.0)*0.5+0.75)<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.context:SetBlendMode(Blend.Alpha)<br /> self.context:DrawText("Scale: "..self.entity:GetScale():ToString(),2,2)<br /><br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 979 views
  39. Entity::GetShape

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Entity* entity = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(35,0,0);<br /> camera->Move(0,0,-8);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create a model<br /> entity = Model::Box(1,1,1);<br /> entity->SetColor(0.0,0.0,1.0);<br /> <br /> Shape* shape = Shape::Box();<br /> entity->SetShape(shape);<br /> Debug::Assert(entity->GetShape()==shape);<br /> shape->Release();<br /><br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /> <br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-8)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create a model<br /> local entity = Model:Box(1,1,1)<br /> entity:SetColor(0.0,0.0,1.0)<br /> <br /> local shape = Shape:Box()<br /> entity:SetShape(shape)<br /> Debug:Assert(entity:GetShape()==shape)<br /> shape:Release()<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,032 views
  40. Entity::GetSweptCollisionMode

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Entity* entity1 = NULL;<br />Entity* entity2 = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(15,0,0);<br /> camera->Move(0,0,-8);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create the ground<br /> Model* ground = Model::Box(10,0.1,10);<br /> ground->SetColor(0.0,1.0,0.0);<br /><br /> //Create a shape<br /> Shape* shape = Shape::Box(0,0,0, 0,0,0, 10,0.1,10);<br /> ground->SetShape(shape);<br /> shape->Release();<br /><br /> //Create a model<br /> entity1 = Model::Box();<br /> entity1->SetScale(1,0.1,4);<br /> entity1->SetColor(0.0,0.0,1.0);<br /> entity1->SetPosition(-2,5,0);<br /> entity1->SetMass(1);<br /> entity1->AddForce(0,-1000,0);<br /> <br /> //Create a shape<br /> shape = Shape::Box();<br /> entity1->SetShape(shape);<br /> shape->Release();<br /><br /> //Create a second model<br /> entity2 = entity1->Instance();<br /> entity2->SetPosition(2,5,0);<br /> entity2->SetSweptCollisionMode(true);<br /> entity2->AddForce(0,-1000,0);<br /><br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /><br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("entity1 swept collision mode: "+String(entity1->GetSweptCollisionMode()),2,2);<br /> context->DrawText("entity2 swept collision mode: "+String(entity2->GetSweptCollisionMode()),2,22);<br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-8)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create the ground<br /> local ground = Model:Box(10,0.1,10) <br /> ground:SetColor(0.0,1.0,0.0) <br /><br /> --Create a shape<br /> local shape = Shape:Box(0,0,0, 0,0,0, 10,0.1,10) <br /> ground:SetShape(shape) <br /> shape:Release() <br /><br /> --Create a model<br /> self.entity1 = Model:Box() <br /> self.entity1:SetScale(1,0.1,4) <br /> self.entity1:SetColor(0.0,0.0,1.0) <br /> self.entity1:SetPosition(-2,5,0) <br /> self.entity1:SetMass(1) <br /> self.entity1:AddForce(0,-1000,0) <br /> <br /> --Create a shape<br /> shape = Shape:Box() <br /> self.entity1:SetShape(shape) <br /> shape:Release() <br /><br /> --Create a second model<br /> self.entity2 = self.entity1:Instance() <br /> self.entity2:SetPosition(2,5,0) <br /> self.entity2:SetSweptCollisionMode(true) <br /> self.entity2:AddForce(0,-1000,0) <br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.context:SetBlendMode(Blend.Alpha) <br /> self.context:DrawText("self.entity1 swept collision mode: "..tostring(self.entity1:GetSweptCollisionMode()),2,2) <br /> self.context:DrawText("self.entity2 swept collision mode: "..tostring(self.entity2:GetSweptCollisionMode()),2,22) <br /><br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,000 views
  41. Entity::GetVelocity

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Entity* entity = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(15,0,0);<br /> camera->Move(0,0,-8);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create the ground<br /> Model* ground = Model::Box(10,0.1,10);<br /> ground->SetColor(0.0,1.0,0.0);<br /><br /> //Create a shape<br /> Shape* shape = Shape::Box(0,0,0, 0,0,0, 10,0.1,10);<br /> ground->SetShape(shape);<br /> shape->Release();<br /><br /> //Create a model<br /> entity = Model::Box();<br /> entity->SetColor(0.0,0.0,1.0);<br /> entity->SetPosition(0,5,0);<br /> entity->SetMass(1);<br /> <br /> //Create a shape<br /> shape = Shape::Box();<br /> entity->SetShape(shape);<br /> shape->Release();<br /><br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /><br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("Velocity: "+entity->GetVelocity().ToString(),2,2);<br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-8)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create the ground<br /> local ground = Model:Box(10,1,10) <br /> ground:SetColor(0.0,1.0,0.0) <br /><br /> --Create a shape<br /> local shape = Shape:Box(0,0,0, 0,0,0, 10,1,10) <br /> ground:SetShape(shape) <br /> shape:Release() <br /><br /> --Create a model<br /> self.entity = Model:Box() <br /> self.entity:SetColor(0.0,0.0,1.0) <br /> self.entity:SetPosition(0,5,0) <br /> self.entity:SetMass(1) <br /> <br /> --Create a shape<br /> shape = Shape:Box() <br /> self.entity:SetShape(shape) <br /> shape:Release() <br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.context:SetBlendMode(Blend.Alpha) <br /> self.context:DrawText("Velocity: "..self.entity:GetVelocity():ToString(),2,2) <br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,567 views
  42. Entity::GetViewRange

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Entity* entity[3] = {NULL};<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->Move(0,2,0);<br /> camera->SetRotation(45,0,0);<br /> camera->Move(0,0,-8);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> Model* box = Model::Box();<br /><br /> for (int i=0; i<100; i++)<br /> {<br /> entity[0] = box->Instance();<br /> entity[0]->SetPosition(-5,1,i*10.0);<br /> entity[0]->SetViewRange(Entity::NearViewRange);<br /> entity[0]->SetColor(Math::Rnd(),Math::Rnd(),Math::Rnd());<br /> }<br /><br /> for (int i=0; i<100; i++)<br /> {<br /> entity[1] = box->Instance();<br /> entity[1]->SetPosition(0,1,i*10.0);<br /> entity[1]->SetViewRange(Entity::MediumViewRange);<br /> entity[1]->SetColor(Math::Rnd(),Math::Rnd(),Math::Rnd());<br /> }<br /><br /> for (int i=0; i<100; i++)<br /> {<br /> entity[2] = box->Instance();<br /> entity[2]->SetPosition(5,1,i*10.0);<br /> entity[2]->SetViewRange(Entity::FarViewRange);<br /> entity[2]->SetColor(Math::Rnd(),Math::Rnd(),Math::Rnd());<br /> }<br /><br /> box->Release();<br /><br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /><br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("Left row view range:"+String(entity[0]->GetViewRange()),2,2);<br /> context->DrawText("Center row view range:"+String(entity[1]->GetViewRange()),2,22);<br /> context->DrawText("Right row view range:"+String(entity[2]->GetViewRange()),2,42);<br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: entity = {}<br /><br />function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:Move(0,2,0)<br /> camera:SetRotation(45,0,0)<br /> camera:Move(0,0,-8) <br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> local box = Model:Box()<br /><br /> for i=0, 100 do <br /> <br /> entity[0] = box:Instance()<br /> entity[0]:SetPosition(-5,1,i*10.0)<br /> entity[0]:SetViewRange(Entity.NearViewRange)<br /> entity[0]:SetColor(Math:Random(),Math:Random(),Math:Random())<br /> end<br /><br /> for i=0, 100 do <br /> <br /> entity[1] = box:Instance()<br /> entity[1]:SetPosition(0,1,i*10.0)<br /> entity[1]:SetViewRange(Entity.MediumViewRange)<br /> entity[1]:SetColor(Math:Random(),Math:Random(),Math:Random())<br /> end<br /><br /> for i=0, 100 do <br /> <br /> entity[2] = box:Instance()<br /> entity[2]:SetPosition(5,1,i*10.0)<br /> entity[2]:SetViewRange(Entity.FarViewRange)<br /> entity[2]:SetColor(Math:Random(),Math:Random(),Math:Random())<br /> end<br /><br /> box:Release()<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.context:SetBlendMode(Blend.Alpha)<br /> self.context:DrawText("Left row view range:"..entity[0]:GetViewRange(),2,2)<br /> self.context:DrawText("Center row view range:"..entity[1]:GetViewRange(),2,22)<br /> self.context:DrawText("Right row view range:"..entity[2]:GetViewRange(),2,42)<br /><br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,078 views
  43. Entity::GoToPoint

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Entity* entity = NULL;<br />Entity* player = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(35,0,0);<br /> camera->Move(0,0,-8);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Enable navmesh debugging<br /> camera->SetDebugNavigationMode(true);<br /> <br /> //Create the ground<br /> Model* ground = Model::Box(10,1,10);<br /> ground->SetPosition(0,-0.5,0);<br /> ground->SetColor(0.0,0.25,0.0);<br /> <br /> //Create a shape<br /> Shape* shape = Shape::Box(0,0,0, 0,0,0, 10,1,10);<br /> ground->SetShape(shape);<br /> shape->Release();<br /> <br /> //Create a model<br /> //This is an obstacle the player will walk around<br /> entity = Model::Box(1,1,3);<br /> entity->SetColor(0.0,0.0,1.0);<br /> entity->SetPosition(0,0.5,0);<br /> <br /> //Create a shape<br /> shape = Shape::Box(0,0,0,0,0,0,1,1,3);<br /> entity->SetShape(shape);<br /> shape->Release();<br /> <br /> //Enable navigation obstacles<br /> ground->SetNavigationMode(true);<br /> entity->SetNavigationMode(true);<br /> <br /> //Build the navigation mesh<br /> world->BuildNavMesh();<br /><br /> //Create a character<br /> player = Pivot::Create();<br /> Entity* visiblecapsule = Model::Cylinder(16,player);<br /> visiblecapsule->SetScale(1,2,1);<br /> visiblecapsule->SetPosition(0,1,0);<br /> player->SetPosition(-4,0,0);<br /> player->SetMass(1);<br /> player->SetPhysicsMode(Entity::CharacterPhysics);<br /> <br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /> <br /> if (player) player->GoToPoint(4,0,0,1.4,1);<br /> <br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> <br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("NavMode: "+String(entity->GetNavigationMode()),2,2);<br /> <br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: --Create a window<br />window = Window:Create()<br /><br />--Create a rendering context<br />context = Context:Create(window)<br /><br />--Create a world<br />world = World:Create()<br /><br />--Create a camera<br />local camera = Camera:Create()<br />camera:SetRotation(35,0,0)<br />camera:Move(0,0,-8)<br /><br />--Create a light<br />local light = DirectionalLight:Create()<br />light:SetRotation(35,35,0)<br /><br />--Enable navmesh debugging<br />camera:SetDebugNavigationMode(true)<br /><br />--Create the ground<br />local ground = Model:Box(10,1,10)<br />ground:SetPosition(0,-0.5,0)<br />ground:SetColor(0.0,0.25,0.0)<br /><br />--Create a shape<br />local shape = Shape:Box(0,0,0, 0,0,0, 10,1,10)<br />ground:SetShape(shape)<br />shape:Release()<br /><br />--Create a model<br />--This is an obstacle the player will walk around<br />entity = Model:Box(1,1,3)<br />entity:SetColor(0.0,0.0,1.0)<br />entity:SetPosition(0,0.5,0)<br /><br />--Create a shape<br />local shape = Shape:Box(0,0,0,0,0,0,1,1,3)<br />entity:SetShape(shape)<br />shape:Release()<br /><br />--Enable navigation obstacles<br />ground:SetNavigationMode(true)<br />entity:SetNavigationMode(true)<br /><br />--Build the navigation mesh<br />world:BuildNavMesh()<br /><br />--Create a character<br />player = Pivot:Create()<br />local visiblecapsule = Model:Cylinder(16,player)<br />visiblecapsule:SetScale(1,2,1)<br />visiblecapsule:SetPosition(0,1,0)<br />player:SetPosition(-4,0,0)<br />player:SetMass(1)<br />player:SetPhysicsMode(Entity.CharacterPhysics)<br /><br />while window:KeyHit(Key.Escape)==false do<br /><br /> if window:Closed() then break end<br /> <br /> if (player) then player:GoToPoint(4,0,0,1.4,1) end<br /><br /> Time:Update()<br /> world:Update()<br /> world:Render()<br /><br /> context:SetBlendMode(Blend.Alpha)<br /> context:DrawText("NavMode: ".. tostring(entity:GetNavigationMode()),2,2)<br /><br /> context:Sync()<br />end Main.lua: --Create a window<br />window = Window:Create()<br /><br />--Create a rendering context<br />context = Context:Create(window)<br /><br />--Create a world<br />world = World:Create()<br /><br />--Create a camera<br />local camera = Camera:Create()<br />camera:SetRotation(35,0,0)<br />camera:Move(0,0,-8)<br /><br />--Create a light<br />local light = DirectionalLight:Create()<br />light:SetRotation(35,35,0)<br /><br />--Enable navmesh debugging<br />camera:SetDebugNavigationMode(true)<br /><br />--Create the ground<br />local ground = Model:Box(10,1,10)<br />ground:SetPosition(0,-0.5,0)<br />ground:SetColor(0.0,0.25,0.0)<br /><br />--Create a shape<br />local shape = Shape:Box(0,0,0, 0,0,0, 10,1,10)<br />ground:SetShape(shape)<br />shape:Release()<br /><br />--Create a model<br />--This is an obstacle the player will walk around<br />entity = Model:Box(1,1,3)<br />entity:SetColor(0.0,0.0,1.0)<br />entity:SetPosition(0,0.5,0)<br /><br />--Create a shape<br />local shape = Shape:Box(0,0,0,0,0,0,1,1,3)<br />entity:SetShape(shape)<br />shape:Release()<br /><br />--Enable navigation obstacles<br />ground:SetNavigationMode(true)<br />entity:SetNavigationMode(true)<br /><br />--Build the navigation mesh<br />world:BuildNavMesh()<br /><br />--Create a character<br />player = Pivot:Create()<br />local visiblecapsule = Model:Cylinder(16,player)<br />visiblecapsule:SetScale(1,2,1)<br />visiblecapsule:SetPosition(0,1,0)<br />player:SetPosition(-4,0,0)<br />player:SetMass(1)<br />player:SetPhysicsMode(Entity.CharacterPhysics)<br /><br />while window:KeyHit(Key.Escape)==false do<br /><br /> if window:Closed() then break end<br /> <br /> if (player) then player:GoToPoint(4,0,0,1.4,1) end<br /><br /> Time:Update()<br /> world:Update()<br /> world:Render()<br /><br /> context:SetBlendMode(Blend.Alpha)<br /> context:DrawText("NavMode: ".. tostring(entity:GetNavigationMode()),2,2)<br /><br /> context:Sync()<br />end Show TOC: False
    • 2 comments
    • 4,423 views
  44. Entity::Hidden

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Model* model = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->Move(0,0,-3);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> model = Model::Box();<br /> model->SetColor(0.0,0.0,1.0);<br /><br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /><br /> model->Turn(0,Time::GetSpeed(),0);<br /><br /> if (window->KeyHit(Key::Space))<br /> {<br /> if (model->Hidden())<br /> {<br /> model->Show();<br /> }<br /> else<br /> {<br /> model->Hide();<br /> }<br /> }<br /> <br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("Press space to change.",2,2);<br /> context->DrawText("Hidden:"+String(model->Hidden()),2,22);<br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: entity = {}<br /><br />function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:Move(0,0,-3) <br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> self.model = Model:Box()<br /> self.model:SetColor(0.0,0.0,1.0)<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> self.model:Turn(0,Time:GetSpeed(),0)<br /><br /> if (self.window:KeyHit(Key.Space)) then<br /> <br /> if (self.model:Hidden()) then <br /> self.model:Show()<br /> else<br /> self.model:Hide()<br /> end<br /> end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.context:SetBlendMode(Blend.Alpha)<br /> self.context:DrawText("Press space to change.",2,2)<br /> self.context:DrawText("Hidden:"..tostring(self.model:Hidden()),2,22)<br /><br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,368 views
  45. Entity::Hide

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Model* model = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->Move(0,0,-3);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> model = Model::Box();<br /> model->SetColor(0.0,0.0,1.0);<br /><br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /><br /> model->Turn(0,Time::GetSpeed(),0);<br /><br /> if (window->KeyHit(Key::Space))<br /> {<br /> if (model->Hidden())<br /> {<br /> model->Show();<br /> }<br /> else<br /> {<br /> model->Hide();<br /> }<br /> }<br /> <br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("Press space to change.",2,2);<br /> context->DrawText("Hidden:"+String(model->Hidden()),2,22);<br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: entity = {}<br /><br />function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:Move(0,0,-3) <br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> self.model = Model:Box()<br /> self.model:SetColor(0.0,0.0,1.0)<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> self.model:Turn(0,Time:GetSpeed(),0)<br /><br /> if (self.window:KeyHit(Key.Space)) then<br /> <br /> if (self.model:Hidden()) then <br /> self.model:Show()<br /> else<br /> self.model:Hide()<br /> end<br /> end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.context:SetBlendMode(Blend.Alpha)<br /> self.context:DrawText("Press space to change.",2,2)<br /> self.context:DrawText("Hidden:"..tostring(self.model:Hidden()),2,22)<br /><br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 2,100 views
  46. Entity::Instance

    Attachments: Show TOC: False
    • 0 comments
    • 1,845 views
  47. Entity::LoadAnimation

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Model* model = NULL;<br />int animationsequence;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->Move(0,1,-3);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Load a model<br /> model = Model::Load("Models/Characters/Barbarian/barbarian.mdl");<br /> <br /> //Load an animation onto the model<br /> animationsequence = model->LoadAnimation("Models/Characters/Barbarian/barbarian_walk.mdl");<br /><br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> //Play animation<br /> if (animationsequence>-1) model->SetAnimationFrame(Time::GetCurrent()/100.0,1,animationsequence);<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-3)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Load a model<br /> self.model = Model:Load("Models/Characters/Barbarian/barbarian.mdl")<br /><br /> --Load an animation onto the model<br /> self.animationsequence = self.model:LoadAnimation("Models/Characters/Barbarian/barbarian@walk.mdl")<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> --Play animation<br /> if (self.animationsequence>-1) then <br /> self.model:SetAnimationFrame(Time:GetCurrent()/50.0,1,self.animationsequence) <br /> end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,673 views
  48. Entity::LockMatrix

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Model* model = NULL;<br />int counter;<br /><br />void UpdateMatrixHook(Entity* entity)<br />{<br /> counter++;<br />}<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->Move(0,1,-3);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Load a model<br /> model = Model::Load("Models/Characters/Barbarian/barbarian.mdl");<br /> model->AddHook(Entity::UpdateMatrixHook,UpdateMatrixHook);<br /> <br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> counter=0;<br /><br /> //We're going to make a lot of changes to the entity orientation, but the expensive update<br /> //stuff will only occur once per loop when we call Entity::UnlockMatrix()<br /> bool mode = !window->KeyDown(Key::Space);<br /> if (mode) model->LockMatrix();<br /> model->SetAnimationFrame(Time::GetCurrent()/100.0,1);<br /> model->SetAnimationFrame(Time::GetCurrent()/100.0,0.5,1);<br /> model->SetAnimationFrame(Time::GetCurrent()/100.0,0.5,2);<br /> if (mode) model->UnlockMatrix();<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /><br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("UpdateMatrixHook was called "+String(counter)+" times.",2,2);<br /> context->DrawText("Hold space for slower mode.",2,22);<br /><br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> self.camera = Camera:Create()<br /> self.camera:Move(0,1,-3)<br /> self.light = DirectionalLight:Create()<br /> self.light:SetRotation(35,35,0)<br /> <br /> --Load a model<br /> self.model = Model:Load("Models/Characters/Barbarian/barbarian.mdl")<br /> <br /> return true<br />end<br /><br />function App:Loop()<br /> if self.window:Closed() or self.window:KeyDown(Key.Escape) then return false end<br /><br /> --We're going to make a lot of changes to the entity orientation, but the expensive update<br /> --stuff will only occur once per loop when we call Entity::UnlockMatrix()<br /> self.model:LockMatrix()<br /> self.model:SetAnimationFrame(Time:GetCurrent()/100.0,1)<br /> self.model:SetAnimationFrame(Time:GetCurrent()/100.0,0.5,1)<br /> self.model:SetAnimationFrame(Time:GetCurrent()/100.0,0.5,2)<br /> self.model:UnlockMatrix()<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,055 views
  49. Entity::Move

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Model* model = NULL;<br />int counter;<br /><br />void UpdateMatrixHook(Entity* entity)<br />{<br /> counter++;<br />}<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->Move(0,1,-3);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create a model<br /> model = Model::Box();<br /> model->SetColor(0.0,0.0,1.0);<br /> model->SetRotation(0,-90,0);<br /><br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> //Make the model move in a circle<br /> model->Turn(0,Time::GetSpeed()*0.5,0);<br /> model->Move(0,0,0.1);<br /> <br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-6)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create a model<br /> self.model = Model:Box()<br /> self.model:SetColor(0.0,0.0,1.0)<br /> self.model:SetRotation(0,-90,0)<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> --Make the model move in a circle<br /> self.model:Turn(0,Time:GetSpeed()*0.5,0);<br /> self.model:Move(0,0,0.1);<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 3,414 views
  50. Entity::PhysicsSetPosition

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Model* model = NULL;<br />Vec3 pos;<br />Vec3 rot;<br />Vec3 mousepos;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->Move(0,1,-5);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create a model<br /> model = Model::Box(1,1,1);<br /> model->SetColor(0.0,0.0,1.0);<br /> model->SetMass(1);<br /><br /> //Add a physics shape<br /> Shape* shape = Shape::Box();<br /> model->SetShape(shape);<br /> <br /> mousepos = window->GetMousePosition();<br /><br /> rot = Vec3(45,0,0);<br /><br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> mousepos = window->GetMousePosition();<br /> mousepos.z=5;<br /> pos = camera->UnProject(mousepos);<br /><br /> float turnspeed=2;<br /> if (window->KeyDown(Key::Up)) rot.x+=turnspeed*Time::GetSpeed();<br /> if (window->KeyDown(Key::Down)) rot.x-=turnspeed*Time::GetSpeed();<br /> if (window->KeyDown(Key::Right)) rot.y+=turnspeed*Time::GetSpeed();<br /> if (window->KeyDown(Key::Left)) rot.y-=turnspeed*Time::GetSpeed();<br /> <br /> model->PhysicsSetPosition(pos.x,pos.y,pos.z,0.5);<br /> model->PhysicsSetRotation(rot.x,rot.y,rot.z,0.5);<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> context->Sync();<br /> <br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("Mouse moves the object",2,2);<br /> context->DrawText("Arrow keys turn the object",2,2);<br /><br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> self.camera = Camera:Create()<br /> self.camera:SetRotation(35,0,0)<br /> self.camera:Move(0,0,-8)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /><br /> --Create a model<br /> self.model = Model:Box(1,1,1) <br /> self.model:SetColor(0.0,0.0,1.0) <br /> self.model:SetMass(1) <br /><br /> --Add a physics shape<br /> local shape = Shape:Box() <br /> self.model:SetShape(shape) <br /> <br /> self.mousepos = self.window:GetMousePosition() <br /><br /> self.rot = Vec3(45,0,0) <br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> self.mousepos = self.window:GetMousePosition() <br /> self.mousepos.z=5 <br /> local pos = self.camera:UnProject(self.mousepos) <br /><br /> local turnspeed=2 <br /> if (self.window:KeyDown(Key.Up)) then self.rot.x=self.rot.x+turnspeed*Time:GetSpeed() end<br /> if (self.window:KeyDown(Key.Down)) then self.rot.x=self.rot.x-turnspeed*Time:GetSpeed() end<br /> if (self.window:KeyDown(Key.Right)) then self.rot.y=self.rot.y+turnspeed*Time:GetSpeed() end <br /> if (self.window:KeyDown(Key.Left)) then self.rot.y=self.rot.y-turnspeed*Time:GetSpeed() end<br /> <br /> self.model:PhysicsSetPosition(pos.x,pos.y,pos.z,0.5) <br /> self.model:PhysicsSetRotation(self.rot.x,self.rot.y,self.rot.z,0.5) <br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 2,086 views
  51. Entity::PhysicsSetRotation

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Model* model = NULL;<br />Vec3 pos;<br />Vec3 rot;<br />Vec3 mousepos;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->Move(0,1,-5);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create a model<br /> model = Model::Box(1,1,1);<br /> model->SetColor(0.0,0.0,1.0);<br /> model->SetMass(1);<br /><br /> //Add a physics shape<br /> Shape* shape = Shape::Box();<br /> model->SetShape(shape);<br /> <br /> mousepos = window->GetMousePosition();<br /><br /> rot = Vec3(45,0,0);<br /><br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> mousepos = window->GetMousePosition();<br /> mousepos.z=5;<br /> pos = camera->UnProject(mousepos);<br /><br /> float turnspeed=2;<br /> if (window->KeyDown(Key::Up)) rot.x+=turnspeed*Time::GetSpeed();<br /> if (window->KeyDown(Key::Down)) rot.x-=turnspeed*Time::GetSpeed();<br /> if (window->KeyDown(Key::Right)) rot.y+=turnspeed*Time::GetSpeed();<br /> if (window->KeyDown(Key::Left)) rot.y-=turnspeed*Time::GetSpeed();<br /> <br /> model->PhysicsSetPosition(pos.x,pos.y,pos.z,0.5);<br /> model->PhysicsSetRotation(rot.x,rot.y,rot.z,0.5);<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> context->Sync();<br /> <br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("Mouse moves the object",2,2);<br /> context->DrawText("Arrow keys turn the object",2,2);<br /><br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> self.camera = Camera:Create()<br /> self.camera:SetRotation(35,0,0)<br /> self.camera:Move(0,0,-8)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /><br /> --Create a model<br /> self.model = Model:Box(1,1,1) <br /> self.model:SetColor(0.0,0.0,1.0) <br /> self.model:SetMass(1) <br /><br /> --Add a physics shape<br /> local shape = Shape:Box() <br /> self.model:SetShape(shape) <br /> <br /> self.mousepos = self.window:GetMousePosition() <br /><br /> self.rot = Vec3(45,0,0) <br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> self.mousepos = self.window:GetMousePosition() <br /> self.mousepos.z=5 <br /> local pos = self.camera:UnProject(self.mousepos) <br /><br /> local turnspeed=2 <br /> if (self.window:KeyDown(Key.Up)) then self.rot.x=self.rot.x+turnspeed*Time:GetSpeed() end<br /> if (self.window:KeyDown(Key.Down)) then self.rot.x=self.rot.x-turnspeed*Time:GetSpeed() end<br /> if (self.window:KeyDown(Key.Right)) then self.rot.y=self.rot.y+turnspeed*Time:GetSpeed() end <br /> if (self.window:KeyDown(Key.Left)) then self.rot.y=self.rot.y-turnspeed*Time:GetSpeed() end<br /> <br /> self.model:PhysicsSetPosition(pos.x,pos.y,pos.z,0.5) <br /> self.model:PhysicsSetRotation(self.rot.x,self.rot.y,self.rot.z,0.5) <br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 2,159 views
  52. Entity::Pick

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->Move(0,0,-8);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> camera->SetProjectionMode(2);<br /> camera->SetZoom(50);<br /><br /> //Create a model<br /> float spherescale = 3.6;<br /> Model* model = Model::Sphere();<br /> model->SetPickMode(Entity::SpherePick);<br /> model->SetPickRadius(spherescale/2.0);<br /> model->SetScale(model->GetPickRadius()*2.0);<br /> <br /> //Create a sphere to indicate where the pick hits<br /> Model* picksphere = Model::Sphere();<br /> picksphere->SetColor(1.0,0.0,0.0);<br /> picksphere->SetPickMode(0);<br /><br /> float pickradius = 0.25;<br /> picksphere->SetScale(pickradius*2.0);<br /><br /> PickInfo pickinfo;<br /> if (model->Pick(Vec3(-10,1,0),Vec3(10,1,0),pickinfo,pickradius,true))<br /> {<br /> picksphere->SetPosition(pickinfo.position);<br /> }<br /> else<br /> {<br /> picksphere->Release();<br /> }<br /><br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-8)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> camera:SetProjectionMode(2) <br /> camera:SetZoom(50) <br /><br /> --Create a model<br /> local spherescale = 3.6 <br /> local model = Model:Sphere() <br /> model:SetPickMode(Entity.SpherePick) <br /> model:SetPickRadius(spherescale/2.0) <br /> model:SetScale(model:GetPickRadius()*2.0) <br /> <br /> --Create a sphere to indicate where the pick hits<br /> local picksphere = Model:Sphere() <br /> picksphere:SetColor(1.0,0.0,0.0) <br /> picksphere:SetPickMode(0) <br /><br /> local pickradius = 0.25 <br /> picksphere:SetScale(pickradius*2.0) <br /><br /> local pickinfo = PickInfo()<br /> if (self.world:Pick(Vec3(-10,1,0),Vec3(10,1,0),pickinfo,pickradius,true)) then<br /> <br /> picksphere:SetPosition(pickinfo.position) <br /> else<br /> <br /> picksphere:Release() <br /> end<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 2,685 views
  53. Entity::PlayAnimation

    Attachments: Lua Example: window = Window:Create()<br /><br />context = Context:Create(window)<br /><br />world = World:Create()<br /><br />camera = Camera:Create()<br />camera:Move(0,0.75,-2)<br /><br />light = DirectionalLight:Create()<br />light:SetRotation(35,35,0)<br /><br />--Load a model<br />model = Model:Load("Models/Characters/Crawler/crawler.mdl")<br /><br />--Play an animation<br />model:PlayAnimation("Run",0.05)<br /><br />while true do<br /> if window:Closed() or window:KeyHit(Key.Escape) then break end<br /> Time:Update()<br /> world:Update()<br /> world:Render()<br /> context:Sync()<br />end Show TOC: False
    • 3 comments
    • 1,005 views
  54. Entity::Point

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Entity* entity1 = NULL;<br />Entity* entity2 = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->Move(0,1,-3);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create a model<br /> entity1 = Model::Box();<br /> entity1->SetColor(0.0,0.0,1.0);<br /> entity1->SetRotation(0,-90,0);<br /> <br /> //Create another model to point at the one that goes in circles<br /> entity2 = Model::Box();<br /> entity2->SetColor(0.0,1.0,0.0);<br /> entity2->SetPosition(0,0,2);<br /> <br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /> <br /> //Make the model move in a circle<br /> entity1->Turn(0,Time::GetSpeed()*0.5,0);<br /> entity1->Move(0,0,0.1);<br /> <br /> //Point this at the moving box when the space key is pressed<br /> if (window->KeyDown(Key::Space))<br /> {<br /> entity2->Point(entity1,2,Time::GetSpeed()*0.1);<br /> }<br /> <br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-6)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create a model<br /> self.entity1 = Model:Box()<br /> self.entity1:SetColor(0.0,0.0,1.0)<br /> self.entity1:SetRotation(0,-90,0)<br /><br /> --Create another model to point at the one that goes in circles<br /> self.entity2 = Model:Box()<br /> self.entity2:SetColor(0.0,1.0,0.0)<br /> self.entity2:SetPosition(0,0,2)<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> --Make the model move in a circle<br /> self.entity1:Turn(0,Time:GetSpeed()*0.5,0);<br /> self.entity1:Move(0,0,0.1);<br /><br /> --Point this at the moving box when the space key is pressed<br /> if (self.window:KeyDown(Key.Space)) then<br /> self.entity2:Point(self.entity1,2,Time:GetSpeed()*0.1);<br /> end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 2,759 views
  55. Entity::PostRenderHook

    Attachments: Show TOC: False
    • 0 comments
    • 1,274 views
  56. Entity::SetAnimationFrame

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Model* model = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->Turn(0,90,0);<br /> camera->Move(0,1,-2);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Load a model<br /> model = Model::Load("Models/Characters/Crawler/crawler.mdl");<br /> <br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /> <br /> model->SetAnimationFrame(Time::GetCurrent()/100.0,1,2);<br /> <br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-3)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Load a model<br /> self.model = Model:Load("Models/Characters/Crawler/crawler.mdl")<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> self.model:SetAnimationFrame(Time:GetCurrent()/100.0,1,2)<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 2,388 views
  57. Entity::SetCollisionType

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Entity* entity1 = NULL;<br />Entity* entity2 = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(15,0,0);<br /> camera->Move(0,0,-8);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create the ground<br /> Model* ground = Model::Box(10,0.1,10);<br /> ground->SetColor(0.0,1.0,0.0);<br /> <br /> //Create a shape<br /> Shape* shape = Shape::Box(0,0,0, 0,0,0, 10,0.1,10);<br /> ground->SetShape(shape);<br /> shape->Release();<br /> <br /> //Create a model<br /> entity1 = Model::Box();<br /> entity1->SetColor(0.0,0.0,1.0);<br /> entity1->SetPosition(-2,5,0);<br /> entity1->SetMass(1);<br /> entity1->SetCollisionType(Collision::Prop);<br /> <br /> //Create a shape<br /> shape = Shape::Box();<br /> entity1->SetShape(shape);<br /> shape->Release();<br /> <br /> //Create a second model<br /> entity2 = entity1->Instance();<br /> entity2->SetPosition(2,5,0);<br /> entity2->SetCollisionType(Collision::None);<br /> <br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /> <br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> <br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("Entity 1 collision type: "+String(entity1->GetCollisionType()),2,2);<br /> context->DrawText("Entity 2 collision type: "+String(entity2->GetCollisionType()),2,22);<br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-8)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create the ground<br /> local ground = Model:Box(10,1,10) <br /> ground:SetColor(0.0,1.0,0.0) <br /> <br /> --Create a shape<br /> local shape = Shape:Box(0,0,0, 0,0,0, 10,1,10) <br /> ground:SetShape(shape) <br /> shape:Release() <br /> <br /> --Create a model<br /> self.entity1 = Model:Box() <br /> self.entity1:SetColor(0.0,0.0,1.0) <br /> self.entity1:SetPosition(-2,3,0) <br /> self.entity1:SetMass(1) <br /> self.entity1:SetCollisionType(Collision.Prop) <br /> <br /> --Create a shape<br /> shape = Shape:Box() <br /> self.entity1:SetShape(shape) <br /> shape:Release() <br /> <br /> --Create a second model<br /> self.entity2 = self.entity1:Instance() <br /> self.entity2:SetPosition(2,3,0) <br /> self.entity2:SetCollisionType(Collision.None) <br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.context:SetBlendMode(Blend.Alpha) <br /> self.context:DrawText("Entity 1 collision type: "..self.entity1:GetCollisionType(),2,2) <br /> self.context:DrawText("Entity 2 collision type: "..self.entity2:GetCollisionType(),2,22) <br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 2,728 views
  58. Entity::SetColor

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />Window* window = NULL;<br />Context* context = NULL;<br />World* world = NULL;<br />Camera* camera = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(35,0,0);<br /> camera->Move(0,0,-6);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create the ground<br /> Model* ground = Model::Box(10,1,10);<br /> ground->SetPosition(0,0,-0.5);<br /> ground->SetColor(0,1,0);<br /><br /> //Create a shape<br /> Shape* shape = Shape::Box(0,0,0, 0,0,0, 10,1,10);<br /> ground->SetShape(shape);<br /> shape->Release();<br /><br /> //Create a box<br /> Model* box = Model::Box(1,1,1);<br /> box->SetPosition(0,5,0);<br /> box->SetColor(0,0,1);<br /> box->SetMass(1);<br /><br /> //Create a shape<br /> shape = Shape::Box(0,0,0, 0,0,0, 1,1,1);<br /> box->SetShape(shape);<br /> shape->Release();<br /><br /> return true;<br />}<br /><br />bool App::Continue()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-6) <br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create the ground<br /> local ground = Model:Box(10,1,10)<br /> ground:SetPosition(0,0,-0.5)<br /> ground:SetColor(0,1,0)<br /><br /> --Create a shape<br /> local shape = Shape:Box(0,0,0, 0,0,0, 10,1,10)<br /> ground:SetShape(shape)<br /> shape:Release()<br /><br /> --Create a box<br /> local box = Model:Box(1,1,1)<br /> box:SetPosition(0,5,0)<br /> box:SetColor(0,0,1)<br /> box:SetMass(1)<br /><br /> --Create a shape<br /> local shape = Shape:Box(0,0,0, 0,0,0, 1,1,1)<br /> box:SetShape(shape)<br /> shape:Release()<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 3 comments
    • 2,486 views
  59. Entity::SetFriction

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Entity* entity1 = NULL;<br />Entity* entity2 = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(15,0,0);<br /> camera->Move(0,0,-8);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create the ground<br /> Model* ground = Model::Box(10,0.1,10);<br /> ground->SetColor(0.0,1.0,0.0);<br /> <br /> //Create a shape<br /> Shape* shape = Shape::Box(0,0,0, 0,0,0, 10,0.1,10);<br /> ground->SetShape(shape);<br /> shape->Release();<br /> <br /> //Create a model<br /> entity1 = Model::Box();<br /> entity1->SetColor(0.0,0.0,1.0);<br /> entity1->SetPosition(-2,1,2);<br /> entity1->SetMass(1);<br /> entity1->SetFriction(0,0);<br /> entity1->AddForce(0,0,-200);<br /> <br /> //Create a shape<br /> shape = Shape::Box();<br /> entity1->SetShape(shape);<br /> shape->Release();<br /> <br /> //Create a second model<br /> entity2 = entity1->Instance();<br /> entity2->SetPosition(2,1,2);<br /> entity2->SetFriction(1,1);<br /> entity2->AddForce(0,0,-200);<br /> <br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /> <br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-8)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create the ground<br /> local ground = Model:Box(10,0.1,10) <br /> ground:SetColor(0.0,1.0,0.0) <br /> <br /> --Create a shape<br /> local shape = Shape:Box(0,0,0, 0,0,0, 10,0.1,10) <br /> ground:SetShape(shape) <br /> shape:Release() <br /> <br /> --Create a model<br /> entity1 = Model:Box() <br /> entity1:SetColor(0.0,0.0,1.0) <br /> entity1:SetPosition(-2,1,2) <br /> entity1:SetMass(1) <br /> entity1:SetFriction(0,0) <br /> entity1:AddForce(0,0,-200) <br /> <br /> --Create a shape<br /> shape = Shape:Box() <br /> entity1:SetShape(shape) <br /> shape:Release() <br /> <br /> --Create a second model<br /> entity2 = entity1:Instance() <br /> entity2:SetPosition(2,1,2) <br /> entity2:SetFriction(1,1) <br /> entity2:AddForce(0,0,-200) <br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,603 views
  60. Entity::SetGravityMode

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Entity* entity = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(35,0,0);<br /> camera->Move(0,0,-4);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create a model<br /> entity = Model::Box();<br /> entity->SetMass(1);<br /> entity->SetGravityMode(false);<br /> entity->AddTorque(0,10,0);<br /><br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /><br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("Gravity mode: "+String(entity->GetGravityMode()),2,2);<br /><br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-8)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create a model<br /> self.entity = Model:Box()<br /> self.entity:SetMass(1)<br /> self.entity:SetGravityMode(false) <br /> self.entity:AddTorque(0,10,0) <br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.context:SetBlendMode(Blend.Alpha) <br /> self.context:DrawText("Gravity mode: "..tostring(self.entity:GetGravityMode()),2,2) <br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,499 views
  61. Entity::SetInput

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Entity* player = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(35,0,0);<br /> camera->Move(0,0,-8);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create the ground<br /> Model* ground = Model::Box(10,1,10);<br /> ground->SetPosition(0,-0.5,0);<br /> ground->SetColor(0.0,1.0,0.0);<br /> <br /> //Create a shape<br /> Shape* shape = Shape::Box(0,0,0, 0,0,0, 10,1,10);<br /> ground->SetShape(shape);<br /> shape->Release();<br /> <br /> //Create a character<br /> player = Pivot::Create();<br /> Entity* visiblecapsule = Model::Cylinder(16,player);<br /> visiblecapsule->SetScale(1,2,1);<br /> visiblecapsule->SetPosition(0,1,0);<br /> player->SetMass(1);<br /> player->SetPhysicsMode(Entity::CharacterPhysics);<br /> <br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /> <br /> Time::Update();<br /> <br /> float move = (window->KeyDown(Key::Up) - window->KeyDown(Key::Down))*4;<br /> float strafe = (window->KeyDown(Key::Right) - window->KeyDown(Key::Left))*4;<br /> player->SetInput(0,move,strafe);<br /> <br /> world->Update();<br /> world->Render();<br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-8)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Enable navmesh debugging<br /> camera:SetDebugNavigationMode(true)<br /> <br /> --Create the ground<br /> local ground = Model:Box(10,1,10)<br /> ground:SetPosition(0,-0.5,0)<br /> ground:SetColor(0.0,0.25,0.0)<br /> <br /> --Create a shape<br /> local shape = Shape:Box(0,0,0, 0,0,0, 10,1,10)<br /> ground:SetShape(shape)<br /> shape:Release()<br /> <br /> --Create a model<br /> --This is an obstacle the player will walk around<br /> self.entity = Model:Box(1,1,3)<br /> self.entity:SetColor(0.0,0.0,1.0)<br /> self.entity:SetPosition(0,5,0)<br /> self.entity:SetMass(1)<br /> <br /> --Create a shape<br /> local shape = Shape:Box(0,0,0,0,0,0,1,1,3)<br /> self.entity:SetShape(shape)<br /> shape:Release()<br /> <br /> --Enable navigation obstacles<br /> ground:SetNavigationMode(true)<br /> self.entity:SetNavigationMode(true)<br /> <br /> --Create a character<br /> self.player = Pivot:Create()<br /> local visiblecapsule = Model:Cylinder(16,self.player)<br /> visiblecapsule:SetScale(1,2,1)<br /> visiblecapsule:SetPosition(0,1,0)<br /> self.player:SetPosition(-4,0,0)<br /> self.player:SetMass(1)<br /> self.player:SetPhysicsMode(Entity.CharacterPhysics)<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> Time:Update()<br /> <br /> local move = ((self.window:KeyDown(Key.Up) and 1 or 0) - (self.window:KeyDown(Key.Down) and 1 or 0))*4<br /> local strafe = ((self.window:KeyDown(Key.Right)and 1 or 0) - (self.window:KeyDown(Key.Left) and 1 or 0))*4<br /> self.player:SetInput(0,move,strafe)<br /><br /> self.world:Update()<br /> self.world:Render()<br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 1 comment
    • 4,190 views
  62. Entity::SetIntensity

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Entity* entity = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(35,0,0);<br /> camera->Move(0,0,-4);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create a model<br /> entity = Model::Box();<br /> entity->SetColor(1,0.5,0.25);<br /><br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> <br /> entity->SetIntensity(Math::Sin(Time::GetCurrent()/10.0)+1.5);<br /><br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("Color: "+entity->GetColor().ToString(),2,2);<br /> context->DrawText("Intensity: "+String(entity->GetIntensity()),2,22);<br /><br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:Move(0,0,-3)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create a model<br /> self.entity = Model:Box()<br /> self.entity :SetColor(1.0,0.5,0.25)<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /> <br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.entity :SetIntensity(Math:Sin(Time:GetCurrent()/10.0)+1.5)<br /><br /> self.context:SetBlendMode(Blend.Alpha)<br /> self.context:DrawText("Color: "..self.entity:GetColor():ToString(),2,2)<br /> self.context:DrawText("Intensity: "..self.entity:GetIntensity(),2,22)<br /><br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,269 views
  63. Entity::SetKeyValue

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Model* model = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->Move(0,0,-3);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create a model<br /> model = Model::Box();<br /> model->SetKeyValue("name","Box1");<br /> model->SetColor(0.0,0.0,1.0);<br /><br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /> <br /> model->Turn(0,Time::GetSpeed(),0);<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> <br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("Name: "+model->GetKeyValue("name"), 2, 2);<br /> context->SetBlendMode(Blend::Solid);<br /> <br /> context->Sync(false);<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-3)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create a model<br /> self.model = Model:Box()<br /> self.model:SetKeyValue("name","Box1")<br /> self.model:SetColor(0.0,0.0,1.0)<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> self.model:Turn(0,Time:GetSpeed(),0)<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.context:SetBlendMode(Blend.Alpha)<br /> self.context:DrawText("Name: "..self.model:GetKeyValue("name"), 2, 2)<br /> self.context:SetBlendMode(Blend.Solid)<br /><br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 1 comment
    • 2,273 views
  64. Entity::SetMass

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Entity* entity = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(35,0,0);<br /> camera->Move(0,0,-6);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create the ground<br /> Model* ground = Model::Box(10,1,10);<br /> ground->SetPosition(0,0,-0.5);<br /> ground->SetColor(0.0,1.0,0.0);<br /><br /> //Create a shape<br /> Shape* shape = Shape::Box(0,0,0, 0,0,0, 10,1,10);<br /> ground->SetShape(shape);<br /> shape->Release();<br /><br /> //Create a model<br /> entity = Model::Box();<br /> entity->SetColor(0.0,0.0,1.0);<br /> entity->SetPosition(0,3,0);<br /> entity->SetMass(1);<br /><br /> //Create a shape<br /> shape = Shape::Box();<br /> entity->SetShape(shape);<br /> shape->Release();<br /><br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> <br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("Mass: "+String(entity->GetMass()),2,2);<br /><br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-8)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create the ground<br /> local ground = Model:Box(10,1,10) <br /> ground:SetPosition(0,0,-0.5) <br /> ground:SetColor(0.0,1.0,0.0) <br /><br /> --Create a shape<br /> local shape = Shape:Box(0,0,0, 0,0,0, 10,1,10) <br /> ground:SetShape(shape) <br /> shape:Release() <br /><br /> --Create a model<br /> self.entity = Model:Box() <br /> self.entity:SetColor(0.0,0.0,1.0) <br /> self.entity:SetPosition(0,3,0) <br /> self.entity:SetMass(1) <br /><br /> --Create a shape<br /> shape = Shape:Box() <br /> self.entity:SetShape(shape) <br /> shape:Release() <br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.context:SetBlendMode(Blend.Alpha) <br /> self.context:DrawText("Mass: "..self.entity:GetMass(),2,2) <br /><br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,509 views
  65. Entity::SetMaterial

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> DirectionalLight::Create()->SetRotation(45,35,0);<br /> <br /> //Create a material<br /> Material* material = Material::Create();<br /> material->SetColor(1,0,0);<br /> <br /> //Create a model and apply the material to it<br /> Model* model = Model::Sphere();<br /> model->SetPosition(0,0,2);<br /> model->SetMaterial(material);<br /> <br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /> <br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> local light = DirectionalLight:Create()<br /> <br /> --Create a material<br /> local material = Material:Create()<br /> material:SetColor(1,0,0)<br /> <br /> --Create a model and apply the material to it<br /> local model = Model:Sphere()<br /> model:SetPosition(0,0,2)<br /> model:SetMaterial(material)<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,714 views
  66. Entity::SetMatrix

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Entity* entity1 = NULL;<br />Entity* entity2 = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->Move(0,0,-3);<br /> DirectionalLight::Create()->SetRotation(45,35,0);<br /> <br /> //Create a model and apply the material to it<br /> entity1 = Model::Box();<br /> entity1->SetColor(0.0,0.0,1.0);<br /> <br /> entity2 = entity1->Instance();<br /> entity2->SetColor(0.0,1.0,0.0);<br /> <br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /> <br /> entity1->Turn(0,Time::GetSpeed()*1.0,0);<br /> entity2->SetMatrix(entity1->GetMatrix());<br /> entity2->Turn(0,45,0);<br /> <br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-6)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create a model<br /> self.entity1 = Model:Box()<br /> self.entity1:SetColor(0.0,0.0,1.0)<br /><br /> self.entity2 = self.entity1:Instance()<br /> self.entity2:SetColor(0.0,1.0,0.0)<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> self.entity1:Turn(0,Time:GetSpeed()*0.5,0)<br /> self.entity2:SetMatrix(self.entity1:GetMatrix())<br /> self.entity2:Turn(0,45,0)<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,249 views
  67. Entity::SetNavigationMode

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Entity* entity = NULL;<br />Entity* player = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(35,0,0);<br /> camera->Move(0,0,-8);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Enable navmesh debugging<br /> camera->SetDebugNavigationMode(true);<br /> <br /> //Create the ground<br /> Model* ground = Model::Box(10,1,10);<br /> ground->SetPosition(0,-0.5,0);<br /> ground->SetColor(0.0,0.25,0.0);<br /> <br /> //Create a shape<br /> Shape* shape = Shape::Box(0,0,0, 0,0,0, 10,1,10);<br /> ground->SetShape(shape);<br /> shape->Release();<br /> <br /> //Create a model<br /> //This is an obstacle the player will walk around<br /> entity = Model::Box(1,1,3);<br /> entity->SetColor(0.0,0.0,1.0);<br /> entity->SetPosition(0,5,0);<br /> entity->SetMass(1);<br /> <br /> //Create a shape<br /> shape = Shape::Box(0,0,0,0,0,0,1,1,3);<br /> entity->SetShape(shape);<br /> shape->Release();<br /> <br /> //Enable navigation obstacles<br /> ground->SetNavigationMode(true);<br /> entity->SetNavigationMode(true);<br /> <br /> //Create a character<br /> player = Pivot::Create();<br /> Entity* visiblecapsule = Model::Cylinder(16,player);<br /> visiblecapsule->SetScale(1,2,1);<br /> visiblecapsule->SetPosition(0,1,0);<br /> player->SetPosition(-4,0,0);<br /> player->SetMass(1);<br /> player->SetPhysicsMode(Entity::CharacterPhysics);<br /> <br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /> <br /> if (player) player->GoToPoint(4,0,0,1.4,1);<br /> <br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> <br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("NavMode: "+String(entity->GetNavigationMode()),2,2);<br /> <br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-8)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Enable navmesh debugging<br /> camera:SetDebugNavigationMode(true)<br /> <br /> --Create the ground<br /> local ground = Model:Box(10,1,10)<br /> ground:SetPosition(0,-0.5,0)<br /> ground:SetColor(0.0,0.25,0.0)<br /> <br /> --Create a shape<br /> local shape = Shape:Box(0,0,0, 0,0,0, 10,1,10)<br /> ground:SetShape(shape)<br /> shape:Release()<br /> <br /> --Create a model<br /> --This is an obstacle the player will walk around<br /> self.entity = Model:Box(1,1,3)<br /> self.entity:SetColor(0.0,0.0,1.0)<br /> self.entity:SetPosition(0,5,0)<br /> self.entity:SetMass(1)<br /> <br /> --Create a shape<br /> local shape = Shape:Box(0,0,0,0,0,0,1,1,3)<br /> self.entity:SetShape(shape)<br /> shape:Release()<br /> <br /> --Enable navigation obstacles<br /> ground:SetNavigationMode(true)<br /> self.entity:SetNavigationMode(true)<br /> <br /> --Create a character<br /> self.player = Pivot:Create()<br /> local visiblecapsule = Model:Cylinder(16,self.player)<br /> visiblecapsule:SetScale(1,2,1)<br /> visiblecapsule:SetPosition(0,1,0)<br /> self.player:SetPosition(-4,0,0)<br /> self.player:SetMass(1)<br /> self.player:SetPhysicsMode(Entity.CharacterPhysics)<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /> <br /> if (self.player) then self.player:GoToPoint(4,0,0,1.4,1) end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.context:SetBlendMode(Blend.Alpha)<br /> self.context:DrawText("NavMode: ".. tostring(self.entity:GetNavigationMode()),2,2)<br /><br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 1 comment
    • 1,976 views
  68. Entity::SetOcclusionCullingMode

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Model* model = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->Move(0,0,-3);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create a model to act as an occluder<br /> model = Model::Box();<br /> model->SetScale(2);<br /> model->SetColor(0.0,0.0,1.0);<br /> <br /> //Create a model to test the visibility of<br /> model = Model::Box();<br /> model->SetColor(0.0,1.0,0.0);<br /> model->SetPosition(0,0,6);<br /> <br /> //Enable individual entity occlusion culling. Normally we would not do this<br /> //because the occlusion test is as expensive as just rendering the object.<br /> //A courser occlusion culling system is always active in the world octree.<br /> model->SetOcclusionCullingMode(true);<br /> <br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /> <br /> model->SetPosition(Math::Sin(Time::GetCurrent()/20.0)*4.0,0,4);<br /> <br /> if (window->KeyHit(Key::Space))<br /> {<br /> model->SetOcclusionCullingMode(!model->GetOcclusionCullingMode());<br /> }<br /> <br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> <br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("Culled: "+String(model->GetCulled(camera)),2,2);<br /> context->DrawText("Occlusion culling mode: "+String(model->GetOcclusionCullingMode()),2,22);<br /> <br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> self.camera = Camera:Create()<br /> self.camera:Move(0,0,-3)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create a model to act as an occluder<br /> local model = Model:Box()<br /> model:SetScale(2)<br /> model:SetColor(0.0,0.0,1.0)<br /> <br /> --Create a model to test the visibility of<br /> self.model = Model:Box()<br /> self.model:SetColor(0.0,1.0,0.0)<br /> self.model:SetPosition(0,0,6)<br /> <br /> --Enable individual entity occlusion culling. Normally we would not do this<br /> --because the occlusion test is as expensive as just rendering the object.<br /> --A courser occlusion culling system is always active in the world octree.<br /> self.model:SetOcclusionCullingMode(true)<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /> <br /><br /> self.model:SetPosition(Math:Sin(Time:GetCurrent()/20.0)*4.0,0,4)<br /> <br /> if (self.window:KeyHit(Key.Space)) then<br /> <br /> self.model:SetOcclusionCullingMode(not self.model:GetOcclusionCullingMode())<br /> end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.context:SetBlendMode(Blend.Alpha)<br /> self.context:DrawText("Culled: "..tostring(self.model:GetCulled(self.camera)),2,2)<br /> self.context:DrawText("Occlusion culling mode: "..tostring(self.model:GetOcclusionCullingMode()),2,22)<br /><br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,801 views
  69. Entity::SetOmega

    Attachments: Show TOC: False
    • 0 comments
    • 1,616 views
  70. Entity::SetParent

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Entity* entity = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(35,0,0);<br /> camera->Move(0,0,-4);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Load a model<br /> entity = Model::Box();<br /> <br /> Entity* child = Model::Box(1,1,1);<br /> child->SetParent(entity);<br /> child->SetColor(1.0,0.0,0.0);<br /> child->SetPosition(2,-2,0);<br /> <br /> child = Model::Box(1,1,1);<br /> child->SetParent(entity);<br /> child->SetColor(0.0,1.0,0.0);<br /> child->SetPosition(-2,-2,0);<br /> <br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /> <br /> Time::Update();<br /> <br /> entity->Turn(1.0*Time::GetSpeed(),2.0*Time::GetSpeed(),3.0*Time::GetSpeed());<br /> <br /> world->Update();<br /> world->Render();<br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-3)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Load a model<br /> self.entity = Model:Box()<br /> <br /> local child = Model:Box(1,1,1)<br /> child:SetParent(self.entity)<br /> child:SetColor(1.0,0.0,0.0)<br /> child:SetPosition(2,-2,0)<br /><br /> child = Model:Box(1,1,1)<br /> child:SetParent(self.entity)<br /> child:SetColor(0.0,1.0,0.0)<br /> child:SetPosition(-2,-2,0)<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> Time:Update()<br /><br /> self.entity:Turn(1.0*Time:GetSpeed(),2.0*Time:GetSpeed(),3.0*Time:GetSpeed())<br /><br /> self.world:Update()<br /> self.world:Render()<br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 1 comment
    • 2,723 views
  71. Entity::SetPhysicsMode

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Entity* entity = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(35,0,0);<br /> camera->Move(0,0,-6);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create the ground<br /> Model* ground = Model::Box(10,1,10);<br /> ground->SetPosition(0,0,-0.5);<br /> ground->SetColor(0.0,1.0,0.0);<br /> <br /> //Create a shape<br /> Shape* shape = Shape::Box(0,0,0, 0,0,0, 10,1,10);<br /> ground->SetShape(shape);<br /> shape->Release();<br /> <br /> //Create a model<br /> entity = Model::Box();<br /> entity->SetPhysicsMode(Entity::RigidBodyPhysics);<br /> entity->SetColor(0.0,0.0,1.0);<br /> entity->SetPosition(0,3,0);<br /> entity->SetMass(1);<br /> <br /> //Create a shape<br /> shape = Shape::Box();<br /> entity->SetShape(shape);<br /> shape->Release();<br /> <br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /> <br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> <br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("Mass: "+String(entity->GetMass()),2,2);<br /> <br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-8)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create the ground<br /> local ground = Model:Box(10,1,10) <br /> ground:SetPosition(0,0,-0.5) <br /> ground:SetColor(0.0,1.0,0.0) <br /><br /> --Create a shape<br /> local shape = Shape:Box(0,0,0, 0,0,0, 10,1,10) <br /> ground:SetShape(shape) <br /> shape:Release() <br /><br /> --Create a model<br /> self.entity = Model:Box() <br /> self.entity:SetPhysicsMode(Entity.RigidBodyPhysics)<br /> self.entity:SetColor(0.0,0.0,1.0) <br /> self.entity:SetPosition(0,3,0) <br /> self.entity:SetMass(1) <br /><br /> --Create a shape<br /> shape = Shape:Box() <br /> self.entity:SetShape(shape) <br /> shape:Release() <br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.context:SetBlendMode(Blend.Alpha) <br /> self.context:DrawText("Mass: "..self.entity:GetMass(),2,2) <br /><br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 2,222 views
  72. Entity::SetPickMode

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->Move(0, 0, -8);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35, 35, 0);<br /><br /> //Create a model<br /> Model* model1 = Model::Box();<br /> model1->SetPosition(2, 0, 0);<br /><br /> Model* model2 = Model::Box();<br /> model2->SetPosition(-2, 0, 0);<br /> model2->SetPickMode(0);// Disable picking on the first hit entity<br /><br /> //Create a sphere to indicate where the pick hits<br /> Model* picksphere = Model::Sphere();<br /> picksphere->SetColor(1.0, 0.0, 0.0);<br /> picksphere->SetPickMode(0);<br /><br /> float pickradius = 0.5;<br /> picksphere->SetScale(pickradius*2.0);<br /><br /> world->Update();<br /> PickInfo pickinfo;<br /> if (world->Pick(-10, 0.75, 0, 10, 0.75, 0, pickinfo, pickradius, true))<br /> {<br /> picksphere->SetPosition(pickinfo.position);<br /><br /> //Make sure the pick mode equals Entity::PolygonPick<br /> Debug::Assert(pickinfo.entity->GetPickMode() == Entity::PolygonPick);<br /> }<br /> else<br /> {<br /> picksphere->Release();<br /> }<br /><br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> context->Sync();<br /><br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-8)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /><br /> --Create a model<br /> local model1 = Model:Box() <br /> model1:SetPosition(2,0,0) <br /><br /> local model2 = Model:Box() <br /> model2:SetPosition(-2,0,0) <br /> model2:SetPickMode(0) -- Disable picking on the first hit entity<br /><br /> --Create a sphere to indicate where the pick hits<br /> local picksphere = Model:Sphere() <br /> picksphere:SetColor(1.0,0.0,0.0) <br /> picksphere:SetPickMode(0) <br /><br /> local pickradius = 0.5 <br /> picksphere:SetScale(pickradius*2.0) <br /><br /> self.world:Update() <br /> local pickinfo = PickInfo() <br /> if (self.world:Pick(-10,0.75,0,10,0.75,0,pickinfo,pickradius,true)) then<br /> <br /> picksphere:SetPosition(pickinfo.position) <br /><br /> --Make sure the pick mode equals Entity:PolygonPick<br /> Debug:Assert(pickinfo.entity:GetPickMode()==Entity.PolygonPick) <br /> <br /> else<br /> <br /> picksphere:Release() <br /> end<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 1 comment
    • 2,366 views
  73. Entity::SetPickRadius

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->Move(0,0,-8);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> camera->SetProjectionMode(2);<br /> camera->SetZoom(50);<br /><br /> //Create a model<br /> float spherescale = 3.6;<br /> Model* model = Model::Sphere();<br /> model->SetPickMode(Entity::SpherePick);<br /> model->SetPickRadius(spherescale/2.0);<br /> model->SetScale(model->GetPickRadius()*2.0);<br /> <br /> //Create a sphere to indicate where the pick hits<br /> Model* picksphere = Model::Sphere();<br /> picksphere->SetColor(1.0,0.0,0.0);<br /> picksphere->SetPickMode(0);<br /><br /> float pickradius = 0.25;<br /> picksphere->SetScale(pickradius*2.0);<br /><br /> PickInfo pickinfo;<br /> if (model->Pick(Vec3(-10,1,0),Vec3(10,1,0),pickinfo,pickradius,true))<br /> {<br /> picksphere->SetPosition(pickinfo.position);<br /> }<br /> else<br /> {<br /> picksphere->Release();<br /> }<br /><br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-8)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> camera:SetProjectionMode(2) <br /> camera:SetZoom(50) <br /><br /> --Create a model<br /> local spherescale = 3.6 <br /> local model = Model:Sphere() <br /> model:SetPickMode(Entity.SpherePick) <br /> model:SetPickRadius(spherescale/2.0) <br /> model:SetScale(model:GetPickRadius()*2.0) <br /> <br /> --Create a sphere to indicate where the pick hits<br /> local picksphere = Model:Sphere() <br /> picksphere:SetColor(1.0,0.0,0.0) <br /> picksphere:SetPickMode(0) <br /><br /> local pickradius = 0.25 <br /> picksphere:SetScale(pickradius*2.0) <br /><br /> local pickinfo = PickInfo()<br /> if (self.world:Pick(Vec3(-10,1,0),Vec3(10,1,0),pickinfo,pickradius,true)) then<br /> <br /> picksphere:SetPosition(pickinfo.position) <br /> else<br /> <br /> picksphere:Release() <br /> end<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,068 views
  74. Entity::SetQuaternion

    Attachments: Show TOC: False
    • 0 comments
    • 842 views
  75. Entity::SetRotation

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Entity* entity = NULL;<br />Vec3 rotation;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(35,0,0);<br /> camera->Move(0,0,-6);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create a model<br /> entity = Model::Box();<br /> entity->SetColor(0.0,0.0,1.0);<br /> <br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /> <br /> rotation.y += Time::GetSpeed();<br /> entity->SetRotation(rotation);<br /> <br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> <br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("Rotation: "+entity->GetRotation().ToString(),2,2);<br /> <br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: rotation = Vec3()<br /><br />function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-6)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create a model<br /> self.entity = Model:Box()<br /> self.entity:SetColor(0.0,0.0,1.0)<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> rotation.y = rotation.y + Time:GetSpeed()<br /> self.entity:SetRotation(rotation);<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.context:SetBlendMode(Blend.Alpha)<br /> self.context:DrawText("Rotation: "..self.entity:GetRotation():ToString(),2,2)<br /><br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 3,406 views
  76. Entity::SetScale

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Entity* entity = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(35,0,0);<br /> camera->Move(0,0,-6);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create a model<br /> entity = Model::Box();<br /> entity->SetColor(0.0,0.0,1.0);<br /> <br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /> <br /> entity->SetScale(sin(Time::GetCurrent()/100.0)*0.5+0.75);<br /> <br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> <br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("Scale: "+entity->GetScale().ToString(),2,2);<br /> <br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-6)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create a model<br /> self.entity = Model:Box()<br /> self.entity:SetColor(0.0,0.0,1.0)<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> self.entity:SetScale(Math:Sin(Time:GetCurrent()/100.0)*0.5+0.75)<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.context:SetBlendMode(Blend.Alpha)<br /> self.context:DrawText("Scale: "..self.entity:GetScale():ToString(),2,2)<br /><br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,401 views
  77. Entity::SetShadowMode

    Attachments: Show TOC: False
    • 0 comments
    • 1,517 views
  78. Entity::SetShape

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Entity* entity = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(35,0,0);<br /> camera->Move(0,0,-6);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create the ground<br /> Model* ground = Model::Box(10,1,10);<br /> ground->SetPosition(0,0,-0.5);<br /> ground->SetColor(0.0,1.0,0.0);<br /><br /> //Create a shape<br /> Shape* shape = Shape::Box(0,0,0, 0,0,0, 10,1,10);<br /> ground->SetShape(shape);<br /> shape->Release();<br /><br /> //Create a model<br /> entity = Model::Box();<br /> entity->SetColor(0.0,0.0,1.0);<br /> entity->SetPosition(0,3,0);<br /> entity->SetMass(1);<br /><br /> //Create a shape<br /> shape = Shape::Box();<br /> entity->SetShape(shape);<br /> shape->Release();<br /><br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> <br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("Mass: "+String(entity->GetMass()),2,2);<br /><br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-8)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create a model<br /> local entity = Model:Box(1,1,1)<br /> entity:SetColor(0.0,0.0,1.0)<br /> <br /> local shape = Shape:Box()<br /> entity:SetShape(shape)<br /> Debug:Assert(entity:GetShape()==shape)<br /> shape:Release()<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,419 views
  79. Entity::SetString

    Attachments: Show TOC: False
    • 0 comments
    • 735 views
  80. Entity::SetSweptCollisionMode

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Entity* entity1 = NULL;<br />Entity* entity2 = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(15,0,0);<br /> camera->Move(0,0,-8);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create the ground<br /> Model* ground = Model::Box(10,0.1,10);<br /> ground->SetColor(0.0,1.0,0.0);<br /><br /> //Create a shape<br /> Shape* shape = Shape::Box(0,0,0, 0,0,0, 10,0.1,10);<br /> ground->SetShape(shape);<br /> shape->Release();<br /><br /> //Create a model<br /> entity1 = Model::Box();<br /> entity1->SetScale(1,0.1,4);<br /> entity1->SetColor(0.0,0.0,1.0);<br /> entity1->SetPosition(-2,5,0);<br /> entity1->SetMass(1);<br /> entity1->AddForce(0,-2000,0);<br /> <br /> //Create a shape<br /> shape = Shape::Box();<br /> entity1->SetShape(shape);<br /> shape->Release();<br /><br /> //Create a second model<br /> entity2 = entity1->Instance();<br /> entity2->SetPosition(2,5,0);<br /> entity2->SetSweptCollisionMode(true);<br /> entity2->AddForce(0,-2000,0);<br /><br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /><br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("entity1 swept collision mode: "+String(entity1->GetSweptCollisionMode()),2,2);<br /> context->DrawText("entity2 swept collision mode: "+String(entity2->GetSweptCollisionMode()),2,22);<br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-8)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create the ground<br /> local ground = Model:Box(10,0.1,10) <br /> ground:SetColor(0.0,1.0,0.0) <br /><br /> --Create a shape<br /> local shape = Shape:Box(0,0,0, 0,0,0, 10,0.1,10) <br /> ground:SetShape(shape) <br /> shape:Release() <br /><br /> --Create a model<br /> self.entity1 = Model:Box() <br /> self.entity1:SetScale(1,0.1,4) <br /> self.entity1:SetColor(0.0,0.0,1.0) <br /> self.entity1:SetPosition(-2,5,0) <br /> self.entity1:SetMass(1) <br /> self.entity1:AddForce(0,-2000,0) <br /> <br /> --Create a shape<br /> shape = Shape:Box() <br /> self.entity1:SetShape(shape) <br /> shape:Release() <br /><br /> --Create a second model<br /> self.entity2 = self.entity1:Instance() <br /> self.entity2:SetPosition(2,5,0) <br /> self.entity2:SetSweptCollisionMode(true) <br /> self.entity2:AddForce(0,-2000,0) <br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.context:SetBlendMode(Blend.Alpha) <br /> self.context:DrawText("self.entity1 swept collision mode: "..tostring(self.entity1:GetSweptCollisionMode()),2,2) <br /> self.context:DrawText("self.entity2 swept collision mode: "..tostring(self.entity2:GetSweptCollisionMode()),2,22) <br /><br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,533 views
  81. Entity::SetVelocity

    Attachments: Show TOC: False
    • 0 comments
    • 1,867 views
  82. Entity::SetViewRange

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Entity* entity[3] = {NULL};<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->Move(0,2,0);<br /> camera->SetRotation(45,0,0);<br /> camera->Move(0,0,-8);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> Model* box = Model::Box();<br /><br /> for (int i=0; i<100; i++)<br /> {<br /> entity[0] = box->Instance();<br /> entity[0]->SetPosition(-5,1,i*10.0);<br /> entity[0]->SetViewRange(Entity::NearViewRange);<br /> entity[0]->SetColor(Math::Rnd(),Math::Rnd(),Math::Rnd());<br /> }<br /><br /> for (int i=0; i<100; i++)<br /> {<br /> entity[1] = box->Instance();<br /> entity[1]->SetPosition(0,1,i*10.0);<br /> entity[1]->SetViewRange(Entity::MediumViewRange);<br /> entity[1]->SetColor(Math::Rnd(),Math::Rnd(),Math::Rnd());<br /> }<br /><br /> for (int i=0; i<100; i++)<br /> {<br /> entity[2] = box->Instance();<br /> entity[2]->SetPosition(5,1,i*10.0);<br /> entity[2]->SetViewRange(Entity::FarViewRange);<br /> entity[2]->SetColor(Math::Rnd(),Math::Rnd(),Math::Rnd());<br /> }<br /><br /> box->Release();<br /><br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /><br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("Left row view range:"+String(entity[0]->GetViewRange()),2,2);<br /> context->DrawText("Center row view range:"+String(entity[1]->GetViewRange()),2,22);<br /> context->DrawText("Right row view range:"+String(entity[2]->GetViewRange()),2,42);<br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: entity = {}<br /><br />function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:Move(0,2,0)<br /> camera:SetRotation(45,0,0)<br /> camera:Move(0,0,-8) <br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> local box = Model:Box()<br /><br /> for i=0, 100 do <br /> <br /> entity[0] = box:Instance()<br /> entity[0]:SetPosition(-5,1,i*10.0)<br /> entity[0]:SetViewRange(Entity.NearViewRange)<br /> entity[0]:SetColor(Math:Random(),Math:Random(),Math:Random())<br /> end<br /><br /> for i=0, 100 do <br /> <br /> entity[1] = box:Instance()<br /> entity[1]:SetPosition(0,1,i*10.0)<br /> entity[1]:SetViewRange(Entity.MediumViewRange)<br /> entity[1]:SetColor(Math:Random(),Math:Random(),Math:Random())<br /> end<br /><br /> for i=0, 100 do <br /> <br /> entity[2] = box:Instance()<br /> entity[2]:SetPosition(5,1,i*10.0)<br /> entity[2]:SetViewRange(Entity.FarViewRange)<br /> entity[2]:SetColor(Math:Random(),Math:Random(),Math:Random())<br /> end<br /><br /> box:Release()<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.context:SetBlendMode(Blend.Alpha)<br /> self.context:DrawText("Left row view range:"..entity[0]:GetViewRange(),2,2)<br /> self.context:DrawText("Center row view range:"..entity[1]:GetViewRange(),2,22)<br /> self.context:DrawText("Right row view range:"..entity[2]:GetViewRange(),2,42)<br /><br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 1 comment
    • 1,458 views
  83. Entity::Show

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Model* model = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->Move(0,0,-3);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> model = Model::Box();<br /> model->SetColor(0.0,0.0,1.0);<br /><br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /><br /> model->Turn(0,Time::GetSpeed(),0);<br /><br /> if (window->KeyHit(Key::Space))<br /> {<br /> if (model->Hidden())<br /> {<br /> model->Show();<br /> }<br /> else<br /> {<br /> model->Hide();<br /> }<br /> }<br /> <br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("Press space to change.",2,2);<br /> context->DrawText("Hidden:"+String(model->Hidden()),2,22);<br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: entity = {}<br /><br />function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:Move(0,0,-3) <br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> self.model = Model:Box()<br /> self.model:SetColor(0.0,0.0,1.0)<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> self.model:Turn(0,Time:GetSpeed(),0)<br /><br /> if (self.window:KeyHit(Key.Space)) then<br /> <br /> if (self.model:Hidden()) then <br /> self.model:Show()<br /> else<br /> self.model:Hide()<br /> end<br /> end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.context:SetBlendMode(Blend.Alpha)<br /> self.context:DrawText("Press space to change.",2,2)<br /> self.context:DrawText("Hidden:"..tostring(self.model:Hidden()),2,22)<br /><br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,263 views
  84. Entity::Stop

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Entity* entity = NULL;<br />Entity* player = NULL;<br />bool pathset = false;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(35,0,0);<br /> camera->Move(0,0,-8);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Enable navmesh debugging<br /> camera->SetDebugNavigationMode(true);<br /> <br /> //Create the ground<br /> Model* ground = Model::Box(10,1,10);<br /> ground->SetPosition(0,-0.5,0);<br /> ground->SetColor(0.0,0.25,0.0);<br /> <br /> //Create a shape<br /> Shape* shape = Shape::Box(0,0,0, 0,0,0, 10,1,10);<br /> ground->SetShape(shape);<br /> shape->Release();<br /> <br /> //Create a model<br /> //This is an obstacle the player will walk around<br /> entity = Model::Box(1,1,3);<br /> entity->SetColor(0.0,0.0,1.0);<br /> entity->SetPosition(0,5,0);<br /> entity->SetMass(1);<br /> <br /> //Create a shape<br /> shape = Shape::Box(0,0,0,0,0,0,1,1,3);<br /> entity->SetShape(shape);<br /> shape->Release();<br /> <br /> //Enable navigation obstacles<br /> ground->SetNavigationMode(true);<br /> entity->SetNavigationMode(true);<br /> <br /> //Create a character<br /> player = Pivot::Create();<br /> Entity* visiblecapsule = Model::Cylinder(16,player);<br /> visiblecapsule->SetScale(1,2,1);<br /> visiblecapsule->SetPosition(0,1,0);<br /> player->SetPosition(-4,0,0);<br /> player->SetMass(1);<br /> player->SetPhysicsMode(Entity::CharacterPhysics);<br /> <br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /> <br /> Vec3 targetpos = Vec3(4,0,0);<br /> <br /> if (!pathset)<br /> {<br /> pathset = player->GoToPoint(targetpos,1.4,1);<br /> }<br /> <br /> //Stop the player when he gets close to the destination<br /> if (player->GetPosition().DistanceToPoint(targetpos)<2.0)<br /> {<br /> player->Stop();<br /> }<br /> <br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> <br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("NavMode: "+String(entity->GetNavigationMode()),2,2);<br /> <br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: pathset = false<br /><br />function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-8)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Enable navmesh debugging<br /> camera:SetDebugNavigationMode(true)<br /> <br /> --Create the ground<br /> local ground = Model:Box(10,1,10)<br /> ground:SetPosition(0,-0.5,0)<br /> ground:SetColor(0.0,0.25,0.0)<br /> <br /> --Create a shape<br /> local shape = Shape:Box(0,0,0, 0,0,0, 10,1,10)<br /> ground:SetShape(shape)<br /> shape:Release()<br /> <br /> --Create a model<br /> --This is an obstacle the player will walk around<br /> self.entity = Model:Box(1,1,3)<br /> self.entity:SetColor(0.0,0.0,1.0)<br /> self.entity:SetPosition(0,5,0)<br /> self.entity:SetMass(1)<br /> <br /> --Create a shape<br /> local shape = Shape:Box(0,0,0,0,0,0,1,1,3)<br /> self.entity:SetShape(shape)<br /> shape:Release()<br /> <br /> --Enable navigation obstacles<br /> ground:SetNavigationMode(true)<br /> self.entity:SetNavigationMode(true)<br /> <br /> --Create a character<br /> self.player = Pivot:Create()<br /> local visiblecapsule = Model:Cylinder(16,self.player)<br /> visiblecapsule:SetScale(1,2,1)<br /> visiblecapsule:SetPosition(0,1,0)<br /> self.player:SetPosition(-4,0,0)<br /> self.player:SetMass(1)<br /> self.player:SetPhysicsMode(Entity.CharacterPhysics)<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> local targetpos = Vec3(4,0,0)<br /> <br /> if (not pathset) then<br /> <br /> pathset = self.player:GoToPoint(targetpos,1.4,1)<br /> end<br /> <br /> --Stop the player when he gets close to the destination<br /> if (self.player:GetPosition():DistanceToPoint(targetpos)<2.0) then <br /> <br /> self.player:Stop()<br /> end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.context:SetBlendMode(Blend.Alpha)<br /> self.context:DrawText("NavMode: "..tostring(self.entity:GetNavigationMode()),2,2)<br /><br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,571 views
  85. Entity::StopAnimation

    Attachments: Show TOC: False
    • 0 comments
    • 358 views
  86. Entity::Translate

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Entity* entity = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(35,0,0);<br /> camera->Move(0,0,-8);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create a model<br /> entity = Model::Box();<br /> entity->SetColor(0.0,0.0,1.0);<br /> <br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /> <br /> Time::Update();<br /> <br /> entity->Turn(0,Time::GetSpeed()*2.0,0);<br /> entity->Translate(0.01*Time::GetSpeed(),0,0);<br /> <br /> world->Update();<br /> world->Render();<br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-6)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create a model<br /> self.entity = Model:Box()<br /> self.entity:SetColor(0.0,0.0,1.0)<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> Time:Update()<br /><br /> self.entity:Turn(0,Time:GetSpeed()*2.0,0)<br /> self.entity:Translate(0.01*Time:GetSpeed(),0,0);<br /><br /> self.world:Update()<br /> self.world:Render()<br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,677 views
  87. Entity::Turn

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Model* model = NULL;<br />int counter;<br /><br />void UpdateMatrixHook(Entity* entity)<br />{<br /> counter++;<br />}<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->Move(0,1,-3);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create a model<br /> model = Model::Box();<br /> model->SetColor(0.0,0.0,1.0);<br /> model->SetRotation(0,-90,0);<br /><br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> //Make the model move in a circle<br /> model->Turn(0,Time::GetSpeed()*0.5,0);<br /> model->Move(0,0,0.1);<br /> <br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-6)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create a model<br /> self.model = Model:Box()<br /> self.model:SetColor(0.0,0.0,1.0)<br /> self.model:SetRotation(0,-90,0)<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> --Make the model move in a circle<br /> self.model:Turn(0,Time:GetSpeed()*0.5,0);<br /> self.model:Move(0,0,0.1);<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 2,503 views
  88. Entity::UnlockMatrix

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Model* model = NULL;<br />int counter;<br /><br />void UpdateMatrixHook(Entity* entity)<br />{<br /> counter++;<br />}<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->Move(0,1,-3);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Load a model<br /> model = Model::Load("Models/Characters/Barbarian/barbarian.mdl");<br /> model->AddHook(Entity::UpdateMatrixHook,UpdateMatrixHook);<br /> <br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> counter=0;<br /><br /> //We're going to make a lot of changes to the entity orientation, but the expensive update<br /> //stuff will only occur once per loop when we call Entity::UnlockMatrix()<br /> bool mode = !window->KeyDown(Key::Space);<br /> if (mode) model->LockMatrix();<br /> model->SetAnimationFrame(Time::GetCurrent()/100.0,1);<br /> model->SetAnimationFrame(Time::GetCurrent()/100.0,0.5,1);<br /> model->SetAnimationFrame(Time::GetCurrent()/100.0,0.5,2);<br /> if (mode) model->UnlockMatrix();<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /><br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("UpdateMatrixHook was called "+String(counter)+" times.",2,2);<br /> context->DrawText("Hold space for slower mode.",2,22);<br /><br /> context->Sync();<br /> <br /> return true;<br />} Show TOC: False
    • 0 comments
    • 903 views
  89. Entity::UpdateAABB

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Model* model = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(35,0,0);<br /> camera->Move(0,0,-3);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create a model<br /> model = Model::Box();<br /> <br /> //Load a material<br /> Material* material = Material::Load("Materials/Brick/brickwall01a.mat");<br /> model->SetMaterial(material);<br /> material->Release();<br /> <br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /> <br /> Time::Update();<br /> <br /> //===========================================<br /> //Begin Model Modification<br /> //===========================================<br /> Surface* surface = model->GetSurface(0);<br /> for (int v=0; v<surface->CountVertices(); v++)<br /> {<br /> Vec3 position = surface->GetVertexPosition(v);<br /> Vec3 normal = surface->GetVertexNormal(v);<br /> Vec2 texcoords = surface->GetVertexTexCoords(v);<br /> Vec4 color = surface->GetVertexColor(v);<br /> <br /> position = position + normal * Vec3(Math::Sin(Time::GetCurrent()/10.0) * 0.001);<br /> texcoords += Time::GetSpeed()/100.0;<br /> <br /> surface->SetVertexPosition(v,position);<br /> surface->SetVertexNormal(v,normal);<br /> surface->SetVertexTexCoords(v,texcoords);<br /> surface->SetVertexColor(v,color);<br /> }<br /> <br /> //Update the surface AABB<br /> surface->UpdateAABB();<br /> <br /> //Update the model local and global AABBs so the renderer keeps proper track of it<br /> model->UpdateAABB(Entity::LocalAABB|Entity::GlobalAABB);<br /> <br /> //===========================================<br /> //End Model Modification<br /> //===========================================<br /> <br /> world->Update();<br /> world->Render();<br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-6)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create a model<br /> self.model = Model:Box()<br /> <br /> --Load a material<br /> local material = Material:Load("Materials/Brick/brickwall01a.mat")<br /> self.model:SetMaterial(material)<br /> material:Release()<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> Time:Update()<br /><br /> --===========================================<br /> --Begin Model Modification<br /> --===========================================<br /> local surface = self.model:GetSurface(0)<br /> for v=0, surface:CountVertices()-1 do<br /> <br /> local position = surface:GetVertexPosition(v)<br /> local normal = surface:GetVertexNormal(v)<br /> local texcoords = surface:GetVertexTexCoords(v)<br /> local color = surface:GetVertexColor(v)<br /> <br /> position = position + normal * Vec3(Math:Sin(Time:GetCurrent()/10.0) * 0.001)<br /> texcoords.x = texcoords.x + Time:GetSpeed()/100.0 <br /> texcoords.y = texcoords.y + Time:GetSpeed()/100.0 <br /><br /> surface:SetVertexPosition(v,position)<br /> surface:SetVertexNormal(v,normal)<br /> surface:SetVertexTexCoords(v,texcoords)<br /> surface:SetVertexColor(v,color)<br /> end<br /> <br /> --Update the surface AABB<br /> surface:UpdateAABB()<br /> <br /> --Update the model local and global AABBs so the renderer keeps proper track of it<br /> self.model:UpdateAABB(Entity.LocalAABB)<br /> self.model:UpdateAABB(Entity.GlobalAABB)<br /> <br /> --===========================================<br /> --End Model Modification<br /> --===========================================<br /><br /> self.world:Update()<br /> self.world:Render()<br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,106 views
  90. Entity::UpdateMatrixHook

    Attachments: Show TOC: False
    • 0 comments
    • 958 views
  91. Entity::UpdatePhysicsHook

    Attachments: Show TOC: False
    • 2 comments
    • 1,597 views
  92. Entity::UpdateWorldHook

    Attachments: Show TOC: False
    • 0 comments
    • 1,253 views
  93. Entity:GetColor

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Entity* entity = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(35,0,0);<br /> camera->Move(0,0,-4);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create a model<br /> entity = Model::Box();<br /> entity->SetColor(1,0.5,0.25);<br /><br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> <br /> entity->SetIntensity(Math::Sin(Time::GetCurrent()/10.0)+1.5);<br /><br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("Color: "+entity->GetColor().ToString(),2,2);<br /> context->DrawText("Intensity: "+String(entity->GetIntensity()),2,22);<br /><br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:Move(0,0,-3)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create a model<br /> self.entity = Model:Box()<br /> self.entity :SetColor(1.0,0.5,0.25)<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /> <br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.entity :SetIntensity(Math:Sin(Time:GetCurrent()/10.0)+1.5)<br /><br /> self.context:SetBlendMode(Blend.Alpha)<br /> self.context:DrawText("Color: "..self.entity:GetColor():ToString(),2,2)<br /> self.context:DrawText("Intensity: "..self.entity:GetIntensity(),2,22)<br /><br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,318 views
  94. Entity:GetCulled

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Model* model = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->Move(0,0,-3);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create a model to act as an occluder<br /> model = Model::Box();<br /> model->SetScale(2);<br /> model->SetColor(0.0,0.0,1.0);<br /> <br /> //Create a model to test the visibility of<br /> model = Model::Box();<br /> model->SetColor(0.0,1.0,0.0);<br /> model->SetPosition(0.0,0.0,6.0);<br /> <br /> //Enable individual entity occlusion culling. Normally we would not do this<br /> //because the occlusion test is as expensive as just rendering the object.<br /> //A courser occlusion culling system is always active in the world octree.<br /> model->SetOcclusionCullingMode(true);<br /> <br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /> <br /> model->SetPosition(Math::Sin(Time::GetCurrent()/20.0)*4.0,0,4);<br /> <br /> if (window->KeyHit(Key::Space))<br /> {<br /> model->SetOcclusionCullingMode(!model->GetOcclusionCullingMode());<br /> }<br /> <br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> <br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("Culled: "+String(model->GetCulled(camera)),2,2);<br /> context->DrawText("Occlusion culling mode: "+String(model->GetOcclusionCullingMode()),2,22);<br /> <br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> self.camera = Camera:Create()<br /> self.camera:Move(0,0,-3)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create a model to act as an occluder<br /> local model = Model:Box()<br /> model:SetScale(2)<br /> model:SetColor(0.0,0.0,1.0)<br /> <br /> --Create a model to test the visibility of<br /> self.model = Model:Box()<br /> self.model:SetColor(0.0,1.0,0.0)<br /> self.model:SetPosition(0,0,6)<br /> <br /> --Enable individual entity occlusion culling. Normally we would not do this<br /> --because the occlusion test is as expensive as just rendering the object.<br /> --A courser occlusion culling system is always active in the world octree.<br /> self.model:SetOcclusionCullingMode(true)<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /> <br /><br /> self.model:SetPosition(Math:Sin(Time:GetCurrent()/20.0)*4.0,0,4)<br /> <br /> if (self.window:KeyHit(Key.Space)) then<br /> <br /> self.model:SetOcclusionCullingMode(not self.model:GetOcclusionCullingMode())<br /> end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.context:SetBlendMode(Blend.Alpha)<br /> self.context:DrawText("Culled: "..tostring(self.model:GetCulled(self.camera)),2,2)<br /> self.context:DrawText("Occlusion culling mode: "..tostring(self.model:GetOcclusionCullingMode()),2,22)<br /><br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,365 views
  95. Entity:SetPosition

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Model* model = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(35,0,0);<br /> camera->Move(0,0,-4);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create a model<br /> model = Model::Box();<br /> <br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /><br /> model->SetPosition(Math::Sin(Time::GetCurrent()/10.0),0,0);<br /><br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /><br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText(model->GetPosition().ToString(),2,2);<br /><br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-6)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create a model<br /> self.model = Model:Box()<br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> self.model:SetPosition(Math:Sin(Time:GetCurrent()/10.0),0,0)<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /> self.context:Sync()<br /><br /> return true<br />end Main.lua: --Create a window<br />window = Window:Create()<br /><br />--Create a rendering context<br />context = Context:Create(window)<br /><br />--Create a world<br />world = World:Create()<br /><br />--Create a camera<br />local camera = Camera:Create()<br />camera:SetRotation(35,0,0)<br />camera:Move(0,0,-6)<br /><br />--Create a directional light<br />local light = DirectionalLight:Create()<br />light:SetRotation(35,35,0)<br /><br />--Create a model<br />model = Model:Box()<br /><br />--Main loop<br />while true do<br /> if window:Closed() or window:KeyHit(Key.Escape) then return false end<br /> model:SetPosition(Math:Sin(Time:GetCurrent()/10.0),0,0)<br /> Time:Update()<br /> world:Update()<br /> world:Render()<br /> context:Sync()<br />end Show TOC: False
    • 0 comments
    • 3,547 views
  96. GetOmega

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Entity* entity;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(35,0,0);<br /> camera->Move(0,0,-8);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create a model<br /> entity = Model::Box(1,1,1);<br /> entity->SetColor(0.0,0.0,1.0);<br /> entity->SetMass(1);<br /> entity->SetGravityMode(false);<br /> <br /> //Create a shape<br /> Shape* shape = Shape::Box(0,0,0,0,0,0,1,1,3);<br /> entity->SetShape(shape);<br /> shape->Release();<br /> <br /> //Add some torque<br /> entity->AddTorque(1000,1000,1000);<br /> <br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /> <br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> <br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("Omega: "+entity->GetOmega().ToString(),2,2);<br /> <br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-8)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create a model<br /> self.entity = Model:Box(1,1,1) <br /> self.entity:SetColor(0.0,0.0,1.0) <br /> self.entity:SetMass(1) <br /> self.entity:SetGravityMode(false) <br /> <br /> --Create a shape<br /> local shape = Shape:Box(0,0,0,0,0,0,1,1,3) <br /> self.entity:SetShape(shape) <br /> shape:Release() <br /> <br /> --Add some torque<br /> self.entity:AddTorque(1000,1000,1000) <br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.context:SetBlendMode(Blend.Alpha) <br /> self.context:DrawText("Omega: "..self.entity:GetOmega():ToString(),2,2) <br /><br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,473 views
  97. GetPointVelocity

    Attachments: C++ Example: #include "App.h"<br /><br />using namespace Leadwerks;<br /><br />App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}<br /><br />App::~App() { delete world; delete window; }<br /><br />Entity* entity = NULL;<br /><br />bool App::Start()<br />{<br /> window = Window::Create();<br /> context = Context::Create(window);<br /> world = World::Create();<br /> camera = Camera::Create();<br /> camera->SetRotation(35,0,0);<br /> camera->Move(0,0,-8);<br /> Light* light = DirectionalLight::Create();<br /> light->SetRotation(35,35,0);<br /> <br /> //Create a model<br /> entity = Model::Box(1,1,1);<br /> entity->SetColor(0.0,0.0,1.0);<br /> entity->SetMass(1);<br /> entity->SetGravityMode(false);<br /> <br /> //Create a shape<br /> Shape* shape = Shape::Box();<br /> entity->SetShape(shape);<br /> shape->Release();<br /> <br /> //Add some torque<br /> entity->AddTorque(0,1000,0);<br /> <br /> return true;<br />}<br /><br />bool App::Loop()<br />{<br /> if (window->Closed() || window->KeyDown(Key::Escape)) return false;<br /> <br /> Time::Update();<br /> world->Update();<br /> world->Render();<br /> <br /> context->SetBlendMode(Blend::Alpha);<br /> context->DrawText("Point velocity: "+entity->GetPointVelocity(2,0,0).ToString(),2,2);<br /> <br /> context->Sync();<br /> <br /> return true;<br />} Lua Example: function App:Start()<br /> --Create a window<br /> self.window = Window:Create()<br /> self.context = Context:Create(self.window)<br /> self.world = World:Create()<br /> local camera = Camera:Create()<br /> camera:SetRotation(35,0,0)<br /> camera:Move(0,0,-8)<br /> local light = DirectionalLight:Create()<br /> light:SetRotation(35,35,0)<br /> <br /> --Create a self.entity<br /> self.entity = Model:Box(1,1,1) <br /> self.entity:SetColor(0,0,1) <br /> self.entity:SetMass(1) <br /> self.entity:SetGravityMode(false) <br /><br /> --Create a shape<br /> local shape = Shape:Box() <br /> self.entity:SetShape(shape) <br /> shape:Release() <br /><br /> --Add some torque<br /> self.entity:AddTorque(0,1000,0) <br /><br /> return true<br />end<br /><br />function App:Loop()<br /> <br /> if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end<br /><br /> Time:Update()<br /> self.world:Update()<br /> self.world:Render()<br /><br /> self.context:SetBlendMode(Blend.Alpha)<br /> self.context:DrawText("Point velocity: "..self.entity:GetPointVelocity(2,0,0):ToString(),2,2)<br /><br /> self.context:Sync()<br /><br /> return true<br />end Show TOC: False
    • 0 comments
    • 1,569 views
  98. UpdateHook

    Attachments: Show TOC: False
    • 0 comments
    • 551 views
×
×
  • Create New...