Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1]
  Print  
Author Topic: TV3D 6.5 and C++ Questions  (Read 976 times)
microdot
Community Member
*
Posts: 58

Owner of Univerb Gaming Studios


WWW
« on: April 01, 2008, 05:05:23 PM »

Hi Guys  Grin

I have two questions. 1) I have loaded a heightmap but textures are not showing and 2) My input code is dodge. I cannot intercept mouse input and my heightmap vanishes after about 50deg in either direction when I rotate using keys A and D.

Here is code:

Issue 1:

Code:
pScene->SetViewFrustum(60,5000);
pScene->SetTextureFilter(cTV_FILTER_TRILINEAR);

pLighting = new CTVLightEngine();
pLighting->SetGlobalAmbient(0,0,0);

pTextureFactory = new CTVTextureFactory();
int Texture = pTextureFactory->LoadTexture("K:\\text.bmp", "landText", 2048, 2048);

pLandscape = new CTVLandscape();

pLandscape = pScene->CreateLandscape("landMap");

pLandscape->GenerateTerrain("K:\\height.bmp", cTV_PRECISION_HIGH, 8, 8, 0, 0, 0,true);
pLandscape->SetLightingMode(cTV_LIGHTING_MANAGED);
pLandscape->ExpandTexture(Texture, 0, 0, 8, 8,true);
    pLandscape->SetCullMode(cTV_BACK_CULL);

PosSx = 1024;
PosSy = 0;
PosSz = 1024;

PosX = 0;
PosY = 100;
PosZ = 0;

    pScene->SetCamera(0, 100, 0, 1024, 0, 1024);
pCamera = pScene->GetCamera();


cTV_3DVECTOR* x = new cTV_3DVECTOR(-1,-1,1);
Sun = pLighting->CreateDirectionalLight(x, 1,1,1,"sunlight",1);
pLighting->SetSpecularLighting(true);

pMaterial = new CTVMaterialFactory();
LandMat = pMaterial->CreateMaterial("landMat");

pMaterial->SetAmbient(LandMat, 0.1f,0.1f,0.1f,1);
pMaterial->SetDiffuse(LandMat, 0.8f,0.8f,0.8f,1);
pMaterial->SetSpecular(LandMat, 0.2f,0.2f,0.2f,1);
pMaterial->SetPower(LandMat, 20);
pMaterial->SetEmissive(LandMat, 0,0,0,1);

pLandscape->SetMaterial(LandMat, -1);

In my render loop -

Code:
pLighting->EnableLight(Sun, true);
pLandscape->Render();

Issue 2:

Code:
void KeyPressCheck()
{
pScene->SetCamera(PosX, PosY, PosZ, (float)(PosX + pMath->ACos(Ang)), (float)(PosY + pMath->ASin(AngY)), (float)(PosZ + pMath->ASin(Ang)));


if (pInput->IsKeyPressed(cTV_KEY_A))
{     
Ang = Ang + pTV->AccurateTimeElapsed()  * 0.001f;
}
if (pInput->IsKeyPressed(cTV_KEY_D))
{
Ang = Ang - pTV->AccurateTimeElapsed()  * 0.001f;
}

PosX = PosSx;
            PosY = PosSy;
            PosZ = PosSz;


Any help appreciated.
« Last Edit: April 01, 2008, 05:24:01 PM by microdot » Logged

Univerb Gaming Studios: www.univerbstudios.co.za
microdot
Community Member
*
Posts: 58

Owner of Univerb Gaming Studios


WWW
« Reply #1 on: April 02, 2008, 01:24:41 AM »

Anyone?
Logged

Univerb Gaming Studios: www.univerbstudios.co.za
JukkaKevät
Customers
Community Member
*****
Posts: 182


« Reply #2 on: April 02, 2008, 01:37:15 AM »

You sure you have set the texture to landscape, currently you are only expanding one. Try Landscape.setTexture after generation.
Logged
microdot
Community Member
*
Posts: 58

Owner of Univerb Gaming Studios


WWW
« Reply #3 on: April 02, 2008, 01:48:47 AM »

Thanks for the advice.

I did try pLanscape->setTexture(texture number, -1); after the heightmap was created. Still grey. I checked log files too, texture is loaded correctly.

Does my second issue, input control look correct? I seem to lose the level at about 50degrees any direction, like the camera doesn't know the level is there anymore. Even tried turning culling off just to test.
Logged

Univerb Gaming Studios: www.univerbstudios.co.za
microdot
Community Member
*
Posts: 58

Owner of Univerb Gaming Studios


WWW
« Reply #4 on: April 02, 2008, 04:33:33 AM »

Anyone? Cheesy I am persistent Wink
Logged

Univerb Gaming Studios: www.univerbstudios.co.za
nadjibus
Community Member
*
Posts: 250

Heavy Dev Process


« Reply #5 on: April 02, 2008, 06:02:15 AM »


Code:
void KeyPressCheck()
{


if (pInput->IsKeyPressed(cTV_KEY_A))
{     
Ang = Ang + pTV->AccurateTimeElapsed()  * 0.001f;
}
if (pInput->IsKeyPressed(cTV_KEY_D))
{
Ang = Ang - pTV->AccurateTimeElapsed()  * 0.001f;
}

PosX = PosSx;
            PosY = PosSy;
            PosZ = PosSz;

pScene->SetCamera(PosX, PosY, PosZ, (float)(PosX + pMath->ACos(Ang)), (float)(PosY + pMath->ASin(AngY)), (float)(PosZ + pMath->ASin(Ang)));


I think you have to call SetCamera after checking keys, not before.
Logged

microdot
Community Member
*
Posts: 58

Owner of Univerb Gaming Studios


WWW
« Reply #6 on: April 02, 2008, 06:34:10 AM »

If I call the set on camera after keyboard processing, when I exit the app protected memory is written to and the app crashes.

Also I had no luck with different results level still goes away when rotating.

Do you have a keyboard and mouse example in C++ for me to compare against?
« Last Edit: April 02, 2008, 06:36:12 AM by microdot » Logged

Univerb Gaming Studios: www.univerbstudios.co.za
nadjibus
Community Member
*
Posts: 250

Heavy Dev Process


« Reply #7 on: April 02, 2008, 06:50:32 AM »

Do you have a keyboard and mouse example in C++ for me to compare against?

Yeah there's TONS of samples in this forum who have this. first thing I meeted on forums now is http://www.truevision3d.com/forums/tv3d_sdk_65/zaks_hlsl_sky_demo_in_vbnet_download-t12366.0.html
All Zak's samples/shaders/demos use good input management.
Logged

microdot
Community Member
*
Posts: 58

Owner of Univerb Gaming Studios


WWW
« Reply #8 on: April 02, 2008, 06:54:13 AM »

That is exactly what I was looking for, If you reckon implementation was good I will use the opportunity to learn from it.

Anyone have ideas on what I did incorrectly with my terrain that took away my texture that was loaded? Debug file says loaded fine, code expands from points 0,0 to heights 8,8 as setup. I have tried setTexture too.

Did my lighting implementation mess it up? I had to add a material to the landscape for lighting to work. Perhaps this is my issue.

Appreciate the help on all this so far.
Logged

Univerb Gaming Studios: www.univerbstudios.co.za
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks