Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Skflowne · Aug 11, 2015 at 02:19 AM · modelcurveracingcurved path

How to generate a curve from a model ?

I have a road model which is a long looped curve made in Blender then exported to FBX.

To make this model, I have created a path and then repeated a portion of road all over it.

Now for my game, I need to get this path back so I can create two lanes for my IAs and player to follow.

I would like to know if it would be possible to extract this path from the model topology via script and if so how ?

That would be ideal so that when I make changes to my model, the paths can be recreated again automatically.

If not possible I'd like to know how I could create those paths otherwise visually in the editor ?

This is the model I'm talking about :

alt text

road.jpg (343.2 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by stepan-stulov · Aug 11, 2015 at 07:56 AM

In order for it to be possible the mesh would have to follow some very strict conventions about order of vertices, how they're paired, etc. So that a pattern could be recognised and you could somehow iterate over mesh sections and take sections' mid-points as you spline's key points. Something tells me this mesh is not one of such. And analysing ambiguously modelled mesh — you don't want to be there with your game, unless you're working on a next PhD about topologies etc.

What I advise instead is to flip you workflow. Don't base an abstract mathematical model on a fuzzy human-made mesh. Create the spline first and generate the road mesh (perhaps by "skinning" the spline with mesh segments) from it then. This will solve the problem of analytical representation of your road as well as will dramatically improve iterations on adjusting curvatures etc. In fact such approach is very "traditional".

Not the worst scenario (looking at the complexity of your track) would also be to create the spline by hand with the road being under it as a visual guide.

Hope this helps.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Skflowne · Aug 11, 2015 at 08:35 PM 0
Share

So what you're saying is I should create the spline in Unity or have a mathemathical representation of it anyway and then import this into blender to generate the mesh ?

avatar image stepan-stulov · Aug 12, 2015 at 12:48 AM 0
Share

(1) Auto-generating the track: I'm not sure if blender can do that, I actually have next to no idea about it. I implied you would create the curve in Unity (or maybe import it from any convenient file format) and also generate the final visual object in Unity (Editor script?) based on the curve and by decorating it with segment meshes from Blender. The problem is there might be much tweaking involved into making the auto-generated result look good, not have seams etc.

(2) Hand-supplying the spline: This approach should produce the best visuals, because you can make a nicely looking track mesh and also highly optimised spline on top of it. The problem of this approach is a much longer iteration of updating the track. First you need to update the mesh, then you need to go back and sync the spline with it. The question is how many tracks you have. If it's 5 — go for it. If it's 1000 — probably auto-generate.

What I would not recommend is to reverse-engineer the mesh, unless you really have to.

Update: what you can do as an option (3) is to reverse-engineer the mesh but then correct all the errors by hand. Could actually be a viable option.

avatar image
0

Answer by Bunny83 · Aug 11, 2015 at 08:44 AM

Since you probably have unwrapped your mesh it should be relatively simple to follow an edge loop along your road by looking at the UV coordinates to determine which neighbor vertex is the next one. So depending on the orientation of your UV map you have to look for a connected edge which second point has a greater / smaller UV value along the road direction.

For this approach all you have to do to start is to pick a start-vertex and move along the edges. That start point could be determined by doing a raycast against a meshcollider. However it also depends on your actual topography of your mesh and where you have edges.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Skflowne · Aug 11, 2015 at 08:33 PM 0
Share

This seems a good technique but I'm afraid I can't do that since the UV is unwrapped only on a portion of road. So if I'm not mistaken, each portion will have the same UVs along the curve right ? But maybe I could try to collect all the UVs in the center and get all vertices that match those coordinates.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

26 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

MMD How to export model and animations to Unity as 3rd person controller? 2 Answers

2D simple road system with curves and intersections 0 Answers

moving forward after bazier curve 1 Answer

Access curves presets from c# 1 Answer

Train spawn on curved path 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges