This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Frustum Camera::CalculateFrustum(float fnear, float ffar) { | |
Frustum returnFrustum; | |
// Calculate the near and far plane points | |
float nearHeight = 2 * tan(fov / 2) * fnear; | |
float nearWidth = nearHeight * aspect; | |
float farHeight = 2 * tan(fov / 2) * ffar; | |
float farWidth = farHeight * aspect; | |
// And their centers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void ScriptSystem::Update(float delta) { | |
// Global updates | |
ScriptTime::SetDelta(delta); | |
for(int i = 0; i < m_scriptablePoolSize; i++) { | |
if(m_scriptables[i]) { | |
// Set global script variables | |
m_currentObject = m_scriptables[i]; | |
Entity* obj = m_currentObject->GetParent(); | |
MeshInstance* instance = (MeshInstance*)obj->FindComponent<MeshInstance>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Script::Initialize(char* src) { | |
v8::Isolate* isolate = v8::Isolate::GetCurrent(); | |
// Create a stack-allocated handle scope. | |
v8::HandleScope handle_scope(isolate); | |
// Create an instance of the global context so we can plug variables in | |
v8::Local<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float ScriptTime::m_delta = 0; | |
ScriptTime::ScriptTime() { | |
m_delta = 0; | |
} | |
ScriptTime::~ScriptTime() { | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Getter and setter functions for our classes to V8 | |
*/ | |
typedef v8::Local<v8::Value> (*ScriptGlobalGetterFunc)(v8::Isolate*); | |
/** | |
* A storage for getter and setter to variable pairs | |
*/ | |
class ScriptGlobalCallbackPair { | |
public: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A helper class that other types can be inherited from (handles basic V8 integration) | |
*/ | |
class ScriptObject { | |
public: | |
ScriptObject(); | |
~ScriptObject(); | |
/** | |
* Unwrap a v8::object back into a C++ object |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ScriptVector3::ScriptVector3() { | |
m_vector.x = m_vector.y = m_vector.z = 0.0f; | |
} | |
ScriptVector3::ScriptVector3(const v8::FunctionCallbackInfo<v8::Value>& info) { | |
float x, y, z; | |
x = y = z = 0.0f; | |
if(info.Length() == 1) { | |
assert(info[0]->IsNumber()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// scripttype.hpp | |
// eternity | |
// | |
// Created by Terry Smith on 2016-09-13. | |
// Copyright © 2016 Terry Smith. All rights reserved. | |
// | |
#ifndef scripttype_hpp | |
#define scripttype_hpp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Script::Script() { | |
} | |
Script::~Script() { | |
} | |
void Script::Initialize(char* src) { | |
v8::Isolate* isolate = v8::Isolate::GetCurrent(); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <eternity.hpp> | |
ScriptSystem::ScriptSystem() { | |
m_platform = 0; | |
m_isolate = 0; | |
m_scriptableCount = 0; | |
m_scriptablePoolSize = 0; | |
m_scriptables = 0; | |
} |
NewerOlder