Exemple #1
0
        }                               //reallinewidth 0 means 1 pixel wide.

        public void drawXYrectangle(cVector3 cornerlo, cVector3 cornerhi,
                                    cColorStyle pcolorstyle, int drawflags)
        {
            drawrectangle(cornerlo, new cVector3(cornerhi.X, cornerlo.Y, cornerlo.Z),
                          cornerhi, new cVector3(cornerlo.X, cornerhi.Y, cornerlo.Z),
                          pcolorstyle, drawflags);
        }
Exemple #2
0
        protected float _realdotradiusweight; //Ratio of vertex marker dot size to _Shaperadius.

        /*	DON'T put in a Real _radius or Real _angle!  C++ will let you do
         * this even though these fields exist in cSprite, but what a mistake.  If you
         * put a second _radius in here, then the cShape methods change the
         * cShape _radius, but the cSprite::radius() accessor returns the cSprite
         * _radius, which will still be 0.0 */
        //Private helper functions

        protected void _initializer() //used by the constructors
        {
            //The two CArrays are set to size 0 by their default constructors
            //Nine decoration fields
            _dotted                   = false;
            _pdotcolorstyle           = new cColorStyle();
            _pdotcolorstyle.FillColor = Color.Yellow;
            _realdotradiusweight      = 0.05f;
            // helper fields
            _convex     = true;
            _vectorvert = new LinkedList <cVector3>(
                delegate(out cVector3 v1, cVector3 v2)
            {
                v1 = new cVector3();
                v1.copy(v2);
            }
                );
            _transformedvert = new LinkedList <cVector3>(
                delegate(out cVector3 v1, cVector3 v2)
            {
                v1 = new cVector3();
                v1.copy(v2);
            }
                );
        }
Exemple #3
0
        /* Useful for wrapping
         *  verts in a Shape class to pass to pgraphics->draw. */
        //Overloaded cSprite methods

        public override void copy(cSprite psprite) //Use this in copy constructor and operator=
        {
            /* Because our class has some CArray fields, we can't use the default overloaded
             * copy constructor and operator=.  So as to avoid having to maintain similar code
             * for these two different methods, we write a helper copy function that both
             * the copy constructor and the operator= can use. */
            base.copy(psprite); //does center(), _radius, _angle, _rotationspeed.
            if (!(psprite is cShape))
            {
                return;                        //You're done if psprite isn't a cShape*.
            }
            cShape pShape = (cShape)(psprite); /* I know it is a cShape
                                                * at this point, but I need to do a cast, so the compiler will let me
                                                * call a bunch of cShape methods. */

            //Arrays
            _vectorvert.Copy(pShape._vectorvert);
            //Decoration fields
            cColorStyle c = new cColorStyle();

            c.copy(pShape.pcolorstyle());
            ColorStyle = c;
            cColorStyle c2 = new cColorStyle();

            c2.copy(pShape.DotColorStyle);
            DotColorStyle        = c2;
            _dotted              = pShape._dotted;
            _realdotradiusweight = pShape._realdotradiusweight;
            //Helper fields
            _convex = pShape._convex;
        }
Exemple #4
0
 /// <summary>
 /// Makes a copy of another cColorStyle object into this object.
 /// </summary>
 /// <param name="colorstyle">The cColorStyle object to make a copy of.</param>
 public virtual void copy(cColorStyle colorstyle)
 {
     _filled          = colorstyle._filled;
     _edged           = colorstyle._edged;
     _fillcolor       = colorstyle._fillcolor;
     _linecolor       = colorstyle._linecolor;
     _linewidth       = colorstyle._linewidth;
     _linewidthweight = colorstyle._linewidthweight;
     _alpha           = colorstyle._alpha;
 }
Exemple #5
0
 public virtual void copy(cSprite psprite)
 {
     _radius = psprite._radius;
     _prismdz = psprite._prismdz;
     _spriteattitude.copy(psprite._spriteattitude);
     _resourceID = psprite._resourceID;
     cColorStyle c = new cColorStyle();
     c.copy(psprite.pcolorstyle());
     ColorStyle = c;
 }
Exemple #6
0
        /* This gets called by the owner cCritter::draw which does multMatrix
        (on the right) with the critter's own _attitude and calls psprite()->draw. 
        cSprite::draw does a multMatrix (on the right) with its own _spriteattitude
        and calls its special overloaded imagedraw method. It's effectively a
        Template Method. */

        public virtual void imagedraw(cGraphics pgraphics, int drawflags)
        {
            /*This is a default approach, just draws a circle. */
            cColorStyle tempcolorstyle = new cColorStyle(true, true, Color.Blue,
                Color.LightGray, Radius / 4.0f);
            /* Params are filled, edged, fillcolor, linecolor,
         linewidth, etc. */
            pgraphics.drawcircle(new cVector3(0.0f, 0.0f, 0.0f), _radius,
                tempcolorstyle, drawflags);
        }
