Jump to content

SpiderPig

Members
  • Posts

    2,285
  • Joined

  • Last visited

Posts posted by SpiderPig

  1. SetTerrainHeight

    C: void SetTerrainHeight( TEntity terrain, long x, long y, flt height )

    C++: void Terrain::SetHeight( int x, int y, flt height )

    BlitzMax: SetTerrainHeight( terrain:TTerrain, x, y, height# )

    Pascal: procedure SetTerrainHeight ( terrain:THandle; x:Integer; y:Integer; height:Single );

    Sets the terrain height at the specified grid point. Height should be a number between 0 and 1.

     

    How is a height between 0 and 1 of any use? Are all vertex heights in a terrain decimals are they?

  2. The description says it!

     

    I've made a function in a dll and I want to write text to the screen through it (on the leadwerks buffer), but printf only prints to the console.

    I could make do with that but it keeps adding to it every loop and it's not pretty...

    Does any one know how to print to the screen using C++ commands?

    Or - printing to the console and erasing text from the previous loop?

     

    Thanks!

  3. Haha, Just figured it out once I posted it...

     

    I had to do;

     

    TPick pick

     

    instead of;

     

    TPick* pick

     

    and call on it like so;

     

    if(MouseHit(1))
    		{
    		if(CameraPick(&pick,camera,Vec3(MouseX(),MouseY(),100),2,0,0))
    		{
    				EntityColor(pick.entity,Vec4(0,1,0,0));
    		};
    		};
    

     

    Well, hope this helps someone else :)

     

    Though how do I check which entity I'm picking in order to change the color of only that entity? The following code didn't work for me;

     

    		if(MouseHit(1))
    		{
    		if(CameraPick(&pick,camera,Vec3(MouseX(),MouseY(),100),2,0,0))
    		{
    			if(pick.entity==cube)
    			{
    				EntityColor(pick.entity,Vec4(0,1,0,0));
    			};
    		};
    		};
    

  4. Hi,

     

    CameraPick() is givening me the following error;

     

    "Unhandled exception at 0x752c9b60 in game-Release.exe: 0xC0000005: Access violation writing location 0x00000000."

     

    and then it goes to this line in "Disassembly";

     

    "752C9B60 rep movs dword ptr es:[edi],dword ptr [esi] "

     

    This is my code;

     

    TPick* pick
    
    while( !KeyHit() && !AppTerminate() )
    {
    	if( !AppSuspended() ) // We are not in focus!
    	{
    
    		if(MouseHit(1))
    		{
    		if(CameraPick(pick,camera,Vec3(MouseX(),MouseY(),100),2,0,0))
    		{
    			EntityColor(pick->entity,Vec4(0,1,0,0));
    		};
    		};
    
    
    		UpdatePlayer();
    
    	                UpdateAppTime();
    		UpdateWorld(AppSpeed()) ;
    
    		// Render
    		SetBuffer(gbuffer);
    		RenderWorld();
    
    		SetBuffer(BackBuffer());
    		RenderLights(gbuffer);//ComputerTexture=GetColorBuffer(BackBuffer(),1);
    
    		Flip(1) ;
    	}
    }
    

     

    I tried it without setting the color of the picked entity or a mouse check but it still crashed.

    What am I missing?

  5. I think this still comes under the same topic:

     

    How do I render lights and shadows to the ComputerBuffer?

    I tried this code but I get no change at all;

     

                   TBuffer currentb=CurrentBuffer();
    TWorld currentw=CurrentWorld();
    
    SetWorld(ComputerWorld);
    RotateEntity(cube,Vec3(0,EntityRotation(cube).Y+=1,0));
    UpdateWorld(AppSpeed());
    
    SetBuffer(ComputerBuffer);
    RenderWorld();
    
    SetBuffer(ComputerLightBuffer);
    RenderLights(ComputerBuffer);
    
    
    ComputerTexture=GetColorBuffer(ComputerBuffer);
    SetMaterialTexture(mat1,ComputerTexture,0);
    SetBuffer(currentb);
    SetWorld(currentw);
    

     

    I've created a directional light after the creation of the ComputerWorld and ComputerLightBuffer is exaclty the same as ComputerBuffer. What am I doing wrong?

     

    EDIT: Figured it out. I have to get the color from the light buffer instead of the geometry buffer...

     

           TBuffer currentb=CurrentBuffer(); 
           TWorld currentw=CurrentWorld(); 
    
           SetWorld(ComputerWorld); 
           RotateEntity(cube,Vec3(0,EntityRotation(cube).Y+=1,0)); 
           UpdateWorld(AppSpeed()); 
    
           SetBuffer(ComputerBuffer); 
           RenderWorld(); 
    
           SetBuffer(ComputerLightBuffer); 
           RenderLights(ComputerBuffer); 
    
    
           ComputerTexture=GetColorBuffer(ComputerLightBuffer); 
           SetMaterialTexture(mat1,ComputerTexture,0); 
           SetBuffer(currentb); 
           SetWorld(currentw);
    

  6. Yeah, your model did. But I did the exact same thing to mine and it didn't. I tried a cube exported from blender with the same materials and through the same process and yet nothing again....no idea...maybe my programs are in need of updateing or somthing. I have UU3D v3.0 and blender 249.2 and leadwerks 2.4.

  7. Tried it and nothing.... No idea whats happeing with it. :) I changed the names and diffuse textures. The model loads and displays the materials fine, it's just when I set the buffer to the texture and change it to the texture0 channel. :(

    I'll just have to try a new model or something, see if that works.

  8. I scaled it to .08 times and the material still didn't work.

     

    I just tried setting the buffer to the material of another model I exported from blender, and this model tiles it's texture about 100 times so if it was going to work, I'd see it. Instead it showed only one rendered cube smack bang in the centre of the entire model. Maybe the UV coordinates arnt being read correctly?

  9. Here it is in .obj;

     

     

     

    I model it in blender and export it to .3ds then open it in UU3D pro and asign it textures then export it to .obj and convert it to .gmf.

    Blenders .obj exporter dosn't work great for me so this is the only way I can get stuff to work.

     

     

    EDIT: Yeah I havn't rescaled my models yet. Would this effect anything?

  10. Thanks,

     

    I just tested the buffer on an extra cube made in the main world and it worked perfectly. It's the model then, but I'm not sure what.

    The UV coordinates are fine and other textures I loaded and applied to the texture0 channel worked....Is there somthing special that needs to be done to a model for this to work?

  11. 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 :D

  12. 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.

  13. 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.

×
×
  • Create New...