페이지

2016년 11월 20일 일요일

Swift tuples, optional value, optional binding, throws, catch, comparisoin, assert

//1. tuples

let httpResponse = ( 404, "File Not Found" )
let (statusCode, errorMsg) = httpResponse
let ( sCode, _ ) = httpResponse
let (code,msg) = (state:505, message:"hi")


//2. optional value

let num = "123"
let numInt = Int(num)
print(numInt)


//3. optional binding

if let a = Int("4"), let b = Int("43") , a < b && b < 100 {
    print("4<43<100 \(a),\(b)")
}
else {
    print("nil")
}

//4. throw error

func canThrowAnError() throws {
    //this function may or not throw an error  
}

do {
    try canThrowAnError()
} catch {    

}

//5. comparison

(1, "zebra") < (2, "apple")   // true because 1 is less than 2; "zebra" and "apple" are not compared
(3, "apple") < (3, "bird")    // true because 3 is equal to 3, and "apple" is less than "bird"
(4, "dog") == (4, "dog")      // true because 4 is equal to 4, and "dog" is equal to "dog”


//6. assert

let aa = -1
assert(aa > 0 ,"number should be larger than zero" )


2016년 7월 31일 일요일

Json array to Object array


JSON Array

string returnString;

returnString=
{
    "object": 
    {
        "name": "nm",
        "place": "plc",
        "description": "dscrptn",
    },
    {
        "name": "nm",
        "place": "plc",
        "description": "dscrptn",
    },
    {
        "name": "nm",
        "place": "plc",
        "description": "dscrptn",
    },
}



  1. [System.Serializable]
  2. public struct MyObject
  3. {
  4.    [System.Serializable]
  5.    public struct ArrayEntry
  6.    {
  7.       public string name;
  8.       public string place;
  9.       public string description;
  10.    }
  11.  
  12.    public ArrayEntry[] object;
  13. }


MyObject obj = JsonUtility.FromJson<MyObject>(returnString);
string strJson = JsonUtility.ToJson(obj);

2016년 3월 21일 월요일

Lightmapping

Unity Lightmapping



texture : image
shader : 화면에 어떻게 그려줄지를 정의한 코드
material : texture, shader 를 포함하는 것
Lightmapping : 빛을 담아내는
Lightmapping 이유: 실시간으로 삧의 경로를 계산하는 것이 부하를 없애기위해 빛에 비추어진 씬화면을 이미지화 해서 만들어줌.

라이트매핑을 하면 exr 파일 포맷이 생김. 채널당 32비트(rgba) 값을 갖는다.
모든 texture는 설치 플랫폼에 맞게 변환이 된다. 엔진내부에서 게임으로 나갈대 변환된다.
그런데 플랫폼에 따라 텍스추어에 비춰진 빛효과가 다르게 나타난다.
그래서 모든 플랫폼 출시시에 조정 필요함.

- Autodesk beast
Unity4 에서 사용한 라이트 매핑 플러그인
굉장히 빠르고 시간대비 괜찮은 수준의 결과를 보여준다.

예) Lightmapping extended (unity4.x 용 라이트맵 에셋스토어)

- Geometrics
실시간은 모바일에서 쓰기 힘들정도로 실시간GI가 힘듬.
Unity5 에서 사용하는 플러그인은 다른 것인데
아직 안정화 안되어 있음


ambient color : 그림자 톤, 색감
ambient occlusion(AO) : 간접광과 간섭광에 의한 음영을 위한 옵션. 이게 활성화 되면 무거워진다.
final gather (FG) : 깔끔하고 이쁘게 나옴.
photon mapping : 얼룩지는 현상 나옴.

Global Illumination : 오브젝트간의 반사, 굴절, 그림자와 같이 다른 오브젝트에 의해 반사되거나 투과, 굴절빛의 횩과를 연출한다.
Drawcall :material 을 mesh 에 옯겨서 그리는 것 화면에 그리는 횟수
같은 material을 사용하는 것을 한번에 그리는 것을 batching 이라고 한다.

batches, saved by batching:

512 2장보다는 1024 한장으로 사용하는 것이 좋다.

static batching
player setting -> static batching 을 모두 static 으로 적용


Directional light
cast shadow : 그림자를 그릴것인가에 대한 옵션
receive shadow : 그림자를 드리울것인가에 대한 옵션

Directional Light를 3개 사용할 경우,
주 광원 :0.8, 사이드 광원: 0.2 , 아래 광원: 0.1  정도의 intensity 값으로 조정한다.
눈으로 보면서 이쁜것을 채택하면 된다.

