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.

Dark GDK / 3D Rectangle

Author
Message
codingtroubl3s
7
Years of Service
User Offline
Joined: 31st Jan 2012
Location:
Posted: 31st Jan 2012 17:11
Hello there, i am currently learning DarkGDK.NET engine using C#, from examples and code base on this site.
However i couldn't find simple solution for this problem :

Need to draw a rectangle which will behave like Cube in provided template in Visual Studio (the rotating cube with DarkGame logo).
I just want to draw a 3D rectangle, to color it's sides as i want and to rotate ( i am sure i could rotate object as in example).
If someone could help me there, i will be glad.
Hawkblood
10
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 31st Jan 2012 19:47
"rectangle"? Do you mean "box"? It seems like you want a box.

The fastest code is the code never written.
codingtroubl3s
7
Years of Service
User Offline
Joined: 31st Jan 2012
Location:
Posted: 31st Jan 2012 22:40
Well, anyhow you call it (my sources are Google, and it seems same lol, maybe i did define it wrong ).
Just took a look about some other code examples, including the one on the main page ( camera rotation ).
I have 3D model of the box, colored and designed according to request from client.
First what i wanted to achieve was Euler rotation, but internet is full of rotating CUBES, millions of them, never saw code for rotation of rectangle or box.
Now, after looking the code on main page, i thought it would be possible to load 3D model ( i have PSD file ) and rotate camera in given direction (arrow keys or mouse ).
The point is that this object MUST rotate in all possible ways (x , y, z axis).
zapakitul
12
Years of Service
User Offline
Joined: 1st Mar 2007
Location: In my world
Posted: 31st Jan 2012 23:39 Edited at: 31st Jan 2012 23:40
Ok, if by .PSD you mean Photoshop file, you have two options:
- Either one, make a 3D model in a modeling package (milkshape, 3D Studio Max, Wings3D, etc) or use dbCreateObjectBox(id,width, height, depth).
- If you want to use that image and rotate it, you can create a Plain object and rotate it based on it's angles. For example, you can do something like this: dbRotateObject(ObjectID, dbObjectAngleX(ObjectID)+1, dbObjectAngleY(ObjectID)+1, dbObjectAngleZ(ObjectID)+1);. I don't use GDK.NET, but the regular GDK (C++), so I can't help you out with the proper commands (you can still use them as a reference with GDK.net's help files).

Hope that clears some things up.

Edit: Forgot to mention, if your going for a textured plain, you must export that .PSD file into a supported format (.PNG <-- recommended, .DDS, .JPG, .BMP, .TGA?).
codingtroubl3s
7
Years of Service
User Offline
Joined: 31st Jan 2012
Location:
Posted: 1st Feb 2012 09:58
Yes, it's drawn in Photoshop, but i am thinking to draw it again in some other program, like Blender and export it as DirectX file (*.X) then then use built in commands to rotate that object.
it just need to be 3D Rectangle (prism with rectangle basis) or how they call it too - Box, and not CUBE.
it's part of some bigger project not even close to graphics and games but someone requested that rotating box as helper for modeling or meditation, my duty is to obey and make that thing.
Any example is good C++ or C#, doesn't matter.
JTK
9
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 1st Feb 2012 14:54
I believe this set of commands is what you need:

dbMakeobjectCube(), dbScaleObjectX/Y/Z(), dbRotateObjectX/Y/Z()

First, make a cube, scale it along the appropriate axis' to the disired shape and rotate the appropriate axis'

When I get some time off, I can put together an example. Until then, this is the best I can offer...

Hope this helps,

JTK
Hawkblood
10
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 1st Feb 2012 16:55
You can use dbMakeObjectBox(iId,SizeX,SizeY,SizeZ) to make a box with any of the 3 size dimensions.

The fastest code is the code never written.
codingtroubl3s
7
Years of Service
User Offline
Joined: 31st Jan 2012
Location:
Posted: 1st Feb 2012 17:25
That sounds better.
Of course i can do like that, by using dbMakeObjectBox from 2D image, define height and width of sides and rotate it.
Should i draw just a 2d rectangle in that case, load it and then with dbMakeObjectBox manipulate with it's movement?
Problem is that i have fixed look for this box (different colors of sides, ellipse drawn inside the top side ).
Can i just draw desired look of 3d box, export to .X and rotate it by just using camera manipulations?
Or if i use dbMakeObjectBox on 2D image, can i later draw inside and fill sides with colors?
codingtroubl3s
7
Years of Service
User Offline
Joined: 31st Jan 2012
Location:
Posted: 1st Feb 2012 17:40
No,it's NOT Cube, so dbMakeObjectCube won't work. Cube's height and width are same size, while Box has different size of width and height.
Problem is that this Box has to be customized, with colors of sides already described to me and on top side of the box there is drawn Ellipse inside it.
In fact, best description of the object i need ( speaking mathematically) is Prism with rectangle base, while Cube is prism with square base.
Hope this helps to clarify my problem.
For me best solution is if i can load already designed box, and rotate it and tie its rotation with mouse or keyboard movements,using maybe math or camera manipulations.
Second possible solution is to use dbMakeObjectBox on 2D image (rectangle) and then draw by C++ or C# functions or DarkGDK functions desired objects inside box and fill sides with colors.
Either or those two solutions.
Hawkblood
10
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 1st Feb 2012 18:06
What I think you are trying to do is make a box and texture each side of the box with different textures... Right? If so, you will need to look into cube mapping. I have never used it (except looking at it in demos), but you can apply 6 different textures to the box's faces.

The fastest code is the code never written.
codingtroubl3s
7
Years of Service
User Offline
Joined: 31st Jan 2012
Location:
Posted: 1st Feb 2012 19:11
Thanks, Hawkblood, that's one of closest solutions.
But is there Box mapping as well, because my object is not cube but box?
So it should look like : i load the 2d image, make object box, apply textures to faces and then use rotate functions on object.
Well, same as you, never used this mapping thing and applying textures by hand.
The way of achieving it is not predetermined, any possible way just to make this box rotate with desired textures.
Brendy boy
14
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 1st Feb 2012 23:08
Quote: "Thanks, Hawkblood, that's one of closest solutions.
But is there Box mapping as well, because my object is not cube but box?"

That won't work. That command is used for reflections, not for texturing.

What you need to do is make your box/cube inside 3D modelling application, texture it and then export it to x/dbo and then import it in DarkGDK

Hawkblood
10
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 1st Feb 2012 23:25
"Cube mapping" refers to a method not that it's a cube-- it just refers to having 6 sides.

@Brendy boy:
Does
Quote: "dbSetCubeMappingOn( int iID, int i1, int i2, int i3, int i4, int i5, int i6 );"
not work? I don't know because I never used it.

The fastest code is the code never written.
Brendy boy
14
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 1st Feb 2012 23:44
Quote: "@Brendy boy:
Does
Quote: "dbSetCubeMappingOn( int iID, int i1, int i2, int i3, int i4, int i5, int i6 );"
not work? I don't know because I never used it."

it is for reflections, not for texturing

Hawkblood
10
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 2nd Feb 2012 01:48
Oh. I've never used it (or even looked at the explaination until now).

An alternative is to make 6 planes--one for each side of the box. Texture them according to where they are on the box. Rotate and position each plane so that they make the box. And finally dbGlueObjectToLimb(..) for planes 2-6 to plane 1.

I like Brendy boy's solution earlier. You can even find boxes (used as sky boxes) that already have the texture and UV data. Just edit the .x file to use your textures and scale the object in the desired axis.

The fastest code is the code never written.
codingtroubl3s
7
Years of Service
User Offline
Joined: 31st Jan 2012
Location:
Posted: 3rd Feb 2012 21:33
So that's it.
I can draw my 3D model in Blender, export it to .X
and simply load and tie mouse movement to camera angles like on example at the home page, few lines of code?
Hawkblood
10
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 4th Feb 2012 03:57
Your 3D model must be done a certain way. You have to assign multiple textures to it (one for each side), and you need to make sure the images for the sides is in the same directory as the .x file when you load it in your program.

The fastest code is the code never written.
codingtroubl3s
7
Years of Service
User Offline
Joined: 31st Jan 2012
Location:
Posted: 4th Feb 2012 16:28
Well, i am in hurry and need to do it till Monday, tried Blender but no help at all, as i am busy with other part of project. Complete project is non-graphic-non-animation-non game at all, but client insisted on that damn object to rotate as helper in...something.
Here is the PSD file how it should look, if some good heart can convert or draw it and export to .X so i can load the figure in DarkGDK or DarkGDK.NET and rotate it, i will appreciate.
Tried with Blender but couldn't find out how to color those sides and shapes, and i never used it before.
So, bottom face should be brown, top face have red ellipse in middle, and left,right,front and back faces are all yellow.

Attachments

Login to view attachments
JTK
9
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 4th Feb 2012 20:13
The code is really quite simple. Attached is a project for VC2008 with a .X file. I don't have Photoshop (or your textures), so I couldn't see your oringal work. This .X file is a pseudo-replacement with generic textures to help you along. You can use a text editor to manually edit the .X file if you need!

Good Luck!

JTK

Attachments

Login to view attachments

Login to post a reply

Server time is: 2019-12-15 07:18:25
Your offset time is: 2019-12-15 07:18:25