L3DT users' community
Large 3D terrain generator

Sapphire Plug-ins

It doesn't hurt to ask...

Sapphire Plug-ins

Postby David Walters » Tue Aug 04, 2009 3:58 pm

Hi, would it be possible to add a plug-in mechanism to Sapphire? (or more powerfully - a way for fully fledged plug-ins to interact with the Sapphire render viewport)

It wouldn't need to be all the complex I don't think. I imagine a system where Sapphire makes a call to my plugin's OnRender function immediately after you're done rendering the usual Sapphire bits. I can then make various GL calls to render 3D elements into the scene.

Everything else would be kind of a luxury really (unless I've forgotten anything really obvious), however two other things spring to mind as being very helpful:

* The mouse position projected onto the terrain in world space (as you have it for the terrain brush)

* The HWND of the Sapphire window so I can get the render size for any 2D overlays, and also to create simple toolbox windows, etc.


Anyway I'm just throwing the idea out there as I think it'll help broaden the development effort, and maybe yield tools that can be rolled into the main application in future?

If you're wondering about the uses I have in mind - things like placing buildings / vegatation / props, and road layout ( like this http://freeworld3d.org/tutorials/roadsystem.html ) are high on my list. I like the idea of using L3DT for as much as possible in my world creation pipeline, but I can't expect you to create all my tools for me! :D
David Walters
Doyen
 
Posts: 129
Joined: Fri Apr 24, 2009 1:10 pm

Postby Aaron » Tue Aug 04, 2009 10:45 pm

Hi David,

Thanks for the request.

This is partly done already. Plugins can currently* do the following to Sapphire:
  • Show/hide the window, and get current show/hide state.
  • Get the HWND.
  • Render a set number of frames.
  • Pause/run renderer, and get current pause state.
  • Open editors for HF/AM/TX.
  • Move/rotate camera, and get current pos/angle.
  • Take screen captures to memory or image file.
  • Set/get all rendering options available in Sapphire.
  • Get/set brush radius.
  • Load/delete/move/rotate/scale arbitrary mesh objects.

These features were added so that I could implement the brush tool plugins (e.g. the 'atAttribBrush' plugin implements the texture/attributes map brush). Some of the other functions were added to allow script control of Sapphire for debugging purposes (see 'Sapphire debug' item in the 'scripts' menu). However, at the time of implementation I was not considering more general use by other plugins, so I will have to add some more features to make this practical. Specifically, from your request the obvious functions still needed are:
  • Ability for plugins to attach callback functions for various events.
  • Ability to get/set mouse cursor position.

I'll put these on the to-do list forthwith.

Once I've finished my current tinkering with mesh support in Sapphire, I'll bash together an example plugin to demonstrate these features (e.g. a flight simulator plugin, or some such).

Cheerio,
Aaron.

* ...by this I mean my current private build. All is coming soon in the next dev build.
User avatar
Aaron
Site Admin
 
Posts: 3696
Joined: Sun Nov 20, 2005 2:41 pm
Location: Melbourne, Australia

Postby David Walters » Tue Aug 04, 2009 11:02 pm

Thanks, this will really be useful!

Sorry if I missed something (I'm very new to OpenGL, all my work is in DirectX), but will I be able to draw additional geometry to the viewport with these changes? I'd like to work on replicating something like that road spline layout tool from FreeWorld3D.

I'm also glad to hear the mesh support has been ticking along in the background - I've long had high hopes that the interaction of meshes and heightfields in one scene will vastly improve L3DT and allow the creation of more seamless worlds (e.g. raising terrain around the edge of a building to make a snow drift or sand dune), plus additional interaction with things like the shadow rendering will really optimise world building workflow.
David Walters
Doyen
 
Posts: 129
Joined: Fri Apr 24, 2009 1:10 pm

Postby Aaron » Wed Aug 05, 2009 9:46 pm

Hi David,

You could directly call the OpenGL API to render additional geometry. However, I would recommend you instead use the functions provided by Sapphire to render geometry or modify the viewport. I shall provide an API in C++ to access these functions from a plugin. This approach should make it easier to integrate with the Sapphire renderer, and also easier to maintain.

Cheerio,
Aaron.
User avatar
Aaron
Site Admin
 
Posts: 3696
Joined: Sun Nov 20, 2005 2:41 pm
Location: Melbourne, Australia

Postby David Walters » Thu Aug 06, 2009 10:41 am

Great, that would definitely be a lot cleaner and robust to future changes.

I reckon you will be able to do a whole lot with just a function to draw coloured 3D lines in the scene. Or at least, my current plans for tools would be achievable with that as a preliminary feature set. Something like a road generator / decal system might need texture management and triangle rendering, but I don't want to be greedy :D (this is why my initial thought was to suggest a raw OpenGL context so it didn't take you away from other requests, etc.)

( It'll probably take me ages to do anything though as I never seem to have enough time to work on any one thing for long :( )
David Walters
Doyen
 
Posts: 129
Joined: Fri Apr 24, 2009 1:10 pm


Return to Feature requests

Who is online

Users browsing this forum: No registered users and 8 guests

cron