New Release D3D9Client Development

DaveS

Addon Developer
Addon Developer
Donator
Beta Tester
Joined
Feb 4, 2008
Messages
9,439
Reaction score
689
Points
203
Is DX9 advanced enough to support reflection maps? There's plenty of reflective surfaces on spacecrafts that would look nice with it. Here's one example, the Ku band Deployed Assembly (DA) on a shuttle:

2010-4426.jpg
 

jarmonik

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 28, 2008
Messages
2,668
Reaction score
796
Points
128
If the axies are rendered for vessels only then it might be better to place the code in a vVessel class.

PHP:
void vVessel::RenderVectors(oapi::Sketchpad *pSkp)
{
   for_every_arrow {
      D3D9Effect::RenderVector(&ref, &dir, &color, length);
      pSkp->Text(x,y,"Label",-1);
   }
}

Rendering the arrows without z-buffer is one possibility but it's also possible to clear the z-buffer, like it's done just before rendering the virtual cockpit.

The D3D9Effect::RenderVector() would be very much like the D3D9Effect::RenderArrow() but it might be good idea to use 3D modelling software to create the vertex list for the arrow.

The Scene::RenderDirectionMarker() section should show how to get the (x,y).

---------- Post added at 01:56 ---------- Previous post was at 01:33 ----------

Is DX9 advanced enough to support reflection maps? There's plenty of reflective surfaces on spacecrafts that would look nice with it. Here's one example, the Ku band Deployed Assembly (DA) on a shuttle:

It's pretty easy and fast to make a vessels to reflect other vessels and planets using environment maps. However, the reflection will become erroneous if the vessels are close to each-other. It's possible to use multible environment maps for some specific parts of a vessel, those parts could reflect the vessel it self, but a client can't know which parts. So, the feature would require some code support from a vessel addon. The maximum map count in a scene would be somewhere around 4 to 8.
 

DaveS

Addon Developer
Addon Developer
Donator
Beta Tester
Joined
Feb 4, 2008
Messages
9,439
Reaction score
689
Points
203
It's pretty easy and fast to make a vessels to reflect other vessels and planets using environment maps. However, the reflection will become erroneous if the vessels are close to each-other. It's possible to use multible environment maps for some specific parts of a vessel, those parts could reflect the vessel it self, but a client can't know which parts. So, the feature would require some code support from a vessel addon. The maximum map count in a scene would be somewhere around 4 to 8.
I guess it would be worth to implement. It could take a while to catch on, it did for OrbiterSound's SDK.
 

Donamy

Addon Developer
Addon Developer
Donator
Beta Tester
Joined
Oct 16, 2007
Messages
6,922
Reaction score
226
Points
138
Location
Cape
Shadows on vessels would be better. IMHO
 

kuddel

Donator
Donator
Joined
Apr 1, 2008
Messages
2,064
Reaction score
508
Points
113
Hi jarmonik,
thanks for the reply. Most of the things are already as you proposed. But as usual, it's the small things that take up the most time ;)

If the axies are rendered for vessels only then it might be better to place the code in a vVessel class.
Yes and No. For the forces, this is true, but the coordinate axes can be shown for vessels, celestial bodies and surface bases. Nevertheless I'll start with the implementation at vVessel class. Maybe later I see how this can/should be moved to the base class (vObject).

PHP:
void vVessel::RenderVectors(oapi::Sketchpad *pSkp)
{
   for_every_arrow {
      D3D9Effect::RenderVector(&ref, &dir, &color, length);
      pSkp->Text(x,y,"Label",-1);
   }
}
Hey! This almost looks exactly like my code ;)


Rendering the arrows without z-buffer is one possibility but it's also possible to clear the z-buffer, like it's done just before rendering the virtual cockpit.
I currently have no idea what you mean by 'clearing the z-buffer' (my D3D foo is still weak you know :embarrassed:) but I am pretty sure I can figure it out. Thanks for the hint, those help a lot!
The D3D9Effect::RenderVector() would be very much like the D3D9Effect::RenderArrow() but it might be good idea to use 3D modelling software to create the vertex list for the arrow.

Allready done. I just have the feeling that all that code needed for rotation is useless there. Nevertheless, once I've ironed out the big things I would like you to look over it anyway.

