Exemple #1
0
	//The imagedraw function 
	
		public override void imagedraw( cGraphics pgraphics, int drawflags = 0 ) 
		{
			if ( (drawflags & ACView.DF_WIREFRAME) == 0 ) 
				pgraphics.drawbitmap( this, drawflags ); 
			else //we're in wireframe mode 
				pgraphics.drawXYrectangle( LoCorner, HiCorner, 
					pcolorstyle(), drawflags ); 
		} 
Exemple #2
0
	//Overload the cSpriteComposite draw function 
	
		public override void draw( cGraphics pgraphics, int drawflags ) 
		{ /* Use the base _spriteattitude and then walk the array of child sprites and call their
		imagedraw methods.   */ 
			pgraphics.pushMatrix(); 
			pgraphics.multMatrix( _spriteattitude );
            foreach (cSprite s in _childspriteptr)
                _childspriteptr.ElementAt().draw(pgraphics, drawflags);
            pgraphics.popMatrix(); 
		} 
Exemple #3
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 #4
0
        /* Fix our member array
         *  _transformedvert so it holds all the M*vert from the _vectorvert array, and then
         *  return a pointer to _transformedvert.  We can't return a copy of this array because
         *  MFC doesn't supply a CArray copy constructor. This method is needed by the
         *  cGraphicsMFC::draw(cShape) call. */
        //cSprite overloads

        public override void imagedraw(cGraphics pgraphics, int drawflags)
        {
            if (_convex)
            {
                pgraphics.drawShape(this, drawflags, topPoint);
            }
            else
            {
                pgraphics.drawstarShape(this, drawflags);
            }
        }
Exemple #5
0
        /* Fix our member array
         *  _transformedvert so it holds all the M*vert from the _vectorvert array, and then
         *  return a pointer to _transformedvert.  We can't return a copy of this array because
         *  MFC doesn't supply a CArray copy constructor. This method is needed by the
         *  cGraphicsMFC::draw(cPolygon) call. */
        //cSprite overloads

        public override void imagedraw(cGraphics pgraphics, int drawflags)
        {
            if (_convex)
            {
                pgraphics.drawpolygon(this, drawflags);
            }
            else
            {
                pgraphics.drawstarpolygon(this, drawflags);
            }
        }
Exemple #6
0
        public override void draw(cGraphics pgraphics, int drawflags = 0)
        { /* Use the base _spriteattitude and then walk the array of child sprites and call their
		imagedraw methods.  Don't try and imagedraw the base cSprite, as it's only there to hold
		the _spriteattitude.  Note that the cSpriteShowOneChild child class only cascades 
		the imagedraw to one child. */
            pgraphics.pushMatrix();
            pgraphics.multMatrix(_spriteattitude);
            /* For now, let's not try and use display lists for the composites, but only for the
        individual pieces. */
            foreach (cSprite s in _childspriteptr)
                _childspriteptr.ElementAt().draw(pgraphics, drawflags); //If there happen to be any.
            //If you don't want to draw the first sprite, like wiht a polypoly, start with i at 1, 
            pgraphics.popMatrix();
        }
Exemple #7
0
 public override void draw(cGraphics pgraphics, int drawflags = 0)
 {
     if (_armed) /* The gun looks bad if
                  * you're near the edge in 2D	graphics as it doesn't get clipped. */
     {
         /* We draw the "gun" as a line.  It might be better to have the following
          * code be part of the cSprite.drawing, because then that would happen while the
          * pDC is clipped in the cCritter call.  One way to do it would be to have a CpopView.DF_GUN
          * drawflag. */
         cVector3 start = _position;
         cVector3 end   = start.add(_aimvector.mult(_gunlength * Radius));
     }
     base.draw(pgraphics, drawflags);
     //Draw sprite on top of gun line.
 }
Exemple #8
0
        public override void imagedraw(cGraphics pgraphics, int drawflags)
        {
            if ((Edged & !Filled) || ((drawflags & ACView.DF_WIREFRAME) != 0))

            /* If the sphere is filled, lets not draw its edges unless we're in wireframe
             * The reason I put this in is because in many games the sprite by default is
             * edged and filled for the sake of the polygonal sprites, and then if we select
             * a sphere sprite and its edged as well as filled it runs too slow. */
            {
                pgraphics.setMaterialColor(LineColor);
                glshape.glutWireSphere(_radius, _slices, _stacks);
            }
            if (Filled && ((drawflags & ACView.DF_WIREFRAME) == 0))
            {
                pgraphics.setMaterialColor(FillColor);
                glshape.glutSolidSphere(_radius, _slices, _stacks);
            }
        }
