Freelancer Community Network
Reminder: Internet Explorer 6 or below are NOT supported.
HomeHome
ForumForum
WikiWiki
DownloadsDownloads
ForgeForge
Multiplayer Connection Tutorial
Collapse/Expand Random Image
Collapse/Expand Login
Username:

Password:

Remember me



Lost Password?

Register now!
Collapse/Expand Chat
Collapse/Expand Who's Online
59 user(s) are online (29 user(s) are browsing Forum)

Members: 1
Guests: 58

SobaniExile, more...
Collapse/Expand Donations
Monthly costs: -30€
Income (ads): +5€
Donations (last month): +10€

Current balance: -300€
(last updated 11/2017)

Please make a donation if you want to help keeping The-Starport online:

Bitcoin address:
Thanks!
Collapse/Expand Links
Collapse/Expand Advertisement
There are currently 98 users playing Freelancer on 34 servers.
November. 22, 2017

Browsing this Thread:   1 Anonymous Users



 Bottom   Previous Topic   Next Topic  Register To Post

« 1 2 (3) 4 5 »


Re: 3D Starchart - Teaser 1: Rendering Planets
Quite a regular
Joined:
2008/6/13 4:53
From Canada
Group:
Registered Users
Posts: 121
Offline
Well i am casting a ray from the mouse x,y into 3d space. this is the function that handles that:

Code:

Ray GetPickRay()
        {
            MouseState mouseState = Mouse.GetState();

            int mouseX = mouseState.X;
            int mouseY = mouseState.Y;

            Vector3 nearsource = new Vector3((float)mouseX, (float)mouseY, 0f);
            Vector3 farsource = new Vector3((float)mouseX, (float)mouseY, 1f);

            Matrix world = Matrix.CreateTranslation(0, 0, 0);

            Vector3 nearPoint = GraphicsDevice.Viewport.Unproject(nearsource,
                proj, view, world);

            Vector3 farPoint = GraphicsDevice.Viewport.Unproject(farsource,
                proj, view, world);

            // Create a ray from the near clip plane to the far clip plane.
            Vector3 direction = farPoint - nearPoint;
            direction.Normalize();
            Ray pickRay = new Ray(nearPoint, direction);

            return pickRay;
        }


the problem comes in when i loop through all the objects in the scene to get the object that is suppose to be selected the result value returned from ray.intersects is always : -1.#IND

so i tried changing the farSource to be the static system size, which does not really work at all except to move the camera to above the sun, or in the case of New York System, sometimes above West Point (mostly though is ends up above the sun)
---

forgive my ignorance of XNA here, i have not done allot with XNA so still feeling my way around to a large degree.

and for the planet rendering issue, i am not at all sure what is going on, the code is pretty much identical (just written in VB.NET not C#). As i said, the Planets are being added as valid system objects but just nothing rendering, or maybe they are rendering but could it be that the 'scale' of the planets is not being calculated right? not sure to be honest, my code matches yours so not sure what i am doing wrong.

I may try changing my app into C# and see if that changes anything.

to your question about why VB.NET instead of using C#? well mostly because i am more comfortable in VB environment. Nothing to do with the language or anything. And secondly, because i can. Also because there is a few quirks about C# i am not fond of.

Don't get me wrong though, i can code in C# just as well as VB or C++.

Posted on: 2011/3/31 19:47

Edited by J.Walker on 2011/3/31 19:54:24
Top
Re: 3D Starchart - Teaser 1: Rendering Planets
Quite a regular
Joined:
2008/6/13 4:53
From Canada
Group:
Registered Users
Posts: 121
Offline
well well, i will be a g*&*&*^ d&^*&^& monkey's uncle.

i did a quite conversion to C# of part of my project and bang, planets and proper lighting.

so i am moving forward to redo my project in solid C#.

anyway just thought i would let you know , cheers.

Posted on: 2011/4/1 4:36
Top
Re: 3D Starchart - Teaser 1: Rendering Planets

Joined:
2011/1/31 13:48
From Darmstadt Depot, Stuttgart System, Rheinland
Group:
Registered Users
Posts: 25
Offline
How do you convert between C# and VB.NET? Is it a VisualStudio function?
I'd like to try it so I can see what it does to my planet creation code.

I didn't want to start a religious war about programming languages here (well thankfully it didn't really start^^). Of course you should use VB if you have good reasons to do so.

