Jump to content

Issue with: "Tutorial: Making a Spectator"


Cheese Cake
 Share

Recommended Posts

Hi guys,

My name is Darryl, new to the forums. Have Leadwerks about a year now (only used it for a few days).

I am used to "FPSC"(first person shooter creator), so no scripting required. But the graphics were limited, so was the actual gameplay.

I wanted something new and decided to try Leadwerks. I have followed the tutorials provided at the wiki. They were a great help!

 

But now i cant get further, i am stuck at the tutorial: Making a spectator.

 

I am using Leadwerks with Microsoft Visual C++ 2008 express edition

I first watched the video and typed everything over. (of course, also downloaded the required files)

But it gave me this error: Unhandled exception at 0x04c038b0 in project.exe: 0xC0000005: Access violation reading location 0x00000050.

 

Then, i decided to copy and paste the code from the PDF. But again, same error.

 

In the .exe it stops at: /mesh_diffuse_bumpmap_specular.frag"...

I am no good at scripting, but hoping to learn the basics and become more known with Leadwerks. but it looks like a file is missing. A diffuse texture or bump or specular map?

Even though i copied the files that were included with the tutorial.

 

 

I hope you guys can help me, as i really cant find the problem and cant move on with the tutorials.

 

Cheers,

Darryl

Link to comment
Share on other sites

How do you mean? I have ordered Leadwerks about a year ago. And used it back then. Dont know why, but i took a break from Leadwerks, switched from computers so in the end i lost track of Leadwerks.

 

I just recently wanted to get on track with Leadwerks. So there are probably some new site edits that they hadn't back then.

 

So if it isn't too much to ask, could you point me out how i exactly can do this?

 

 

Also, i saw that there was an update on Leadwerks, are you guys recommending this update? Is it making stuff easier? Or better graphics?

 

Thanks in advance!

Darryl

Link to comment
Share on other sites

So if it isn't too much to ask, could you point me out how i exactly can do this?

Hi Daril,

This is an easy one, it's the first sticky post of this forum section "If you need access to the forums..." http://leadwerks.com/werkspace/index.php?/topic/127-if-you-need-access-to-the-forum/

 

;)

Welcome back

if you did not loose your first name, last name and email adress it should not be a problem :blink:

 

if you want us to tell you what's news since your version, then you should start by telling us what version number you currently have.

 

2.3 adds Lua script programming in the editor

2.4 adds rendering speed optimisations for heavy scenes

 

if you don't need scripting and don't have heavy scenes you can stick with a vesrion previous 2.3 (my opinion) and wait for LE3 big jump.

Windows 7 home - 32 bits

Intel Quad Q6600 - nVidia GTX 460 1GB - 2 GB RAM

Link to comment
Share on other sites

Many of the C++ tutorials are outdated and might not be working correctly anymore. They are more for giving people a general idea of how things work in Leadwerks. Many things like rendering are now easier because of the use of Framework. You can still do it the old by making world and buffers your self, but it for most people it is easier to use framework as there are so many features in it that cover complex code (godrays, anisotropic filtering, buffer rendering, water etc.)

 

Welcome back btw :blink:

Link to comment
Share on other sites

Thanks guys!

 

I have version: 2.28

 

But if those tutorials are outdated, are there new tutorials? Or should i wait until i get registered as a SDK owner, so i can find them.

 

For now i am trying to get used with the tutorials that dont give a error. And trying to get a basic understanding of coding in Leadwerks.

 

Cheers,

Darryl

Link to comment
Share on other sites

I think there may be something else wrong here. Unfortunately, I don't have c++ on this PC to test. But, I'm fairly certain the tutorial will mostly work.

 

I have recently tested this tutorial in C# as I updated my compiler and needed to re-qual some code. As part of this process I re-download the files on 10/04/2010 so I had fresh files. Note: I've ran this with older versions of Leadwerks engine also.

 

I've ran this tutorial in 4 sections based strongly on the lesson,where one section is uncommented at a time for testing:

 

Note: C# code only for explanation to show 4 different tests performed based on lessons

 

class Program

{

static void Main(string[] args)

{

Tutorial tutorial = new Tutorial();

 

tutorial.NoPhysics();

//tutorial.PhysicsBody();

//tutorial.Movement();

//tutorial.Collision();

}

}

 

The only issue I had was in the Physics Body and Movement segment where the spectator/camera initialized at a slightly wierd position and I didn't bother to figure it out as I was only concerned with compiler errors for the testing I was doing.

 

Edit: I should mention I use Engine 2.40

Edit: removed double word

Edit:spelling error

Link to comment
Share on other sites

If your project is a VS2008 console application, press CTRL F5 (starts the project in release mode without debugging). Now when the error occurs, the command prompt window will stay open so you can see which file is failing to load.