baked lightmap
Tilling x : 몇번 반복할 것인지
Offset x : 몇번째것을 쓸것인지

Bounce : 빛이 반사되는 횟수와 반사되는 감도



라이트 맵 예
1. 씬저장
2. 오브젝트 선택하고 inspector 우측 상단 "static" 에서 'Lightmap Static' 선택하기
3. Skybox 생성. procedual 머터리얼 생성 속성값 조정
4. Skybox를 씬에 적용
5. Precomputed realtime GI 끄기  ( 라이트맵 적용할 경우 실시간 불필요 )
6. Baked GUI : 한정에 꽉 채우는 것이 좋다
Baked Resolution : 라이트맵 텍스츄어가 한장을 넘어서면 Baked resolution 값을 조정하여 한장으로 나오게 하자.
Compressed : unchecked.

7. General GI
Directional Mode : Non directional
Default Parameter : default-lowResolution

Directional light 를 제외한 라이트들은 베이크된 이후에는 씬에서 삭제해준다.



Shader
(Matcamp shader)
모바일에서는 Diffuse Shader, Transparent Shader만 가지고도 충분한 효과를 볼수 있다.




2015년 10월 6일 화요일

Making wireless ap on Windows 10

netsh wlan set hostednetwork mode=allow ssid="techtuft.com" key="Pa$$w0rd"
netsh wlan start hostednetwork
netsh wlan show hostednetwork


https://www.youtube.com/watch?v=0XP7GpcownQ





Method 1: The issue seems to occur on computers that have Windows Firewall disabled. Windows Firewall service has to be running even if you’re using another antivirus/firewall program on your computer.

I recommend you to check for the status of the “Windows Firewallservice and set it to “Automatic”.
Follow these steps:
  1. Press Windows + R keys and type services.msc, and click OK.
  2. Locate Windows Firewall, right-click on it and click Properties.
  3. In the General tab, select Automatic under the Startup type.
  4. Click Start to start the service.
  5. Click Apply and OK.
  6. Restart the computer and check if the issue gets fixed.

If the issue still persists then, try the below,
Method 2: You may try to check all the services that run Internet Connection Sharing (ICS) and check.
  1. Press Windows + R keys and type services.msc, and click OK.
  2. To enable a service, find it in the right pane and double-click its entry.
  3. Be sure its Startup type is set to Automatic and click OK.

All the following services must be thus configured in order to use ICS:
  • Application Layer Gateway Service
  • Network Connections
  • Network Location Awareness (NLA)
  • Plug And Play
  • Remote Access Auto Connection Manager
  • Remote Access Connection Manager
  • Remote Procedure Call (RPC)
  • Telephony



After verifying and/or configuring Automatic startup for each of these services, close the Services window and restart the computer before attempting again to enable ICS.


http://answers.microsoft.com/en-us/windows/forum/windows_10-networking/wifi-hotspot-on-windows-10-with-error-an-error/b80e6222-bc1c-4d13-8619-ba3a4d4b3757?auth=1



But
in my case,
it didn't work

Error still occurred
" an error occurred while internet connection sharing was being enabled"


i think mac is better than windows. and windows should try to get better on UX.

2015년 9월 25일 금요일

OSX Yosemite 부팅 USB 만드는 법

OS X Yosemite 클린 설치를 위해서는 Yosemite로 부팅할 수 있는 USB가 필요하다. 부팅 USB를 만드는 여러 방법이 있는 것 같은데, 아래 방법이 제일 깔끔하고 간단한 것 같다. 

1. App Store 를 통해 OS X Yosemite를 다운로드한다. 
2. 8GB 이상 USB를 준비한 뒤, Disk Utility 프로그램을 이용하여 이 USB를 포맷한다 - Mac OS Extended (Journaled)로
3. 터미널에서 다음 명령을 실행한다. (아래 명령에서 붉은색의 Untitled는 USB의 볼륨 이름이다. 보통 위 포맷 과정을 거치고 나면 볼륨 이름이 Untitled가 된다.)

sudo /Applications/Install\ OS\ X\ Yosemite.app/Contents/Resources/createinstallmedia --volume /Volumes/Untitled--applicationpath /Applications/Install\ OS\ X\ Yosemite.app --nointeraction

4. 암호를 입력한 뒤 기다리면 된다. 
5. 이후  [Option] 키를 누른 채 재부팅한 뒤 USB를 선택해서 클린설치를 하면 된다.