3D그래픽2011. 8. 31. 18:22
Khronos Group Logo


static mesh는 <library_visual_scenes>에 정의된 <node>들을 이용하여 렌더링을 하게 된다.


 static mesh를 구분하는 방법<library_visual_scenes>의 child node인 <node> element의 type attribute가 JOINT가 아닌지 확인이 필요(<node> element의 type attribute의 기본값은 NODE이며, 없어도 되는 optional attribute)하고, <node>의 child element에 <instance_geometry> element가 존재해야 한다.


 <library_geometries>는 <library_visual_scenes>에서 참조하는 모든 Vertices, Normals, Texcoords(Texture Coordinates) 그리고 이들을 참조하여 삼각형들을 구성할 수 있는 indices를 포함하고 있다.


 (2011.08.26) <node> element에는 child element로 <matrix>를 가지고 있고, 이것은 해당 node의 World Matrix를 나타낸다.

<node name="Teapot001" id="Teapot001" sid="Teapot001">

<matrix sid="matrix">

1.000000 0.000000 0.000000 0.000000

0.000000 -0.000000 1.000000 -7.700000

0.000000 -1.000000 -0.000000 -0.000000

0.000000 0.000000 0.000000 1.000000

</matrix>

</node>


OpenGL에서는 보이는 형식 그대로 float array를 만들면 되고, DirectX에서는 전치(transpose)를 해야 한다고 한다. 그런데 이것도 항상 그런것은 아닌듯. Platform에 따라 다른것 같다. Android에서는 OpenGL을 사용함에도 불구하고 Matrix class의multiplyMM을 이용하려면 전치(transpose)를 해야 한다! 혹시 Android 개발자들 중에 DirectX에 익숙한 사람이 있었던 것일까? :(

(2011.10.06 추가) 의문이 풀렸다. COLLADA Spec.에서 아래와 같은 문장을 발견. 모든것엔 이유가 있다.

It is written in row-major order in the COLLADA document for human readability.




 (2011.08.31) Collada의 Spec.이 그런건지, modeling tool들이 그런건지 아직 확실하지 않지만, Android의 텍스쳐의 좌표계가 다른 것 같다. 즉, 뒤집어져 출력 된다. 어떻게 해결해야 할지는 다시 고민해 봐야겠다.

찾아보니 보통 DirectX의 텍스쳐 좌표계를 OpenGL(또는 Android) 텍스쳐 좌표계로 변환할 때, 다음과 같이 한다고 한다.

glMatrixMode(GL10.GL_TEXTURE);

glPushMatrix();

glLoadIdentity();

glScalef(1.0f, -1.0f, 1.0f);


이것은 (s, t) 좌표 중 t를 반대로 뒤집어 주는 것. 즉, 상하 반전을 시켜주는 효과!
그래서 실제 데이터를 추출하는 과정에서 t 값에 -1을 곱해 주었더니 제대로 나온다.
그런데, 문제는 model data 마다 다를 수 도 있을것 같다는 사실...

어떻게 알아낼 수 있을까?

3DS Max에서 출력해 주는 데이터는 제대로 되어 있을까?

Collada Spec.에서 (s, t) 좌표계의 종류를 나타내는 property는 못 본것 같은데...


 (2011.08.31) Triangle Mesh라는 개념이 궁금하다.
Bullet Physics Simulation User Manual 에 보면, Triangle Mesh는 vertices data와 indices로 구성된다고 하는데...
Triangle Mesh는 이래야 한다는 어떤 정의나 관습 같은게 있는걸까? 언젠가는 알 수 있겠지: )


 (2011.08.31) Tangent and Bi-Tangent for each vertex? 이건 뭐하는데 사용되는 걸까?
