I test this simple 3D code:
// Animation Demo
// Start: Friday, March 22, 2002
SYSTEMPOINTER TRUE
SETSCREEN 480,320,TRUE
SMOOTHSHADING TRUE
TYPE tMouse
x%
y%
active%
ENDTYPE
// Array to hold mice
GLOBAL mouse[] AS tMouse
DIM mouse[5]
X_LOADOBJ "media/1.ddd", 1
LOADSPRITE "media/player01.jpg", 1
WHILE TRUE
updateMice()
IF mouse[0].active THEN phi=phi+GETTIMER()/100
// IF KEY(208) THEN MOVE = MOVE - 10
X_MAKE3D 1, 1000, 45
X_CAMERA 0, 0, -250 + MOVE, 0, 0, 0
X_SPOT_LT 0, RGB(255,255,255), 0,50,100,0,10,100,180
//phi=phi+GETTIMER()/100
permil=permil+GETTIMER()/20000; IF permil>=1 THEN permil=0
X_ROTATION 180, 1,0,0
X_ROTATION phi, 0,-1,0
X_SETTEXTURE 1,-1
X_DRAWANIM 1, 0, 128, permil, TRUE
GOSUB ShowFPS
PRINT "MOVE" + MOVE,0,20
SHOWSCREEN
WEND
// ------------------------------------------------------------- //
// -=# SHOWFPS #=-
// ------------------------------------------------------------- //
SUB ShowFPS:
X_MAKE2D
dtime=GETTIMER()
fps = ((1000/dtime)+fps)/2
delay=delay+dtime
IF delay>1000 // 1/2 sec
delay=0
fps_draw=fps
ENDIF
PRINT "FPS: "+fps_draw+"px:" + ply_x + " py:" + ply_y + " d:" + ply_dir, 0 ,0
ENDSUB // SHOWFPS
FUNCTION updateMice:
FOR imouse% = 0 TO GETMOUSECOUNT()-1
SETACTIVEMOUSE imouse%
MOUSESTATE mx%, my%, b1%, b2%
mouse[imouse].x=mx
mouse[imouse].y=my
mouse[imouse].active=b1
NEXT
ENDFUNCTION
I export the 3D model from 3D studio max to 3ds ... and i convert the 3ds (whit tool) in .ddd model
In Windows mode the code work fine, but in iphone runtime the model not show in screen ...
Detail model:
3d model polys -> 700
texture format -> jpg - 128x128
Help!
Could be a DDD issue because ARM architecture. Wait for Kitty, he will check it.
I test sample cube ... (whit texture .png and whitout texture ) but the result is the black screen ....
Make sure that your media paths/filenames have the same case on the iPhone as in your code. The windows version would work fine as it is not case sensitive, the iPhone would not.
Check if DOESFILEEXIST also! Also you may discover 3DS files exported from 3D Studio Max give errors on the iPhone, but not when exported as OBJ for DDD conversion. ;)
I export 3ds and convert in DDD .... Export in Obj Format????
How many polys limit ????
Texture size????
Yes. Select the object and "Export selected...".
Any more than 24bit 512x512 png is really not needed for the iPhone.
Test experiment with low to high poly count model versus frame rate.
What is your 3D model of and have you got it running on the iPhone?
I create a simple plane in 3ds max ... I use diffuse Map (from Material Editor of 3Dsmax) and I texture whit 64x64 png 16 bit image.
I export the plane in 3ds format and i convert it in ddd format (I check 1 frame)
The path in xcode project (for the model "Media\plane.ddd" - for the texture "Media\texture01.png") is the same in my code (Case sensitive).
But when i test in my iphone the Application, it start and after 3 sec. the application exit...
I surrender .. not work ...
any question.
I use this code for polyvector
FUNCTION box:x%,y%,width%,height%,c1%,c2%,c3%,c4%
STARTPOLY 500
POLYVECTOR width%,y%,0,0,c1%
POLYVECTOR x%,y%,0,0,c2%
POLYVECTOR x%,height%,0,0,c3%
POLYVECTOR width%,height%,0,0,c4%
ENDPOLY
ENDFUNCTION
how to implement a texture for each polyvector?
------------------------------------
Resolved ..... :good:
STARTPOLY picture_id
Upper left: 0,0
Lower left: 0,1
Lower right: 1,1
upper right: 1,0
Export it as .OBJ (with texture coords) from 3ds Max and it won't crash on the iPhone.
Quote from: matchy on 2010-Feb-15
Export it as .OBJ (with texture coords) from 3ds Max and it won't crash on the iPhone.
thanks I'll try tomorrow :good:
another question
I did a test using polyvector.
I use a TYPE to create multiple sprites on the screen.
I use one sprite 115x63 png 24 bit (whit trasparency) but the result has been slow.
- with 10 Polyvector sprite -> 28 frames
- between 10 and 20 Polyvector sprite -> 23 frames
- over 20 Polyvector sprite -> 18 frames
Whit multiple parrallax (3 Polyvector) whit scroll texture ->30 frame
Whit multiple parrallax (3 Polyvector) whit scroll texture and 1 Polyvector sprite ->24 frame
Whit multiple parrallax (3 Polyvector) whit scroll texture and 5 Polyvector sprite ->20 frame
Whit multiple parrallax (3 Polyvector) whit scroll texture and 10 Polyvector sprite ->17 frame
The polys parallax dimension: Width 480 - Height 320 (and also the texture)
I use this code to handle the parallax:
TYPE tsfondo
x%
y%
r
g
b
active%
ENDTYPE
GLOBAL sfondo[] AS tsfondo
DIM sfondo[3]
I use this code to handle the polyvector sprite:
TYPE tpolys
x%
y%
r
g
b
active%
ruota
pivot
ENDTYPE
GLOBAL polys[] AS tpolys
DIM polys[101]
Update the parallax
PukeSprite(200,200, 0, 0, 0,240, 160, 0,0,1,255,255,255,0,0)
PukeSprite(201,201, 0, 0, 0,240, 160, 0,0,1,255,255,255,scrolltext,0)
PukeSprite(202,202, 0, 0, 0,240, 160, 0,0,1,255,255,255,scrolltext1,0)
Update Polyvector sprite:
FOR i=1 TO max_sprite
polys[i].ruota = polys[i].ruota + 1
IF polys[i].ruota >= 360 THEN polys[i].ruota = 0
PukeSprite(0,0, 0, 0, polys[i].ruota, polys[i].x, polys[i].y,0,polys[i].pivot,1,polys[i].r,polys[i].g,polys[i].b,0,0)
NEXT
The function for update parallax and polyvector sprite:
//img1 - number sprite or parallax
//img2 - disable
//rotx - rotate the sprite X
//roty - rotate the sprite y
//rozx - rotate the sprite z
//x - move in x position on the screen
//y - move in y position on the screen
//piv_x - move the pivot in x position on the polyvector to change rotation
//piv_y - move the pivot in y position on the polyvector to change rotation
// scalex - scale the polivector size (zoom effect)
//r - red color
//g - green color
//b- blue color
// scrolltx - scroll the texture in xpos
// scrollty - scroll the texture in ypos
FUNCTION PukeSprite: img1, img2, rotX, rotY, rotZ, x,y, piv_x,piv_y,scalex,r,g,b,scrolltx,scrollty
LOCAL w, h, phi, swap, tx, ty
LOCAL s, c, cl, px, py
GETSPRITESIZE img1, w,h
tx=w
ty=h
phi = MOD(ABS(rotY), 360)
IF phi < 90 OR phi>270
swap = img1
img1=img2
img2=swap
ENDIF
w = w * COS(phi)
phi = MOD(ABS(rotX), 360)
IF phi < 90 OR phi>270
swap = img1
img1=img2
img2=swap
ENDIF
h = h * COS(phi)
s=SIN(rotZ)
c=COS(rotZ)
w=(w/2) *scalex
h=(h/2) *scalex
cl=RGB(255,255,255)
STARTPOLY img1
px=-w-piv_y; py=-h-piv_x; POLYVECTOR x+px*c+py*s, y-px*s+py*c, 0+scrolltx, 0+scrollty,RGB(r,g,b)
px=-w-piv_y; py= h-piv_x; POLYVECTOR x+px*c+py*s, y-px*s+py*c, 0+scrolltx,ty+scrollty,RGB(r,g,b)
px= w-piv_y; py= h-piv_x; POLYVECTOR x+px*c+py*s, y-px*s+py*c, tx+scrolltx,ty+scrollty,RGB(r,g,b)
px= w-piv_y; py=-h-piv_x; POLYVECTOR x+px*c+py*s, y-px*s+py*c, tx+scrolltx, 0+scrollty,RGB(r,g,b)
// and back for back face culling
//px= w-piv_y; py= h-piv_x; POLYVECTOR x+px*c+py*s, y-px*s+py*c, tx,ty,RGB(r,g,b)
//px=-w-piv_y; py= h-piv_x; POLYVECTOR x+px*c+py*s, y-px*s+py*c, 0,ty,RGB(r,g,b)
//px=-w-piv_y; py=-h-piv_x; POLYVECTOR x+px*c+py*s, y-px*s+py*c, 0, 0,RGB(r,g,b)
ENDPOLY
ENDFUNCTION
can speed up the code????
It's possible to create shoot'm'up with glbasic for iPhone?
First, the fill rate of the iPhone is not very decent.
If you try to fill the screen twice with pixels (simple drawrect) you will start to get to the end of the possible.
Second, the number of glDrawArrays is limted. If you call many STARTPOLY, it will be slower than trying to get one big batch of POLYVECTOR. See the new triangel strips and the POLY_NEW_STRIP command (or so...)
Thirs, you use SIN/COS a lot in your code. Try to store these values once in an "update sprite" function. Also, don't call RGB function all the time. Store the result in an integer variable before using it.
HTH.
another question
I use 32x32 image size
if i use :
GETSPRITESIZE img1, w,h
the POLYVECTOR work fine
if i use:
w= 32
h=32
the POLYVECTOR not draw..
Paste a sample code?
it's possible to use the multitexturing for POLYSPRITES?
it's possible to use a type of alpha for each POLYNEWSTRIP?
The alpha can be changed with the ALPHAMODE just before the POLYNEWSTRIP. I've not tested it, but that's the way I would expect it.
Multitexturing is not possible. What are you trying to do?
Quote from: Kitty Hello on 2010-Feb-18
The alpha can be changed with the ALPHAMODE just before the POLYNEWSTRIP. I've not tested it, but that's the way I would expect it.
Multitexturing is not possible. What are you trying to do?
if i use :
STARTPOLY 0,2
ALPHAMODE -0.8
LOCAL c%=RGB(255,255,255)
POLYVECTOR 0, 0, 0,0,c
POLYVECTOR 0,40, 0,0,c
POLYVECTOR 40,20, 0,0,c
POLYVECTOR 40,40, 0,0,c
POLYNEWSTRIP
ALPHAMODE 0
// same at 100,100
POLYVECTOR 100,100, 0,0,c
POLYVECTOR 100,140, 0,0,c
POLYVECTOR 140,120, 0,0,c
POLYVECTOR 140,140, 0,0,c
ENDPOLY
SHOWSCREEN
MOUSEWAIT
the polysprite use only the last call to alpha (ALPHAMODE 0) but not the first call (ALPHAMODE -0.8 )
if I use :
STARTPOLY 0,2
ALPHAMODE 0
LOCAL c%=RGB(255,255,255)
POLYVECTOR 0, 0, 0,0,c
POLYVECTOR 0,40, 0,0,c
POLYVECTOR 40,20, 0,0,c
POLYVECTOR 40,40, 0,0,c
POLYNEWSTRIP
ALPHAMODE -0.8
// same at 100,100
POLYVECTOR 100,100, 0,0,c
POLYVECTOR 100,140, 0,0,c
POLYVECTOR 140,120, 0,0,c
POLYVECTOR 140,140, 0,0,c
ENDPOLY
SHOWSCREEN
MOUSEWAIT
the polysprite use only the last call to alpha (ALPHAMODE -0.8 ) but not the first call (ALPHAMODE 0)
I use The multitexture for create many polys whit more texture using a single call to STARTPOLY and more POLYNEWSTRIP.
Slow answer but "media/" in your path should read "Media/"
Quote from: bigsofty on 2010-Feb-19
Slow answer but "media/" in your path should read "Media/"
Yes the path is Media :good:
before starting to make a my game I did test with sprites not mine.
My game use
- 2 textures (single texture: 800 x 800 px ) for the player (ready stance - walk forward - walk back - jump ecc.)
- 1 texture for the hud, the shadow under the characters ecc (300 X 300 - px)
- 1 texture for the stage only one parallax (no multiparallax) (500 X 400 - px)
I make four calls at STARTPOLY .... :rant: (slow code ...)
1 Type:
TYPE tanim
img%
x%
y%
active%
cl%
scalex%
box_col_x% // Box X for collision - player hit
box_col_y% // Box y for collision - player hit
box_col_h% // Box h for collision - player hit
box_col_w%// Box w for collision - player hit
box_atk_x% // Box X for collision - player attack
box_atk_y% // Box y for collision - player attack
box_atk_h% // Box h for collision - player attack
box_atk_w%// Box w for collision - player attack
tx% // UV X Texture
ty% // UV Y Texture
txf%// UV W Texture
tyf%// UV H Texture
ENDTYPE
GLOBAL anim[] AS tanim
DIM anim[2][20][20] // [1] 0,1 player 1 e 2 // [20] num max of animation // [30] num max of frame for single animation
My game run at 20 FPS on iPhone .... :'(
If I could change the texture after the call STARPOLY would be fantastic!
Example:
loadsprite "Media/bla0.png",1
loadsprite "Media/bla1.png",2
loadsprite "Media/bla2.png",3
STARTPOLY 1,2 // apply the texture 1
LOCAL c%=RGB(255,255,255)
POLYVECTOR 0, 0, 0,0,c
POLYVECTOR 0,40, 0,40,c
POLYVECTOR 40,20, 40,0,c
POLYVECTOR 40,40, 40,40,c
POLYNEWSTRIP 2 // apply the texture 2
POLYVECTOR 0, 0, 0,0,c
POLYVECTOR 0,40, 0,40,c
POLYVECTOR 40,20, 40,0,c
POLYVECTOR 40,40, 40,40,c
POLYNEWSTRIP 3 // apply the texture 3
POLYVECTOR 0, 0, 0,0,c
POLYVECTOR 0,40, 0,40,c
POLYVECTOR 40,20, 40,0,c
POLYVECTOR 40,40, 40,40,c
ENDPOLY
Now I'm looking for another solution.
This is a screenshot of my test game:
(http://img99.imageshack.us/img99/7982/gameay.jpg)
Changing textures costs performance. No way to implement that in the new vertex group. I would have to startpoly/endpoly anyway.
Your sprites are big. The fill rate of the iPhone is very limited. I try if I can change the internal texture format to something better, but don't expect too much speed boost.
Quote from: Kitty Hello on 2010-Feb-20
Changing textures costs performance. No way to implement that in the new vertex group. I would have to startpoly/endpoly anyway.
Your sprites are big. The fill rate of the iPhone is very limited. I try if I can change the internal texture format to something better, but don't expect too much speed boost.
thanks for the info. I'll try to do anything.... :good: