void CVXS_SimGLView::DrawGeometry(int Selected, bool ViewSection, int SectionLayer, vfloat ScaleVox) { #ifdef VX2 CVoxelyze* pVx = &pSim->Vx; const std::list<CVX_Voxel*>* voxels = pVx->voxelList(); for (std::list<CVX_Voxel*>::const_iterator it = voxels->begin(); it!=voxels->end(); it++){ CVX_Voxel* pVox = *it; glPushMatrix(); glTranslated(pVox->position().x, pVox->position().y, pVox->position().z); glRotated(pVox->orientation().Angle(), pVox->orientation().x, pVox->orientation().y, pVox->orientation().z); CGL_Utils::DrawCube(pVox->cornerNegative(), pVox->cornerPositive(), true, true, 1.0, CColor(pVox->material()->red()/255.0, pVox->material()->green()/255.0, pVox->material()->blue()/255.0, 1.0)); // glScaled(ScaleVox*pVx->latticeSize(), ScaleVox*pVx->latticeSize(), ScaleVox*pVx->latticeSize()); // CGL_Utils::DrawCube(true, true, 1.0, CColor(pVox->material()->red()/255.0, pVox->material()->green()/255.0, pVox->material()->blue()/255.0, 1.0)); glPopMatrix(); } #else Vec3D<> Center; Vec3D<> tmp(0,0,0); int iT = pSim->NumVox(); int x, y, z; CColor ThisColor; for (int i = 0; i<iT; i++) //go through all the voxels... { pSim->pEnv->pObj->GetXYZNom(&x, &y, &z, pSim->StoXIndexMap[i]); if (ViewSection && z>SectionLayer) continue; //exit if obscured in a section view! Center = pSim->VoxArray[i].GetCurPos(); ThisColor = GetCurVoxColor(i, Selected); glColor4d(ThisColor.r, ThisColor.g, ThisColor.b, ThisColor.a); Vec3D<> CenterOff = ScaleVox*(pSim->VoxArray[i].GetCornerPos() + pSim->VoxArray[i].GetCornerNeg())/2; glPushMatrix(); glTranslated(Center.x + CenterOff.x, Center.y + CenterOff.y, Center.z + CenterOff.z); glLoadName (pSim->StoXIndexMap[i]); //to enable picking //generate rotation matrix here!!! (from quaternion) Vec3D<> Axis; vfloat AngleAmt; CQuat<>(pSim->VoxArray[i].GetCurAngle()).AngleAxis(AngleAmt, Axis); glRotated(AngleAmt*180/3.1415926, Axis.x, Axis.y, Axis.z); Vec3D<> CurrentSizeDisplay = pSim->VoxArray[i].GetSizeCurrent(); glScaled(CurrentSizeDisplay.x, CurrentSizeDisplay.y, CurrentSizeDisplay.z); pSim->LocalVXC.Voxel.DrawVoxel(&Center, ScaleVox); //draw unit size since we scaled just now glPopMatrix(); } #endif }
void CVX_Sim::DrawGeometry(int Selected, bool ViewSection, int SectionLayer) { bool DrawInputVoxel = false; Vec3D<> Center; Vec3D<> tmp(0,0,0); int iT = NumVox(); int x, y, z; CColor ThisColor; for (int i = 0; i<iT; i++) //go through all the voxels... { pEnv->pObj->GetXYZNom(&x, &y, &z, StoXIndexMap[i]); if (ViewSection && z>SectionLayer) continue; //exit if obscured in a section view! Center = VoxArray[i].GetCurPos(); ThisColor = GetCurVoxColor(i, Selected); glColor4d(ThisColor.r, ThisColor.g, ThisColor.b, ThisColor.a); glPushMatrix(); glTranslated(Center.x, Center.y, Center.z); glLoadName (StoXIndexMap[i]); //to enable picking //generate rotation matrix here!!! (from quaternion) Vec3D<> Axis; vfloat AngleAmt; CQuat<>(VoxArray[i].GetCurAngle()).AngleAxis(AngleAmt, Axis); glRotated(AngleAmt*180/3.1415926, Axis.x, Axis.y, Axis.z); Vec3D<> Scale = VoxArray[i].GetCurScale(); //show deformed voxel size glScaled(Scale.x, Scale.y, Scale.z); //LocalVXC.Voxel.DrawVoxel(&tmp, LocalVXC.Lattice.Lattice_Dim*(1+0.5*CurTemp * pMaterials[CVoxelArray[i].MatIndex].CTE), LocalVXC.Lattice.Z_Dim_Adj); LocalVXC.Voxel.DrawVoxel(&tmp, 1); //LocalVXC.GetLatticeDim()); //[i].CurSize.x); //, LocalVXC.Lattice.Z_Dim_Adj); glPopMatrix(); } if (DrawInputVoxel){ Vec3D<> tmp(0,0,0); Center = VoxArray[NumVox()].GetCurPos(); glColor4d(1.0, 0.2, 0.2, 1.0); glPushMatrix(); glTranslated(Center.x, Center.y, Center.z); Vec3D<> Scale = LocalVXC.GetLatDimEnv(); glScaled(Scale.x, Scale.y, Scale.z); LocalVXC.Voxel.DrawVoxel(&tmp, 1); //LocalVXC.GetLatticeDim()); //[i].CurSize.x); //, LocalVXC.Lattice.Z_Dim_Adj); glPopMatrix(); } }
void CVXS_SimGLView::DrawGeometry(int Selected, bool ViewSection, int SectionLayer, vfloat ScaleVox) { Vec3D<> Center; Vec3D<> tmp(0,0,0); int iT = pSim->NumVox(); int x, y, z; CColor ThisColor; for (int i = 0; i<iT; i++) //go through all the voxels... { pSim->pEnv->pObj->GetXYZNom(&x, &y, &z, pSim->StoXIndexMap[i]); if (ViewSection && z>SectionLayer) continue; //exit if obscured in a section view! Center = pSim->VoxArray[i].GetCurPos(); ThisColor = GetCurVoxColor(i, Selected); glColor4d(ThisColor.r, ThisColor.g, ThisColor.b, ThisColor.a); Vec3D<> CenterOff = ScaleVox*(pSim->VoxArray[i].GetCornerPos() + pSim->VoxArray[i].GetCornerNeg())/2; glPushMatrix(); glTranslated(Center.x + CenterOff.x, Center.y + CenterOff.y, Center.z + CenterOff.z); glLoadName (pSim->StoXIndexMap[i]); //to enable picking //generate rotation matrix here!!! (from quaternion) Vec3D<> Axis; vfloat AngleAmt; CQuat<>(pSim->VoxArray[i].GetCurAngle()).AngleAxis(AngleAmt, Axis); glRotated(AngleAmt*180/3.1415926, Axis.x, Axis.y, Axis.z); Vec3D<> CurrentSizeDisplay = pSim->VoxArray[i].GetSizeCurrent(); glScaled(CurrentSizeDisplay.x, CurrentSizeDisplay.y, CurrentSizeDisplay.z); pSim->LocalVXC.Voxel.DrawVoxel(&Center, ScaleVox); //draw unit size since we scaled just now glPopMatrix(); } }