seamless planetary descent with automaic mesh generation
Moderator: Mod Contributor
-
- Trader
- Posts: 22
- Joined: Mon Feb 11, 2008 11:31 am
seamless planetary descent with automaic mesh generation
Hello,
i'm new in this forum. I've downloaded the game in his stable version (0.4.3). I think this game has a great potential so i'd like to participate to the dev. I've developped a procedure in C++ allowing a vessel to fly from space to surface of a planet in real time. I join some screenshots of this procedure. If you are interresting in included this i can give you the source.
The surface of teh planet is procedural, the texture is a mix of original texture with a noise texture (i can join the pixel shader code)
Color of atmosphere is calculated in function of the star position so when you are on the opposite side => darker
have fun and comment wellcome.
i'm new in this forum. I've downloaded the game in his stable version (0.4.3). I think this game has a great potential so i'd like to participate to the dev. I've developped a procedure in C++ allowing a vessel to fly from space to surface of a planet in real time. I join some screenshots of this procedure. If you are interresting in included this i can give you the source.
The surface of teh planet is procedural, the texture is a mix of original texture with a noise texture (i can join the pixel shader code)
Color of atmosphere is calculated in function of the star position so when you are on the opposite side => darker
have fun and comment wellcome.
-
- Elite Mercenary
- Posts: 1329
- Joined: Thu Mar 27, 2003 11:51 pm
- Location: Manchester, UK
- Contact:
I guess the best thing for you to do would be to check out SVN (see wiki for details / instructions) and see how the planet, physics, and rendering code are different from your own so you can assess what aspects of your implementation can be applied to VS without having to start over.
Free Gamer - free software games compendium and commentary!
FreeGameDev forum - open source game development community
FreeGameDev forum - open source game development community
-
- The Shepherd
- Posts: 5841
- Joined: Fri May 13, 2005 8:37 pm
- Location: Ottawa
- Contact:
@Tarzan02 if you have any problems getting it to build just post in the Compiling Problems forum most problems are missing dependencies so a careful read of your failed configure is in order
Enjoy the Choice
Enjoy the Choice
my box::HP Envy i5-6400 @2Q70GHzx4 8 Gb ram/1 Tb(Win10 64)/3 Tb Mint 19.2/GTX745 4Gb acer S243HL K222HQL
Q8200/Asus P5QDLX/8 Gb ram/WD 2Tb 2-500 G HD/GF GT640 2Gb Mint 17.3 64 bit Win 10 32 bit acer and Lenovo ideapad 320-15ARB Win 10/Mint 19.2
Q8200/Asus P5QDLX/8 Gb ram/WD 2Tb 2-500 G HD/GF GT640 2Gb Mint 17.3 64 bit Win 10 32 bit acer and Lenovo ideapad 320-15ARB Win 10/Mint 19.2
-
- Lead Network Developer
- Posts: 2560
- Joined: Sun Jan 12, 2003 9:13 am
- Location: Palo Alto CA
- Contact:
Wow that looks awesome.
Just as a warning, the code is incredibly messy. But I figure you have already
I would recommend trying to cut out some part of the code to work on.
Maybe one way to start would be to completely override the Planet's Draw() function with something completely different.
Indeed I believe we do have support for detail textures (at least for plain Units), and if you look at the way that certain types of "citylights" are done it is similar to that (does repeating).
It would be cool if you could add in bump maps with our shader support.
Just as a warning, the code is incredibly messy. But I figure you have already
I would recommend trying to cut out some part of the code to work on.
Maybe one way to start would be to completely override the Planet's Draw() function with something completely different.
Indeed I believe we do have support for detail textures (at least for plain Units), and if you look at the way that certain types of "citylights" are done it is similar to that (does repeating).
It would be cool if you could add in bump maps with our shader support.
-
- Trader
- Posts: 22
- Joined: Mon Feb 11, 2008 11:31 am
-
- Lead Network Developer
- Posts: 2560
- Joined: Sun Jan 12, 2003 9:13 am
- Location: Palo Alto CA
- Contact:
-
- Lead Network Developer
- Posts: 2560
- Joined: Sun Jan 12, 2003 9:13 am
- Location: Palo Alto CA
- Contact:
Hi,
I don't know if the VC6 project works. We haven't had anyone develop with VC6 in years.
You really might have much better luck with VC8, although admittedly VC6 is much faster and isn't nearly as much of a pain to install.
Also, if you want, could you post code for the demo screenshots you posted? If you don't have the time and persistence to work on the Vega Strike engine, someone else might be able to help out.
I don't know if the VC6 project works. We haven't had anyone develop with VC6 in years.
You really might have much better luck with VC8, although admittedly VC6 is much faster and isn't nearly as much of a pain to install.
Also, if you want, could you post code for the demo screenshots you posted? If you don't have the time and persistence to work on the Vega Strike engine, someone else might be able to help out.
-
- Trader
- Posts: 22
- Joined: Mon Feb 11, 2008 11:31 am
sure. The first thing i will do it's to modify the (vertex and pixel shader => fragment program ???) to add a noise texture in order to break a little the planet texture => the render will be more natureal.
Question: I've donwload the source but i can't locate the fragment program someone can tell me where are the fragment program ?
Here you can find the vertex and pixel shader i use (noise is in texture stage 1, planet texture is in texture stage 0)
vertex shader
vs.2.0
dcl_position v0; ; declare position
dcl_normal v1; ; declare normal
dcl_color v2; ; declare color
dcl_texcoord0 v3; ; declare texture coordinate
; transpose and transform position to clip space
m4x4 oPos,v0,c4
;le 200607
; calculate light vector
mov r3,c8
m4x4 r2,r3,c0
; normalize light vector
dp3 r2.w, r2, r2
rsq r2.w, r2.w
mul r2, r2, r2.w
; calculate light color
dp3 r3, v1, r2 ; dp3 with negative light vector
add r3,r3,c20 ;
min r3,r3,c21 ; prendre max 1
lit r5, r3 ; clamp to zero if r3 < 0, r5 has diffuce component in r5.y
mul r5.xyz, r5.y, c9 ; ouput diffuse color
add oD0,r5,c19
mov oT0, v3 ; store texture coordinates
pixel shader:
ps_2_0
dcl_2d s0
dcl_2d s1
def c0, 50.000000, 500.000000, 2.600000, 10000.000000 => the factor to
dcl t0.xy => the planet texture
dcl t1.xy => the noise texture
dcl v0
texld r3, t0, s0 => loading of the texture color
mul r2.xy, t1, c0.x => now i multiply the u,v coord by the factir
mul r0.xy, t1, c0.w
mul r1.xy, t1, c0.y
texld r4, r2, s1 => loading of the tecture noise color from the scaled coord
texld r0, r0, s1
texld r1, r1, s1
texld r2, t1, s1
mul r2, r3, r2 => multiply all the value together
mul r2, r4, r2
mul r1, r1, c0.z
mul r0, r0, c0.z
mul r1, r2, r1
mul r0, r1, r0
mul r0, r0, c0.z
mul r0,r0,v0 => taking the color of the vertex in account
mov oC0, r0 => all that in the output register ==> that's all
i'll make a zip of my planetary code (it's including all the work to culled the triangle not seen)
Question: I've donwload the source but i can't locate the fragment program someone can tell me where are the fragment program ?
Here you can find the vertex and pixel shader i use (noise is in texture stage 1, planet texture is in texture stage 0)
vertex shader
vs.2.0
dcl_position v0; ; declare position
dcl_normal v1; ; declare normal
dcl_color v2; ; declare color
dcl_texcoord0 v3; ; declare texture coordinate
; transpose and transform position to clip space
m4x4 oPos,v0,c4
;le 200607
; calculate light vector
mov r3,c8
m4x4 r2,r3,c0
; normalize light vector
dp3 r2.w, r2, r2
rsq r2.w, r2.w
mul r2, r2, r2.w
; calculate light color
dp3 r3, v1, r2 ; dp3 with negative light vector
add r3,r3,c20 ;
min r3,r3,c21 ; prendre max 1
lit r5, r3 ; clamp to zero if r3 < 0, r5 has diffuce component in r5.y
mul r5.xyz, r5.y, c9 ; ouput diffuse color
add oD0,r5,c19
mov oT0, v3 ; store texture coordinates
pixel shader:
ps_2_0
dcl_2d s0
dcl_2d s1
def c0, 50.000000, 500.000000, 2.600000, 10000.000000 => the factor to
dcl t0.xy => the planet texture
dcl t1.xy => the noise texture
dcl v0
texld r3, t0, s0 => loading of the texture color
mul r2.xy, t1, c0.x => now i multiply the u,v coord by the factir
mul r0.xy, t1, c0.w
mul r1.xy, t1, c0.y
texld r4, r2, s1 => loading of the tecture noise color from the scaled coord
texld r0, r0, s1
texld r1, r1, s1
texld r2, t1, s1
mul r2, r3, r2 => multiply all the value together
mul r2, r4, r2
mul r1, r1, c0.z
mul r0, r0, c0.z
mul r1, r2, r1
mul r0, r1, r0
mul r0, r0, c0.z
mul r0,r0,v0 => taking the color of the vertex in account
mov oC0, r0 => all that in the output register ==> that's all
i'll make a zip of my planetary code (it's including all the work to culled the triangle not seen)
-
- Lead Network Developer
- Posts: 2560
- Joined: Sun Jan 12, 2003 9:13 am
- Location: Palo Alto CA
- Contact:
The programs are in the "data4.x" module.
To download them from HTTP without the whole data, you can go to
http://vegastrike.svn.sourceforge.net/v ... /programs/
We use GLSL for the shaders, but they should be pretty easy to convert.
To download them from HTTP without the whole data, you can go to
http://vegastrike.svn.sourceforge.net/v ... /programs/
We use GLSL for the shaders, but they should be pretty easy to convert.
-
- Lead Network Developer
- Posts: 2560
- Joined: Sun Jan 12, 2003 9:13 am
- Location: Palo Alto CA
- Contact:
-
- Elite Mercenary
- Posts: 1329
- Joined: Thu Mar 27, 2003 11:51 pm
- Location: Manchester, UK
- Contact:
Any progress?
Free Gamer - free software games compendium and commentary!
FreeGameDev forum - open source game development community
FreeGameDev forum - open source game development community
-
- Trader
- Posts: 22
- Joined: Mon Feb 11, 2008 11:31 am
OK, i've rewrite the vertex and pixel shader in order to work in opengl, some loose of perf. Investigate in the problem (i've lost 10% in perf than with directx).
vertex shader:
!!ARBvp1.0
# part of the Irrlicht Engine Shader example.
# Please note that these example shaders don't do anything really useful.
# They only demonstrate that shaders can be used in Irrlicht.
#input
ATTRIB InPos = vertex.position;
ATTRIB InColor = vertex.color;
ATTRIB InNormal = vertex.normal;
ATTRIB InTexCoord = vertex.texcoord;
#output
OUTPUT OutPos = result.position;
OUTPUT OutColor = result.color;
OUTPUT OutTexCoord = result.texcoord[0];
OUTPUT OutTexCoord1=result.texcoord[1];
PARAM MVP[4] = { state.matrix.mvp }; # modelViewProjection matrix.
TEMP TempColor;
TEMP TempNormal;
TEMP TempPos;
#transform position to clip space
DP4 OutPos.x, MVP[0], InPos;
DP4 OutPos.y, MVP[1], InPos;
DP4 OutPos.z, MVP[2], InPos;
DP4 OutPos.w, MVP[3], InPos;
# calculate light vector
DP3 TempPos.x,program.local[8].x,program.local[0];
DP3 TempPos.y,program.local[8].y,program.local[0];
DP3 TempPos.z,program.local[8].z,program.local[0];
#ADD TempPos, program.local[8], -TempPos; # vtxpos - lightpos
# normalize light vector
DP3 TempPos.w, TempPos, TempPos;
RSQ TempPos.w, TempPos.w;
MUL TempPos, TempPos, TempPos.w;
# calculate light color
DP3 TempColor, InNormal, TempPos; # dp3 with negative light vector
ADD TempColor,TempColor,program.local[20];
MIN TempColor,TempColor,program.local[21];
LIT TempColor, TempColor; # clamp to zero if r3 < 0, r5 has diffuce component in r5.y
MUL TempColor.xyz, TempColor.y, program.local[9]; # ouput diffuse color
#MOV TempColor,program.local[9];
ADD OutColor,TempColor,program.local[19];
MOV OutTexCoord, InTexCoord; # store texture coordinate
MOV OutTexCoord1, InTexCoord; # store texture coordinate
END
pixel shader:
!!ARBfp1.0
# part of the Irrlicht Engine Shader example.
# Please note that these example shaders don't do anything really useful.
# They only demonstrate that shaders can be used in Irrlicht.
#Input
ATTRIB inTexCoord = fragment.texcoord[0]; # texture coordinates
ATTRIB inTexCoord1=fragment.texcoord[1]; # texture coordinates de la texture noise
ATTRIB inColor = fragment.color.primary; # interpolated diffuse color
#Output
OUTPUT outColor = result.color;
PARAM c[1] = { { 50,500,3,10000 } };
TEMP R0;
TEMP R1;
TEMP R2;
TEMP R3;
TEMP R4;
TEX R3, inTexCoord, texture[0], 2D;
MUL R2.xy, inTexCoord1, c[0].x;
MUL R0.xy, inTexCoord1, c[0].w;
MUL R1.xy, inTexCoord1, c[0].y;
TEX R4, R2, texture[1], 2D;
#TEX R0, R0, texture[1], 2D;
#TEX R1, R1, texture[1], 2D;
#TEX R2, inTexCoord1, texture[1], 2D;
#MUL R2,R3,R2;
#MUL R2,R4,R2;
#MUL R1,R1,c[0].z;
#MUL R0,R0,c[0].z;
#MUL R1,R2,R1;
#MUL R0,R1,R0;
#MUL R0,R0,c[0].z;
#MUL result.color, R0, inColor;
ADD R3,R3,R4;
TEX R2, R0, texture[1], 2D;
ADD R3,R3,R2;
TEX R2, R1, texture[1], 2D;
ADD R3,R3,R2;
MOV R1,inTexCoord1;
TEX R2, R1, texture[1], 2D;
ADD R3,R3,R2;
ADD R3,R3,c[0].z;
MUL result.color,R3,inColor;
END
allways the noise texture in texture stage 1 and the planet texture in texture stage 0
Continue the work in my free time.
vertex shader:
!!ARBvp1.0
# part of the Irrlicht Engine Shader example.
# Please note that these example shaders don't do anything really useful.
# They only demonstrate that shaders can be used in Irrlicht.
#input
ATTRIB InPos = vertex.position;
ATTRIB InColor = vertex.color;
ATTRIB InNormal = vertex.normal;
ATTRIB InTexCoord = vertex.texcoord;
#output
OUTPUT OutPos = result.position;
OUTPUT OutColor = result.color;
OUTPUT OutTexCoord = result.texcoord[0];
OUTPUT OutTexCoord1=result.texcoord[1];
PARAM MVP[4] = { state.matrix.mvp }; # modelViewProjection matrix.
TEMP TempColor;
TEMP TempNormal;
TEMP TempPos;
#transform position to clip space
DP4 OutPos.x, MVP[0], InPos;
DP4 OutPos.y, MVP[1], InPos;
DP4 OutPos.z, MVP[2], InPos;
DP4 OutPos.w, MVP[3], InPos;
# calculate light vector
DP3 TempPos.x,program.local[8].x,program.local[0];
DP3 TempPos.y,program.local[8].y,program.local[0];
DP3 TempPos.z,program.local[8].z,program.local[0];
#ADD TempPos, program.local[8], -TempPos; # vtxpos - lightpos
# normalize light vector
DP3 TempPos.w, TempPos, TempPos;
RSQ TempPos.w, TempPos.w;
MUL TempPos, TempPos, TempPos.w;
# calculate light color
DP3 TempColor, InNormal, TempPos; # dp3 with negative light vector
ADD TempColor,TempColor,program.local[20];
MIN TempColor,TempColor,program.local[21];
LIT TempColor, TempColor; # clamp to zero if r3 < 0, r5 has diffuce component in r5.y
MUL TempColor.xyz, TempColor.y, program.local[9]; # ouput diffuse color
#MOV TempColor,program.local[9];
ADD OutColor,TempColor,program.local[19];
MOV OutTexCoord, InTexCoord; # store texture coordinate
MOV OutTexCoord1, InTexCoord; # store texture coordinate
END
pixel shader:
!!ARBfp1.0
# part of the Irrlicht Engine Shader example.
# Please note that these example shaders don't do anything really useful.
# They only demonstrate that shaders can be used in Irrlicht.
#Input
ATTRIB inTexCoord = fragment.texcoord[0]; # texture coordinates
ATTRIB inTexCoord1=fragment.texcoord[1]; # texture coordinates de la texture noise
ATTRIB inColor = fragment.color.primary; # interpolated diffuse color
#Output
OUTPUT outColor = result.color;
PARAM c[1] = { { 50,500,3,10000 } };
TEMP R0;
TEMP R1;
TEMP R2;
TEMP R3;
TEMP R4;
TEX R3, inTexCoord, texture[0], 2D;
MUL R2.xy, inTexCoord1, c[0].x;
MUL R0.xy, inTexCoord1, c[0].w;
MUL R1.xy, inTexCoord1, c[0].y;
TEX R4, R2, texture[1], 2D;
#TEX R0, R0, texture[1], 2D;
#TEX R1, R1, texture[1], 2D;
#TEX R2, inTexCoord1, texture[1], 2D;
#MUL R2,R3,R2;
#MUL R2,R4,R2;
#MUL R1,R1,c[0].z;
#MUL R0,R0,c[0].z;
#MUL R1,R2,R1;
#MUL R0,R1,R0;
#MUL R0,R0,c[0].z;
#MUL result.color, R0, inColor;
ADD R3,R3,R4;
TEX R2, R0, texture[1], 2D;
ADD R3,R3,R2;
TEX R2, R1, texture[1], 2D;
ADD R3,R3,R2;
MOV R1,inTexCoord1;
TEX R2, R1, texture[1], 2D;
ADD R3,R3,R2;
ADD R3,R3,c[0].z;
MUL result.color,R3,inColor;
END
allways the noise texture in texture stage 1 and the planet texture in texture stage 0
Continue the work in my free time.
-
- Elite Mercenary
- Posts: 1329
- Joined: Thu Mar 27, 2003 11:51 pm
- Location: Manchester, UK
- Contact:
Don't worry too much about performance. Whilst important, functional>performing, and detail can be kept down to maintain speed.
Also many eyes can help with functioning code to optimize and improve, whereas only a few can make code originally functional.
Anyway, I'm watching this one keenly.
Also many eyes can help with functioning code to optimize and improve, whereas only a few can make code originally functional.
Anyway, I'm watching this one keenly.
Free Gamer - free software games compendium and commentary!
FreeGameDev forum - open source game development community
FreeGameDev forum - open source game development community
-
- Trader
- Posts: 22
- Joined: Mon Feb 11, 2008 11:31 am
So, now i will begin to work in the planetary descent. I need help for the code.
I plan to work in several step:
first: generate some base on the planet surface (without taking the height map in count) so i need help in:
-disable the docking procedure on planet descent (strike 'd' key) in order to manage the planetary base as an orbit base.
-generate the coord of the base (polar coord and computing the x, y and z coordinate ??)
-manage the base as an orbit base.
second:
-add detail to the planet based on the camera view (allways without the heightmap)
Thank's for your help
I plan to work in several step:
first: generate some base on the planet surface (without taking the height map in count) so i need help in:
-disable the docking procedure on planet descent (strike 'd' key) in order to manage the planetary base as an orbit base.
-generate the coord of the base (polar coord and computing the x, y and z coordinate ??)
-manage the base as an orbit base.
second:
-add detail to the planet based on the camera view (allways without the heightmap)
Thank's for your help
-
- Elite
- Posts: 8014
- Joined: Fri Sep 05, 2003 4:03 am
- Location: Montreal
- Contact:
I'm no engine guru, Tarzan, but I think you need to ask more specific questions to get help. First point comes later, it would seem to me, when it's time to integrate --unless you need that for testing. Second point I think you'll need to do that yourself. Third point I don't understand. Last point is the million dollar question, I think.
Latest version of Cinemut Opaque
Latest version of LaGrande noodleworks (scroll down).
An evolving La Grande How-To...
The non-working, but latest, CineMut test_bike
PU (Privateer: Parallel Universe's Home). WC or Privateer Drayman for you?
WCpedia --The Wing Commander Encyclopedia-- From Angel Deveraux through Belisarius to Zachary Banfeld...
WC Nexus forum, the Moonbase Tycho of WC fans.
Latest version of LaGrande noodleworks (scroll down).
An evolving La Grande How-To...
The non-working, but latest, CineMut test_bike
PU (Privateer: Parallel Universe's Home). WC or Privateer Drayman for you?
WCpedia --The Wing Commander Encyclopedia-- From Angel Deveraux through Belisarius to Zachary Banfeld...
WC Nexus forum, the Moonbase Tycho of WC fans.
-
- Developer
- Posts: 2150
- Joined: Mon Apr 23, 2007 1:17 am
- Location: Pennsylvania
- Contact:
I know this has been brought up.. but assuming you get detail mesh generation to work (which is 50% of the problem, because you can already pretty much crash into the surface of a planet), how will you texture this detail?
Basically, what is your goal with planetary flight? Do we want it to look all Flight Simulator like, generic and indistinguishable, or what? I forsee many textures related to each planetary type. in either setup. Plus, fly through clouds? etc, that's a lot of gl effects that we currently dont have.
But in any case, getting the first 50% done without any textures would be impressive, and likely useful for things other than planets.
Basically, what is your goal with planetary flight? Do we want it to look all Flight Simulator like, generic and indistinguishable, or what? I forsee many textures related to each planetary type. in either setup. Plus, fly through clouds? etc, that's a lot of gl effects that we currently dont have.
But in any case, getting the first 50% done without any textures would be impressive, and likely useful for things other than planets.
Ed Sweetman endorses this message.
-
- Lead Network Developer
- Posts: 2560
- Joined: Sun Jan 12, 2003 9:13 am
- Location: Palo Alto CA
- Contact:
As safemode said, mesh generation is much more important than landable bases... if you can add the ability to get close to the planet before hitting 'd', then that's most of the work...
There's a variable in section "physics" called "num_planet_docking_port".
If you set that to 0, planets will have no docking ports, do hitting 'd' will not cause you to dock.
There is preliminary support for 'space elevators'... you may be able to use some of that code without making them actual elevators.
For now, you can make bases into orbiting units with a very low radius.
Orbits are ellipses, so the way you do it for a round orbit is to have ri,rj,rk have magnitutude equal to the planet's radius. Same goes for si,sj,sk, as long as it is perpendicular to ri,rj,rk (R dot S == 0)
If you want this orbiting in a circle around the equator, I think you might be able to do ri=radius, rj=0, rk=0, si=0, sj=radius, sk=0. Then, I think you make sure the "year" variable matches the "day" of the planet, and the "day" variable is either 0 or the same as the "year"....
There's a variable in section "physics" called "num_planet_docking_port".
If you set that to 0, planets will have no docking ports, do hitting 'd' will not cause you to dock.
There is preliminary support for 'space elevators'... you may be able to use some of that code without making them actual elevators.
For now, you can make bases into orbiting units with a very low radius.
Orbits are ellipses, so the way you do it for a round orbit is to have ri,rj,rk have magnitutude equal to the planet's radius. Same goes for si,sj,sk, as long as it is perpendicular to ri,rj,rk (R dot S == 0)
If you want this orbiting in a circle around the equator, I think you might be able to do ri=radius, rj=0, rk=0, si=0, sj=radius, sk=0. Then, I think you make sure the "year" variable matches the "day" of the planet, and the "day" variable is either 0 or the same as the "year"....
-
- Elite Mercenary
- Posts: 1329
- Joined: Thu Mar 27, 2003 11:51 pm
- Location: Manchester, UK
- Contact:
Once the mesh generation is done, I suspect you'll see a few developers come out the woodwork to help with the other aspects (GL effects etc). The major effort is getting it going on a basic level, after that it's all joy =).
Free Gamer - free software games compendium and commentary!
FreeGameDev forum - open source game development community
FreeGameDev forum - open source game development community
-
- Developer
- Posts: 2150
- Joined: Mon Apr 23, 2007 1:17 am
- Location: Pennsylvania
- Contact:
you can get close to a planet now. Very very close. The thing is, there is no detail generation. That's all that's missing from that. Also, there is no sense of atmosphere, since the textures are just layered on top of eachother, with no concern for depth.
I'm still unconvinced that there is a place for this within VS. maybe for other mods....but i dont see the payoff. Nothing stopping you though. I'd just feel much happier about a whole new smooth wormhole animation with a nifty in-transit fullscreen video played on another thread while the new system loads ... Or auto-docking the correct way or larger ships utilizing shuttles to interact with bases/ships. In the end though, i guess someone will be able to use this feature so i'll just shut up.
I'm still unconvinced that there is a place for this within VS. maybe for other mods....but i dont see the payoff. Nothing stopping you though. I'd just feel much happier about a whole new smooth wormhole animation with a nifty in-transit fullscreen video played on another thread while the new system loads ... Or auto-docking the correct way or larger ships utilizing shuttles to interact with bases/ships. In the end though, i guess someone will be able to use this feature so i'll just shut up.
Ed Sweetman endorses this message.
-
- Trader
- Posts: 22
- Joined: Mon Feb 11, 2008 11:31 am
High, thanks for your reply.
Actually i've two class in my program: planet class (preparation of the impostor, preparation of the display, etc...) planetscenenode class, this doing the most interresting things: display the planet mesh root (consisting of a spherical mesh with few triangles (allmost 1280) visible from a far distance, and displaying the detailed mesh (only the part near the camera is detailed, the detailed can be up to 10000 triangles (depend on the graphical card and the cpu power)).
in order to decrease the time of display, i use the impostor technic, i can display a planet with its satellites with a descent framerate (when only impostors are used, i can run at 400 fps, of course without any vessels).
the planetscenenode uses the camera position and the planete position to determinate the level of tessalation of the mesh. i join the piece of code which realize the split of the mesh:
each triangle is a structure contening several information, the sons of the triangle (when i split, the triangle is divided in 4 sons)
/*====================================================
Fonctino de split des triangles avec gestion du
relief
=====================================================*/
bool CPlaneteSceneNode::SplitTriangleDetail(STriangle *tri,float dt)
{
int i;
// On verifie la place disponible
if (NbTriangles>9990) return false;
// On essaye de spliter un triangle dont le pointeur est NULL => erreur
if (tri==NULL)
{
return false;
}
// Testons si le triangle a deja ete splittee
if (tri->f[0]!=NULL)
{
// Le triangle a deja ete splite => faux
return false;
}
// Pas plus du niveau 7 de split
if (tri->Seuil==10) return false;
if (tri->p!=NULL)
{
for (i=0;i<3;i++)
{
// test du fils 3
if (tri->p->f[3]==tri)
{
// Il faut spliter les voisins du triangle parent
for (i=0;i<3;i++)
{
SplitTriangleDetail(tri->p->e,dt);
}
}
// 2 solutions soit on split le voisin si il n'est pas deja spliter => recursif
// if (tri->e==NULL)
// {
// if (NbTriangles>9990) return false;
// SplitTriangleDetail(tri->p->e);
// }
// soit on ne split un triangle que si le voisin est deja splite => + rapide mais - joli
if (tri->e==NULL) return false;
}
}
// Creation des points milieux
vector3df n[3],nn[3];
bool bn[3];
myRnd->PseudoRandom(tri->Seed);
float Alpha,UnAlpha; // Coeeficient de poid pour les points du triangle
/* Alpha=0.45f+(float)myRnd->PseudoRandom()/RAND_MAX*0.1f;
UnAlpha=1.0f-Alpha;
n[0]=tri->s[0].Pos*UnAlpha+tri->s[1].Pos*Alpha;
bn[0]=false;
n[1]=tri->s[1].Pos*UnAlpha+tri->s[2].Pos*Alpha;
bn[1]=false;
n[2]=tri->s[2].Pos*UnAlpha+tri->s[0].Pos*Alpha;
bn[2]=false;*/
Alpha=0.5f;
UnAlpha=0.5f;
n[0]=(tri->s[0].Pos+tri->s[1].Pos)/2.0f;
bn[0]=false;
n[1]=(tri->s[1].Pos+tri->s[2].Pos)/2.0f;
bn[1]=false;
n[2]=(tri->s[2].Pos+tri->s[0].Pos)/2.0f;
bn[2]=false;
vector2df t[3],uv[3];
t[0]=(tri->s[0].TCoords*UnAlpha+tri->s[1].TCoords*Alpha);
t[1]=(tri->s[1].TCoords*UnAlpha+tri->s[2].TCoords*Alpha);
t[2]=(tri->s[2].TCoords*UnAlpha+tri->s[0].TCoords*Alpha);
// Calcul de la valeur de la couleur des points en fonction des coordonnees U et V
// et calcule de la hauteur correspondante h1
float h1[3];
int h;
int u,v;
if (p_Planete->PlaneteMap!=NULL)
{
for (i=0;i<3;i++)
{
// La planete possede une map
// On genere les hauteurs en fonction de cette map
// La hauteur des points representant la valeur de la map pour
// les coordonnes U et V du point
u=(int)(255.0f*t.X);
v=(int)(255.0f*t.Y);
if (u>255) u=255;
if (v>255) v=255;
h=*(p_Planete->PlaneteMap+u*256+v);
h1=(float)h;
// if (h1>130.0f) h1*=3.0f;
if (h1>200.0f) h1[i]*=7.0f;
h1[i]+=324000.0f;
// if (((h1[i])/dt)<ERREUR_SPLIT) return false;
}
}
else
{
// La planete est plutot plate (telle est gazeux)
h1[0]=324000.0f;
h1[1]=324000.0f;
h1[2]=324000.0f;
}
// Deplacement des points milieux ssi le voisin a deja des fils
{
for (i=0;i<3;i++)
{
if ((tri->e[i]!=NULL)&&(tri->e[i]->f[0]!=NULL))
{
if (tri->Seuil<3)
{
// Init du gene aleatoire
// OK le voisin a des fils => leger deplacement
nn[i]=n[i];
nn[i].normalize();
bn[i]=true;
n[i]=nn[i]*h1[i];
int it0=SharedEdge(tri->e[i],tri);
int it1=it0+1; if (it1>2) it1=0;
int it2=it1+1; if (it2>2) it2=0;
tri->e[i]->f[it0]->s[it1].Pos=n[i];
tri->e[i]->f[it1]->s[it0].Pos=n[i];
tri->e[i]->f[3]->s[it2].Pos=n[i];
}
else
{
// Init du gene aleatoire avec le seed du triangle afin de toujours avoir
// le meme deplacement dans le split du triangle
myRnd->PseudoRandom(tri->Seed);
int it0=SharedEdge(tri->e[i],tri);
int it1=it0+1; if (it1>2) it1=0;
int it2=it1+1; if (it2>2) it2=0;
// On deplace entre le min et le max
float Min,Max;
float r;
// Recuperation de la hauteur des 2 points limites
Min=tri->s[it1].Pos.dotProduct(tri->s[it1].Normal);
Max=tri->s[it2].Pos.dotProduct(tri->s[it2].Normal);
if (Max<Min)
{
r=Max;
Max=Min;
Min=r;
}
// Calcul du delta / 2
Max-=Min;
Max/=2.0f;
// Bon a priori il faut normaliser => indicateur positonne
bn[i]=true;
nn[i]=n[i];
nn[i].normalize();
// Calcul de la hauteur du point intermediaire
n[i]+=nn[i]*Max*((((float)myRnd->PseudoRandom()/(RAND_MAX*2.0f))-0.25f)-0.25f*(float)myRnd->PseudoRandom()/RAND_MAX);
// n[i]+=nn[i]*Max*(((float)rand()/(RAND_MAX))-0.5f);
// La on peut ajouter des variables telles que
// la rugosite, l'erosion, etc... en fonction des planetes
// et on met tout cela dans les bons triangles
tri->e[i]->f[it0]->s[it1].Pos=n[i];
tri->e[i]->f[it1]->s[it0].Pos=n[i];
tri->e[i]->f[3]->s[it2].Pos=n[i];
}
}
}
}
// Creation des fils
// Fils 0
tri->f[0]=AllocateTriangle();
tri->f[0]->s[0]=tri->s[0];
tri->f[0]->s[1].Pos=n[0];
tri->f[0]->s[1].Color=SColor(255,255,255,255);
tri->f[0]->s[1].TCoords=t[0];
// si l'indicateur nn correspondant n'est pas positionne => normalize
if (!bn[0])
{
// Pas encore normalise
n[0].normalize();
tri->f[0]->s[1].Normal=n[0];
}
else
{
// deja normalise
tri->f[0]->s[1].Normal=nn[0];
}
tri->f[0]->s[2].Pos=n[2];
tri->f[0]->s[2].Color=SColor(255,255,255,255);
tri->f[0]->s[2].TCoords=t[2];
if (!bn[2])
{
n[2].normalize();
tri->f[0]->s[2].Normal=n[2];
}
else
{
// deja normalise
tri->f[0]->s[2].Normal=nn[2];
}
tri->f[0]->Sup=false;
tri->f[0]->Systeme=false;
tri->f[0]->Nuage=false;
// Fils 1
tri->f[1]=AllocateTriangle();
tri->f[1]->s[1]=tri->s[1];
tri->f[1]->s[0]=tri->f[0]->s[1];
tri->f[1]->s[2].Pos=n[1];
tri->f[1]->s[2].Color=SColor(255,255,255,255);
tri->f[1]->s[2].TCoords=t[1];
if (!bn[1])
{
n[1].normalize();
tri->f[1]->s[2].Normal=n[1];
}
else
{
// Deja normalise
tri->f[1]->s[2].Normal=nn[1];
}
tri->f[1]->Sup=false;
tri->f[1]->Systeme=false;
tri->f[1]->Nuage=false;
// Fils2
tri->f[2]=AllocateTriangle();
tri->f[2]->s[0]=tri->f[0]->s[2];
tri->f[2]->s[1]=tri->f[1]->s[2];
tri->f[2]->s[2]=tri->s[2];
tri->f[2]->Sup=false;
tri->f[2]->Systeme=false;
tri->f[2]->Nuage=false;
// Fils 3
tri->f[3]=AllocateTriangle();
tri->f[3]->s[0]=tri->f[1]->s[2];
tri->f[3]->s[1]=tri->f[2]->s[0];
tri->f[3]->s[2]=tri->f[1]->s[0];
tri->f[3]->Sup=false;
tri->f[3]->Systeme=false;
tri->f[3]->Nuage=false;
// Gestion des nuages ou particule
if (p_Planete->TypePlanete==PLANETE_VOLCANIQUE)
{
// if (tri->Seuil==7) AjouteParticule(tri->f[0]);
}
// if (p_Planete->Atmosphere)
// {
// if (tri->Seuil==2) AjouteNuage(tri->f[0]);
// }
// Mise en place des parents et des seuils
myRnd->PseudoRandom(tri->Seed);
vector3df pt;
bool WaterLine;
int j;
for (i=0;i<4;i++)
{
tri->f[i]->p=tri;
tri->f[i]->Seuil=tri->Seuil+1;
tri->f[i]->Seed=myRnd->PseudoRandom();
}
// Chargement des normales definissant les plans pour le calcul des intersections des triangles
pt=tri->f[0]->s[2].Normal-tri->f[0]->s[0].Normal;
tri->f[0]->Normal[0]=tri->f[0]->s[0].Normal.crossProduct(pt);
pt=tri->f[0]->s[0].Normal-tri->f[0]->s[1].Normal;
tri->f[0]->Normal[1]=tri->f[0]->s[1].Normal.crossProduct(pt);
pt=tri->f[0]->s[1].Normal-tri->f[0]->s[2].Normal;
tri->f[0]->Normal[2]=tri->f[0]->s[2].Normal.crossProduct(pt);
pt=tri->f[1]->s[2].Normal-tri->f[1]->s[0].Normal;
tri->f[1]->Normal[0]=tri->f[1]->s[0].Normal.crossProduct(pt);
pt=tri->f[1]->s[0].Normal-tri->f[1]->s[1].Normal;
tri->f[1]->Normal[1]=tri->f[1]->s[1].Normal.crossProduct(pt);
pt=tri->f[1]->s[1].Normal-tri->f[1]->s[2].Normal;
tri->f[1]->Normal[2]=tri->f[1]->s[2].Normal.crossProduct(pt);
pt=tri->f[2]->s[2].Normal-tri->f[2]->s[0].Normal;
tri->f[2]->Normal[0]=tri->f[2]->s[0].Normal.crossProduct(pt);
pt=tri->f[2]->s[0].Normal-tri->f[2]->s[1].Normal;
tri->f[2]->Normal[1]=tri->f[2]->s[1].Normal.crossProduct(pt);
pt=tri->f[2]->s[1].Normal-tri->f[2]->s[2].Normal;
tri->f[2]->Normal[2]=tri->f[2]->s[2].Normal.crossProduct(pt);
pt=tri->f[3]->s[2].Normal-tri->f[3]->s[0].Normal;
tri->f[3]->Normal[0]=tri->f[3]->s[0].Normal.crossProduct(pt);
pt=tri->f[3]->s[0].Normal-tri->f[3]->s[1].Normal;
tri->f[3]->Normal[1]=tri->f[3]->s[1].Normal.crossProduct(pt);
pt=tri->f[3]->s[1].Normal-tri->f[3]->s[2].Normal;
tri->f[3]->Normal[2]=tri->f[3]->s[2].Normal.crossProduct(pt);
// Mise en place des aretes que l'on connait
tri->f[0]->e[1]=tri->f[3];
tri->f[1]->e[2]=tri->f[3];
tri->f[2]->e[0]=tri->f[3];
// Le fils 3 a toutes ses aretes renseignees
tri->f[3]->e[0]=tri->f[2];
tri->f[3]->e[1]=tri->f[0];
tri->f[3]->e[2]=tri->f[1];
// Mise en place des liens avec les voisins
for (i=0;i<3;i++)
{
if (tri->e[i])
{
if (tri->e[i]->f[0]!=NULL)
{
// Le triangle voisin a des enfants => maj de liens
int j=i+1; if (j>2) j=0;
int Shared=SharedEdge(tri->e[i],tri);
if (Shared!=-1)
{
int k=Shared+1; if (k>2) k=0;
tri->f[i]->e[i]=tri->e[i]->f[k];
tri->f[j]->e[i]=tri->e[i]->f[Shared];
tri->e[i]->f[Shared]->e[Shared]=tri->f[j];
tri->e[i]->f[k]->e[Shared]=tri->f[i];
}
}
}
}
// Ajouter les 4 fils a la liste des triangles du mesh
for (i=0;i<4;i++)
ListTriangle.push_back(tri->f[i]);
// Marque le parent comme supprimable de la liste
tri->Sup=true;
return true;
}
Actually i've two class in my program: planet class (preparation of the impostor, preparation of the display, etc...) planetscenenode class, this doing the most interresting things: display the planet mesh root (consisting of a spherical mesh with few triangles (allmost 1280) visible from a far distance, and displaying the detailed mesh (only the part near the camera is detailed, the detailed can be up to 10000 triangles (depend on the graphical card and the cpu power)).
in order to decrease the time of display, i use the impostor technic, i can display a planet with its satellites with a descent framerate (when only impostors are used, i can run at 400 fps, of course without any vessels).
the planetscenenode uses the camera position and the planete position to determinate the level of tessalation of the mesh. i join the piece of code which realize the split of the mesh:
each triangle is a structure contening several information, the sons of the triangle (when i split, the triangle is divided in 4 sons)
/*====================================================
Fonctino de split des triangles avec gestion du
relief
=====================================================*/
bool CPlaneteSceneNode::SplitTriangleDetail(STriangle *tri,float dt)
{
int i;
// On verifie la place disponible
if (NbTriangles>9990) return false;
// On essaye de spliter un triangle dont le pointeur est NULL => erreur
if (tri==NULL)
{
return false;
}
// Testons si le triangle a deja ete splittee
if (tri->f[0]!=NULL)
{
// Le triangle a deja ete splite => faux
return false;
}
// Pas plus du niveau 7 de split
if (tri->Seuil==10) return false;
if (tri->p!=NULL)
{
for (i=0;i<3;i++)
{
// test du fils 3
if (tri->p->f[3]==tri)
{
// Il faut spliter les voisins du triangle parent
for (i=0;i<3;i++)
{
SplitTriangleDetail(tri->p->e,dt);
}
}
// 2 solutions soit on split le voisin si il n'est pas deja spliter => recursif
// if (tri->e==NULL)
// {
// if (NbTriangles>9990) return false;
// SplitTriangleDetail(tri->p->e);
// }
// soit on ne split un triangle que si le voisin est deja splite => + rapide mais - joli
if (tri->e==NULL) return false;
}
}
// Creation des points milieux
vector3df n[3],nn[3];
bool bn[3];
myRnd->PseudoRandom(tri->Seed);
float Alpha,UnAlpha; // Coeeficient de poid pour les points du triangle
/* Alpha=0.45f+(float)myRnd->PseudoRandom()/RAND_MAX*0.1f;
UnAlpha=1.0f-Alpha;
n[0]=tri->s[0].Pos*UnAlpha+tri->s[1].Pos*Alpha;
bn[0]=false;
n[1]=tri->s[1].Pos*UnAlpha+tri->s[2].Pos*Alpha;
bn[1]=false;
n[2]=tri->s[2].Pos*UnAlpha+tri->s[0].Pos*Alpha;
bn[2]=false;*/
Alpha=0.5f;
UnAlpha=0.5f;
n[0]=(tri->s[0].Pos+tri->s[1].Pos)/2.0f;
bn[0]=false;
n[1]=(tri->s[1].Pos+tri->s[2].Pos)/2.0f;
bn[1]=false;
n[2]=(tri->s[2].Pos+tri->s[0].Pos)/2.0f;
bn[2]=false;
vector2df t[3],uv[3];
t[0]=(tri->s[0].TCoords*UnAlpha+tri->s[1].TCoords*Alpha);
t[1]=(tri->s[1].TCoords*UnAlpha+tri->s[2].TCoords*Alpha);
t[2]=(tri->s[2].TCoords*UnAlpha+tri->s[0].TCoords*Alpha);
// Calcul de la valeur de la couleur des points en fonction des coordonnees U et V
// et calcule de la hauteur correspondante h1
float h1[3];
int h;
int u,v;
if (p_Planete->PlaneteMap!=NULL)
{
for (i=0;i<3;i++)
{
// La planete possede une map
// On genere les hauteurs en fonction de cette map
// La hauteur des points representant la valeur de la map pour
// les coordonnes U et V du point
u=(int)(255.0f*t.X);
v=(int)(255.0f*t.Y);
if (u>255) u=255;
if (v>255) v=255;
h=*(p_Planete->PlaneteMap+u*256+v);
h1=(float)h;
// if (h1>130.0f) h1*=3.0f;
if (h1>200.0f) h1[i]*=7.0f;
h1[i]+=324000.0f;
// if (((h1[i])/dt)<ERREUR_SPLIT) return false;
}
}
else
{
// La planete est plutot plate (telle est gazeux)
h1[0]=324000.0f;
h1[1]=324000.0f;
h1[2]=324000.0f;
}
// Deplacement des points milieux ssi le voisin a deja des fils
{
for (i=0;i<3;i++)
{
if ((tri->e[i]!=NULL)&&(tri->e[i]->f[0]!=NULL))
{
if (tri->Seuil<3)
{
// Init du gene aleatoire
// OK le voisin a des fils => leger deplacement
nn[i]=n[i];
nn[i].normalize();
bn[i]=true;
n[i]=nn[i]*h1[i];
int it0=SharedEdge(tri->e[i],tri);
int it1=it0+1; if (it1>2) it1=0;
int it2=it1+1; if (it2>2) it2=0;
tri->e[i]->f[it0]->s[it1].Pos=n[i];
tri->e[i]->f[it1]->s[it0].Pos=n[i];
tri->e[i]->f[3]->s[it2].Pos=n[i];
}
else
{
// Init du gene aleatoire avec le seed du triangle afin de toujours avoir
// le meme deplacement dans le split du triangle
myRnd->PseudoRandom(tri->Seed);
int it0=SharedEdge(tri->e[i],tri);
int it1=it0+1; if (it1>2) it1=0;
int it2=it1+1; if (it2>2) it2=0;
// On deplace entre le min et le max
float Min,Max;
float r;
// Recuperation de la hauteur des 2 points limites
Min=tri->s[it1].Pos.dotProduct(tri->s[it1].Normal);
Max=tri->s[it2].Pos.dotProduct(tri->s[it2].Normal);
if (Max<Min)
{
r=Max;
Max=Min;
Min=r;
}
// Calcul du delta / 2
Max-=Min;
Max/=2.0f;
// Bon a priori il faut normaliser => indicateur positonne
bn[i]=true;
nn[i]=n[i];
nn[i].normalize();
// Calcul de la hauteur du point intermediaire
n[i]+=nn[i]*Max*((((float)myRnd->PseudoRandom()/(RAND_MAX*2.0f))-0.25f)-0.25f*(float)myRnd->PseudoRandom()/RAND_MAX);
// n[i]+=nn[i]*Max*(((float)rand()/(RAND_MAX))-0.5f);
// La on peut ajouter des variables telles que
// la rugosite, l'erosion, etc... en fonction des planetes
// et on met tout cela dans les bons triangles
tri->e[i]->f[it0]->s[it1].Pos=n[i];
tri->e[i]->f[it1]->s[it0].Pos=n[i];
tri->e[i]->f[3]->s[it2].Pos=n[i];
}
}
}
}
// Creation des fils
// Fils 0
tri->f[0]=AllocateTriangle();
tri->f[0]->s[0]=tri->s[0];
tri->f[0]->s[1].Pos=n[0];
tri->f[0]->s[1].Color=SColor(255,255,255,255);
tri->f[0]->s[1].TCoords=t[0];
// si l'indicateur nn correspondant n'est pas positionne => normalize
if (!bn[0])
{
// Pas encore normalise
n[0].normalize();
tri->f[0]->s[1].Normal=n[0];
}
else
{
// deja normalise
tri->f[0]->s[1].Normal=nn[0];
}
tri->f[0]->s[2].Pos=n[2];
tri->f[0]->s[2].Color=SColor(255,255,255,255);
tri->f[0]->s[2].TCoords=t[2];
if (!bn[2])
{
n[2].normalize();
tri->f[0]->s[2].Normal=n[2];
}
else
{
// deja normalise
tri->f[0]->s[2].Normal=nn[2];
}
tri->f[0]->Sup=false;
tri->f[0]->Systeme=false;
tri->f[0]->Nuage=false;
// Fils 1
tri->f[1]=AllocateTriangle();
tri->f[1]->s[1]=tri->s[1];
tri->f[1]->s[0]=tri->f[0]->s[1];
tri->f[1]->s[2].Pos=n[1];
tri->f[1]->s[2].Color=SColor(255,255,255,255);
tri->f[1]->s[2].TCoords=t[1];
if (!bn[1])
{
n[1].normalize();
tri->f[1]->s[2].Normal=n[1];
}
else
{
// Deja normalise
tri->f[1]->s[2].Normal=nn[1];
}
tri->f[1]->Sup=false;
tri->f[1]->Systeme=false;
tri->f[1]->Nuage=false;
// Fils2
tri->f[2]=AllocateTriangle();
tri->f[2]->s[0]=tri->f[0]->s[2];
tri->f[2]->s[1]=tri->f[1]->s[2];
tri->f[2]->s[2]=tri->s[2];
tri->f[2]->Sup=false;
tri->f[2]->Systeme=false;
tri->f[2]->Nuage=false;
// Fils 3
tri->f[3]=AllocateTriangle();
tri->f[3]->s[0]=tri->f[1]->s[2];
tri->f[3]->s[1]=tri->f[2]->s[0];
tri->f[3]->s[2]=tri->f[1]->s[0];
tri->f[3]->Sup=false;
tri->f[3]->Systeme=false;
tri->f[3]->Nuage=false;
// Gestion des nuages ou particule
if (p_Planete->TypePlanete==PLANETE_VOLCANIQUE)
{
// if (tri->Seuil==7) AjouteParticule(tri->f[0]);
}
// if (p_Planete->Atmosphere)
// {
// if (tri->Seuil==2) AjouteNuage(tri->f[0]);
// }
// Mise en place des parents et des seuils
myRnd->PseudoRandom(tri->Seed);
vector3df pt;
bool WaterLine;
int j;
for (i=0;i<4;i++)
{
tri->f[i]->p=tri;
tri->f[i]->Seuil=tri->Seuil+1;
tri->f[i]->Seed=myRnd->PseudoRandom();
}
// Chargement des normales definissant les plans pour le calcul des intersections des triangles
pt=tri->f[0]->s[2].Normal-tri->f[0]->s[0].Normal;
tri->f[0]->Normal[0]=tri->f[0]->s[0].Normal.crossProduct(pt);
pt=tri->f[0]->s[0].Normal-tri->f[0]->s[1].Normal;
tri->f[0]->Normal[1]=tri->f[0]->s[1].Normal.crossProduct(pt);
pt=tri->f[0]->s[1].Normal-tri->f[0]->s[2].Normal;
tri->f[0]->Normal[2]=tri->f[0]->s[2].Normal.crossProduct(pt);
pt=tri->f[1]->s[2].Normal-tri->f[1]->s[0].Normal;
tri->f[1]->Normal[0]=tri->f[1]->s[0].Normal.crossProduct(pt);
pt=tri->f[1]->s[0].Normal-tri->f[1]->s[1].Normal;
tri->f[1]->Normal[1]=tri->f[1]->s[1].Normal.crossProduct(pt);
pt=tri->f[1]->s[1].Normal-tri->f[1]->s[2].Normal;
tri->f[1]->Normal[2]=tri->f[1]->s[2].Normal.crossProduct(pt);
pt=tri->f[2]->s[2].Normal-tri->f[2]->s[0].Normal;
tri->f[2]->Normal[0]=tri->f[2]->s[0].Normal.crossProduct(pt);
pt=tri->f[2]->s[0].Normal-tri->f[2]->s[1].Normal;
tri->f[2]->Normal[1]=tri->f[2]->s[1].Normal.crossProduct(pt);
pt=tri->f[2]->s[1].Normal-tri->f[2]->s[2].Normal;
tri->f[2]->Normal[2]=tri->f[2]->s[2].Normal.crossProduct(pt);
pt=tri->f[3]->s[2].Normal-tri->f[3]->s[0].Normal;
tri->f[3]->Normal[0]=tri->f[3]->s[0].Normal.crossProduct(pt);
pt=tri->f[3]->s[0].Normal-tri->f[3]->s[1].Normal;
tri->f[3]->Normal[1]=tri->f[3]->s[1].Normal.crossProduct(pt);
pt=tri->f[3]->s[1].Normal-tri->f[3]->s[2].Normal;
tri->f[3]->Normal[2]=tri->f[3]->s[2].Normal.crossProduct(pt);
// Mise en place des aretes que l'on connait
tri->f[0]->e[1]=tri->f[3];
tri->f[1]->e[2]=tri->f[3];
tri->f[2]->e[0]=tri->f[3];
// Le fils 3 a toutes ses aretes renseignees
tri->f[3]->e[0]=tri->f[2];
tri->f[3]->e[1]=tri->f[0];
tri->f[3]->e[2]=tri->f[1];
// Mise en place des liens avec les voisins
for (i=0;i<3;i++)
{
if (tri->e[i])
{
if (tri->e[i]->f[0]!=NULL)
{
// Le triangle voisin a des enfants => maj de liens
int j=i+1; if (j>2) j=0;
int Shared=SharedEdge(tri->e[i],tri);
if (Shared!=-1)
{
int k=Shared+1; if (k>2) k=0;
tri->f[i]->e[i]=tri->e[i]->f[k];
tri->f[j]->e[i]=tri->e[i]->f[Shared];
tri->e[i]->f[Shared]->e[Shared]=tri->f[j];
tri->e[i]->f[k]->e[Shared]=tri->f[i];
}
}
}
}
// Ajouter les 4 fils a la liste des triangles du mesh
for (i=0;i<4;i++)
ListTriangle.push_back(tri->f[i]);
// Marque le parent comme supprimable de la liste
tri->Sup=true;
return true;
}
-
- Hunter
- Posts: 95
- Joined: Tue Jun 03, 2008 6:43 am
Safemode: People have been clamoring for seamless planetary flight for YEARS in vs. Now here is someone who is MAKING IT HAPPEN and you BLOW HIM OFF. Screw you safemode. VS players WANT THIS. LET US HAVE IT.safemode wrote:you can get close to a planet now. Very very close. The thing is, there is no detail generation. That's all that's missing from that. Also, there is no sense of atmosphere, since the textures are just layered on top of eachother, with no concern for depth.
I'm still unconvinced that there is a place for this within VS. maybe for other mods....but i dont see the payoff. Nothing stopping you though. I'd just feel much happier about a whole new smooth wormhole animation with a nifty in-transit fullscreen video played on another thread while the new system loads ... Or auto-docking the correct way or larger ships utilizing shuttles to interact with bases/ships. In the end though, i guess someone will be able to use this feature so i'll just shut up.