Jump to content

Recommended Posts

Posted

Hey guys.

Before anything I'm using LE 2.22 so this may be a issue (after that I started to have strange bugs).

 

Anyway. How can I create a terrain just from code?

 

I tried this

"terrain = CreateTerrain(512,2);

UpdateTerrainNormals(terrain);"

 

but it doesn't seem to work at all. I see nothing.

I tried loading a heightmap but again I see nothing.

I tested the lights and other things with a cube which shows pretty well.

 

I just want to have a terrain to which I can set my elevations manually. I'm trying to make a scene editor (since I don't fancy the original one all that much).

I create the game you play. I create the rulles you will obey.

Posted

CreateTerrain

 

* C: TTerrain CreateTerrain( int resolution=2048 )

* C++:

o Terrain::Terrain( TEntity ent )

o Terrain::Terrain( int resolution = 2048 )

o virtual void Create( int resolution = 2048 )

* BlitzMax: CreateTerrain:TTerrain( resolution:Int=2048 )

* Pascal: function CreateTerrain ( resolution:Integer=2048 ): THandle;

 

Creates a new terrain. A power-of-two size must be used for the resolution or the command will fail and return Null. To further scale the terrain, use the ScaleEntity command.

 

 

and

 

UpdateTerrainNormals

 

* C: void UpdateTerrainNormals( TEntity terrain, int x=-1, int y=-1, int width=1, int height=1 )

* C++: void Terrain::UpdateNormals( int x=-1, int y=-1, int width=1, int height=1 )

* BlitzMax: UpdateTerrainNormals( terrain:TTerrain,x:Int=-1,y:Int=-1,width:Int=1,height:Int=1 )

* Pascal: procedure UpdateTerrainNormals ( terrain:THandle,x,y,width,height );

 

Updates all terrain point normals.

 

Your not calling them correctly

AMD Phenom II x6 1100T - 16GB RAM - ATI 5870 HD - OCZ Vertex 2 60GB SSD

76561197984667096.png

Posted

No.. actually because I am using LE 2.22 I had to call BuildTerrain(terrain) as well. I figured it out when I looked at the change log on the old forum but I didn't know how to delete this topic.

Anyway maybe some future user might need this info :)

Thanks for answering tho.

I create the game you play. I create the rulles you will obey.

Posted

I updated to 2.3 and now I don't have that command anymore

However now when I try to load a terrain I get a very weird visual bug:

weirdyp.jpg

It's as if the image is not clearing anymore when I move the camera around.

I tried to find a command to clear the screen but I don't think there is one.

My one code was

terrain = CreateTerrain(1024);

I have a cube there.. a directional light and a point light. Intresting is the fact that the point light draws over and over on the terrain untill it becomes totally white. I faced this problem when I wasn't clearing the screen but this only happens on the terrain.

Is it just me or is this a bug?

I create the game you play. I create the rulles you will obey.

Posted

Could you post the code?

Do you have multiple worlds? Did you use framewerk (framework on 2.3) or skyboxes?

Intel Corei7-6700, NVIDIA GeForce GTX 980, 32GB DDR4, W-10.

Posted

Well since the project is a bit more large I can't really post the code plus that I'm not sure I'm allowed (I have to do this for someone).

No framewerk. I really don't like that thing. No sandbox (this is supposed to be a type of sandbox it'self). Just one world without any skyboxes.

 

Here are some chunks of code

float omx;
float omy;
SetUp();
CreateInterface();
TVec3 camRot = EntityRotation(viewCam);
TMesh cube = CreateCube();

terrain = CreateTerrain(1024);

 

The way I draw the scene in the while loop:

UpdateWorld();
SetBuffer(buffer);
RenderWorld();
SetBuffer(BackBuffer());
RenderLights(buffer);
UpdateInterface();
Flip(0);

 

Also here is the log(nothing wrong with it as far as I can see):

Leadwerks Engine 2.3

Initializing Renderer...

OpenGL Version: 2.1.2

GLSL Version: 1.20 NVIDIA via Cg compiler

Render device: GeForce 8600M GT/PCI/SSE2

Vendor: NVIDIA Corporation

DrawBuffers2 supported: 1

32 texture units supported.

GPU instancing supported: 0

Shader model 4.0 supported: 1

Conditional render supported: 0

Loading shader "zip::c:/documents and settings/admin/desktop/sceneeditor/debug/shaders.pak//query.vert", ""...

Loading shader "zip::c:/documents and settings/admin/desktop/sceneeditor/debug/shaders.pak//editor/generic.vert", "zip::c:/documents and settings/admin/desktop/sceneeditor/debug/shaders.pak//editor/sobel.frag"...

Loading shader "zip::c:/documents and settings/admin/desktop/sceneeditor/debug/shaders.pak//mesh/mesh_shadow.vert", ""...

Loading shader "zip::c:/documents and settings/admin/desktop/sceneeditor/debug/shaders.pak//mesh/mesh.vert", "zip::c:/documents and settings/admin/desktop/sceneeditor/debug/shaders.pak//mesh/mesh.frag"...

