[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24903] trunk/blender/source/blender/ editors/space_view3d/drawobject.c: v Cloud to matrix
Jens Ole Wund (bjornmose)
bjornmose at gmx.net
Thu Nov 26 01:15:26 CET 2009
Revision: 24903
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24903
Author: bjornmose
Date: 2009-11-26 01:15:26 +0100 (Thu, 26 Nov 2009)
Log Message:
-----------
v Cloud to matrix
nice drawing for soft bodies
BTW could be used by any object by design
Modified Paths:
--------------
trunk/blender/source/blender/editors/space_view3d/drawobject.c
Modified: trunk/blender/source/blender/editors/space_view3d/drawobject.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/drawobject.c 2009-11-25 23:54:21 UTC (rev 24902)
+++ trunk/blender/source/blender/editors/space_view3d/drawobject.c 2009-11-26 00:15:26 UTC (rev 24903)
@@ -4326,64 +4326,169 @@
glPointSize(1.0);
}
-static void draw_sb_motion(Scene *scene, Object *ob)
+//static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float tw,float th)
+static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float itw,float ith,float drw_size)
{
- SoftBody *sb = 0;
- if ((sb= ob->soft)){
- if(sb->solverflags & SBSO_MONITOR ||sb->solverflags & SBSO_ESTIMATEIPO){
- /* draw com */
- float rt[3][3],sc[3][3],tr[3][3];
- /* looks like to swap a b in reverse */
- copy_m3_m3(sc,sb->lscale);
- copy_m3_m3(rt,sb->lrot);
- mul_m3_m3m3(tr,rt,sc);
- if(1){
- float root[3],tip[3];
+ float tr[3][3];
+ float root[3],tip[3];
+ float tw,th;
+ /* take a copy for not spoiling original */
+ copy_m3_m3(tr,rotscale);
+ tw = itw * drw_size;
+ th = ith * drw_size;
- glBegin(GL_LINES);
- root[1] = root[2] = 0.0f;
- root[0] = -1.0f;
- mul_m3_v3(tr,root);
- VECADD(root,root,sb->lcom);
- glVertex3fv(root);
- tip[1] = tip[2] = 0.0f;
- tip[0] = 1.0f;
- mul_m3_v3(tr,tip);
- VECADD(tip,tip,sb->lcom);
- glVertex3fv(tip);
- glEnd();
+ glColor4ub(0x7F, 0x00, 0x00, 155);
+ glBegin(GL_LINES);
+ root[1] = root[2] = 0.0f;
+ root[0] = -drw_size;
+ mul_m3_v3(tr,root);
+ VECADD(root,root,com);
+ glVertex3fv(root);
+ tip[1] = tip[2] = 0.0f;
+ tip[0] = drw_size;
+ mul_m3_v3(tr,tip);
+ VECADD(tip,tip,com);
+ glVertex3fv(tip);
+ glEnd();
- glBegin(GL_LINES);
- root[0] = root[2] = 0.0f;
- root[1] = -1.0f;
- mul_m3_v3(tr,root);
- VECADD(root,root,sb->lcom);
- glVertex3fv(root);
- tip[0] = tip[2] = 0.0f;
- tip[1] = 1.0f;
- mul_m3_v3(tr,tip);
- VECADD(tip,tip,sb->lcom);
- glVertex3fv(tip);
- glEnd();
+ root[1] =0.0f; root[2] = tw;
+ root[0] = th;
+ glBegin(GL_LINES);
+ mul_m3_v3(tr,root);
+ VECADD(root,root,com);
+ glVertex3fv(root);
+ glVertex3fv(tip);
+ glEnd();
- glBegin(GL_LINES);
- root[0] = root[1] = 0.0f;
- root[2] = -1.0f;
- mul_m3_v3(tr,root);
- VECADD(root,root,sb->lcom);
- glVertex3fv(root);
- tip[0] = tip[1] = 0.0f;
- tip[2] = 1.0f;
- mul_m3_v3(tr,tip);
- VECADD(tip,tip,sb->lcom);
- glVertex3fv(tip);
- glEnd();
- }
+ root[1] =0.0f; root[2] = -tw;
+ root[0] = th;
+ glBegin(GL_LINES);
+ mul_m3_v3(tr,root);
+ VECADD(root,root,com);
+ glVertex3fv(root);
+ glVertex3fv(tip);
+ glEnd();
- }
- }
-};
+ root[1] =tw; root[2] = 0.0f;
+ root[0] =th;
+ glBegin(GL_LINES);
+ mul_m3_v3(tr,root);
+ VECADD(root,root,com);
+ glVertex3fv(root);
+ glVertex3fv(tip);
+ glEnd();
+ root[1] =-tw; root[2] = 0.0f;
+ root[0] = th;
+ glBegin(GL_LINES);
+ mul_m3_v3(tr,root);
+ VECADD(root,root,com);
+ glVertex3fv(root);
+ glVertex3fv(tip);
+ glEnd();
+
+ glColor4ub(0x00, 0x7F, 0x00, 155);
+
+ glBegin(GL_LINES);
+ root[0] = root[2] = 0.0f;
+ root[1] = -drw_size;
+ mul_m3_v3(tr,root);
+ VECADD(root,root,com);
+ glVertex3fv(root);
+ tip[0] = tip[2] = 0.0f;
+ tip[1] = drw_size;
+ mul_m3_v3(tr,tip);
+ VECADD(tip,tip,com);
+ glVertex3fv(tip);
+ glEnd();
+
+ root[0] =0.0f; root[2] = tw;
+ root[1] = th;
+ glBegin(GL_LINES);
+ mul_m3_v3(tr,root);
+ VECADD(root,root,com);
+ glVertex3fv(root);
+ glVertex3fv(tip);
+ glEnd();
+
+ root[0] =0.0f; root[2] = -tw;
+ root[1] = th;
+ glBegin(GL_LINES);
+ mul_m3_v3(tr,root);
+ VECADD(root,root,com);
+ glVertex3fv(root);
+ glVertex3fv(tip);
+ glEnd();
+
+ root[0] =tw; root[2] = 0.0f;
+ root[1] =th;
+ glBegin(GL_LINES);
+ mul_m3_v3(tr,root);
+ VECADD(root,root,com);
+ glVertex3fv(root);
+ glVertex3fv(tip);
+ glEnd();
+
+ root[0] =-tw; root[2] = 0.0f;
+ root[1] = th;
+ glBegin(GL_LINES);
+ mul_m3_v3(tr,root);
+ VECADD(root,root,com);
+ glVertex3fv(root);
+ glVertex3fv(tip);
+ glEnd();
+
+ glColor4ub(0x00, 0x00, 0x7F, 155);
+ glBegin(GL_LINES);
+ root[0] = root[1] = 0.0f;
+ root[2] = -drw_size;
+ mul_m3_v3(tr,root);
+ VECADD(root,root,com);
+ glVertex3fv(root);
+ tip[0] = tip[1] = 0.0f;
+ tip[2] = drw_size;
+ mul_m3_v3(tr,tip);
+ VECADD(tip,tip,com);
+ glVertex3fv(tip);
+ glEnd();
+
+ root[0] =0.0f; root[1] = tw;
+ root[2] = th;
+ glBegin(GL_LINES);
+ mul_m3_v3(tr,root);
+ VECADD(root,root,com);
+ glVertex3fv(root);
+ glVertex3fv(tip);
+ glEnd();
+
+ root[0] =0.0f; root[1] = -tw;
+ root[2] = th;
+ glBegin(GL_LINES);
+ mul_m3_v3(tr,root);
+ VECADD(root,root,com);
+ glVertex3fv(root);
+ glVertex3fv(tip);
+ glEnd();
+
+ root[0] = tw; root[1] = 0.0f;
+ root[2] = th;
+ glBegin(GL_LINES);
+ mul_m3_v3(tr,root);
+ VECADD(root,root,com);
+ glVertex3fv(root);
+ glVertex3fv(tip);
+ glEnd();
+
+ root[0] = -tw; root[1] = 0.0f;
+ root[2] = th;
+ glBegin(GL_LINES);
+ mul_m3_v3(tr,root);
+ VECADD(root,root,com);
+ glVertex3fv(root);
+ glVertex3fv(tip);
+ glEnd();
+}
+
/*place to add drawers */
unsigned int nurbcol[8]= {
0, 0x9090, 0x409030, 0x603080, 0, 0x40fff0, 0x40c033, 0xA090F0 };
@@ -5779,8 +5884,23 @@
default:
drawaxes(1.0, flag, OB_ARROWS);
}
- if(ob->soft /*&& flag & OB_SBMOTION*/) draw_sb_motion(scene, ob);
+ if(ob->soft /*&& flag & OB_SBMOTION*/){
+ float mrt[3][3],msc[3][3],mtr[3][3];
+ SoftBody *sb = 0;
+ float tipw = 0.5f, tiph = 0.5f,drawsize = 4.0f;
+ if ((sb= ob->soft)){
+ if(sb->solverflags & SBSO_MONITOR ||sb->solverflags & SBSO_ESTIMATEIPO){
+ wmLoadMatrix(rv3d->viewmat);
+ copy_m3_m3(msc,sb->lscale);
+ copy_m3_m3(mrt,sb->lrot);
+ mul_m3_m3m3(mtr,mrt,msc);
+ ob_draw_RE_motion(sb->lcom,mtr,tipw,tiph,drawsize);
+ wmMultMatrix(ob->obmat);
+ }
+ }
+ }
+
if(ob->pd && ob->pd->forcefield) draw_forcefield(scene, ob);
/* particle mode has to be drawn first so that possible child particles get cached in edit mode */
More information about the Bf-blender-cvs
mailing list