PIXNET Logo登入

彥霖 實驗筆記

跳到主文

個人筆記...

部落格全站分類:數位生活

  • 相簿
  • 部落格
  • 留言
  • 名片
  • 3月 07 週六 201523:34
  • 顯示被佔住的 Port

命令提示字元輸入:
netstat -ao
這時會顯示 IP & PID ,知道 PID 就可以用工作管理員關閉
----------------------------
Linux :
(繼續閱讀...)
文章標籤

黃彥霖 發表在 痞客邦 留言(0) 人氣(295)

  • 個人分類:[作業系統] Windows
▲top
  • 3月 07 週六 201522:26
  • Java 編譯 Java


import java.io.BufferedReader;
import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
(繼續閱讀...)
文章標籤

黃彥霖 發表在 痞客邦 留言(0) 人氣(107)

  • 個人分類:[程式語言] Java
▲top
  • 3月 04 週三 201519:38
  • Unity 匯入 obj 檔


using UnityEngine; 
using System.Collections; 
public class Test : MonoBehaviour { 
    void Start () { 
        string objPath = "file:///Users/Loli/Desktop/untitled.obj";
        string imgPath = "file:///Users/Loli/Desktop/untitled.png";
        ObjReaderInSence obj = new ObjReaderInSence();
        StartCoroutine(obj.SomeFunction(objPath, imgPath));
    }  
}
//-------------------------------------------------------
using UnityEngine; 
using System.Collections;
using System.IO;
using System.Collections.Generic;
using System.Globalization;
public class ObjReaderInSence : MonoBehaviour { 
    Mesh _myMesh;
    Material _myMaterial = new Material(Shader.Find("Diffuse"));
    Vector3[] _vertexArray; 
    ArrayList _vertexArrayList = new ArrayList(); 
    Vector3[] _normalArray; 
    ArrayList _normalArrayList = new ArrayList(); 
    Vector2[] _uvArray; 
    ArrayList _uvArrayList = new ArrayList();  
    int[] _triangleArray;  
    ArrayList _facesVertNormUV = new ArrayList();  
    internal class PlacesByIndex { 
        public PlacesByIndex(int index) {
            _index = index; 
        } 
        public int _index; 
        public ArrayList _places = new ArrayList(); 
    } 
    public IEnumerator SomeFunction(string objPath,string imgPath) {
        GameObject obj_gameobject = new GameObject();
        obj_gameobject.name = objPath;
        if (_myMesh != null) {
            _myMesh.Clear(); 
        }            
        _myMesh = new Mesh(); 
        _myMesh.name = objPath; 
        WWW www3d = new WWW(objPath); 
        yield return www3d; 
        string s = www3d.text;
        s = s.Replace(" ", " "); 
        s = s.Replace(" ", " "); 
        LoadFile(s); 
        _myMesh.vertices = _vertexArray; 
        _myMesh.triangles = _triangleArray; 
        if (_uvArrayList.Count > 0){
            _myMesh.uv = _uvArray; 
        }            
        if (_normalArrayList.Count > 0){
            _myMesh.normals = _normalArray; 
        }else {
            _myMesh.RecalculateNormals();
        }
        _myMesh.RecalculateBounds(); 
        if ((MeshFilter)obj_gameobject.GetComponent ("MeshFilter") == null) {
            obj_gameobject.AddComponent("MeshFilter"); 
        }            
        MeshFilter temp; 
        temp = (MeshFilter)obj_gameobject.GetComponent("MeshFilter"); 
        temp.mesh = _myMesh;
        if ((MeshRenderer)obj_gameobject.GetComponent("MeshRenderer") == null) 
            obj_gameobject.AddComponent("MeshRenderer"); 
        if (_uvArrayList.Count > 0 && imgPath != "") {
            WWW wwwtx = new WWW(imgPath); 
            yield return wwwtx; 
            _myMaterial.mainTexture = wwwtx.texture; 
        } 
        MeshRenderer temp2; 
        temp2 = (MeshRenderer)obj_gameobject.GetComponent("MeshRenderer"); 
        if (_uvArrayList.Count > 0 && imgPath != "") { 
            temp2.material = _myMaterial; 
            _myMaterial.shader = Shader.Find("Diffuse");
        }
    }  
    public void LoadFile(string s) { 
        string[] lines = s.Split("\n"[0]); 
        foreach (string item in lines) { 
            ReadLine(item);
        } 
        ArrayList tempArrayList = new ArrayList();
        for (int i = 0; i < _facesVertNormUV.Count; ++i) { 
            if (_facesVertNormUV[i] != null) { 
                PlacesByIndex indextemp = new PlacesByIndex(i); 
                indextemp._places.Add(i); 
                for (int j = 0; j < _facesVertNormUV.Count; ++j) {
                    if (_facesVertNormUV[j] != null) { 
                        if (i != j) {
                            Vector3 iTemp = (Vector3)_facesVertNormUV[i];
                            Vector3 jTemp = (Vector3)_facesVertNormUV[j]; 
                            if (iTemp.x == jTemp.x && iTemp.y == jTemp.y) { 
                                indextemp._places.Add(j); 
                                _facesVertNormUV[j] = null;
                            } 
                        }
                    } 
                } 
                tempArrayList.Add(indextemp);
            } 
        } 
        _vertexArray = new Vector3[tempArrayList.Count]; 
        _uvArray = new Vector2[tempArrayList.Count]; 
        _normalArray = new Vector3[tempArrayList.Count];
        _triangleArray = new int[_facesVertNormUV.Count]; 
        int teller = 0; 
        foreach (PlacesByIndex item in tempArrayList) { 
            foreach (int item2 in item._places) {
                _triangleArray[item2] = teller; 
            } 
            Vector3 vTemp = (Vector3)_facesVertNormUV[item._index];
            _vertexArray[teller] = (Vector3)_vertexArrayList[(int)vTemp.x - 1];
            if (_uvArrayList.Count > 0) { 
                Vector3 tVec = (Vector3)_uvArrayList[(int)vTemp.y - 1]; 
                _uvArray[teller] = new Vector2(tVec.x, tVec.y);
            }
            if (_normalArrayList.Count > 0) { 
                _normalArray[teller] = (Vector3)_normalArrayList[(int)vTemp.z - 1]; 
            } 
            teller++; 
        } 
    } 
    public void ReadLine(string s) {
        char[] charsToTrim = {' ', '\n', '\t', '\r'}; 
        s= s.TrimEnd(charsToTrim); 
        string[] words = s.Split(" "[0]);
        foreach (string item in words){
            item.Trim();
        }
        if (words[0] == "v"){
            _vertexArrayList.Add(new Vector3(-System.Convert.ToSingle(words[1], CultureInfo.InvariantCulture), System.Convert.ToSingle(words[2], CultureInfo.InvariantCulture), System.Convert.ToSingle(words[3], CultureInfo.InvariantCulture))); 
        }else if (words [0] == "vn") {
            _normalArrayList.Add(new Vector3(System.Convert.ToSingle(words[1], CultureInfo.InvariantCulture), System.Convert.ToSingle(words[2], CultureInfo.InvariantCulture), System.Convert.ToSingle(words[3], CultureInfo.InvariantCulture))); 
        }else if (words [0] == "vt") {
            _uvArrayList.Add(new Vector3(System.Convert.ToSingle(words[1], CultureInfo.InvariantCulture), System.Convert.ToSingle(words[2], CultureInfo.InvariantCulture))); 
        }else if (words[0] == "f") { 
            ArrayList temp = new ArrayList();
            ArrayList triangleList = new ArrayList(); 
            for (int j = 1; j < words.Length; ++j) {
                Vector3 indexVector = new Vector3(0,0); 
                string[] indices = words[j].Split("/"[0]); 
                indexVector.x = System.Convert.ToInt32(indices[0], CultureInfo.InvariantCulture); 
                if (indices.Length > 1) { 
                    if (indices[1] != "") {
                        indexVector.y = System.Convert.ToInt32(indices[1], CultureInfo.InvariantCulture); 
                    }
                }
                if (indices.Length > 2) { 
                    if (indices[2] != ""){
                        indexVector.z = System.Convert.ToInt32(indices[2], CultureInfo.InvariantCulture); 
                    }
                } 
                temp.Add(indexVector);
            }
            for (int i = 1; i < temp.Count - 1; ++i) {
                triangleList.Add(temp[0]);
                triangleList.Add(temp[i+1]);
                triangleList.Add(temp[i]); 
            }  
            foreach (Vector3 item in triangleList) { 
                _facesVertNormUV.Add(item);
            }
        } 
    } 
}

