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.

DarkBASIC Discussion / New DBC objects!

Author
Message
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 10th Feb 2008 21:15 Edited at: 11th Feb 2008 18:55
Hey guys!

You don`t need to complain about making objects like prisms and pyramids any more! I have created 4 functions for 4 different new objects in DBC.

Here is how it works:

At the start of your program, you will have to include the functions:
#Include "objects.dba"

Now you can start using my commands:

create object pyramid(object number,size,type)

This command will create a pyramid, either with 3 or 4 sides.

You should know everything here except for "type". You can either give in a "3" which will give your pyramid 3 sides and a triangle as the bottom. If you set it to a "4", your pyramid will have 4 sides and a square as the bottom.

create object prism(object number,size)

This command will create a prism with 3 sides.

create object diamond(object number,size,stretch)

This command will create an 8 sided diamond.

Everything should be clear, except for the "stretch" value. I you give in a "0", your diamond will be symmetrical. If you enter a "1", your diamond will stretch itself along the y-axis.

create object capsule(object number,size,type)

This command will create a capsule like object. It is perfect for any pong games.

If you enter a "1" into "type", you will get a capsule with rounded edges, if you enter a "2", you will get a capsule with pointed edges.


Download the file attached. It contains an object viewer applet, and the DBC object dba file. To use my objects, you have to copy the file "objects.dba" into your project folder.

Have fun, TheComet


If you would like to view the screen shots of the new objects, then Click Here or Download the viewer(That`s what created the screen shots...)

Oooooops!!! I accidentally formated drive c.

Attachments

Login to view attachments
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 11th Feb 2008 13:24 Edited at: 11th Feb 2008 18:21
Come on! (GASP!) (CRIES!) 35 Views and no posts! Doesnt anyone have any comments for this cool code?! I have made the effort to make something really helpful, and I don`t get any comments...

By the way, I made a game to show the use of my objects.

(File attached)

Please post your comments!

TheComet

Here are the screenshots of the game:






Oooooops!!! I accidentally formated drive c.

Attachments

Login to view attachments
Insert Name Here
18
Years of Service
User Offline
Joined: 20th Mar 2007
Location: Worcester, England
Posted: 11th Feb 2008 16:02
Hows about some screenies?


This image is purely work in progress.
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 11th Feb 2008 22:49
@TheComet

Very nice functions! A few suggestions on how to improve overhead and manage resources a little better.

If you don't plan on texturing each limb with a different image or you have no intention of moving the limbs independently, it's best to have a solid object without limbs. Limbs will slow processing down because they are indexed as individual meshes. You can do this by creating a mesh from the limbed object, deleting the limbed object then recreating the object using MAKE OBJECT.

In your general cleanup, I see you are deleting the unnecessary objects that you made meshes from. That's good, but you should also delete all of the unused meshes. Once you've created all the limbs from a mesh that you need, the mesh is no longer useful. If it's hanging around in memory, it's just eating up resources.

Also, in the general structure, you don't really need to create so many separate objects and separate meshes. One extra object and one extra mesh is all you need. You can reuse both. You are slowing your functions down and adding more code than you need by checking for so many available objects and meshes. The following example shows one way of implementing the overhead cuts I suggest. The top object is a solid mesh, the bottom object is limbed. I do use 1 check for available object and 1 check for available mesh which I don't really think is a great thing to do. I think it's best though, to have the user manage this themselves and for it not to be part of the function and have them pass the parameters of these values to the function unless there's too many objects or meshes to handle. DBC will error out if the object already exist, but it will replace the mesh with the new one if that exists.



Enjoy your day.
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 12th Feb 2008 20:19 Edited at: 12th Feb 2008 20:23
@ Latch

I`m not sure if I get you. So I`ll run through one of the functions the way you explained it should be:

1)Make a core object for the center of the object
2)Find 1 free object and 1 free mesh
3)Make one object, turn it to mesh, delete it, add a limb to the core, delete mesh(and repeat that until I have got all of the limbs added)
4)Make mesh from the core object, make an object (make object) with the mesh, delete the mesh, delete the objects and all of it`s limbs
5)Now you have 1 object without any limbs or any meshes not deleted.