LE Version: 2.50 (Eventually)

Link to comment
Share on other sites

Hi Mumbles i tried what you said.

 

And this came up:

 

1>------ Build started: Project: project, Configuration: Release Win32 ------

1>Compiling...

1>project.cpp

1>.\project.cpp(56) : warning C4305: 'argument' : truncation from 'double' to 'flt'

1>.\project.cpp(58) : error C3861: 'CreateMaterial': identifier not found

1>.\project.cpp(59) : error C3861: 'SetMaterialColor': identifier not found

1>.\project.cpp(62) : warning C4305: 'initializing' : truncation from 'double' to 'float'

1>.\project.cpp(71) : warning C4244: 'argument' : conversion from 'int' to 'flt', possible loss of data

1>.\project.cpp(72) : warning C4244: 'argument' : conversion from 'int' to 'flt', possible loss of data

1>.\project.cpp(93) : warning C4305: '+=' : truncation from 'double' to 'float'

1>.\project.cpp(94) : warning C4305: '-=' : truncation from 'double' to 'float'

1>.\project.cpp(95) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data

1>Build log was saved at "file://c:\Users\Gebruiker\Desktop\project\project\project\Release\BuildLog.htm"

1>project - 2 error(s), 7 warning(s)

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

 

Is the code provided in the tutorial like you guys said outdated so it probably isnt working anymore? Or is it something else?

 

Thanks,

Darryl

Link to comment
Share on other sites

Oh, I thought you meant it compiled fine but crashed whilst running.

 

Sounds like there might be a problem with your engine.h file because the missing identifiers are fine for me. The AutoUpdater might have an updated version. If need be, do a clean install to a new folder, then copy the new engine.h over the old one.

LE Version: 2.50 (Eventually)

Link to comment
Share on other sites

Note in my original post I mentioned some weird initial position. I re-watched the first part of the video and the behavior was identical to what I saw running the tutorial n my PC. So, I *assume* the second piece would also behave the same way. In that case, ignore my original comments as this tutorial works fine.

 

Are we really talking about the "Making a spectator" tutorial here or am I confused (very possible)? I see it as the 13th tutorial from the top in the Wiki. I can't find 'CreateMaterial' or 'SetMaterialColor' in the tutorial, so I'm a little confused here. Please correct me (I was very much confused all day yesterday for whatever reason).

 

As mentioned, I've recently gone through the tutorials and can easilly tell you what is working (the vast majority does work). If the errors are in your tutorial code and *not* in engine.h or related stuff as Mumbles mentioned I can compare notes for you.

Link to comment
Share on other sites

I tried now with LE 2.40 (don't know if 2.28 has the same code because some functions were changed from 2.3x e.g. UpdateController, however I haven't pre-2.30 to test) the tutorial code from the last 2 pages and it worked for me with no exception:

 

#include "engine.h"

int main( int argn, char* argv[] )
{
Initialize() ;
RegisterAbstractPath("D:/LE/2.40");
SetAppTitle( "ConsoleC" ) ;
Graphics( 800, 600 ) ;
AFilter() ;
TFilter() ;

//Create a world
if (!CreateWorld()) {
	MessageBoxA(0,"Error","Failed to create world.",0);
	goto exitapp;
}

//Create a camera
TEntity cam=CreateCamera();
CameraClearColor(cam,Vec4(0,0,1,1));
PositionEntity(cam,Vec3(0,2,-10));

//Create a light
TLight light=CreateDirectionalLight();
RotateEntity(light,Vec3(45,45,0));
Collisions(1,2,1);
Collisions(1,3,1);
Collisions(2,2,1);

//Create a render buffer
TBuffer buffer=CreateBuffer(800,600,BUFFER_COLOR|BUFFER_DEPTH|BUFFER_NORMAL);
Collisions(1,1,1);

TModel scene=LoadModel("abstract::tutorial_spectator.gmf");
if (!scene) {
	MessageBoxA(0,"Error","Failed to load mesh.",0);
	goto exitapp;
}
EntityType(scene,1);

TModel model=LoadModel("abstract::oildrum.gmf");
if (!model) {
	MessageBoxA(0,"Error","Failed to load mesh.",0);
	goto exitapp;
}
EntityType(model,2);
SetBodyMass(model,1);
for ( int n=1; n<=100; n++ ) {
	model=CopyEntity(model);
	PositionEntity(model,Vec3(random(-5,5),random(5,15),random(-5,5)));
	RotateEntity(model,Vec3(random(0,360),random(0,360),random(0,360)));
}

//Create the spectator
TBody spectator=CreateBodySphere();
SetBodyMass(spectator,1);
SetBodyGravityMode(spectator,0);
SetBodyDamping(spectator,1.0);
EntityType(spectator,3);
PositionEntity(spectator,Vec3(0,2,-10));
TVec3 camrotation=Vec3(0);
float mx=0;
float my=0;
float move=0;
float strafe=0;
HideMouse();
MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2);