The Scene::RenderDirectionMarker() section should show how to get the (x,y).
Yeah. As stated above, those hints help a lot.:thumbup:

By the way, could you please tell me how I change the technique I use for the 'pointers' to look more like this
attachment.php

instead of looking 'unshaded' like this
attachment.php
?
The current technique I use is a copy of the ArrowTech technique with disabled Z-buffering:
Code:
// This is used for rendering force vectors and coordinate axes ----------------
//
technique PointerTech
{
    pass P0
    {
	vertexShader = compile VS_MOD ArrowTechVS();
	pixelShader = compile PS_MOD ArrowTechPS();

	AlphaBlendEnable = true;
	BlendOp = Add;
	SrcBlend = SrcAlpha;
	DestBlend = InvSrcAlpha;
	ZWriteEnable = false;
	ZEnable = false;
    } 
}


Cheers,
Kuddel
 

Attachments

  • is.jpg
    is.jpg
    12.5 KB · Views: 6
  • shouldBe.jpg
    shouldBe.jpg
    12.4 KB · Views: 11
Last edited:

Enjo

Mostly harmless
Addon Developer
Tutorial Publisher
Donator
Joined
Nov 25, 2007
Messages
1,665
Reaction score
13
Points
38
Location
Germany
Website
www.enderspace.de
Preferred Pronouns
Can't you smell my T levels?
Reporting that Launch MFD works fine in DX9 client, because I made sure of that two years ago by patiently implementing the new Orbiter interface.

Top work guys! I can't believe that the client runs with so many FPS. :cheers:
 

jarmonik

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 28, 2008
Messages
2,668
Reaction score
796
Points
128
By the way, could you please tell me how I change the technique I use for the 'pointers' to look more like this instead of looking 'unshaded' like this ?

Sorry, I didn't notice your post earlier. Please add a new post instead of editing an old post.

I should have foreseen this coming. The vertex declaration will need normals for shading the arrows. The normals will remain constant even-if the arrow is stretched. It might be good idea to use the default NTVERTEX declaration.

The vertex format is (x,y,z), (nx,ny,nz), (tu,tv)
(tu,tv) will be zero since it's not used. There is a good example in D3D9Effect::RenderReEntry() how to use the NTVERTEX.

PHP:
pDev->SetVertexDeclaration(pNTVertexDecl);
pDev->DrawPrimitiveUP(..., sizeof(NTVERTEX));
PHP:
float4 ArrowTech2PS(SimpleVS frg) : COLOR
{
    return gColor * max(0, dot(-gSun.direction, normalize(frg.nrmW)));
}
Code:
technique PointerTech
{
    pass P0
    {
    vertexShader = compile VS_MOD BasicVS();
    pixelShader = compile PS_MOD ArrowTech2PS();

    AlphaBlendEnable = true;
    BlendOp = Add;
    SrcBlend = SrcAlpha;
    DestBlend = InvSrcAlpha;
    ZWriteEnable = true;
    ZEnable = true;
    } 
}
Scene.cpp:
PHP:
// render exhaust particle system
...

if (vectors_enabled) 
{
   // clear z-buffer only if the vectors are enabled
   pDevice->Clear(0, NULL, D3DCLEAR_ZBUFFER,  0, 1.0f, 0L); 
   for_every_visual pv->vobj->RenderVectors(pSketch);
}

// render the internal parts of the focus object in a separate render pass
...


---------- Post added at 16:54 ---------- Previous post was at 16:44 ----------

There exists an easier way to stretch the arrows by using the (tu,tv) and gMix


Code:
SimpleVS ArrowTech2VS(NTVERTEX vrt)
{
    SimpleVS outVS = (SimpleVS)0;

    // This will stretch the vector among the y-axis. 
    // Stretch scale factor for vertex is stored in (tu) (i.e. vrt.tex0.x). 
    // And the length is in the gMix.
    float3 stretchedL = vrt.posL + float3(0,1,0)*(vrt.tex0.x*gMix);

    float3 posW  = mul(float4(stretchedL, 1.0f), gW).xyz;
    outVS.posH   = mul(float4(posW, 1.0f), gVP);
    outVS.nrmW   = mul(float4(vrt.nrmL, 0.0f), gW).xyz;
    outVS.toCamW = -posW;
    outVS.tex0   = vrt.tex0;
    return outVS;
}
PHP:
HR(FX->SetFloat(eMix, float(length)));
 
