public static int OutputRichText( int nFontId, //## 使用的字体对象id。 IntPtr pParam, // IntPtr psText, //## 要输出的字符串。 int nCount = GLB.KRF_ZERO_END, //## 要输出的字符串的长度(BYTE)。\当nCount大于等于0时,字符串可以不包括特殊的结束符号来表示输出字符的结束。\当nCount小于0时,表示此字符串是以'\0'结尾,且中间不存在'\0'的字符。\默认值为-1。 int nLineWidth = 0 //##Documentation\自动换行的行宽限制,如果其值小于一个全角字符宽度则不做自动换行处理。默认值为0,既不做自动换行处理。 ) { // todo: txt address + xy to uuid long uuid = (long)psText; string sText2 = Marshal.PtrToStringAnsi(psText); byte[] txtbuff = new byte[nCount + 1]; Marshal.Copy(psText, txtbuff, 0, nCount); string sText = GLB.GBK.GetString(txtbuff); //Debug.Log(sText); KOutputTextParam param = (KOutputTextParam)Marshal.PtrToStructure(pParam, typeof(KOutputTextParam)); int nX = param.nX; int nY = param.nY; float x = (float)nX / 100; float y = 8.0f - (float)nY / 100; float z = zbuff; zbuff -= 0.1f; //Debug.Log(string.Format("OutputRichText: {0} : {1} @ [{2}, {3}]", sText, nCount, nX, nY)); SprMgr.DrawText(uuid, sText, x, y, z); return(1); }
public static uint CreateImage(string imageName, int width, int height) { SprMgr self = SprMgr.GetInstance(); GameObject go = null;// new GameObject(imageName); self.ImagePool.Add(self.ImageSeed, go); return(self.ImageSeed++); }
public static bool RepresentBegin( int bClear, //## 是否清除设备上当前的图形。 uint Color //## 如果bClear为非0值,则Color指出用什么颜色值来清除设备原来的图形。 ) { if (SprMgr.GetInstance() != null) { SprMgr.GetInstance().Swap(); } zbuff = 0f; return(true); }
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; } }
public static uint CreateImage( IntPtr pszName, //## 图形的名字。 int nWidth, //## 图形横宽 int nHeight, //## 图形纵宽 KIS_IMAGE_TYPE nType //## 图形类型 ) { string szName = Marshal.PtrToStringAnsi(pszName); Debug.Log("CreateImage: " + szName); uint imgId = SprMgr.CreateImage(szName, nWidth, nHeight); return(imgId); }
// Update is called once per frame void FixedUpdate() { interval--; if (interval == 0) { nFrame++; interval = 60; Texture2D tx = SprMgr.GetInstance().LoadSpr(sprPath, nFrame); if (tx == null) { nFrame = -1; return; } Sprite newsp = Sprite.Create(tx, new Rect(0f, 0f, tx.width, tx.height), new Vector2(0.0f, 1.0f)); sr.sprite = newsp; } }
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); }
public static bool DrawSpr(long cmd_addr, pic_cmd_t cmds) { SprMgr self = SprMgr.GetInstance(); GameObject go = self.GetSpr(cmd_addr); Vector3 pos = new Vector3(cmds.pos1.x, cmds.pos1.y, cmds.pos1.z); bool bReload = false; string szImage = Encoding.UTF8.GetString(Encoding.Convert(GLB.GBK, Encoding.UTF8, cmds.filename)); KSSprite ksp; if (!go) { go = new GameObject(szImage); ksp = go.AddComponent <KSSprite>(); self.SprMap.Add(cmd_addr, ksp); //pos += new Vector3(tx.width/200, -tx.height/200, 0f); bReload = true; } else { ksp = go.GetComponent <KSSprite>(); if (ksp.GetFrame() != cmds.frame_index) { bReload = true; } } if (bReload) { Texture2D tx = self.LoadSpr(szImage, cmds.frame_index); if (!tx) { Debug.LogError("Load Spr Error: " + szImage); return(false); } Sprite sp = Sprite.Create(tx, new Rect(0f, 0f, tx.width, tx.height), new Vector2(0.0f, 1.0f), 100.0f, 0, SpriteMeshType.FullRect); ksp.SetSprite(sp, cmds.frame_index); } go.transform.parent = self.front.transform; go.transform.localPosition = pos; return(true); }
public static bool DrawText(long uuid, string text, float x, float y, float z = 0f) { SprMgr self = SprMgr.GetInstance(); GameObject go; if (!self.TxtPool.TryGetValue(uuid, out go)) { go = new GameObject(text); go.AddComponent <MeshRenderer>(); TextMesh _tm = go.AddComponent <TextMesh>(); _tm.characterSize = 0.04f; _tm.fontSize = 30; self.TxtPool.Add(uuid, go); } go.transform.parent = self.front.transform; TextMesh tm = go.GetComponent <TextMesh>(); tm.text = text; go.transform.localPosition = new Vector3(x, y, z); return(true); }
// Use this for initialization void Start() { string file = @"\UImage\第三版\ib系统\ib系统_底图.spr"; CoreWrapper.InitFile(); int size = CoreWrapper.GetFileSize(GLB.GBK.GetBytes(file)); Debug.Log("size = " + size); byte[] data = new byte[size]; //int read = CoreWrapper.LoadFile2(GLB.GBK.GetBytes(file), ref data, size); IntPtr read = CoreWrapper.LoadFile(GLB.GBK.GetBytes(file)); Marshal.Copy(read, data, 0, size); Debug.Log(read); sr = gameObject.GetComponent <SpriteRenderer>(); //Sprite sp = sr.sprite; //Color32[] colors1 = sp.texture.GetPixels32(); //Debug.Log(colors1); //Color32[] colors = new Color32[100 * 100]; //for (int i = 0; i < 100 * 100; i++) //{ // byte c = (byte)i; // colors[i] = new Color32(c, c, c, c); //} //Texture2D tx = new Texture2D(100, 100); //tx.SetPixels32(colors); //Sprite newsp = Sprite.Create(tx, new Rect(0f, 0f, 100f, 100f), new Vector2(0.5f, 0.5f)); Texture2D tx = SprMgr.GetInstance().LoadSpr(sprPath, 0); Sprite newsp = Sprite.Create(tx, new Rect(0f, 0f, tx.width, tx.height), new Vector2(0f, 1f)); sr.sprite = newsp; sr.flipY = true; //transform.localPosition -= new Vector3(tx.width / 200, tx.height / 200, 0f); }
public static void OutputText( int nFontId, //## 使用的字体对象id。 IntPtr psText, //## 要输出的字符串。 int nCount = GLB.KRF_ZERO_END, //## 要输出的字符串的长度(BYTE)。\当nCount大于等于0时,字符串可以不包括特殊的结束符号来表示输出字符的结束。\当nCount小于0时,表示此字符串是以'\0'结尾,将根据结束字符来确定输出字符串的长度。\默认值为-1。 int nX = GLB.KRF_FOLLOW, //## 字符串显示起点坐标X,如果传入值为KF_FOLLOW,\则此字符串紧接在上次字符串的输出位置之后。\默认值为KRF_FOLLOW。 int nY = GLB.KRF_FOLLOW, //## 字符串显示起点坐标Y, 如果传入值为KF_FOLLOW,\此字符串与前一次输出字符串在同一行的位置。\默认值为KRF_FOLLOW。 uint Color = 0xFF000000, //## 字符串显示颜色,默认为黑色,用32bit数以ARGB的格\式表示颜色,每个分量8bit。 int nLineWidth = 0, //## 自动换行的行宽限制,如果其值小于一个全角字符宽度则不做自动换行处理。默认值为0,既不做自动换行处理。 int nZ = GLB.TEXT_IN_SINGLE_PLANE_COORD, // uint BorderColor = 0 //字的边缘颜色 ) { long uuid = (long)psText; string sText = Marshal.PtrToStringAnsi(psText); //Debug.Log(string.Format("OutputText: {0} : {1} @ [{2}, {3}]", sText, nCount, nX, nY)); float x = (float)nX / 100; float y = 8.0f - (float)nY / 100; float z = zbuff; zbuff -= 0.1f; SprMgr.DrawText(uuid, sText, x, y, z); //g_pRepresent->OutputText(12, szDebugRef, KRF_ZERO_END, nX, nY, 0xffffffff, 0, 0); }
// Use this for initialization void Start() { _instance = this; del.SetActive(false); }