GithubHelp home page GithubHelp logo

820fans / voxelviewer Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 3.09 MB

View a voxel model. File format is customized by myself.

CMake 0.50% C++ 5.41% C 93.29% Makefile 0.39% Objective-C 0.07% Python 0.34%

voxelviewer's Introduction

VoxelViewer

View a voxel model. File format is customized by myself.

一次偶然的机会,接触了体素相关的内容. 每次一点点改进都让自己开心非常.

这里,基于CMakeOpenGL,自行编写了一个体素显示软件. 软件写的不是很好,基本上只能算是一个demo吧.

动机

本来看到了一个很好的显示软件叫做magicaVoxel,确实无论是渲染还是操作都特别好,我也针对自己的体素程序输出了它的格式.但是它的格式存在几个问题.

  1. 不能显示多分辨率体素. 比如我的体素模型包含多种大小的体素,这个程序就抓瞎了.
  2. 不能显示超过128*128*128大小的模型.这对于显示高分辨率模型是远远不够的.
  3. 接上条,貌似现在magicaVoxel作者开发了magicaViewer能显示最大2048^3但是似乎要求是MineCraft格式的. 但是自己写个体素程序而已,再去研究MineCraft似乎有点费时间.

基于这两个出发点,我写了这一款自己的体素显示软件,主要的功能点是:

  • 正确显示多分辨率体素模型
  • 显示多分辨率体素时候,能够让不同大小体素呈现出不同的颜色.

如果你的需求仅仅是显示小分辨率均一体素模型,可以去用magicaVoxel,友情链接

文件格式说明

size 12 12 12 
3.5 4.5 5.5 1 0 
3.5 4.5 4.5 0.5 0

第一行表示整个模型的大小,格式为size x y z,以空格分开。
从第二行开始,表示一个体素,格式为xi yi zi voxel_size depth
由于OpenGLdrawSolidCube函数的设计,xi yi zi表示当前体素的中心点。
voxel_size 表示当前体素的边长。
depth 表示当前体素的层级,因为体素化程序使用到了多分辨率体素化。
depthvoxel_size大小相关,符合voxel_size=1/2^depth

虽然这种存储方式比较粗糙,而且体素数量多时会导致文件特别大。但是本着够用就好的原则,没有设计二进制的格式。

PyViewer

尝试过拿python去写openGL的显示,不过这个写到一半夭折了. 而且运行速度上,应该比不上c++版本,就放弃了.

操作指导

在Linux下鼠标滚轮失效(暂未排查原因).

  • 右键拖拽页面, 所用的手势和magicaVoxel相同.
  • 大幅度放大缩小视角,操作按键z x c
  • 小幅度放大缩小视角,操作按键n m j k
  • 滚轮拉近或拉远视角(仅在windows下有效)

编译要求

Windows

在windows环境下,使用的dll和头文件全部放在了文件里。 使用Visual Studio 2013打开。 配置好之后可正常运行。

Linux

在Ubuntu环境下,要求安装OpenGLGLUT

目前可在Clion下编译运行

TODO

  • 规范化代码
  • 有空修一修bug
  • 规范化ReadMe
  • 输出二进制版本

voxelviewer's People

Contributors

820fans avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.