# HG changeset patch # User John Tsiombikas # Date 1347950328 -10800 # Node ID 0a53b22f7caf1d9ff63e977c947d346198ad5f33 # Parent fbccc3c0d43e26fe6573678c40b7e93ecea502cb the billboarding was wrong ... diff -r fbccc3c0d43e -r 0a53b22f7caf src/psys.c --- a/src/psys.c Mon Sep 17 08:21:39 2012 +0300 +++ b/src/psys.c Tue Sep 18 09:38:48 2012 +0300 @@ -88,6 +88,21 @@ anm_set_pivot(&em->prs, pivot); } +vec3_t psys_get_pos(struct psys_emitter *em, float tm) +{ + return anm_get_node_position(&em->prs, ANM_SEC2TM(tm)); +} + +quat_t psys_get_rot(struct psys_emitter *em, float tm) +{ + return anm_get_node_rotation(&em->prs, ANM_SEC2TM(tm)); +} + +vec3_t psys_get_pivot(struct psys_emitter *em) +{ + return anm_get_pivot(&em->prs); +} + void psys_clear_collision_planes(struct psys_emitter *em) { struct psys_plane *plane; diff -r fbccc3c0d43e -r 0a53b22f7caf src/psys.h --- a/src/psys.h Mon Sep 17 08:21:39 2012 +0300 +++ b/src/psys.h Tue Sep 18 09:38:48 2012 +0300 @@ -85,6 +85,10 @@ void psys_set_rot(struct psys_emitter *em, quat_t rot, float tm); void psys_set_pivot(struct psys_emitter *em, vec3_t pivot); +vec3_t psys_get_pos(struct psys_emitter *em, float tm); +quat_t psys_get_rot(struct psys_emitter *em, float tm); +vec3_t psys_get_pivot(struct psys_emitter *em); + void psys_clear_collision_planes(struct psys_emitter *em); int psys_add_collision_plane(struct psys_emitter *em, plane_t plane, float elast); diff -r fbccc3c0d43e -r 0a53b22f7caf src/psys_gl.c --- a/src/psys_gl.c Mon Sep 17 08:21:39 2012 +0300 +++ b/src/psys_gl.c Tue Sep 18 09:38:48 2012 +0300 @@ -18,17 +18,6 @@ void psys_gl_draw_start(struct psys_emitter *em, void *cls) { - float xform[16]; - - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - - glGetFloatv(GL_MODELVIEW_MATRIX, xform); - xform[0] = xform[5] = xform[10] = 1.0; - xform[1] = xform[2] = xform[4] = xform[6] = xform[8] = xform[9] = 0.0; - - glLoadMatrixf(xform); - glPushAttrib(GL_ENABLE_BIT); glDisable(GL_LIGHTING); @@ -41,39 +30,48 @@ } glDepthMask(0); - - glBegin(GL_QUADS); - glColor3f(1, 1, 1); } void psys_gl_draw(struct psys_emitter *em, struct psys_particle *p, void *cls) { float hsz = p->size / 2.0; + float xform[16]; + + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + + glTranslatef(p->pos.x, p->pos.y, p->pos.z); + + glGetFloatv(GL_MODELVIEW_MATRIX, xform); + xform[0] = xform[5] = xform[10] = 1.0; + xform[1] = xform[2] = xform[4] = xform[6] = xform[8] = xform[9] = 0.0; + glLoadMatrixf(xform); + + glBegin(GL_QUADS); glColor4f(p->color.x, p->color.y, p->color.z, p->alpha); glTexCoord2f(0, 0); - glVertex3f(p->pos.x - hsz, p->pos.y - hsz, p->pos.z); + glVertex2f(-hsz, -hsz); glTexCoord2f(1, 0); - glVertex3f(p->pos.x + hsz, p->pos.y - hsz, p->pos.z); + glVertex2f(hsz, -hsz); glTexCoord2f(1, 1); - glVertex3f(p->pos.x + hsz, p->pos.y + hsz, p->pos.z); + glVertex2f(hsz, hsz); glTexCoord2f(0, 1); - glVertex3f(p->pos.x - hsz, p->pos.y + hsz, p->pos.z); + glVertex2f(-hsz, hsz); + glEnd(); + + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); } void psys_gl_draw_end(struct psys_emitter *em, void *cls) { - glEnd(); - glDepthMask(1); glPopAttrib(); - - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); }