Jump to content

wim1976

Members
  • Posts

    154
  • Joined

  • Last visited

Everything posted by wim1976

  1. I have two installations of X-Plane. One for development and one for flying (with the SAAB, DC-3, MU-2 etc.). In the development version I don't have installed any X-Aviation product and used an outdated beta version of Gizmo. After copying the most recent version of Gizmo from the 'flying' version I could use the camera.setPositionGL function. Thanks!
  2. Is there anybody who can shine his light on this question (and the other two (in separate topics) until now unanswered question)?
  3. Last question today, before I quit my PC and go cycling. When using camera.setPositionGL there is no change in position. How can i use this function to set the camera, or is it better to change the dref values of the pilots_head position. The following is the buggy code I made until now: function BtnGo_OnClick() x,y,z = camera.getPositionGL() --console.log ("x: "..x.." y: "..y.." z: "..z) x = x + 0.01 y = y + 0.01 z = z + 0.01 camera.getControl() camera.setPositionGL(x,y,z) camera.releaseControl() --console.log ("nx: "..x.." ny: "..y.." nz: "..z)end
  4. For my goal it would be easy to create labels or (preferrable) custom widgets with multilines. But is seems Gizmo handles the newline escape characters not good, or more likely I am doing something wrong. See picture with code and result. EDIT: The uploader did an ugly compression. The info is barely readable, but I think still usable.
  5. I am experimenting with Gizmo to program a in-game tutorial, so people can learn a plan step by step, while my program gives instructions and test if the instructions are followed etc. I want to use custom widget. I already succeeded in one important step: showing pictures in a custom widget. But I have also created an _OnClick eventprocedure but that one isn't called after clicking on my pixture. What am I doing wrong. local window = gui.newWindow("wndTutor")function wndTutor_OnCreate() local sw, sh = gfx.getScreenSize() local w = 500 local h = 500 local l = sw/2 - w/2 local t = sh/2 - h/2 gui.setWindowSize(window,l,t,w,h) gui.setWindowCaption(window,"Flight Instructor (experimental)") local cw = 329 local ch = 153 local cl = w/2 - cw/2 local ct = h/2 - ch/2 -- loading the texture to use it in the picturebox texture = gfx.newTexture() texture = gfx.loadPng(acf.getFolder().."/scripts/data/xplane.png") picturebox = gui.newCustomWidget(window,"PictureBox1",cl,ct,cw,ch) gui.showWindow(window)endfunction PictureBox1_OnDraw() gfx.useTexture(texture,0) gfx.drawTexturedQuad(1,1,329,153)endfunction PictureBox1_OnClick() sound.say("Clicked on picture") console.log("Clicked on picture")end
  6. In what folder did you install the X-Aviation products. They have to be in the X-Aviation folder and not in other folders.
  7. To me it looks like that the video is posted to prove the powerback possibility of the Saab.
  8. Most times I taxi through the buildings before me and ask my kids looking at my flying to look elsewhere for the next two minutes.
  9. I am trying to create an aircraft profile for PFPX so this program calculates the flightplan based on the correct data. I found most of the needed data in the Charts (although most digits are difficult to read*). But I have some questions to get a good aircraft profile. 1. In the charts there a two descent profiles each based on a descent of 3.000 feet per minute. I thought that in real life a more modest descent is flown. What is the usual descent speed and how can I get or calculate the right performance data for it? 2. What are the optimum en maximum altitudes for the Saab 340A related the weight of the plane. 3. What is the fuel use per minute while taxiing * I would welcome a better readable Charts document.
  10. Maybe a stupid question, but how do I turn on the GPS?
  11. Found a working solution. I have made a table with all sound sources. The key of the table is the number of the sound source and the value is a reference to the sound object (which is actually a function/table). With these reference I can change the values of the object fields to get the data synchronized. I am checking the sound states of all created source in the OnUpdate() function. Could it be helpful to create an own event procedure with event.register? I don't understand really what the benefit is of this function. But maybe somebody can explain it.
  12. I am experimenting with OOP programming in LUA. I have made a class (soundClass). Based on this class several sound objects are made, e.g. Wind. I want to have an automatic method for assigning and releasing sound sources. This way it is possible to keep the used sound sources to a minimum. Only the playing sources are attached to a sound source, after stopping the sound it is released from the source and it can be assigned to a new sound that must start playing. For releasing the sounds there are two situation I have to deal with: 1. My application decides it is time to stop 2. The sound is stopped because the end of the soundfile is reached The first situation is an easy, because in this case a field of the object is changed and it is very easy to create an event-procedure for it. For the second I don't know how to determine the event, because no field of the object is changed after the soundfile has come to an end (OpenAL have an extra challenge because it has no events itself), I have to check the source state myself (if al.GetSource(source_id,al.SOURCE_STATE) == al.STOPPED do release_sound end). The source_id is stored in the field source of the soundobject, e.g. Wind.source. Is it possible to have the created objects checking each frame if the sound is stopped? Of course it is possible to check it in the OnUpdate() function of my main program myself, but this is a more stupid approach. I want to realize this in the "class", so I have to write it once and don't need to worry about it ever. My second problem with this solution is that I have to write a method call for each sound object I created.
  13. Oh yes, don't being afraid for a simple add-on. PMDG only makes studysims. And the DC6 have many, many knobs. They even modelled the circuit breakers. I think it will become a rail brainbreaker.
  14. Don't worry, it is still a far cry from the Wright flyer I was afraid for ...
  15. To give more insight in the rotationproblem of the sound in X-Plane I made another video. Now with the function of X-Alberto (translated to Lua). I also added debug information in the inspector window So you can get an idea of the values I used and the results of the rotation. The difference between the code of X-Alberto and me are: - I have no unary minus at heading and roll degrees - I have changed the order of the calculation. In my code: My, Mx, Mz. In the code of X-Alberto the order is: Mz, Mx, My - I have added an unary minus to the second column of the Mx matrix (-cos_P and -sin_P) - I have not added a calculation of the translation. I decided to make a seperate translation fucntion. The code of X-Alberto is in essention the same as the advised conversion in the XPlane SDK (although the SDK uses a direct calculation instead of a matrix calculation): http://www.xsquawkbox.net/xpsdk/mediawiki/ScreenCoordinates I can't explain exactly why my codes gives the good result, but the (theoretically right calculations!!) of X-Alberto and the X-Plane SDK not. For the explanation of the rotation theory see: http://en.wikipedia.org/wiki/Rotation_matrix Maybe there is a math expert on this forum who can explains why I needed a slightly changed algoritm to get a good rotation. What I know is that X-Plane uses a Z-axis where the theory uses and Y-axis and the Z-axis is negative where the maths theory uses positive values. But I assume that X-Alberto and Ben Supnik knows the math theories more thoroughly than I. For you information I post also the code of X-alberto (programmed in lua and without the translation): function rotate3D_variant_x_alberto(x,y,z,p,r,h)-- this function seems unusable for rotation of the source position. local p_Rad = math.rad(p) local r_Rad = math.rad(-r) local h_Rad = math.rad(-h) local cos_P = math.cos(p_Rad) local sin_P = math.sin(p_Rad) local cos_R = math.cos(r_Rad) local sin_R = math.sin(r_Rad) local cos_H = math.cos(h_Rad) local sin_H = math.sin(h_Rad) --Pitch rotation matrix Mx = { { 1, 0, 0}, { 0, cos_P, -sin_P}, { 0, sin_P, cos_P} } --Heading rotation matrix My = { { cos_H, 0, sin_H}, { 0, 1, 0}, { -sin_H, 0, cos_H} } --Roll rotation matrix Mz = { { cos_R, -sin_R, 0}, { sin_R, cos_R, 0}, { 0, 0, 1} } -- Calculate dimensions in the sequence of: -- Mz -- Mx -- My local XYZ_R = {x,y,z} XYZ_R = mmult(XYZ_R,Mz) XYZ_R = mmult(XYZ_R,Mx) XYZ_R = mmult(XYZ_R,My) return XYZ_R[1], XYZ_R[2], XYZ_R[3]endfunction mmult(inX,R) local outX = {0,0,0} for i = 1,3 do for j = 1, 3 do outX[i] = outX[i] + (R[i] [j] * inX[j]) end end return outXend
  16. This afternoon I will post an explanation on the difference with the code of X-Alberto. Hope that will help.
  17. No I tried that one, but the result was buggy.
  18. It tooks me more then a week to find the solution. After relearning all the math-stuff I have learned at school I understood the principles of rotation and I was able (after drawing and analyzing) to correct what was going wrong. I the next video you can hear the sound positioning I made in Gizmo. You can hear sounds coming from right or left. OK that part wasn't the difficult one, but in my first attempts when I pitched the view the sound got completed disoriented. And as you can hear the sound is now correct. It was made possible with this function: function rotate3D(x,y,z,p,r,h) local p_Rad = math.rad(p) local r_Rad = math.rad(r) local h_Rad = math.rad(h) local cos_P = math.cos(p_Rad) local sin_P = math.sin(p_Rad) local cos_R = math.cos(r_Rad) local sin_R = math.sin(r_Rad) local cos_H = math.cos(h_Rad) local sin_H = math.sin(h_Rad) --Pitch rotation matrix Mx = { { 1, 0, 0}, { 0, -cos_P, -sin_P}, { 0, -sin_P, cos_P} } --Heading rotation matrix My = { { cos_H, 0, sin_H}, { 0, 1, 0}, { -sin_H, 0, cos_H} } --Roll rotation matrix Mz = { { cos_R, -sin_R, 0}, { sin_R, cos_R, 0}, { 0, 0, 1} } -- Calculate dimensions in the sequence of: -- My -- Mx -- Mz local XYZ_R = {x,y,z} XYZ_R = mmult(XYZ_R,My) XYZ_R = mmult(XYZ_R,Mx) XYZ_R = mmult(XYZ_R,Mz) return XYZ_R[1], XYZ_R[2], XYZ_R[3]endfunction mmult(inX,R) local outX = {0,0,0} for i = 1,3 do for j = 1, 3 do outX[i] = outX[i] + (R[i] [j] * inX[j]) end end return outXendAnd as you can see it was inspired on the code of X-Alberto: http://forums.x-pilot.com/topic/1442-3d-transform/?hl=x-alberto#entry16421 Maybe some of you have some optimization suggestions.
  19. For my attempt to create full 3D sound I have written a function to calculate the correct listener position. Therefore the distance between the soundsource and the listener (actually cameraview x,y,z transformed to 0,0,0) and the correction for pitch, roll and heading leads to a transformation of the x,y,z. The XZ dimension was relatively easy because it has a 360 degrees angle. But pitch [-90..90] and roll [-180..180] have different values. And I do not know how to correct them to use them in my function. Is there anyone who can helps me to get the code working. I have tried the gizmo function matrix.transform3D( x,y,z, tx,ty,tz, tp,tr,th ) but for me it doesn't work or I don't understand it. function convertViewPos(x,y,z,p,r,h) local angleZY = p -- the value of pitch is between -90 and 90, but the second half of the circle the roll is negative local angleXY = r -- the value of roll is between -180.0 and 180.0 local angleXZ = h -- no conversion needed --XZ dimension (vector is heading h) Xn1 = x * math.cos(math.rad(angleXZ)) + z * math.sin(math.rad(angleXZ)) Yn1 = y Zn1 = -x * math.sin(math.rad(angleXZ)) + z * math.cos(math.rad(angleXZ)) --XY dimension (vector is roll r) Xn2 = Xn1 * math.cos(math.rad(angleXY)) + Yn1 * math.sin(math.rad(angleXY)) Yn2 = -Xn1 * math.sin(math.rad(angleXY)) + Yn1 * math.cos(math.rad(angleXY)) Zn2 = Zn1 --YZ dimension (vector is pitch p) Xn3 = Xn2 Yn3 = Zn2 * math.cos(math.rad(angleZY)) + Yn2 * math.sin(math.rad(angleZY)) Zn3 = -Zn2 * math.sin(math.rad(angleZY)) + Yn2 * math.cos(math.rad(angleZY)) -- return transformed coördinates return Xn3, Yn3, Zn3end
  20. Thanks, I discovered the HPT last week and I already used it getting an efficient code-path. Passing values by reference would be great.
  21. A short question for a short programming advice. Due to the event model of the SDK it is very difficult to use very few (or none) global variables. Because many variables are used in more then one function, or because of efficiency reasons I do some preparation in the OnBoot() function and later on in the OnUpdate() I manipulate the loop of X-Plane with the same variables. I have learned (myself) to prevent global variables as much as possible. In the documentation of LUA I read that local variables are faster dan global variables. So I am considering to assign the global variables first to local variables and then use it in the different functions. What is the good programming strategy in Gizmo? ... or do i have to accept global variables as part of the game. Is assigning globals to locals more efficient thant using globals directly?
  22. In the attached file you find a pdf document explaining the OpenAL implementation in Gizmo. This is the 'side effect' of many hours of searching to find the solution of setting the sound position with Gizmo. I hope this can help someone using Gizmo for programming the sound part of the plugin. If you find any typo's, mistakes, please let me know. Implementation of the OpenAl API in Gizmo.pdf
  23. After reading the documentation of OpenAL I conclude my ears are still good. OpenAl have a 6dB attenuation at 0.5. FSX plays at -3B at that moment. FSX uses an other gain curve. So I have to think about a conversion formula.
  24. I think I have found the bug in Gizmo. The listener orientation is set to zero for al the six variables. According to OpenAL 1.1 Specification and Reference (page 32) this is wrong. And see also: http://stackoverflow.com/questions/7861306/clarification-on-openal-listener-orientation The default values are 0,0, 0,0, -1,0, 0,0, 1,0, 0,0. The first group of 3 are for the AT orientation and the second group of 3 are for the UP orientation. A workaround for the bug is the following line of code: al.Listener(al.ORIENTATION,0.0,0.0,-1.0,0.0,1.0,0.0)Place this code in the OnBoot (or maybe OnFirstFrame) module and sound positioning is working.
  25. Some (more) questions about OpenAL and Gizmo: In the Gizmo folder there is an OpenAL32.dll. Why is the OpenAL32.dll of X-Plane not used? It looks like OpenAl32.dll of X-Plane is more recent. It looks like the functions sound.getcontrol() and sound.releasecontrol() are not needed anymore. Is this true? What is the difference between sound.load() and sound.loadEx() It looks like that not only the Gizmo sound functions are limited, but the OpenAL API in Gizmo is very limited too: It looks like that only the Listener and Source functions of OpenAL are implemented in the OpenAL API. The functions of Buffers, Errors, Context are not implemented. Also some functions of Source are not implemented: GenSources, DeleteSources, IsSource). What LUA binding is used for the OpenAL API?
×
×
  • Create New...