Camera: Difference between revisions
From Crumbled World Wiki
(Created page with "{{:CameraExampleCode}} ==Inheritance== SceneNode ==Static functions== {| class="wikitable" !|return !|function !|description |- |Camera |new() |Create a new Instance of the the Camera |- |Camera |new(Text nodeName) |Create a new Instance of the the Camera |- |Camera |new(Text nodeName, bool canRender3D) |Create a new Instance of the the Camera |- |Ca...") |
|||
| (One intermediate revision by the same user not shown) | |||
| Line 101: | Line 101: | ||
|[[Camera:getDefferRenderShader()|getDefferRenderShader]]() | |[[Camera:getDefferRenderShader()|getDefferRenderShader]]() | ||
| | | | ||
|- | |||
| | |||
|[[Camera:setActive(bool active)|setActive]](bool active) | |||
|Set if the camera should be active, if deactivated the camera will not be sent of to render | |||
|- | |- | ||
| | | | ||
| Line 128: | Line 132: | ||
| | | | ||
|[[Camera:setUseAntiAliasing(bool enable)|setUseAntiAliasing]](bool enable) | |[[Camera:setUseAntiAliasing(bool enable)|setUseAntiAliasing]](bool enable) | ||
| | |||
|- | |||
| | |||
|[[Camera:setUseSelectedRender(bool enable)|setUseSelectedRender]](bool enable) | |||
| | | | ||
|- | |- | ||
Latest revision as of 05:45, 19 August 2025
Example Code
--this = Camera()
function create()
keyBinds = Core.getBillboard("keyBind");
keyBindForward = keyBinds:getKeyBind("forward");
keyBindBackward = keyBinds:getKeyBind("backward");
keyBindLeft = keyBinds:getKeyBind("left");
keyBindRight = keyBinds:getKeyBind("right");
end
function update()
local deltaTime = Core.getDeltaTime()
local localMat = this:getLocalMatrix()
if keyBindForward:getHeld() then
localMat:setPosition( localMat:getPosition() - localMat:getAtVec() * deltaTime * 20 )
end
if keyBindBackward:getHeld() then
localMat:setPosition( localMat:getPosition() + localMat:getAtVec() * deltaTime * 20 )
end
if keyBindLeft:getHeld() then
localMat:setPosition( localMat:getPosition() - localMat:getRightVec() * deltaTime * 20 )
end
if keyBindRight:getHeld() then
localMat:setPosition( localMat:getPosition() + localMat:getRightVec() * deltaTime * 20 )
end
--update rotate
if Core.getInput():getKeyHeld(Key.space) then
local moseDiff = Core.getInput():getMouseDelta() * 0.002
quatRot = Quat()
quatRot:fromEuler(moseDiff.y, moseDiff.x, 0.0)
localMat = localMat * quatRot:getMatrix()
end
this:setLocalMatrix(localMat)
return true
end
Inheritance
Static functions
| return | function | description |
|---|---|---|
| Camera | new() | Create a new Instance of the the Camera |
| Camera | new(Text nodeName) | Create a new Instance of the the Camera |
| Camera | new(Text nodeName, bool canRender3D) | Create a new Instance of the the Camera |
| Camera | new(Text nodeName, bool canRender3D, int frameBufferWidth, int frameBufferHeight) | Create a new Instance of the the Camera |
| Camera | new(string nodeName) | Create a new Instance of the the Camera |
| Camera | new(string nodeName, bool canRender3D) | Create a new Instance of the the Camera |
| Camera | new(string nodeName, bool canRender3D, int frameBufferWidth, int frameBufferHeight) | Create a new Instance of the the Camera |
Functions
| return | function | description |
|---|---|---|
| Vec3 | getAtVec() | |
| Vec3 | getUpVec() | |
| Vec3 | getRightVec() | |
| {SceneNode()} | getAllNodeByTypeInView(NodeId type) | |
| {SceneNode()} | getAllNodeByTypeInViewFromNode(SceneNode node, NodeId type) | |
| Line3D | getWorldLineFromScreen(Vec2 pos) | |
| Texture | getTexture() | |
| AmbientLight | getAmbientLight() | |
| DirectionalLight | getDirectionLight() | |
| Vec2 | getScreenCoordFromglobalPos(Vec3 globalPosition) | Get screen coordinates from a global position. |
| Vec2 | getResolution() | Get the screen resolution of this camera. |
| bool | getDynamicLightsEnable() | |
| bool | getVisibleInCamera() | Returns true if the node was visible for a camera. |
| Shader | getDefferRenderShader() | |
| setActive(bool active) | Set if the camera should be active, if deactivated the camera will not be sent of to render | |
| setDefferRenderShader(Shader defferedShader) | Set the shader that will make the final render from deferred buffers to one buffer. | |
| render() | ||
| setLocalMatrix(Matrix mat) | ||
| setLocalPosition(Vec3 position) | ||
| setUseShadow(bool enable) | ||
| setUseGlow(bool enable) | ||
| setUseAntiAliasing(bool enable) | ||
| setUseSelectedRender(bool enable) | ||
| setDynamicLightsEnable(bool enable) | ||
| setClearColor(Vec4 clearColor) | ||
| setShadowScale(float scale) | Cameras shadow map is of the same size as the camera resolution but this can be changed by a scalar with this function. | |
| setAmbientLight(AmbientLight light) | ||
| setDirectionLight(DirectionalLight light) | ||
| setFrameBufferSize(Vec2i size) | ||
| setRenderScript(string scriptName) | ||
| add2DScene(Scene2DNode scene2DNode) | ||
| bool | saveScreenshot(string fileName) | return true if the image was successfully saved to file. Cameras rendering directly to screen can not save a screenshot. |
| bool | remove2DScene(Scene2DNode scene2DNode) | return true if the scene2DNode was removed. |