Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Announcements and Showcase
.obj file loader script

sven
Registered User
Quote
2023-04-29 13:41:19

Download:
https://5v3n.itch.io/coppercube-...

It has no big use but i need it for my room editor so i made it (it will have more usage than just preview created room)

EDIT -fixed: [It has some issues -object loaded is flipped ( and i cant figure out what to do to prevent this -if you know let me know )]

Current version works with object with one texture.


Guest
Guest
Quote
2023-04-29 14:19:05

@sven thanks for sharing, this is very innovative

Maybe you could also put the code into a simple custom obj importer plugin which later could be developed further allowing for things like e.g. random object batch import from specified folder, etc.


just_in_case
Moderator
Quote
2023-04-29 14:26:36

Nice one, @sven, if you want I can add an API command that will allow you to load external models. That will be not limited to .obj format only, you probably will be able to load many of the formats that CopperCube already supports. I actually have this in my learning version of CC source, in which I first test the commands and learn how to use them or utilize them. It won't take that much effort to push this into my work environment.


sven
Registered User
Quote
2023-04-29 14:45:26

Thanks, Loading an external 3D model by script into game would be very useful.


just_in_case
Moderator
Quote
2023-04-29 15:05:20

Yeah, and also you won't require additional empty nodes or existing nodes for modifying the vertex and adding mesh buffer, also, with the command for collision, it will also be possible to have collision for the loaded model as well. right now with your action, there is no collision, even if you turn the collision on for the empties. So, in the next version, you will be able to have collision for your obj loader as well.


andgameplay
Registered User
Quote
2023-04-29 20:01:04

Good sven, thanks to share with us!


okeoke
Registered User
Quote
2023-04-30 09:50:00

Hi Sven,
Thank you for sharing this - it's very useful.

It's seems to me that mirror thing happens because coppercube uses left-handed coordinate system and according to wikipedia obj format uses right-handed. So either z or x axis should be flipped - not sure which one.


okeoke
Registered User
Quote
2023-04-30 09:53:51

But it seems like you're already doing that...


sven
Registered User
Quote
2023-04-30 10:53:53

Thanks..
I think i got it to work now..
I was focused on wrong part of code thats why nothing did work and got another issue if first was fixed :D


//In editor i set it 0,0,0 and make it in script now ( doesnt matter actually where but its simpler this way (for me)
ccbSetSceneNodeProperty(this.DummyNode, "Scale", new vector3d(-1,1,1) );
//Here i changed ORDER for face .instead of 1-2-3 to 1-3-2
IND+=1;
AddVNT(this.DummyNode, 0, IND, v_list[parseInt(face1[0])], vn_list[parseInt(face1[2])], vt_list[parseInt(face1[1])] );
IND+=1;
AddVNT(this.DummyNode, 0, IND, v_list[parseInt(face3[0])], vn_list[parseInt(face3[2])], vt_list[parseInt(face3[1])] );
IND+=1;
AddVNT(this.DummyNode, 0, IND, v_list[parseInt(face2[0])], vn_list[parseInt(face2[2])], vt_list[parseInt(face2[1])] );


Now i try to add support for multiple textures so grouped triangles will have different buffer and texture if set.


sven
Registered User
Quote
2023-04-30 18:02:08

Now it supports .obj with multiple textures.
There is 2 files to download so newest is v3svcOBJ_loader.zip


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internati?nal" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact