Jump to content

Recommended Posts

Posted

Hi

Can somebody give some help on this topic. I have tried to find as much as possible on the web, however, the information is limited. I have also tested the example http://www.xsquawkbox.net/xpsdk/mediawiki/DrawingHook   which works well with my plugin, however, frankly speaking I have a lack of understanding how to continue from this point with the 'string issue'.

Although, the following code snippet is probably missing essential parts I include it just to illustrate where am I at the moment with my considerations:


XPLMRegisterDrawCallback(My3DTest, xplm_Phase_FirstScene, 0, NULL);	
XPLMUnregisterDrawCallback(My3DTest, xplm_Phase_LastScene, 0, NULL);

int My3DTest(
	XPLMDrawingPhase     inPhase,
	int                  inIsBefore,
	void *               inRefcon)
{
	float	color[] = { 1.0, 1.0, 1.0 };
	
	glPushMatrix();

		XPLMDrawString(color, 300, 120, "Teststring", NULL, xplmFont_Basic);

	glPopMatrix();
	
	return 1;
}

If I understand the SDK documentaton correctly then the xplm_Phases should be correct for 3D drawing.

Thank you very much for possible help and best regards

SHJ

Posted
7 hours ago, SchneiH2 said:

Hi

Can somebody give some help on this topic. I have tried to find as much as possible on the web, however, the information is limited. I have also tested the example http://www.xsquawkbox.net/xpsdk/mediawiki/DrawingHook   which works well with my plugin, however, frankly speaking I have a lack of understanding how to continue from this point with the 'string issue'.

Although, the following code snippet is probably missing essential parts I include it just to illustrate where am I at the moment with my considerations:



XPLMRegisterDrawCallback(My3DTest, xplm_Phase_FirstScene, 0, NULL);	
XPLMUnregisterDrawCallback(My3DTest, xplm_Phase_LastScene, 0, NULL);

int My3DTest(
	XPLMDrawingPhase     inPhase,
	int                  inIsBefore,
	void *               inRefcon)
{
	float	color[] = { 1.0, 1.0, 1.0 };
	
	glPushMatrix();

		XPLMDrawString(color, 300, 120, "Teststring", NULL, xplmFont_Basic);

	glPopMatrix();
	
	return 1;
}

If I understand the SDK documentaton correctly then the xplm_Phases should be correct for 3D drawing.

Thank you very much for possible help and best regards

SHJ

The 3D panel is a 2D bitmap rendered in 3D space.

You cannot use XPLMDrawString to draw directly into a 3D space. Period.

 

You must use something like  xplm_Phase_Gauges

 

You will find that while C++ seems like a purist choice and can be satisfying you will battle these annoying trivialities and rain dances forever more.

 

Enjoy and good luck.

 

Posted (edited)

You can draw text in 3D, but you will have to do it yourself, the SDK does not provide anything for this. The basic things to do is to generate a set of quads, each textured with one letter of the text you want to display. Then, depending on what you want to achieve you will have to either draw them facing the camera or facing a fixed direction that you deem suitable.

You, off course, do not want to render these one letter a a time, you also do not want to render these that do not belong to the current view frustum. Welcome to 3d graphics :-)

You can look at impostors and billboards to get an idea of what needs to be done. A text string is no more than one of these made of several quads instead of one.

PhM

Edited by PhM
Posted

Hi guys

Many thanks to all of you for your responses. Regarding your comments on the advantages of Gizmo64 I fully agree. It is indeed a very handy tool/plugin that allows also people like me with quite basic programming skills to achieve great results. Basically, I could realize almost all functionality I wanted for my a/c with this tool/plugin. However, as the plugin meanwhile became payware and can be obtained according to Ben’s post

Quote

The official way to get the latest version of Gizmo is to install an X-A payware product that requires it.

not on a standalone basis but only together with a X-A payware product it is no longer an option for my project. This because I plan to publish it once it will be ready (god knows when) on a free basis and thus people who want to use it would be forced to buy a X-A payware a/c to get the Gizmo64 plugin to run the freeware a/c they want. Please do not take the aforesaid as any criticism, it is just considering a fact. My project is a pure hobby and I am realistic enough to understand that the result will hardly be on a level that asking money for it can be justified. Therefore, I probably must do it the ‘hard way’ and will see how far I get. At least for the moment I am still more excited than frustrated.

Back to the problem itself many thanks to you Ben for the hint with xplm_Phase_Gauges and PhM’s comment. Out of your comments I concluded that I perhaps gave a wrong description of my problem/aim. Basically, I would like to write on the 3D panel (instrument) and not somewhere into the 3D space. After reading your comments and again the SDK docs I suspect that there might be a difference.

Please find below as example of the Gizmo64/Lua code I use to display on the EFB (which background is in the 3D panel graphic) the current weather of the destination airport. I just wanted to reproduce this option with the SDK; It might be of course again a good argument for Gizmo64 since a could realize this feature quite easily.

function OnDraw_Gauges_3D()	

if efb_power == 1 and efb_mode ==3 then   	--EFB wheather
		
			gl.PushMatrix() 
					
			gfx.drawString("AIRPORT   ", 1820, 580)
			gfx.drawString(metar_apt, 1820, 560)
			gfx.drawString("WHEATHER  ",1820, 530)
			gfx.drawString(metar_data1, 1820, 510)
			gfx.drawString(metar_data2, 1820, 490)
			gfx.drawString(metar_data3, 1820, 470)
			gfx.drawString(metar_data4, 1820, 450)
			
			gl.PopMatrix()
		
		end
end

 

I must admit that I do not know whether Gizmo64 interacts directly with XPlane independently from the SDK structure or if they are linked. In case of the latter I assume that there might be a possibility to do it similarly using the SDK?

Whatsoever, many thanks already know for additional comments.

Best regards

SHJ

2018-01-07_112441.png

Posted

in Gizmo, "OnDraw_gauges_3D" tells X-Plane what phase you want to draw in.  So, in C/C++, an equivalent would be XPLMDrawingPhase = xplm_Phase_Gauges as Ben described above.  Phases in the SDK are defined here.

Posted

Hi Jim

Thanks for your reply. If I understand correctly than Gizmo64 acts as a kind of overlay to the SDK and uses the SDK code set/API? Using xplm_Phase_Gauges works in a way that it indeed draws the string on the 2D panel. Regarding the Gizmo64 code shown above I am a bit puzzled that to my understanding with glPushMatrix() and glPopMatrix() OpenGL is being addressed. However, adding this to the plugin code does not give any effect.

Could there be a necessity to somehow 'load'  the 3D panel png in the plugin code? Frankly speaking I do not fully understand the meaning of the second part of below explanantion from the SDK

Quote

Draw to the 2-d panel's opaque area (from xplm_Phase_Gauges) and use the panel texture. (You cannot draw into transparent areas.)

Thanks up front for additional comments

Best regards

SHJ

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...