Last edited:

kuddel

Donator
Donator
Joined
Apr 1, 2008
Messages
2,064
Reaction score
508
Points
113
Thanks for the information jarmonik!

I'll see what I can make of it.

Regarding the streching of the arrow... this is very interesting
But maybe I'll have to mix several things with that technique:
In the inline-client the arrows are only shown as 'head' when they represent 'small' values. With the 'tip' just beeing longer or more flat (should also be possible by just streching the y-axis).
Only if the value is greater, the 'shaft' of the arrow is added.
As I try to mimic the inline client, I'll try to do the same.

Nevertheless, thanks again for your tips. I think I can now get further with that.
By the way, the label implementation works the way you've suggested. Although I still have to clean up my dirty code a lot ;)

I will come back when I have any further questions.

Cheers,
Kuddel

P.S.: Attached you will find a package containig Visual Studio 2010 project files and some documentation changes I've done in my spare time. Those could be added to the next RC if you like (although the chm file is not really needed in my opinion). The included OapiExtension class is the newest revision, that should be stable except for some documentation updates maybe.
 

Attachments

  • RC44based_VS2010prj+docs.zip
    529.3 KB · Views: 12

jarmonik

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 28, 2008
Messages
2,668
Reaction score
796
Points
128
In the inline-client the arrows are only shown as 'head' when they represent 'small' values. With the 'tip' just beeing longer or more flat (should also be possible by just streching the y-axis).
Only if the value is greater, the 'shaft' of the arrow is added.
In that case the (tu) value for the vertices of the end of the "shaft" would need to be zero and the rest would need to be set to one. That would make only the "shaft" to stretch.

Thanks about the files, I'll take a look into them.
 

markl316

XR2 Ravenstar Commander
Addon Developer
Tutorial Publisher
Joined
Mar 30, 2008
Messages
450
Reaction score
1
Points
18
Hey, love the runway lights! Thanks!

Is there any way to make the papi bigger, or is that still in the works?
Also, has anybody experimented with Computerex's Orb Reentry Stream addon, or any way to get flames visible from the cockpit?
 
Last edited:

Tschachim

Addon Developer
Addon Developer
Donator
Beta Tester
Joined
Feb 7, 2008
Messages
300
Reaction score
0
Points
16
Location
nassp.sf.net
Website
nassp.sf.net
Hi Jarmo,

after a long pause I had the chance to test the recent D3D9Client versions and can only repeat the praise, especially on Win7 with a recent graphics adapter your client is working a lot better then the inline client, very well done! :thumbup:

I noticed 2 things related to the 2D panels in NASSP (old panel API), I'm not sure if they are issues actually:

On both my old PC (ATI X1600 with 256MB) and my new PC (NVidia Quadro 2000M 2048MB) there's a "[WARNING] Texture Surface(0xXXX) (x,y) failed to release 1 instance(s) remains" message when switching between the panels. Log files are attached, as a test I removed every surface but the panel background from the panels, so you'll see only one " New Surface" call per switching. With all surfaces present the effect is the same, i.e. all surfaces get deleted and "1 instance(s) remains". Using the (very useful) "Ctrl-Shift-C" monitoring feature I cannot see any memory loss however, so I don't know if it's a problem actually.

On my old PC the client crashes after switching between the panels a couple of times with "[ERROR] .\D3D9Surface.cpp Line:541 Error:-2005532292 D3DXCreateTexture(...", see log file. The new one is running great however, so this might be not enough video memory or outdated drivers or another problem on my side, I just want to mention it.

Anyway, please keep up your great work, on my new PC I don't use the inline client anymore, your's better! :)

Cheers
Tschachim
 

Attachments

  • D3D9ClientLog.zip
    59.2 KB · Views: 4

ggrof

Member
Joined
Mar 5, 2011
Messages
93
Reaction score
0
Points
6
Location
São Paulo
Hi

My LC39 pad in the D3D Client RC 41 is weird, darker than the rest of the KSC tiles. Someone had a problem like this? What I have to do?
 

ggrof

Member
Joined
Mar 5, 2011
Messages
93
Reaction score
0
Points
6
Location
São Paulo
First, use D3D9 Client RC44, which is the latest update.

