Amiga.org
Operating System Specific Discussions => Amiga OS => Amiga OS -- Development => Topic started by: Minuous on April 12, 2012, 05:55:39 PM
-
Hello, I am trying to use Warp3D to enable a flat texture-mapped square/rectangle to be viewed at different angles.
How can I create non-triangular objects? I want to create a square/rectangle. This can be done by creating two triangles adjacent to each other, but Warp3D seems to be designed to wrap rectangular textures onto triangles for some reason, which isn't very useful. How do I tell the system to wrap the texture around both triangles (ie. to treat them as a single object)?
How do I move the camera/viewpoint (as can be done in eg. AMOS 3D), there doesn't seem to be any way of doing this? Must I instead move the triangles?
Is there any example code or tutorials available? I had a look on Aminet, there is almost nothing.
-
Hello, I am trying to use Warp3D to enable a flat texture-mapped square/rectangle to be viewed at different angles.
You need to use W3D_DrawTriFan(), W3D_DrawTriSttrip() or better still, W3D_DrawArray() with their corresponding data structures. I suggest the latter since you have much more control over how the vertex data is organised.
How can I create non-triangular objects? I want to create a square/rectangle. This can be done by creating two triangles adjacent to each other, but Warp3D seems to be designed to wrap rectangular textures onto triangles for some reason, which isn't very useful. How do I tell the system to wrap the texture around both triangles (ie. to treat them as a single object)?
You create a triangle strip or a triangle fan. In a strip, alternate triangles share two points along an edge. In a fan, all triangles share one common vertex and adjacent triangles also share an edge. The simplest to illustrate is the strip. A rectangle is simply a 2 triangle strip, something like this:
V[0]--V[1]
| /|
| / |
| / |
| / |
| / |
V[2]--V[3]
Using one of the strip drawing methods, the same texture is applied to all polygons in the strip. If you use the old single triangle routines, you have to either enable global texture environment or specify the texture in each polygon separately.
How do I move the camera/viewpoint (as can be done in eg. AMOS 3D), there doesn't seem to be any way of doing this? Must I instead move the triangles?
Warp3D is a rasterizer only. That means that it draws primitives in screen space. Stictly, the axes are defined as X=left to right in pixels, Y top to botton in pixels, Z is plane of the screen into the distance. The valid range for Z is 0.0 - 1.0.
You need to calculate your vertices in screen space directly or write your own transformation pipeline.
-
Hello
have a look to
http://aminet.net/dev/src/StarshipW3D.lha
replace StarShipW3D.h with a simple textured square object like that
/* This file contain all the datas for the 3D-object */
/* All points : a point is defined as 5 coordinates U V X Y Z */
/* All triangles : a triangle is defined as 3 indices to the points */
#define TEXNAME "StarShip_256X256X24.RAW"
#define TEXSIZE 256
#define pointsCount 4
#define trianglesCount 2
float points[pointsCount*5] = {
0.00 0.00 0.0 1.0 0.0
0.99 0.00 1.0 0.0 0.0
0.99 0.99 1.0 1.0 0.0
0.00 0.99 0.0 1.0 0.0
};
ULONG indices[trianglesCount*3] = {
0,1,2,
0,2,3
};
Alain
-
It sounds like you could do with a source of some basic information about Perspective, Model and World transformations. Or the OpenGL transformation pipeline. (try Google)
Some of the NeHe tutorials come in for a lot of flack for being out of date and a lot of them definitely NOT the best way of doing things. However, as a resource to learn from a lot of people find them very useful. The link to the lessons is on the right of the page.
http://nehe.gamedev.net/
They're aimed at Windows originally, and texture mapping starts around lesson 6. I recommend just going through them one lesson at a time, implementing/porting them in Warp3D and asking on here for the equivalent Warp3D functions.
It's a little more involved but everything, certainly at this stage, is really simple and shouldn't require more than a few nudges and hints from people :)
Good luck.
-
Yes, I'm nearly finished implementing the feature using Direct3D for the Windows version and then might try implementing that functionality via Warp3D for the Amiga version. I will rotate the object which will obviate the need to move the camera.
-
Hi,
@all,
You know why Karlos knows som much about Warp 3D, probably because he is warped. After all it takes one to know one
smerf