Public Member Functions

scene3d Class Reference

全3D场景类. More...

List of all members.

Public Member Functions

def destroy
def create_light
def get_preset_camera
def get_camera
def screen_to_world
def world_to_screen
def pick
def add_to_group
def get_bounding
def get_model
def get_model_count
def get_models
def get_models_in_group
def get_object_groups
def get_objs_in_group
def get_sfx_count
def get_sfxes_in_group
def auto_load_scene
def set_view_range
def set_view_position
def remove_from_group
def detour_load_mesh
def detour_load_config
def detour_debugdraw_mesh
def detour_debugdraw_path
def detour_get_poly_area
def detour_set_poly_area
def detour_get_poly_ref
def detour_get_path
def detour_rebuild
def detour_remove_mesh
def detour_set_area_cost

Detailed Description

全3D场景类.

请通过 iworld3d.create_scene3d 或 iworld3d.create_terrian_scene3d 函数创建.


Member Function Documentation

def destroy (   self )
销毁场景.
def create_light (   self,
  type 
)
创建动态光源
慎用,目前不能单独对光源进行销毁,所以如果大量使用可能会产生效率问题

参数 :
        type		: int 光源类型
                iworld3d.LIGHT_TYPE_POINT = 1  点光源
                iworld3d.LIGHT_TYPE_SPOT = 2  聚光灯光源
                iworld3d.LIGHT_TYPE_DIRECTION = 3  平行光源
        
返回值:
        iworld3d.light3d 光源实例
def get_preset_camera (   self,
  name 
)
获取场景预先定义好的相机矩阵

参数 :
        name		: 相机名字

返回值 :
        matrix :  math3d::matrix 相机的矩阵,包含了位置和方向
def get_camera (   self )
获取场景的相机

返回值:
        camera3d实例
def screen_to_world (   self,
  x,
  y 
)
屏幕坐标到世界坐标变换

参数:
        x	: int 屏幕x坐标
        y	: int 屏幕y坐标
返回值 :
        (math3d.vector, math3d.vector)  世界坐标下的射线(p0, dir), p0是原点, dir是方向
def world_to_screen (   self,
  pos 
)
世界坐标到屏幕坐标变换

参数:
        pos		: math3d.vector 世界坐标
返回值 :
        (x, y)  屏幕坐标
def pick (   self,
  x,
  y 
)
屏幕一点与3D场景中设置过set_pick的3D对象做碰撞检测,如果屏幕同一点叠有多个对象,会得到与相机最近的对象。
如果2D对象需要做碰撞检测,还需要先obj2d.set_pick()

参数:
        x		: int	屏幕坐标x
        y		: int	屏幕坐标y
返回值:
        model3d
        如果没碰撞,则返回None
def add_to_group (   self,
  obj,
  group_name 
)
添加一个模型/特效到指定的组.

参数:
        obj : iworld3d.model3d, iworld3d.fx3d 要添加的模型或特效
        group_name : string 对象组名称
def get_bounding (   self )
获取场景包围盒.

返回值:
        (max, min): (最大值, 最小值)
def get_model (   self,
  idx 
)
获取场景内的模型

参数:
        idx : string 模型索引标识
返回值:
        iworld3d.model3d 模型对象。如果找不到则返回None
def get_model_count (   self )
获取场景内的模型数量.

返回值:
        int 模型数量
def get_models (   self )
获取场景内所有的模型

返回值:
        list 模型列表
def get_models_in_group (   self,
  group_name 
)
得到指定组中的模型列表.

参数:
        group_name : string 对象组名称(可由场景编辑器编辑,或通过add_model_to_group生成)
返回值:
        list 模型列表
def get_object_groups (   self )
获取场景中所有物品组名称

返回值:
        list 所有物品的名字列表
def get_objs_in_group (   self,
  group_name 
)
得到指定组里面的模型和特效.
参数:
        group_name : string 对象组名称(可由场景编辑器编辑,或通过add_model_to_group生成)

返回值:
        list 组内所有模型和特效
def get_sfx_count (   self )
获取场景内的特效.

返回值:
        int 特效数量
def get_sfxes_in_group (   self,
  group_name 
)
得到指定组中的特效列表.

参数:
        group_name : string 对象组名称(可由场景编辑器编辑,或通过add_fx_to_group生成)
返回值:
        list : 组内特效
def auto_load_scene (   self,
  scn_file,
  offset 
)
动态加载分块的场景

参数:
        scn_file : str 场景文件名,该文件为3D场景编辑器编辑而来的文件。
        offset : math3d.vector 新场景相对原场景的偏移值
def set_view_range (   self,
  range 
)
场景自动加载的范围,默认为800
需要在auto_load_scene调用后才有效

参数:
        range : float 范围
def set_view_position (   self,
  position 
)
场景自动加载的中心点
需要在auto_load_scene调用后才有效

参数:
        position : math3d.vector 中心点位置
def remove_from_group (   self,
  obj,
  group_name 
)
从组内移除 模型或特效.

