Script API registration cleanup: asMETHODPR changed to asMETHOD where possible.
Added Remove() to Component & Node & UIElement; before it was script-only. Renamed FrameUpdate back to FrameInfo. Documentation update.
This commit is contained in:
parent
2a6c10874c
commit
a7a458b3a9
@ -12,9 +12,9 @@ The build process will also compile models and shaders from the Source_Asset dir
|
||||
|
||||
After the build is complete, the programs can be run from the Bin directory.
|
||||
|
||||
To run the main executable Urho3D.exe from the Visual Studio debugger, set it as a startup project and enter its relative path and filename into Debugging -> Command: ..\\Bin\\Urho3D.exe (release) or ..\\Bin\\Urho3D_d.exe (debug.) Entering -w into Debugging -> Command Arguments is highly recommended. This enables startup in windowed mode: without it running into an exception or breakpoint will be obnoxious as the mouse cursor will most probably be hidden.
|
||||
To run Urho3D from the Visual Studio debugger, set it as a startup project and enter its relative path and filename into Properties -> Debugging -> Command: ..\\Bin\\Urho3D.exe (release) or ..\\Bin\\Urho3D_d.exe (debug.) Entering -w into Debugging -> Command Arguments is highly recommended. This enables startup in windowed mode: without it running into an exception or breakpoint will be obnoxious as the mouse cursor will most probably be hidden.
|
||||
|
||||
To actually make Urho3D.exe do something useful, it must be supplied with the name of the script file it should load and run. See \subpage Running "Running Urho3D" for more information, but for a quick test you can try the following Command Arguments: Scripts/TestScene.as -w
|
||||
To actually make Urho3D.exe do something useful, it must be supplied with the name of the script file it should load and run. See \subpage Running "Running Urho3D" for more information, but for a quick test you can try the following arguments: Scripts/TestScene.as -w
|
||||
|
||||
Note: some SM2.0 shaders in Urho3D reach exactly the arithmetic instruction count limit. The fxc.exe in newer DirectX SDK's may fail to compile them. At least the February 2010 SDK is known to work.
|
||||
|
||||
@ -23,7 +23,7 @@ Note: some SM2.0 shaders in Urho3D reach exactly the arithmetic instruction coun
|
||||
|
||||
Urho3D requires Windows XP or newer, DirectX 9.0c, and a display adapter with SM2.0 support. SM3.0 is highly recommended.
|
||||
|
||||
The main executable Urho3d.exe in the Bin directory contains all the engine runtime functionality. However, it does not contain any inbuilt logic or application, and therefore must be supplied with the name of the application script file it should run:
|
||||
The main executable Urho3D.exe in the Bin directory contains all the engine runtime functionality. However, it does not contain any inbuilt logic or application, and therefore must be supplied with the name of the application script file it should run:
|
||||
|
||||
Urho3D.exe <scriptfilename> [options]
|
||||
|
||||
@ -149,13 +149,13 @@ For more details related to the C++ coding style, see also \subpage CodingConven
|
||||
|
||||
When Urho3D.exe executes the application script's Start() function, all the engine subsystems are already in place, so any initialization that needs to be done is specific to the application. In the following example, a minimal "Hello World" application with 3D content will be built.
|
||||
|
||||
First, we need to declare an object handle for the 3D scene we are going to create. This must be outside the Start() function so that the Scene object will remain even when function's the execution ends. Angelscript uses the @ symbol for object handles, which correspond to SharedPtr's on C++ side (ie. they keep alive the object pointed to.)
|
||||
First we need to declare an object handle for the 3D scene we are going to create. This must be outside the Start() function so that the Scene object will remain even when function's the execution ends. Angelscript uses the @ symbol for object handles, which correspond to SharedPtr's on C++ side (ie. they keep alive the object pointed to.)
|
||||
|
||||
\code
|
||||
Scene@ helloScene;
|
||||
\endcode
|
||||
|
||||
Now we can begin with the Start() function. First of all we create the 3D scene. Note the lack of "new" keyword. Then we branch off to further initialization functions that will be explained below.
|
||||
Next is the Start() function. First of all we create the 3D scene. Note the lack of "new" keyword. Then we branch off to further initialization functions that will be explained below.
|
||||
|
||||
Note: Urho3D has tweaked AngelScript slightly to allow object handle assignment without the @ symbol, if the object in question does not support value assignment. None of the Urho3D reference-counted objects, such as Scene, support value assignment. In unmodified AngelScript the line would have to read "@helloScene = Scene()".
|
||||
|
||||
@ -170,7 +170,9 @@ void Start()
|
||||
}
|
||||
\endcode
|
||||
|
||||
Next, the scene will be filled with some content. The Urho3D scene model is basically a scene graph; the Scene object serves also as the root node. Three child nodes will be created: one for a 3D model object, one for a directional light, and one for the camera. The scene nodes themselves display nothing in the 3D world; components need to be created into them for the actual visible content. First, however, we need to create an Octree component into the root node. This is used for accelerated visibility queries to check what the camera "sees", and without it nothing would be visible.
|
||||
In CreateObjects(), which is defined next, the scene will be filled with some content. The Urho3D scene model is basically a scene graph; the Scene object serves also as the root node.
|
||||
|
||||
Three child nodes will be created: one for a 3D model object, one for a directional light, and one for the camera. The scene nodes themselves display nothing in the 3D world; components need to be created into them for the actual visible content. First, however, we need to create an Octree component into the root node. This is used for accelerated visibility queries to check what the camera "sees", and without it nothing would be visible.
|
||||
|
||||
Child nodes can be created with or without names; uniqueness of names is not enforced. In this case we opt to not use names, as we do not need to find the nodes later after creation.
|
||||
|
||||
@ -222,7 +224,7 @@ void CreateText()
|
||||
}
|
||||
\endcode
|
||||
|
||||
The final step we need is to subscribe to the frame update event; otherwise the application would just be left running with no possibility to interact with it, until it was forcibly exited with Alt-F4. The frame update event will be sent on each iteration of the main loop. When subscribing, we need to give the name of the event, and the name of the event handler function. We could also require the event to be sent by a specific sender, but in this case that is unnecessary.
|
||||
The final step is to subscribe to the frame update event; otherwise the application would just be left running with no possibility to interact with it, until it was forcibly exited with Alt-F4. The frame update event will be sent on each iteration of the main loop. When subscribing, we need to give the name of the event, and the name of the event handler function. We could also require the event to be sent by a specific sender, but in this case that is unnecessary.
|
||||
|
||||
\code
|
||||
void SubscribeToEvents()
|
||||
@ -330,7 +332,7 @@ public:
|
||||
};
|
||||
\endcode
|
||||
|
||||
Next, before actual the HelloWorld implementation, we can define WinMain. First, we need to create the Context object, which holds all subsystems and object factories, and keeps track of event senders and receivers. All Object subclasses need to be supplied a pointer to that context. When using an object factory (such as when creating components) that is automatic, but when creating objects manually, the pointer also needs to be passed manually.
|
||||
Before the actual HelloWorld implementation, we define WinMain. First, we need to create the Context object, which holds all subsystems and object factories, and keeps track of event senders and receivers. All Object subclasses need to be supplied a pointer to that context. When using an object factory (such as when creating components) that is automatic, but when creating objects manually, the pointer also needs to be passed manually.
|
||||
|
||||
With the context at hand, we create the Engine and initialize it. The arguments for the Initialize() function are the initial window title, the log file name, and command line parameters, which are parsed using the ParseArguments() helper function.
|
||||
|
||||
@ -352,7 +354,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE prevInstance, PSTR cmdLine, in
|
||||
}
|
||||
\endcode
|
||||
|
||||
Now we can continue with HelloWorld implementation. Note the OBJECTTYPESTATIC macro, which creates the static name and name hash for object type identification. For each OBJECT macro, a matching OBJECTTYPESTATIC must appear in a .cpp file. The reason to do that instead of defining them directly inside the OBJECT macro as function-static data is thread safety: if the first invocation to an object's GetTypeStatic() or GetTypeNameStatic() was started on several threads simultaneously, the results of function-static data initialization would be erratic.
|
||||
Next is the HelloWorld implementation. Note the OBJECTTYPESTATIC macro, which creates the static name and name hash for object type identification. For each OBJECT macro, a matching OBJECTTYPESTATIC must appear in a .cpp file. The reason to do that instead of defining them directly inside the OBJECT macro as function-static data is thread safety: if the first invocation to an object's GetTypeStatic() or GetTypeNameStatic() was started on several threads simultaneously, the results of function-static data initialization would be erratic.
|
||||
|
||||
During construction, we store the ResourceCache subsystem pointer for later access:
|
||||
|
||||
@ -366,7 +368,7 @@ HelloWorld::HelloWorld(Context* context) :
|
||||
}
|
||||
\endcode
|
||||
|
||||
Next is the Start() function, in which the Scene will be created:
|
||||
In the Start() function the Scene will be created:
|
||||
|
||||
\code
|
||||
void HelloWorld::Start()
|
||||
@ -379,7 +381,7 @@ void HelloWorld::Start()
|
||||
}
|
||||
\endcode
|
||||
|
||||
Then we get to scene object creation and defining the viewport. Unlike in script, where properties were used to set the component values and scene node transforms, here we must use setter functions instead. Also, whereas strings were used in script to identify the components to create, here it is most convenient to use the template form of CreateComponent():
|
||||
Next is scene object creation and defining the viewport. Unlike in script, where properties were used to set the component values and scene node transforms, here we must use setter functions instead. Also, whereas strings were used in script to identify the components to create, here it is most convenient to use the template form of CreateComponent():
|
||||
|
||||
\code
|
||||
void HelloWorld::CreateObjects()
|
||||
@ -405,7 +407,7 @@ void HelloWorld::CreateObjects()
|
||||
}
|
||||
\endcode
|
||||
|
||||
Next is the text overlay creation:
|
||||
The text overlay creation is next. Again, setters are used throughout:
|
||||
|
||||
\code
|
||||
void HelloWorld::CreateText()
|
||||
|
@ -1,5 +1,8 @@
|
||||
/**
|
||||
|
||||
\page ObjectTypes Object types and factories
|
||||
|
||||
|
||||
\page Subsystems Subsystems
|
||||
|
||||
|
||||
@ -15,15 +18,15 @@
|
||||
\page Resources Resources
|
||||
|
||||
|
||||
\page Scripting Scripting
|
||||
|
||||
|
||||
\page Rendering Rendering
|
||||
|
||||
|
||||
\page Input Input
|
||||
|
||||
|
||||
\page Network Networking
|
||||
|
||||
|
||||
\page Audio Audio
|
||||
|
||||
|
||||
@ -33,7 +36,10 @@
|
||||
\page UI User interface
|
||||
|
||||
|
||||
\page Scripting Scripting internals
|
||||
\page Serialization Serialization
|
||||
|
||||
|
||||
\page Network Networking
|
||||
|
||||
|
||||
\page Tools Tools
|
||||
|
@ -15,18 +15,20 @@ For getting started, see:
|
||||
|
||||
For further reference, see:
|
||||
|
||||
\subpage ObjectTypes "Object types and factories" <br>
|
||||
\subpage Subsystems "Subsystems" <br>
|
||||
\subpage Events "Events" <br>
|
||||
\subpage MainLoop "Main loop and frame update" <br>
|
||||
\subpage SceneModel "Scene model" <br>
|
||||
\subpage Scripting "Scripting" <br>
|
||||
\subpage Resources "Resources" <br>
|
||||
\subpage Scripting "Scripting" <br>
|
||||
\subpage Rendering "Rendering" <br>
|
||||
\subpage Input "Input" <br>
|
||||
\subpage Network "Networking" <br>
|
||||
\subpage Audio "Audio" <br>
|
||||
\subpage Physics "Physics" <br>
|
||||
\subpage UI "User interface" <br>
|
||||
\subpage Serialization "Serialization" <br>
|
||||
\subpage Network "Networking" <br>
|
||||
\subpage Tools "Tools" <br>
|
||||
\subpage FileFormats "Custom file formats" <br>
|
||||
\subpage CodingConventions "Coding conventions" <br>
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "Context.h"
|
||||
#include "Drawable.h"
|
||||
#include "File.h"
|
||||
#include "Renderer.h"
|
||||
#include "Resource.h"
|
||||
#include "Script.h"
|
||||
#include "ScriptInstance.h"
|
||||
@ -304,19 +305,12 @@ template <class T> void RegisterSerializable(asIScriptEngine* engine, const char
|
||||
RegisterSubclass<Object, T>(engine, "Serializable", className);
|
||||
}
|
||||
|
||||
static void ComponentRemoveSelf(Component* ptr)
|
||||
{
|
||||
Node* node = ptr->GetNode();
|
||||
if (node)
|
||||
node->RemoveComponent(ptr);
|
||||
}
|
||||
|
||||
/// Template function for registering a class derived from Component
|
||||
template <class T> void RegisterComponent(asIScriptEngine* engine, const char* className, bool nodeRegistered = true)
|
||||
{
|
||||
RegisterSerializable<T>(engine, className);
|
||||
RegisterSubclass<Component, T>(engine, "Component", className);
|
||||
engine->RegisterObjectMethod(className, "void Remove()", asFUNCTION(ComponentRemoveSelf), asCALL_CDECL_OBJLAST);
|
||||
engine->RegisterObjectMethod(className, "void Remove()", asMETHODPR(T, Remove, (), void), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "uint get_id()", asMETHODPR(T, GetID, () const, unsigned), asCALL_THISCALL);
|
||||
if (nodeRegistered)
|
||||
engine->RegisterObjectMethod(className, "Node@+ get_node() const", asMETHODPR(T, GetNode, () const, Node*), asCALL_THISCALL);
|
||||
@ -407,13 +401,6 @@ static Node* NodeGetChild(unsigned index, Node* ptr)
|
||||
return children[index].GetPtr();
|
||||
}
|
||||
|
||||
static void NodeRemoveSelf(Node* ptr)
|
||||
{
|
||||
Node* parent = ptr->GetParent();
|
||||
if (parent)
|
||||
parent->RemoveChild(ptr);
|
||||
}
|
||||
|
||||
static CScriptArray* NodeGetScriptedChildren(bool recursive, Node* ptr)
|
||||
{
|
||||
std::vector<Node*> nodes;
|
||||
@ -454,20 +441,20 @@ template <class T> void RegisterNode(asIScriptEngine* engine, const char* classN
|
||||
engine->RegisterObjectMethod(className, "void SetTransform(const Vector3& in, const Quaternion& in, float)", asMETHODPR(T, SetTransform, (const Vector3&, const Quaternion&, float), void), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void SetTransform(const Vector3& in, const Quaternion& in, const Vector3& in)", asMETHODPR(T, SetTransform, (const Vector3&, const Quaternion&, const Vector3&), void), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void SetScale(float)", asMETHODPR(T, SetScale, (float), void), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void Translate(const Vector3& in)", asMETHODPR(T, Translate, (const Vector3&), void), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void TranslateRelative(const Vector3& in)", asMETHODPR(T, TranslateRelative, (const Vector3&), void), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void Rotate(const Quaternion& in, bool)", asMETHODPR(T, Rotate, (const Quaternion&, bool), void), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void Pitch(float, bool)", asMETHODPR(T, Pitch, (float, bool), void), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void Yaw(float, bool)", asMETHODPR(T, Yaw, (float, bool), void), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void Roll(float, bool)", asMETHODPR(T, Roll, (float, bool), void), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void Translate(const Vector3& in)", asMETHOD(T, Translate), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void TranslateRelative(const Vector3& in)", asMETHOD(T, TranslateRelative), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void Rotate(const Quaternion& in, bool)", asMETHOD(T, Rotate), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void Pitch(float, bool)", asMETHOD(T, Pitch), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void Yaw(float, bool)", asMETHOD(T, Yaw), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void Roll(float, bool)", asMETHOD(T, Roll), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void Scale(float)", asMETHODPR(T, Scale, (float), void), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void Scale(const Vector3& in)", asMETHODPR(T, Scale, (const Vector3&), void), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "Node@+ CreateChild(const String& in)", asMETHODPR(T, CreateChild, (const std::string&), Node*), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "Node@+ CreateChild()", asFUNCTION(NodeCreateChild), asCALL_CDECL_OBJLAST);
|
||||
engine->RegisterObjectMethod(className, "void AddChild(Node@+)", asMETHODPR(T, AddChild, (Node*), void), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void AddChild(Node@+)", asMETHOD(T, AddChild), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void RemoveChild(Node@+)", asMETHODPR(T, RemoveChild, (Node*), void), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void RemoveAllChildren()", asMETHODPR(T, RemoveAllChildren, (), void), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void Remove()", asFUNCTION(NodeRemoveSelf), asCALL_CDECL_OBJLAST);
|
||||
engine->RegisterObjectMethod(className, "void RemoveAllChildren()", asMETHOD(T, RemoveAllChildren), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void Remove()", asMETHOD(T, Remove), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "Component@+ CreateComponent(const String& in)", asFUNCTION(NodeCreateComponent), asCALL_CDECL_OBJLAST);
|
||||
engine->RegisterObjectMethod(className, "Component@+ GetOrCreateComponent(const String& in)", asFUNCTION(NodeGetOrCreateComponent), asCALL_CDECL_OBJLAST);
|
||||
engine->RegisterObjectMethod(className, "Array<Node@>@ GetChildren(bool) const", asFUNCTION(NodeGetChildren), asCALL_CDECL_OBJLAST);
|
||||
@ -479,28 +466,28 @@ template <class T> void RegisterNode(asIScriptEngine* engine, const char* classN
|
||||
engine->RegisterObjectMethod(className, "bool HasComponent(const String& in) const", asFUNCTION(NodeHasComponent), asCALL_CDECL_OBJLAST);
|
||||
engine->RegisterObjectMethod(className, "Component@+ GetComponent(const String& in) const", asFUNCTION(NodeGetComponentWithType), asCALL_CDECL_OBJLAST);
|
||||
engine->RegisterObjectMethod(className, "Component@+ GetComponent(const String& in, uint) const", asFUNCTION(NodeGetComponentWithTypeAndIndex), asCALL_CDECL_OBJLAST);
|
||||
engine->RegisterObjectMethod(className, "void set_position(const Vector3& in)", asMETHODPR(T, SetPosition, (const Vector3&), void), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "const Vector3& get_position() const", asMETHODPR(T, GetPosition, () const, const Vector3&), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void set_rotation(const Quaternion& in)", asMETHODPR(T, SetRotation, (const Quaternion&), void), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "const Quaternion& get_rotation() const", asMETHODPR(T, GetRotation, () const, const Quaternion&), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void set_direction(const Vector3& in)", asMETHODPR(T, SetDirection, (const Vector3&), void), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "Vector3 get_direction() const", asMETHODPR(T, GetDirection, () const, Vector3), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void set_position(const Vector3& in)", asMETHOD(T, SetPosition), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "const Vector3& get_position() const", asMETHOD(T, GetPosition), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void set_rotation(const Quaternion& in)", asMETHOD(T, SetRotation), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "const Quaternion& get_rotation() const", asMETHOD(T, GetRotation), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void set_direction(const Vector3& in)", asMETHOD(T, SetDirection), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "Vector3 get_direction() const", asMETHOD(T, GetDirection), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void set_scale(const Vector3& in)", asMETHODPR(T, SetScale, (const Vector3&), void), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "const Vector3& get_scale() const", asMETHODPR(T, GetScale, () const, const Vector3&), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "Vector3 get_worldPosition()", asMETHODPR(T, GetWorldPosition, (), Vector3), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "Quaternion get_worldRotation()", asMETHODPR(T, GetWorldRotation, (), Quaternion), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "Vector3 get_worldDirection()", asMETHODPR(T, GetWorldDirection, (), Vector3), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "Vector3 get_worldScale()", asMETHODPR(T, GetWorldScale, (), Vector3), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "uint get_id()", asMETHODPR(T, GetID, () const, unsigned), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "const Vector3& get_scale() const", asMETHOD(T, GetScale), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "Vector3 get_worldPosition()", asMETHOD(T, GetWorldPosition), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "Quaternion get_worldRotation()", asMETHOD(T, GetWorldRotation), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "Vector3 get_worldDirection()", asMETHOD(T, GetWorldDirection), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "Vector3 get_worldScale()", asMETHOD(T, GetWorldScale), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "uint get_id()", asMETHOD(T, GetID), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "uint get_numChildren() const", asFUNCTION(NodeGetNumChildrenNonRecursive), asCALL_CDECL_OBJLAST);
|
||||
engine->RegisterObjectMethod(className, "uint get_numAllChildren() const", asFUNCTION(NodeGetNumChildrenRecursive), asCALL_CDECL_OBJLAST);
|
||||
engine->RegisterObjectMethod(className, "Node@+ get_children(uint) const", asFUNCTION(NodeGetChild), asCALL_CDECL_OBJLAST);
|
||||
engine->RegisterObjectMethod(className, "uint get_numComponents() const", asMETHODPR(T, GetNumComponents, () const, unsigned), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "uint get_numComponents() const", asMETHOD(T, GetNumComponents), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "Component@+ get_components(uint) const", asFUNCTION(NodeGetComponent), asCALL_CDECL_OBJLAST);
|
||||
engine->RegisterObjectMethod(className, "void set_name(const String& in)", asMETHODPR(T, SetName, (const std::string&), void), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "const String& get_name() const", asMETHODPR(T, GetName, () const, const std::string&), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void set_parent(Node@+)", asMETHODPR(T, SetParent, (Node*), void), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "Node@+ get_parent() const", asMETHODPR(T, GetParent, () const, Node*), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void set_name(const String& in)", asMETHOD(T, SetName), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "const String& get_name() const", asMETHOD(T, GetName), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void set_parent(Node@+)", asMETHOD(T, SetParent), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "Node@+ get_parent() const", asMETHOD(T, GetParent), asCALL_THISCALL);
|
||||
}
|
||||
|
||||
static bool ResourceLoad(File* file, XMLFile* ptr)
|
||||
@ -538,29 +525,39 @@ template <class T> void RegisterResource(asIScriptEngine* engine, const char* cl
|
||||
engine->RegisterObjectMethod(className, "uint get_useTimer()" ,asMETHODPR(T, GetUseTimer, (), unsigned), asCALL_THISCALL);
|
||||
}
|
||||
|
||||
static bool DrawableIsInView(Drawable* ptr)
|
||||
{
|
||||
// Get the last frame number processed by the Renderer to be able to check
|
||||
Renderer* renderer = GetScriptContext()->GetSubsystem<Renderer>();
|
||||
if (!renderer)
|
||||
return false;
|
||||
const FrameInfo& frame = renderer->GetFrameInfo();
|
||||
return ptr->IsInView(frame.frameNumber_);
|
||||
}
|
||||
|
||||
/// Template function for registering a class derived from Drawable
|
||||
template <class T> void RegisterDrawable(asIScriptEngine* engine, const char* className)
|
||||
{
|
||||
RegisterComponent<T>(engine, className);
|
||||
RegisterSubclass<Drawable, T>(engine, "Drawable", className);
|
||||
engine->RegisterObjectMethod(className, "bool IsInView(uint) const", asMETHODPR(T, IsInView, (unsigned) const, bool), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void set_castShadows(bool)", asMETHODPR(T, SetCastShadows, (bool), void), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "bool get_castShadows() const", asMETHODPR(T, GetCastShadows, () const, bool), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void set_occluder(bool)", asMETHODPR(T, SetOccluder, (bool), void), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "bool get_occluder() const", asMETHODPR(T, IsOccluder, () const, bool), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void set_visible(bool)", asMETHODPR(T, SetVisible, (bool), void), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "bool get_visible() const", asMETHODPR(T, IsVisible, () const, bool), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void set_drawDistance(float)", asMETHODPR(T, SetDrawDistance, (float), void), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "float get_drawDistance() const", asMETHODPR(T, GetDrawDistance, () const, float), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void set_shadowDistance(float)", asMETHODPR(T, SetShadowDistance, (float), void), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "float get_shadowDistance() const", asMETHODPR(T, GetShadowDistance, () const, float), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void set_lodBias(float)", asMETHODPR(T, SetLodBias, (float), void), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "float get_lodBias() const", asMETHODPR(T, GetLodBias, () const, float), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void set_viewMask(uint)", asMETHODPR(T, SetViewMask, (unsigned), void), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "uint get_viewMask() const", asMETHODPR(T, GetViewMask, () const, unsigned), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void set_lightMask(uint)", asMETHODPR(T, SetLightMask, (unsigned), void), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "uint get_lightMask() const", asMETHODPR(T, GetLightMask, () const, unsigned), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "const BoundingBox& get_worldBoundingBox()", asMETHODPR(T, GetWorldBoundingBox, (), const BoundingBox&), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "bool IsInView() const", asFUNCTION(DrawableIsInView), asCALL_CDECL_OBJLAST);
|
||||
engine->RegisterObjectMethod(className, "void set_castShadows(bool)", asMETHOD(T, SetCastShadows), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "bool get_castShadows() const", asMETHOD(T, GetCastShadows), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void set_occluder(bool)", asMETHOD(T, SetOccluder), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "bool get_occluder() const", asMETHOD(T, IsOccluder), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void set_visible(bool)", asMETHOD(T, SetVisible), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "bool get_visible() const", asMETHOD(T, IsVisible), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void set_drawDistance(float)", asMETHOD(T, SetDrawDistance), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "float get_drawDistance() const", asMETHOD(T, GetDrawDistance), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void set_shadowDistance(float)", asMETHOD(T, SetShadowDistance), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "float get_shadowDistance() const", asMETHOD(T, GetShadowDistance), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void set_lodBias(float)", asMETHOD(T, SetLodBias), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "float get_lodBias() const", asMETHOD(T, GetLodBias), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void set_viewMask(uint)", asMETHOD(T, SetViewMask), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "uint get_viewMask() const", asMETHOD(T, GetViewMask), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void set_lightMask(uint)", asMETHOD(T, SetLightMask), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "uint get_lightMask() const", asMETHOD(T, GetLightMask), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "const BoundingBox& get_worldBoundingBox()", asMETHOD(T, GetWorldBoundingBox), asCALL_THISCALL);
|
||||
}
|
||||
|
||||
/// Template function for registering a class derived from SoundSource
|
||||
@ -573,20 +570,20 @@ template <class T> void RegisterSoundSource(asIScriptEngine* engine, const char*
|
||||
engine->RegisterObjectMethod(className, "void Play(Sound@+, float, float)", asMETHODPR(T, Play, (Sound*, float, float), void), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void Play(Sound@+, float, float, float)", asMETHODPR(T, Play, (Sound*, float, float, float), void), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void Stop()", asMETHOD(T, Stop), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void set_soundType(SoundType)", asMETHODPR(T, SetSoundType, (SoundType), void), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "SoundType get_soundType() const", asMETHODPR(T, GetSoundType, () const, SoundType), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void set_frequency(float)", asMETHODPR(T, SetFrequency, (float), void), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "float get_frequency() const", asMETHODPR(T, GetFrequency, () const, float), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void set_gain(float)", asMETHODPR(T, SetGain, (float), void), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "float get_gain() const", asMETHODPR(T, GetGain, () const, float), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void set_panning(float)", asMETHODPR(T, SetPanning, (float), void), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "float get_panning() const", asMETHODPR(T, GetPanning, () const, float), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "Sound@+ get_soundClip() const", asMETHODPR(T, GetSound, () const, Sound*), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "float get_timePosition() const", asMETHODPR(T, GetTimePosition, () const, float), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "float get_attenuation() const", asMETHODPR(T, GetAttenuation, () const, float), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void set_autoRemove(bool)", asMETHODPR(T, SetAutoRemove, (bool), void), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "bool get_autoRemove() const", asMETHODPR(T, GetAutoRemove, () const, bool), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "bool get_playing() const", asMETHODPR(T, IsPlaying, () const, bool), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void set_soundType(SoundType)", asMETHOD(T, SetSoundType), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "SoundType get_soundType() const", asMETHOD(T, GetSoundType), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void set_frequency(float)", asMETHOD(T, SetFrequency), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "float get_frequency() const", asMETHOD(T, GetFrequency), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void set_gain(float)", asMETHOD(T, SetGain), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "float get_gain() const", asMETHOD(T, GetGain), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void set_panning(float)", asMETHOD(T, SetPanning), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "float get_panning() const", asMETHOD(T, GetPanning), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "Sound@+ get_sound() const", asMETHOD(T, GetSound), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "float get_timePosition() const", asMETHOD(T, GetTimePosition), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "float get_attenuation() const", asMETHOD(T, GetAttenuation), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void set_autoRemove(bool)", asMETHOD(T, SetAutoRemove), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "bool get_autoRemove() const", asMETHOD(T, GetAutoRemove), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "bool get_playing() const", asMETHOD(T, IsPlaying), asCALL_THISCALL);
|
||||
}
|
||||
|
||||
/// Template function for registering a class derived from Texture
|
||||
@ -612,13 +609,6 @@ template <class T> void RegisterTexture(asIScriptEngine* engine, const char* cla
|
||||
engine->RegisterObjectMethod(className, "bool get_dataLost() const", asMETHOD(T, IsDataLost), asCALL_THISCALL);
|
||||
}
|
||||
|
||||
static void UIElementRemoveSelf(UIElement* ptr)
|
||||
{
|
||||
UIElement* parent = ptr->GetParent();
|
||||
if (parent)
|
||||
parent->RemoveChild(ptr);
|
||||
}
|
||||
|
||||
/// Template function for registering a class derived from UIElement
|
||||
template <class T> void RegisterUIElement(asIScriptEngine* engine, const char* className)
|
||||
{
|
||||
@ -647,7 +637,7 @@ template <class T> void RegisterUIElement(asIScriptEngine* engine, const char* c
|
||||
engine->RegisterObjectMethod(className, "void InsertChild(uint, UIElement@+)", asMETHOD(T, InsertChild), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void RemoveChild(UIElement@+)", asMETHOD(T, RemoveChild), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void RemoveAllChildren()", asMETHOD(T, RemoveAllChildren), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "void Remove()", asFUNCTION(UIElementRemoveSelf), asCALL_CDECL_OBJLAST);
|
||||
engine->RegisterObjectMethod(className, "void Remove()", asMETHOD(T, Remove), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "UIElement@+ GetChild(const String& in, bool) const", asMETHODPR(T, GetChild, (const std::string&, bool) const, UIElement*), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "IntVector2 ScreenToElement(const IntVector2& in)", asMETHOD(T, ScreenToElement), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod(className, "IntVector2 ElementToScreen(const IntVector2& in)", asMETHOD(T, ElementToScreen), asCALL_THISCALL);
|
||||
|
@ -35,7 +35,6 @@
|
||||
#include "Octree.h"
|
||||
#include "OctreeQuery.h"
|
||||
#include "ParticleEmitter.h"
|
||||
#include "Renderer.h"
|
||||
#include "Scene.h"
|
||||
#include "Technique.h"
|
||||
#include "Texture2D.h"
|
||||
|
@ -274,7 +274,7 @@ void AnimatedModel::ProcessRayQuery(RayOctreeQuery& query, float initialDistance
|
||||
}
|
||||
}
|
||||
|
||||
void AnimatedModel::Update(const FrameUpdate& frame)
|
||||
void AnimatedModel::Update(const FrameInfo& frame)
|
||||
{
|
||||
// Update animation here
|
||||
if ((!animationDirty_) && (!animationOrderDirty_))
|
||||
@ -298,7 +298,7 @@ void AnimatedModel::Update(const FrameUpdate& frame)
|
||||
UpdateAnimation(frame);
|
||||
}
|
||||
|
||||
void AnimatedModel::UpdateDistance(const FrameUpdate& frame)
|
||||
void AnimatedModel::UpdateDistance(const FrameInfo& frame)
|
||||
{
|
||||
distance_ = frame.camera_->GetDistance(GetWorldPosition());
|
||||
|
||||
@ -321,7 +321,7 @@ void AnimatedModel::UpdateDistance(const FrameUpdate& frame)
|
||||
}
|
||||
}
|
||||
|
||||
void AnimatedModel::UpdateGeometry(const FrameUpdate& frame)
|
||||
void AnimatedModel::UpdateGeometry(const FrameInfo& frame)
|
||||
{
|
||||
if (lodLevelsDirty_)
|
||||
CalculateLodLevels();
|
||||
@ -333,7 +333,7 @@ void AnimatedModel::UpdateGeometry(const FrameUpdate& frame)
|
||||
UpdateSkinning();
|
||||
}
|
||||
|
||||
void AnimatedModel::GetBatch(const FrameUpdate& frame, unsigned batchIndex, Batch& batch)
|
||||
void AnimatedModel::GetBatch(const FrameInfo& frame, unsigned batchIndex, Batch& batch)
|
||||
{
|
||||
batch.geometry_ = geometries_[batchIndex][lodLevels_[batchIndex]];
|
||||
batch.geometryType_ = GEOM_SKINNED;
|
||||
@ -891,7 +891,7 @@ void AnimatedModel::RefreshGeometryBoneMappings()
|
||||
}
|
||||
}
|
||||
|
||||
void AnimatedModel::UpdateAnimation(const FrameUpdate& frame)
|
||||
void AnimatedModel::UpdateAnimation(const FrameInfo& frame)
|
||||
{
|
||||
// If using animation LOD, accumulate time and see if it is time to update
|
||||
if ((animationLodBias_ > 0.0f) && (animationLodDistance_ > 0.0f))
|
||||
|
@ -57,13 +57,13 @@ public:
|
||||
/// Process renderer raycast
|
||||
virtual void ProcessRayQuery(RayOctreeQuery& query, float initialDistance);
|
||||
/// Update before octree reinsertion. Animation is updated here
|
||||
virtual void Update(const FrameUpdate& frame);
|
||||
virtual void Update(const FrameInfo& frame);
|
||||
/// Calculate distance for rendering
|
||||
virtual void UpdateDistance(const FrameUpdate& frame);
|
||||
virtual void UpdateDistance(const FrameInfo& frame);
|
||||
/// Prepare geometry for rendering
|
||||
virtual void UpdateGeometry(const FrameUpdate& frame);
|
||||
virtual void UpdateGeometry(const FrameInfo& frame);
|
||||
/// Return rendering batch
|
||||
virtual void GetBatch(const FrameUpdate& frame, unsigned batchIndex, Batch& batch);
|
||||
virtual void GetBatch(const FrameInfo& frame, unsigned batchIndex, Batch& batch);
|
||||
/// Add debug geometry to the debug graphics
|
||||
virtual void DrawDebugGeometry(DebugRenderer* debug, bool depthTest);
|
||||
|
||||
@ -151,7 +151,7 @@ private:
|
||||
/// Clone geometries as required
|
||||
void cloneGeometries();
|
||||
/// Recalculate animations. Called from updateNode()
|
||||
void UpdateAnimation(const FrameUpdate& frame);
|
||||
void UpdateAnimation(const FrameInfo& frame);
|
||||
/// Recalculate skinning
|
||||
void UpdateSkinning();
|
||||
/// Reapply all vertex morphs
|
||||
|
@ -160,7 +160,7 @@ Variant BillboardSet::OnGetAttribute(const AttributeInfo& attr)
|
||||
|
||||
}
|
||||
|
||||
void BillboardSet::UpdateDistance(const FrameUpdate& frame)
|
||||
void BillboardSet::UpdateDistance(const FrameInfo& frame)
|
||||
{
|
||||
// Check if position relative to camera has changed, and re-sort in that case
|
||||
const Vector3& worldPos = GetWorldPosition();
|
||||
@ -191,7 +191,7 @@ void BillboardSet::UpdateDistance(const FrameUpdate& frame)
|
||||
lodDistance_ = 0.0f;
|
||||
}
|
||||
|
||||
void BillboardSet::UpdateGeometry(const FrameUpdate& frame)
|
||||
void BillboardSet::UpdateGeometry(const FrameInfo& frame)
|
||||
{
|
||||
if (bufferSizeDirty_)
|
||||
{
|
||||
@ -213,7 +213,7 @@ unsigned BillboardSet::GetNumBatches()
|
||||
return 1;
|
||||
}
|
||||
|
||||
void BillboardSet::GetBatch(const FrameUpdate& frame, unsigned batchIndex, Batch& batch)
|
||||
void BillboardSet::GetBatch(const FrameInfo& frame, unsigned batchIndex, Batch& batch)
|
||||
{
|
||||
batch.geometry_ = geometry_;
|
||||
batch.geometryType_ = GEOM_BILLBOARD;
|
||||
@ -358,7 +358,7 @@ void BillboardSet::UpdateBufferSize()
|
||||
indexBuffer_->Unlock();
|
||||
}
|
||||
|
||||
void BillboardSet::UpdateVertexBuffer(const FrameUpdate& frame)
|
||||
void BillboardSet::UpdateVertexBuffer(const FrameInfo& frame)
|
||||
{
|
||||
// If using animation LOD, accumulate time and see if it is time to update
|
||||
if ((animationLodBias_ > 0.0f) && (lodDistance_ > 0.0f))
|
||||
|
@ -68,13 +68,13 @@ public:
|
||||
/// Handle attribute read access
|
||||
virtual Variant OnGetAttribute(const AttributeInfo& attr);
|
||||
/// Calculate distance for rendering
|
||||
virtual void UpdateDistance(const FrameUpdate& frame);
|
||||
virtual void UpdateDistance(const FrameInfo& frame);
|
||||
/// Prepare geometry for rendering
|
||||
virtual void UpdateGeometry(const FrameUpdate& frame);
|
||||
virtual void UpdateGeometry(const FrameInfo& frame);
|
||||
/// Return number of batches
|
||||
virtual unsigned GetNumBatches();
|
||||
/// Return rendering batch
|
||||
virtual void GetBatch(const FrameUpdate& frame, unsigned batchIndex, Batch& batch);
|
||||
virtual void GetBatch(const FrameInfo& frame, unsigned batchIndex, Batch& batch);
|
||||
|
||||
/// Set material
|
||||
void SetMaterial(Material* material);
|
||||
@ -133,7 +133,7 @@ private:
|
||||
/// Resize billboard vertex and index buffers
|
||||
void UpdateBufferSize();
|
||||
/// Rewrite billboard vertex buffer
|
||||
void UpdateVertexBuffer(const FrameUpdate& frame);
|
||||
void UpdateVertexBuffer(const FrameInfo& frame);
|
||||
|
||||
/// Geometry
|
||||
SharedPtr<Geometry> geometry_;
|
||||
|
@ -90,7 +90,7 @@ void Drawable::ProcessRayQuery(RayOctreeQuery& query, float initialDistance)
|
||||
query.result_.push_back(result);
|
||||
}
|
||||
|
||||
void Drawable::UpdateDistance(const FrameUpdate& frame)
|
||||
void Drawable::UpdateDistance(const FrameInfo& frame)
|
||||
{
|
||||
distance_ = frame.camera_->GetDistance(GetWorldPosition());
|
||||
|
||||
@ -171,13 +171,13 @@ const BoundingBox& Drawable::GetWorldBoundingBox()
|
||||
return worldBoundingBox_;
|
||||
}
|
||||
|
||||
void Drawable::MarkInView(const FrameUpdate& frame)
|
||||
void Drawable::MarkInView(const FrameInfo& frame)
|
||||
{
|
||||
viewFrameNumber_ = frame.frameNumber_;
|
||||
viewCamera_ = frame.camera_;
|
||||
}
|
||||
|
||||
void Drawable::MarkInShadowView(const FrameUpdate& frame)
|
||||
void Drawable::MarkInShadowView(const FrameInfo& frame)
|
||||
{
|
||||
if (viewFrameNumber_ != frame.frameNumber_)
|
||||
{
|
||||
@ -240,7 +240,7 @@ bool Drawable::IsInView(unsigned frameNumber) const
|
||||
return viewFrameNumber_ == frameNumber;
|
||||
}
|
||||
|
||||
bool Drawable::IsInView(const FrameUpdate& frame) const
|
||||
bool Drawable::IsInView(const FrameInfo& frame) const
|
||||
{
|
||||
return (viewFrameNumber_ == frame.frameNumber_) && (viewCamera_ == frame.camera_);
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ class Octant;
|
||||
class RayOctreeQuery;
|
||||
|
||||
/// Rendering frame update parameters
|
||||
struct FrameUpdate
|
||||
struct FrameInfo
|
||||
{
|
||||
/// Frame number
|
||||
unsigned frameNumber_;
|
||||
@ -75,15 +75,15 @@ public:
|
||||
/// Process octree raycast
|
||||
virtual void ProcessRayQuery(RayOctreeQuery& query, float initialDistance);
|
||||
/// Update before octree reinsertion. Needs to be requested with MarkForUpdate()
|
||||
virtual void Update(const FrameUpdate& frame) {}
|
||||
virtual void Update(const FrameInfo& frame) {}
|
||||
/// Calculate distance for rendering
|
||||
virtual void UpdateDistance(const FrameUpdate& frame);
|
||||
virtual void UpdateDistance(const FrameInfo& frame);
|
||||
/// Prepare geometry for rendering
|
||||
virtual void UpdateGeometry(const FrameUpdate& frame) {}
|
||||
virtual void UpdateGeometry(const FrameInfo& frame) {}
|
||||
/// Return number of rendering batches
|
||||
virtual unsigned GetNumBatches() { return 0; }
|
||||
/// Return rendering batch
|
||||
virtual void GetBatch(const FrameUpdate& frame, unsigned batchIndex, Batch& batch) {}
|
||||
virtual void GetBatch(const FrameInfo& frame, unsigned batchIndex, Batch& batch) {}
|
||||
/// Draw to occlusion buffer
|
||||
virtual bool DrawOcclusion(OcclusionBuffer* buffer) { return true; }
|
||||
/// Draw debug geometry
|
||||
@ -138,9 +138,9 @@ public:
|
||||
/// Set sorting value. Called by View
|
||||
void SetSortValue(float value);
|
||||
/// Mark in view this frame. Called by View
|
||||
void MarkInView(const FrameUpdate& frame);
|
||||
void MarkInView(const FrameInfo& frame);
|
||||
/// Mark in a shadow camera view this frame. If an actual view is already set, does not override it. Called by View
|
||||
void MarkInShadowView(const FrameUpdate& frame);
|
||||
void MarkInShadowView(const FrameInfo& frame);
|
||||
/// Clear base pass flags. Also resets light vector
|
||||
void ClearBasePass();
|
||||
/// Set base pass flag for a batch
|
||||
@ -158,7 +158,7 @@ public:
|
||||
/// Return whether is in view this frame
|
||||
bool IsInView(unsigned frameNumber) const;
|
||||
/// Return whether is visible in a specific view this frame
|
||||
bool IsInView(const FrameUpdate& frame) const;
|
||||
bool IsInView(const FrameInfo& frame) const;
|
||||
/// Return whether has a base pass
|
||||
bool HasBasePass(unsigned batchIndex) const { return (basePassFlags_ & (1 << batchIndex)) != 0; }
|
||||
/// Return lights
|
||||
|
@ -182,7 +182,7 @@ Variant Light::OnGetAttribute(const AttributeInfo& attr)
|
||||
}
|
||||
}
|
||||
|
||||
void Light::UpdateDistance(const FrameUpdate& frame)
|
||||
void Light::UpdateDistance(const FrameInfo& frame)
|
||||
{
|
||||
switch (lightType_)
|
||||
{
|
||||
|
@ -150,7 +150,7 @@ public:
|
||||
/// Handle attribute read access
|
||||
virtual Variant OnGetAttribute(const AttributeInfo& attr);
|
||||
/// Calculate distance for rendering
|
||||
virtual void UpdateDistance(const FrameUpdate& frame);
|
||||
virtual void UpdateDistance(const FrameInfo& frame);
|
||||
/// Add debug geometry to the debug graphics
|
||||
virtual void DrawDebugGeometry(DebugRenderer* debug, bool depthTest);
|
||||
|
||||
|
@ -325,7 +325,7 @@ void Octree::Resize(const BoundingBox& box, unsigned numLevels)
|
||||
numLevels_ = numLevels;
|
||||
}
|
||||
|
||||
void Octree::Update(const FrameUpdate& frame)
|
||||
void Octree::Update(const FrameInfo& frame)
|
||||
{
|
||||
{
|
||||
PROFILE(UpdateDrawables);
|
||||
|
@ -165,7 +165,7 @@ public:
|
||||
/// Resize octree. If octree is not empty, drawable objects will be temporarily moved to the root
|
||||
void Resize(const BoundingBox& box, unsigned numLevels);
|
||||
/// Update and reinsert drawable objects
|
||||
void Update(const FrameUpdate& frame);
|
||||
void Update(const FrameInfo& frame);
|
||||
|
||||
/// Return drawable objects by a query
|
||||
void GetDrawables(OctreeQuery& query) const;
|
||||
|
@ -264,7 +264,7 @@ Renderer::Renderer(Context* context) :
|
||||
defaultZone_(new Zone(context)),
|
||||
numViews_(0),
|
||||
numShadowCameras_(0),
|
||||
nusplitLights__(0),
|
||||
numSplitLights_(0),
|
||||
numTempNodes_(0),
|
||||
specularLighting_(true),
|
||||
drawShadows_(true),
|
||||
@ -563,7 +563,7 @@ void Renderer::Update(float timeStep)
|
||||
frame_.timeStep_ = timeStep;
|
||||
frame_.camera_ = 0;
|
||||
numShadowCameras_ = 0;
|
||||
nusplitLights__ = 0;
|
||||
numSplitLights_ = 0;
|
||||
numTempNodes_ = 0;
|
||||
updateOctrees_.clear();
|
||||
|
||||
@ -1301,13 +1301,13 @@ Camera* Renderer::CreateShadowCamera()
|
||||
|
||||
Light* Renderer::CreateSplitLight(Light* original)
|
||||
{
|
||||
if (nusplitLights__ >= splitLightStore_.size())
|
||||
if (numSplitLights_ >= splitLightStore_.size())
|
||||
splitLightStore_.push_back(SharedPtr<Light>(new Light(context_)));
|
||||
Light* light = splitLightStore_[nusplitLights__];
|
||||
Light* light = splitLightStore_[numSplitLights_];
|
||||
light->SetNode(CreateTempNode());
|
||||
light->copyFrom(original);
|
||||
|
||||
++nusplitLights__;
|
||||
++numSplitLights_;
|
||||
return light;
|
||||
}
|
||||
|
||||
|
@ -242,6 +242,8 @@ public:
|
||||
VertexShader* GetVertexShader(const std::string& name, bool checkExists = false) const;
|
||||
/// Return a pixel shader by name
|
||||
PixelShader* GetPixelShader(const std::string& name, bool checkExists = false) const;
|
||||
/// Return the frame update parameters
|
||||
const FrameInfo& GetFrameInfo() { return frame_; }
|
||||
|
||||
/// Update for rendering. Called by handleRenderUpdate()
|
||||
void Update(float timeStep);
|
||||
@ -367,7 +369,7 @@ private:
|
||||
/// Number of shadow cameras
|
||||
unsigned numShadowCameras_;
|
||||
/// Number of split lights
|
||||
unsigned nusplitLights__;
|
||||
unsigned numSplitLights_;
|
||||
/// Number of temporary scene nodes
|
||||
unsigned numTempNodes_;
|
||||
/// Number of primitives (3D geometry only)
|
||||
@ -403,7 +405,7 @@ private:
|
||||
/// Frame number on which shaders last changed
|
||||
unsigned shadersChangedFrameNumber_;
|
||||
/// Frame info for rendering
|
||||
FrameUpdate frame_;
|
||||
FrameInfo frame_;
|
||||
/// Shaders need reloading flag
|
||||
bool shadersDirty_;
|
||||
/// Initialized flag
|
||||
|
@ -44,12 +44,12 @@ void Skybox::RegisterObject(Context* context)
|
||||
context->CopyBaseAttributes<StaticModel, Skybox>();
|
||||
}
|
||||
|
||||
void Skybox::UpdateDistance(const FrameUpdate& frame)
|
||||
void Skybox::UpdateDistance(const FrameInfo& frame)
|
||||
{
|
||||
distance_ = 0.0f;
|
||||
}
|
||||
|
||||
void Skybox::GetBatch(const FrameUpdate& frame, unsigned batchIndex, Batch& batch)
|
||||
void Skybox::GetBatch(const FrameInfo& frame, unsigned batchIndex, Batch& batch)
|
||||
{
|
||||
// Follow only the camera rotation, not position
|
||||
Matrix4x3 customView(Vector3::ZERO, frame.camera_->GetWorldRotation().GetInverse(), Vector3::UNITY);
|
||||
|
@ -39,9 +39,9 @@ public:
|
||||
static void RegisterObject(Context* context);
|
||||
|
||||
/// Calculate distance for rendering
|
||||
virtual void UpdateDistance(const FrameUpdate& frame);
|
||||
virtual void UpdateDistance(const FrameInfo& frame);
|
||||
/// Return rendering batch
|
||||
virtual void GetBatch(const FrameUpdate& frame, unsigned batchIndex, Batch& batch);
|
||||
virtual void GetBatch(const FrameInfo& frame, unsigned batchIndex, Batch& batch);
|
||||
|
||||
protected:
|
||||
/// Update world-space bounding box
|
||||
|
@ -178,7 +178,7 @@ void StaticModel::ProcessRayQuery(RayOctreeQuery& query, float initialDistance)
|
||||
}
|
||||
}
|
||||
|
||||
void StaticModel::UpdateGeometry(const FrameUpdate& frame)
|
||||
void StaticModel::UpdateGeometry(const FrameInfo& frame)
|
||||
{
|
||||
if (lodLevelsDirty_)
|
||||
CalculateLodLevels();
|
||||
@ -189,7 +189,7 @@ unsigned StaticModel::GetNumBatches()
|
||||
return geometries_.size();
|
||||
}
|
||||
|
||||
void StaticModel::GetBatch(const FrameUpdate& frame, unsigned batchIndex, Batch& batch)
|
||||
void StaticModel::GetBatch(const FrameInfo& frame, unsigned batchIndex, Batch& batch)
|
||||
{
|
||||
batch.geometry_ = geometries_[batchIndex][lodLevels_[batchIndex]];
|
||||
batch.worldTransform_ = &GetWorldTransform();
|
||||
|
@ -47,11 +47,11 @@ public:
|
||||
/// Process renderer raycast
|
||||
virtual void ProcessRayQuery(RayOctreeQuery& query, float initialDistance);
|
||||
/// Prepare geometry for rendering
|
||||
virtual void UpdateGeometry(const FrameUpdate& frame);
|
||||
virtual void UpdateGeometry(const FrameInfo& frame);
|
||||
/// Return number of batches
|
||||
virtual unsigned GetNumBatches();
|
||||
/// Return rendering batch
|
||||
virtual void GetBatch(const FrameUpdate& frame, unsigned batchIndex, Batch& batch);
|
||||
virtual void GetBatch(const FrameInfo& frame, unsigned batchIndex, Batch& batch);
|
||||
/// Draw to occlusion buffer
|
||||
virtual bool DrawOcclusion(OcclusionBuffer* buffer);
|
||||
|
||||
|
@ -160,7 +160,7 @@ bool View::Define(RenderSurface* renderTarget, const Viewport& viewport)
|
||||
return true;
|
||||
}
|
||||
|
||||
void View::Update(const FrameUpdate& frame)
|
||||
void View::Update(const FrameInfo& frame)
|
||||
{
|
||||
if ((!camera_) || (!octree_))
|
||||
return;
|
||||
|
@ -102,7 +102,7 @@ public:
|
||||
/// Define with rendertarget and viewport. Return true if successful
|
||||
bool Define(RenderSurface* renderTarget, const Viewport& viewport);
|
||||
/// Update culling and construct rendering batches
|
||||
void Update(const FrameUpdate& frame);
|
||||
void Update(const FrameInfo& frame);
|
||||
/// Render batches
|
||||
void Render();
|
||||
|
||||
@ -214,7 +214,7 @@ private:
|
||||
/// Previous view matrix for temporal antialiasing
|
||||
Matrix4x3 lastCameraView_;
|
||||
/// Information of the frame being rendered
|
||||
FrameUpdate frame_;
|
||||
FrameInfo frame_;
|
||||
/// Combined bounding box of visible geometries
|
||||
BoundingBox sceneBox_;
|
||||
/// Combined bounding box of visible geometries in view space
|
||||
|
@ -39,6 +39,12 @@ Component::~Component()
|
||||
{
|
||||
}
|
||||
|
||||
void Component::Remove()
|
||||
{
|
||||
if (node_)
|
||||
node_->RemoveComponent(this);
|
||||
}
|
||||
|
||||
void Component::SetID(unsigned id)
|
||||
{
|
||||
id_ = id;
|
||||
|
@ -46,6 +46,9 @@ public:
|
||||
/// Handle scene node transform dirtied
|
||||
virtual void OnMarkedDirty(Node* node) {};
|
||||
|
||||
/// Remove from the scene node. If no other shared pointer references exist, causes immediate deletion
|
||||
void Remove();
|
||||
|
||||
/// Return ID
|
||||
unsigned GetID() const { return id_; }
|
||||
/// Get scene node
|
||||
|
@ -541,6 +541,12 @@ void Node::RemoveListener(Component* component)
|
||||
}
|
||||
}
|
||||
|
||||
void Node::Remove()
|
||||
{
|
||||
if (parent_)
|
||||
parent_->RemoveChild(this);
|
||||
}
|
||||
|
||||
unsigned Node::GetNumChildren(bool recursive) const
|
||||
{
|
||||
if (!recursive)
|
||||
|
@ -105,7 +105,9 @@ public:
|
||||
void RemoveChild(Node* node);
|
||||
/// Remove all child scene nodes
|
||||
void RemoveAllChildren();
|
||||
/// Set parent. Same as parent->AddChild(this)
|
||||
/// Remove from the parent node. If no other shared pointer references exist, causes immediate deletion
|
||||
void Remove();
|
||||
/// Set parent scene node. Same as parent->AddChild(this)
|
||||
void SetParent(Node* parent);
|
||||
/// Create a component to this node
|
||||
Component* CreateComponent(ShortStringHash type);
|
||||
|
@ -815,13 +815,18 @@ void UIElement::RemoveAllChildren()
|
||||
}
|
||||
}
|
||||
|
||||
void UIElement::Remove()
|
||||
{
|
||||
if (parent_)
|
||||
parent_->RemoveChild(this);
|
||||
}
|
||||
|
||||
void UIElement::SetParent(UIElement* parent)
|
||||
{
|
||||
if (parent)
|
||||
parent->AddChild(this);
|
||||
}
|
||||
|
||||
|
||||
IntVector2 UIElement::GetScreenPosition()
|
||||
{
|
||||
if (positionDirty_)
|
||||
|
@ -249,6 +249,8 @@ public:
|
||||
void RemoveChild(UIElement* element);
|
||||
/// Remove all child elements
|
||||
void RemoveAllChildren();
|
||||
/// Remove from the parent element. If no other shared pointer references exist, causes immediate deletion
|
||||
void Remove();
|
||||
/// Set parent element. Same as parent->AddChild(this)
|
||||
void SetParent(UIElement* parent);
|
||||
|
||||
|
14
Readme.txt
14
Readme.txt
@ -78,13 +78,17 @@ asset build scripts to work in both debug & release builds.
|
||||
|
||||
After the build is complete, the programs can be run from the Bin directory.
|
||||
|
||||
To run Urho3D.exe from the Visual Studio debugger, set it as a startup project
|
||||
and enter its relative path and filename into Debugging -> Command:
|
||||
..\Bin\Urho3D.exe or ..\Bin\Urho3D_d.exe. Additionally, entering -w into
|
||||
Debugging -> Command Arguments is highly recommended. This enables startup in
|
||||
windowed mode: without it running into an exception or breakpoint will be
|
||||
To run Urho3D from the Visual Studio debugger, set it as a startup project and
|
||||
enter its relative path and filename into Properties -> Debugging -> Command:
|
||||
..\Bin\Urho3D.exe or ..\Bin\Urho3D_d.exe. Additionally, entering -w into
|
||||
Debugging -> Command Arguments is highly recommended. This enables startup in
|
||||
windowed mode: without it running into an exception or breakpoint will be
|
||||
obnoxious as the mouse cursor will most probably be hidden.
|
||||
|
||||
To actually make Urho3D.exe do something useful, it must be supplied with the
|
||||
name of the script file it should load and run. You can try for example the
|
||||
following arguments: Scripts/TestScene.as -w
|
||||
|
||||
Note: some SM2.0 shaders in Urho3D reach exactly the arithmetic instruction
|
||||
count limit. The fxc.exe in newer DirectX SDK's may fail to compile them. At
|
||||
least the February 2010 SDK is known to work.
|
||||
|
Loading…
Reference in New Issue
Block a user