Steve_Yorkshire Posted February 12, 2015 Share Posted February 12, 2015 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.zipMake 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.csnew 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 Quote Link to comment Share on other sites More sharing options...
Gibby Posted February 13, 2015 Share Posted February 13, 2015 @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... Quote Link to comment Share on other sites More sharing options...
8bitprodigy Posted February 13, 2015 Share Posted February 13, 2015 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. Quote Link to comment Share on other sites More sharing options...
Steve_Yorkshire Posted February 13, 2015 Author Share Posted February 13, 2015 @8bitprodigy Well volunteered to accept this important assignment yourself! ;) Quote Link to comment Share on other sites More sharing options...
Gibby Posted March 26, 2015 Share Posted March 26, 2015 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; } Quote Link to comment Share on other sites More sharing options...
Steve_Yorkshire Posted March 26, 2015 Author Share Posted March 26, 2015 "Emitter" works fine for me in v3.6.2 with the code files I'm using. Quote Link to comment Share on other sites More sharing options...
highground Posted March 27, 2015 Share Posted March 27, 2015 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?? Quote Link to comment Share on other sites More sharing options...
Steve_Yorkshire Posted March 27, 2015 Author Share Posted March 27, 2015 @highgroundMy 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. Quote Link to comment Share on other sites More sharing options...
Gibby Posted March 27, 2015 Share Posted March 27, 2015 @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+ Quote Link to comment Share on other sites More sharing options...
jnovosel Posted January 2, 2016 Share Posted January 2, 2016 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? Quote Link to comment Share on other sites More sharing options...
Johxz Posted January 2, 2016 Share Posted January 2, 2016 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.