Loading shader "zip::c:/documents and settings/admin/desktop/sceneeditor/debug/shaders.pak//terrain/terrain.vert", "zip::c:/documents and settings/admin/desktop/sceneeditor/debug/shaders.pak//terrain/terrain.frag"...

Loading shader "zip::c:/documents and settings/admin/desktop/sceneeditor/debug/shaders.pak//postfilters/postfilter.vert", "zip::c:/documents and settings/admin/desktop/sceneeditor/debug/shaders.pak//postfilters/depthblit.frag"...

Loading texture "incbin::noise.dds"...

Loading shader "zip::c:/documents and settings/admin/desktop/sceneeditor/debug/shaders.pak//postfilters/postfilter.vert", "zip::c:/documents and settings/admin/desktop/sceneeditor/debug/shaders.pak//lighting/directionallight.frag"...

Loading shader "zip::c:/documents and settings/admin/desktop/sceneeditor/debug/shaders.pak//lighting/lightvolume.vert", "zip::c:/documents and settings/admin/desktop/sceneeditor/debug/shaders.pak//lighting/pointlight.frag"...

Loading texture "incbin::Arial9.dds"...

I create the game you play. I create the rulles you will obey.

Posted

Well can't help you so much without seeing the code..

Anyway the best way to track a bug is start to comment part of the code till you found what cause the problem.

Intel Corei7-6700, NVIDIA GeForce GTX 980, 32GB DDR4, W-10.

Posted

I edited the code while you were writing...

 

Huh... solved.

Playing with SetBlend is a bad ideed (I do this in my interface)

Using a SetBlend(BLEND_NONE) before drawing the scene seems to fix it.

I create the game you play. I create the rulles you will obey.

Posted

Well I just used SetBlend(BLEND_ALPHA) somewhere to be able to have transparent interface.

Anyway I'm quite sure this is a little bug. Stragely it only happens to terrain. If I comment the terrain creation I see everything fine even without the SetBlend(BLEND_NONE) command.

If it is indeed a bug maybe it can be fixed in LE 2.32 :huh:

I create the game you play. I create the rulles you will obey.

Posted

Sanctus, also try to update your videocard drivers ;)

I have the same one:

Leadwerks Engine 2.31

Initializing Renderer...

OpenGL Version: 3.2.0

GLSL Version: 1.50 NVIDIA via Cg compiler

Render device: GeForce 8600M GT/PCI/SSE2

Vendor: NVIDIA Corporation

DrawBuffers2 supported: 1

32 texture units supported.

GPU instancing supported: 1

Max batch size: 1024

Shader model 4.0 supported: 1

Conditional render supported: 0

Loading shader "zip::huh::/leadwerks engine sdk/vetal/client/shaders.pak//query.vert", ""...

 

And i got large increase of FPS after updating drivers.

Working on LeaFAQ :)

Posted

Hm.. I'm running this on a laptop so I'm not sure if you have the same card.(Altough I know M stands for mobile-> laptops)

Anyway last time I checked the drivers from the Dell were really old or something. Is there any place to download them?

I create the game you play. I create the rulles you will obey.

Posted

Well sadly I installed the new drivers twice and it went bad. I mean my maximum resolution was 640x480 with 16 colors. Nice eh?

Downloaded drivers from laptopvideo2go.com (or something like that) and from nvidia oficial page.

Now I installed back the old driver which seams to work.

Also note that my windows instalation(XP) is basically a wreck. I'm still hanging on it untill it will crash and I'll have to install windows 7 or something.

Anyway from my experience with OpenGL the setblend command is clearly not a driver issue.

Btw.. thanks guys for your answers. You've been helpfull

I still have a problem with terrain raycast but I'll try to see it more indeep before thinking it's a bug.

I create the game you play. I create the rulles you will obey.

Posted

New problem.

This time I'm really clueless.

 

I created a terrain. I use this to modify it

 

for(int i=p.Z-radius;i<p.Z+radius;i++)
{
for(int j=p.X-radius;j<p.X+radius;j++)
{
	float oh = TerrainHeight(terrain,i+512,j+512);
	float d = (radius-dist(p.Z,p.X,i,j))/5000.0f*strength;
	if (d>=0)
	{
		if(currentTool==TOOL_RISE)
		{
			SetTerrainHeight(terrain,i+512,j+512,oh+d);
		}
		if(currentTool==TOOL_LOWER)
		{
			SetTerrainHeight(terrain,i+512,j+512,oh-d);
		}
	}

}
}
UpdateTerrainNormals(terrain);

 

I saved it's heightmap using SaveTerrainHeightmap and the in the same way I loaded it back into a new terrain.

 

If I try to modify a loaded terrain it aparently modifies it as if it had no heightmap data.

Studied the problem more and TerrainHeight does not return the height from the new heightmap that I loaded.

Can anyone help me here?

EDIT:

Even more.. Aparently when you save a heiightmap and load it back. It get's rotated and flipped.

I attached before and after images.

post-414-12691010054242_thumb.jpg

post-414-12691010182374_thumb.jpg

I create the game you play. I create the rulles you will obey.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...