void P3DBranchingAlgStdPanel::OnStartRevAngleChanged (wxSpinSliderEvent &event) { P3DApp::GetApp()->ExecEditCmd (new P3DBAlgStdFloatParamEditCmd (Alg, P3DMATH_DEG2RAD((float)(event.GetIntValue())), Alg->GetStartRevAngle(), &P3DBranchingAlgStd::SetStartRevAngle)); }
void P3DBranchingAlgWingsPanel::OnRotAngleChanged (wxSpinSliderEvent &event) { P3DApp::GetApp()->ExecEditCmd (new P3DBAlgWingsFloatParamEditCmd (Alg, P3DMATH_DEG2RAD((float)(event.GetIntValue())), Alg->GetRotationAngle(), &P3DBranchingAlgWings::SetRotationAngle)); }
P3DCanvas3D::P3DCanvas3D(wxWindow *parent) : wxGLCanvas(parent,wxID_ANY,wxDefaultPosition,wxSize(512,512),0,wxT("GLCanvas"),P3DCanvas3DGLAttrs), viewport(0,0,320,240) { int w,h; GLExtInited = false; GetClientSize(&w,&h); if (h > 0) { viewport.setSize(w,h); } m_x = -1; m_y = -1; camera.RotateCS(P3DMATH_DEG2RAD(20.0f),1.0f,0.0f,0.0f); ZoomFactor = 1.0f; OrthoCamera = true; }
void P3DBranchingAlgStd::CreateBranches (P3DBranchingFactory *Factory, const P3DStemModelInstance *Parent, P3DMathRNG *RNG) { unsigned int BranchCount; float OffsetStep; float CurrRevAngle; float BranchRegionLength; CurrRevAngle = StartRevAngle; BranchRegionLength = Parent->GetLength() * (MaxOffset - MinOffset); if (BranchRegionLength <= 0.0f) { return; } if (RNG != 0) { BranchCount = (int)(BranchRegionLength * (Density + RNG->UniformFloat(-DensityV,DensityV) * Density)); } else { BranchCount = (int)(BranchRegionLength * Density); } BranchCount /= Multiplicity; if (BranchCount < MinNumber) { BranchCount = MinNumber; } if (MaxLimitEnabled && BranchCount > MaxNumber) { BranchCount = MaxNumber; } if (BranchCount > 0) { P3DQuaternionf orientation; P3DQuaternionf decl; P3DQuaternionf rev; P3DQuaternionf Rot; P3DQuaternionf TempRot; float MultRevAngleStep; OffsetStep = (MaxOffset - MinOffset) / (BranchCount + 1); P3DVector3f CurrOffset(0.0f,MinOffset + OffsetStep,0.0f); MultRevAngleStep = (2.0f * P3DMATH_PI) / Multiplicity; for (unsigned int i = 0; i < BranchCount; i++) { float BaseDeclination; for (unsigned int MultIndex = 0; MultIndex < Multiplicity; MultIndex++) { BaseDeclination = DeclinationCurve.GetValue(CurrOffset.Y()); if (RNG != 0) { BaseDeclination += RNG->UniformFloat(-DeclinationV,DeclinationV) * BaseDeclination; } decl.FromAxisAndAngle(0.0f,0.0f,-1.0f,P3DMATH_DEG2RAD(180.0f * BaseDeclination)); rev.FromAxisAndAngle(0.0f,1.0f,0.0f,CurrRevAngle + MultRevAngleStep * MultIndex); Rot.FromAxisAndAngle(0.0f,1.0f,0.0f,Rotation); P3DQuaternionf::CrossProduct(TempRot.q,rev.q,decl.q); P3DQuaternionf::CrossProduct(orientation.q,TempRot.q,Rot.q); Factory->GenerateBranch(&CurrOffset,&orientation); } if (RNG != 0) { CurrRevAngle += RevAngle + (RevAngle * RNG->UniformFloat(-RevAngleV,RevAngleV)); } else { CurrRevAngle += RevAngle; } CurrOffset.Y() += OffsetStep; } } }