Hopefully I'll find some time at the weekend to experiment with object selection (I had something similar working in another project, but it might be a bit harder here)

Don't worry about XNA, I'm a newbie, too. I actually did Starchart to learn a bit more about XNA than what you do in tutorials.

Posted on: 2011/4/1 13:35
MFG
Obstbaum

"What's the secret of time travel doing on Fry's ass?"
"It was bound to be somewhere"
Top
Re: 3D Starchart - Teaser 1: Rendering Planets
Just can't stay away
Joined:
2010/10/21 16:18
Group:
Registered Users
FLServer Admins
Posts: 202
Offline
i have a probleme with a custom FL :
"mat count 11!=12" or something similar.
i will post the exact message when i have some more time.
I think it's a probleme in the mod file, but didn't crash the game, anyway to ignore it and continue ?

Good job for your 0.5 release, it's work like a charm on vanilla FL, fast and precise

Posted on: 2011/4/1 14:38
Top
Anonymous
Re: 3D Starchart - Teaser 1: Rendering Planets
Anonymous-Anonymous
Wait... Does it read costum models? Or I'll have to wait for the Beta for that?

Posted on: 2011/4/1 18:31
Top
Re: 3D Starchart - Teaser 1: Rendering Planets
Quite a regular
Joined:
2008/6/13 4:53
From Canada
Group:
Registered Users
Posts: 121
Offline
No worries mate, i did not take it as a religious 'C# vs VB/NET' war. .

for converting code to and from c# to vb.net i use this:

http://converter.telerik.com/

works pretty good.

you just have to watch out though, some adjustments to the code need to be done.

for example, in your xna classes the object:

private Game game;

in VB would be:

private game as Game

but this will not work, so what i did is to simply change the varaible name to: igame:

private igame as Game

once you go to the page, copy your entire class code, paste it into the top textarea, and click convert. rinse repeat for each one.

there may be other things that may need to be adjusted once you put the converted code into a vb project but those should be pretty simple to do.

and to get the game to run you need to import the system.threading namespace, and do something like this, at least this is what i had to do:

Dim gameThread As Thread 'class level decaration

i put the thread start in the sub new, as mentioned below, because i have the game embedded in a custom user control.

public sub new()
gameThread = New Thread(AddressOf RunGame)
gameThread.Start()
end sub

private sub RunGame()
igame = New MainGame(mhandle, fdata, 1280, 720, True)
igame.Run()
end sub

i have embedded the game inside a windows usercontrol and then inside a windows form.

here is a screenshot of it in it's VB.NET version, and as you can see, lighting is all messed up because of the lack of planet rendering. And like i mentioned, I am still feeling my way around XNA. Using VB.NET or C# for game development is kinda foreign territory for me, for game dev i am use to C++, this though is kinda different. Although, C# feels more comfortable than VB for this.

if you use MSN, you can get me there at: r.orr AT hotmail DOT ca

Open in new window

Posted on: 2011/4/1 19:07
Top
Re: 3D Starchart - Teaser 1: Rendering Planets

Joined:
2011/1/31 13:48
From Darmstadt Depot, Stuttgart System, Rheinland
Group:
Registered Users
Posts: 25
Offline
Quote:

Ezekiel wrote:
i have a probleme with a custom FL :
"mat count 11!=12" or something similar.


I think I found where this comes from. Happens if a "material library" node contains more materials than its "material count" value would suggest. But it will still work, this is one of my many exceptions that are thrown on principle if there's an error in the file though the program would still work. Will remove it in the next release (which will come tonight or tomorrow , its already gone in the code on svn, if you want to build it yourself )

Quote:

Ezekiel wrote:
...anyway to ignore it and continue ?


If that works (see above) why not

