---++!! !CommonCtrl.ObjEditor %TOC{title="Contents:"}% %STARTINCLUDE% ---++ the object editor for ParaEngine 3D environment development library | *Title* | the object editor for ParaEngine 3D environment development library | | *Author(s)* | LiXizhi | | *Date* | 2007/10/12 | | *File* | script/ide/object_editor.lua | ---+++ Description %T% __Sample Code__ <verbatim> NPL.load("(gl)script/ide/object_editor.lua"); </verbatim> ---+++ Member Functions ---++++ !ObjEditor.GetObjectByParams [[ObjEditor library]] if(not ObjEditor) then ObjEditor={}; end ObjEditor.objectCounter = 0; get the ParaObject by its params. * _return_ ____ : it may return nil or invalid object(). __syntax__ <verbatim>function ObjEditor.GetObjectByParams(param)</verbatim> __parameters__ | *param* | | | *return* | it may return nil or invalid object(). | ---++++ !ObjEditor.GetObjectParams save all parameters of a object to a table. So that we can create a new object with similar or modifed parameters. * _param_ __obj__ : para object of which the parameters are extracted. * _param_ __o__ : nil or a table to write the data * _return_ ____ : o or a new table containing the parameter __syntax__ <verbatim>function ObjEditor.GetObjectParams(obj,param)</verbatim> __parameters__ | *obj* | para object of which the parameters are extracted. | | *param* | | | *return* | o or a new table containing the parameter | ---++++ !ObjEditor.CreateObjectByParams <verbatim>[[ create an object by parameter. But it does NOT attach it to the scene. One need to call ParaScene.Attach(obj); with the returned object. The error code is in ObjEditor.LastErrorMessage * _param_ __param__ : paramter of the object. known paramters are given below param = { name, AssetFile, -- primary asset file: either string or para asset object. x, y, z, IsCharacter, -- can be nil CCSInfoStr, -- can be nil -- added by Andy scaling, -- can be nil rotation, -- can be nil or {x=0,y=0,z=0,w=1} which is rotational quaternion. facing, -- can be nil IsGlobal, -- can be nil ViewBox, -- can be nil Density, -- can be nil PhysicsRadius, -- can be nil IsPersistent, -- can be nil ReplaceableTextures = {[1] = "filepath"}, -- can be nil SkinIndex, -- can be nil localMatrix, -- can be nil EnablePhysics, -- can be nil, whether physics is enabled for the mesh -- TODO: Customizable character properties here? -- TODO: dynamic properties? }</verbatim> * _return_ ____ : the object is returned or nil ]] __syntax__ <verbatim>function ObjEditor.CreateObjectByParams(param)</verbatim> __parameters__ | *param* | paramter of the object. known paramters are given below param = { name, AssetFile, -- primary asset file: either string or para asset object. x, y, z, IsCharacter, -- can be nil CCSInfoStr, -- can be nil -- added by Andy scaling, -- can be nil rotation, -- can be nil or {x=0,y=0,z=0,w=1} which is rotational quaternion. facing, -- can be nil IsGlobal, -- can be nil ViewBox, -- can be nil Density, -- can be nil PhysicsRadius, -- can be nil IsPersistent, -- can be nil ReplaceableTextures = {[1] = "filepath"}, -- can be nil SkinIndex, -- can be nil localMatrix, -- can be nil EnablePhysics, -- can be nil, whether physics is enabled for the mesh -- TODO: Customizable character properties here? -- TODO: dynamic properties? }</verbatim> | ---++ the object editor for ParaEngine 3D environment development library | *Title* | the object editor for ParaEngine 3D environment development library | | *Author(s)* | LiXizhi | | *Date* | 2005/11 | | *File* | script/ide/object_editor_v1.lua | ---+++ Description %T% __Sample Code__ <verbatim> NPL.load("(gl)script/ide/object_editor_v1.lua"); </verbatim> ---+++ Member Functions ---++++ !ObjEditor.LoadDevAsset requires: NPL.load("(gl)script/ide/gui_helper.lua"); NPL.load("(gl)script/ide/FileDialog.lua"); NPL.load("(gl)script/ide/terrain_editor.lua"); NPL.load("(gl)script/ide/property_control.lua"); NPL.load("(gl)script/ide/user_action.lua"); CommonCtrl.user_action:AddAction({id = CommonCtrl.user_action.action_id.Player_Create_Mesh, name="noName", FilePath="XXX", x=10,y=10,z=10}); [[ObjEditor library]] if(not ObjEditor) then ObjEditor={}; end list of ParaObjects that can be edited in the current scene. ObjEditor.objects = {}; The current ParaObject that is being selected. ObjEditor.currentObj = nil; assets in categories ObjEditor.assets={}; ObjEditor.RandomStaticMeshFacing = false; -- whether to randomize the mesh facing when created. ObjEditor.CurrentDir = "model/"; ObjEditor.CurrentAssetIndex = 0; -- category index of the ObjEditor.assets table ObjEditor.SelectedGroupIndex = 0; ObjEditor.LastCreatedModelName = ""; ObjEditor.LastCreatedModelPath = ""; ObjEditor.LastCreatePos = {x=0,y=0,z=0}; ObjEditor.objectCounter = 0; ObjEditor.MIN_OBJ_DIST = 0.15; -- smallest distance between two identical objects __syntax__ <verbatim>function ObjEditor.LoadDevAsset()</verbatim> ---++++ !ObjEditor.GetObject load development asset by default. ObjEditor.LoadDevAsset(); [[ Get a named object in the scene * _param_ __sName__ : string: the name of the object. * _return_ ____ : nil if not found; a ParaObject if found. ]] __syntax__ <verbatim>function ObjEditor.GetObject(sName)</verbatim> __parameters__ | *sName* | string: the name of the object. | ---++++ !ObjEditor.GetCurrentObj [[ get the current object ]] __syntax__ <verbatim>function ObjEditor.GetCurrentObj()</verbatim> ---++++ !ObjEditor.SetCurrentObj [[ Set the current object ]] __syntax__ <verbatim>function ObjEditor.SetCurrentObj(o)</verbatim> __parameters__ | *o* | | ---++++ !ObjEditor.GetObjectNum [get the number of active objects in the scene] __syntax__ <verbatim>function ObjEditor.GetObjectNum()</verbatim> ---++++ !ObjEditor.RemoveObject [[Remove the object from the active object list * _param_ __object__ :_name: string value: actor name * _return_ ____ : return the object that is removed. if nil, there is no such object. ]] __syntax__ <verbatim>function ObjEditor.RemoveObject(object_name)</verbatim> __parameters__ | *object* | _name: string value: actor name | | *name* | | ---++++ !ObjEditor.CreatePhysicsObject [[ create a physics object at the specifed position using a Model asset. The newly created object will be further editable. * _param_ __sName__ : the name of the physics objects, if there is already an object with the same name, an error message will be returned.if it If the file name ends with _a, such as "xxx_a.x", then the mesh will by default be created without physics. * _param_ __Model__ : [string|ParaAssetObject] if this is a string, then it will be treated as the file name of the model asset; otherwise, it will be treated like a ParaAssetObject. * _param_ __x__ :,y,z: where the model will be positioned in the world coordinate system. * _return_ ____ : return the object created if succeeded, otherwise return nil. ]] __syntax__ <verbatim>function ObjEditor.CreatePhysicsObject(sName, Model, x,y,z,bSilentMode, reserved)</verbatim> __parameters__ | *sName* | the name of the physics objects, if there is already an object with the same name, an error message will be returned.if it If the file name ends with _a, such as "xxx_a.x", then the mesh will by default be created without physics. | | *Model* | | | *x* | ,y,z: where the model will be positioned in the world coordinate system. | | *y* | | | *z* | | | *bSilentMode* | | | *reserved* | | ---++++ !ObjEditor.CreateMesh [[ create mesh objects, such as grass, that does not contain physics.]] __syntax__ <verbatim>function ObjEditor.CreateMesh(sName, Model, x,y,z)</verbatim> __parameters__ | *sName* | | | *Model* | | | *x* | | | *y* | | | *z* | | ---++++ !ObjEditor.load [[ load file * _param_ __filename__ :string: name of the file from which objects are loaded. In this version. the name is always appended with "temp/" and so it is with the managed loader name in the file. ]] __syntax__ <verbatim>function ObjEditor.load(filename_)</verbatim> __parameters__ | *filename* | string: name of the file from which objects are loaded. In this version. the name is always appended with "temp/" and so it is with the managed loader name in the file. ]] | ---++++ !ObjEditor.OffsetObj [[ offset a specified object by a specifed amount. * _param_ __obj__ : the ParaObject to move, if this is nil, the current selected object will be moved. ]] __syntax__ <verbatim>function ObjEditor.OffsetObj(obj,dx,dy,dz)</verbatim> __parameters__ | *obj* | the ParaObject to move, if this is nil, the current selected object will be moved. ]] | | *dx* | | | *dy* | | | *dz* | | ---++++ !ObjEditor.RotateObj [[ rotate a specified object by a specifed amount. * _param_ __obj__ : the ParaObject to rotate, if this is nil, the current selected object will be moved. * _param_ __dx__ :,dy,dz: rotation around the x,y,z axis in rads. ]] __syntax__ <verbatim>function ObjEditor.RotateObj(obj,dx,dy,dz)</verbatim> __parameters__ | *obj* | the ParaObject to rotate, if this is nil, the current selected object will be moved. | | *dx* | | | *dy* | | | *dz* | | ---++++ !ObjEditor.ScaleObj [[ Scale a specified object by a specifed amount. * _param_ __obj__ : the ParaObject to rotate, if this is nil, the current selected object will be moved. * _param_ __dx__ :,dy,dz: rotation around the x,y,z axis in rads. ]] __syntax__ <verbatim>function ObjEditor.ScaleObj(obj,s)</verbatim> __parameters__ | *obj* | the ParaObject to rotate, if this is nil, the current selected object will be moved. | | *s* | | ---++++ !ObjEditor.CameraToWorldSpace return x,y,z: transform from camera space to world space, only for x,z. __syntax__ <verbatim>function ObjEditor.CameraToWorldSpace(dx,dy,dz)</verbatim> __parameters__ | *dx* | | | *dy* | | | *dz* | | ---++++ !ObjEditor.offsetByCamera [[ offset object relative to the current camera position and orientation * _param_ __obj__ : the ParaObject to move, if this is nil, the current selected object will be moved. ]] __syntax__ <verbatim>function ObjEditor.offsetByCamera(obj,dx,dy,dz)</verbatim> __parameters__ | *obj* | the ParaObject to move, if this is nil, the current selected object will be moved. ]] | | *dx* | | | *dy* | | | *dz* | | ---++++ !ObjEditor.MoveCurrentObj offset the current object __syntax__ <verbatim>function ObjEditor.MoveCurrentObj(dx,dy,dz)</verbatim> __parameters__ | *dx* | | | *dy* | | | *dz* | | ---++++ !ObjEditor.RotateCurrentObj [[ rotate the current object by a specified degrees around an axis. * _param_ __dx__ :,dy,dz: rotation in rads around x,y,z axis]] __syntax__ <verbatim>function ObjEditor.RotateCurrentObj(dx,dy,dz)</verbatim> __parameters__ | *dx* | ,dy,dz: rotation in rads around x,y,z axis]] | | *dy* | | | *dz* | | ---++++ !ObjEditor.ScaleCurrentObj [[ scale the current object ]] __syntax__ <verbatim>function ObjEditor.ScaleCurrentObj(dS)</verbatim> __parameters__ | *dS* | | ---++++ !ObjEditor.EnablePhysics turn on/off physics object __syntax__ <verbatim>function ObjEditor.EnablePhysics(bEnable)</verbatim> __parameters__ | *bEnable* | | ---++++ !ObjEditor.ResetCurrentObj reset object __syntax__ <verbatim>function ObjEditor.ResetCurrentObj()</verbatim> ---++++ !ObjEditor.ShowObjProperty [[ show and update the property of the current object * _param_ __obj__ : if nil, the current object is used * _param_ __bShow__ : true to hide property window ]] __syntax__ <verbatim>function ObjEditor.ShowObjProperty(obj, bShow)</verbatim> __parameters__ | *obj* | if nil, the current object is used | | *bShow* | | ---++++ !ObjEditor.UnbindObjProperty [[ unbind the current object from the object property control]] __syntax__ <verbatim>function ObjEditor.UnbindObjProperty()</verbatim> ---++++ !ObjEditor.AutoCreateObject * _obsoleted_ ____ : use CreateObjectByParam automatically create a new object by a file path name pos: {x,y,z} position, if nil, the current player position is used. sCategoryName: this can be nil, where the current name is used. Otherwise it could be "浜虹墿", "鍦板舰","鑴氭湰","鐏厜" or anything else. bSlientMode: if this is nil or false, no effect will be used and the created object is not selected. If true, there is missle firing to the target and that it is automatically selected as the target. __syntax__ <verbatim>function ObjEditor.AutoCreateObject(ObjName, FilePath, pos, sCategoryName, bSilentMode, reserved)</verbatim> __parameters__ | *ObjName* | | | *FilePath* | | | *pos* | | | *sCategoryName* | | | *bSilentMode* | | | *reserved* | | ---++++ !ObjEditor.CreateLastObject pos: can be {x,y,z} or nil __syntax__ <verbatim>function ObjEditor.CreateLastObject(pos)</verbatim> __parameters__ | *pos* | | ---++++ !ObjEditor.SaveNearPlayer save all scene objects as well as the scene itself in the current player's terrain location. __syntax__ <verbatim>function ObjEditor.SaveNearPlayer()</verbatim> ---++++ !ObjEditor.LoadNearPlayer load from disk file. __syntax__ <verbatim>function ObjEditor.LoadNearPlayer()</verbatim> ---++++ !ObjEditor.SelObjectByName select an existing object by name, and fire a missle to it. __syntax__ <verbatim>function ObjEditor.SelObjectByName(objectname)</verbatim> __parameters__ | *objectname* | | ---++++ !ObjEditor.RemoveSelectedObject Remove an current object from the list, but not from the scene. __syntax__ <verbatim>function ObjEditor.RemoveSelectedObject()</verbatim> ---++++ !ObjEditor.DelObject safe delete the given object return true if succeeded. __syntax__ <verbatim>function ObjEditor.DelObject(obj)</verbatim> __parameters__ | *obj* | | ---++++ !ObjEditor.DelSeletedObject delete an object from the scene return true if succeeded. __syntax__ <verbatim>function ObjEditor.DelSeletedObject()</verbatim> %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