Jump to content

tutorials


webhead
 Share

Recommended Posts

hello im new to this programming stuff ,can anyone point me in the direction of lots of basic tutorials for me to try please.

 

engine looks great,seems pretty easy but then im only mucking around at the moment , need to learn something so can you help thanks.

 

and hello to all..

Link to comment
Share on other sites

  • 2 weeks later...

Hey guys,

 

I think this is the right Thread so I dont have to create a new one ^^

 

I started on the lua tutorials here and stuck at the Lightning section. I wrote it exactly like it is in there but the script editor is giving me following error:

 

attempt to index global 'cube' (a nil value)

 

anyway, here is the code I have in the script editor:

-- Register the abstract path
RegisterAbstractPath("")

--Set a graphics mode
Graphics(800,600)

--Create a framework object

fw = CreateFramework()

--set the camera

camera = fw.main.camera
camera:SetPosition(Vec3(0,2,-10))

--Create a cube
cube: CreateCube() 
cube: SetPosition(Vec3(0,1,0)) 
cube: SetScale(Vec3(2,2,2))

--Create ground
cube:CreateCube()
cube:SetPosition(Vec3(0,-2,0))
cube:SetScale(Vec3(20,1,20))

--Create a light
light=CreateSpotLight(8)
light:SetPosition(Vec3(0,3,0))
DebugLights (1)


-- Create the main loop

while AppTerminate() == 0 

do

-- Rotate the cube every frame by 0.1 in every direction
cube:Turn(Vec3(0.1,0.1,0.1))

fw:Render()
fw:Render()

Flip(0)

end

Link to comment
Share on other sites

Hey guys,

 

got another problem with one of the lua tutorials, I went through the Camera Control tutorial and wrote the code in the script editor exactly like it is in the pdf. When I run the code now, the camera does rotate like crazy, but I dont know what the problem could be...

 

hope someone can help me here:

 

--Include the engine_const.lua file for keyboard input 
require("Scripts/constants/engine_const")

--registering the abstract path
RegisterAbstractPath("")

--Set a graphics mode
Graphics(800,600)

--Framework object 
fw = CreateFramework()

--Set camera 
camera = fw.main.camera 
camera:SetPosition(Vec3(0,1,-5))

--Create directionallight 
light1 = CreateDirectionalLight() 
light1:SetRotation(Vec3(45,45,0))

--Load a mesh 
scene = LoadMesh("abstract::scene.gmf")
if scene == nil then 
Notify("Failed to load scene.gmf") 
end

--Move the mouse to the center of the screen and hide it 
MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2) 
HideMouse(1) 
camrotation=Vec3(0)

--Main loop 
while KeyDown(KEY_ESCAPE)==0 do

--Camera rotation 
gx=Curve(MouseX() - GraphicsWidth() /2, 
gx, 10) gx=Curve(MouseX() - GraphicsWidth() /2, 
gx, 10) gy=Curve(MouseY() - GraphicsHeight() /2, gy, 10) 
camrotation.x = camrotation.x + gy / 10 
camrotation.y = camrotation.y - gx / 10 
camera:SetRotation(camrotation,1)

--Camera movement 
move = Curve(KeyDown(KEY_W) - KeyDown(KEY_S), move, 10) 
strafe = Curve(KeyDown(KEY_D) - KeyDown(KEY_A), strafe, 10) 
camera:Move(Vec3(move/10, 0, strafe/10))

fw:Update() 
fw:Render()

Flip(0)

end

Link to comment
Share on other sites

These lines look at bit wierd:

gx=Curve(MouseX() - GraphicsWidth() /2, 
gx, 10) gx=Curve(MouseX() - GraphicsWidth() /2, 
gx, 10) gy=Curve(MouseY() - GraphicsHeight() /2, gy, 10) 

It should be:

gx=Curve(MouseX() - GraphicsWidth ()/2, gx, 10)
gy=Curve(MouseY() - GraphicsHeight()/2, gy, 10)

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

try this:

require("Scripts/constants/engine_const")
require("Scripts/math/math")
RegisterAbstractPath("")
Graphics(800,600)
fw = CreateFramework()

fw.main.camera:SetPosition(Vec3(0,1,-5))

light1 = CreateDirectionalLight() 
light1:SetRotation(Vec3(45,45,0))

scene = LoadMesh("abstract::scene.gmf")

gx=Round(GraphicsWidth()/2)
gy=Round(GraphicsHeight()/2)
MoveMouse(gx,gy) 
camerapitch=fw.main.camera.rotation.x
camerayaw=fw.main.camera.rotation.y

HideMouse(1) 
while KeyDown(KEY_ESCAPE)==0 do
dx=Curve((MouseX()-gx)/4.0,dx,3.0/AppSpeed())
dy=Curve((MouseY()-gy)/4.0,dy,3.0/AppSpeed())
MoveMouse(gx,gy)
camerapitch=camerapitch+dy
camerayaw=camerayaw-dx
fw.main.camera:SetRotationf(camerapitch,camerayaw,0)

move = Curve(KeyDown(KEY_W) - KeyDown(KEY_S), move, 10) 
strafe = Curve(KeyDown(KEY_D) - KeyDown(KEY_A), strafe, 10) 
fw.main.camera:Move(Vec3(strafe/10, 0, move/10))

fw:Update() 
fw:Render()

Flip(1)
end

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

I think 3.0/AppSpeed() is wrong, because it will amplify lag differences, so slow things get slower, and fast things get faster when the FPS changes.

I should be: 3.0*AppSpeed(), or just plain 8.0.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

Actually by multiplying you are reducing the number of increments between the new value parameter and the old value parameter depending on if vsynch is turned on or not. With vsych on, i get roughly about 1 for AppSpeed. With it off, I get ~0.2. So with vsynch off, you get a choppy rotation which is why i used division so it would always be at least 3 increments. This might just be a poor place to use it but it was pulled from one of the SDK's inherent scripts.

 

Granted that could be resolved by simply just using a value that has nothing to do with AppSpeed. But as megatron said and according to the wiki, movement should be multiplied by appspeed but in this case it might make sense to have more increments at a higher frame rate.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

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