• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

112 Neutral

About bisslad

  • Rank
  1. And the draw and update methods in my skysphere.cs file.   public override void LoadContent() { SkySphereModel = XNAGame.Instance().Content.Load<Model>("SkySphere/SphereHighPoly"); TextureCube SkySphereTexture = XNAGame.Instance().Content.Load<TextureCube>("SkySphere/SkySphereTexture"); SkySphereEffect = XNAGame.Instance().Content.Load<Effect>("SkySphere"); SkySphereEffect.Parameters["ViewMatrix"].SetValue(XNAGame.Instance().Camera.view); SkySphereEffect.Parameters["ProjectionMatrix"].SetValue(XNAGame.Instance().Camera.projection); SkySphereEffect.Parameters["SkyboxTexture"].SetValue(SkySphereTexture); SkySphereEffect = XNAGame.Instance().Content.Load<Effect>("SkySphere"); foreach (ModelMesh mesh in SkySphereModel.Meshes) { foreach (ModelMeshPart part in mesh.MeshParts) { part.Effect = SkySphereEffect; } } } public override void Draw(GameTime gameTime) { SkySphereEffect.Parameters["ViewMatrix"].SetValue(XNAGame.Instance().Camera.view); SkySphereEffect.Parameters["ProjectionMatrix"].SetValue(XNAGame.Instance().Camera.projection); DepthStencilState dss = new DepthStencilState(); dss.DepthBufferEnable = false; XNAGame.Instance().GraphicsDevice.DepthStencilState = dss; foreach (ModelMesh mesh in SkySphereModel.Meshes) { mesh.Draw(); } dss = new DepthStencilState(); dss.DepthBufferEnable = true; XNAGame.Instance().GraphicsDevice.DepthStencilState = dss; } }
  2. Also the shader operating on the texture is as follows skybox.fx   uniform extern float4x4 ViewMatrix; uniform extern float4x4 ProjectionMatrix; void SkyboxVertexShader( float3 pos : POSITION0, out float4 SkyPos : POSITION0, out float3 SkyCoord : TEXCOORD0 ) { // Calculate rotation. Using a float3 result, so translation is ignored float3 rotatedPosition = mul(pos, ViewMatrix); // Calculate projection, moving all vertices to the far clip plane // (w and z both 1.0) SkyPos = mul(float4(rotatedPosition, 1), ProjectionMatrix).xyww; SkyCoord = pos; }; uniform extern texture SkyboxTexture; sampler SkyboxS = sampler_state { Texture = <SkyboxTexture>; MinFilter = LINEAR; MagFilter = LINEAR; MipFilter = LINEAR; AddressU = CLAMP; AddressV = CLAMP; }; float4 SkyboxPixelShader( float3 SkyCoord : TEXCOORD0 ) : COLOR { // grab the pixel color value from the skybox cube map return texCUBE(SkyboxS, SkyCoord); }; technique SkyboxTechnique { pass P0 { vertexShader = compile vs_2_0 SkyboxVertexShader(); pixelShader = compile ps_2_0 SkyboxPixelShader(); // We're drawing the inside of a model CullMode = None; // We don't want it to obscure objects with a Z < 1 ZWriteEnable = false; } }
  3. Yeah I suppose I could have a better grasp though I am aware of the byte code compilation process during the build process.. The thing is, that is exactly why I don't understand the differences between the on screen results I am achieving. I mean, if the content pipeline is supposed to pretty much automatically apply scale, sampling and other pertinent texture info at compile time and imbedded in the model, all of which is sent to the GPU to be rendered, then what is causing the scaling issues I am having? If you know what  mean.   I dont mean to sound like an idiot either, but I am not really a guy who has often tried to stitch his own textures together in photoshop. My reference to the file sizes are simply what I see on the screen and in the properties of the files, I was just including them in case it had context for the problem. I not really an artist. I dont really know how to measure what size an image is except by what I see on the screen. When I create a new photoshop document I set  it to 6144 x 1024 pixels at 300 pixels per inch in 32 bit RGB mode. Then exported it to .dds with default options bar changing it from 2D texture to cubemap. The resulting mipmapped file appears to be 1Mb in the file explorer then.
  4. Yeah that was my understanding as well of the way video memory was handled on the GPU, but there is still the fact that the texture being referenced is of that size and those dimensions in the content folder.. So the only thing I can think of is that its being either scaled down or sampled in some way along the content pipeline that I am unaware of, or perhaps that there is some sort of compression technique that was applied to the original texture during its creation that enables the image data to be referenced at runtime... Im just fishing here because, as you say, it doesn't conform to my understanding of the the addresing limitations of the environment..   Cheers though I appreciate the response!
  5. Hi all,   I'm working on a 3D space shooter with XNA 4.0 and have downloaded a temporary skybox(actually a sphere) with texture which I would like to replace with another scene.   So I finished creating the cube map with the photoshop CS3 Nvidia dds plugin and exported as a cubemap (other settings default) and, while I can import the texture and it displays well, no seams etc, I was forced to scale down to a size below 4096 for use with XNA.   However this results in the skybox feeling very "close" to the scene due to the smaller texture size compared to the original.   After checking the dimensions of the original texture in photoshop (even though it only displays a black background?) it seems to be a 9000 x 1500 texture size and the file size is just over 100 Mb!   My own texture is a paltry 3072 x 512 with a file size of about 1 Mb by comparison.   So my question is are there some export settings I am ignoring? Or, why exactly does XNA turn it's nose up at my own texture when it is over 4096 and not another?   I have checked the content importer and processor settings for each texture and they appear the same so is there something I'm missing?   If anyone can shed some light I would be much obliged.   Thanks.    
  6. Hi there, this is my first post as I have been reading and re-reading all related posts to this topic that i could find on the boards. Basically, I understand the process of making a bullet fire (ie. when fire button pressed bullet created and life set to true, outside of conditional statement bullet position updated if life true, draw bullet if life is true etc.) I have done tests that will work if I create a bitmap and use it as a bullet, however, when trying to fill an array with my bullet class and then implement the shooting it will not work and it is driving me insane! Here is my main code: #include <allegro.h> #include "player.h" #include "console.h" #include"Bullet.h" #include"Enemy.h" #include"Thing.h" #include"obstacle.h" #include<list> using namespace std; const int SCREEN_WIDTH = 640; const int SCREEN_HEIGHT = 480; const int NUM = 500; const int FPS = 60; volatile int ticks = 0; void ticker() { ticks++; } END_OF_FUNCTION(ticker) void main() { console(true); if (allegro_init() != 0) { return; } set_color_depth(16); install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, 0); if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0) != 0) { return; } BITMAP *background = load_bitmap("galaxy.tga", NULL); BITMAP *backBuffer = create_bitmap(SCREEN_WIDTH, SCREEN_HEIGHT); MIDI *main = load_midi("starforce.mid"); play_midi(main, true); set_palette(default_palette); install_keyboard(); install_timer(); LOCK_VARIABLE(ticks); LOCK_FUNCTION(ticker); install_int_ex(ticker, BPS_TO_TIMER(FPS)); //INITIALISE PLAYER, ENEMY, OBSTACLE etc AND DEFINE START POSITIONS. Player player1; Enemy enemy1; Bullet bullet[NUM]; int canshoot = 1; Obstacle ob1; ob1.init(300.0f, 220.0f); enemy1.enemy_init(100.0f, 400.0f); player1.player_init(player1, 20.0f, 20.0f); for (int i;i = 0, i < NUM, i++;) { bullet[i].bitmap = load_bitmap("bullet.bmp", NULL); } //MAIN LOGIC LOOP bool done = false; while (! done) { while(ticks== 0) { rest(1); } while(ticks > 0) { int old_ticks = ticks; blit(background, backBuffer, 0, 0, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); if (key[KEY_W] ) { player1.thrust(4.0f); } if (key[KEY_S]) { player1.thrust(-5.0f); } if (key[KEY_A]) { player1.rotate((player1.getSpeed() / -10)); } if (key[KEY_D]) { player1.rotate((player1.getSpeed() / 10)); } if (key[KEY_SPACE]) { for (int i;i = 0, i < NUM, i++;) //cycle through aray { if ((!bullet[i].life) && canshoot == 1) //if bullet doesn't already exist and we can shoot...shoot { bullet[i].life = true; bullet[i].pos.x = (player1.pos.x + 30); //define where the x position of the bullet is going to originate from bullet[i].pos.y = (player1.pos.y + 5); canshoot = 0; //prevent space bar bing held down. } } } else if (!key[KEY_SPACE]) { canshoot = 1; } if (keypressed()) { int key = readkey() >> 8; switch (key) { case KEY_ESC: done = true; break; } }//ENDIF for(int i; i = 0, i < NUM, i++;) { if(bullet[i].life==true) { bullet[i].move(); } } ticks--; if(old_ticks <= ticks)//logic is taking too long: abort and draw a frame break; //DRAW BLOCK for (int i; i = 0; i < NUM, i++) // for all bullets on screen, update their position. { bullet[i].draw(backBuffer); } ob1.draw(backBuffer); player1.draw(backBuffer); player1.think(0.1f); enemy1.think(1.0f); enemy1.draw(backBuffer); blit(backBuffer, screen, 0, 0, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); clear(backBuffer); } }// END MAIN LOGIC LOOP for (int i; i=0, i < NUM, i++;) { destroy_bitmap(bullet[i].bitmap); } destroy_midi(main); destroy_bitmap(background); destroy_bitmap(backBuffer); } END_OF_MAIN() I would really appreciate some help getting this together as I have been at it for about two weeks now and nothing seems to work. Also, here is my bullet.cpp class code: #include"Bullet.h" #include"player.h" #include<allegro.h> using namespace GameMaths; Bullet::Bullet() { bitmap= create_bitmap(10, 10); bitmap = load_bitmap("bullet.bmp"); pos.x = 0; pos.y = 0; life = false; speed = 5.0f; damage = 10; } void Bullet::draw(BITMAP *b_buffer) { draw_sprite(b_buffer, bitmap, pos.x, pos.y); } void Bullet::move() { pos.x += speed; pos.y += speed; if (pos.x > 640 || pos.y > 480) { life = false; } } bool Bullet::islive() { return life; } Vector2 Bullet::getPos(Bullet) { return pos; } void Bullet::setPos(Vector2 p_pos) { pos.x = p_pos.x; pos.y = p_pos.y; } Thanks in advance! ;)
  • Advertisement