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 Professional Discussion / Sprites on a 3D object?!

Author
Message
Paronamixxe
AGK Bronze Backer
14
Years of Service
User Offline
Joined: 10th Feb 2012
Location: Sweden
Posted: 1st Dec 2012 17:53
Hi!
So I've been looking around the forum trying to find some code which could be both helpful and interesting... Pasting / putting sprites on a 3D object. This comes initially from me wanting to create a 3D menuscreen which tilts depending on where the mouse is (like in Crysis), and I have managed to get that working, now I just need to know how I can place sprites on this cube which rotates to get the desired effect. Also, when thinking about the possibilities this uncovers, I'm really looking forward to receiving any and all help!

Thanks in advance!
//Anton

//Anton
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 1st Dec 2012 18:32
Hi there.
Here is an example :




Cheers.

I'm not a grumpy grandpa
Paronamixxe
AGK Bronze Backer
14
Years of Service
User Offline
Joined: 10th Feb 2012
Location: Sweden
Posted: 1st Dec 2012 19:38
Thanks But this basically just adds a sprite which follows the X and Y coordinates of the object... What I am looking for, is a sprite/image which is placed on the surface of the cube. Which then has the same rotation and such as the object.
Thanks though, this could be of great use in for example light flares
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 1st Dec 2012 19:56
Quote: "What I am looking for, is a sprite/image which is placed on the surface of the cube. Which then has the same rotation and such as the object."


And why can't you use an object for this ie. limb'd plain or the object it self?

As of sprite's we don't have enough control over them. Skew transforms is what is required and there's no way to skew a sprite. Though you might be able to fake it with altering the uv's and scale but you'd need a texture with boarders to fake the edges. Hmm... this is complex to explain. I'll have a play... (side note, clipping the sprite based on the object won't be as fun).

As of images, same as sprites really minus memblocks, but you'd have to have extensive knowledge of them.

Either way, you might aswell just use an object... it would be far far quicker to implement.
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 1st Dec 2012 19:56 Edited at: 1st Dec 2012 20:00
In that case you could use an object plain

sorry sasuke...I didn't see your answer...:p

I'm not a grumpy grandpa
Paronamixxe
AGK Bronze Backer
14
Years of Service
User Offline
Joined: 10th Feb 2012
Location: Sweden
Posted: 1st Dec 2012 19:59
Ok, thanks for the feedback guys, I think using a plane/objects on the side of my cube would probably be easier, I'll have a look into it, although any additional help/pokes in the right direction would be greatly appreciated
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 2nd Dec 2012 13:07
I think you are looking for billboarding, using planes... and that is very simple...

I will not give code as I learned mine through a plugin... but it is pretty simple...

Paronamixxe
AGK Bronze Backer
14
Years of Service
User Offline
Joined: 10th Feb 2012
Location: Sweden
Posted: 2nd Dec 2012 13:54
Ok, what plugin? I', quite new to DBPRO and BASIC, so yeah anything you can send my way would be appreciated
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 2nd Dec 2012 14:23 Edited at: 2nd Dec 2012 14:24
eXtends

EDIT

I should probably mention that you should not expect everything to work in that pack...

Paronamixxe
AGK Bronze Backer
14
Years of Service
User Offline
Joined: 10th Feb 2012
Location: Sweden
Posted: 2nd Dec 2012 14:32
Ohright I'll have a look in there! Thanks!
//Anton
Sergey K
22
Years of Service
User Offline
Joined: 4th Jan 2004
Location:
Posted: 2nd Dec 2012 14:38 Edited at: 2nd Dec 2012 14:38
just think about sprites that way..
sprites are basicly made from images, right?
example: sprite 1,0,0,<IMG NUM>
you can use that IMG NUM to act like texture on 3d object.
wich means you have only to TEXTURE OBJECT using same IMG NUM

how simple is that?

Advanced Updater for your games!
Paronamixxe
AGK Bronze Backer
14
Years of Service
User Offline
Joined: 10th Feb 2012
Location: Sweden
Posted: 2nd Dec 2012 15:19
Then you just need to get a way of checking for 'clicking on' ... Which isnt as simlpe But thanks anyway!
Sergey K
22
Years of Service
User Offline
Joined: 4th Jan 2004
Location:
Posted: 2nd Dec 2012 16:07
Quote: "Then you just need to get a way of checking for 'clicking on' ... Which isnt as simlpe But thanks anyway!
"

Pick Object command just for that

Advanced Updater for your games!
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 3rd Dec 2012 10:24
Sparky's collision is even better

As of what you want to do. If you want it to act like a sprite, meaning sprites sit on top of all 3d you can do this:


But if you don't want it to sit on top of all the 3d then you can't simply just sit the plain slightly in front of the cube face because they will clip each other, and it will get worse even further away. You could just make a cube out of plains.
Duffer
23
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 3rd Dec 2012 18:18
So if you had a 4x4 animation (16 frames) in the one image and you applied that image to a 3d plane, if you played the sprite, how would the animation single frame -by frame- (as opposed to the 4x4 image) apply to the surface of the plane?

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 3rd Dec 2012 18:42
I have precisely that in one of my tech demos... Will dig it up if I remember tonight...

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 3rd Dec 2012 18:48
Quote: "So if you had a 4x4 animation (16 frames) in the one image and you applied that image to a 3d plane, if you played the sprite, how would the animation single frame -by frame- (as opposed to the 4x4 image) apply to the surface of the plane?"


1) You could either create 16 individual images and re-texture the object once in a while.

2) You could texture the object with the 4x4 image, then change the UV data every once in a while.

TheComet

Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 3rd Dec 2012 22:56
Quote: "Skew transforms is what is required and there's no way to skew a sprite."


It is possible to skew sprites, using sprite tex coordinate commands.

Quote: "1) You could either create 16 individual images and re-texture the object once in a while.

2) You could texture the object with the 4x4 image, then change the UV data every once in a while."


Following on from TheComet, you can animate a 4x4 image using the scroll object texture command, and the scale object texture command.

I'm not sure what kind game or application you are creating, but if you really really wanted a sprite on a 3D object, you could extract the sprite off a bitmap and texture the object that way; but that's a little more advanced than using the pick object methods recommended.

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 3rd Dec 2012 23:07
Quote: "Following on from TheComet, you can animate a 4x4 image using the scroll object texture command, and the scale object texture command."


Interesting idea, but there's a flaw with that method. Scrolling the texture is relative to the last state, so all of the small floating point errors start to add up until your texture is no longer centered on the object (assuming you have a grid of images that don't divide well, for example the number 7).

TheComet

Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 5th Dec 2012 00:07
True, I did not remember that. So you must advance back at the end of the animation to resolve that issue; so when you reach frame 10, the next frame is 10 - 10, instead of 10 + 1.

chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 5th Dec 2012 01:15
Quote: "1) You could either create 16 individual images and re-texture the object once in a while."


As The Comet says, we can create several individual images ...we can get differents parts of an image and make all the images we need.




Cheers.

I'm not a grumpy grandpa

Login to post a reply

Server time is: 2026-07-08 03:47:18
Your offset time is: 2026-07-08 03:47:18