Add finite grid ground
parent
230bc2d04a
commit
d7ef7d6d08
22
README.md
22
README.md
|
@ -6,15 +6,27 @@ Idea
|
|||
===========
|
||||
I was inspired by Jimmy Gunawan's blogs of monster generation, here is the first one [INSPIRATION / Pixar Monster Factory Part One](http://blendersushi.blogspot.com.au/2013/06/inspiration-pixar-monster-factory-part.html), and by search the Skin Modifier of Blender, I found the theory of Skin Modifier:
|
||||
[B-Mesh: A Fast Modeling System for Base Meshes
|
||||
of 3D Articulated Shapes](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.357.7134&rep=rep1&type=pdf)(Authors: Zhongping Ji, Ligang Liu2, Yigang Wang1). I started to think of monster model generation for game development from years ago, thanks for this paper, Dust3D is achievable now.
|
||||
of 3D Articulated Shapes](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.357.7134&rep=rep1&type=pdf)(Authors: Zhongping Ji, Ligang Liu, Yigang Wang). I started to think of monster model generation for game development from years ago, thanks for this paper, Dust3D is achievable now.
|
||||
From my initial thought, Dust3D should be a tool like [Makehuman](http://www.makehuman.org), with more versatile features, not only can make human, but also be able to **generate monsters automatically**.
|
||||
|
||||
Progress
|
||||
TODO & Progress
|
||||
==============
|
||||
Drawing Primitives
|
||||
-----------
|
||||
- [x] Drawing Primitives (Dec 15, 2016 ~ Dec 17, 2016)
|
||||
*Sphere*
|
||||
I don't want the whole project have any unnecessary dependent, like glu library.
|
||||
Let's start with [drawing a sphere without gluSphere]( http://stackoverflow.com/questions/7687148/drawing-sphere-in-opengl-without-using-glusphere), because I want implement the same balls which presented in the [B-Mesh paper](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.357.7134&rep=rep1&type=pdf).
|
||||
Let's start with [drawing a sphere without gluSphere]( http://stackoverflow.com/questions/7687148/drawing-sphere-in-opengl-without-using-glusphere), because I want implement the same spheres which presented in the [B-Mesh paper](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.357.7134&rep=rep1&type=pdf).
|
||||
*Cylinder*
|
||||
Two caps and many strips composites a cylinder.
|
||||
*Infinite Grid*
|
||||
Almost all 3D editor have a infinite grid ground, I just made a finite one, in the future, I should expand the grid outside of the screen to make it infinite.
|
||||
Now, for just beginning, I think it's a not bad start.
|
||||
<img src="screenshot/dust3d_sphere_cylinder.png">
|
||||
- [ ] Implement B-Mesh algorithm
|
||||
- [ ] Export Wavefront .obj
|
||||
- [ ] Render B-Mesh result
|
||||
- [ ] Design UI for monster parts configuration
|
||||
- [ ] Test B-Mesh realtime generation with UI
|
||||
- [ ] Render rigid animation
|
||||
- [ ] png exporter for isometric 2.5D game
|
||||
- [ ] Version 0.01 release
|
||||
- [ ] Materials merge of different parts
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 128 KiB |
|
@ -29,6 +29,23 @@ int drawCylinder(int slices, float radius, float height) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
// strips
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
for (a = 0, lv = 0; lv <= slices; ++lv) {
|
||||
float cosa = cos(a);
|
||||
float sina = sin(a);
|
||||
x = cosa * radius;
|
||||
y = sina * radius;
|
||||
z = -halfHeight;
|
||||
glNormal3f(cosa, sina, 0);
|
||||
glVertex3f(x, y, z);
|
||||
z = halfHeight;
|
||||
glNormal3f(cosa, sina, 0);
|
||||
glVertex3f(x, y, z);
|
||||
a += theta;
|
||||
}
|
||||
glEnd();
|
||||
|
||||
// bottom cap
|
||||
z = -halfHeight;
|
||||
glBegin(GL_TRIANGLE_FAN);
|
||||
|
@ -57,23 +74,6 @@ int drawCylinder(int slices, float radius, float height) {
|
|||
}
|
||||
glEnd();
|
||||
|
||||
// strips
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
for (a = 0, lv = 0; lv <= slices; ++lv) {
|
||||
float cosa = cos(a);
|
||||
float sina = sin(a);
|
||||
x = cosa * radius;
|
||||
y = sina * radius;
|
||||
z = -halfHeight;
|
||||
glNormal3f(cosa, sina, 0);
|
||||
glVertex3f(x, y, z);
|
||||
z = halfHeight;
|
||||
glNormal3f(cosa, sina, 0);
|
||||
glVertex3f(x, y, z);
|
||||
a += theta;
|
||||
}
|
||||
glEnd();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -88,22 +88,30 @@ GLWidget::~GLWidget() {
|
|||
}
|
||||
|
||||
void GLWidget::initializeGL() {
|
||||
GLfloat mat_specular[] = {1.0, 1.0, 1.0, 1.0};
|
||||
GLfloat mat_shininess[] = {50.0};
|
||||
GLfloat light_position[] = {1.0, 1.0, 1.0, 0.0};
|
||||
GLfloat light[] = {1.0, 0.2, 0.2};
|
||||
GLfloat lmodel_ambient[] = {0.1, 0.1, 0.1, 1.0};
|
||||
GLfloat mat_ambient[] = { 0.0 , 0.0 , 0.0 , 1.0 };
|
||||
GLfloat mat_diffuse[] = { 0.55 , 0.55 , 0.55 , 1.0 };
|
||||
GLfloat mat_specular[] = {0.7 , 0.7 , 0.7, 1.0 };
|
||||
GLfloat mat_shininess[] = { 32 };
|
||||
|
||||
GLfloat light_diffuse[] = { 1.0 , 1.0 , 1.0 , 1.0 };
|
||||
GLfloat light_specular[] = { 1.0 , 1.0 , 1.0 , 1.0 };
|
||||
GLfloat light_ambient[] = { 0.2 , 0.2 , 0.2 , 1.0 };
|
||||
GLfloat light_position[] = { -1,1,1 , 0 };
|
||||
|
||||
glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||
glShadeModel(GL_SMOOTH);
|
||||
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
|
||||
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
|
||||
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
|
||||
glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
|
||||
|
||||
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
|
||||
glLightfv(GL_LIGHT0, GL_DIFFUSE, light);
|
||||
glLightfv(GL_LIGHT0, GL_SPECULAR, light);
|
||||
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
|
||||
glLightfv(GL_LIGHT0 , GL_POSITION , light_position);
|
||||
glLightfv(GL_LIGHT0 , GL_DIFFUSE , light_diffuse);
|
||||
glLightfv(GL_LIGHT0 , GL_AMBIENT , light_ambient);
|
||||
glLightfv(GL_LIGHT0 , GL_SPECULAR , light_specular);
|
||||
|
||||
glDepthFunc(GL_LESS);
|
||||
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT0);
|
||||
|
@ -113,27 +121,38 @@ void GLWidget::initializeGL() {
|
|||
void GLWidget::paintGL() {
|
||||
static int angle = 0;
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
//drawSphere(3);
|
||||
|
||||
glBegin(GL_LINES);
|
||||
for (GLfloat i = -2.5; i <= 2.5; i += 0.25) {
|
||||
glVertex3f(i, 0, 2.5); glVertex3f(i, 0, -2.5);
|
||||
glVertex3f(2.5, 0, i); glVertex3f(-2.5, 0, i);
|
||||
}
|
||||
glEnd();
|
||||
|
||||
drawSphere(4);
|
||||
|
||||
glPushMatrix();
|
||||
glRotatef(angle, 1, 0, 0);
|
||||
glRotatef(angle, 1, 1, 0);
|
||||
angle = (angle + 1) % 360;
|
||||
drawCylinder(50, 0.2, 2);
|
||||
drawCylinder(40, 0.2, 2.1);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
void GLWidget::resizeGL(int w, int h) {
|
||||
glViewport(0, 0, (GLsizei)w, (GLsizei)h);
|
||||
|
||||
glClearColor(0.92, 0.92, 0.92, 1.0);
|
||||
glColor3f(1.0, 1.0, 1.0);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
if (w <= h) {
|
||||
glOrtho(-1.5, 1.5, -1.5*(GLfloat)h/(GLfloat)w,
|
||||
1.5*(GLfloat)h/(GLfloat)w, -10.0, 10.0);
|
||||
} else {
|
||||
glOrtho(-1.5*(GLfloat)w/(GLfloat)h,
|
||||
1.5*(GLfloat)w/(GLfloat)h, -1.5, 1.5, -10.0, 10.0);
|
||||
}
|
||||
glFrustum(-2, 2, -1.5, 1.5, 1, 10);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(0, 0, -2);
|
||||
glRotatef(50, 1, 0, 0);
|
||||
glRotatef(70, 0, 1, 0);
|
||||
}
|
||||
|
||||
void GLWidget::mousePressEvent(QMouseEvent *event) {
|
||||
|
|
Loading…
Reference in New Issue