The problem is i´m using the Beta Version (P2) and the RC41 has the binaries for this version. The new LC39 mesh that comes in Orbiter 111105 is great, but when I use the D3D client, the pad´s tile is darker than the rest.
 

Ripley

Tutorial translator
Donator
Joined
Sep 12, 2010
Messages
3,135
Reaction score
409
Points
123
Location
Rome
Website
www.tuttovola.org
Hi Jarmo.
I just noticed that upon a new fresh O2010P1 installation, if I directly run orbiter_ng.exe for the first time ever (without launching orbiter.exe, that is), the "usual" DirectX check and all that stuff doesn't take place.

Isn't that somehow needed?
 

orb

New member
News Reporter
Joined
Oct 30, 2009
Messages
14,020
Reaction score
4
Points
0
I just noticed that upon a new fresh O2010P1 installation, if I directly run orbiter_ng.exe for the first time ever (without launching orbiter.exe, that is), the "usual" DirectX check and all that stuff doesn't take place.

Isn't that somehow needed?
It isn't needed at all if you know you have all requirements satisfied.

For example, I don't run it at all. I just copy orbiter.bin from the Install folder over the orbiter.exe in the root folder of the installation, or patch it with beta version, which has the actual Orbiter executable in the root folder of the archive.

The cause for the check with running the regular orbiter.exe for the first time is that it isn't actually Orbiter executable, but executable of the Installation verification tool, which replaces itself with the actual Orbiter executable after performing all the checks, and orbiter_ng.exe is always the same file (which executes Modules/Server/orbiter.exe with working directory set to Orbiter's root).
 

Marvin42

Mostly Harmless
Joined
Nov 1, 2011
Messages
67
Reaction score
0
Points
6
Alt-Tab

ALT-TAB

Is it my old rig too old or RC44 is always loosing connection to the Direct3DDevice when Alt-Tab is pressed or when searching at Help dialog from ALT-F1?
sanstitregup.png


Edit. Also it should be mentioned that the Dragonfly ship that comes with Orbiter is not working with D3D9Client (CTD)

---------- Post added 04-12-12 at 11:32 AM ---------- Previous post was 04-11-12 at 10:19 PM ----------


Moons Names
I was getting some errors in Orbiter.log:
Code:
Planet Not Found 'Kale                    '
hPlanet is NULL in FileParser::ScanBases(Config\Kale\Base)
Planet Not Found 'Ymir                    '
hPlanet is NULL in FileParser::ScanBases(Config\Ymir\Base)
Planet Not Found 'Paaliaq                 '
hPlanet is NULL in FileParser::ScanBases(Config\Paaliaq\Base)....etc
These moons have only one thing in common: in their cfg there is a comment like this:
Code:
; === Configuration file for moon Kale-S/2001_J8(Jupiter) by Rolf Keibel Carl Romanik and Tony Dunn ===
Name = Kale                    ; S2001-J8
EllipticOrbit = TRUE           ; assume unperturbed orbit
HasElements = TRUE             ; orbital elements follow .....etc

If I remove the " ; S2001-J8" comment, the error is gone.

Can the FileParser.cpp be made to check the "Name" string untill the ";" sign (or any other way to support having comments after the Name)?
Edit: If I have one or more " " (spaces) after the Name I get "Planet Not Found 'Ymir ".
 
Last edited:

kuddel

Donator
Donator
Joined
Apr 1, 2008
Messages
2,064
Reaction score
508
Points
113
Moons Names
I was getting some errors in Orbiter.log:
Code:
Planet Not Found 'Kale                    '
hPlanet is NULL in FileParser::ScanBases(Config\Kale\Base)
Planet Not Found 'Ymir                    '
hPlanet is NULL in FileParser::ScanBases(Config\Ymir\Base)
Planet Not Found 'Paaliaq                 '
hPlanet is NULL in FileParser::ScanBases(Config\Paaliaq\Base)....etc
These moons have only one thing in common: in their cfg there is a comment like this:
Code:
; === Configuration file for moon Kale-S/2001_J8(Jupiter) by Rolf Keibel Carl Romanik and Tony Dunn ===
Name = Kale                    ; S2001-J8
EllipticOrbit = TRUE           ; assume unperturbed orbit
HasElements = TRUE             ; orbital elements follow .....etc
If I remove the " ; S2001-J8" comment, the error is gone.

