Vuforia 收藏本版 已有9人收藏 +发表新主题
查看: 66365|回复: 29
打印 上一主题 下一主题

APP ColAR Mix 解析

[复制链接]

APP ColAR Mix 解析

爱生活爱AR 发表于 2014-1-22 10:37:40 浏览:  66365 回复:  29 只看该作者 复制链接
提示: 作者被禁止或删除 内容自动屏蔽
分享至:
| 人收藏
回复

使用道具 举报

该用户从未签到

沙发
click 发表于 2014-1-26 00:50:52 只看该作者
貌似我们已经搞定了这个,可以自己做了
回复 支持 反对

使用道具 举报

爱生活爱AR 该用户已被删除
板凳
爱生活爱AR
 楼主|
发表于 2014-1-29 20:17:21 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

该用户从未签到

地板
777 发表于 2014-2-2 23:12:42 只看该作者
我想说的是。
呵呵 最近研究粒子特效的时候  突然发现 里面的有些动画  也是粒子做的 。
这样整 既省时又省力呵呵
回复 支持 反对

使用道具 举报

该用户从未签到

5#
kvaliu 发表于 2014-3-28 15:10:32 只看该作者
click 发表于 2014-1-26 00:50
貌似我们已经搞定了这个,可以自己做了

能说下是怎么知道截图位置和正确的大小的啊,谢谢
回复 支持 反对

使用道具 举报

该用户从未签到

6#
777 发表于 2014-6-18 14:37:34 只看该作者
  1. using System;
  2. using UnityEngine;
  3. public class BGRenderingBehaviour : MonoBehaviour
  4. {
  5.         //
  6.         // Fields
  7.         //
  8.         private int mScreenWidth;

  9.         private int mScreenHeight;

  10.         private bool mFlipHorizontally;

  11.         public Camera Camera;

  12.         private QCARRenderer.VideoTextureInfo mTextureInfo;

  13.         private ScreenOrientation mScreenOrientation;

  14.         //
  15.         // Methods
  16.         //
  17.         public void CheckAndSetActive (bool isActive)
  18.         {
  19.                 if (this.Camera.gameObject.active != isActive)
  20.                 {
  21.                         this.Camera.gameObject.SetActiveRecursively (isActive);
  22.                 }
  23.         }

  24.         private Mesh CreateVideoMesh ()
  25.         {
  26.                 Mesh mesh = new Mesh ();
  27.                 mesh.vertices = new Vector3[4];
  28.                 Vector3[] vertices = mesh.vertices;
  29.                 for (int i = 0; i < 2; i++)
  30.                 {
  31.                         for (int j = 0; j < 2; j++)
  32.                         {
  33.                                 float num = (float)j / 1f - 0.5f;
  34.                                 float num2 = 1f - (float)i / 1f - 0.5f;
  35.                                 vertices [i * 2 + j].x = num * 2f;
  36.                                 vertices [i * 2 + j].y = 0f;
  37.                                 vertices [i * 2 + j].z = num2 * 2f;
  38.                         }
  39.                 }
  40.                 mesh.vertices = vertices;
  41.                 mesh.triangles = new int[24];
  42.                 int num3 = 0;
  43.                 float num4 = (float)this.mTextureInfo.imageSize.x / (float)this.mTextureInfo.textureSize.x;
  44.                 float num5 = (float)this.mTextureInfo.imageSize.y / (float)this.mTextureInfo.textureSize.y;
  45.                 mesh.uv = new Vector2[4];
  46.                 int[] triangles = mesh.triangles;
  47.                 Vector2[] uv = mesh.uv;
  48.                 for (int k = 0; k < 1; k++)
  49.                 {
  50.                         for (int l = 0; l < 1; l++)
  51.                         {
  52.                                 int num6 = k * 2 + l;
  53.                                 int num7 = k * 2 + l + 2 + 1;
  54.                                 int num8 = k * 2 + l + 2;
  55.                                 int num9 = k * 2 + l + 1;
  56.                                 triangles [num3++] = num6;
  57.                                 triangles [num3++] = num7;
  58.                                 triangles [num3++] = num8;
  59.                                 triangles [num3++] = num7;
  60.                                 triangles [num3++] = num6;
  61.                                 triangles [num3++] = num9;
  62.                                 uv [num6] = new Vector2 ((float)l / 1f * num4, (float)k / 1f * num5);
  63.                                 uv [num7] = new Vector2 ((float)(l + 1) / 1f * num4, (float)(k + 1) / 1f * num5);
  64.                                 uv [num8] = new Vector2 ((float)l / 1f * num4, (float)(k + 1) / 1f * num5);
  65.                                 uv [num9] = new Vector2 ((float)(l + 1) / 1f * num4, (float)k / 1f * num5);
  66.                                 if (this.mFlipHorizontally)
  67.                                 {
  68.                                         uv [num6].x = 1f - uv [num6].x;
  69.                                         uv [num7].x = 1f - uv [num7].x;
  70.                                         uv [num8].x = 1f - uv [num8].x;
  71.                                         uv [num9].x = 1f - uv [num9].x;
  72.                                 }
  73.                         }
  74.                 }
  75.                 mesh.triangles = triangles;
  76.                 mesh.uv = uv;
  77.                 mesh.normals = new Vector3[mesh.vertices.Length];
  78.                 mesh.RecalculateNormals ();
  79.                 return mesh;
  80.         }

  81.         private void PositionVideoMesh ()
  82.         {
  83.                 this.mScreenOrientation = QCARRuntimeUtilities.ScreenOrientation;
  84.                 this.mScreenWidth = Screen.width;
  85.                 this.mScreenHeight = Screen.height;
  86.                 base.gameObject.transform.localRotation = Quaternion.AngleAxis (270f, Vector3.right);
  87.                 if (this.mScreenOrientation == ScreenOrientation.LandscapeLeft)
  88.                 {
  89.                         base.gameObject.transform.localRotation *= Quaternion.identity;
  90.                 }
  91.                 else
  92.                 {
  93.                         if (this.mScreenOrientation == ScreenOrientation.Portrait)
  94.                         {
  95.                                 base.gameObject.transform.localRotation *= Quaternion.AngleAxis (90f, Vector3.up);
  96.                         }
  97.                         else
  98.                         {
  99.                                 if (this.mScreenOrientation == ScreenOrientation.LandscapeRight)
  100.                                 {
  101.                                         base.gameObject.transform.localRotation *= Quaternion.AngleAxis (180f, Vector3.up);
  102.                                 }
  103.                                 else
  104.                                 {
  105.                                         if (this.mScreenOrientation == ScreenOrientation.PortraitUpsideDown)
  106.                                         {
  107.                                                 base.gameObject.transform.localRotation *= Quaternion.AngleAxis (270f, Vector3.up);
  108.                                         }
  109.                                 }
  110.                         }
  111.                 }
  112.                 base.gameObject.transform.localScale = new Vector3 (1f, 1f, 1f * (float)this.mTextureInfo.imageSize.y / (float)this.mTextureInfo.imageSize.x);
  113.                 this.Camera.orthographic = true;
  114.                 float orthographicSize;
  115.                 if (this.ShouldFitWidth ())
  116.                 {
  117.                         if (QCARRuntimeUtilities.IsPortraitOrientation)
  118.                         {
  119.                                 orthographicSize = (float)this.mTextureInfo.imageSize.y / (float)this.mTextureInfo.imageSize.x * ((float)this.mScreenHeight / (float)this.mScreenWidth);
  120.                         }
  121.                         else
  122.                         {
  123.                                 orthographicSize = (float)this.mScreenHeight / (float)this.mScreenWidth;
  124.                         }
  125.                 }
  126.                 else
  127.                 {
  128.                         if (QCARRuntimeUtilities.IsPortraitOrientation)
  129.                         {
  130.                                 orthographicSize = 1f;
  131.                         }
  132.                         else
  133.                         {
  134.                                 orthographicSize = (float)this.mTextureInfo.imageSize.y / (float)this.mTextureInfo.imageSize.x;
  135.                         }
  136.                 }
  137.                 this.Camera.orthographicSize = orthographicSize;
  138.         }

  139.         public void SetFlipHorizontally (bool flip)
  140.         {
  141.                 this.mFlipHorizontally = flip;
  142.         }

  143.         public void SetTexture (Texture texture)
  144.         {
  145.                 base.renderer.material.mainTexture = texture;
  146.         }

  147.         private bool ShouldFitWidth ()
  148.         {
  149.                 float num = (float)this.mScreenWidth / (float)this.mScreenHeight;
  150.                 float num2;
  151.                 if (QCARRuntimeUtilities.IsPortraitOrientation)
  152.                 {
  153.                         num2 = (float)this.mTextureInfo.imageSize.y / (float)this.mTextureInfo.imageSize.x;
  154.                 }
  155.                 else
  156.                 {
  157.                         num2 = (float)this.mTextureInfo.imageSize.x / (float)this.mTextureInfo.imageSize.y;
  158.                 }
  159.                 return num >= num2;
  160.         }

  161.         private void Start ()
  162.         {
  163.                 if (this.Camera == null)
  164.                 {
  165.                         this.Camera = Camera.main;
  166.                 }
  167.         }

  168.         private void Update ()
  169.         {
  170.                 if (QCARRenderer.Instance.IsVideoBackgroundInfoAvailable ())
  171.                 {
  172.                         QCARRenderer.VideoTextureInfo videoTextureInfo = QCARRenderer.Instance.GetVideoTextureInfo ();
  173.                         if (!this.mTextureInfo.imageSize.Equals (videoTextureInfo.imageSize) || !this.mTextureInfo.textureSize.Equals (videoTextureInfo.textureSize))
  174.                         {
  175.                                 this.mTextureInfo = videoTextureInfo;
  176.                                 Debug.Log (string.Concat (new object[]
  177.                                 {
  178.                                         "VideoTextureInfo ",
  179.                                         videoTextureInfo.textureSize.x,
  180.                                         " ",
  181.                                         videoTextureInfo.textureSize.y,
  182.                                         " ",
  183.                                         videoTextureInfo.imageSize.x,
  184.                                         " ",
  185.                                         videoTextureInfo.imageSize.y
  186.                                 }));
  187.                                 MeshFilter meshFilter = base.GetComponent<MeshFilter> ();
  188.                                 if (meshFilter == null)
  189.                                 {
  190.                                         meshFilter = base.gameObject.AddComponent<MeshFilter> ();
  191.                                 }
  192.                                 meshFilter.mesh = this.CreateVideoMesh ();
  193.                                 this.PositionVideoMesh ();
  194.                         }
  195.                         else
  196.                         {
  197.                                 if (this.mScreenOrientation != QCARRuntimeUtilities.ScreenOrientation || this.mScreenWidth != Screen.width || this.mScreenHeight != Screen.height)
  198.                                 {
  199.                                         this.PositionVideoMesh ();
  200.                                 }
  201.                         }
  202.                 }
  203.         }
  204. }
复制代码
回复 支持 反对

使用道具 举报

该用户从未签到

7#
777 发表于 2014-6-18 14:39:32 只看该作者
抓取 图片设置成贴图 图片。
回复 支持 反对

使用道具 举报

该用户从未签到

8#
zeroAR 发表于 2014-7-29 22:32:41 只看该作者
777 发表于 2014-6-18 14:39
抓取 图片设置成贴图 图片。

那怎么抓取呐?
回复 支持 反对

使用道具 举报

该用户从未签到

9#
大白菜 发表于 2014-7-30 10:06:57 只看该作者
zeroAR 发表于 2014-7-29 22:32
那怎么抓取呐?

自己看代码
回复 支持 反对

使用道具 举报

该用户从未签到

10#
zeroAR 发表于 2014-7-30 14:19:51 只看该作者
大白菜 发表于 2014-7-30 10:06
自己看代码

这代码我测试过了 只是创建了 对应的MESH ~~

抓图 不在这代码里面吧
回复 支持 反对

使用道具 举报

123下一页
*滑动验证:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Copyright © 2013-2017 ARinChina-增强现实中国技术论坛   All Rights Reserved.