Quote:

TheDvDMan wrote:
Wait... Does it read costum models? Or I'll have to wait for the Beta for that?


It might/should. Please, try it and give me some feedback if and how well it worked

@J.Walker
OK, that sounds much more complicated / time consuming than I hab hoped, so I can't promise I'll really try it...
But considering that so much has to be changed, of course there open up hundreds of possible sources for the planet rendering problem as well as the lighting problem (they aren't really connected).
Rendering of models and planets isn't much different except that the vertices for planets don't come from a file but are generated by a sphere formula (I didn't come up with that, copied it ). So the problem must lie there somewhere (PlanetRendere.generateSphere).
Lighting is another thing, it's all done in the shader (StarchartContent/effects/Models.fx and Planets.fx) so maybe there is a problem with the content pipeline (thats an XNA feature usually used to load all models, textures and effects. But as everything except these effects is loaded from the Freelancer game files it could be).
Well, as of now I can only speculate

About game development:
I know that it is usually done in C++ but I hate that language
Well seems I'm simply spoiled by garbage collection and large, well documentet libraries combined with welll working auto-complete, in other words by Java and .NET
And as .NET is much more performant than Java (and with VisualStudio has the best IDE ever) my choice was natural. As for C#, I really like the syntax and language features.
When I found out there was the XNA framework as wrapper for the DirectX API it was clear to me that my first serious game / 3D graphics project would be done in C# using XNA

Well, so much about my motives...

Your windows forms intergation looks really nice. I'm really glad my work seems already fit for use in other projects.

I finally worked out how to select objects in 3D space (your approach was exactly the right thing, except that for some strange reason it doesn't work when you set the z values of nearSource and farSource to 0 and 1, it must be larger than 1 so setting it to 2 and 3 works great. To find out what objects lie beneath the cursor I added BoundingBoxes to all objects so we can simply use Ray.Intersects)

I will update the SVN shortly and, as stated above, upload release 0.0.0.6 some time tonight or tomorrow.

Posted on: 2011/4/1 20:22

Edited by obstbaum on 2011/4/1 20:47:53
Edited by obstbaum on 2011/4/1 20:48:23
MFG
Obstbaum

"What's the secret of time travel doing on Fry's ass?"
"It was bound to be somewhere"
Top
Re: 3D Starchart - Teaser 1: Rendering Planets
Starport Staff
Joined:
2008/10/7 19:56
From England
Group:
Registered Users
Starport Staff
FLServer Admins
$$$ Supporters $$$
Senior Members
Posts: 624
Offline
This looked pretty cool, so I downloaded the binaries.

Quote:
WARNING: The runtime version supported by this application is unavailable.
Using default runtime: v1.1.4322

** (Starchart.exe:10299): WARNING **: The following assembly referenced from /home/alex/Downloads/FLStarchart/Starchart.exe could not be loaded:
Assembly: Microsoft.Xna.Framework.Game (assemblyref_index=0)
Version: 4.0.0.0
Public Key: 842cf8be1de50553
The assembly was not found in the Global Assembly Cache, a path listed in the MONO_PATH environment variable, or in the location of the executing assembly (/home/alex/Downloads/FLStarchart/).


** (Starchart.exe:10299): WARNING **: Could not load file or assembly 'Microsoft.Xna.Framework.Game, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553' or one of its dependencies.

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Xna.Framework.Game, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553' or one of its dependencies.
File name: "Microsoft.Xna.Framework.Game, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553"



And under Windows:
Open in new window

Any ideas?

Posted on: 2011/4/1 20:57
Top
Re: 3D Starchart - Teaser 1: Rendering Planets
Starport Admin
Joined:
2009/2/21 21:42
Group:
Webmasters
Registered Users
Posts: 3457
Offline
Have you installed the XNA framework? Seems like XNA 4 is what you need:

http://www.microsoft.com/downloads/en ... ae-42cd-a108-d35c013c3b97

Posted on: 2011/4/1 20:59
"Cynicism is not realistic and tough. It's unrealistic and kind of cowardly because it means you don't have to try."
-Peggy Noonan
Top
Re: 3D Starchart - Teaser 1: Rendering Planets

Joined:
2011/1/31 13:48
From Darmstadt Depot, Stuttgart System, Rheinland
Group:
Registered Users
Posts: 25
Offline
Quote:

FriendlyFire wrote:
Seems like XNA 4 is what you need


You definitely do.

And it looks like you are using mono, I have no idea if that works, I only tested it on windows 7 professional 64bit with both .NET and XNA frameworks installed (both in the development, not the client / redistributable versions)

Posted on: 2011/4/1 21:11
MFG
Obstbaum

"What's the secret of time travel doing on Fry's ass?"
"It was bound to be somewhere"
Top
Re: 3D Starchart - Teaser 1: Rendering Planets
Quite a regular
Joined:
2008/6/13 4:53
From Canada
Group:
Registered Users
Posts: 121
Offline
Thats good news about the object selection, i will eagerly wait for the 06 release.

for costumes it is really not that difficult to get than to display

In: FLApi.Characters.Costume.cs, change it to look like this:
Code:


using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using FLApi;
using FLApi.Solar;
using FLApi.Universe;
using FLParser;
using FLParser.Ini;
using FLParser.Utf;

namespace FLApi.Characters
{
    public class Costume
    {

        /// <summary>
        /// Gets or Sets the selected SpaceObject's Docking Character Costume
        /// </summary>
        public string costume 
        {
            set
            {
                m_costume = value;
                setcostume();
            }
            get
            {
                return m_costume;
            }
        }
        private string m_costume;

        public Costume(string s1, string s2)
        {
            if (s1 == null) s1 = "";
            if (s2 == null) s2 = "";

            if (s1 != String.Empty && s2 == String.Empty) this.costume = s1;
            if (s1 == String.Empty && s2 != String.Empty) this.costume = s2;            
            if (s1 != String.Empty && s2 != String.Empty) this.costume = s1 + ", " + s2;            
        }
                
        /// <summary>
        /// changes the spacecostume for the selected spaceobject
        /// </summary>
        private void setcostume(string newcostume = "")
        {
            // TODO: code it to allow changing the space_costume (Class: FLAPi.Characters.Costume, Function: setcostume(string newcostume = ""))
            if (!string.IsNullOrEmpty(newcostume))
            {
                this.m_costume = newcostume;
            }
        }
    }
}


then in FLApi.Universe.SpaceObject.cs

in function: public SpaceObject(...)

locate: case "space_costume":

and the line before: break;
change it to:
SpaceCostume = new Costume(e[0].ToString(), e[1].ToString());

and when you want to display the costume string read it from the costume property:

spaceObject.SpaceCostume.costume;

Posted on: 2011/4/1 21:31
Top
Anonymous
Re: 3D Starchart - Teaser 1: Rendering Planets
Anonymous-Anonymous
Dammit, it doesn't even work on my Windows (Vista Ultimate)!!!

Posted on: 2011/4/1 21:37
Top
Re: 3D Starchart - Teaser 1: Rendering Planets
Quite a regular
Joined:
2008/6/13 4:53
From Canada
Group:
Registered Users
Posts: 121
Offline
what doesn't work?

Posted on: 2011/4/1 21:40
Top
Anonymous
Re: 3D Starchart - Teaser 1: Rendering Planets
Anonymous-Anonymous
The program, what ealse?

Posted on: 2011/4/1 21:55
Top
Re: 3D Starchart - Teaser 1: Rendering Planets

Joined:
2011/1/31 13:48
From Darmstadt Depot, Stuttgart System, Rheinland
Group:
Registered Users
Posts: 25
Offline
ehm, I would be helpful if you posted the exact error message (if there was any). I would have thought if it works on 7 it would work on vista, if you have the .net and xna frameworks installed (see my previous posts)

Posted on: 2011/4/1 22:05
MFG
Obstbaum

"What's the secret of time travel doing on Fry's ass?"
"It was bound to be somewhere"
Top
« 1 2 (3) 4 5 »