Can the FileParser.cpp be made to check the "Name" string untill the ";" sign (or any other way to support having comments after the Name)?
Edit: If I have one or more " " (spaces) after the Name I get "Planet Not Found 'Ymir ".

@jarmonik: A more robust line-parser like the following example might be an option

PHP:
#include <vector>
#include <iostream>

#include <functional> 
#include <algorithm>

using namespace std;

// trim from start
static inline std::string &ltrim(std::string &s) {
    s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int>(isspace))));
    return s;
}

// trim from end
static inline std::string &rtrim(std::string &s) {
    s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int>(isspace))).base(), s.end());
    return s;
}

// trim from both ends
static inline std::string &trim(std::string &s) {
    return ltrim(rtrim(s));
}

// split string into (multiple) parts
void split( vector<string> & theStringVector,  // Altered/returned value 
            const  string  & theString,
            const  string  & theDelimiter)
{
    _ASSERT(theDelimiter.size() > 0);

    size_t  start = 0, end = 0;

    while (end != string::npos) {
        end = theString.find( theDelimiter, start);

        // If at end, use length=maxLength.  Else use length=end-start.
        theStringVector.push_back(theString.substr(start,
            (end == string::npos) ? string::npos : end - start));

        // If at end, use start=maxSize.  Else use start=end+delimiter.
        start = (   ( end > (string::npos - theDelimiter.size()) )
            ?  string::npos  :  end + theDelimiter.size());
    }
}

// THE function ;)
int parseLine (
    const std::string &s,       ///< (in)           input string
    std::string &key,           ///< (out)          receives clean 'key'
    std::string &val,           ///< (out)          receives clean 'value'
    std::string &com = string() ///< (out,optional) receives clean 'comment'
    )
{
    vector<string> v, v2;
    int num = 0;

    key.erase(); val.erase(); com.erase();

    // 'remove' comment
    split(v, s, ";");
    if (v.size()) {

        // Handle 'pre-comment' part (v[0])
        split(v2, trim(v[0]), "=");
        if (v2.size())
        {
            key = trim(v2[0]);
            if (v2.size() == 2) {
                val = trim(v2[1]);
            }
        }

        // Handle 'comment' parts (v[1],...,v[n])
        if (v.size() >= 2)
        {
            com = ltrim(v[1]);
            for (size_t i = 2; i < v.size(); i++) {
                (com += ";") += v[i];
            }
            trim(com);
        }
    }

    if (!key.empty()) num |= 0x01;
    if (!val.empty()) num |= 0x02;
    if (!com.empty()) num |= 0x04;

    return num;
}


int main(int argc, char* argv[])
{
    // test-list
    const char* lst[] = {
        "name = Hello World   ; this is a comment with a = and a ; symbol ",
        "a",
        "this should not work = but it does ;)",
        "b\t\r\n\t ", // multi-line should not be fed, but should also create no errors ;)
        "a\t \t o",
        "syntax-error ; with = in comment",
        "; name = Hello World",
        "name = Hello World",
        // Block
        "WHATEVER",
        "END",

        NULL // end-of-list marker
    };

    string k, v, c;

    for (int i=0; lst[i]; i++) {

        int n = parseLine(lst[i], k, v, c);

        printf(           "line %2d  : '%s'\n", i, lst[i]);
        if (n & 1) printf("  key    : '%s'\n", k.c_str());
        if (n & 2) printf("  value  : '%s'\n", v.c_str());
        if (n & 4) printf("  comment: '%s'\n", c.c_str());
        printf(           "\n");

    }

    return 0;
}
The main() was just to test some 'exotic' lines ;)
In real life a simple
Code:
while(readLineFromFile(line)) {
  parseLine(line, key, value);
  ...
}

should be enough to get 'clean' key and value pairs

/Kuddel
 

Bibi Uncle

50% Orbinaut, 50% Developer
Addon Developer
Joined
Aug 12, 2010
Messages
192
Reaction score
0
Points
0
Location
Québec, QC
I already made some functions for that. It searches the config file based on "Name" flag and it removes spaces and comments automaticaly. Check in RunwayLights.cpp, for the private static methoeds RunwayLights::SearchConfigFile (and it uses RunwayLights::_fgets)

You can write a whole new file parser based on this.
 
Top