(繼續閱讀...)
文章標籤

黃彥霖 發表在 痞客邦 留言(0) 人氣(1,064)

  • 個人分類:[遊戲設計] Unity
▲top
  • 2月 13 週五 201522:17
  • Servlet 合併 文字 & 圖片 並顯示

GetCheckImage
執行結果:
程式碼:
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
(繼續閱讀...)
文章標籤

黃彥霖 發表在 痞客邦 留言(0) 人氣(684)

  • 個人分類:[網頁] JSP / Servlet
▲top
  • 2月 09 週一 201513:00
  • Unity 入門教學:[使用 iOS Etcetera Plugin 插件] 選擇本地圖片

IMG_0026
Android 版本可以參考這篇: http://lolikitty.pixnet.net/blog/post/187372167
1. 打開後為一片空白,我們點選左上角的按鈕
2. 這時他會跳出選擇本地圖片還是照相機,這時我們選擇本地圖片
3. 選擇一張你喜歡的圖片
 
4. 選好後 Unity Texture 就會換成你選好的圖片
 
把以下程式碼套用到 Quad 或 Plane 或 Cube ...等等 之類的 3D 物件上
(繼續閱讀...)
文章標籤

黃彥霖 發表在 痞客邦 留言(0) 人氣(862)

  • 個人分類:[遊戲設計] Unity
