Jump to content

Ribbons Projectiles And Objects Resource


Recommended Posts

s12zj4WQKa0

90% of the code comes from Tim at MaxGaming for TGE/A, 10% from myself to get it working in Torque3D.

http://www.yorkshirerifles.com/downloads/ribbons_Torque3D.zip


Make sure you've got ribbon.cpp/h and ribbonNode.cpp/h in T3D/fx and the ribbon shaders basicRibbonShaderP/V.hlsl in shaders/ribbons.


ribbons.cs goes in art/datablocks, don't forget to exec it in art/datablocks/datablockExec.cs.


ribbons.cs

new ShaderData( basicRibbonShader )
{
   DXVertexShaderFile   = "shaders/ribbons/basicRibbonShaderV.hlsl";
   DXPixelShaderFile    = "shaders/ribbons/basicRibbonShaderP.hlsl";
 
   pixVersion = 2.0;
};
 
//custom material////////////////////////////////////
 
singleton CustomMaterial( basicRibbonGlow )
{
   shader = basicRibbonShader;
   version = 2.0;
 
   emissive[0] = true;
   glow[0] = true;
 
   doubleSided = false;
   translucent = true;
   BlendOp = AddAlpha;
   translucentBlendOp = AddAlpha;
 
   preload = false;//yorks
};
 
//ribbon data////////////////////////////////////////
 
datablock RibbonData(basicRibbon)
{
	category = "Misc";
 
   size[0] = 0.8;
   color[0] = "1.0 0.3 0.0 1.0";
   position[0] = 1.0;
 
   size[1] = 0;
   color[1] = "1.0 0 0.0 0.0";
   position[1] = 0.0;
 
   RibbonLength = 6;
   fadeAwayStep = 0.25;
   RibbonMaterial =  basicRibbonGlow;
};
 
datablock RibbonData(longRibbon)
{
   size[0] = 0.5;
   color[0] = "0.6 0.7 0.8 1.0";
   position[0] = 1.0;
 
   size[1] = 0.25;
   color[1] = "0.6 0.7 0.8 0.5";
   position[1] = 0.5;
 
   size[2] = 0;
   color[2] = "0.6 0.7 0.8 0.0";
   position[2] = 0.0;
 
   RibbonLength = 40;
   fadeAwayStep = 0.25;
   UseFadeOut = true;
   RibbonMaterial = basicRibbonGlow;
};
 
datablock RibbonData(amberRibbon)
{
   size[0] = 0.2;
   color[0] = "1.0 0.65 0.1 1.0";
   position[0] = 1.0;
 
   size[1] = 0;
   color[1] = "1.0 0.65 0.1 0.0";
   position[1] = 0.0;
 
   RibbonLength = 30;
   fadeAwayStep = 0.25;
   UseFadeOut = true;
   RibbonMaterial = basicRibbonGlow;
};
 
datablock RibbonData(greenRibbon)
{
   size[0] = 0.2;
   color[0] = "0.0 1.0 0.0 1.0";
   position[0] = 1.0;
 
   size[1] = 0;
   color[1] = "0.0 1.0 0.0 0.0";
   position[1] = 0.0;
 
   RibbonLength = 30;
   fadeAwayStep = 0.25;
   UseFadeOut = true;
   RibbonMaterial = basicRibbonGlow;
};
 
datablock RibbonNodeData(DefaultRibbonNodeData)
{
   timeMultiple = 1.0;
};
 
function createRibbon(%emitter, %pos)
{
   %r = new RibbonNode()
   {
      datablock = DefaultRibbonNodeData;
      emitter = %emitter;
      position = %pos;
   };
   if(isObject(MissionCleanup))
      MissionCleanup.add(%r);
 
   return %r;
}

 

scripts/server/weapon.cs weaponImage::onFire function at the end.

 

