Ribbons Projectiles And Objects Resource

  • 1
  • 2
11 posts Page 1 of 2
Steve_Yorkshire
Posts: 202
Joined: Tue Feb 03, 2015 10:30 pm
 
  by Steve_Yorkshire » Thu Feb 12, 2015 7:03 pm

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
}
}
}


Image
Gibby
Posts: 72
Joined: Wed Feb 11, 2015 2:40 pm
by Gibby » Fri Feb 13, 2015 4:09 am
@Steve: Muchimas Gracias! Dunno why I wasn't able to get the ribbon to mount to the weapon - seems to work fine now using your scripts...
8bitprodigy
Posts: 13
Joined: Fri Feb 06, 2015 6:43 pm
by 8bitprodigy » Fri Feb 13, 2015 6:03 am
Could you possibly upload another version of the video, but this time all the trails are the Nyan Cat trail and everything makes the Nyan Cat song when it's moving? Even the Cheetah, but only when it's moving.

Thanks in advance.
Steve_Yorkshire
Posts: 202
Joined: Tue Feb 03, 2015 10:30 pm
 
by Steve_Yorkshire » Fri Feb 13, 2015 11:01 pm
@
User avatar
8bitprodigy
Well volunteered to accept this important assignment yourself! ;)
Gibby
Posts: 72
Joined: Wed Feb 11, 2015 2:40 pm
by Gibby » Thu Mar 26, 2015 6:30 pm
the create function needs to look like this:

Code: Select all

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;
}
Steve_Yorkshire
Posts: 202
Joined: Tue Feb 03, 2015 10:30 pm
 
by Steve_Yorkshire » Thu Mar 26, 2015 9:47 pm
"Emitter" works fine for me in v3.6.2 with the code files I'm using.
highground
Posts: 1
Joined: Fri Mar 27, 2015 4:20 am
by highground » Fri Mar 27, 2015 4:22 am
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<T>::set' : cannot convert 'this' pointer


Etc....Has anyone else experienced this??
Steve_Yorkshire
Posts: 202
Joined: Tue Feb 03, 2015 10:30 pm
 
by Steve_Yorkshire » Fri Mar 27, 2015 5:48 pm
@
User avatar
highground

My bad! I forgot to include the source/gfx/gfxVertexTypes.cpp/h changes. :oops:

I've updated the zip file so if you redownload it the new code files will be there.
Gibby
Posts: 72
Joined: Wed Feb 11, 2015 2:40 pm
by Gibby » Fri Mar 27, 2015 7:08 pm
@Steve: I think that was what had held me up for a day, I had it working fine per your instructions in 3.6.1 but had to change it to work with 3.7+
jnovosel
Posts: 1
Joined: Sat Jan 02, 2016 4:00 pm
by jnovosel » Sat Jan 02, 2016 4:20 pm
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?
  • 1
  • 2
11 posts Page 1 of 2

Who is online

Users browsing this forum: No registered users and 1 guest