diff options
| author | Alexander <alex@cogarr.net> | 2020-06-29 15:29:03 -0400 |
|---|---|---|
| committer | Alexander <alex@cogarr.net> | 2020-06-29 15:29:03 -0400 |
| commit | 80789508b9655d25629223b9dcc84b4cfb77ce45 (patch) | |
| tree | 37e140e532af61c1ca4699c8b6254cf2cb07ed02 /src/client/lua_api/scene | |
| parent | 44a1421c393632978d59c0698a93ae22243b97e9 (diff) | |
| download | brokengine-80789508b9655d25629223b9dcc84b4cfb77ce45.tar.gz brokengine-80789508b9655d25629223b9dcc84b4cfb77ce45.tar.bz2 brokengine-80789508b9655d25629223b9dcc84b4cfb77ce45.zip | |
Updates for mdoc
Also more tests
Diffstat (limited to 'src/client/lua_api/scene')
| -rw-r--r-- | src/client/lua_api/scene/icamera.cpp | 61 | ||||
| -rw-r--r-- | src/client/lua_api/scene/igeneric.cpp | 72 | ||||
| -rw-r--r-- | src/client/lua_api/scene/ilight.cpp | 36 | ||||
| -rw-r--r-- | src/client/lua_api/scene/imesh.cpp | 3 |
4 files changed, 160 insertions, 12 deletions
diff --git a/src/client/lua_api/scene/icamera.cpp b/src/client/lua_api/scene/icamera.cpp index 003f2ad..34b3447 100644 --- a/src/client/lua_api/scene/icamera.cpp +++ b/src/client/lua_api/scene/icamera.cpp @@ -22,6 +22,20 @@ using namespace core; extern IrrlichtDevice* device; +/*** +Create a maya camera +Creates a camera that can be controlled with maya style controls by default, +click and drag rotates the camera, while right click and mouse up/down zooms +in or out. +@function scene.newmayacamera() +@treturn iscenemayacamera +*/ +/*** +A maya camera. +A camera that can be controlled similar to the 3d modeling software "Maya" +@class iscenemayacamera +@inherits iscenecamera +*/ static int newiscenemayacamera(lua_State* L){ printf("createing maya camera!\n"); ISceneManager* smgr = device->getSceneManager(); @@ -38,6 +52,20 @@ static int newiscenemayacamera(lua_State* L){ return 1; } +/*** +Create an fps camera. +Create a camera with default first person shooter controls. The camera and +be rotated with the mouse, and moved with the arrow keys. +@function scene.newfpscamera() +@treturn iscenefpscamera The camera +*/ +/*** +A camera with default FPS controls +An FPS camera can be controlled with the arrow keys, and rotated with the mouse +by default. +@class iscenefpscamera +@inherits iscenecamera +*/ // ifpscamera.new() static int newiscenefpscamera(lua_State* L){// ISceneManager* smgr = device->getSceneManager(); @@ -60,6 +88,21 @@ static int newiscenefpscamera(lua_State* L){// return 1; } +/*** +Create a new camera +Creates a new camera at the given position. +@function scene.newiscenecamera(vector3d position, vector3d lookat, iscenenode parent) +@tparam vector3d position The position to create the camera in +@tparam vector3d lookat A vector for the camera to look at. Use this to set it's rotation. +@tparam? iscenenode parent A node to parent this camera to. If the parent moves, the camera will move with it. +@treturn iscenecamera The camera +*/ +/*** +A camera. +The world is rendered through cameras. +@class iscenecamera +@inherits iscenenode +*/ //iscenecamera.new(Vector position, Vector lookat,{node=parent}) static int newiscenecamera(lua_State* L){ printf("Createing camera!\n"); @@ -98,6 +141,12 @@ static int newiscenecamera(lua_State* L){ return 1; } +/*** +Lock on +Should the camera be locked on to something? +@function iscenecamera:bindtarget(boolean bind) +@tparam boolean bind Should the camera be locked on to it's "lookat"? +*/ //camera:bind_target(bool) :: nil static int icamerabindtarget(lua_State *L){ int should_bind = lua_toboolean(L,-1);//{node=ud_cam},bool_shouldbind @@ -110,6 +159,12 @@ static int icamerabindtarget(lua_State *L){ return 0; } +/*** +Gets the target of a camera +Gets the vector that a camera is looking at +@function iscenecamera:gettarget() +@treturn vector3d The vector that the camera is looking at +*/ //camera:gettarget() :: v3f static int icameragettarget(lua_State *L){ lua_getfield(L,-1,"node"); @@ -120,6 +175,12 @@ static int icameragettarget(lua_State *L){ return 1; } +/*** +Set the camera's target +Forcefully set the rotation the camera should be looking +@function iscenecamera:settarget(vector3d target) +@tparam vector3d target The vector that the camera should be looking at +*/ //camera:settarget(v3f) static int icamerasettarget(lua_State *L){ double x,y,z; diff --git a/src/client/lua_api/scene/igeneric.cpp b/src/client/lua_api/scene/igeneric.cpp index dcac022..a0c33b3 100644 --- a/src/client/lua_api/scene/igeneric.cpp +++ b/src/client/lua_api/scene/igeneric.cpp @@ -14,14 +14,8 @@ using namespace core; using namespace scene; using namespace video; -/*** -@classmod iscenenode -*/ - extern IrrlichtDevice* device; - - /*** Get the position of a scene element. @function iscenenode:getpos() @@ -82,13 +76,74 @@ int iscenesetangle(lua_State* L){//{node=ud_ISceneNode},{x,y,z} } /*** +Gets the material of a scene element. +To check if to materials are equal, compare their .texture fields, these hold +a light userdata. +@function iscenenode:getmaterial() +@treturn smaterial The material that was applied to this node +*/ +//iscenenode:getmaterial({node=ud_ISceneNode},texture_number=0) :: {texture=ud_itexture} +int iscenegetmaterial(lua_State *L){ + int args = lua_gettop(L); + u32 layer = 0; + if(args == 2){ + layer = lua_tonumber(L,-1); + lua_pop(L,1); + } + lua_getfield(L,-1,"node"); + ISceneNode *i = (ISceneNode*)lua_touserdata(L,-1); + lua_pop(L,2);// + SMaterial mat = i->getMaterial(layer); + ITexture *tex = mat.getTexture(0); + printf("got texutre:%p\n",(void*)tex); + lua_newtable(L);//{} + lua_pushlightuserdata(L,tex);//{},ud_texture + lua_setfield(L,-2,"texture");//{material} + luaL_getmetatable(L,"video.smaterial");//{material},{material_m} + lua_setmetatable(L,-2);//{material} + return 1; +} + +/*** +Gets the number of materials on a scene node. +@function iscenenode:getmaterialcount() +@treturn number The number of materials on this node +*/ +//iscenenode:getmaterialcount() +int iscenegetmaterialcount(lua_State *L){ + lua_getfield(L,-1,"node"); + ISceneNode *i = (ISceneNode*)lua_touserdata(L,-1); + lua_pop(L,2);// + u32 count = i->getMaterialCount(); + lua_pushnumber(L,count); + return 1; +} + +/*** +Sets a flag on the material +@function iscenenode:setmaterialflag(flag,on) +@tparam number flag The flag to modify +@tparam boolean on Should the flag be set +*/ +//iscenenode:setmaterialflag(flag,on) +int iscenesetmaterialflag(lua_State *L){ + int on = lua_toboolean(L,-1); + E_MATERIAL_FLAG flag = (E_MATERIAL_FLAG)lua_tonumber(L,-2); + lua_pop(L,2); + lua_getfield(L,-1,"node"); + ISceneNode *i = (ISceneNode*)lua_touserdata(L,-1); + lua_pop(L,2);// + i->setMaterialFlag(flag,on == 1); + return 0; +} + +/*** Set the mateiral of a scene element. @function iscenenode:setmaterial() @tparam texture texture The texture to apply to this material */ //iscenesetmaterialtexture({node=ud_ISceneNode},{texture=ud_itexture},texture_number=0) int iscenesetmaterial(lua_State *L){ - printf("Calling generic iscenesetmaterial function\n"); int args = lua_gettop(L); u32 layer = 0; if(args == 3){ @@ -220,6 +275,9 @@ extern const luaL_reg igeneric_m[] = { {"getang", iscenegetangle}, {"setang", iscenesetangle}, {"setmaterialtexture", iscenesetmaterial}, + {"getmaterial", iscenegetmaterial}, + {"getmaterialcount", iscenegetmaterialcount}, + {"setmaterialflag", iscenesetmaterialflag}, {"getname", iscenegetname}, {"setname", iscenesetname}, {"setscale", iscenesetscale}, diff --git a/src/client/lua_api/scene/ilight.cpp b/src/client/lua_api/scene/ilight.cpp index 1e292ee..e405443 100644 --- a/src/client/lua_api/scene/ilight.cpp +++ b/src/client/lua_api/scene/ilight.cpp @@ -23,6 +23,21 @@ using namespace core; extern IrrlichtDevice* device; +/*** +Create a light +Creates a light that illuminates the surrounding objects dynamically. +@function scene.newlight(number radius, vector3d position) +@tparam number radius The radius that the light should shine +@tparam vector3d position The position to create the light at +@treturn iscenelight The created light +*/ +/*** +A light. +Lights illuminate the scene nodes arounded them based on mesh vertexes. You +probably want to bake the lightmap instead of using light nodes. +@class iscenelight +@inherits iscenenode +*/ //{} :: scene.newlight(radius, {v3 position}) static int newiscenelight(lua_State* L){ printf("Createing light!\n"); @@ -48,6 +63,12 @@ static int newiscenelight(lua_State* L){ } +/*** +Sets the light type +Different light types illuminate the surrounding meshes in different ways. +@function iscenelight:settype(number type) +@tparam number type The type the light should be +*/ //settype(self,const) int settype(lua_State *L){ video::E_LIGHT_TYPE type = (video::E_LIGHT_TYPE)lua_tonumber(L,-1);//self,type @@ -60,8 +81,6 @@ int settype(lua_State *L){ } static const luaL_reg ilight_m[] = { - {"getpos", iscenegetpos}, - {"setpos", iscenesetpos}, {"settype", settype}, {0, 0}, }; @@ -72,8 +91,20 @@ void ilight_register(lua_State* L){ lua_pushcfunction(L,newiscenelight);//{scene},newiscenelight() lua_setfield(L,-2,"newlight");//{scene} +/*** +A point light +@field scene.ELT_POINT +*/ set_const(L,ELT_POINT); +/*** +A spot light +@field scene.ELT_SPOT +*/ set_const(L,ELT_SPOT); +/*** +A sun light +@field scene.ELT_DIRECTIONAL +*/ set_const(L,ELT_DIRECTIONAL); lua_pop(L,1);// @@ -81,6 +112,7 @@ void ilight_register(lua_State* L){ luaL_newmetatable(L,"scene.ilight");//scene.ilight lua_newtable(L);//scene.ilight,{} luaL_register(L, NULL, ilight_m);//scene.ilight,{} + luaL_register(L, NULL, igeneric_m); lua_setfield(L,-2,"__index");//scene.ilight lua_pop(L,1); diff --git a/src/client/lua_api/scene/imesh.cpp b/src/client/lua_api/scene/imesh.cpp index 8ed357c..479da15 100644 --- a/src/client/lua_api/scene/imesh.cpp +++ b/src/client/lua_api/scene/imesh.cpp @@ -16,9 +16,6 @@ extern "C" { #include "igeneric.hpp" #include <shared/lua_api/common.hpp> -/*** -@module scene -*/ using namespace irr; using namespace scene; using namespace core; |
