CommonCtrl.ObjEditor

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

TIP Sample Code

NPL.load("(gl)script/ide/object_editor.lua");

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

function ObjEditor.GetObjectByParams(param)

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

function ObjEditor.GetObjectParams(obj,param)

parameters

obj para object of which the parameters are extracted.
param  
return o or a new table containing the parameter

ObjEditor.CreateObjectByParams

[[ 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?
}
  • return __ : the object is returned or nil
]]

syntax

function ObjEditor.CreateObjectByParams(param)

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? } |

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

TIP Sample Code

NPL.load("(gl)script/ide/object_editor_v1.lua");

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={};

RandomStaticMeshFacing = false; -- whether to randomize the mesh facing when created. CurrentDir = "model/"; CurrentAssetIndex = 0; -- category index of the ObjEditor.assets table SelectedGroupIndex = 0; LastCreatedModelName = ""; LastCreatedModelPath = ""; LastCreatePos = {x=0,y=0,z=0}; ObjEditor.objectCounter = 0; ObjEditor.MIN_OBJ_DIST = 0.15; -- smallest distance between two identical objects

syntax

function ObjEditor.LoadDevAsset()

ObjEditor.GetObject

load development asset by default. 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

function ObjEditor.GetObject(sName)

parameters

sName string: the name of the object.

ObjEditor.GetCurrentObj

get the current object

syntax

function ObjEditor.GetCurrentObj()

ObjEditor.SetCurrentObj

Set the current object

syntax

function ObjEditor.SetCurrentObj(o)

parameters

o  

ObjEditor.GetObjectNum

[get the number of active objects in the scene]

syntax

function ObjEditor.GetObjectNum()

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

function ObjEditor.RemoveObject(object_name)

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

function ObjEditor.CreatePhysicsObject(sName, Model, x,y,z,bSilentMode, reserved)

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

function ObjEditor.CreateMesh(sName, Model, x,y,z)

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

function ObjEditor.load(filename_)

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

function ObjEditor.OffsetObj(obj,dx,dy,dz)

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

function ObjEditor.RotateObj(obj,dx,dy,dz)

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

function ObjEditor.ScaleObj(obj,s)

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

function ObjEditor.CameraToWorldSpace(dx,dy,dz)

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

function ObjEditor.offsetByCamera(obj,dx,dy,dz)

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

function ObjEditor.MoveCurrentObj(dx,dy,dz)

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

function ObjEditor.RotateCurrentObj(dx,dy,dz)

parameters

dx ,dy,dz: rotation in rads around x,y,z axis]]
dy  
dz  

ObjEditor.ScaleCurrentObj

scale the current object

syntax

function ObjEditor.ScaleCurrentObj(dS)

parameters

dS  

ObjEditor.EnablePhysics

turn on/off physics object

syntax

function ObjEditor.EnablePhysics(bEnable)

parameters

bEnable  

ObjEditor.ResetCurrentObj

reset object

syntax

function ObjEditor.ResetCurrentObj()

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

function ObjEditor.ShowObjProperty(obj, bShow)

parameters

obj if nil, the current object is used
bShow  

ObjEditor.UnbindObjProperty

unbind the current object from the object property control

syntax

function ObjEditor.UnbindObjProperty()

ObjEditor.AutoCreateObject

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

function ObjEditor.AutoCreateObject(ObjName, FilePath, pos, sCategoryName, bSilentMode, reserved)

parameters

ObjName  
FilePath  
pos  
sCategoryName  
bSilentMode  
reserved  

ObjEditor.CreateLastObject

pos: can be {x,y,z} or nil

syntax

function ObjEditor.CreateLastObject(pos)

parameters

pos  

ObjEditor.SaveNearPlayer

save all scene objects as well as the scene itself in the current player's terrain location.

syntax

function ObjEditor.SaveNearPlayer()

ObjEditor.LoadNearPlayer

load from disk file.

syntax

function ObjEditor.LoadNearPlayer()

ObjEditor.SelObjectByName

select an existing object by name, and fire a missle to it.

syntax

function ObjEditor.SelObjectByName(objectname)

parameters

objectname  

ObjEditor.RemoveSelectedObject

Remove an current object from the list, but not from the scene.

syntax

function ObjEditor.RemoveSelectedObject()

ObjEditor.DelObject

safe delete the given object return true if succeeded.

syntax

function ObjEditor.DelObject(obj)

parameters

obj  

ObjEditor.DelSeletedObject

delete an object from the scene return true if succeeded.

syntax

function ObjEditor.DelSeletedObject()
Topic revision: r1 - 2008-02-29 - LiXizhi
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 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