Пример #1
0
    public static void DrawPrimitives(
        int nPrimitiveCount,    //## 绘制的图元的数目
        IntPtr pPrimitives,     //## 描述图元的结构的数组
        uint uGenre,            //## Primitive类型,取值来自枚举值REPRESENT_UNIT_TYPE
        int bSinglePlaneCoord   //## 图元绘制操作提供的坐标是否为垂直与视线的单平面坐标。如果不是,则图元绘制操作提供的坐标是三维空间坐标。
        )
    {
        //Debug.Log("DrawPrimitives: ");
        switch (uGenre)
        {
        case (int)REPRESENT_UNIT_TYPE.RU_T_IMAGE:
        case (int)REPRESENT_UNIT_TYPE.RU_T_IMAGE_PART:
        case (int)REPRESENT_UNIT_TYPE.RU_T_IMAGE_4:
        case (int)REPRESENT_UNIT_TYPE.RU_T_IMAGE_STRETCH:
        {
            IntPtr pSpr = pPrimitives;
            for (int n = 0; n < nPrimitiveCount; n++, IntPtrOffset(pSpr, IntPtr.Size))
            {
                long      uuid = (long)pSpr;
                pic_cmd_t cmds = (pic_cmd_t)Marshal.PtrToStructure(pSpr, typeof(pic_cmd_t));
                //Debug.Log("uuid: " + uuid + ", Type: " + uGenre);
                //Debug.Log(GLB.GBK.GetString(cmds.filename));
                cmds.pos1.x /= 100;
                cmds.pos1.y /= 100;
                cmds.pos1.y  = 8.0f - cmds.pos1.y;
                cmds.pos1.z /= 100;
                cmds.pos1.z += zbuff;
                zbuff       -= 0.1f;
                //Debug.Log(string.Format("Image: {0},{4} at [{1},{2},{3}]", "", cmds.pos1.x, cmds.pos1.y, cmds.pos1.z, cmds.frame_index));
                if (cmds.filename[0] == 0)
                {
                    break;
                }
                SprMgr.DrawSpr(uuid, cmds);
            }
        }
        break;

        case (int)REPRESENT_UNIT_TYPE.RU_T_MODEL:
        {
            long uuid = (long)pPrimitives;
            space_obj_primitive_cmd_t cmds = (space_obj_primitive_cmd_t)Marshal.PtrToStructure(pPrimitives, typeof(space_obj_primitive_cmd_t));
            cmds.pos.x /= 100;
            cmds.pos.y /= 100;
            cmds.pos.y  = 8.0f - cmds.pos.y;
            cmds.pos.z += zbuff;
            zbuff      += 0.1f;
            //SprMgr.DrawModel(uuid, cmds);
        }
        break;
        }
    }
Пример #2
0
    public static void DrawModel(long uuid, space_obj_primitive_cmd_t cmds)
    {
        IntPtr obj;

        SprMgr     self = SprMgr.GetInstance();
        GameObject go;

        if (!self.modelPool.TryGetValue(uuid, out go))
        {
            go = new GameObject();
            go.AddComponent <SkinnedMeshRenderer>();
            go.AddComponent <Animation>();
            go.AddComponent <KSMesh>();
            self.modelPool.Add(uuid, go);
        }
        go.transform.parent        = self.front.transform;
        go.transform.localPosition = new Vector3(cmds.pos.x, cmds.pos.y, cmds.pos.z);
    }