Exemple #7
0
        //Makes a default regular Shape with n verts.

        public cShape(int n, cVector3[] pverts, cColorStyle pcolorstyle = null)
        {
            _initializer();
            for (int i = 0; i < n; i++)
            {
                _vectorvert.Add(pverts[i]);
            }
            if (pcolorstyle != null)
            {
                cColorStyle c = new cColorStyle();
                c.copy(pcolorstyle);
                ColorStyle = c; //Otherwise keep the default.
            }
            fixCenterAndRadius();
        }
Exemple #8
0
        protected bool _newgeometryflag; /* This is for use with sophisticated graphics like 
			cGraphicsOpenGL, where we speed up the drawing
			of some kinds of sprites by saving a display list index that encapsulates the steps
			used to draw the sprite.  If you change the intrinsic geometry of the sprite, for
			instance by changing the number of vertices in a polygon, then you need to 
			make a new display list for that sprite, and the _newgeometryflag is the flag
			we have a cSprite use so as to signal this to the cGraphicsOpenGL. 
			At construction, _newgeometryflag is TRUE. We don't serialize this field. */

        public cSprite()
        {
            _prismdz = CRITTERPRISMDZ;
            _newgeometryflag = true;
            _resourceID = -1;
            _spriteattitude = new cMatrix3();
            Center = new cVector3(0.0f, 0.0f); //Sets last column of _spriteattitude.
            /* We start the cSprite with a nonzero radius so that we can readily adjust
        its size by scaling it, that is, by multiplying it by scale factors. Let's start
        it as the average of the cCritter min and max.*/
            _radius = (cCritter.MinRadius + cCritter.MaxRadius) / 2.0f;
            _pcolorstyle = new cColorStyle();
            //Default constructor of _spriteattidute will be an identity matrix.
            _spriteID = cSprite.SPRITEID++; // The the first one gets a value of 1.
        }
        public void setPlainRectangle(int boxside)
        {
            if (!(_childspriteptr.Size > boxside))
            {
                return;
            }
            cSpriteRectangle prect = null;

            switch (boxside)
            {
            case 0:
                prect = new cSpriteRectangle(Loy, Loz, Hiy, Hiz);
                _childspriteptr.SetAt(boxside, prect);;
                break;

            case 1:
                prect = new cSpriteRectangle(Loy, Loz, Hiy, Hiz);
                _childspriteptr.SetAt(boxside, prect);;
                break;

            case 2:
                prect = new cSpriteRectangle(Lox, Loz, Hix, Hiz);
                _childspriteptr.SetAt(boxside, prect);;
                break;

            case 3:
                prect = new cSpriteRectangle(Lox, Loz, Hix, Hiz);
                _childspriteptr.SetAt(boxside, prect);;
                break;

            case 4:
                prect = new cSpriteRectangle(Lox, Loy, Hix, Hiy);
                _childspriteptr.SetAt(boxside, prect);;
                break;

            case 5:
                prect = new cSpriteRectangle(Lox, Loy, Hix, Hiy);
                _childspriteptr.SetAt(boxside, prect);;
                break;
            }
            cColorStyle c = new cColorStyle();

            c.copy(pcolorstyle());
            prect.ColorStyle = c;             //Use the base class colorstyle.
            _fixspriteattitude(boxside);
            fixResourceID();
        }
Exemple #10
0
 public cPrism(int n, float r, float length, cVector3[] pverts, cColorStyle pcolorstyle = null)
     : base(n, pverts, pcolorstyle)
 {
     Radius  = r;
     PrismDz = length;
 }
Exemple #11
0
        }                     //Defined in indivdiual graphics files.

        public virtual void drawcircle(cVector3 center, float radius,
                                       cColorStyle pcolorstyle, int drawflags)
        {
        }
Exemple #12
0
        /* Turns the 2 points into 4 and calls the virtual
         *      drawrectangle method that uses four corners.  The 2 corner call assumes
         *      the rectangle has its z values averaged between
         *      cornerlo and cornerhi and traverses the 4 corners starting out heading from
         *      cornerlo.x() to cornerhi.x(). */

        public virtual void drawrectangle(cVector3 corner0, cVector3 corner1,
                                          cVector3 corner2, cVector3 corner3, cColorStyle pcolorstyle,
                                          int drawflags)
        {
        }                     //Defined in indivdiual graphics files.
Exemple #13
0
 public virtual void drawline(cVector3 posa, cVector3 posb,
                              cColorStyle pcolorstyle)
 {
 }                               //reallinewidth 0 means 1 pixel wide.