---++!! !CommonCtrl.Canvas3D %TOC{title="Contents:"}% %STARTINCLUDE% ---++ A 3D canvas container for displaying picture, 3D scene | *Title* | A 3D canvas container for displaying picture, 3D scene | | *Author(s)* | LiXizhi | | *Date* | 2007/3/27 | | *File* | script/ide/Canvas3D.lua | ---+++ Description A 3D canvas container for displaying picture, 3D scene, etc. Basic picture and scene manipulation is implemented, such as zooming, panning pictures, and mouse control of 3d scenes. __Note__ one can create as many instances of this class as they like, but one must create as few miniscene graph name as possible, as each new mini scene graph will consume some memory and processing time. ---+++ Member Functions ---++++ !Canvas3D:new <verbatim> common control library NPL.load("(gl)script/ide/common_control.lua"); define a new control in the common control libary default member attributes local Canvas3D = { -- the top level control name name = "Canvas3D1", -- default background image path. background = nil, -- normal window size alignment = "_lt", left = 0, top = 0, width = 512, height = 290, parent = nil, -- attributes --how many degrees per pixel movement rotSpeed = 0.004, -- how many degrees (in radian) to rotate around the Y axis per second. if nil or 0 it will not rotate. common values are 0.12 autoRotateSpeed = nil, -- how many percentage of maxZoomDist to pan for each mouse pixel movement panSpeed = 0.001, -- camera lift up angle range in 3D mode. maxLiftupAngle = 1.3, minLiftupAngle = 0.1, -- how many meters to zoom in and out in 3D mode. maxZoomDist = 20, minZoomDist = 0.01, -- must be power of 2, like 128, 256. This is only used in ShowModel. -- However, one can use the set size function miniscenegraph to specify both height and width. RenderTargetSize=256, -- whether it will receive and responds to mouse event IsInteractive = true, -- private: -- 1. resourceType==nil means miniscenegraph, -- 2. resource == 0 means image or swf or avi resourceType = nil, resourceName = nil, -- the miniscenegraph name to use if no one is specified. self.name is used. miniscenegraphname, -- whether miniscene graph uses active rendering. default to false. IsActiveRendering = false, }</verbatim> CommonCtrl.Canvas3D = Canvas3D; constructor __syntax__ <verbatim>function Canvas3D:new (o)</verbatim> __parameters__ | *o* | | ---++++ !Canvas3D:Destroy Destroy the UI control __syntax__ <verbatim>function Canvas3D:Destroy ()</verbatim> ---++++ !Canvas3D:Show * _param_ __bShow__ : boolean to show or hide. if nil, it will toggle current setting. __syntax__ <verbatim>function Canvas3D:Show(bShow)</verbatim> __parameters__ | *bShow* | boolean to show or hide. if nil, it will toggle current setting. | ---++++ !Canvas3D.OnClose close the given control __syntax__ <verbatim>function Canvas3D.OnClose(sCtrlName)</verbatim> __parameters__ | *sCtrlName* | | ---++++ !Canvas3D:ShowImage ---------------------------------------------------- public methods ---------------------------------------------------- public: bind the canvas to an image. * _param_ __filename__ : the image file path or the image asset object. __syntax__ <verbatim>function Canvas3D:ShowImage(filename)</verbatim> __parameters__ | *filename* | the image file path or the image asset object. | ---++++ !Canvas3D:SetEnabled set enabled __syntax__ <verbatim>function Canvas3D:SetEnabled(bEnabled)</verbatim> __parameters__ | *bEnabled* | | ---++++ !Canvas3D:SetRenderTargetSize auto set render target size,input are rounded to power of 2. it is only used in ShowModel(); __syntax__ <verbatim>function Canvas3D:SetRenderTargetSize(width, height)</verbatim> __parameters__ | *width* | | | *height* | | ---++++ !Canvas3D:ShowModel public: bind the canvas to a given 3d model or character. it will reset the scene before adding the new model. it will use the currently bind miniscene graph to display it. if no miniscene graph is bind, it will create a default one named "Canvas3D", which is 128*128 in size. * _param_ __obj__ : a newly created ParaObject or it can be objParams. Note: it can NOT be an object from the main scene or an attached object. __syntax__ <verbatim>function Canvas3D:ShowModel(obj)</verbatim> __parameters__ | *obj* | a newly created ParaObject or it can be objParams. Note: it can NOT be an object from the main scene or an attached object. | ---++++ !Canvas3D:Draw manually draw the miniscene graph, in case active rendering is disabled. __syntax__ <verbatim>function Canvas3D:Draw(deltaTime)</verbatim> __parameters__ | *deltaTime* | | ---++++ !Canvas3D:ShowMiniscene public: bind the canvas to a miniscenegraph. * _param_ __name__ : mini scene graph name. __syntax__ <verbatim>function Canvas3D:ShowMiniscene(name)</verbatim> __parameters__ | *name* | mini scene graph name. | ---++++ !Canvas3D:SaveToFile public: save the canvas content to file * _param_ __filename__ : sFileName a texture file path to save the file to. we support ".dds", ".jpg", ".png" files. If the file extension is not recognized, ".png" file is used. * _param_ __nImageSize__ : if this is zero, the original size is used. If it is dds, all mip map levels are saved. __syntax__ <verbatim>function Canvas3D:SaveToFile(filename, imageSize)</verbatim> __parameters__ | *filename* | sFileName a texture file path to save the file to. we support ".dds", ".jpg", ".png" files. If the file extension is not recognized, ".png" file is used. | | *imageSize* | | ---++++ !Canvas3D:CameraSetEyePosByAngle directly set the camera with engine api calls __syntax__ <verbatim>function Canvas3D:CameraSetEyePosByAngle(fRotY, fLiftupAngle, fCameraObjectDist)</verbatim> __parameters__ | *fRotY* | | | *fLiftupAngle* | | | *fCameraObjectDist* | | ---++++ !Canvas3D.OnMouseDown mouse down position Canvas3D.lastMouseDown = {x = 0, y=0} Canvas3D.lastMousePos = {x = 0, y=0} whether any mouse button is down Canvas3D.IsMouseDown = false; whether middle mouse button is down Canvas3D.IsMidMouseDown = false; __syntax__ <verbatim>function Canvas3D.OnMouseDown(sCtrlName)</verbatim> __parameters__ | *sCtrlName* | | %STOPINCLUDE%
E
dit
|
A
ttach
|
P
rint version
|
H
istory
: r1
|
B
acklinks
|
V
iew topic
|
Ra
w
edit
|
M
ore topic actions
Topic revision: r1 - 2008-02-29
-
LiXizhi
Home
Site map
CCWeb web
HaqiTeen web
Main web
ParaEngine web
TWiki web
Main Web
Users
Groups
Index
Search
Changes
Notifications
RSS Feed
Statistics
导航页WebTopMenu
Preferences
开发指南
Getting Started
ParacraftSDK
NPL
MCML
NPL Reference Manual
美术Mod
Account
Log In
English
简体中文
簡體中文
E
dit
A
ttach
Copyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback