本学期计算机图形学作业的一部分。
还是采用vrml读取为obj, 和obj写入为vrml。
只能读取最简单的点和面, 其他纹理没写。
#ifndef VRML_H_
#define VRML_H_
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int vrml_point(FILE *fp, float (*point)[3])
{
char tmp[256];
int point_count = 0;
while(!feof(fp))
{
fscanf(fp, "%s", tmp);
if (!strcmp(tmp, "["))
{
fscanf(fp, "%s", tmp);
while(strcmp(tmp, "]"))
{
point[point_count][0] = atof(tmp);
fscanf(fp, "%s", tmp);
point[point_count][1] = atof(tmp);
fscanf(fp, "%s", tmp);
point[point_count][2] = atof(tmp);
point_count++;
fscanf(fp, "%s", tmp);
}
return point_count;
}
}
}
int vrml_face(FILE *fp, int (*face)[3])
{
char tmp[256];
int face_count = 0;
while(!feof(fp))
{
fscanf(fp, "%s", tmp);
if (!strcmp(tmp, "["))
{
fscanf(fp, "%s", tmp);
while(strcmp(tmp, "]"))
{
face[

这篇博客介绍了作者在计算机图形学课程中完成的作业,涉及使用VRML进行OBJ文件的读取和转换回VRML格式。目前仅支持基本的点和面,不包含纹理处理。
最低0.47元/天 解锁文章
2900

被折叠的 条评论
为什么被折叠?



