コード例 #1
0
        public CS_SegmentImpl(/*Params params, LevelParams lparams,*/
            CS_StemImpl stm, int inx, DX_Transformation trf,
            float r1, float r2)
        {
            index = inx;
            transf = trf;
            rad1 = r1;
            rad2 = r2;
            stem = stm;

            par = stem.par;
            lpar = stem.lpar;
            length = stem.segmentLength;

            // FIXME: rad1 and rad2 could be calculated only when output occurs (?)
            // or here in the constructor ?
            // FIXME: inialize subsegs with a better estimation of size
            subsegments = new List<CS_SubsegmentImpl>(10);
        }
コード例 #2
0
ファイル: CS_Params.cs プロジェクト: khazanJM/arbaro-csharp
        public CS_Params(CS_Params other)
        {
            // copy values from other
            //debug = other.debug;
            //verbose = other.verbose;
            ignoreVParams = other.ignoreVParams;
            stopLevel = other.stopLevel;
            Species = other.Species;
            //		Seed = other.Seed;
            Smooth = other.Smooth;

            // create paramDB
            paramDB = new Hashtable();
            levelParams = new CS_LevelParams[4];
            for (int l = 0; l < 4; l++)
            {
                levelParams[l] = new CS_LevelParams(l, paramDB);
            }
            registerParams();

            // copy param values
            foreach (CS_AbstractParam p in paramDB.Values)
            {
                try
                {
                    CS_AbstractParam otherParam = other.getParam(p.name);
                    if (!otherParam.empty())
                    {
                        p.setValue(otherParam.getValue());
                    } // else use default value
                }
                catch (Exception err)
                {
                    Console.WriteLine("Error copying params: " + err.Message);
                }
            }
        }
コード例 #3
0
ファイル: CS_Params.cs プロジェクト: khazanJM/arbaro-csharp
        /*
        protected ChangeEvent changeEvent = null;
        protected EventListenerList listenerList = new EventListenerList();
        */
        public CS_Params()
        {
            //		debug = false;
            //verbose = true;
            ignoreVParams = false;

            stopLevel = -1;

            Species = "default";

            LeafQuality = 1;

            Smooth = 0.5f;

            // the default seed
            //		Seed = 13;

            // create paramDB
            paramDB = new Hashtable();
            levelParams = new CS_LevelParams[4];
            for (int l = 0; l < 4; l++)
            {
                levelParams[l] = new CS_LevelParams(l, paramDB);
            }
            registerParams();
        }
コード例 #4
0
ファイル: CS_StemImpl.cs プロジェクト: khazanJM/arbaro-csharp
        /* offs=0 */
        /**
         * Creates a new stem
         *
         * @param tr the tree object
         * @param params the general tree parameters
         * @param lparams the parameters for the stem level
         * @param parnt the parent stem, from wich the stems grows out
         * @param stlev the stem level
         * @param trf the base transformation of the stem
         * @param offs the offset of ste stem within the parent stem (0..1)
         */
        public CS_StemImpl(CS_TreeImpl tr, CS_StemImpl growsOutOf, int stlev,
                DX_Transformation trf, float offs)
        {
            tree = tr;
                    stemlevel = stlev;
                    transf = trf;
                    offset = offs;

                    if (growsOutOf != null)
                    {
                        if (growsOutOf.stemlevel < stemlevel)
                            parent = growsOutOf;
                        else
                        {
                            clonedFrom = growsOutOf;
                            parent = growsOutOf.parent;
                        }
                    }

                    par = tree.csparams;
                    lpar = par.getLevelParams(stemlevel);

                    // initialize lists
                    segments = new List<CS_SegmentImpl>(lpar.nCurveRes);

                    if (lpar.nSegSplits > 0 || par._0BaseSplits > 0)
                    {
                        clones = new List<CS_StemImpl>(); // lpar.nSegSplits*lpar.nCurveRes+1);
                    }

                    if (stemlevel < par.Levels - 1)
                    {
                        CS_LevelParams lpar_1 = par.getLevelParams(lpar.level + 1);
                        substems = new List<CS_StemImpl>(lpar_1.nBranches);
                    }

                    if (stemlevel == par.Levels - 1 && par.Leaves != 0)
                    {
                        leaves = new List<CS_LeafImpl>(Math.Abs(par.Leaves));
                    }

                    // inialize other variables
                    leavesPerSegment = 0;
                    splitCorrection = 0;

                    index = 0; // substem number

                    cloneIndex = new List<int>();
                    pruneTest = false; // flag used for pruning

                    //...
                    maxPoint = new Vector3(-float.MaxValue, -float.MaxValue, -float.MaxValue);
                    minPoint = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue);
        }
コード例 #5
0
ファイル: CS_TreeImpl.cs プロジェクト: khazanJM/arbaro-csharp
        /* (non-Javadoc)
         * @see net.sourceforge.arbaro.tree.TraversableTree#traverseTree(net.sourceforge.arbaro.tree.TreeTraversal)
         */
        DX_Transformation trunkDirection(DX_Transformation trf, CS_LevelParams lpar)
        {
            // get rotation angle
            double rotangle;
            if (lpar.nRotate >= 0)
            { // rotating trunk
                trunk_rotangle = (trunk_rotangle + lpar.nRotate + lpar.var(lpar.nRotateV) + 360) % 360;
                rotangle = trunk_rotangle;
            }
            else
            { // alternating trunks
                if (Math.Abs(trunk_rotangle) != 1) trunk_rotangle = 1;
                trunk_rotangle = -trunk_rotangle;
                rotangle = trunk_rotangle * (180 + lpar.nRotate + lpar.var(lpar.nRotateV));
            }

            // get downangle
            double downangle;
            downangle = lpar.nDownAngle + lpar.var(lpar.nDownAngleV);

            return trf.rotxz(downangle, rotangle);
        }