nyartoolkit 

Commit MetaInfo

Revision1051 (tree)
Time2012-05-30 08:38:27
Authornyatla

Log Message

change character encoding to UNICODE.

Change Summary

Diff

--- NyARToolkitUnity/trunk/Assets/sample/MarkerPlane/MarkerPlaneBehavior.cs (revision 1050)
+++ NyARToolkitUnity/trunk/Assets/sample/MarkerPlane/MarkerPlaneBehavior.cs (revision 1051)
@@ -1,75 +1,76 @@
1-using UnityEngine;
2-using UnityEditor;
3-using System;
4-using System.Collections;
5-using jp.nyatla.nyartoolkit.cs.markersystem;
6-using jp.nyatla.nyartoolkit.cs.core;
7-using NyARUnityUtils;
8-using System.IO;
9-/// <summary>
10-/// このサンプルプログラムは、マーカ表面の画像をテクスチャとして取得します。
11-/// マーカファイルには、hiroマーカを使用してください。
12-/// </summary>
13-public class MarkerPlaneBehavior : MonoBehaviour
14-{
15- private NyARUnityMarkerSystem _ms;
16- private NyARUnityWebCam _ss;
17- private int mid;//marker id
18- private GameObject _bg_panel;
19- void Awake()
20- {
21- //setup unity webcam
22- WebCamDevice[] devices= WebCamTexture.devices;
23- WebCamTexture w;
24- if (devices.Length > 0){
25- w=new WebCamTexture(320, 240, 15);
26- this._ss=new NyARUnityWebCam(w);
27- NyARMarkerSystemConfig config = new NyARMarkerSystemConfig(w.requestedWidth,w.requestedHeight);
28- this._ms=new NyARUnityMarkerSystem(config);
29- mid=this._ms.addARMarker("./Assets/Data/patt.hiro",16,25,80);
30-
31- //setup background
32- this._bg_panel=GameObject.Find("Plane");
33- this._bg_panel.renderer.material.mainTexture=w;
34- this._ms.setARBackgroundTransform(this._bg_panel.transform);
35-
36- //setup camera projection
37- this._ms.setARCameraProjection(this.camera);
38-
39- }else{
40- Debug.LogError("No Webcam.");
41- }
42- }
43- // Use this for initialization
44- void Start ()
45- {
46- this._ss.start();
47- }
48- int c=0;
49- // Update is called once per frame
50- void Update ()
51- {
52- //Update marker system by ss
53- this._ss.update();
54- this._ms.update(this._ss);
55- Vector3 mpos=Input.mousePosition;
56- mpos=this.camera.ScreenToViewportPoint(mpos);
57- mpos.x=(mpos.x)*320;
58- mpos.y=(1.0f-mpos.y)*240;
59- Debug.Log(c+":"+mpos.x+","+mpos.y+","+mpos.z);c++;
60- //update Gameobject transform
61- if(this._ms.isExistMarker(mid)){
62- this._ms.setMarkerTransform(mid,GameObject.Find("MarkerObject").transform);
63- //マウス座標の取得
64- //平面座標に変換
65- Vector3 p=new Vector3();
66- this._ms.getMarkerPlanePos(mid,(int)mpos.x,(int)mpos.y,ref p);
67- GameObject.Find("Cube").transform.localPosition=p;
68- Transform t=GameObject.Find("MarkerObject").transform;
69- }else{
70- // hide Game object
71- GameObject.Find("MarkerObject").transform.localPosition=new Vector3(0,0,-100);
72- }
73- }
74-}
75-
1+using UnityEngine;
2+using UnityEditor;
3+using System;
4+using System.Collections;
5+using jp.nyatla.nyartoolkit.cs.markersystem;
6+using jp.nyatla.nyartoolkit.cs.core;
7+using NyARUnityUtils;
8+using System.IO;
9+/// <summary>
10+/// S0n0オ0?ラ0?ラ0?ー0??o00゙0?ォ0h?溶0;uマP?ニ0ッ0ケ0チ0?h0W0f0ヨS誉W0~0Y00
11+/// ゙0?ォ0ユ0。0、0?k0o00hiro゙0?ォ0?O(uW0f0O0`0U0D00
12+/// </summary>
13+public class MarkerPlaneBehavior : MonoBehaviour
14+{
15+ private NyARUnityMarkerSystem _ms;
16+ private NyARUnityWebCam _ss;
17+ private int mid;//marker id
18+ private GameObject _bg_panel;
19+ void Awake()
20+ {
21+ //setup unity webcam
22+ WebCamDevice[] devices= WebCamTexture.devices;
23+ WebCamTexture w;
24+ if (devices.Length > 0){
25+ w=new WebCamTexture(320, 240, 15);
26+ this._ss=new NyARUnityWebCam(w);
27+ NyARMarkerSystemConfig config = new NyARMarkerSystemConfig(w.requestedWidth,w.requestedHeight);
28+ this._ms=new NyARUnityMarkerSystem(config);
29+ mid=this._ms.addARMarker("./Assets/Data/patt.hiro",16,25,80);
30+
31+ //setup background
32+ this._bg_panel=GameObject.Find("Plane");
33+ this._bg_panel.renderer.material.mainTexture=w;
34+ this._ms.setARBackgroundTransform(this._bg_panel.transform);
35+
36+ //setup camera projection
37+ this._ms.setARCameraProjection(this.camera);
38+
39+ }else{
40+ Debug.LogError("No Webcam.");
41+ }
42+ }
43+ // Use this for initialization
44+ void Start ()
45+ {
46+ this._ss.start();
47+ }
48+ int c=0;
49+ // Update is called once per frame
50+ void Update ()
51+ {
52+ //Update marker system by ss
53+ this._ss.update();
54+ this._ms.update(this._ss);
55+ Vector3 mpos=Input.mousePosition;
56+ mpos=this.camera.ScreenToViewportPoint(mpos);
57+ mpos.x=(mpos.x)*320;
58+ mpos.y=(1.0f-mpos.y)*240;
59+ Debug.Log(c+":"+mpos.x+","+mpos.y+","+mpos.z);c++;
60+ //update Gameobject transform
61+ if(this._ms.isExistMarker(mid)){
62+ this._ms.setMarkerTransform(mid,GameObject.Find("MarkerObject").transform);
63+ //゙0ヲ0ケ0ァ^jn0ヨS誉
64+ //s^b立^jk0 Yロc
65+ Vector3 p=new Vector3();
66+ this._ms.getMarkerPlanePos(mid,(int)mpos.x,(int)mpos.y,ref p);
67+ GameObject.Find("Cube").transform.localPosition=p;
68+ Transform t=GameObject.Find("MarkerObject").transform;
69+ }else{
70+ // hide Game object
71+ GameObject.Find("MarkerObject").transform.localPosition=new Vector3(0,0,-100);
72+ }
73+ }
74+}
75+
76+
\ No newline at end of file
--- NyARToolkitUnity/trunk/Assets/sample/SimpleLiteM/SimpleLiteMBehaviour.cs (revision 1050)
+++ NyARToolkitUnity/trunk/Assets/sample/SimpleLiteM/SimpleLiteMBehaviour.cs (revision 1051)
@@ -1,76 +1,77 @@
1-using UnityEngine;
2-using System;
3-using System.Collections;
4-using jp.nyatla.nyartoolkit.cs.markersystem;
5-using jp.nyatla.nyartoolkit.cs.core;
6-using NyARUnityUtils;
7-using System.IO;
8-
9-/// <summary>
10-/// AR camera behaviour.
11-/// This sample shows simpleLite demo.
12-/// 1.Connect webcam to your computer.
13-/// 2.Start sample program
14-/// 3.Take a "HIRO" marker and "KANJI" on capture image
15-///
16-/// </summary>
17-public class SimpleLiteMBehaviour : MonoBehaviour
18-{
19- private NyARUnityMarkerSystem _ms;
20- private NyARUnityWebCam _ss;
21- private int mid1;//marker id
22- private int mid2;//marker id
23- private GameObject _bg_panel;
24- void Awake()
25- {
26- //setup unity webcam
27- WebCamDevice[] devices= WebCamTexture.devices;
28- WebCamTexture w;
29- if (devices.Length > 0){
30- w=new WebCamTexture(320, 240, 15);
31- this._ss=new NyARUnityWebCam(w);
32- NyARMarkerSystemConfig config = new NyARMarkerSystemConfig(w.requestedWidth,w.requestedHeight);
33- this._ms=new NyARUnityMarkerSystem(config);
34- mid1=this._ms.addARMarker("./Assets/Data/patt.hiro",16,25,80);
35- mid2=this._ms.addARMarker("./Assets/Data/patt.kanji",16,25,80);
36-
37- //setup background
38- this._bg_panel=GameObject.Find("Plane");
39- this._bg_panel.renderer.material.mainTexture=w;
40- this._ms.setARBackgroundTransform(this._bg_panel.transform);
41-
42- //setup camera projection
43- this._ms.setARCameraProjection(this.camera);
44-
45- }else{
46- Debug.LogError("No Webcam.");
47- }
48- }
49- // Use this for initialization
50- void Start ()
51- {
52- //start sensor
53- this._ss.start();
54- }
55- // Update is called once per frame
56- void Update ()
57- {
58- //Update SensourSystem
59- this._ss.update();
60- //Update marker system by ss
61- this._ms.update(this._ss);
62- //update Gameobject transform
63- if(this._ms.isExistMarker(mid1)){
64- this._ms.setMarkerTransform(mid1,GameObject.Find("MarkerObject").transform);
65- }else{
66- // hide Game object
67- GameObject.Find("MarkerObject").transform.localPosition=new Vector3(0,0,20);
68- }
69- if(this._ms.isExistMarker(mid2)){
70- this._ms.setMarkerTransform(mid2,GameObject.Find("MarkerObject2").transform);
71- }else{
72- // hide Game object
73- GameObject.Find("MarkerObject2").transform.localPosition=new Vector3(0,0,-100);
74- }
75- }
76-}
1+using UnityEngine;
2+using System;
3+using System.Collections;
4+using jp.nyatla.nyartoolkit.cs.markersystem;
5+using jp.nyatla.nyartoolkit.cs.core;
6+using NyARUnityUtils;
7+using System.IO;
8+
9+/// <summary>
10+/// AR camera behaviour.
11+/// This sample shows simpleLite demo.
12+/// 1.Connect webcam to your computer.
13+/// 2.Start sample program
14+/// 3.Take a "HIRO" marker and "KANJI" on capture image
15+///
16+/// </summary>
17+public class SimpleLiteMBehaviour : MonoBehaviour
18+{
19+ private NyARUnityMarkerSystem _ms;
20+ private NyARUnityWebCam _ss;
21+ private int mid1;//marker id
22+ private int mid2;//marker id
23+ private GameObject _bg_panel;
24+ void Awake()
25+ {
26+ //setup unity webcam
27+ WebCamDevice[] devices= WebCamTexture.devices;
28+ WebCamTexture w;
29+ if (devices.Length > 0){
30+ w=new WebCamTexture(320, 240, 15);
31+ this._ss=new NyARUnityWebCam(w);
32+ NyARMarkerSystemConfig config = new NyARMarkerSystemConfig(w.requestedWidth,w.requestedHeight);
33+ this._ms=new NyARUnityMarkerSystem(config);
34+ mid1=this._ms.addARMarker("./Assets/Data/patt.hiro",16,25,80);
35+ mid2=this._ms.addARMarker("./Assets/Data/patt.kanji",16,25,80);
36+
37+ //setup background
38+ this._bg_panel=GameObject.Find("Plane");
39+ this._bg_panel.renderer.material.mainTexture=w;
40+ this._ms.setARBackgroundTransform(this._bg_panel.transform);
41+
42+ //setup camera projection
43+ this._ms.setARCameraProjection(this.camera);
44+
45+ }else{
46+ Debug.LogError("No Webcam.");
47+ }
48+ }
49+ // Use this for initialization
50+ void Start ()
51+ {
52+ //start sensor
53+ this._ss.start();
54+ }
55+ // Update is called once per frame
56+ void Update ()
57+ {
58+ //Update SensourSystem
59+ this._ss.update();
60+ //Update marker system by ss
61+ this._ms.update(this._ss);
62+ //update Gameobject transform
63+ if(this._ms.isExistMarker(mid1)){
64+ this._ms.setMarkerTransform(mid1,GameObject.Find("MarkerObject").transform);
65+ }else{
66+ // hide Game object
67+ GameObject.Find("MarkerObject").transform.localPosition=new Vector3(0,0,20);
68+ }
69+ if(this._ms.isExistMarker(mid2)){
70+ this._ms.setMarkerTransform(mid2,GameObject.Find("MarkerObject2").transform);
71+ }else{
72+ // hide Game object
73+ GameObject.Find("MarkerObject2").transform.localPosition=new Vector3(0,0,-100);
74+ }
75+ }
76+}
77+
\ No newline at end of file
--- NyARToolkitUnity/trunk/Assets/sample/JpegFile/ARJpegBehaviour.cs (revision 1050)
+++ NyARToolkitUnity/trunk/Assets/sample/JpegFile/ARJpegBehaviour.cs (revision 1051)
@@ -1,57 +1,58 @@
1-using UnityEngine;
2-using UnityEditor;
3-using System;
4-using System.Collections;
5-using jp.nyatla.nyartoolkit.cs.markersystem;
6-using jp.nyatla.nyartoolkit.cs.core;
7-using NyARUnityUtils;
8-using System.IO;
9-
10-public class ARJpegBehaviour : MonoBehaviour
11-{
12- private NyARUnityMarkerSystem _ms;
13- private NyARUnitySensor _ss;
14- private int mid;//marker id
15- private GameObject _bg_panel;
16-
17- void Awake()
18- {
19- //setup texture
20- Texture2D tex= (Texture2D)Resources.Load("320x240ABGR", typeof(Texture2D));
21- this._ss=new NyARUnitySensor(tex.width,tex.height);
22- this._ss.update(tex);
23-
24- NyARMarkerSystemConfig config = new NyARMarkerSystemConfig(tex.width,tex.height);
25- this._ms=new NyARUnityMarkerSystem(config);
26- this._ms.setConfidenceThreshold(0.1);
27- mid=this._ms.addARMarker("./Assets/Data/patt.hiro",16,25,80);
28-
29- //setup background
30- this._bg_panel=GameObject.Find("Plane");
31- this._bg_panel.renderer.material.mainTexture=tex;
32- this._ms.setARBackgroundTransform(this._bg_panel.transform);
33-
34- //setup camera projection
35- this._ms.setARCameraProjection(this.camera);
36- }
37- // Use this for initialization
38- void Start ()
39- {
40- }
41- // Update is called once per frame
42- void Update ()
43- {
44- //Update marker system by ss
45- this._ms.update(this._ss);
46- //update Gameobject transform
47- if(this._ms.isExistMarker(mid)){
48- Debug.Log(c+":"+this._ms.getConfidence(mid));
49- this._ms.setMarkerTransform(mid,GameObject.Find("MarkerObject").transform);
50- Debug.Log(this._ms.getConfidence(mid));
51- }else{
52- // hide Game object
53- GameObject.Find("MarkerObject").transform.localPosition=new Vector3(0,0,-100);
54- }
55- }
56- int c=0;
57-}
1+using UnityEngine;
2+using UnityEditor;
3+using System;
4+using System.Collections;
5+using jp.nyatla.nyartoolkit.cs.markersystem;
6+using jp.nyatla.nyartoolkit.cs.core;
7+using NyARUnityUtils;
8+using System.IO;
9+
10+public class ARJpegBehaviour : MonoBehaviour
11+{
12+ private NyARUnityMarkerSystem _ms;
13+ private NyARUnitySensor _ss;
14+ private int mid;//marker id
15+ private GameObject _bg_panel;
16+
17+ void Awake()
18+ {
19+ //setup texture
20+ Texture2D tex= (Texture2D)Resources.Load("320x240ABGR", typeof(Texture2D));
21+ this._ss=new NyARUnitySensor(tex.width,tex.height);
22+ this._ss.update(tex);
23+
24+ NyARMarkerSystemConfig config = new NyARMarkerSystemConfig(tex.width,tex.height);
25+ this._ms=new NyARUnityMarkerSystem(config);
26+ this._ms.setConfidenceThreshold(0.1);
27+ mid=this._ms.addARMarker("./Assets/Data/patt.hiro",16,25,80);
28+
29+ //setup background
30+ this._bg_panel=GameObject.Find("Plane");
31+ this._bg_panel.renderer.material.mainTexture=tex;
32+ this._ms.setARBackgroundTransform(this._bg_panel.transform);
33+
34+ //setup camera projection
35+ this._ms.setARCameraProjection(this.camera);
36+ }
37+ // Use this for initialization
38+ void Start ()
39+ {
40+ }
41+ // Update is called once per frame
42+ void Update ()
43+ {
44+ //Update marker system by ss
45+ this._ms.update(this._ss);
46+ //update Gameobject transform
47+ if(this._ms.isExistMarker(mid)){
48+ Debug.Log(c+":"+this._ms.getConfidence(mid));
49+ this._ms.setMarkerTransform(mid,GameObject.Find("MarkerObject").transform);
50+ Debug.Log(this._ms.getConfidence(mid));
51+ }else{
52+ // hide Game object
53+ GameObject.Find("MarkerObject").transform.localPosition=new Vector3(0,0,-100);
54+ }
55+ }
56+ int c=0;
57+}
58+
\ No newline at end of file
--- NyARToolkitUnity/trunk/Assets/sample/SimpleLite/ARCameraBehaviour.cs (revision 1050)
+++ NyARToolkitUnity/trunk/Assets/sample/SimpleLite/ARCameraBehaviour.cs (revision 1051)
@@ -1,74 +1,75 @@
1-using UnityEngine;
2-using System;
3-using System.Collections;
4-using jp.nyatla.nyartoolkit.cs.markersystem;
5-using jp.nyatla.nyartoolkit.cs.core;
6-using NyARUnityUtils;
7-using System.IO;
8-
9-/// <summary>
10-/// AR camera behaviour.
11-/// This sample shows simpleLite demo.
12-/// 1.Connect webcam to your computer.
13-/// 2.Start sample program
14-/// 3.Take a "HIRO" marker on capture image
15-///
16-/// </summary>
17-public class ARCameraBehaviour : MonoBehaviour
18-{
19- private NyARUnityMarkerSystem _ms;
20- private NyARUnityWebCam _ss;
21- private int mid;//marker id
22- private GameObject _bg_panel;
23- void Awake()
24- {
25- //setup unity webcam
26- WebCamDevice[] devices= WebCamTexture.devices;
27- WebCamTexture w;
28- if (devices.Length > 0){
29- w=new WebCamTexture(320, 240, 15);
30- this._ss=new NyARUnityWebCam(w);
31- NyARMarkerSystemConfig config = new NyARMarkerSystemConfig(w.requestedWidth,w.requestedHeight);
32- this._ms=new NyARUnityMarkerSystem(config);
33- //mid=this._ms.addARMarker("./Assets/Data/patt.hiro",16,25,80);
34- //This line loads a marker from texture
35- mid=this._ms.addARMarker((Texture2D)(Resources.Load("MarkerHiro", typeof(Texture2D))),16,25,80);
36-
37- //setup background
38- this._bg_panel=GameObject.Find("Plane");
39- this._bg_panel.renderer.material.mainTexture=w;
40- this._ms.setARBackgroundTransform(this._bg_panel.transform);
41-
42- //setup camera projection
43- this._ms.setARCameraProjection(this.camera);
44-
45- }else{
46- Debug.LogError("No Webcam.");
47- }
48- }
49- // Use this for initialization
50- void Start ()
51- {
52- //start sensor
53- this._ss.start();
54- }
55- // Update is called once per frame
56- void Update ()
57- {
58- //Update SensourSystem
59- this._ss.update();
60- //Update marker system by ss
61- this._ms.update(this._ss);
62- //update Gameobject transform
63- if(this._ms.isExistMarker(mid)){
64- this._ms.setMarkerTransform(mid,GameObject.Find("MarkerObject").transform);
65- Debug.Log(c+":"+this._ms.getConfidence(mid));
66- }else{
67- Debug.Log(c+":not found");
68- // hide Game object
69- GameObject.Find("MarkerObject").transform.localPosition=new Vector3(0,0,-100);
70- }
71- c++;
72- }
73- static int c=0;
74-}
1+using UnityEngine;
2+using System;
3+using System.Collections;
4+using jp.nyatla.nyartoolkit.cs.markersystem;
5+using jp.nyatla.nyartoolkit.cs.core;
6+using NyARUnityUtils;
7+using System.IO;
8+
9+/// <summary>
10+/// AR camera behaviour.
11+/// This sample shows simpleLite demo.
12+/// 1.Connect webcam to your computer.
13+/// 2.Start sample program
14+/// 3.Take a "HIRO" marker on capture image
15+///
16+/// </summary>
17+public class ARCameraBehaviour : MonoBehaviour
18+{
19+ private NyARUnityMarkerSystem _ms;
20+ private NyARUnityWebCam _ss;
21+ private int mid;//marker id
22+ private GameObject _bg_panel;
23+ void Awake()
24+ {
25+ //setup unity webcam
26+ WebCamDevice[] devices= WebCamTexture.devices;
27+ WebCamTexture w;
28+ if (devices.Length > 0){
29+ w=new WebCamTexture(320, 240, 15);
30+ this._ss=new NyARUnityWebCam(w);
31+ NyARMarkerSystemConfig config = new NyARMarkerSystemConfig(w.requestedWidth,w.requestedHeight);
32+ this._ms=new NyARUnityMarkerSystem(config);
33+ //mid=this._ms.addARMarker("./Assets/Data/patt.hiro",16,25,80);
34+ //This line loads a marker from texture
35+ mid=this._ms.addARMarker((Texture2D)(Resources.Load("MarkerHiro", typeof(Texture2D))),16,25,80);
36+
37+ //setup background
38+ this._bg_panel=GameObject.Find("Plane");
39+ this._bg_panel.renderer.material.mainTexture=w;
40+ this._ms.setARBackgroundTransform(this._bg_panel.transform);
41+
42+ //setup camera projection
43+ this._ms.setARCameraProjection(this.camera);
44+
45+ }else{
46+ Debug.LogError("No Webcam.");
47+ }
48+ }
49+ // Use this for initialization
50+ void Start ()
51+ {
52+ //start sensor
53+ this._ss.start();
54+ }
55+ // Update is called once per frame
56+ void Update ()
57+ {
58+ //Update SensourSystem
59+ this._ss.update();
60+ //Update marker system by ss
61+ this._ms.update(this._ss);
62+ //update Gameobject transform
63+ if(this._ms.isExistMarker(mid)){
64+ this._ms.setMarkerTransform(mid,GameObject.Find("MarkerObject").transform);
65+ Debug.Log(c+":"+this._ms.getConfidence(mid));
66+ }else{
67+ Debug.Log(c+":not found");
68+ // hide Game object
69+ GameObject.Find("MarkerObject").transform.localPosition=new Vector3(0,0,-100);
70+ }
71+ c++;
72+ }
73+ static int c=0;
74+}
75+
\ No newline at end of file
--- NyARToolkitUnity/trunk/Assets/sample/ImagePickup/ImagePickup.cs (revision 1050)
+++ NyARToolkitUnity/trunk/Assets/sample/ImagePickup/ImagePickup.cs (revision 1051)
@@ -1,64 +1,65 @@
1-using UnityEngine;
2-using UnityEditor;
3-using System;
4-using System.Collections;
5-using jp.nyatla.nyartoolkit.cs.markersystem;
6-using jp.nyatla.nyartoolkit.cs.core;
7-using NyARUnityUtils;
8-using System.IO;
9-/// <summary>
10-/// このサンプルプログラムは、マーカ表面の画像をテクスチャとして取得します。
11-/// マーカファイルには、hiroマーカを使用してください。
12-/// </summary>
13-public class ImagePickup : MonoBehaviour
14-{
15- private NyARUnityMarkerSystem _ms;
16- private NyARUnityWebCam _ss;
17- private int mid;//marker id
18- private GameObject _bg_panel;
19- void Awake()
20- {
21- //setup unity webcam
22- WebCamDevice[] devices= WebCamTexture.devices;
23- WebCamTexture w;
24- if (devices.Length > 0){
25- w=new WebCamTexture(320, 240, 15);
26- this._ss=new NyARUnityWebCam(w);
27- NyARMarkerSystemConfig config = new NyARMarkerSystemConfig(w.requestedWidth,w.requestedHeight);
28- this._ms=new NyARUnityMarkerSystem(config);
29- mid=this._ms.addARMarker("./Assets/Data/patt.hiro",16,25,80);
30-
31- //setup background
32- this._bg_panel=GameObject.Find("Plane");
33- this._bg_panel.renderer.material.mainTexture=w;
34- this._ms.setARBackgroundTransform(this._bg_panel.transform);
35-
36- //setup camera projection
37- this._ms.setARCameraProjection(this.camera);
38- GameObject.Find("Cube").renderer.material.mainTexture=new Texture2D(64,64);
39- }else{
40- Debug.LogError("No Webcam.");
41- }
42- }
43- // Use this for initialization
44- void Start ()
45- {
46- this._ss.start();
47- }
48- // Update is called once per frame
49- void Update ()
50- {
51- //Update marker system by ss
52- this._ss.update();
53- this._ms.update(this._ss);
54- //update Gameobject transform
55- if(this._ms.isExistMarker(mid)){
56- this._ms.setMarkerTransform(mid,GameObject.Find("MarkerObject").transform);
57- //update cube texture
58- this._ms.getMarkerPlaneImage(mid,this._ss,-40,-40,80,80,(Texture2D)(GameObject.Find("Cube").renderer.material.mainTexture));
59- }else{
60- // hide Game object
61- GameObject.Find("MarkerObject").transform.localPosition=new Vector3(0,0,-100);
62- }
63- }
64-}
1+using UnityEngine;
2+using UnityEditor;
3+using System;
4+using System.Collections;
5+using jp.nyatla.nyartoolkit.cs.markersystem;
6+using jp.nyatla.nyartoolkit.cs.core;
7+using NyARUnityUtils;
8+using System.IO;
9+/// <summary>
10+/// S0n0オ0?ラ0?ラ0?ー0??o00゙0?ォ0h?溶0;uマP?ニ0ッ0ケ0チ0?h0W0f0ヨS誉W0~0Y00
11+/// ゙0?ォ0ユ0。0、0?k0o00hiro゙0?ォ0?O(uW0f0O0`0U0D00
12+/// </summary>
13+public class ImagePickup : MonoBehaviour
14+{
15+ private NyARUnityMarkerSystem _ms;
16+ private NyARUnityWebCam _ss;
17+ private int mid;//marker id
18+ private GameObject _bg_panel;
19+ void Awake()
20+ {
21+ //setup unity webcam
22+ WebCamDevice[] devices= WebCamTexture.devices;
23+ WebCamTexture w;
24+ if (devices.Length > 0){
25+ w=new WebCamTexture(320, 240, 15);
26+ this._ss=new NyARUnityWebCam(w);
27+ NyARMarkerSystemConfig config = new NyARMarkerSystemConfig(w.requestedWidth,w.requestedHeight);
28+ this._ms=new NyARUnityMarkerSystem(config);
29+ mid=this._ms.addARMarker("./Assets/Data/patt.hiro",16,25,80);
30+
31+ //setup background
32+ this._bg_panel=GameObject.Find("Plane");
33+ this._bg_panel.renderer.material.mainTexture=w;
34+ this._ms.setARBackgroundTransform(this._bg_panel.transform);
35+
36+ //setup camera projection
37+ this._ms.setARCameraProjection(this.camera);
38+ GameObject.Find("Cube").renderer.material.mainTexture=new Texture2D(64,64);
39+ }else{
40+ Debug.LogError("No Webcam.");
41+ }
42+ }
43+ // Use this for initialization
44+ void Start ()
45+ {
46+ this._ss.start();
47+ }
48+ // Update is called once per frame
49+ void Update ()
50+ {
51+ //Update marker system by ss
52+ this._ss.update();
53+ this._ms.update(this._ss);
54+ //update Gameobject transform
55+ if(this._ms.isExistMarker(mid)){
56+ this._ms.setMarkerTransform(mid,GameObject.Find("MarkerObject").transform);
57+ //update cube texture
58+ this._ms.getMarkerPlaneImage(mid,this._ss,-40,-40,80,80,(Texture2D)(GameObject.Find("Cube").renderer.material.mainTexture));
59+ }else{
60+ // hide Game object
61+ GameObject.Find("MarkerObject").transform.localPosition=new Vector3(0,0,-100);
62+ }
63+ }
64+}
65+
\ No newline at end of file
--- NyARToolkitUnity/trunk/Assets/NyARUnityUtils/NyARUnitySensor.cs (revision 1050)
+++ NyARToolkitUnity/trunk/Assets/NyARUnityUtils/NyARUnitySensor.cs (revision 1051)
@@ -1,41 +1,44 @@
1-using UnityEngine;
2-using System.Collections;
3-using NyARUnityUtils;
4-using jp.nyatla.nyartoolkit.cs.markersystem;
5-using jp.nyatla.nyartoolkit.cs.core;
6-
7-namespace NyARUnityUtils
8-{
9- public class NyARUnitySensor :NyARSensor
10- {
11- private NyARUnityRaster _raster;
12- public NyARUnitySensor(int i_width,int i_height): base(new NyARIntSize(i_width,i_height))
13- {
14- //RGBラスタの生成(Texture2Dは上下反転不要)
15- this._raster = new NyARUnityRaster(i_width,i_height,true);
16- //ラスタのセット
17- base.update(this._raster);
18- }
19- public void update(Texture2D i_input)
20- {
21- this._raster.updateByTexture2D(i_input);
22- }
23- public void dGetGsTex(Texture2D tx)
24- {
25- NyARIntSize sz=this._raster.getSize();
26- int[] s=(int[])this._gs_raster.getBuffer();
27- Debug.Log(s.Length);
28- Color32[] c=new Color32[sz.w*sz.h];
29- for(int i=0;i<sz.h;i++){
30- for(int i2=0;i2<sz.w;i2++){
31- c[i*sz.w+i2].r=c[i*sz.w+i2].g=c[i*sz.w+i2].b=(byte)s[i*sz.w+i2];
32- c[i*sz.w+i2].a=0xff;
33- }
34- }
35- tx.SetPixels32(c);
36- tx.Apply( false );
37- }
38- }
39-
40-}
41-
1+using UnityEngine;
2+using System.Collections;
3+using NyARUnityUtils;
4+using jp.nyatla.nyartoolkit.cs.markersystem;
5+using jp.nyatla.nyartoolkit.cs.core;
6+
7+namespace NyARUnityUtils
8+{
9+ public class NyARUnitySensor :NyARSensor
10+ {
11+ private NyARUnityRaster _raster;
12+ public NyARUnitySensor(int i_width,int i_height): base(new NyARIntSize(i_width,i_height))
13+ {
14+ //RGB000n0ub(Texture2Do0
15+N NヘS竡 +N♂)
16+ this._raster = new NyARUnityRaster(i_width,i_height,true);
17+ //000n0000
18+ base.update(this._raster);
19+ }
20+ public void update(Texture2D i_input)
21+ {
22+ this._raster.updateByTexture2D(i_input);
23+ }
24+ public void dGetGsTex(Texture2D tx)
25+ {
26+ NyARIntSize sz=this._raster.getSize();
27+ int[] s=(int[])this._gs_raster.getBuffer();
28+ Debug.Log(s.Length);
29+ Color32[] c=new Color32[sz.w*sz.h];
30+ for(int i=0;i<sz.h;i++){
31+ for(int i2=0;i2<sz.w;i2++){
32+ c[i*sz.w+i2].r=c[i*sz.w+i2].g=c[i*sz.w+i2].b=(byte)s[i*sz.w+i2];
33+ c[i*sz.w+i2].a=0xff;
34+ }
35+ }
36+ tx.SetPixels32(c);
37+ tx.Apply( false );
38+ }
39+ }
40+
41+}
42+
43+
\ No newline at end of file
--- NyARToolkitUnity/trunk/Assets/NyARUnityUtils/NyARUnityWebCam.cs (revision 1050)
+++ NyARToolkitUnity/trunk/Assets/NyARUnityUtils/NyARUnityWebCam.cs (revision 1051)
@@ -1,75 +1,77 @@
1-using UnityEngine;
2-using System.Collections;
3-using NyARUnityUtils;
4-using jp.nyatla.nyartoolkit.cs.markersystem;
5-using jp.nyatla.nyartoolkit.cs.core;
6-
7-namespace NyARUnityUtils
8-{
9- /// <summary>
10- /// This class provides WebCamTexture wrapper derived from NyARMarkerSystemSensor.
11- /// </summary>
12- /// <exception cref='NyARException'>
13- /// Is thrown when the ny AR exception.
14- /// </exception>
15- public class NyARUnityWebCam :NyARSensor
16- {
17- private WebCamTexture _wtx;
18- private NyARUnityRaster _raster;
19- public NyARUnityWebCam(WebCamTexture i_wtx): base(new NyARIntSize(i_wtx.requestedWidth,i_wtx.requestedHeight))
20- {
21- //RGBラスタの生成(Webtextureは上下反転必要)
22- this._raster = new NyARUnityRaster(i_wtx.requestedWidth,i_wtx.requestedHeight,true);
23- //ラスタのセット
24- base.update(this._raster);
25- this._wtx=i_wtx;
26- }
27- /**
28- * この関数は、JMFの非同期更新を停止します。
29- */
30- public void stop()
31- {
32- this._wtx.Stop();
33- }
34- /**
35- * この関数は、JMFの非同期更新を開始します。
36- */
37- public void start()
38- {
39- this._wtx.Play();
40- }
41- /**
42- * Call this function on update!
43- */
44- public void update()
45- {
46- if(!this._wtx.didUpdateThisFrame){
47- return;
48- }
49- //テクスチャがアップデートされていたら、ラスタを更新
50- this._raster.updateByWebCamTexture(this._wtx);
51- //センサのタイムスタンプを更新
52- base.updateTimeStamp();
53- return;
54- }
55- public override void update(INyARRgbRaster i_input)
56- {
57- throw new NyARException();
58- }
59- public void dGetGsTex(Texture2D tx)
60- {
61- int[] s=(int[])this._gs_raster.getBuffer();
62- Color32[] c=new Color32[320*240];
63- for(int i=0;i<240;i++){
64- for(int i2=0;i2<320;i2++){
65- c[i*320+i2].r=c[i*320+i2].g=c[i*320+i2].b=(byte)s[i*320+i2];
66- c[i*320+i2].a=0xff;
67- }
68- }
69- tx.SetPixels32(c);
70- tx.Apply( false );
71- }
72- }
73-
74-}
75-
1+using UnityEngine;
2+using System.Collections;
3+using NyARUnityUtils;
4+using jp.nyatla.nyartoolkit.cs.markersystem;
5+using jp.nyatla.nyartoolkit.cs.core;
6+
7+namespace NyARUnityUtils
8+{
9+ /// <summary>
10+ /// This class provides WebCamTexture wrapper derived from NyARMarkerSystemSensor.
11+ /// </summary>
12+ /// <exception cref='NyARException'>
13+ /// Is thrown when the ny AR exception.
14+ /// </exception>
15+ public class NyARUnityWebCam :NyARSensor
16+ {
17+ private WebCamTexture _wtx;
18+ private NyARUnityRaster _raster;
19+ public NyARUnityWebCam(WebCamTexture i_wtx): base(new NyARIntSize(i_wtx.requestedWidth,i_wtx.requestedHeight))
20+ {
21+ //RGB000n0ub(Webtextureo0
22+N NヘS竡ナ_♂)
23+ this._raster = new NyARUnityRaster(i_wtx.requestedWidth,i_wtx.requestedHeight,true);
24+ //000n0000
25+ base.update(this._raster);
26+ this._wtx=i_wtx;
27+ }
28+ /**
29+ * S0n0「頻eo00JMFn0^ Tg?ーe?\PbkW0~0Y00
30+ */
31+ public void stop()
32+ {
33+ this._wtx.Stop();
34+ }
35+ /**
36+ * S0n0「頻eo00JMFn0^ Tg?ーe?虚ヒYW0~0Y00
37+ */
38+ public void start()
39+ {
40+ this._wtx.Play();
41+ }
42+ /**
43+ * Call this function on update!
44+ */
45+ public void update()
46+ {
47+ if(!this._wtx.didUpdateThisFrame){
48+ return;
49+ }
50+ //ニ0ッ0ケ0チ0?L0「0テ0ラ0ヌ0?ネ0U0?f0D0_0?0?ケ0ソ0??ーe
51+ this._raster.updateByWebCamTexture(this._wtx);
52+ //サ0?オ0n0ソ0、0?ケ0ソ0?ラ0??ーe
53+ base.updateTimeStamp();
54+ return;
55+ }
56+ public override void update(INyARRgbRaster i_input)
57+ {
58+ throw new NyARException();
59+ }
60+ public void dGetGsTex(Texture2D tx)
61+ {
62+ int[] s=(int[])this._gs_raster.getBuffer();
63+ Color32[] c=new Color32[320*240];
64+ for(int i=0;i<240;i++){
65+ for(int i2=0;i2<320;i2++){
66+ c[i*320+i2].r=c[i*320+i2].g=c[i*320+i2].b=(byte)s[i*320+i2];
67+ c[i*320+i2].a=0xff;
68+ }
69+ }
70+ tx.SetPixels32(c);
71+ tx.Apply( false );
72+ }
73+ }
74+
75+}
76+
77+
\ No newline at end of file
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
旧リポジトリブラウザで表示