Announcement

Collapse
No announcement yet.

My Canvas HUD code to Draw a Variable Thick 3D Line

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • replied
    That's awesome dude!Just like the watch dogs effect


    Sent from my iPhone using Tapatalk

    Leave a comment:


  • My Canvas HUD code to Draw a Variable Thick 3D Line

    Dear Community,

    I am not aware of any Canvas/HUD class code to draw a THICK 3D line

    You can draw 2D lines that have thickness and even map them to 3D space, but I did not find that desirable or visually appealing

    so I wrote my own THICK 3D Line code!

    I hope you can make use of this code!

    Let me know if you like it!




    Code:
    function drawThicker(vector v1, vector v2, color c, int PosFromCenter) {
    	local vector start;
    	local vector end;
    	
    	//so we can modify
    	start = v1;
    	end = v2;
    	
    	start.x += PosFromCenter;
    	end.x += PosFromCenter;
    	draw3DLine(start, end, c);
    	
    	start.y += PosFromCenter;
    	end.y += PosFromCenter;
    	draw3DLine(start, end, c);
    	
    	start.z += PosFromCenter;
    	end.z += PosFromCenter;
    	draw3DLine(start, end, c);
    	
            //since we modified with +=
            //must *2 to get to other side of
           //center
    	start.x -= PosFromCenter*2;
    	end.x -= PosFromCenter*2;
    	draw3DLine(start, end, c);
    	
    	start.y -= PosFromCenter*2;
    	end.y -= PosFromCenter*2;
    	draw3DLine(start, end, c);
    	
    	start.z -= PosFromCenter*2;
    	end.z -= PosFromCenter*2;
    	draw3DLine(start, end, c);
    }
    function drawThickLine(vector v1, vector v2, color c, int thickness) {
    	local int thickIncrement;
    	
    	//center of line
    	draw3DLine(v1, v2, c);
    	
    	//draw surrounding layers of thickness from center
    	for (thickIncrement = 1; thickIncrement <= thickness; thickIncrement++ ) {
    		drawThicker(v1, v2, c, thickIncrement);
    	}
    
    }
    You call the function like this

    Code:
    //inside your custom HUD class
    
    DrawHUD()
    {
    //need a color struct
    local color c;
    
    //set color
    c.R = 255; c.G = 0; c.B = 0; c.A = 255;
    drawThickLine(someActor.Location, anotherActor.Location, c, 6);
    }

    Let me know if this helps you!



    Rama

    PS: Spoof is awesome.

    He has helped me on numerous occasions

    I now have my own udk game up and running, where you can build a world within my own in-game 3D editor! And you can save/load levels from hard disk, even after turning computer off! all this without ever opening the UDK. More than 150,000 lines of Unreal Script code involved
Working...
X