Is that what you mean?

Quote: "If you don't plan on texturing each limb with a different image or you have no intention of moving the limbs independently, it's best to have a solid object without limbs."


There`s no problem with texturing the object, you just "texture object" and it textures every limb. I think it`s better that you can move and offset the limbs later, to move the core object around. If you Downloaded the game example two posts above, Look at the gate in front of the house. You will see it swings open like, well, like a gate. I have repositioned the core later in the program, so I can just rotate the object, because the core used to be right in the middle, not on the outside.

By using this technique, you don`t have to program how far you have to move the object away from the axis, to make it rotate on the outside.

If you do step 4) above, you can`t do the same with the gate.

Thank you sincerely, for your tips you gave me. I will have to update the code, once I get your response to this post, so I know, that I understood you correctly.

Oooooops!!! I accidentally formated drive c.
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 12th Feb 2008 23:50
Quote: "1)Make a core object for the center of the object
2)Find 1 free object and 1 free mesh
3)Make one object, turn it to mesh, delete it, add a limb to the core, delete mesh(and repeat that until I have got all of the limbs added)
4)Make mesh from the core object, make an object (make object) with the mesh, delete the mesh, delete the objects and all of it`s limbs
5)Now you have 1 object without any limbs or any meshes not deleted.
"


Number 1, it doesn't have to be the center, but it is the main object onto which you add limbs. If you make a "core" object, you can offset it's position (it's pivot) from 0,0,0 with OFFSET LIMB <obj>,0,x,y,z : MAKE MESH FROM OBJECT <msh>,<obj> : DELETE OBJECT <obj> : MAKE OBJECT <obj>,<msh>,<texture> or 0

Whatever values are set for x,y, and z will be the rotation point for the "core". You could make a baseball bat that swings around from the base instead of rotating around it's center using this method.

Number 2 - well, you have to make sure you have your main object, then 1 extra object to make any different shapes from (so you don't change the "core" objects shape). And yes, you only need 1 mesh (in most cases).

With 3, you really don't have to delete the mesh until the very end when your whole object is finished. Every time you MAKE MESH FROM OBJECT, it will replace the mesh if it already exists so you can keep reusing the same mesh number over and over until you are done with it without deleting it in between.

Number 4, in the example I included, I added a parameter for a flag that controls if the object is posable (an object with individual limbs), or if it is solid. That's so there is a choice. If you want to have moving parts (like the swinging gate), then setting limbflag to 1 in the example prevents Number 4 from taking place. If it's 0, then Number 4 takes place.

This is just for management purposes. If you made a wall or a rock or an arrow or something that's just going to sit there, it will take less processing power if it doesn't have limbs. But, if you want moving parts, and/or you want to be able to texture each part with it's own image, then you make sure it has limbs.

Enjoy your day.
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 13th Feb 2008 09:50
Ok, I will edit the functions and update the code. Thanks for the tips Latch!

TheComet

Oooooops!!! I accidentally formated drive c.
Dark Dragon
17
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 25th Feb 2008 20:18
These are some Good Functions, TheComet! The game was nice to.
You Get a ......
Stig Design Stig Magne
19
Years of Service
User Offline
Joined: 23rd Mar 2006
Location: Norway
Posted: 15th Mar 2008 07:18
Werry Cool (TheComet)
You are Pretty Cool How did you Make Cutom Code to Dark Basic i My self have tryed like function`s and so on butt i havent get it worked plees help me.
i will down load Your`s and test it.
Keep on Woking in this direction and you probly wil have a game jobb soon. ps ceep thing`s free Like thi`s

Stig Design (Free Games,Sources,Textures,Photo`s)
Lisence Free at http://dashboard.filefront.com/StigDesign/
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 15th Mar 2008 10:41
@ Stig Design Stig Magne

Thanks!
You have to work with "Make Object Triangle". All objects are made of triangles.
If you still don`t get it, just look into my download in the file "objects.dba"
All of the functions are there.

Oooooops!!! I accidentally formated drive c.

Login to post a reply

Server time is: 2025-06-04 03:11:19
Your offset time is: 2025-06-04 03:11:19