[1.0]Heightfield

radsun

25-07-2008 12:38:06

I created using Terragen heightfield, saved as raw8,using Flour converted:
flour heightfield in:hf.raw
and...
1.HoleMaterial
When it's default (0) terrain not exists, no collisions and there is nothing in RemoteDebugger
2.Visualise Terrain
This function not work or maby i try to use it wrong
"centering:xz-above, hole-material:65556, terrain-flags: +vt"
3.Heightfield
:shock:
Another thing is in game, another in remote debugger.
Ogre::Real TERRAIN_PAGEWORLDX = 140.0;
Ogre::Real TERRAIN_PAGESIZE = 257.0;
Ogre::Real TERRAIN_TILESIZE = 33.0;
Ogre::Real TERRAIN_MAXHEIGHT = 20.0;

Real Scale = TERRAIN_PAGEWORLDX / ( TERRAIN_PAGESIZE - 1.0 );
NxOgre::ActorParams ap;
ap.setToDefault();
ap.mMass = 0.0; // <--- make it static
ap.mDensity = 0.0;

NxOgre::ShapeParams sp;
sp.setToDefault();

//- sp.mMaterialAsIndex = 0;
//- sp.mMeshScale = NxVec3( Scale, 1.0, Scale );

NxOgre::Resources::Heightfield* hf = NxOgre::Resources::ResourceSystem::getSingleton()->getHeightfield("terrain");

NxOgre::Terrain* terrain = new NxOgre::Terrain(
hf,
NxOgre::float3(128,4,128),
sp,
"centering:xz-above, hole-material:65556");

NxOgre::Actor* mTerrainCollision = mNxScene->createActor("terenik", terrain,
Ogre::Vector3(64, 4, 64),
"static: yes");

:?: :?: :?:

betajaen

25-07-2008 12:43:22

The raw has been saved as a greyscale image with a power of two size?

radsun

25-07-2008 12:47:33

Raw/binary (grayscale) image with 8 bits per pixel

Data width is 257
Data height is 257

zissakos

25-07-2008 12:59:30

what does flour say when you convert it?

radsun

25-07-2008 13:02:53

D:\Ogre>flour heightfield in:t.raw
[NxOgre] NxOgre 1.0.22 Bleeding Edge started. Working with
[NxOgre] - PhysX => 2.8.0 (280)
[NxOgre] - Ogre => 1.4.6 (Eihort)
[NxOgre] - Hardware => Probably
[NxOgre] - Platform => Windows (Debug)
[NxOgre]
leng:66049
Sqrt:148.378
Image is 181x181 px @ 16-bit.
Combined wh is 32761 (181, 181)
Byte = 131044
Size of hfs = 4
[NxOgre] PhysX SDK has stopped.

zissakos

25-07-2008 13:19:12

I think 8 bits per pixel is not enough. You should have 24 or 32 bits per pixel. That solved the problem fopr me.

What I did was increase Color depth to 24bit in Corel Paint Shop Pro before saving the image as a .raw.

Try to increase the color depth to true-color!

betajaen

25-07-2008 13:24:46

And 257x257 isn't a power of two.

radsun

25-07-2008 18:17:47

And 257x257 isn't a power of two.
power of two+1

I can only select 129,257 or 513.

EDIT: i converted using InfranView to 256x256x24 and it's working but i need to use 8bpp for ogre :P

how about 1&&2 :?:

betajaen

25-07-2008 18:29:43

If you want to you can modify flour to accept width/height from the commandline. It's only around 8-9 lines across two/three files.

jonnys

28-07-2008 18:52:37

I converted a terrain.png to a 512x512 raw file, then to a .xhf file and loaded it in, and now, there is a huge performance hit, when I load the terrain scene. And also it (terrain collision model) is not aligned with the terrain in the ogre scene. Is there something wrong with my code:


NxOgre::Resources::ResourceSystem::getSingleton()->addHeightfieldAs("file://terrain.xhf", "terrain_terrain");

//Got thes values from terrain2.cfg
//Real Scale = Globals::TERRAIN_PAGEWORLDX / ( Globals::TERRAIN_PAGESIZE - 1.0 );
Real Scale = 1500 / 512 ;
NxOgre::ActorParams ap;
ap.setToDefault();
ap.mMass = 0.0; // <--- make it static
ap.mDensity = 0.0;

NxOgre::ShapeParams sp;
sp.setToDefault();


//- sp.mMaterialAsIndex = 0;


//NxOgre::Pose terrainPose(0, 0, 0);

NxOgre::Resources::Heightfield* hf = NxOgre::Resources::ResourceSystem::getSingleton()->getHeightfield("terrain_terrain");
NxOgre::Terrain* terrain = new NxOgre::Terrain(
hf,
//NxOgre::float3(1500,100,1500),
NxOgre::float3(128,4,128),
sp,
"centering: xz-above, hole-material: 65535");

NxOgre::Actor *mTerrainCollision = mScene->createActor("nxterrain", terrain,
Ogre::Vector3(64, 4, 64),
//terrainPose,
"static: yes");


Also this is my terrain.cfg I use:


# The main world texture (if you wish the terrain manager to create a material for you)
WorldTexture=terrain_texture2.jpg

# The detail texture (if you wish the terrain manager to create a material for you)
DetailTexture=terrain_detail.jpg

#number of times the detail texture will tile in a terrain tile
DetailTile=5

# Heightmap source
PageSource=Heightmap

# Heightmap-source specific settings
Heightmap.image=terrain.png

# If you use RAW, fill in the below too
# RAW-specific setting - size (horizontal/vertical)
# Heightmap.raw.size=512
# RAW-specific setting - bytes per pixel (1 = 8bit, 2=16bit)
# Heightmap.raw.bpp=2

# How large is a page of tiles (in vertices)? Must be (2^n)+1
PageSize=513

# How large is each tile? Must be (2^n)+1 and be smaller than PageSize
TileSize=65

# The maximum error allowed when determining which LOD to use
MaxPixelError=3

# The size of a terrain page, in world units
PageWorldX=1500
PageWorldZ=1500
# Maximum height of the terrain
MaxHeight=100

# Upper LOD limit
MaxMipMapLevel=5

#VertexNormals=yes
#VertexColors=yes
#UseTriStrips=yes

# Use vertex program to morph LODs, if available
VertexProgramMorph=yes

# The proportional distance range at which the LOD morph starts to take effect
# This is as a proportion of the distance between the current LODs effective range,
# and the effective range of the next lower LOD
LODMorphStart=0.2

# This following section is for if you want to provide your own terrain shading routine
# Note that since you define your textures within the material this makes the
# WorldTexture and DetailTexture settings redundant

# The name of the vertex program parameter you wish to bind the morph LOD factor to
# this is 0 when there is no adjustment (highest) to 1 when the morph takes it completely
# to the same position as the next lower LOD
# USE THIS IF YOU USE HIGH-LEVEL VERTEX PROGRAMS WITH LOD MORPHING
#MorphLODFactorParamName=morphFactor

# The index of the vertex program parameter you wish to bind the morph LOD factor to
# this is 0 when there is no adjustment (highest) to 1 when the morph takes it completely
# to the same position as the next lower LOD
# USE THIS IF YOU USE ASSEMBLER VERTEX PROGRAMS WITH LOD MORPHING
#MorphLODFactorParamIndex=4

# The name of the material you will define to shade the terrain
#CustomMaterialName=TestTerrainMaterial



With the terrain shape size set to NxOgre::float3(1500,100,1500) there is a huge performance hit.

jonnys

31-07-2008 16:29:17

Any body have any input or help?...I guess we are taking our well deserved rest :)