// Create the projectile object
      %p = new (%this.projectileType)()
      {
         dataBlock = %this.projectile;
         initialVelocity = %muzzleVelocity;
         initialPosition = %obj.getMuzzlePoint(%slot);
         sourceObject = %obj;
         sourceSlot = %slot;
         client = %obj.client;
         sourceClass = %obj.getClassName();
      };
      MissionCleanup.add(%p);
 
	  //yorks we now have a projectile so let's attach a ribbon to it
	    %ribbon = createRibbon(longRibbon, %obj.getMuzzlePoint(%slot));
        %p.mountObject(%ribbon, 0);
   }
}

 

Next lets add some ribbons to the Cheetah. scripts/server/cheetah.cs, onAdd function

// Mount the brake lights
   %obj.mountObject(%obj.rightBrakeLight, %this.rightBrakeSlot);
   %obj.mountObject(%obj.leftBrakeLight, %this.leftBrakeSlot);
 
   //yorks add ribbons!
   %ribbon1 = createRibbon(amberRibbon, %obj.getTransform());
   %ribbon2 = createRibbon(greenRibbon, %obj.getTransform());
 
   %obj.mountObject(%ribbon1, %this.rightBrakeSlot);
   %obj.mountObject(%ribbon2, %this.leftBrakeSlot);

 

And make sure we don't get console spam when the vehicle is removed.

scripts/server/vehicle.cs VehicleData::onRemove function

 

function VehicleData::onRemove(%this, %obj)
{
   //echo("\c4VehicleData::onRemove("@ %this.getName() @", "@ %obj.getClassName() @")");
 
   // if there are passengers/driver, kick them out
   for(%i = 0; %i < %obj.getDatablock().numMountPoints; %i++)
   {
      if (%obj.getMountNodeObject(%i))
      {
         %passenger = %obj.getMountNodeObject(%i);
         if(isMethod(%passenger, doDismount))//yorks in
            %passenger.getDataBlock().doDismount(%passenger, true);
         else//yorks in
            %passenger.delete();//yorks in for ribbons etc
      }
   }
}

 

http://www.yorkshirerifles.com/random/ribbons_cheetah.jpg

Link to post
Share on other sites
  • 1 month later...

the create function needs to look like this:

function createRibbon(%emitter, %pos)
{
  %r = new RibbonNode()
  {
     datablock = DefaultRibbonNodeData;
     Ribbon = %emitter;  //Gibby should be 'Ribbon' not 'emitter'
     position = %pos;
  };
  if(isObject(MissionCleanup))
     MissionCleanup.add(%r);

  return %r;
}

Link to post
Share on other sites

Hey Steve, followed instructions, go to compile the engine and get 42 errors???


01.'GFXVertexPCNTT' : undeclared identifier

02.'GFXVertexPCNTT' : undeclared identifier

03.'GFXVertexBufferHandle' : no appropriate default constructor available

04.'GFXVertexPCNTT' : undeclared identifier

05.'const GFXVertexFormat *getGFXVertexFormat(void)' : could not deduce template argument for 'T'

06.'GFXVertexPCNTT' : undeclared identifier

07.'GFXVertexBufferHandle::set' : cannot convert 'this' pointer



Etc....Has anyone else experienced this??

Link to post
Share on other sites
  • 9 months later...

Using the 3.8 codebase I added ribbons to my projectiles and have noticed a strange side effect - shooting bullets into the terrain leaves a RibbonNode object at the point of impact for each projectile. Jump into mission edit mode after shooting some of these into the ground to see them. I modified the projectile.cs onExplode and onCollision script files to delete the ribbon. Seems to work but then thought about the projectiles that are shot into the air and hit nothing - are those ribbons being deleted when the projectile gets cleaned up. Checked the projectile.cpp code and added similar code to Projectile::onRemove() to check for the ribbon when the projectile gets deleted but this is sometimes crashing..not sure if removefromScene or Parent::onRemove handle the ribbon or not. Not sure of the implications of having tons of ribbonodes laying around but it can't be good.

Anyone else notice this?

Link to post
Share on other sites
then thought about the projectiles that are shot into the air and hit nothing - are those ribbons being deleted when the projectile gets cleaned up

 

no sorry I not notice, I have not played with ribbons yet... but what you say makes sense. It would have to do more tests.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...