Jump to content
  • Advertisement
Sign in to follow this  

OpenGL How to design a 3D road viewing tool

This topic is 4281 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'd like to design a 3D road viewing tool, some basic functions should be implemented, such as rotation, scaling, transforming,etc. Some coordinates data would be recorded on a file, which represents the intersections of the road. Then I'll import the file into this viewing tool, and the 3D road model should be dynamically constructed, which can be viewed from different perspectives with mouse and keyboard input. The project should be written in C#, because of our group's requirement. Both managed directx and opengl are OK. The effect should be like the following: http://hiphotos.baidu.com/chosen%5Fone/pic/item/f7783534a20d8b385bb5f588.jpg Can anyone suggest some idea on how to realize this? I've been frustrated for months. I'm wondering if I can modify the .X file and write the coordinates into it, so the road can be displayed? But I'm rather confused about the structure of .X file, and there seems no suitbale tool for editing .X files. Or can I just use some basic drawing functions provided by Directx library? But it seems that I can't pick up the road with the mouse. Can anyone help? I'll be really appreciating your help:)

Share this post

Link to post
Share on other sites
You can certainly use (Managed) DirectX for this - but bare in mind that it's a relatively low-level API and you're requesting some fairly high-level features that aren't directly provided. Yes, some helper functions exist for generating geometry and picking it (clicking with the mouse and dragging it around) but you still need to implement a lot of the code for this.

It may well be that you want to use some middleware for this sort of project - something that implements a lot of the low level plumbing and allows you to focus on the main features. Unfortunately I don't know of any middleware to point you at - maybe another member of the community can help [wink]

I wouldn't use the .X format directly but you can use the Mesh object to store your data - that way you can use the standard D3DX helper functions on your raw geometry. There should be a way of constructing a Mesh object without pointing it at a .X file - D3DXCreateMesh() in C/C++ does this.

Look into 'Vertex Buffers' for your road - you can generate all of your road geometry in these and then pass them to the device for rendering. However it's entirely down to you to convert the incoming data to a format that can be rendered by the API - e.g. converting intersections to splines/lines and then making them into roads. Direct3D has no concept of what a road is - all it cares about is a list of vertices defining some triangles [smile]


Share this post

Link to post
Share on other sites
Thank you, jollyjeffers! Your suggestion is very helpful to me. It seems that .X format is really a terrible nightmare, which can't supported by most tools. I'll try to do some research into the mesh matter, to make clear how it works.

I did use 'Vertex Buffers' to draw some roads. I stored some coordinate data in a .txt file and load them to draw some triangles, tnen I used the Texture function to put on the 'skin'.

Here is a snapshot:

But just as I mentioned, they're just stationary triangles, I can't treat them as a 'object', thus picking them up with the mouse.( To rotate, scale, etc)

While importing a model construted in 3DMAX(export to .X format), I can take it as an 'object' and pick it up with the mouse.

Here is another snapshot:

I made the latter one with the help on Artificial Engine. But it seems to have limited support with data manipulation.

I hope I've made it clear for you to understand. Is there any middleware still available? Or I may turn to OpenGL which can support more model formats than DirectX does.

It's been really frustrating. I was new to D3D and picked it up at the end of last year, but unfortunately I could only find limited resources on Managed DirectX, and its only supporting the .X format makes me really annoyed.

Anyway, I still appreciate your patience and I'll try the best as I can.

You're a great guy, jollyjeffers:)

Share this post

Link to post
Share on other sites
Original post by OrangeQi
... Or I may turn to OpenGL which can support more model formats than DirectX does.

OpenGL does not support any format. You will have to load anything manually in OpenGL. Direct3D and OpenGL are low level graphic APIs, what you need is a 3D-Engine like Irrlicht(irrlicht.sourceforge.net).
Supported mesh file formats by Irrlicht:
* 3D Studio meshes (.3ds)
* B3D files (.b3d)
* Alias Wavefront Maya (.obj)
* Cartography shop 4 (.csm)
* COLLADA (.xml, .dae)
* DeleD (.dmf)
* FSRad oct (.oct)
* Irrlicht scenes (.irr)
* Microsoft DirectX (.x) (binary & text)
* Milkshape (.ms3d)
* My3DTools 3 (.my3D)
* OGRE meshes (.mesh)
* Pulsar LMTools (.lmts)
* Quake 3 levels (.bsp)
* Quake 2 models (.md2)

See also DevMaster's Game and Graphics Engines Database

***But if you have to construct the 3D road model dynamically in your application why do you need a 3d file format? Generating the Vertex Buffer is the right way. You can pick such an object by doing some ray-triangle intersection tests and you can scale and rotate the object easily using the correct matrixes.

[Edited by - Kambiz on March 27, 2007 10:12:51 AM]

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!