Exemple #9
0
        }                                                                                          //Used by cSpriteQuake constructor and setRadius.

        /* Used by cGraphicsOpenGL::selectSkinTexture in
         *  the cGraphicsOpenGL::interpolateAndRender method. */

        /* Used by cGraphicsOpenGL::selectSkinTexture. */
        //Individual Instance Methods

        public int Animate(cGraphics pgraphics, int startFrame, int endFrame, float percent)
        {
            if ((startFrame > _currentFrame))
            {
                _currentFrame = startFrame;
            }
            if ((startFrame < 0) || (endFrame < 0))
            {
                return(-1);
            }
            if ((startFrame >= NumFrames) || (endFrame >= NumFrames))
            {
                return(-1);
            }
            if (_interpol >= 1.0f)
            {
                _interpol = 0.0f;
                _currentFrame++;
                if (_currentFrame >= endFrame)
                {
                    _currentFrame = startFrame;
                }
                _nextFrame = _currentFrame + 1;
                if (_nextFrame >= endFrame)
                {
                    _nextFrame = startFrame;
                }
            }

            cMD2Info pinfo = MD2Info;
            int      numvertsperframe = pinfo.numVertices;
            int      startframe, endframe;

            startframe = numvertsperframe * _currentFrame;
            endframe   = numvertsperframe * _nextFrame;
            pgraphics.interpolateAndRender(this, pinfo.vertexList, startframe, endframe, _interpol);

            _interpol += percent; // increase percentage of interpolation between frames

            return(0);
        }
        public virtual void draw(cGraphics pgraphics, int drawflags)
        { /* This is an example of the Template Method.  For the primitive (non-composite)
           *     sprites we only overload the imagedraw method and use this template code. */
            if ((drawflags & ACView.DF_WIREFRAME) != 0)
            {
                if (this is cSpriteQuake)
                {
                    cSpriteSphere sphere = new cSphere(_radius, Color.DarkGreen);
                    sphere.LineColor = Color.Black;
                    sphere.draw(pgraphics, drawflags);
                }
            }
            pgraphics.pushMatrix();
            pgraphics.multMatrix(_spriteattitude);

            /* If I don't have UNCONDITIONAL_ADJUSTATTRIBUTES turned on in
             * cGraphicsOpenGL, then I should actually call pgraphics.adjustAttributes(this);
             * right here instead of down inside the display list --- see the comment where
             * UNCONDITIONAL_ADJUSTATTRIBUTES is defined. */
            if (EnabledDisplayList && pgraphics.SupportsDisplayList)
            {
                if (!pgraphics.activateDisplayList(this)) /* If you plan to use display lists,
                                                           * look if one's ready, and if not, open one and draw into it. */
                {
                    pgraphics.adjustAttributes(this);     //See comment above.
                    imagedraw(pgraphics, drawflags);
                }
                pgraphics.callActiveDisplayList(this); //Now call the display list.
            }
            else //Not trying to use display lists for this kind of sprite.  Just draw it.
            {
                pgraphics.adjustAttributes(this); //See comment above.
                imagedraw(pgraphics, drawflags);
            }
            pgraphics.popMatrix();
            //After the draw, tell the sprite that its current geometry has now been drawn once.
            NewGeometryFlag = false; /* This is for use by the cGraphicsOpenGL for
                                      * knowing when it may need to change any display list id being used for the sprites.  */
        }
 public override void imagedraw(cGraphics pgraphics, int drawflags)
 {
     /*
      * if (( Edged & !Filled ) || ( (drawflags & ACView.DF_WIREFRAME) != 0 ))
      *          {
      *                  pgraphics.setMaterialColor( LineColor );
      *                  glshape.glutWireSphere( _radius, _slices, _stacks );
      *          }
      *          if ( Filled && ( (drawflags & ACView.DF_WIREFRAME) == 0 ))
      *          {
      *                  pgraphics.setMaterialColor( FillColor );
      *                  glshape.glutSolidSphere( _radius, _slices, _stacks );
      *          }
      */
     pgraphics.setMaterialColor(LineColor);
     glshape.glutWireSphere(_radius, _slices, _stacks);
     if (Filled)
     {
         pgraphics.setMaterialColor(FillColor);
         glshape.glutSolidSphere(_radius, _slices, _stacks);
     }
 }
Exemple #12
0
        //list-walking methods.
        public virtual void draw(cGraphics pgraphics, int drawflags = 0)
        {
            cCritter pcritter;

            /* The critters should be drawn from the end of the list to the beginning of
             * the list.  I did not make the LinkedList doubly-linked, so that we don't
             * use an extra pointer's worth of space for each member.  The LinkedList has
             * an indexer, which would allows us to uses indexes to go from the back of
             * the list to the front, but this would end up being theta-n-squared.  So
             * I ended up using making a list in reverse order first.  Thus, this function
             * is theta-n instead of theta-n-squared, a significant savings in time.  -- JC */

            LinkedList <cCritter> reverseList = new LinkedList <cCritter> (
                delegate(out cCritter c1, cCritter c2)
            {
                c1 = c2;
            });

            foreach (cCritter c in this)
            {
                reverseList.InsertAt(0, ElementAt());
            }

            foreach (cCritter c in reverseList)   /* Draw the lower-numbered critters last,
                                                   * so those are visually "on top".)*/
            {
                pcritter = reverseList.ElementAt( );
                if (pcritter == null)
                {
                    return;
                }
                pcritter.draw(pgraphics, drawflags);
                if (pcritter == _pgame.pFocus())
                {
                    pcritter.drawHighlight(pgraphics, cSprite.HIGHLIGHTRATIO);
                }
            }
        }
Exemple #13
0
 public virtual void drawBackground(cGraphics pgraphics, int drawflags)
 {
     /* I'm going to interpret the DF_FULL_BACKGROUND flag
      * as meaning draw the solid skybox, and I'm going to interpret
      * the DF_SIMPLIFIED_BACKGROUND as meaning draw a wireframe skybox.
      * I don't make a separate case for !pgraphics()->is3D, as in that
      * case my cSpriteTexturebox.draw just calls
      * call _childspriteptr[LOZ]->draw(pgraphics, drawflags);*/
     if ((drawflags & ACView.DF_FULL_BACKGROUND) != 0)
     {
         drawflags &= ~ACView.DF_WIREFRAME; //turn off wireframe
         _pskybox.draw(pgraphics, drawflags);
     }
     else if ((drawflags & ACView.DF_SIMPLIFIED_BACKGROUND) != 0)
     {
         drawflags |= ACView.DF_WIREFRAME; //turn on wireframe
         if (_pskybox != null)
         {
             _pskybox.draw(pgraphics, drawflags);
         }
     }
     //else don't draw SIMPLIFIED or FULL background, that is, draw nothing.
 }
Exemple #14
0
        /* Call the
         *  _pbiota draw to walk the array. */
        //Special Methods you are likely to overload

        public virtual void drawWorld(cGraphics pgraphics, int drawflags)
        {
            drawBackground(pgraphics, drawflags); //Uses skybox
        }
Exemple #15
0
 public virtual void drawCritters(cGraphics pgraphics, int drawflags)
 {
     _pbiota.draw(pgraphics, drawflags);
 }
Exemple #16
0
 public override void imagedraw(cGraphics pgraphics, int drawflags)
 {
     pgraphics.setMaterialColor(FillColor, .6f);
     pgraphics.selectTexture(new cTexture(BitmapRes.Fire, true));
     glshape.glutSolidSphere(_radius, _slices, _stacks);
 }
 //override the draw method to do nothing so that the floor is invisible.
 public override void draw(cGraphics pgraphics, int drawflags = 0)
 {
 }
        }                                                          /* Might choose sprite
                                                                    * based on age, change the radius of the sprite with time, or choose a sprite based
                                                                    * on direction or health of powner, or maybe spin. */

        public virtual void draw(cGraphics pgraphics)
        {
            draw(pgraphics, 0);
        }
Exemple #19
0
        // render model with interpolation to get animation

        public int RenderFrame(cGraphics pgraphics, int keyFrame)
        {
            return(Animate(pgraphics, keyFrame, keyFrame, 0.0f));
        }
