Jump to content

SpiderPig

Members
  • Posts

    2,352
  • Joined

  • Last visited

Everything posted by SpiderPig

  1. From this code my computer screen is loaded with the material "Tex_ComputerScreen" already asigned to its screen. I load that same material and change the texture0 channel to the texture I get from "GetColorBuffer(ComputerBuffer)" every frame after my ComputerBuffer has been updated. The ComputerBuffer rendering process works perfectly. I never intented to texture the cube, only the computer screen with the new texture. I rendered the cube into the ComputerWorld so instead of seeing black on my computer screen, I had a white square in the centre so I could tell if it was working properly. (See the previous attachment) It didn't work so I drew the texture on screen, which said it was working, but clearly on my computer screen it wasn't. Other textures have worked by loading them indapendantly. It's just the texture from "GetColorBuffer(ComputerBuffer)" isn't showing on the computers screen (via the texture0 channel). Hope this makes sense, Thanks for the code, will have closer look in the morning
  2. Just to be sure: the cube is just a reference object so I'm able to see if the buffer has been asigned to the computers screen. Here is where I render and update my computer stuff; #include "engine.h" TWorld ComputerWorld; TBuffer ComputerBuffer; TCamera ComputerCamera; TTexture ComputerTexture; TMaterial mat1; void ComputerSetup(void); void SetupComputerBuffer(void); void UpdateComputer(void); int main(int argc,char** argv) { Initialize() ; RegisterAbstractPath("C:/Leadwerks Engine SDK"); SetAppTitle( "Game." ) ; Graphics( 1024, 600 ) ; TWorld world; TBuffer gbuffer; TCamera camera; world = CreateWorld() ; if(!world) { MessageBoxA(0,"Error","Failed To Create World.",0); return Terminate(); }; gbuffer=CreateBuffer(GraphicsWidth(),GraphicsHeight(),BUFFER_COLOR|BUFFER_DEPTH|BUFFER_NORMAL); camera=CreateCamera(); TLight light = CreateDirectionalLight(); ComputerSetup(void); //loop while( !KeyHit() && !AppTerminate() ) { // Update timing and world UpdateAppTime(); UpdateWorld(AppSpeed()) ; UpdateComputer(); // Render SetBuffer(gbuffer); RenderWorld(); SetBuffer(BackBuffer()); RenderLights(gbuffer);//ComputerTexture=GetColorBuffer(BackBuffer(),1); DrawImage(ComputerTexture,0,0,-1,-1); Flip(1) ; } return Terminate() ; } void ComputerSetup(void) { ComputerScreen=LoadModel("abstract::ComputerScreen.gmf"); SetupComputerBuffer(); }; void SetupComputerBuffer(void) { TWorld current=CurrentWorld(); ComputerWorld=CreateWorld(); TModel cube=CreateCube(); //I tested a material on the cube here, which was a diffuse shader with a red.dds texture. Only the basic and it worked fine. ComputerBuffer=CreateBuffer(64,64,BUFFER_COLOR|BUFFER_DEPTH|BUFFER_NORMAL); ComputerCamera=CreateCamera(); PositionEntity(ComputerCamera,Vec3(0,0,-4)); SetWorld(current); mat1=LoadMaterial("abstract::Tex_ComputerScreen.mat"); }; void UpdateComputer(void) { TBuffer currentb=CurrentBuffer(); TWorld currentw=CurrentWorld(); SetBuffer(ComputerBuffer); SetWorld(ComputerWorld); RenderWorld(); ComputerTexture=GetColorBuffer(ComputerBuffer); SetMaterialTexture(mat1,ComputerTexture,0); SetBuffer(currentb); SetWorld(currentw); }; I've chopped out the insignificant bits so that's all the code relivant to textureing the computer screen. I had to move the camera back a bit in order to see the cube. Otherwise it is black.
  3. The cube itself has no texture, it's just so I can see if its actually rendering somthing. (see attachment) screen.bmp The material file for the screen is as below; texture0="abstract::Tex_ComputerScreen.dds" clamp0=0,0,0 blend=0 depthmask=1 depthtest=1 overlay=0 zsort=0 cullface=1 castshadows=1 specular=1.00000000 bumpscale=1.00000000 gloss=0.500000000 shader="abstract::mesh_diffuse.vert","abstract::mesh_diffuse.frag" shadowshader="","" "abstract::Tex_ComputerScreen.dds" is just a 64x64 black image. I painted the cube with a material and it rendered fine without rendering the buffer to the material.
  4. Sorry. Neither code puts the texture onto the model. I just wrote it like that to show that the texture is being assigned to the material because I'm able to recall and draw it to the screen.
  5. Having a little problem with getting my texture rendered to my computer screen... I've created an extra world, buffer and camera, and I've made a cube in that world just a little in front of the camera. void SetupComputerBuffer(void) { TWorld current=CurrentWorld(); ComputerWorld=CreateWorld(); TModel cube=CreateCube(); ComputerBuffer=CreateBuffer(64,64,BUFFER_COLOR|BUFFER_DEPTH|BUFFER_NORMAL); ComputerCamera=CreateCamera(); PositionEntity(ComputerCamera,Vec3(0,0,-4)); SetWorld(current); mat1=LoadMaterial("abstract::Tex_ComputerScreen.mat"); };//called once on setup void UpdateComputer(void) { TBuffer currentb=CurrentBuffer(); TWorld currentw=CurrentWorld(); SetBuffer(ComputerBuffer); SetWorld(ComputerWorld); RenderWorld(); ComputerTexture=GetColorBuffer(ComputerBuffer); SetMaterialTexture(mat1,ComputerTexture,0); SetBuffer(currentb); SetWorld(currentw); };//called every loop before the main world and light render Everything draws fine with this code at the end of my main world and light renders; DrawImage(GetBufferColor(ComputerBuffer),0,0,-1,-1); ..and this code; ComputerTexture=GetBufferColor(ComputerBuffer); SetMaterialTexture(mat1,ComputerTexture,0); DrawImage(GetMaterialTexture(mat1,0),0,0,-1,-1); but with this code; ComputerTexture=GetBufferColor(ComputerBuffer); SetMaterialTexture(mat1,ComputerTexture,0); ..my screen dosn't have the texture, but clearly it is being asigned to the material, it's just not showing. I loaded a seperate texture and asigned it to the material and the screen showed that, so my models fine. Any sugestions?
  6. I used your link. Turns out I was using the wrong installer/updater..... :S
  7. Okay, I always thought that because my updater said I was all up to date and after copying all the updated files it still said it was using 2.3. Much thanks anyway
  8. No idea how to get it..... :S I thought it might have been only if I bought PureLight??
  9. I have v2.3 and it's not there. I've never used scripts until now so it hasn't been moved or deleted. Is there any where else I can get it from?
  10. Is "Class.lua" meant to be in the Scripts folder or do I have to download it else where? I can't find it anywhere. Thanks
  11. Thanks for the code, I'll see what I can get out of it
  12. Does any one have code for rendering a second camera to a separate buffer and then to a texture so I can use it on a material for my security camera? I know of the GetBufferColor() function but I'm unsure of the process used to actually get from my second camera to my texture! Can any one help me?
  13. Your right there doesn't seem to be anything for desaturate in "postfilter.frag", I also tried the "postfilter_distancefog.frag" but it still gave me the same grey screen. I have a feeling something else is going here...as well as the failure to recognise "LW_DESATURATE". Would Framework be the better option?
  14. I've made this simple program based on the Post-Processing tutorial which works fine until I set a shader which causes the end result to be a solid grey image. I'm positive it's a problem somewhere when setting the shader because it all rendered fine before I added that code. I've tried 'abstract' file system as well as loading each file directly. Can anyone help? Here's the code : #include "engine.h" int main(int argc,char** argv) { Initialize(); Graphics(640,480); TWorld world=CreateWorld(); TEntity MainCam=CreateCamera(); MoveEntity(MainCam,Vec3(0,5,-20)); CameraClearMode(MainCam,BUFFER_DEPTH); //creat a render buffer for lighting TBuffer gbuffer=CreateBuffer(640,480,BUFFER_COLOR|BUFFER_DEPTH|BUFFER_NORMAL); //create a buffer for post processing effects TBuffer postbuffer=CreateBuffer(640,480,BUFFER_COLOR); //creat a directional light, e.g. the sun TLight light=CreateDirectionalLight(); RotateEntity(light,Vec3(45,45,0)); //create the skybox TWorld background=CreateWorld(); TMesh skybox=CreateCube(); TCamera skycam=CreateCamera(); FlipMesh(skybox); PaintEntity(skybox,LoadMaterial("FullskiesBlueClear0016_2_L.mat")); SetWorld(world); TTerrain terrain=CreateTerrain(64); ScaleEntity(terrain,Vec3(5,5,5)); TEntity Oak=LoadModel("Oak/Oak.gmf"); PositionEntity(Oak,Vec3(-40,0,-30)); TShader postfilter=LoadShader("abstract::postfilter.vert","abstract::postfilter_desaturate.frag"); TTexture grass1=LoadTexture("terrain_forest_grass.dds"); SetTerrainTexture(terrain,grass1,0,0); SetTerrainTextureScale(terrain,6,0); TVec3 camrotation=Vec3(0); float mx=0; float my=0; HideMouse(); MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2); while(!KeyHit(KEY_ESCAPE)) { mx=Curve(MouseX()-GraphicsWidth()/2,mx,6); my=Curve(MouseY()-GraphicsHeight()/2,my,6); MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2); camrotation.X=camrotation.X+my/10.0; camrotation.Y=camrotation.Y-mx/10.0; RotateEntity(MainCam,camrotation); if(KeyDown(KEY_W)) { MoveEntity(MainCam,Vec3(0.0,0.0,0.2)); }; if(KeyDown(KEY_S)) { MoveEntity(MainCam,Vec3(0.0,0.0,-0.2)); }; UpdateAppTime(); UpdateWorld(); SetBuffer(gbuffer); //render the background RotateEntity(skycam,EntityRotation(MainCam)); SetWorld(background); RenderWorld(); SetWorld(world); RenderWorld(); SetBuffer(postbuffer); RenderLights(gbuffer); SetBuffer(BackBuffer()); SetShader(postfilter); DrawImage(GetColorBuffer(postbuffer),0,GraphicsHeight(),GraphicsWidth(),-GraphicsHeight()); Flip(); } Terminate(); return 0; }
  15. Hmmm, thanks Masterxilo, I had a feeling lighting would be a pain...I'll have to give it more thought=] maybe the surface commands are the best shot, though they're awfully slow when changeing a vertexs postion.. I'll do reasearch thanks,
  16. I want to make my own terrain generator/editor with LOD levels, and the built in surface commands are two slow for me..so I'm going to use OpenGL. But before I go any further with it...would it be possible to set up the terrain model some how to accept leadwerks collision commands, with vehicles and controllers? Everything..? I havn't gone far with this project yet...jsut want to see if its all possible..=] Thanks=]
  17. I'm useing both a directional light and several points - they all have the same problem. Thanks for your thoughts Flexman, I was thinking along similar lines. Floating point errors? So they're a game engine thing? Not a C++ thing? Hasn't anyone tried fixing them? Thanks for the replys..=]
  18. Hey everyone, I'm fairly new to Leadwerks, so go easy on me =] I'm not sure if I'm doing something wrong or not...but I had a building, and lights with the centre at : (0,0,0) Everything was fine until I moved it a huge distance away : (10000,0,10000) - because I have a huge island... Every time The camera moves the shadows are very jumpy, and even some of the objects seem to have the jitters... but when the camera stops so do the jitters...it seems to be less jittery the closer I move everything to the worlds centre.. Any Ideas? or is the answer stareing me in the face?? =] Thanks
  19. Ok, I'll declare them before the function, Thanks
  20. You know, just as I posted that I thought, "I know how to fix that," At the beginning of the code (before 'main') i added : TEntity Tailgate; Then when I load the model instead of TEntity TailGate=LoadModel("TailGate.gmf"); I just used : TailGate=LoadModel("TailGate.gmf");!!!! And it works fine....(I feel stupid) Thanks though!!
  21. Here's The code I'm using, Everything else works fine. It just doesn't know what 'TailGate' is, #include "engine.h" void UdateTailGate(void); int TailGateAngle=0; int TailGateStatus=0; int main(int argc,char** argv) { Initialize(); Graphics(1024,768); CreateWorld(); TEntity MainCam=CreateCamera(); PositionEntity(MainCam,Vec3(0,6,-7)); RotateEntity(MainCam,Vec3(30,0,0)); TLight MainLight=CreateSpotLight(20.0); TLight MainLight2=CreateSpotLight(20.0); PositionEntity(MainLight,Vec3(0,12,6)); PositionEntity(MainLight2,Vec3(0,12,-6)); SetShadowmapSize(MainLight,2000); SetShadowmapSize(MainLight2,2000); RotateEntity(MainLight,Vec3(90,0,0)); RotateEntity(MainLight2,Vec3(90,0,0)); TEntity Floor=CreatePlane(); ScaleEntity(Floor,Vec3(10,1,10)); TEntity Car=LoadModel("JeepMain.gmf"); TEntity Bonnet=LoadModel("Bonnet.gmf"); PositionEntity(Bonnet,Vec3(0.012,3.177,-1.297)); EntityParent(Bonnet,Car); int BonnetAngle=0; int BonnetStatus=0;//0-closed,1-open,2-opening,3-closeing TEntity TailGate=LoadModel("TailGate.gmf"); PositionEntity(TailGate,Vec3(-1.105,2.249,4.578)); EntityParent(TailGate,Car); TEntity SpareWheel=LoadModel("Wheel.gmf"); PositionEntity(SpareWheel,Vec3(0,2.293,5)); EntityParent(SpareWheel,TailGate); TEntity LeftDoor=LoadModel("LeftDoor.gmf"); PositionEntity(LeftDoor,Vec3(1.975,2.669,-0.618)); EntityParent(LeftDoor,Car); TBuffer Buffer=CreateBuffer(1024,768,BUFFER_COLOR|BUFFER_DEPTH|BUFFER_NORMAL);//buffer for teh lights float CarAng=0.0; while(!KeyHit(KEY_ESCAPE)) { if(KeyHit(KEY_==1) { if(BonnetStatus==0) { BonnetStatus=2; } else { if(BonnetStatus==1) { BonnetStatus=3; } } } if(BonnetStatus==2) { if(BonnetAngle<60) { BonnetAngle++; RotateEntity(Bonnet,Vec3(BonnetAngle,0,0)); } else { BonnetStatus=1;//open } } if(BonnetStatus==3) { if(BonnetAngle>0) { BonnetAngle--; RotateEntity(Bonnet,Vec3(BonnetAngle,0,0)); } else { BonnetStatus=0;//closed } } UdateTailGate(); RotateEntity(Car,Vec3(0,CarAng,0)); CarAng=CarAng-0.2; UpdateWorld(1); SetBuffer(Buffer); RenderWorld(RENDER_ALL); SetBuffer(BackBuffer()); RenderLights(Buffer); SetBuffer(BackBuffer()); Flip(1); } Terminate(); return 0; } void UdateTailGate(void) { if(KeyHit(KEY_T)==1) { if(TailGateStatus==0) { TailGateStatus=2; } else { if(TailGateStatus==1) { TailGateStatus=3; } } } if(TailGateStatus==2) { if(TailGateAngle<100) { TailGateAngle++; RotateEntity(TailGate,Vec3(0,TailGateAngle,0));//Tailgate is an undeclared Identifier } else { TailGateStatus=1;//open } } if(TailGateStatus==3) { if(TailGateAngle>0) { TailGateAngle--; RotateEntity(TailGate,Vec3(0,TailGateAngle,0)); } else { TailGateStatus=0;//closed } } };
  22. Ahhh, really? That'd explain a few problems... Thanks carlb! So is this global Entity problem only with 2010 you think? Or its got nothing to do with it?
  23. I'm using C++ 2010, and I'm trying to make a function to rotate a car door, but the door model is loaded in the "main" function so that makes it local only to that function right? How do I get other functions to recognize it too? I've tried Initializing, setting up the graphics and loading the door before "main", but it doesn't work... Any suggestions? (I'm rather new to both C++ and LeadWerks) Thanks
×
×
  • Create New...