Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / looks like i have successfully decoded an obj file

Author
Message
SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 5th Jun 2014 23:36 Edited at: 2nd Jul 2014 16:54
Here is an object extractor from an obj file. Basicaly what this does is extract the mesh objects from within a single obj file and outputs multiple obj files.

1 thing it does not do is retain pivot points and original offset data. I have made a command to reset pivot points under this page if needed.

http://forum.thegamecreators.com/?m=forum_view&t=211339&b=41

ok now i have not fully tested the texturing aspect of this so please do and report any problems back. Also this program only works with 3 face triangles and does not work with quads. In blender there is a setting to select all your meshes to convert back to triangles if you where not drawing with them.

the program:
http://www.smotion3d.com/downloads/objectextractor.zip

screen shot:


-currently batch is not coded yet and one is not either.
-if requested i will get on it asap!

Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 6th Jun 2014 00:13
hmmm, i don't like this workaround, it waste your time only.

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265
SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 6th Jun 2014 05:30
ok well it is a possibility anyways....

looks like I only got it to work with only 1 format of obj... looks like each application can dump the data in different orders.

painful ! but I will code a fix for my drawing app anyways...

Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 6th Jun 2014 10:58
the only useful 3d formats i know are 3ds now fbx,open collada,direct x.
yes, its very nonsense that every application import&export files incorrect
or with loss of data. but the biggest nonsense are import&export settings^^

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 6th Jun 2014 11:21
I think it would be very useful in conjunction with a limb animation system. Like, if you could use pivot points, or even be able to set new pivot points for each limb, then save it all out, and have a file that AppGameKit loads, telling it which limbs are connected.

I think that would be incredibly useful, like a basic limb hierarchy that AppGameKit can handle with code. It might be stretching things a bit, but I can see that being a great help to people using 3D.

I am the one who knocks...
29 games
19
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 6th Jun 2014 17:08
Yes, I would definitely find something like this useful.

I'm currently working on a limb animation system:

http://forum.thegamecreators.com/?m=forum_view&t=210562&b=48

For the models, I'm currently making a "master" model in blender for the whole robot. I then break it up into individual bits, reposition the limbs to 0,0,0 and then export. It's a bit of a faff.

I'm also beginning to make maps and these also need to be split up so the textures can be applied, as you can't texture different limbs with different images. I'm also splitting the maps up to help with things like collision management and occlusion.

So, yes, anything to make this easier would help.

There are a few requests I'd like to make if you were going to do this:

1) I'd like the file names of the .obj's to match the limb names. That way I can set the file names up in blender and give them proper meaning.

2) The limbs should be repositioned to 0,0,0.

3) I'd like the converter to be very easy to use. There was a .3ds to .x converter that came with DBC and all you had to do was put the .3ds file in the same folder as the converter program, run the program and it would scan for all .3ds files and then convert them. That's really all I'm looking for. I don't really need anything with too much polish, just something that's fast and easy to use.

Even if you made a test program like this I'd use it.

SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 6th Jun 2014 20:32 Edited at: 6th Jun 2014 20:35
cool guys...

pivot points resort back to 0,0,0 by the looks of things. Do you know if blender can load an obj file and have the pivot points still correct for seperate objects? Also im confused on the obj file formats way of texturing uv... didn't know you could have values >1.0 but looks like obj files have them.

maybe you could post me an obj file that has pivot points listed so I can figure out grab them and reset the object with. Im yet to see one that has pivot points altered.

SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 10th Jun 2014 03:18 Edited at: 10th Jun 2014 05:40
ok so the first of new object commands...

i've set this up to mimic vertex data commands from darkbasic pro and also ian's matrix utils

(yes you can now make a new object from scratch using this in agk!)

