Hello, I am fairly new to Java game programming, and I was wondering how I should go about texture mapping polygons in a 3D environment with Java2D, with No polygon scan conversions… Can anyone help?
Sorry if this is the wrong place for this topic =\
I assume that “with No polygon scan conversions” you mean you don’t want to code the texture mapper yourself? Then it is not possible. As the name aplies it is a 2D api.
hmm… I meant without turning the polygons on the screen into horizontal scans, like
900 (1 scan)
990 (another scan)
999 (yet another scan)
= a triangle (sort of)
|\
\ |
---|
Is that what you meant? Sorry if I don’t seem to make the best sense … =(
Is is still not possible without scan converting? …
It’s not possible.
Ah… ok I see.
Btw, do you know where to look for on the internet to learn how to texture map w/o Java3D?
[quote]It’s not possible.
[/quote]
Of course it’s possible! You just have to get imaginitive! The Graphics2D object provides everything you need to draw 3D graphics. The downside is that they’ll be Affine Texture Mapped, slow, and you’ll have to do all the 3D transforms yourself.
All you have to do is figure out the scaling factor for a texture, set the 2D clipping area for the polygon (see: setClip(Shape clip)), and draw the image with an AffineTransform object that includes the scaling and rotation factors.
That’s it. Simple, isn’t it?
When you say slow… does that mean so slow that you shouldn’t even bother for a game? ???
Where can I learn this in detail?
The way you say it, it sounds not too hard Or is it?
tyvm.
[quote] When you say slow… does that mean so slow that you shouldn’t even bother for a game? ???
[/quote]
It wouldn’t be my first choice. But I have no hard data on perfomance one way or the other. My opinion is that it would be spectacularly slow, but that’s no guarante.
You can see a demo of what you can do in the jfc/Java2D demos that come with the JDK.
[quote]Where can I learn this in detail?
[/quote]
The 2D Graphics trail in the Java Tutorial is a good place to start:
http://java.sun.com/docs/books/tutorial/2d/index.html
[quote]The way you say it, it sounds not too hard Or is it?
[/quote]
It’s not so bad. You still have to have a grip on 3D math, so you’re not getting away scot free. However, Java2D can handle the intracasies of rendering to the screen.
The primary things you need to understand are:
- How to convert 3D coordinates to screen coordinates.
- How to rotate and translate 3D coodinates.
- How to calculate the distance from a 3D normal.
If you can handle those three, then the rendering should be something of a snap.
One other thing. I said that Java2D could only do Affine texture mapping. (Affine means that a texture is literally cut out of an image, and is thus unable to “tilt” if a polygon is tilted away from the screen.) This is only partially correct. Something called “perspective affine” can be accomplished by pinching and shearing the image in line with the 3D polygon’s rotation. However, it’s much more difficult to implement, so you probably want to start with simple affine.
:o Well I stand corrected.
[quote]
When you say slow… does that mean so slow that you shouldn’t even bother for a game? ???
Where can I learn this in detail?
The way you say it, it sounds not too hard Or is it?
tyvm.
[/quote]
It was meant as a joke (I hope). Although it is possible in theory, it would be easier and faster to do your own rastariser.
There are texture mapping articles on flipcode.
Why don’t you use OpenGL with JOGL or LWJGL?
I’m moving under the disguise that I’m trying to learn how they work
But really, I’m just doing this in my free time, just for my own quasi-entertainement/satisfaction. My entertainement values tell me that I should do it without OpenGL or anything else. Just for the sake of making the game.
Call it a complete waste of my time, but I see it as fun. Semi.
Thx for the articles, I’ll be sure to look into them.
If you want to make a game you should just use OpenGL. If you are after entertainment then nothing beats creating your first rotating cube from scratch
Yep, I’ve heard of the ‘3D rotating cube.’ Made one with solid polygons (because I have not much of an idea how to go about texture mapping ) / :-[
But a complete game would provide so much more entertainement
How did your particle system and matrix calculations go?
Hint, both names start with a D!
Anyways, to get you started off with 3D and OpenGL. I suggest you look at the neHe tutorials like previously suggested (http://nehe.gamedev.net), then if your seriously confused like I was, go and have a bash at jME (its a scene graph btw), so it should get you started onto making a game as fast as possible!
And i’l also be around to help ya with stuff too!
DP (or should i say digiwired?)
ehh… i dunno…
Particles, I sort of put off until later(is it supposed to be easy or hard?), and matrices;… well instead of using matricies directly I used trig functions, like
camLoc.location.x -= distanceChange * camLoc.getCosAngleY();
camLoc.location.z += distanceChange * camLoc.getSinAngleY();
which might be better or worse than matricies (im guessing worse :P).
really, matrices aren’t as hard as everyone makes them out to be. Just grab a good book/site and just read the section. The hard part is knowing when to use them, but fortunetly, thats well documented on where and why you should use them.
About particle systems, i wouldnt’ say easy, but i wouldn’t say hard either. Somewhere in the middle verging on hard a likkle bit…Just start with a simple particle factory emitting simple dots, then build it up.
DP