2012-06-09 2 views
2

내가 읽은 적이있다 Java에서 게임 개발 David Brackeen. 나는 지금까지이 책의 모든 것을 이해했다. Wavefront Object 파일에서 v 명령이 수행하는 내용을 이해하지만 f 명령을 이해할 수 없습니다. 예를 들어 :WaveFront .obj 파일 - "f"명령의 기능은 무엇입니까?

# OBJ - Wavefront object file 
# The javagamebook loader only understands these commands: 
# mtllib <filename> - Load materials from an external .mtl 
#       file. 
# v <x> <y> <z>  - Define a vertex with floating-point 
#       coords (x,y,z). 
# f <v1> <v2> <v3> ... - Define a new face. a face is a flat, 
#       convex polygon with vertices in 
#       counter-clockwise order. Positive 
#       numbers indicate the index of the 
#       vertex that is defined in the file. 
#       Negative numbers indicate the vertex 
#       defined relative to last vertex read. 
#       For example, 1 indicates the first 
#       vertex in the file, -1 means the last 
#       vertex read, and -2 is the vertex 
#       before that. 
# g <name>    - Define a new group by name. The faces 
#       following are added to this group. 
# usemtl <name>  - Use the named material (loaded from a 
#       .mtl file) for the faces in this group. 

# load materials 
mtllib textures.mtl 

# define vertices 
v 16 32 16 
v 16 32 -16 
v 16 0 16 
v 16 0 -16 
v -16 32 16 
v -16 32 -16 
v -16 0 16 
v -16 0 -16 

g myCube 
usemtl wall1 
f 1 3 4 2 
f 6 8 7 5 
f 2 6 5 1 
f 3 7 8 4 
f 1 5 7 3 
f 4 8 6 2 

f 명령은 여기에 무엇입니까?

답변

4

f은 모델의면 (예 : 삼각형 또는 쿼드)을 나타냅니다. 숫자는 얼굴을 형성하기 위해 합치는 방법을 나타내는 꼭지점 목록의 인덱스입니다.

게시 된 obj 파일에서 첫 번째 f은 정점 # 1, # 3, # 4 및 # 2가있는 쿼드 (4 개의 정점이 있기 때문에)로 얼굴이 형성되었음을 나타냅니다.

중요 : 법선 계산 및/또는 비 다각형 (자체 교차) 모양의 문제가 발생하지 않도록하려면 지정된 순서로 정점을 결합해야합니다.

3

입방체는 v (v는 정점)로 정의되는 모서리 (정점 또는 점으로 표시)가 8 개 있습니다. 그림 (Polygon_mesh 참조)은 모서리의 좌표 (v)로 정의 된 표면입니다. .

v1+-----------+ v2 
    /  /
    / f1 /
/  /
v4+------------+v3 
    |   | 
    |   | 
    |  f2  | 
    |   | 
    |   | 
v6+------------+v5 

즉, 얼굴 f1은 v1, v2, v3 및 v4로 정의됩니다. f2 by v4, v3, v5, v6.

+0

v3과 v4를 교체했습니다. 질문에서 f1은 시계 반대 방향으로 1 3 4 2입니다. –

관련 문제