new commands for agk:
-initialize_objectsinclude()..preps the array data for first usage
-makenewobject(vertexcount,indexcount)
-setvertexdataposition(vertex,x#,y#,z#)
-setvertexdatauv(vertex,u#,v#,w#)
-setvertexdatanormals(vertex,x#,y#,z#)
-setindexdata(index,vertex)
-savenewobject(object_number,filename$,flag1,flag2)

(the last command has the option of loading the new object in at the object_number specified)

include_file...


here is an example of its usage



questions... requests... let me know as im trying to add as much new 3d stuff as I can using code.

any raw shapes you would like to see as single commands...eg make triangle... ill add it in if ya wish

requests now open

SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 10th Jun 2014 08:03 Edited at: 10th Jun 2014 08:03
oh just a quick tutorial for those new to vertex data and forming index faces:

-It takes 3 vertex points in 3d space to set an index face triangle.
-An index is in order of 3's and defines the 3d faces as triangles
-each vertex point holds position values,normals ,and texture information.

-setting index data clockwise creates a face pointing outwards.
-setting index data counter clockwise draws a face pointing inwards.

to give an example of this... imagine you are looking at a character in your 3d world. You would be visualy seeing 3d faces pointing outwards. (clockwise)

now imagine you have a cube box and you moved the camera inside the box. If you only had outward facing triangles... you would not see the cube at all. If you made inward facing triangles... it would appear that you were inside a cube (counter-clockwise)

again any questions let me know....
I will be trying some limb commands next as well as animation stuff simular to dbc (thanks for the idea van and 29games!)

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 10th Jun 2014 14:12
That's actually pretty handy for a couple of projects I'm working on. Thanks for sharing. I don't think I saved my own code for this and my own was not complete by any stretch.
SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 11th Jun 2014 06:24 Edited at: 13th Jun 2014 05:22
excellent!

fyi im starting a much bigger include file to include limbs and animations. These commands will be included in it.

29 games
19
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 25th Jun 2014 18:58
I completely forgot about this and I also realised that trying to sort out the pivot points when they get deleted is tricky, to say the least

Did you ever create something that just breaks a obj into separate files? Do you have anything worth testing or are you now focused on the animation editor. I'm currently putting together a level for my new game so this might be useful.

It's cool if you've expanded the project and are busy with other things, hope I don't come across as pushy.

SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 25th Jun 2014 19:14
nope not at all.... can you post me a generated obj file from blender so I can see if its possible to reset pivot points on the multiple objects it contains?

that will help me to see if its even possible. I can split the models apart...I just don't know if the pivot points can be restored.

29 games
19
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 26th Jun 2014 19:30 Edited at: 26th Jun 2014 19:31
I've attached a model of a robot. I've included the original blender file, done in 2.5, and a jpg so you know what the model looks like should anything go awry.

If you can't restore the pivot points then that's fine, it would still make creating the maps and other non-animated models easier.

Although I am kinda wondering if I could learn how to do all of this through blender (or see if someone already has).

Attachments

Login to view attachments
SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 26th Jun 2014 21:25 Edited at: 26th Jun 2014 21:38
ok...perfect!
it looks like this will be a piece of cake to split the models for an exported obj blender model. the other good news is that it has limb names stored in the file aswell.
what I don't see however is the original pivot point data nor the actual limb linkage data. I will dig deeper but it doesn't look like its there.
will this still be useful for you? let me know and I will start coding it.


edit: oh I stumbled on a potential bad problem. Do you know if the model was saved with uv texture data? when I look at the face data to form the models its written as f 1//1 2//2 3//3 the bad news is the texture data belongs in the middle of the slashes and its not present. second im wondering why blender did not save an mtl file? without the mtl file I cannot properly link the objects with the proper texture either.

i may have a better solution what other file format can blender export that is text based? id be able to crack it if its written in text and clearly defines limb linkage and texturing.

29 games
19
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 28th Jun 2014 00:02
Oops, looks like I forgot to unwrap the original model.

I've attached a new version to this post, with UV coordinates and included the mtl file (I left that out as I don't normally export it as AppGameKit doesn't use it). I've also added a .x file.

Attachments

Login to view attachments
SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 28th Jun 2014 00:29 Edited at: 28th Jun 2014 02:09
ok excellent! the uv data is in there. So we have a few options here.

A. Make an obj ripper that dumps out solid objects into a specific directory... or

B. Make it so agk loads the model and splits it and reloads it as several models.


which do you prefer?

option C would be the direct x way however I figure the time it takes me to decode that one it will already be a new command in agk v2...lol so no point going with that option.


edit: ok so the pivot point data is lost on an obj file... does not look like this will help you at all. give me a week to have a look at that .x file cause I do see the data clearly in it and the joined linkage system structure. Maybe option c is the best here!

29 games
19
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 28th Jun 2014 18:32
Option A would be best for me, as I might end up doing modular designs so individual files might be used across multiple robots.

Quote: "ok so the pivot point data is lost on an obj file"


That's ok. I can still use it for the robots, I can just position all the limbs to zero, export it as a single obj then break it up. I also have some non-animated models, mainly maps, that will need to be broken up. This tool could save me a lot of time.

SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 29th Jun 2014 01:55
ok I will code it for ya and post it

SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 2nd Jul 2014 12:10 Edited at: 2nd Jul 2014 12:13
ok i finished up the converter today... however i ran into a snag.

turns out the file you sent me uses 4 verts to form a face.
is there any control with the output format of your obj files to use 3 faces instead of 4?
i was thrown off when i seen that your file is using 4 verts to make a face indexed.

example of your file:


normaly a face only uses 3 verts to form a triangle. this appears to be making a square face?

i will look into it and see if i can just add more 3 vert triangles to link those back together. but let me know if you can alter that on your end. if ya can its complete and fully works with 3 vert indexes...but not 4 at the moment.

SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 2nd Jul 2014 12:16 Edited at: 2nd Jul 2014 16:57
ah found the solution....can you follow this and send me the new obj file.

http://stackoverflow.com/questions/5257272/how-to-get-wavefront-obj-file-with-3-faces-traingle

instructions pulled...
Quote: "use blender to convert wavefront .obj file with quads to triangles.
1.Import wavefront .obj file in Blender and change the mode to Edit Mode.
2.Now select all the meshes.
3.Go to Mesh -> Face menu options and select convert Quads to triangles
4.Export the current model again to wavefront .obj file
"

here are instructions to convert quads to triangles before exporting to obj

can you do this and send me the new obj file. I will run a test with it and if it works the converter is ready to go

edit: instead you can try it out once you have it converted to triangles. download the converter on first post. let me know if uv data is correct or not.

SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 3rd Jul 2014 16:04 Edited at: 3rd Jul 2014 17:36
hold the boat!

i forgot that dbp can load a .x model in.

from there i should be able to save the multiple objects and have the correct pivot points.



i will have a look at this possibly this week if i get a chance to

29 games
19
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 5th Jul 2014 18:16
I just downloaded the extractor and I'll give it a go and let you know how it works.

29 games
19
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 13th Aug 2014 18:56
Sorry I've not gotten back to you on this sooner, I've been really busy.

Unfortunately this doesn't seem to be working very well for me.

I tried it with a simple model and if I turned all the quads to tris I got an array out of bounds error when running the extractor.

Quote: "Runtime Error 118 - Array does not exist or arry subscript out of bounds at line 258"


If I just keep the object as quads then the extractor does actually split the obj file up but when I load them into agk there are missing faces and the normals aren't right.

Also, it's a bit of a pain having to turn all the quads into tris. It's not particularly difficult but it does make editing the model afterward a bit of a chore (it's quite easy toggling from quads to tris and back again but it all feels a bit of a faff)

I think this was a good idea but it might be more hassle than it's worth. Sorry I can't be more positive.

SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 13th Aug 2014 19:10
Yeah that's no problem .... I tried anyways.

One good thing that came out of this was the ability to create a 3d animation format that I now use for agk.

Login to post a reply

Server time is: 2024-11-25 07:23:55
Your offset time is: 2024-11-25 07:23:55