How is it ridiculous?
Fine, just a simple 3D tut.
Printable View
How is it ridiculous?
Fine, just a simple 3D tut.
That's still pretty ridiculous.
There's much, much more to a 3D engine than just graphics. And I don't see much chance of calculus being done properly in Lua, so the likelihood of physics being at all accurate is pretty low.
Yea but you could still make a 3D tutorial.
All I want it to be able to do is walk around.
here is what i have read now i would only like a simple explanation for each please as i dont know what each one specifically does or in which order they are meant to be placed when being used but first of all it would help if i knew what they meant
thanks
Zitat:
3D GU mapping
Gu.start3d(), Gu.clearColor, Gu.clearDepth, Gu.clear, Gum.matrixMode, Gum.loadIdentity, Gum.perspective, Gum.translate, Gum.rotateXYZ, Gu.texImage, Gu.texFunc, Gu.texEnvColor, Gu.texFilter, Gu.texScale, Gu.texOffset, Gu.ambientColor, Gu.enable, Gu.disable, Gu.blendFunc, Gu.light, Gu.lightAtt, Gu.lightColor, Gu.lightMode, Gu.lightSpot and Gum.drawArray.
I am not sure but cant you get an idea of what they do by looking at the LuaPLayer source?
This is a really basic question, but how would I go about having an image blitted to the screen upon the pressing of a button? I don't want it to be showing only when pressing the button, however, for I can do that fine. Basically, I want an image to appear when a button is pressed, but not go away. This is still a problem I've yet to figure out....
Code:showimg = false
img = Image.load("someimg.png")
while true do
pad = Controls.read()
screen:clear()
if pad:cross() then showimg = true end
if showimg then screen:blit(0,0,img) end
screen.waitVblankStart()
screen.flip()
end
Thanks- I knew it would be a simple solution. Actually, I thought I tried something like that... obviously not!
Another question.... what I am trying to do is blit the same image in many different spots on the screen based on where the "cursor" is at that moment. How would you recommend doing that? Could I save the current (when the button is pressed) coordinates of the "cursor" into an unchanging variable? Because right now the blitted image is moving with the "cursor." Thanks for any help!
Code:locations = {}
function addLocation(x,y)
table.insert(locations,{x=x,y=y})
end
while true do
pad = Controls.read()
screen:clear()
if pad:cross() then addLocation(cursorx,cursory) end
for i = 1, table.getn(locations) do
screen:blit(locations[i].x,locations[i].y,img)
end
screen.waitVblankStart()
screen.flip()
end
Zitat:
Zitat von FaT3oYCG
Have a look at the 3D cube example that comes with Lua. It's pretty much direct PSPgl commands.
I also remember a tut from a while back, I'll see if I can find it.
EDIT: Found it (From the GDI)
Awesome thanks!
thanks i will do it in 3d then, i hope your all looking forward to it i am lolZitat:
Zitat von Nielkie
wow i didn't realize that 3d was so easy i thought it would be much harder i spent some time messing around with the different functions e.g. views rotation zoom and things like that and it is pretty simple i think that i should have a poc out for ut lua very soon
thanks
Ah, I see. Thanks a lot. I figured it would have to do with using tables- that's definitely one thing I need to learn more about.Zitat:
Zitat von TuxThePenguin
hey andy use this link for some good tuts on tables and how they work it also shows the two different methods of using tables http://www.evilmana.com/tutorials/lua_tutorial_05.phpZitat:
Zitat von andyauff
Funny I couldn't get the script I put together to work it kept giving me a Wrong number of vertexes or something like that error.Zitat:
Zitat von FaT3oYCG
hmm first off i modified the 3d cube example to understand what each function did
here is my modified code
now for my question i am reading a file and i have the string how would i say read from a certain point in that string until another point say 5 letters in a 20 letter sentence thanks EDIT: nvm i found out how to do it i used string.sub(string, start, finish) thanks ne wayCode:red = Color.new(255, 0, 0)
green = Color.new(0, 255, 0)
blue = Color.new(0, 0, 255)
black = Color.new(0, 0, 0)
white = Color.new(255, 255, 255)
gray = Color.new(128, 128, 128)
cyan = Color.new(100, 255, 255)
sqre = 0
trng = 0
lr = 0
logo = Image.createEmpty(64, 64)
logo:clear(gray)
logo:print(20, 20, "Lua", black)
logo:print(10, 40, "Player", black)
cube = {
{0, 0, red, -1, -1, 1}, -- 0
{2, 0, red, -1, 1, 1}, -- 4
{2, 2, red, 1, 1, 1}, -- 5
{0, 0, red, -1, -1, 1}, -- 0
{2, 2, red, 1, 1, 1}, -- 5
{0, 2, red, 1, -1, 1}, -- 1
{0, 0, red, -1, -1, -1}, -- 3
{2, 0, red, 1, -1, -1}, -- 2
{2, 2, red, 1, 1, -1}, -- 6
{0, 0, red, -1, -1, -1}, -- 3
{2, 2, red, 1, 1, -1}, -- 6
{0, 2, red, -1, 1, -1}, -- 7
{0, 0, green, 1, -1, -1}, -- 0
{2, 0, green, 1, -1, 1}, -- 3
{2, 2, green, 1, 1, 1}, -- 7
{0, 0, green, 1, -1, -1}, -- 0
{2, 2, green, 1, 1, 1}, -- 7
{0, 2, green, 1, 1, -1}, -- 4
{0, 0, green, -1, -1, -1}, -- 0
{2, 0, green, -1, 1, -1}, -- 3
{2, 2, green, -1, 1, 1}, -- 7
{0, 0, green, -1, -1, -1}, -- 0
{2, 2, green, -1, 1, 1}, -- 7
{0, 2, green, -1, -1, 1}, -- 4
{0, 0, blue, -1, 1, -1}, -- 0
{2, 0, blue, 1, 1, -1}, -- 1
{2, 2, blue, 1, 1, 1}, -- 2
{0, 0, blue, -1, 1, -1}, -- 0
{2, 2, blue, 1, 1, 1}, -- 2
{0, 2, blue, -1, 1, 1}, -- 3
{0, 0, blue, -1, -1, -1}, -- 4
{2, 0, blue, -1, -1, 1}, -- 7
{2, 2, blue, 1, -1, 1}, -- 6
{0, 0, blue, -1, -1, -1}, -- 4
{2, 2, blue, 1, -1, 1}, -- 6
{0, 2, blue, 1, -1, -1}, -- 5
}
plane = {
{blue, -8, -3, 0},
{cyan, 8, 3, 0},
{blue, 8, -3, 0},
{cyan, 8, 3, 0},
{blue, -8, -3, 0},
{cyan, -8, 3, 0},
}
while true do
Gu.start3d()
-- clear screen
Gu.clearDepth(0);
Gu.clear(Gu.COLOR_BUFFER_BIT+Gu.DEPTH_BUFFER_BIT)
-- setup projection and view matrices
Gum.matrixMode(Gu.PROJECTION)
Gum.loadIdentity()
Gum.perspective(75, 16/9, 0.1, 4000)
Gum.matrixMode(Gu.VIEW)
Gum.loadIdentity()
-- setup matrix for triangle
Gum.matrixMode(Gu.MODEL)
Gum.loadIdentity()
Gum.translate(0, 0, -5);
-- draw triangle without texture
Gu.disable(Gu.TEXTURE_2D)
Gum.drawArray(Gu.TRIANGLES, Gu.COLOR_8888+Gu.VERTEX_32BITF+Gu.TRANSFORM_3D, plane)
-- setup texture
Gu.enable(Gu.BLEND)
Gu.blendFunc(Gu.ADD, Gu.SRC_ALPHA, Gu.ONE_MINUS_SRC_ALPHA, 0, 0)
Gu.enable(Gu.TEXTURE_2D);
Gu.texImage(logo)
Gu.texFunc(Gu.TFX_MODULATE, Gu.TCC_RGBA)
Gu.texEnvColor(white)
Gu.texFilter(Gu.LINEAR, Gu.LINEAR)
Gu.texScale(1, 1)
Gu.texOffset(0, 0)
Gu.ambientColor(white)
-- setup matrix for cube
Gum.matrixMode(Gu.MODEL)
Gum.loadIdentity()
Gum.translate(0, 0, -3);
Gum.rotateXYZ(sqre, trng, lr)
-- draw cube
Gum.drawArray(Gu.TRIANGLES, Gu.TEXTURE_32BITF+Gu.COLOR_8888+Gu.VERTEX_32BITF+Gu.TRANSFORM_3D, cube)
degr = (Gu.PI/180)
if Controls.read():square() then
sqre = sqre + (10 * degr)
end
if Controls.read():circle() then
sqre = sqre - (10 * degr)
end
if Controls.read():triangle() then
trng = trng + (10 * degr)
end
if Controls.read():cross() then
trng = trng - (10 * degr)
end
if Controls.read():l() then
lr = lr + (10 * degr)
end
if Controls.read():r() then
lr = lr - (10 * degr)
end
Gu.end3d()
if Controls.read():start() then
screen:clear()
break
end
screen.waitVblankStart()
screen.flip()
end
Yeah, those (the evilmana ones) are basically the only tutorials I have used (besides one tut for 3D). I need more in-depth explanations of the table functions such as table.getn and the use if "i". I'll be checking out lua.org and other good resources when I get a chance. Thanks for the consideration though, even if I have already gone through that tutorial! :)Zitat:
Zitat von FaT3oYCG
oh ok well the table.getn() command and such are easy to use you almost never need to use them unless you are creating a file browser which i can post an example of if you want and ill add in some comments explaining what each function does
That's okay, I think I understand, I just need to practice using them. Thanks.
ok no probs if you need help or get stuck you know where to come
Seriously? You think this is simple stuff?Zitat:
Zitat von hakk3r
You're making it pretty obvious that you've done little to no coding yourself...
You use table.getn in MANY more situations than a filebrowser. Wanna run through every entry of a table? Wanna find out how many of something you have? etc
table.getn returns the number of items in the given table.
For the whole i thing, look at the lua-users.org for loop tutorial.Code:table1 = {3,2,4,5,6,3,5}
print(table.getn(table1)) --will print 7
table2 = {{1,2,3},{4,5,6},{7,8,9}}
print(table.getn(table2)) --will print 3
Tables: http://lua-users.org/wiki/TablesTutorial
For loops: http://lua-users.org/wiki/ForTutorial
i didn't say that there weren't more uses i said you hardly ever need to do something like that except for in file browsers
By hardly ever, you were implying that filebrowsers were one of the very select few applications of table.getn when in fact filebrowsers are just one of several implementations of it. I use it in almost every program I make.
Same here.Zitat:
Zitat von TuxThePenguin
In a game, for example, it's easy to just chuck all objects in a table and loop through them to render them. That also makes it easy to construct levels and make a level editor.
I never said it would be simple. All I said was I want a tutorial. Also why aren't you flaming the guy who said:Zitat:
Zitat von FreePlay
DurrZitat:
Zitat von FaT3oYCG
FreePlay is ten times smarter than you'll ever be. Lua isn't the language (for PSP) to learn how to make a model with a high number of polygons walk around. Sure the cube sample is easy but that involves barely any physics.
hmm let me think i understand lua i havent just started learning it - i ask for places to learn, and try to fix my own mistakes if i dont have time or i cant fix it myself then i will post here before asking someone like freeplay for an example 3d world where i can walk arround - as that in its self would take a while to makeZitat:
Zitat von hakk3r
and as i do have previous experience i will find it easier to use the basic 3d commands and learn how to use the advanced ones so unless you are going to make a 3d game or something
shut up !!!!!
I was just saying that freeplay doesn't need to be such a jerk just because he knows more than us.
Okay, so I have used TuxThePenguin's advice for blitting multiple images using a cursor, and it works great. But now I need to be able to erase whichever one is underneath the cursor when another button is pressed. I have tried using the table.remove function, which works, but it needs a number for which entry to delete. I don't know which entries are which... I simply need to erase whichever one is underneath the cursor. Would there be a way to do something like that without too much stress?
You miss need to shut up.Zitat:
Zitat von FaT3oYCG
Your saying how 3d is soooo easy yet I bet you cant do any more than a cube example if that without looking at the already made one. Also, no you do not understand Lua.
Have you learned 3D? If not then how do you know its soo easy. If so then I'm sorry I asked.
I dont have much time right now to scribble up some code but here's what I can tell you you should be aiming at
-When button is pressed, start a for loop (for i = 1, table.getn(placedimgs) do)
-In that for loop, check if the mouse is over that image by comparing placedimgs[i].x and y and the cursor x and y and the width/height of placed image
if the cursor IS over that image then
table.remove(placedimngs, i)
break
end
I see. I will try that for sure. Thanks a lot.
Are you coding Lua or HTML?Zitat:
Zitat von FaT3oYCG
lua obv soz about that it is the way the forum put it,Zitat:
Zitat von Judas
its supposed to be
Zitat:
Zitat von FaT3oYCG
Is there a function to completely empty a table?
EDIT: Nevermind, I figured it out.
tablename = {}
lol
huh. :Argh:
lemme guess, you were doing something like
for i = 1, table.getn(table) do
table.remove(table,i)
end