Im not sure how to do this but im creating a space sim and what I want to do is place billboard sprites in static position's so as you move you get the effect that you really are moving, what should I do here
Your resource manager seems fairly simple, but if it does the job then fine. Although, in my experience its as much about "pure" software engineering and good software architecture as it is anything DirectX-specific. If you want discussion on that topic, then I'd recommend you start a new thread
Smacker wrote:
I do this each rendering cycle, now is this the right way to do this or is there a better way.
Without any further info on how your resource manager works, this might not be a good thing! Any sort of resource loading/creation is slow - so you dont really want to be doing that per-frame... But if you're just passing references around then its probably okay.
Smacker wrote:
now with the pointSprites I know im doing something wrong
Hmm... care to elaborate on this There are lots of possible things you could do wrong with PSprites, but without some sort of info/description its difficult to say anything useful!!Your code fragment doesn't strike me as obviously wrong.
Remember that alpha blending is draw-order dependent, so be careful with that.
In my book, "Beginning .NET Game Programming in C#", I talk about how to do what I call the "Haynie Effect" in using a simple star/nebula environment map to get a twinkling star appearance. Basically putting the environment map (in the case of Spacewar 3D, a sphere) on a slow rotation. The net effect is that the little white dots appear to twinkle as the renderer tries to approximate each individual star's brightness. It's really quite effective.
And, yes, I can be accused of plugging my book here, but you can download the source code for free from the Apress.com website and look at it without needing to buy the book (aren't I a nice guy :-) )
I got the polar cords working great, such a great Idea and im using the sphere as my boundries to my world, I wonder if there would be a good way to create random shooting stars....im going to play around with it.
now when I place my point sprites with something like this it only draws one, also the other strange thing is when I shoot a object, the point sprites dissapear then reapear after the shot has left the screen.the shoot code is simple
Your placement code doesn't follow what I suggested - that intentional
Your code should generate a distribution across a 20x20x15 area of 3D space. Thus you'll probably be able to fly past/around your stars - as well as get stars appearing in front of planets. Up to you of course, but that doesn't seem right to me
For my polar-coordinate method to work, you'd need to randomize between 0 and 2*pi and use the three equations that I originally posted.
As for your last part... you're changing the world transformation - anything rendered *after* that call will be affected by that translation matrix. Check that you're not "leaking" it into other bits of code that don't want/need that translation. A simple way is to make sure any other rendering assumes nothing about the state of the pipeline - and resets/restores/reconfigures before every frames rendering.
thanks for the responce, but I have a question about rendering multiple meshes and sprites
I have a resource manager that makes it very easy to load different meshes/textures, now if I add a object to the scene lets say a mesh I load it from my resource manager like this
Mesh mesh = ResourceManager.GetMesh(meshname.X)
then I set the transform like this
device.Transform.World = Matrix.Translation(x, y, z);
then I draw the subsets,
I do this each rendering cycle, now is this the right way to do this or is there a better way.
now with the pointSprites I know im doing something wrong here is what I have done
I first before the player switches screens I call a preload function, witch removes all the objects/GUI from the scene, loads all static textures like backgrounds ect...this is where I preload my pointSprites
Point sprites are probably a good enough solution to this - although the initial positioning should be carefully done.
If you have a background (e.g. not just black space - maybe one with nebula's/galaxies/whatever) then render it first. Next you want to render your point sprites - but do so without any Z Testing or Z Writing. You want them on top of the background, but you don't want them contributing to the Z values for the scene as they should appear *behind* everything else.
A single batch of point sprites uses all of a single texture, so creating N batches for getting N different star textures, or possibly randomizing the colour to shades of blue (look up the physics of light wavelengths - i forget - stars either tend towards the blue or red end of the spectrum) should stop them all looking identical.
Randomizing points across the surface of a unit sphere should give you a good enough "coverage" - but if you want more accurate patterns then you'll obviously have to think of something much cleverer (e.g. projecting spiral/galaxy patterns onto the surface of the sphere). Using polar coordinates should be a nice and simple way of doing things.
Randomize two coordinates on the surface, phi and theta, the position for the star is then:
X = Sin( theta ) * Cos( phi ) Y = Sin( theta ) * Sin( phi ) Z = Cos( theta )
creating stars
lallousx86
Without any further info on how your resource manager works, this might not be a good thing! Any sort of resource loading/creation is slow - so you dont really want to be doing that per-frame... But if you're just passing references around then its probably okay.
Hmm... care to elaborate on this There are lots of possible things you could do wrong with PSprites, but without some sort of info/description its difficult to say anything useful!!Your code fragment doesn't strike me as obviously wrong.
Remember that alpha blending is draw-order dependent, so be careful with that.
hth
Jack
armadya
In my book, "Beginning .NET Game Programming in C#", I talk about how to do what I call the "Haynie Effect" in using a simple star/nebula environment map to get a twinkling star appearance. Basically putting the environment map (in the case of Spacewar 3D, a sphere) on a slow rotation. The net effect is that the little white dots appear to twinkle as the renderer tries to approximate each individual star's brightness. It's really quite effective.
And, yes, I can be accused of plugging my book here, but you can download the source code for free from the Apress.com website and look at it without needing to buy the book (aren't I a nice guy :-) )
bakup
I got the polar cords working great, such a great Idea and im using the sphere as my boundries to my world, I wonder if there would be a good way to create random shooting stars....im going to play around with it.
thanks for the help guys
neonDog
ok sorry for the lack of info, I belive most of my problem is done in my placment of the psprites
CustomVertex.PositionColored[] verts = (CustomVertex.PositionColored[])vb.Lock(0,0);
Random r =
new Random(); for(int i=0;i<10;i++){
verts
.X = (
float)(r.Next(-20, 20) * (float)r.Next(-20, 15));verts
.Y = (
float)(r.Next(-20, 20) * (float)r.Next(-20, 15));verts
.Z = (float)(r.Next(-20, 20) * (float)r.Next(-20, 15));
}
vb.Unlock();
now when I place my point sprites with something like this it only draws one, also the other strange thing is when I shoot a object, the point sprites dissapear then reapear after the shot has left the screen.the shoot code is simplev4 =
new Vector3(x1,y1, z1);//=positionv3 =
new Vector3(x, y, z);//=directionv4 += v3 *(time);
device.Transform.World = Matrix.Translate(v4.x, v4.y, v4.z);
thanks again
jpv
Your placement code doesn't follow what I suggested - that intentional
Your code should generate a distribution across a 20x20x15 area of 3D space. Thus you'll probably be able to fly past/around your stars - as well as get stars appearing in front of planets. Up to you of course, but that doesn't seem right to me
For my polar-coordinate method to work, you'd need to randomize between 0 and 2*pi and use the three equations that I originally posted.
As for your last part... you're changing the world transformation - anything rendered *after* that call will be affected by that translation matrix. Check that you're not "leaking" it into other bits of code that don't want/need that translation. A simple way is to make sure any other rendering assumes nothing about the state of the pipeline - and resets/restores/reconfigures before every frames rendering.
hth
Jack
nole12
thanks for the responce, but I have a question about rendering multiple meshes and sprites
I have a resource manager that makes it very easy to load different meshes/textures, now if I add a object to the scene lets say a mesh I load it from my resource manager like this
Mesh mesh = ResourceManager.GetMesh(meshname.X)
then I set the transform like this
device.Transform.World = Matrix.Translation(x, y, z);
then I draw the subsets,
I do this each rendering cycle, now is this the right way to do this or is there a better way.
now with the pointSprites I know im doing something wrong here is what I have done
I first before the player switches screens I call a preload function, witch removes all the objects/GUI from the scene, loads all static textures like backgrounds ect...this is where I preload my pointSprites
pointSprites.PreLoad(texture, number_to_load);
then I set my renderStates
Device.RenderState.SourceBlend = Blend.SourceAlpha;
Device.RenderState.DestinationBlend = Blend.InvSourceAlpha;
Device.RenderState.AlphaBlendEnable = true;
Device.RenderState.ZBufferWriteEnable = false;
Device.RenderState.ZBufferEnable = false;
Device.SetTexture(0, start.GRender.tex);
Device.RenderState.PointSpriteEnable = true;
Device.RenderState.PointScaleEnable = true;
Device.RenderState.PointSize = 2.0f;
then I create my vertexbuffer
vb =
new VertexBuffer(typeof(CustomVertex.PositionColored), num_to_load, device, Usage.None, VertexFormats.PointSize, Pool.Default);then I setup my position(witch I know im doing wrong, so im not going to even post that)
then after I draw my background I call this
dev.DrawPrimitives(PrimitiveType.PointList, 0, number);
any help would be great
thanks a bunch
BrandonFields
If you have a background (e.g. not just black space - maybe one with nebula's/galaxies/whatever) then render it first. Next you want to render your point sprites - but do so without any Z Testing or Z Writing. You want them on top of the background, but you don't want them contributing to the Z values for the scene as they should appear *behind* everything else.
A single batch of point sprites uses all of a single texture, so creating N batches for getting N different star textures, or possibly randomizing the colour to shades of blue (look up the physics of light wavelengths - i forget - stars either tend towards the blue or red end of the spectrum) should stop them all looking identical.
Randomizing points across the surface of a unit sphere should give you a good enough "coverage" - but if you want more accurate patterns then you'll obviously have to think of something much cleverer (e.g. projecting spiral/galaxy patterns onto the surface of the sphere). Using polar coordinates should be a nice and simple way of doing things.
Randomize two coordinates on the surface, phi and theta, the position for the star is then:
X = Sin( theta ) * Cos( phi )
Y = Sin( theta ) * Sin( phi )
Z = Cos( theta )
hth
Jack