Jump to content

LE2:: Camera control tutorial code anomaly


Juggernaut
 Share

Recommended Posts

Hi,

 

I am following the camera control tutorial of LE 2 as shown here -

 

http://www.leadwerks.com/werkspace/page/Documentation/le2/_/tutorials/camera-controls-r385

 

When I move my mouse sideways I find a slight frosted glass or watery wave along surface of the brick columns and a bit jittery on the edges of the brick columns.

 

What is causing this ? How can I fix it so that it does not happen in my game ?

 

Thanks,

Link to comment
Share on other sites

Well the problem is that it happens only when I am moving the camera using the mouse. So I do not think a picture will tell the what I mean. You might be able to see it in the tutorial video if you are viewing it in high quality. It is more like a subtle heat-haze effect on the

edges and surface of the brick columns - happens only when the camera is moved. No such effect noticed on the concrete floor

though.

Link to comment
Share on other sites

ok. But I think activating anti-aliasing can fix my issue. I found the function SetAntialias();

But when I call it after Graphics(), though the program builds but it does not run - throws run-time error. "Unhandled exception at 0x777015de in Game_3.exe: 0xC0000005: Access violation reading location 0x00000000."

 

When should I call SetAntialias(1) ? Before Graphics() or after Graphics() or somewhere else ?

Link to comment
Share on other sites

No. I am just trying to set up anti-aliasing working in that camera tutorial.

Link to comment
Share on other sites

TFramework framework=CreateFramework();

if (!framework) {

MessageBoxA(0,"Error","Failed to create framework.",0);

return Terminate();

}

TLayer layer = GetFrameworkLayer(0);

TCamera cam=GetLayerCamera(layer);

//Set Lua variable

BP L=GetLuaState();

lua_pushobject(L,framework);

lua_setglobal(L,"fw");

lua_pop(L,1);

//DebugPhysics(true);

// Post Processing FX

SetGodRays(0);

SetHDR(0);

 

Framework creates a world for you.

amd quad core 4 ghz / geforce 660 ti 2gb / win 10

Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++

Link to comment
Share on other sites

All right, I will try to look at that "Framework" thing first smile.png ..... if that is a wonder wand for us ( new comers ).

 

It seems your code is in LUA and I am using C++ ...... so I guess I look for the C++ version of the framework.

Link to comment
Share on other sites

Heres some code that sets up a third person camera. Easily changed to first person.

NOTE: I have removed my own gameplay code and this may cause a syntax error. If so it will be something to do with curly brackets.

 

#include "engine.h"

 

TEntity scene;

 

int

 

 

main(int argc, char** argv)

{

 

Initialize();

RegisterAbstractPath(

 

"c:/mygame");

Graphics(1100,800);

AFilter(4) ;

TFilter(1) ;

 

TFramework framework=CreateFramework();

 

 

if (!framework) {

MessageBoxA(0,

 

"Error","Failed to create framework.",0);

 

 

return Terminate();

}

TLayer layer = GetFrameworkLayer(0);

TCamera cam=GetLayerCamera(layer);

 

 

//Set Lua variable

BP L=GetLuaState();

lua_pushobject(L,framework);

lua_setglobal(L,

 

"fw");

lua_pop(L,1);

DebugPhysics(

 

false);

 

 

// Post Processing FX

SetGodRays(0);

SetHDR(0);

SetSSAO(0);

SetBloom(0);

SetAntialias(0);

SetStats(1);

SetReflectionElements(ENTITY_RENDERABLE);

 

 

 

 

// Skybox

SetSkybox(LoadMaterial(

 

"abstract::NiceSky.mat"));

 

 

//SetBackgroundColor(Vec4(1.0f, 1.0f, 1.0f, 1));

SetBackgroundColor(Vec4(1.12f, 0.82f, 0.82f, 1));

// Movement vars

 

 

float move=0.0, strafe=0.0;

TVec3 camrotation=Vec3(0);

 

 

float mx=0, my=0;

 

 

HideMouse();

MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2);

AmbientLight(Vec3(1.0));

 

 

// ************************* main loop ******************

while

 

 

( !KeyHit(KEY_ESCAPE ))

 

UpdateAppTime();

UpdateWorld(AppSpeed());

mx=Curve(MouseX()-GraphicsWidth()/2,mx,6);

my=Curve(MouseY()-GraphicsHeight()/2,my,6);

MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2);

camrotation.X=camrotation.X+my/10.0;

camrotation.Y=camrotation.Y-mx/10.0;

RotateEntity(cam,camrotation);

move = 3.5 * (KeyDown(KEY_W) - KeyDown(KEY_S));

strafe = 3 * (KeyDown(KEY_D) - KeyDown(KEY_A));

 

 

 

float jump=0.0;

 

 

if (KeyHit(KEY_SPACE)) {

 

 

if (!ControllerAirborne(player)) {

jump=8.0;

}

}

 

 

// move faster

 

 

if(KeyDown(KEY_E) ){

 

 

if (!ControllerAirborne(player)) {

move*=3.0;

strafe*=2.0;

}

 

}

 

 

}

 

 

//Position camera and 3rd person main character

TVec3 playerpos=EntityPosition(player);

TVec3 camerapos=EntityPosition(cam);

camerapos.Y=Curve(playerpos.Y+ 0.80,camerapos.Y,2.0);

camerapos=Vec3(playerpos.X,camerapos.Y,playerpos.Z);

camerapos=Vec3(playerpos.X,camerapos.Y,playerpos.Z);

PositionEntity(cam,camerapos);

MoveEntity(cam,Vec3(0.3,0,-2.3));

UpdateController(player, camrotation.Y, move, strafe, jump, 500.0f);

 

UpdateFramework();

RenderFramework() Flip(0) ;

}

}

 

}

 

// main

amd quad core 4 ghz / geforce 660 ti 2gb / win 10

Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++

Link to comment
Share on other sites

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.

 Share

×
×
  • Create New...