flat model to terrain?

Posted By: JerahYalyn

flat model to terrain? - 04/19/15 10:02

hi, I made couple of road models which is just a flat model with couple of vertices, like this.


How do I flat it on the terrain surface without just like it's a part of the terrain. I know I have to look for the terrain normal for this but it confuses me on how to implement it. Setting it's orientation to terrain surface is not enough since the road model with usually intersect multiple terrain surface and it will look funny if a part of the road is not connected to the surface.

And also is the a way to enable keep both normal map and detailed texture for the terrain. When set my terrain to use normal map to for terrain shadow it ignores the detail map resulting a bad terrain detail up close.
Posted By: Reconnoiter

Re: flat model to terrain? - 04/19/15 14:27

Hi,

To your first question: you can do a c_trace with SCAN_TEXTURE to hit the terrain and use the 'hit' (/hit.nx,ny,nz) info combined with vec_to_angle wink .

This may also help https://www.google.nl/search?q=angle+to+...eTqHMfvaI74gagH
Posted By: Superku

Re: flat model to terrain? - 04/19/15 19:50

This is not a trivial problem but a rather complicated one instead. I think best results (or any decent at all) would come from subdividing the road's mesh, based on the terrain's triangle grid and the road's orientation, then adapt the vertex height. You would have to dig into DirectX functions for that plan though.
Posted By: Anonymous

Re: flat model to terrain? - 04/19/15 20:02

Why not simply use bmap pixel instructions to paint the road texture onto the terrain at the location? or can this not be done for some reason?
Posted By: Superku

Re: flat model to terrain? - 04/19/15 21:25

This works in theory but the terrain texture would have to be huge, even on small terrains, to only have bare acceptable results let's say for an airplane simulator.
Maybe one could come up with a fancy projection shader on the terrain skin to solve the resolution issue but this won't work of course when you want to use 3d meshes for the road and its border.
Posted By: JerahYalyn

Re: flat model to terrain? - 04/20/15 01:24

Now it just fot more complicated. But I guess directx function is the only solution. I concept was actualy from a game I use to play called arma and road models ar actual mesh that ars set flat to the ground. Now flatting mesh to the surface will cause flickering on the surface so I have to work with z-bias aswell to make sure road is drawn on top of the terrain and not just move it one quants higher. I thought it would be an simple task.
Posted By: Wjbender

Re: flat model to terrain? - 04/20/15 09:04

it would be simpler if your modeler , modeled the road on to the terrain ,for eg. in 3dstudio max ,you could create the terrain with a displace modifier ,on a plane with sections in width and height to the amount of tiles needed , then you could export and import in to MED and convert to terrain , and convert your road separately .

you could also lightmap it etc..

you can also convert both as a single model but that would miss out on real terrain performance.

coding it would be difficult ,however if I am not mistaken tust has spline roads ?
Posted By: JerahYalyn

Re: flat model to terrain? - 04/20/15 10:36

That would make allot of road models if I export it individually. I have several models of the road including different curvs. One idea I have is to move the model's vertecis based on the terrain slope since I have a scaled terrain and adjust the uv. I will only call the function once per model during initialization of the level. Again it is still in my head and I have to look in to the manual for all functions that I can use.
Posted By: Reconnoiter

Re: flat model to terrain? - 04/20/15 11:45

Oh sry I see now you meant laying the road over the terrain as like a curtain over a floor (maybe bad analogy? grin ). I thought you just meant changing the tilt/angle.

You could change the vertices. Maybe trace to get the world coordinates of the terrain points and than convert them to local coordinates (see vector calculations). I think that will work, don't know for sure cause never tried moving vertices.
© 2024 lite-C Forums