Jump to content


Photo

Easy Roads 3


  • Please log in to reply
27 replies to this topic

#21 Stingreye

Stingreye

    Advanced Member

  • Members
  • PipPipPip
  • 137 posts
  • LocationSouthern California

Posted 24 February 2019 - 07:24 PM

I'm doing the Blender cart paths and so far, I'm digging them.
Now mind you, the powers that be, I hope, are working on pieces for a "Y" but for now, these babies stick right to the ground and join seamlessly.
Just throwing that out there.

Peace

1dy4FHv.png


Those look VERY nice!
  • axe360 likes this

#22 clubcaptain

clubcaptain

    Advanced Member

  • Members
  • PipPipPip
  • 1,152 posts

Posted 02 April 2019 - 12:07 AM

using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using EasyRoads3Dv3;
using EasyRoads3Dv3Editor;

public class ERAPIEditor : ScriptableObject {

	[MenuItem( "EasyRoads3D/Custom Road Shape" )]
	public static void   RefreshRoad() 
	{
		ERRoad road = EREditor.GetSelectedRoad();

		if(road != null){

			List<Vector2> shape = new List<Vector2>();
			List<float> uv = new List<float>();
			List<bool> tris = new List<bool>();

			shape.Add(new Vector2(3f,0f));
			uv.Add(1f);
			tris.Add(true);

			shape.Add(new Vector2(2.9f,0.05f));
			uv.Add(0.99f);
			tris.Add(true);

			shape.Add(new Vector2(0f,0.1f));
			uv.Add(0.5f);
			tris.Add(true);

			shape.Add(new Vector2(-2.9f,0.05f));
			uv.Add(0.01f);
			tris.Add(true);

			shape.Add(new Vector2(-3f,0f));
			uv.Add(0f);
			tris.Add(true);

			road.roadScript.roadShape = new List<Vector2>(shape);
			road.roadScript.roadShapeUVs = new List<float>(uv);
			road.roadScript.doConnectionTri = new List<bool>(tris);

			road.roadScript.isCustomRoad = true;

			foreach(ERMarkerExt m in road.roadScript.markersExt){
				m.roadShape = new List<Vector2>(shape);
			}

			road.Refresh();

		}else{
			Debug.Log("Please select a road object first");
		}
		Debug.Log("done");
	}

}

Thats the script.  You can see the variables in how it adds the Vector2. 

EDIT: also, I think the file I posted has the comments removed, but you need to remove the comments before using

EasyRoads3Dv3;

using EasyRoads3Dv3Editor;

I removed them in the script above.

EDIT2:  Ok with the help of Shimonko,  he helped me understand the script.

So with the script above the following is the graphic Shimonko gave me to help understand the road.

unknown.png

 

And here is a sketchup I did to show how the variables are linked,  its not pretty but helps me understand it.

unknown.png

 

And then even with that great explanation and thinking I understood it, I still managed to mess it up but Shimonko was patient and helped me with it.

Here is the modified code that will work for cart paths that are 3 wide like mine.

using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using EasyRoads3Dv3;
using EasyRoads3Dv3Editor;

public class ERAPIEditor : ScriptableObject {

	[MenuItem( "EasyRoads3D/Custom Road Shape" )]
	public static void   RefreshRoad() 
	{
		ERRoad road = EREditor.GetSelectedRoad();

		if(road != null){

			List<Vector2> shape = new List<Vector2>();
			List<float> uv = new List<float>();
			List<bool> tris = new List<bool>();

			shape.Add(new Vector2(1.5f,0f));
			uv.Add(1f);
			tris.Add(true);

			shape.Add(new Vector2(1.4f,0.1f));
			uv.Add(0.99f);
			tris.Add(true);

			shape.Add(new Vector2(0f,0.1f));
			uv.Add(0.5f);
			tris.Add(true);

			shape.Add(new Vector2(-1.4f,0.1f));
			uv.Add(0.01f);
			tris.Add(true);

			shape.Add(new Vector2(-1.5f,0f));
			uv.Add(0f);
			tris.Add(true);

			road.roadScript.roadShape = new List<Vector2>(shape);
			road.roadScript.roadShapeUVs = new List<float>(uv);
			road.roadScript.doConnectionTri = new List<bool>(tris);

			road.roadScript.isCustomRoad = true;

			foreach(ERMarkerExt m in road.roadScript.markersExt){
				m.roadShape = new List<Vector2>(shape);
			}

			road.Refresh();

		}else{
			Debug.Log("Please select a road object first");
		}
		Debug.Log("done");
	}

}

I personally like the thicker road look and it should provide more forgiveness from floating roads that can happen with EasyRoads.

 

Some more pics: path with spline off:

unknown.png

 

Path with spline on:

 

unknown.png

 

A great view of what this script actually does (you will notice shimonko's drawing mimics this).

unknown.png

 

NOTE: I think it causes trouble with pefab connnections, so depending on how you do your connections (I don't use connectors yet).

 

Matt, I think this will work with free version of v3.0.  I don't see why it wouldn't.  Let me know if you have any questions. Please note I am still a rookie with unity, CF, and easyroads.

 

How do you implement this script. Do you place it as it is shown above into standard assets/scripts or does it need to be in it's own folder in standard assets/scripts. Does this script provide a drawing and editing facility or does some version of Easy Roads (not V 3) also need to be installed ?


PC specs...

Intel core I73770k 3.5 GHZ
16 Gb Corsair vengeance DDR3 1600MHZ/PC12800
Asus mobo PB8277-V Lx
Nvidea GeForce GTX970 4GB
X box 360 wired controller
Windows 10 home  64 bit


#23 Stingreye

Stingreye

    Advanced Member

  • Members
  • PipPipPip
  • 137 posts
  • LocationSouthern California

Posted 02 April 2019 - 12:11 AM

How do you implement this script. Do you place it as it is shown above into standard assets/scripts or does it need to be in it's own folder in standard assets/scripts. Does this script provide a drawing and editing facility or does some version of Easy Roads (not V 3) also need to be installed 

This script I stopped using.  I am attempting to learn the method DPRoberts describes using blender.  Seems to be much better, here is his video.

https://www.youtube....h?v=rq1uS_XTZRs



#24 Stingreye

Stingreye

    Advanced Member

  • Members
  • PipPipPip
  • 137 posts
  • LocationSouthern California

Posted 02 April 2019 - 02:38 AM

How do you implement this script. Do you place it as it is shown above into standard assets/scripts or does it need to be in it's own folder in standard assets/scripts. Does this script provide a drawing and editing facility or does some version of Easy Roads (not V 3) also need to be installed ?

OK I went back and verified.  IN your assets folder there will be amn EasyRoads3D Folder then inside that the editor:

 

so Project/Assets/EasyRoads3D/Editor/

The script is called ERAPIEditor.cs

 

It will add a new menu option on the top menu bar in unity.  Let me know if you have any trouble.



#25 clubcaptain

clubcaptain

    Advanced Member

  • Members
  • PipPipPip
  • 1,152 posts

Posted 02 April 2019 - 11:13 AM

Presumably that's the free edition ?


PC specs...

Intel core I73770k 3.5 GHZ
16 Gb Corsair vengeance DDR3 1600MHZ/PC12800
Asus mobo PB8277-V Lx
Nvidea GeForce GTX970 4GB
X box 360 wired controller
Windows 10 home  64 bit


#26 Stingreye

Stingreye

    Advanced Member

  • Members
  • PipPipPip
  • 137 posts
  • LocationSouthern California

Posted 02 April 2019 - 01:55 PM

Presumably that's the free edition ?

I was using the professional version. I have no idea if it works with the free one.

#27 clubcaptain

clubcaptain

    Advanced Member

  • Members
  • PipPipPip
  • 1,152 posts

Posted 02 April 2019 - 02:40 PM

I thought that V3 wasn't available for our version of Unity. You're saying the current version of EasyRoads 3D Pro  works fine with 5.2.3


PC specs...

Intel core I73770k 3.5 GHZ
16 Gb Corsair vengeance DDR3 1600MHZ/PC12800
Asus mobo PB8277-V Lx
Nvidea GeForce GTX970 4GB
X box 360 wired controller
Windows 10 home  64 bit


#28 Stingreye

Stingreye

    Advanced Member

  • Members
  • PipPipPip
  • 137 posts
  • LocationSouthern California

Posted 02 April 2019 - 02:50 PM

Shoot me a PM. I kept the install file for version 3.0 which works with our version of unity. You still need the license code from easy roads fornit to work. Version 3.0 works with our version of unity. Also, I think if you extract the DLL’s from the newer version you can upgrade it to a newer version too.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users