Exemple #20
0
        /* This virtual helper method is needed
         *  because I plan to use _resourceID in cBiota::Add to see if
         *  two sprites use the same textures.  A cSpriteQuake will set a
         *  _resoruceID keyed to its skin file. */

        /* enabledisplaylist specifies whetehr or not you want to
         *  try and use a display list to show this kind of sprite. By default this is TRUE.  We
         *  make it FALSE because the cSpriteIcon actually runs slower with displaylists, so we
         *  want to be able turn of display lists for them.  */

        public override void imagedraw(cGraphics pgraphics, int drawflags)
        {
            if (_pModel == null)
            {
                base.imagedraw(pgraphics, drawflags); //Use the baseclass draw (a circle)
                return;
            }
            // set interpolation between keyframes
            float percent;

            //percent = 0.2;
            if (_dt > 0.00001f)
            {
                //	percent = 0.001 * _framerate / _dt;
                percent = _framerate * _dt;
            }

            /* Want to get a number around 0.1
             * to 0.3 range.  I stick in the 0.001 multiplier so that "_framerate"
             * can be a reasonable kind of number like 2 or 3 */
            else
            {
                percent = 0.2f;
            }

            /*
             * Frame#  Action
             * ----------------
             * 0-39    idle
             * 40-46   running
             * 47-60   getting shot but not falling (back bending)
             * 61-66   getting shot in shoulder
             * 67-73   jumping
             * 74-95   idle
             * 96-112  getting shot and falling down
             * 113-122 idle
             * 123-135 idle
             * 136-154 crouch
             * 155-161 crouch crawl
             * 162-169 crouch adjust weapon (idle)
             * 170-177 kneeling dying
             * 178-185 falling back dying
             * 186-190 falling forward dying
             * 191-198 falling back slow dying
             */

            // set current model animation state
            _pModel.ModelState = _modelState;
            if (_modelState != _lastModelState)
            {
                _lastModelState        = _modelState;
                _pModel.AnimatePercent = 0.0f;
                statelock = false;
            }
            // perform animation based on model state
            switch (_pModel.ModelState)
            {
            case State.Idle:
                _pModel.Animate(pgraphics, 0, 39, percent);
                break;

            case State.Run:
                _pModel.Animate(pgraphics, 40, 46, percent);
                break;

            case State.ShotButStillStanding:
                _pModel.Animate(pgraphics, 47, 60, percent);
                break;

            case State.ShotInShoulder:
                _pModel.Animate(pgraphics, 61, 66, percent);
                break;

            case State.Jump:
                _pModel.Animate(pgraphics, 67, 73, percent);
                break;

            case State.ShotDown:
                _pModel.Animate(pgraphics, 96, 112, percent);
                break;

            case State.Crouch:
                _pModel.Animate(pgraphics, 136, 154, percent);
                break;

            case State.CrouchCrawl:
                _pModel.Animate(pgraphics, 155, 161, percent);
                break;

            case State.CrouchWeapon:
                _pModel.Animate(pgraphics, 162, 169, percent);
                break;

            case State.KneelDying:
                _pModel.Animate(pgraphics, 170, 171, percent);
                break;

            case State.FallbackDie:
                if ((_pModel.AnimatePercent < 1.0f ||
                     _pModel.CurrentFrame + 1 < _endframe) && !statelock)
                {
                    _pModel.AnimateHold(pgraphics, 178, 185, percent);
                }
                else
                {
                    _pModel.RenderFrame(pgraphics, 183);
                    statelock = true;
                }
                break;

            case State.FallForwardDie:
                if ((_pModel.AnimatePercent < 1.0f ||
                     _pModel.CurrentFrame + 1 < _endframe) && !statelock)
                {
                    _pModel.AnimateHold(pgraphics, 186, 190, percent);
                }
                else
                {
                    _pModel.RenderFrame(pgraphics, 189);
                    statelock = true;
                }
                break;

            case State.Other:
                if (_stateType == StateType.Hold)
                {
                    if ((_pModel.AnimatePercent < 1.0f ||
                         _pModel.CurrentFrame + 1 < _endframe) && !statelock)
                    {
                        _pModel.AnimateHold(pgraphics, _begframe, _endframe, percent);
                    }
                    else
                    {
                        _pModel.RenderFrame(pgraphics, _endframe);
                        statelock = true;
                    }
                }
                else if (_stateType == StateType.Repeat)
                {
                    _pModel.Animate(pgraphics, _begframe, _endframe, percent);
                }
                break;

            default:
                break;
            }
        }
Exemple #21
0
 public override void draw(cGraphics pgraphics, int drawflags = 0)
 {
     base.draw(pgraphics, drawflags);
 }