Cocos2D and PowerVR .POD files. Profit :)

Forums Programming cocos2d support (graphics engine) Cocos2D and PowerVR .POD files. Profit :)

This topic contains 13 replies, has 8 voices, and was last updated by  just.danne 3 years, 10 months ago.

Viewing 14 posts - 1 through 14 (of 14 total)
Author Posts
Author Posts
March 16, 2010 at 3:28 pm #220444

skeeet
@skeeet

Hi everyone. I saw many posts on forum about using 3D objects with Cococs2d.

here is ready to run implementation.

I’ll be glad to start it as project on google code or add to Cococs2d repo. It needs more work for now, but have potential :)

Screenshot:

Demo project:http://www.munkyinteractive.com/stuff/PodLoad.zip

Hope to hear any comments and improvements related to this code.

Thanks.

March 16, 2010 at 4:01 pm #276744

yarri
@yarri

Hi, nice work! Why not add a method to update the object matrix so you can have cocos2d control the rotation, position, alpha, etc.

And some pointers for you –

Wolfgang Engel has extended the IT PowerVR POD libraries to create a C++ engine with dynamic lighting, shadows, 3D particle systems and 3D physics (Bullet); you might be able to leverage some of this code:

http://oolongengine.com/

Erwin Coumans is working on GameKit which supports iPhone, some of his blender object parsing might be helpful for you:

http://code.google.com/p/gamekit/

And there’s also SIO2…

–yarri

March 16, 2010 at 5:12 pm #276745

skeeet
@skeeet

Well idea is to build 2d game, but use 3d object for… maybe character, whatever.

And i know about oolongengine. It is just refactored PoverVR SDK and some libs i don’t need.

March 16, 2010 at 5:23 pm #276746

mhussa
@mhussa

Just took a quick look at this. Very cool. It would be a fantastic feature to be able to integrate 3d models so easily.

So long as it stays within the context of 2D, e.g fitting 3D models into 2D environments rather than trying to turn cocos2d into a 3D engine.

If the Z rotation was all that was needed then using the cocos2d rotation angle would make sense but that would really cripple the use of a 3d node such as this.

Its a testament to the excellent design of the framework that it can be integrated like this.

Thankyou for the contribution skeeet.

March 16, 2010 at 5:25 pm #276747

jd
Participant
@jd

I took a quick look at the code. Looks very simple to use. How is performance? I think a useful thing to do would be to take one of riq’s sprite performance tests and run the same amount of images and compare. Let me know when you think it’s ready/stable and I’ll try it out if you don’t want to do it.

Edit: Looks like mhussa and I are on the same page :P

March 16, 2010 at 5:44 pm #276748

skeeet
@skeeet

About perfomance.

It needs CC3DNodeManager or something like that to be implemented. So we can keep all vertex data in one place and then put instances (Just like CCtexturecache and texture2d does).

Also i cannot figure out some issues (like sprites always overlapping 3d object).

And making animations with 3d objects can be cheaper than creating big spritesheet.

March 17, 2010 at 7:00 pm #276749

mhussa
@mhussa

@skeeet: The reason the CCNode Z ordering isn’t working the way you expect is because the depth buffer is handling the z. The cocosnode z is different. Disable the depth buffer and you’ll see that the cocosnode Z works as you’d expect you can put a sprite over a model.

The problem with doing that then is that the model itself isn’t depth sorted so it looks wrong as it spins around.

Its strange that the model depth sorts correctly against a CCLabel but not a CCSprite.

March 17, 2010 at 11:00 pm #276750

skeeet
@skeeet

Well i solved that already and now i can control if my 3d object is above or below cocos layers. Now need to solve thing like on screenshot.

Part of model are dismissed by depth test. I cannot disable it, because then model will be rendered crappy. My only idea for now is to render to offscreen buffer and then apply like normal sprite.

Ideas anyone?:)

March 18, 2010 at 3:42 pm #276751

PhilM
Participant
@philm

Looks great already! Looking to make use of some 3d elements in a few months time, between this & yarri’s & others examples in another thread, it sounds like its more than possible. Will be keeping a close eye on how this progresses. Very interesting stuff, thanks for posting!

March 18, 2010 at 4:16 pm #276752

riq
Keymaster
@admin

@skeet: take a look at this thread:

http://www.cocos2d-iphone.org/forum/topic/4348

in particular when we discuss glAlphaFunc almost at the end of the discussion.

March 18, 2010 at 4:39 pm #276753

skeeet
@skeeet

@riq

well my current solution is like:

glColorMask(TRUE, FALSE, FALSE, TRUE);
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColorMask(TRUE, TRUE, TRUE, TRUE);
[self renderModel];
glColorMask(TRUE, TRUE, TRUE, FALSE);

Something like fake stencil or so.

Also tried to use CCRenderTexture. It doesn’t require such masking stuff, and works ok, but having issue with normals (all inverted). No idea why.

Offtop: What you think, should i post it to google-code?

March 18, 2010 at 6:54 pm #276754

riq
Keymaster
@admin

@skeet: Although I wanted to have 3d sprites in cocos2d, I’m not so sure that I would like to have them included in trunk, or at least not in the near future.

3d sprites might be useful in some games (eg: Rolando2 and Bounce On 2 use 3d sprites and they are 2d games) but before adding them I would like to understand the use cases and all the implications that it might have.

In the meantime I suggest the following:

- host the 3D sprite classes somewhere (your server, or you could also upload the patch to the issue tracker)

- and add a link in Tip & Tricks (http://www.cocos2d-iphone.org/wiki/doku.php/tips) explaining how to use it.

March 18, 2010 at 9:04 pm #276755

slycrel
Participant
@slycrel

@skeeet,

I’d love to follow this, please let us know where you host the code (assuming you make it available).

May 28, 2010 at 3:18 pm #276756

just.danne
@justdanne

@skeeet

How do you control 3D objects to be displayed over or beneath CCNodes?

I am drawing simple 3D cubes from verticies but i can’t get any cocos2d stuff to be displayed over the 3D cubes.

/Danne

Viewing 14 posts - 1 through 14 (of 14 total)

You must be logged in to reply to this topic.