▲top
  • 1月 31 週六 201523:53
  • 檔案格式:*.obj

 



索引
參數
說明


#
 
 註解


v
 
 頂點 (vertex)


vt
 
 貼圖座標


vn
 
 法線


f
 頂點索引/UV點索引/法線索引
 面


s
 
 光滑組


usemtl
 
 使用的材質


g
 
 群組


 
 
 


(繼續閱讀...)
文章標籤

黃彥霖 發表在 痞客邦 留言(0) 人氣(377)

  • 個人分類:[檔案格式] 3D 檔案
▲top
  • 1月 30 週五 201522:58
  • Unity 入門教學:用 C# 建立物件,並動態調整 UV

Unity - B.unity - New Unity Project 27 - PC, Mac & Linux Standalone DX11

1. 我們先建立一個空物件,把以下腳本拖入。 
2. 我們建立一個 含貼圖 的 Material,把該材質拖入該腳本的 public Material myMaterial; 中
3. 執行遊戲,並拖動該腳本的 public float uvValue = 0.9f; 即可看見變化
using UnityEngine;
using UnityEditor;
using System.Collections;
(繼續閱讀...)
文章標籤

黃彥霖 發表在 痞客邦 留言(1) 人氣(4,058)

  • 個人分類:[遊戲設計] Unity
▲top
  • 1月 29 週四 201521:05
  • Unity 入門教學:用觸控縮放+ 移動 攝影機 (iOS/Android)

// 未來會更新此程式碼
using UnityEngine;
using System.Collections;
public class MyCamera : MonoBehaviour {
(繼續閱讀...)
文章標籤

黃彥霖 發表在 痞客邦 留言(0) 人氣(2,446)

  • 個人分類:[遊戲設計] Unity
▲top
  • 1月 29 週四 201514:11
  • Unity 入門教學:用觸控縮放攝影機 (iOS/Android)

// 該程式請套用在 Main Camera 上
using UnityEngine;
using System.Collections;
public class MyCamera : MonoBehaviour {
(繼續閱讀...)
文章標籤

黃彥霖 發表在 痞客邦 留言(0) 人氣(993)

  • 個人分類:[遊戲設計] Unity
▲top
  • 1月 29 週四 201500:32
  • Unity 影像處理:飽和度 ( 使用 YUV )

Unity - A.unity - New Unity Project 14 - PC, Mac & Linux Standalone DX11
 
using UnityEngine;
using System.Collections;
public class Test : MonoBehaviour {
    public Texture2D t;
(繼續閱讀...)
文章標籤

黃彥霖 發表在 痞客邦 留言(0) 人氣(425)

  • 個人分類:[遊戲設計] Unity
▲top
«1...12131446»

實驗人員

黃彥霖
暱稱:
黃彥霖
分類:
數位生活
好友:
累積中
地區:

文章分類

  • [遊戲設計] Unity (100)
  • [程式語言] Java (91)
  • [程式語言] Go (31)
  • [程式語言] C # (15)
  • [程式語言] Python 3 (11)
  • [程式語言] Erlang (2)
  • [程式語言] Python 2 (2)
  • [程式語言] C++ (10)
  • [程式語言] C (8)
  • [程式語言] Node.js (5)
  • [程式語言] JavaScript (8)
  • [程式語言] Java-Android (2)
  • [資料庫] PostgreSQL (28)
  • [資料庫] Hadoop (2)
  • [作業系統] Linux (23)
  • [作業系統] Windows (3)
  • [作業系統] FreeRTOS (1)
  • [單晶片] Arduino (19)
  • [單晶片] ARM-STM32-F4 (15)
  • [單晶片] ARM-STM32-F1 (13)
  • [單晶片] ARM-LPC1114 (1)
  • [單晶片] PIC33FJ128MC804 (4)
  • [硬體設計] 常用IC (1)
  • [硬體設計] 3D 印表機 (3)
  • [硬體設計] 其他 (4)
  • [數學+程式語言] Matlab (4)
  • [數學] 應用數學 (2)
  • [論壇架設] Discuz! (1)
  • [科技新聞] 機器人 (3)
  • [轉碼工具] FFMPEG (1)
  • [檔案格式] 3D 檔案 (1)
  • [程式語言] 程式設計經驗談 (2)
  • [伺服器] GlassFish 筆記 (1)
  • [網頁] HTML 教學 (5)
  • [網頁] CSS 語法 (1)
  • [網頁] JSP / Servlet (7)
  • [網路監控] SmartSniff (1)
  • [虛擬機器] VirtualBox (1)
  • [電腦安全] 開發者 (1)
  • [美術設計] 繪畫 (0)
  • [3D設計] Blender 教學 (2)
  • [3D設計] Blender 外掛設計 (1)
  • [2D設計] GIMP Python (2)
  • [3D設計] Shroud Studio (3)
  • [展示] 作品、比賽、專題 (4)
  • [人類語言] 希伯來語 (1)
  • [金融] 外匯 (1)
  • 未分類文章 (1)

FB 粉絲頁

最新留言

  • [24/05/04] 訪客 於文章「Arduino 入門教學:讀取 ADXL...」留言:
    我想問一下關於ADXL345的問題,我在ARDUINO上測量...
  • [23/01/14] 訪客 於文章「Arduino 入門教學:Timer 使...」留言:
    如果我的callfunction是需要帶參數的 那t.ev...
  • [21/10/21] 陳霖 於文章「Arduino 入門教學:讀取 LSM3...」留言:
    不好意思不知道您還看不看的到,想請問您,你抓出的加速度器資料...
  • [21/07/23] wjb5741 於文章「Arduino 入門教學:讀取 ADXL...」發表了一則私密留言
  • [21/07/23] wjb5741 於文章「Arduino 入門教學:讀取 ADXL...」發表了一則私密留言
  • [20/10/27] 蔡金龍 於文章「STM32F1 入門教學:UART 接收...」發表了一則私密留言
  • [20/09/17] 秋本 嵐 於文章「Unity 入門教學:使用攝影機...」留言:
    您好,我最近在做Unity與Webcam相關的東西。 我想...
  • [20/08/09] 訪客 於文章「STM32F4 入門教學:SysTick...」留言:
    謝謝分享 ~ : )...
  • [20/07/24] 楊昇逸 於文章「C++ ( Qt 5 ) 入門範例:各種...」發表了一則私密留言
  • [20/03/04] 訪客 於文章「Java Json 教學:使用 org....」留言:
    <script>alert('hello');</scrip...

參觀人氣

  • 本日人氣:
  • 累積人氣: