Posted: Sat May 30, 2009 5:20 am
got ya, thanks for the info.
Official forum of the Irrlicht Engine
https://irrlicht.sourceforge.io/forum/
Code: Select all
CTexture = driver->addTexture(core::dimension2d<s32>(tw, th), "colortexture", video::ECF_A8R8G8B8);
Code: Select all
CTexture = driver->addTexture(core::dimension2d<u32>(tw, th), "colortexture", video::ECF_A8R8G8B8);
Code: Select all
void makeRandomHills(ShTlTerrainSceneNode* node, s32 hillCount, s32 maxRadius)
{
double pi = 3.1415926535;
// make hills
for(int n=0; n<hillCount; n++)
{
s32 radius = rnd(1, maxRadius);
f32 height = rnd(1, radius);
height = height/10;
core::vector2d<s32> pos;
pos.X = rnd(-radius, node->getSize().Width-radius);
pos.Y = rnd(-radius, node->getSize().Height-radius);
// decide if add or substract
if(rnd(1)==1) height = -height;
// create hill using sinus and distance to center
for(int j=0; j<=radius*2; j++)
for(int i=0; i<=radius*2; i++)
{
f32 distance = core::vector2d<s32>(i-radius, j-radius).getLength();
if(distance <= radius)
{
f32 v = radius;
v = v - distance;
v = v / radius;
v = v * pi / 2;
v = sin(v);
if(pos.X+i>=0 && pos.X+i<node->getSize().Width+1 && pos.Y+j>=0 && pos.Y+j<node->getSize().Height+1)
node->setHeight(pos.X+i, pos.Y+j, node->getHeight(pos.X+i, pos.Y+j)+v*height*node->getTileSize());
}
}
}
}
Code: Select all
1>c:\users\valued customer\documents\visual studio 2008\projects\shtit2\somefunctions.h(19) : warning C4244: 'initializing' : conversion from 'int' to 'irr::f32', possible loss of data
1>c:\users\valued customer\documents\visual studio 2008\projects\shtit2\somefunctions.h(32) : warning C4244: 'initializing' : conversion from 'irr::s32' to 'irr::f32', possible loss of data
1>c:\users\valued customer\documents\visual studio 2008\projects\shtit2\somefunctions.h(35) : warning C4244: 'initializing' : conversion from 'irr::s32' to 'irr::f32', possible loss of data
1>c:\users\valued customer\documents\visual studio 2008\projects\shtit2\somefunctions.h(38) : warning C4244: '=' : conversion from 'double' to 'irr::f32', possible loss of data
1>ShTlTerrainSceneNode.cpp
1>c:\users\valued customer\documents\visual studio 2008\projects\shtit2\shtlterrainscenenode.cpp(1235) : warning C4018: '<' : signed/unsigned mismatch
1>c:\users\valued customer\documents\visual studio 2008\projects\shtit2\shtlterrainscenenode.cpp(1237) : warning C4018: '<' : signed/unsigned mismatch
Code: Select all
f32 height = rnd(1, radius);
Code: Select all
if(MeshSize.Width < CTexture->getSize().Width) w = 1;
s32 h = 0;
if(MeshSize.Height < CTexture->getSize().Height) h = 1;
Code: Select all
int i = 10;
float f = (float)i;
Code: Select all
float f = 10.9f;
int i = (int)f;
Code: Select all
void makeRandomHills(ShTlTerrainSceneNode* node, s32 hillCount, s32 maxRadius)
{
double pi = 3.1415926535;
// make hills
for(int n=0; n<hillCount; n++)
{
s32 radius = rnd(1, maxRadius);
f32 height = (f32)rnd(1, radius);
height = height/10;
core::vector2d<s32> pos;
pos.X = rnd(-radius, node->getSize().Width-radius);
pos.Y = rnd(-radius, node->getSize().Height-radius);
// decide if add or substract
if(rnd(1)==1) height = -height;
// create hill using sinus and distance to center
for(s32 j=0; j<=radius*2; j++)
for(s32 i=0; i<=radius*2; i++)
{
f32 distance = core::vector2d<s32>(i-radius, j-radius).getLength();
if(distance <= radius)
{
f32 v = (f32)radius;
v = v - distance;
v = v / radius;
v = v * pi / 2;
v = sin(v);
if(pos.X+i>=0 && pos.X+i<node->getSize().Width+1 && pos.Y+j>=0 && pos.Y+j<node->getSize().Height+1)
node->setHeight(pos.X+i, pos.Y+j, node->getHeight(pos.X+i, pos.Y+j)+v*height*node->getTileSize());
}
}
}
}
Code: Select all
1>visual studio 2008\projects\letsgohuntin\somefunctions.h(32) : warning C4244: 'initializing' : conversion from 'irr::s32' to 'irr::f32', possible loss of data
1>visual studio 2008\projects\letsgohuntin\somefunctions.h(38) : warning C4244: '=' : conversion from 'double' to 'irr::f32', possible loss of data
Line 32 // f32 distance = core::vector2d<s32>(i-radius, j-radius).getLength();
Line 38 // v = v * pi / 2;
Code: Select all
f32 distance = core::vector2d<f32>(i-radius, j-radius).getLength();
v = v *core::PI / 2; // too lazy to look at the code right now
I don't know what you mean by that. You can get height of any tile corner given you know its coordinates (in tiles) with virtual f32 getHeight(s32 w, s32 h); and you can get its normal with virtual core::vector3df getNormal(s32 w, s32 h);. There are corresponding seter functions also so you can modifi (deform) terrain at run time. You can get any height of terrain at any coordinate with virtual f32 getHeight(core::vector3df pos); and last you can get intersection with line using virtual bool getIntersectionWithLine( core::line3d<f32> line, core::vector3df &outIntersection);. That pretty much covers all physical interaction with terrain needed I can imagine.-Will you ever add support for adding physics? (obtaining verts?)
No I don't.-Do you plan to page an entire terrain to make it truly endless? (using files)
No I don't. I was planing to develop it further with texture blending (current texturing method is not too flexible) and I was planing LOD of kind. I wanted to use "atlas" texture for blending but so far Irrlicht does not grant access to mipmap levels and without one atlas texture will not work good. hybrid did plan to implement direct access to mipmap levels in to Irrlicht but it is apparently not high on to-do list so no idea when and if at all it will be implemented.-Are you still updating this great addon?
No, tiles are not removed from memory when mesh shifts in to new position. There is no reason as no new ones are added. Same set of tiles is used all the time. Instead whole mesh is moved and updated at the new position. This happens in void ShTlTerrainSceneNode::updateVertices(TlTSector §or). Only time some tiles are added or removed is when you initiate terrain or resize its visible mesh.-when a "tile" is removed while you navigate, is it also removed from memory?
Unfortuanatly I want to know everything, I wouldnt dream of turning this off, I bet shadowslair does the same! I like a clean house.It might be, you can change it somewhere in compiler settings
I am on this site many times during my adventures in Irrlicht, its very useful and for anyone using C++ I would think it to be a "tool", This and the IrrLicht CHM work nicely together.Thinking in C++ 2nd Edition by Bruce Eckel
Arras, I dont think you can go wrong here. It seems as an addon for the big picture, this suggestion IMO would be something surely to consider. Reading through this thread and also knowing that the possibility to add this to the irrlicht library was being reviewed could not only help the irrlicht library but also many "many" 3d programmers using Irrlicht. By the response of your Tiled Terrain and also responses on the french forum as well to the subject it seems that there is a great interest in the Tiled Terrain applications in not only Irrlicht but many of the 3d engines.I was also thinking to make it more "Irrlichtish"
arras wrote-Will you ever add support for adding physics? (obtaining verts?)
I am a bit away from actually contributing code to your project, however, I hope to one day be there, sooner than later I hope! I will do what I can to mull over your Tiled Terrain, I have it integrated with a couple of play projects I have and do beat it up some!I don't plan on that but I might help you to do it. That might however include only advice, I will not have time for some heavy coding so you would be one to carry on burden.
arras wrote-Do you plan to page an entire terrain to make it truly endless? (using files)
just know that like myself, many people are looking for that "endless" terrain as presented in WOW. Your code is the beginning of that in the free community without having to spend a few months putting it together themselves.No I don't.
I see your edit and see that hybrid has come through, wonderful. I am so looking forward to this and hope you can find time to incorporate your new texture blending.planing to develop it further with texture blending
arras wrote-when a "tile" is removed while you navigate, is it also removed from memory?
Again, my thinking around truly endless terrain, shifting into a newly loaded terrain would need to have the old one removed to conserve memory. In theory, using files, we should be able to construct many terrains, load them, unload them etc. I know this is far reaching however, if indeed your in a rewrite, maybe you could consider some of these idea's.No, tiles are not removed from memory when mesh shifts in to new position.