//Main loop
while(!KeyHit(KEY_ESCAPE)) {

	DebugPhysics(KeyDown(KEY_P));

	//Camera look
	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);

	//Camera movement
	move=KeyDown(KEY_W)-KeyDown(KEY_S);
	strafe=KeyDown(KEY_D)-KeyDown(KEY_A);
	TVec3 force = Vec3(strafe*10.0,0,move*10.0);
	force=TFormVector(force,cam,0);
	AddBodyForce(spectator,force);

	//Update the world
	UpdateWorld();

	//Position the camera
	PositionEntity(cam,EntityPosition(spectator));

	//Render the scene
	SetBuffer(buffer);
	RenderWorld();

	//Render lighting
	SetBuffer(BackBuffer());
	RenderLights(buffer);

	//Swap the front and back buffer
	Flip();
}
exitapp:
return Terminate();
}

?? FRANCESCO CROCETTI ??

http://skaredcreations.com

Link to comment
Share on other sites

Hey guys,

 

I copied your code Ziored, but it didn't worked. So i guess it has something to do with the changes in 2.3

 

I also reinstalled Leadwerks, this time i downloaded the installer instead of a ZIP file.

I guess i had an older version on my computer. Now i use 2.28 i think the one i was using before was 2.24,

now it came with Project Wizard. (which i hadn't before this one)

I used the Project Wizard (which is a great addon) set it up for "C++ 2008 windows".

Downloaded the resources (from the tutorial) again, extracted them in the main folder of the project.

Copy and pasted the code from the tutorial and run the project under "release" and "debug" neither of them worked.

 

I also tried the "Loading a Scene" tutorial. But it gave the same error. I think it stops when its loading the scene.

I didn't had any problems before with the other tutorials like: "camera controls" or "character controllers"

Too bad i dont have Leadwerks and Visual C++ on this computer.

 

Cheers,

Darryl

Link to comment
Share on other sites

Hey guys,

 

I copied your code Ziored, but it didn't worked. So i guess it has something to do with the changes in 2.3

 

Yes, there appears to be something wrong here.

 

I downloaded Leadwerks 2.8 and then found I already had it on my PC. Oops... I forgot it was in the Program Files directory! It would have been nice to test my original Leadwerks 2.8 but I have now overridden it.

 

I tested against my C# code which is working against Leadwerks 2.40 and found errors. In the Making a Spectator tutorial I found the barrels created in the CopyEntity loop just hang in the air. If you don't do that loop things seem to work.

 

I had tried the Load Scene tutorial. At this point I had switched the tutorial to a test scene for PureLight (an external scene not from the tutorial) and that is definately broken now. I'll try the original tutorial file but expect it to also be broken.

 

I'll try ZioRed's code and also try to get any additional general information I can from testing. If i have time, I'll get my original 2.28 from my backup and test. I still seem to believe these worked at one time under 2.28, but I'm not confident to say that without testing.

Link to comment
Share on other sites

I had a little bit of time to test more. I copied ZioRed's code, but I'm fairly certain it's right from the tutorial:

 

Background:

- Renamed 'C:\Program Files\Leadwerks Engine SDK' to 'C:\Program Files\zzzLeadwerks Engine SDK' and rebooted PC so I'm not having any version conflict with paths.

- Leadwerks Am renaming currently used Leadwerks Engine SDK version to 'C:\Leadwerks Engine SDK' with a path to that directory

-Am still testing with C#

-Added class prefixes to code (for C#)

-I have a C compatibility class so I don't need modify code with casts, changes, etc. such as 'while (!LW_CC.KeyHit(KEY.KEY_ESCAPE))'

--Changed the scene file path from ZioRed's code. Verified on the Wiki tutorial it's what I have - most likely just a file name change for ZioRed

//TModel scene = LW.LoadModel("abstract::tutorial_spectator.gmf");

TModel scene = LW.LoadModel("abstract::scene.gmf");

 

-Used my existing C# code for the barrels which drop.

for (int n = 1; n <= 100; n++)

{

TEntity modelCopy = LW.CopyEntity(model.Entity);

LW.PositionEntity(modelCopy, LW.Vec3(random.Next(-5, 5), random.Next(5, 15), random.Next(-5, 5)));

LW.RotateEntity(modelCopy, LW.Vec3(random.Next(0, 360), random.Next(0, 360), random.Next(0, 360)));

}

 

-Other than that, ZioRed's code gave me the same result as I got from the Wiki - everything works except the barrels stay in mid-air.

 


Leadwerks Engine 2.28
Initializing Renderer...
OpenGL Version: 4.0.10151 Compatibility Profile Context
GLSL Version: 4.00
Render device: ATI Radeon HD 5700 Series
Vendor: ATI Technologies Inc.
DrawBuffers2 supported: 1
16 texture units supported.
GPU instancing supported: 1
Max batch size: 1024
Shader model 4.0 supported: 1
Conditional render supported: 0
Loading shader "zip::c:/leadwerks engine sdk/shaders.pak//query.vert", ""...
Loading model "c:/users/bill/documents/projects/leadwerks/tutorials/spectator/making_a_spectator_files/scene.gmf"...
Loading mesh "c:/users/bill/documents/projects/leadwerks/tutorials/spectator/making_a_spectator_files/scene.gmf"...
Loading material "c:/users/bill/documents/projects/leadwerks/tutorials/spectator/making_a_spectator_files/concrete_floor01.mat"...
Loading texture "c:/users/bill/documents/projects/leadwerks/tutorials/spectator/making_a_spectator_files/concrete_floor01.dds"...
Loading texture "c:/users/bill/documents/projects/leadwerks/tutorials/spectator/making_a_spectator_files/concrete_floor01dot3.dds"...
Loading shader "zip::c:/leadwerks engine sdk/shaders.pak//mesh/mesh_diffuse_bumpmap.vert", "zip::c:/leadwerks engine sdk/shaders.pak//mesh/mesh_diffuse_bumpmap.frag"...
Loading material "c:/users/bill/documents/projects/leadwerks/tutorials/spectator/making_a_spectator_files/brickwall06.mat"...
Loading texture "c:/users/bill/documents/projects/leadwerks/tutorials/spectator/making_a_spectator_files/brickwall06.dds"...
Loading texture "c:/users/bill/documents/projects/leadwerks/tutorials/spectator/making_a_spectator_files/brickwall06dot3.dds"...
Loading model "c:/users/bill/documents/projects/leadwerks/tutorials/spectator/making_a_spectator_files/oildrum.gmf"...
Loading mesh "c:/users/bill/documents/projects/leadwerks/tutorials/spectator/making_a_spectator_files/oildrum.gmf"...
Loading material "c:/users/bill/documents/projects/leadwerks/tutorials/spectator/making_a_spectator_files/oildrum.mat"...
Loading texture "c:/users/bill/documents/projects/leadwerks/tutorials/spectator/making_a_spectator_files/oildrum.dds"...
Loading texture "c:/users/bill/documents/projects/leadwerks/tutorials/spectator/making_a_spectator_files/oildrumdot3.dds"...
Loading shader "zip::c:/leadwerks engine sdk/shaders.pak//mesh/mesh_diffuse_bumpmap.vert", "zip::c:/leadwerks engine sdk/shaders.pak//mesh/mesh_diffuse_bumpmap_specular.frag"...
Loading mesh "c:/users/bill/documents/projects/leadwerks/tutorials/spectator/making_a_spectator_files/oildrumlod1.gmf"...
Loading mesh "c:/users/bill/documents/projects/leadwerks/tutorials/spectator/making_a_spectator_files/oildrumlod2.gmf"...
Loading shader "zip::c:/leadwerks engine sdk/shaders.pak//mesh/mesh_shadow.vert", ""...
Loading shader "zip::c:/leadwerks engine sdk/shaders.pak//postfilters/postfilter.vert", "zip::c:/leadwerks engine sdk/shaders.pak//postfilters/depthblit.frag"...
Loading texture "incbin::noise.dds"...
Loading shader "zip::c:/leadwerks engine sdk/shaders.pak//postfilters/postfilter.vert", "zip::c:/leadwerks engine sdk/shaders.pak//lighting/directionallight.frag"...
Terminate function
Press any key to continue . . .
[/Code]

 

If I have time this evening, I'll try the following:

-Retrieve my Leadwerks 2.28 engine backup and test that

-Download VS2008 C++ (my real motivation here!)

-Verify there is not an issue with my C# code for copying entities (I don't believe so as it works in 2.40)

Link to comment
Share on other sites

I am probably going to update to 2.3

It looks a bit easier and i saw some updates in the sandbox editor which looks pretty cool.

 

So i am going to continue reading the wiki for commands, just trying to learn the basics. And hopefully i can start and create something very basic when i have 2.3

 

Anyway, thanks for the help guys. If i expierence the same problem in 2.3 (which won't happen, i guess) i'll post it over here.

 

Cheers,

Darryl

Link to comment
Share on other sites

Just for closure, I had Leadwerks 2.25, 2.26, and 2.27 on my backup drive from my old PC.

 

2.2.5 is the only one which ran ZioRed's post and the Spectator tutorial 100% (all in C#) besides 2.40.

 

The other versions had the issue I mentioned. I don't have 2.24 (or earlier?) and won't download it as it's meaningless to do so.

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...