[2011.09.30] 이건 bump mapping으로 lighting을 표현할 때 필요한 요소! 좀더 사실적인 깊이 표현을 위해 texture와 그 texture에 맞는 적절한 normal map(이 또한 texture)을 이용하여 fragment shader에서 빛을 계산하게 된다.


 (2011.08.31) 이런 고민도 된다. 결과적으로 성능 이슈때문에 NDK로 다시 개발해야 하지 않을까 라는... 과연? : (
[2011.09.30] NDK로 다시 개발하기 보다는 필요한 data format을 binary로 정의하고, 이 format에 맞도록 offline으로 데이터를 추출하여 저장하는 방식으로 하면 될 것 같다.


 (2011.09.30) COLLADA의 <light> element spec.을 보면, <color> element  하나만 정의되어 있는데, 보통은 light도 ambient / diffuse / specular term을 모두 가지고 있다. 왜 이러한 mismatch가 발생하는지 궁금했었다.
[2011.09.30] 처음에는 <color> element가 하나만 있으므로, 당연히 diffuse term을 계산할 때 사용해야 한다고 생각했으나, spec.에서 <phong> element 부분을 보다가, 다음과 같은 식을 발견하면서 (내 마음대로) 한 가지 사실을 알게 되었다.

<color>=<emission>+<ambient>*al+<diffuse>*max(N•L,0)+<specular>*max(R•I,0)shineness

where:
• al – A constant amount of ambient light contribution coming from the scene. In the COMMON profile,
this is the sum of all the <light><technique_common><ambient><color> values in the <visual_scene>.

• N – Normal vector
• L – Light vector
• I – Eye vector
• R – Perfect reflection vector (reflect (L around N))


즉, al은 <light> element의 <color> 값을 의미하며, 이것은 ambient term을 계산할 때 사용한다는 것이다.
여기서 한가지 헷갈리는 점은, spec.에 명시적으로 ambient light의 <color>로 되어 있다는 것! ambient light 이기때문에 ambient term에 적용한다는 것인지, 예를 들어 설명한 것인지 모르겠다. directional / point / spot light 모두 <color> element는 하나만 있기 때문에 동일한 것이 아닌가란 생각이 들었다.

그런데 또 다른 의문점은, 그렇다면 백색광원이 아닌 유색광원의 경우, diffuse term에 적용해야 할 텐데 이런경우에 대한 COLLADA sample을 보지 못해서, 어떻게 표현해야 할지 난감. 우선은 이대로 진행한다 -_-;


 (2011.10.03) Light Spec.에서의 특이점(또는 암시적 가정-_-;)
* <ambient> - It defines a single <color>  element that contains the RGB color value for the light. The ambient color value can be targeted for animation as discussed in Chapter 6, “COLLADA Animations,” page 121. The ambient light is not affected by such spatial transformations since it radiates omnidirectionally from everywhere in the scene equally.

* <directional> - Its type implicitly means that it has a direction vector that shines the light down its local negative Z-axis. This direction can be reoriented by rotating the light when it is placed in the scene.

* <point> - The location of the point light is established when it is placed in the scene. For example, here we place a point light at the local coordinates X=50, Y=30, and Z=20 using a <translate> element.

* <spot> - The <spot>  element has an implied direction facing down the negative Z-axis, just like the <directional> element. The actual orientation is established when the light is placed in the scene, as with the other light types. The value of <falloff_angle> can range from 0 to 90 degrees, or it can have the special value of 180 degrees for a uniform distribution. The value of <falloff_exponent> can range from 0 to 128. Higher exponent values focus the beam.

즉, 기본적으로 방향이 있는 모든 조명은 -Z 축을 향하고 있다... 는 얘기!


 (2011.10.05) 각각의 <node>는 각각의 local coordinate system을 정의한다. 그러므로 <node>에서 변환에 의해 정해지는 local coordinate system은 view transformation에 의해 world coordinate system으로 옮겨줘야 하는 것 같다. (...?)


 (2011.10.04) 관련 링크

 (2011.10.06) COLLADA에서 읽어 들이는 data는 실제로는 Joint. Bone은 두 개의 Joint를 연결하는 가상의 선이라고 생각 하면 된다.


 (2011.10.09) Skeletal Animation 정보 <library_controllers> -> <controller> -> <skin>
(1) Save <bind_shape_matrix> element를 읽어 저장한다
(2) <vertex_weights> element를 읽는다
 - 이 개수는 geometry mesh의 vertices의 개수와 동일하다
 - <vcount> element의 value의 개수는 <vertex_weights> element의 "count" attribute의 값과 동일하므로 참고
 - <vcount> element의 각각의 값은, 탐색중인 특정 vertex에 영향을 미치는 Joint의 개수를 의미


'3D그래픽' 카테고리의 다른 글

Transforms (변환 행렬)  (0) 2011.09.06
Goraud shading vs. Phong shading  (0) 2011.09.02
Normal Transform(법선벡터 변환)  (0) 2011.09.02
OpenGL ES 2.0 Q&A by myself  (5) 2011.07.12
OpenGL ES 2.0 on Android 2.2  (0) 2011.06.29
Posted by 세월의돌