参数:
        obj : iworld3d.model 或iworld3d.fx3d
        group_name : string 组名称
def detour_load_mesh (   self,
  mesh_name,
  file_name,
  ofs = None 
)
加载静态寻路网格.
特点:网格信息在场景编辑器中预先生成,适用于小场景寻路。

参数:
        mesh_name : string 寻路网格名称
        file_name : string 寻路网格文件名,对应3D场景编辑器中生成的 .nav 文件
        ofs : maht3d.vector 加载偏移位置,暂时请先不使用此参数

返回值:
        bool : 是否成功
def detour_load_config (   self,
  mesh_name,
  file_name 
)
加载动态寻路网格.
特定:网格信息在程序中动态生成,适用于需要拼接的大场景。

参数:
        mesh_name : string 寻路网格名称
        file_name : string 寻路网格文件名,对应3D场景编辑器中生成的 .nac 文件

返回值:
        bool : 是否成功
def detour_debugdraw_mesh (   self,
  mesh_name,
  flag 
)
设置寻路网格debug绘制开关.

注意:采用 iworld3d.scene3d.detour_load_config 加载的网格为异步加载,如果马上在此后
立刻打开debug绘制开关,可能网格不会显示。可参考idemos/detourdemo中的使用方法来使用
debug绘制开关接口.
参数:
        mesh_name : string 寻路网格名称
        flag : bool True/False 打开/关闭debug绘制
def detour_debugdraw_path (   self,
  flag 
)
设置寻路路径debug绘制开关.

参数:
        flag : bool True/False 开关/关闭debug绘制,关闭时会将网格debug绘制也关闭。
def detour_get_poly_area (   self,
  mesh_name,
  poly_ref 
)
根据多边形标识得到其对应的区域.

参数:
        mesh_name : string 寻路网格名称
        poly_ref : unsigned short 多边形标识

返回值:
        int/None 对应的区域,失败返回None
def detour_set_poly_area (   self,
  mesh_name,
  poly_ref,
  area 
)
根据多边形标识设置其对应的区域.

参数:
        mesh_name : string 寻路网格名称
        poly_ref : unsigned short 多边形标识
        area : int [0, 15] 可设置的16种区域,其中0为普通区域(由几何建模生成的地方)

返回值:
        bool : 是否成功
def detour_get_poly_ref (   self,
  mesh_name,
  bmin,
  bmax,
  filter_flag = 0xffff 
)
返回指定范围内,符合filter_flag的所有多边形的标识.

参数:
        mesh_name : string 寻路网格名称
        bmin : math.vector3d AABB最小值
        bmax : math.vector3d AABB最大值
        filter_flag : 对多边形进行区域类型过滤,与区域的关系为:
filter_flag为2的area_idx幂,例 0xffff表示所有的区域可行,0x10表示区域1可行, 0x00表示所有区域不可行
特别注意 0x01为区域0(对应普通区域,几何建模生成的地方)

返回值:
        tuple/None : 多边形标识列表,由一串 unsigned short 组成,失败则返回None
def detour_get_path (   self,
  mesh_name,
  start_pos,
  end_pos,
  poly_search = 256,
  filter_flag = 0xffff 
)
得到寻路路径.

参数:
        mesh_name : string 寻路网格名称
        start_pos : math3d.vector 起始位置
        end_pos : math3d.vector 结束位置
        poly_search : int 搜索的多边形的个数,越大越慢,太小就找不到长路径, 默认256
        filter_flag : 对多边形进行区域类型过滤,与区域的关系为:
filter_flag为2的area_idx幂,例 0xffff表示所有的区域可行,0x10表示区域1可行, 0x00表示所有区域不可行
特别注意 0x01为区域0(对应普通区域,几何建模生成的地方)
举例:如某些情况水面可行,某些情况水面不可行,可用filter_flag对区域进行过滤.

返回值:
        tuple 得到的路径,由一串 math3d.vector 组成.
def detour_rebuild (   self,
  mesh_name,
  bmin = None,
  bmax = None 
)
重新生成寻路网格信息.
如果不指定起止位置则整个场景重建寻路网格

参数:
        mesh_name : string 寻路网格名称
        bmin : math3d.vector AABB最小值
        bmax : math3d.vector AABB最大值

返回值:
        bool : 是否成功
def detour_remove_mesh (   self,
  mesh_name 
)
从场景中移除某寻路网格.

参数:
        mesh_name : string 寻路网格名称
返回值:
        bool : 是否成功
def detour_set_area_cost (   self,
  mesh_name,
  area_idx,
  cost 
)
设置区域对应的权重.
说明:该权重对应于寻路中A*算法的权重.该功能属于寻路的高级功能,比如可用于
针对水面,草地,沙地的不同给出不同的权重.

参数:
        mesh_name : string 寻路网格名称
        area_idx : int [0, 15] 可设置的16种区域,其中0为普通区域(由几何建模生成的地方)
        cost : float 范围>=1
        
返回值:
        bool : 是否成功
 All Classes Namespaces Functions Variables Properties