Applying Textures to an IndexedTriangleStripArray

Hi @ all,
As mentioned in the topic, I want use an IndexedTriangleStripArray for rendering Textures. But I can't programm a prototype with which i would be able to design more complex geometry objects.
I' m not able to assign the right indices to the vertex- and texturecoordinates in the Array.
I've tried to implement it with data BY_REFERENCE like below:
float[] coordinates={
1.0f, 1.0f, -1.0f,
1.0f, -1.0f, -1.0f,
-1.0f, 1.0f, -1.0f,
-1.0f, -1.0f, -1.0f};
float[] texCoord={
0.0f, 0.0f,
0.0f, 1.0f,
1.0f, 0.0f,
1.0f, 1.0f};
int[] coordIndex={0, 2,     3, 0, 1, 3};
int[] texCoordIndex={0, 2, 3, 0, 1, 3};
int[] stripIndexCounts={6};
IndexedTriangleStripArray plane = new IndexedTriangleStripArray(4, GeometryArray.COORDINATES | GeometryArray.BY_REFERENCE     |      GeometryArray.TEXTURE_COORDINATE_2, 6,stripIndexCounts);
plane.setCoordRefFloat(coordinates);
plane.setTexCoordRefFloat(0,texCoord);
plane.setCoordinateIndices(0,coordIndex);
plane.setTextureCoordinateIndices(0,0,texCoordIndex);
//Later a texture image is being loaded and the Geometry is embedded in the SimpleUniverse
Unfortunately this sample just displays a white square without the Texture image. Why is the image not been displayed? What did I wrong with the indices numbers?

Hi,
here is the complete source code of the testprogram. It's a modified file of the Java3D Examples1.6
import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.GraphicsConfiguration;
import com.sun.j3d.utils.geometry.*;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.image.TextureLoader;
import javax.media.j3d.*;
import javax.vecmath.*;
* SimpleTextureApp creates a single plane with texture mapping.
public class SimpleTextureApp extends Applet
BranchGroup createScene()
BranchGroup objRoot = new BranchGroup();
Transform3D transform = new Transform3D();
               float[] coordinates={
               1.0f, 1.0f, -1.0f,
               1.0f, -1.0f, -1.0f,
               -1.0f, 1.0f, -1.0f,
               -1.0f, -1.0f, -1.0f};
               float[] texCoord={
               0.0f, 0.0f,
               0.0f, 1.0f,
               1.0f, 0.0f,
               1.0f, 1.0f};
               int[] coordIndex={
               0,
               2,
               3,
               0,
               1,
               3};
               int[] texCoordIndex={
               0,
               2,
               3,
               0,
               1,
               3};
               int[] stripIndexCounts={
               6};
               IndexedTriangleStripArray plane = new IndexedTriangleStripArray(4, GeometryArray.COORDINATES | GeometryArray.BY_REFERENCE     |
               GeometryArray.TEXTURE_COORDINATE_2, 6,stripIndexCounts);
               plane.setCoordRefFloat(coordinates);
               plane.setTexCoordRefFloat(0,texCoord);
               plane.setCoordinateIndices(0,coordIndex);
               plane.setTextureCoordinateIndices(0,0,texCoordIndex);
Appearance appear = new Appearance();
String filename = "stripe.gif";
TextureLoader loader = new TextureLoader(filename, null);
ImageComponent2D image = loader.getImage();
if(image == null) {
System.out.println("load failed for texture: "+filename);
// can't use parameterless constuctor
Texture2D texture = new Texture2D(Texture.BASE_LEVEL, Texture.RGBA, image.getWidth(), image.getHeight());
texture.setImage(0, image);
               appear.setTransparencyAttributes(new TransparencyAttributes(TransparencyAttributes.FASTEST, 0.1f));
Shape3D planeObj = new Shape3D(plane, appear);
objRoot.addChild(planeObj);
Background background = new Background();
background.setColor(0.5f, 0.5f, 0.5f);
background.setApplicationBounds(new BoundingSphere());
objRoot.addChild(background);
return objRoot;
public SimpleTextureApp()
setLayout(new BorderLayout());
GraphicsConfiguration config =
SimpleUniverse.getPreferredConfiguration();
Canvas3D canvas3D = new Canvas3D(config);
add("Center", canvas3D);
canvas3D.setStereoEnable(false);
SimpleUniverse u = new SimpleUniverse(canvas3D);
// This will move the ViewPlatform back a bit so the
// objects in the scene can be viewed.
u.getViewingPlatform().setNominalViewingTransform();
u.addBranchGraph(createScene());
public static void main(String argv[])
System.out.print("SimpleTextureApp.java \n- ");
System.out.println("The simpliest example of using texture mapping.\n");
System.out.println("This is a simple example progam from The Java 3D API Tutorial.");
System.out.println("The Java 3D Tutorial is available on the web at:");
System.out.println("http://java.sun.com/products/java-media/3D/collateral ");
new MainFrame(new SimpleTextureApp(), 256, 256);
I hope this is helpful for you.
Geetings User239

Similar Messages

  • Apply texture on an 3D object

    Hi,
    I have a 3D scanner that outputs 3D model (STL file) as well as texture for that model (PNG file). I'm able to open the STL file in Labview (as mesh object), but I don't know how to plot texture on the mesh, because Apply Texture.vi doesn't work (at least not correctly). However, I'm able to apply the same texture on a simple sphere (see the attached example), therefore I don't understand why it's not working for my mesh.
    Any help is greatly appreciated. Also the example is attached.
    Attachments:
    3DPicture.7z ‏3677 KB

    Now, I think that you probably want to show your 'hand' on top of your points. Then, although STL doesn't have Texture information, once you read into LabVIEW, you can manipulate the mesh to generate the missing infomation.
    The Texture is specified by two parameters S and V. They correspond to the Horizontal and Vertical coordinates (normalize between 0 and 1) of the picture that will be use inside the triangle. So, I noticed that you want to see your hand 'projected' to the points measured. Also, I noticed that the X, Y position is 'similar' to the location of your picture, so I just tried to map the X and Y points (ignoring Z) into the S and V parameters. I also noticed that your dimensions were way bigger than the picture, so I normalized the X,Y,Z coordinates. Then, by applying a those two transformations, I was able to get this:
    Now, I also noticed a relationship between the size of the picture and points, so that is the reason I tried 'eye ball' it. Also, I have to flip the picture vertically to match the inicial points.
    Notice also that your measurements have several points that are not in the hand, so probably you'd want ot clean those points and also remove points that are 'off' the hand (probably errors).
    In short, the trick in using textures and meshes is to map the part of the picture you want to map into your object (in your case, the triangles). If you look into the shipping example: "C:\Program Files (x86)\National Instruments\LabVIEW 2013\examples\Graphics and Sound\3D Picture Control\Using Meshes.vi", you will see how meshes work with textures.
    Would this work for you?
    Barp - Control and Simulation Group - LabVIEW R&D - National Instruments
    Attachments:
    STL and JPEG examples with texture.vi ‏41 KB
    hand 2.jpg ‏60 KB

  • Blending/applying textures from symbols panel

    Using the Artistic Textures in the Symbols Panel, can someone give me some idea for how you can use these textures in a piece of artwork? How do you blend or apply something like this into a piece of art? Any examples will be appreciated.
    Thanks.

    "Artistic" doesn't necessarily mean they have to be used in art. It may also mean that they were derived from art. Those are just examples of what can be used in a symbol. Illustrator is used in so many ways. If you want an overview, you could take a look at the Illustrator Wow book to see how people use it.

  • Code to apply texture a raw image?

    i tried loading a raw image using the code i wrote below.
    can anybody please help me debug this code.
    i can only see a black and white strip on the entire screen with this.
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.image.*;
    import java.awt.*;
    import javax.media.j3d.*;
    import javax.vecmath.*;
    import com.sun.j3d.utils.geometry.*;
    import com.sun.j3d.utils.universe.*;
    import com.sun.j3d.utils.image.TextureLoader;
    import java.io.*;
    public class TexTry extends JFrame
         Image img;
         public static void main(String arg[])
              new TexTry();
         public TexTry()
              img=null;
              Container c=getContentPane();
              readImage();
              if(img==null)
                   System.exit(1);
              SimpleUniverse u=new SimpleUniverse();
              //c.add(u);
              BranchGroup bg=new BranchGroup();
              Background back=new Background();
              back.setApplicationBounds(new BoundingSphere( new Point3d(0.0,0.0,0.0), 200.0 ));
              Appearance app=new Appearance();
              Texture tex=new TextureLoader(img,this).getTexture();
              app.setTexture(tex);
              BranchGroup bgGeometry = new BranchGroup();
              Sphere sphere = new Sphere( 1.0f,
    Primitive.GENERATE_TEXTURE_COORDS |
    Primitive.GENERATE_NORMALS_INWARD, app );
              bgGeometry.addChild( sphere );
              back.setGeometry( bgGeometry );
              bg.addChild(back);
              u.addBranchGraph(bg);     
              //setSize(500,500);
              //show();
         public void readImage()
              try
                   FileInputStream f=new FileInputStream(new File("himg.raw"));
                   int size =f.available();
                   byte b[]=new byte[size];
                   f.read(b);
                   byte[] gray=new byte[256];
                   for(int i=0;i<256;i++)
                        gray=(byte)i;
                   ColorModel cm=new IndexColorModel(8,256,gray,gray,gray);     
                   img=createImage(new MemoryImageSource(640,480,cm,b,0,640));
              }catch(Exception e)
                   System.out.println("Error:"+e);

    Have you tried this code with another image that you know does work - just using a textureLoader to load in a gif or jpg for example? If the problem isn't with the loading then it is likely your viewPlatform is in a funny place or can't see the entire shape for one reason or another.

  • How do I apply a texture to a text field's fill area?

    Hi all, first post and all that!
    I've seen that it's possible to format a specific bit of text in a text field with:
    setTextFormat(format:TextFormat, beginIndex:int = -1, endIndex:int = -1):void
    I need to format a section of text by applying a texture to the rectangular fill space around the letters. (Imagine in Microsoft Word that you've written a short sentence and you highlight it. Then you fill the text background with a colour. Then imagine that that colour is a single repeating texture. That's what I'm trying to achieve.) Note that the text field must be multiline, and I'm not looking to fill the whole rectangular text field area. The applied texture needs to fit to each character.
    Is this possible in Actionscript?
    Would I need to use some kind of HTML or CSS formatting?
    Is it possible at all?
    If it is possible, is it possible to change the size of the fill area around the text?
    Thanks all!

    Actually, that's pretty much what I'm looking for. For anyone else reading this thread:
    http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=00001279.html
    That'll fill an area with a repeating texture. The tricky bit now is to work out a top left coordinate for each line of text, and the length of each line in pixels (based on the sum of the character widths). I'll have a poke around and see if there's a way to get that information back from a movie clip.

  • FEATURE REQUEST: Enhanced Texture Options in FW

    Recently, a forum user was asking how to change the color of a texture in Fireworks to red or blue. In particular, he/she was struggling with attempting to apply a texture to a white object, and it wasn't showing up.
    http://forums.adobe.com/thread/1006694?tstart=0
    The question got me thinking about textures, how they're created and how they're applied. Textures are a unique and distinctive feature of Fireworks. On the one hand, the interface for textures is very simple to use and almost magical; on the other hand, it's surprisingly limited. The concept is great, but the implementation seems only half-baked.
    With this in mind, I'd like to suggest a few simple ways that textures could be made more fluid and versatile in Fireworks.
    First, a little background...
    WHAT IS A TEXTURE?
    In the world of Fireworks, a texture is basically a type of pattern that's applied to an object. However, unlike a pattern fill, textures include transparency and integrate with the existing fill content (color, gradient or pattern). They're suggestive of textures in the real world, which are often tactile and defined visually by light and shadow.
    Texture graphics are most commonly grayscale ("black and white") in GIF or PNG format. Applied within the application, the graphics are converted "on the fly" to white-on-transparency. If the Transparent option is checked, the graphic is converted into a sort of mask, making the "textured" areas invisible instead of white.
    And that's about it.
    So what if you'd like to apply a dark texture to a white object? Sorry, it can't be done. What if you'd like to apply a texture in color? It can't be done. What if you'd like to reverse or invert the pattern of the texture? Can't be done.
    Well, in fact, these things can be done, but not directly. They require workarounds such as cloning the object and placing the clone above or beneath the original, applying textures as pattern fills (instead of as textures) and adding effects like Color Fill, Invert, and Convert to Alpha, or editing the texture file directly, saving out a new copy, etc. In short, there are unintuitive ways to accomplish these goals that lead to bloated effects lists and layers or that require extra time and care.
    HOW CAN TEXTURES BE IMPROVED?
    First of all, does it make any sense that textures are applied exclusively in white? Not really. In the real world, a texture can be defined not just by light but by shadow. And even shadows can have color. This means that, at minimum, it would make sense to allow for the application of a texture in black, and, at maximum, in any chosen color.
    Secondly, textures are relative. They represent change to an existing surface. Sometimes, it might make sense to highlight the texture itself; other times, the surface around the texture. This means that being able to quickly reverse the figure-ground relationship of a texture would be a very handy feature.
    With the above concerns in mind, I've devised three 'user interface' scenarios, presented here in order of most conservative to most extreme. The first scenario is the least powerful but still doubles the number of possible outcomes (compared to the existing interface). The second scenario may be the most logical of the bunch and represents a modest evolution of the existing interface, while increasing the number of potential outcomes even further. The third scenario allows for the application of any color to a texture but also represents the biggest change to the existing interface; that said, it's also quite compact.
    Scenario 1: Invert option
    The idea here is simply to add an Invert checkbox to the existing options. Checking this option would convert white to black, allowing for the application of dark textures to white or light-colored objects. In "Transparent" mode, this option would invert or reverse the figure-ground relationship of the existing texture.
    Scenario 2: Dropdown menu plus Reverse option
    Here, the Transparent checkbox is replaced by a dropdown menu that includes 3 mutually exclusive options: White, Black, or Transparent. Checking the "Reverse" option would invert the figure-ground relationship of the texture. This scenario allows for 6 possible outcomes in place of the existing 2, and is actually more logical than the first scenario, which conflates two options.
    Scenario 3: Color picker plus Reverse option
    Here, the Transparent checkbox is removed, and in its place, a color chip/palette is added to allow for the selection of any color to be applied to a texture. (Choosing Fill: None would create Transparency.) Again, a "Reverse" option would invert the figure-ground relationship of the texture. This scenario differs most from the existing interface but is quite compact and allows for the greatest number of outcomes.
    SO WHAT CAN YOU DO?
    I've submitted a feature request to Adobe's official site:
    https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform
    When it comes to bugs and/or feature requests, every vote counts. If you care about this issue, I encourage you to submit your own feature request to the above URL, referencing this post if desired. Feel free to copy and paste the feature request below or write your own. (Be aware that there is a 2,000 character limit to the "issue description" of a bug report or feature request, and the following report is very close to that maximum.)
    FEATURE REQUEST
    Product name: Fireworks
    Product Version: 12.0.0.236
    Product language: English
    *******Enhancement / FMR*********
    Brief title for your desired feature: Enhanced texture controls, including the ability to apply textures in black and/or color (instead of white), and the ability to reverse or invert texture.
    How would you like the feature to work? Three possible implementations have been outlined in this forum posting:
    http://forums.adobe.com/thread/1042206?tstart=0
    The basic scenarios are as follows:
    SCENARIO 1: An additional "Invert" option. Checking this option would convert white to black, allowing for the application of dark textures to white or light-colored objects. In "Transparent" mode, this option would invert or reverse the figure-ground relationship of the existing texture. This scenario would allow for 4 options in place of the existing 2.
    SCENARIO 2: Replace Transparent checkbox with a dropdown menu (White-Black-Transparent) and a "Reverse" checkbox. The dropdown menu offers 3 mutually exclusive options, while "Reverse" inverts the figure-ground relationship of the texture in each case. This scenario would allow for 6 options in place of the existing 2.
    SCENARIO 3: Replace Transparent checkbox with a color chip/palette and a "Reverse" checkbox. The color palette would allow for the application of a texture in any color, while choosing Fill: None would create Transparency. This scenario would allow for the greatest number of options.
    Why is this feature important to you? Textures are unique to Fireworks and potentially very useful, but their implementation is incomplete. The use of 'white only' means that textures cannot be applied to a white object. Inverting a texture or applying a texture in color requires advanced workarounds and can lead to bloat. The suggested options would make the feature exponentially more powerful and intuitive.

    Thanks, Jim! It is a very blog-like post. (I still haven't gotten around to starting a blog but keep thinking I should.)
    I figured the clearer and more thought-out the presentation, the greater the likelihood it might get implemented. Also, I was originally stuck on Scenario 1 as a solution, and writing this helped me see other options.

  • Photoshop crashes when working with 3D Diffusion Textures

    Hello,
    first off, sorry if this has been answered before, but I couldnt find anything close to my issue.
    First some details:
    ######### WINDOWS Vista Error Reporting ##########
    Produkt
    Adobe Photoshop CS5.1
    Problem
    Funktioniert nicht mehr
    Datum
    15.06.2011 15:10
    Status
    Nicht berichtet
    Problemsignatur
    Problemereignisame:    APPCRASH
    Anwendungsname:    Photoshop.exe
    Anwendungsversion:    12.1.0.0
    Anwendungszeitstempel:    4d90d339
    Fehlermodulname:    Photoshop3DEngine.8BI
    Fehlermodulversion:    12.1.0.0
    Fehlermodulzeitstempel:    4d90d6b9
    Ausnahmecode:    c0000005
    Ausnahmeoffset:    00000000000c6b80
    Betriebsystemversion:    6.0.6002.2.2.0.256.6
    Gebietsschema-ID:    3079
    Zusatzinformation 1:    116b
    Zusatzinformation 2:    917f5288b8c1ef2c5072afa809e0734b
    Zusatzinformation 3:    3aed
    Zusatzinformation 4:    8d77fb9353dcc6d39eaaa17594d2720b
    Model: Dell Latitude D830
    System: MS Windows Vista x64 Business
    Processor: Intel Core 2 Duo T7800 @ 2,6 GHz ea.
    RAM: 4GB
    HDD: 160GB Intel SSD (INTEL_SSDSA2M160G2GC)
    No overclocking or any other system tricks or tweaks.
    Only payed licensed and trusted opensource / freeware programs installed.
    Adobe Photoshop CS5.1 x64 installed as part of the CS5.5 Web-Premium.
    The Problem:
    Ok, so in Google SketchUp (8.0.4811, free edition) I have prepared a 3D model of 6 simple boxes in different sizes, as well as an underlying plane.
    Each face of the model has it's own unique texture already set up in SketchUp.
    Using the export functionality included in the base install of SketchUp I exported the model in the formats dae and kmz.
    Importing the model in PS5.1x64 works fine, as well as positioning etc.
    Once I select a certain face to have its diffusion-texture replaced, the program crashes with the above error. This only happens on some faces, not all of them.
    If I double click on the specific texture using the layer module, it opens it fine. The original texture loads fine too. Once updated, the program crashes. Also if selected using the 3D module, the program crashes.
    I have tried:
    * importing the model into different types of clean empty documents
    * importing dae instead of kmz
    * apllying .png instead of .psd textures
    * setting performance options higher
    * toggling to several different types of combinations for the 3D-view
    Have not tried yet, but will do so and keep this post updated:
    * redo the model in SketchUp
    * redo the model using Blender (if above does not work)
    Hope to have helped you fix the bug. Couldnt find a decent section ("free support" :/) elsewhere to post this.
    best regards, -david c.

    @ Mylenium - Thank you for the tip/info!
    @ Chris - Have sent you the file causing the problems.
    So far I have redone the whole model using SketchUp again. I created each box in a separate file, following the exact same steps and not doing a single click too much, like defining or applying textures twice.
    Imported all boxes into a fresh SketchUp file, positioned them the way i wanted, and then exploded all compounds (boxes).
    For now I have not had any troubles after importing this into Phothoshop.
    Will keep you updated if this changes.
    Thanks for the quick support guys! Hope my file helps w/ ironing out bugs and / or importing procedures.
    best regards, -davic c.

  • Photoshop CS6 Extended Load/Replace Texture Command Issues

    In the 3d Materials Panel in Adobe Photoshop Extended CS6, the REPLACE TEXTURE and LOAD TEXTURE commands for the 3d materials seem to create a single  "smart" texture that all other textures created via the "replace/load texture" commands link to.
    For instance, to texture a sphere using a Photoshop file, I first created a file called "horizontal stripes for 3d peel.psd" and saved it on my desktop.
    I went to the Materials Panel>Diffuse>(Clicked icon to right of "Diffuse") and chose "Load Texture>"horizontal stripes for 3d peel.psd," to apply it to my sphere.  I then edited this diffuse file by right-clicking the icon to the right of "Diffuse," choosing "Edit" and adding a color layer at the top of the layer stack, then saving (not saving as) and closing the Diffuse .PSB smart object  file.
    I then loaded a texture to the Opacity material of my sphere using the same Photoshop file on my desktop called "horizontal stripes for 3d peel.psd",
    going to Materials Panel>Opacity>(Clicking the  icon to the right of "Opacity") and choosing "Load Texture>"horizontal stripes for 3d peel.psd,"  When I opened this file to edit it by right-clicking the icon to right of "Opacity" and choosing "Edit," I found I'd loaded not the original file on my desktop that I had chosen, but my edited "Diffuse" file. Furthermore, these Diffuse and Opacity files appear not to be independently editable--they behave like linked Smart Objects, and when one is edited, the other is updated with the changes.
    Is this a bug? I can't find any mention of this behavior in the Photoshop User Manual. I'm using Windows 7, and I get the same behavior on 2 different computers with Photoshop.
    http://helpx.adobe.com/photoshop/using/3d-panel-settings-photoshop-extended.html
    I had hoped to use the Load/Replace texture command as a quick way to load up independently editable versions of the same file to the different 3d material attributes (opacity, shine, etc.), but that doesn't seem possible.   Or is there a better way to do this?
    Thanks!
    Jeff Combs

    Postscript:
    I just started working with Extruded 3d shapes, and 3d text, and, as it turns out, this is actually a dandy feature, since these 3d objects each contain multiple elements to apply textures to (ex. Front Inflation Material, Front Bevel Material, Extrusion Material, etc.) that would be pain to edit individually, rather than via a single Smart Layer, especially if you plan to use the same materials for each.
    So, anyway, onwards to more adventures as I climb the Photoshop 3d learning curve. I've been a wee-bit frustrated that this learning curve seems to be more difficult because the Adobe Photoshop_CS6 reference PDF file seems to reference mostly CS5 and, more often than not, references CS5 interfaces. For instance, in the CS6 manual—the sections on 3d concepts and Tools, 3d Panel Settings, 3D rendering and saving—to name a few—all explicitly refer to Photoshop CS5 Extended! So, if anyone knows of a detailed source of CS6 information, I’d be grateful.

  • Live Type textures and Objects not working

    Everything had been working. Moved to a new home...so I had to take editing suite apart. Now when I open LiveType there seems to be a red render bar...and when i try to apply textures and objects to a new track...you see it in the canvas as a small black line. And you get nothing if you try to render the movie. though the font seems to be working
    please help

    Look in this discussion: http://discussions.apple.com/thread.jspa?threadID=1392289&tstart=0
    To nutshell it, use an app called "Pacifist" to revert your ProApps to 4.0 from 4.5 and Quicktime from 7.4 back to 7.3. You can find links to all that in the other discussion. I found my liveType dead this morning and the culprit appears to be the combination of the ProApp update and the Quicktime update. I used Pacifist to revert and it was simple and fairly painless. Install Pacifist, drop the "old" update's .pkg onto the Pacifist icon in your Application folder and rock on.

  • IPhone: OpenGL ES Texturing

    I just began writing an iPhone game and I'm having difficulties displaying multiple textures.
    Only the last texture I generate is appearing and all the textures I generated previously appear white.
    Here is major rendering functions so far, is there anything that stands out as incorrect?
    //Generates textures for a game object
    - (void)GenerateTextures:(Hairball::Objects)Obj
    CGImageRef spriteImage;
    CGContextRef spriteContext;
    GLubyte *spriteData;
    size_t width, height;
    GLuint *tempTex;
    // Creates a Core Graphics image from an image file
    switch (Obj)
    case Hairball::PLAYER:
    spriteImage = [UIImage imageNamed:@"Sprite.png"].CGImage;
    tempTex = &(TextureArray[0]);
    break;
    case Hairball::BACKGROUND:
    spriteImage = [UIImage imageNamed:@"BG1.png"].CGImage;
    tempTex = &(TextureArray[1]);
    break;
    case Hairball::HUD:
    spriteImage = [UIImage imageNamed:@"Icon.png"].CGImage;
    tempTex = &(TextureArray[2]);
    break;
    default:
    break;
    // Get the width and height of the image
    width = CGImageGetWidth(spriteImage);
    height = CGImageGetHeight(spriteImage);
    if(spriteImage)
    // Allocated memory needed for the bitmap context
    spriteData = (GLubyte *) malloc(width * height * 4);
    // Uses the bitmatp creation function provided by the Core Graphics framework.
    spriteContext = CGBitmapContextCreate(spriteData, width, height, 8, width * 4, CGImageGetColorSpace(spriteImage), kCGImageAlphaPremultipliedLast);
    // After you create the context, you can draw the sprite image to the context.
    CGContextDrawImage(spriteContext, CGRectMake(0.0, 0.0, (CGFloat)width, (CGFloat)height), spriteImage);
    // You don't need the context at this point, so you need to release it to avoid memory leaks.
    CGContextRelease(spriteContext);
    // Use OpenGL ES to generate a name for the texture.
    glGenTextures(1, tempTex);
    // Bind the texture name.
    glBindTexture(GLTEXTURE2D, *tempTex);
    // Speidfy a 2D texture image, provideing the a pointer to the image data in memory
    glTexImage2D(GLTEXTURE2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GLUNSIGNEDBYTE, spriteData);
    // Release the image data
    free(spriteData);
    //Inits OpenGl for drawing
    - (void)setupView
    //Creates object Manager to handle
    ObjectMgr = new ObjectManager();
    //Create Objects
    GameObject* Object1 = new GameObject(Hairball::BACKGROUND, 0.0f, 0.0f, 0.0f, 0.0f, 3.2f, 3.2f);
    ObjectMgr->AddToList(Object1);
    GameObject* Object2 = new GameObject(Hairball::PLAYER, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f);
    ObjectMgr->AddToList(Object2);
    //Generate all textures
    [self GenerateTextures:Hairball::PLAYER];
    [self GenerateTextures:Hairball::BACKGROUND];
    //For each obj assign a texture
    std::list<GameObject*>::iterator Object = (ObjectMgr->mObjectList.begin());
    std::list<GameObject*>::iterator End = (ObjectMgr->mObjectList.end());
    //For each game object
    while(Object != End)
    //Apply texture to each object
    switch ((*Object)->mObjectType)
    case Hairball::PLAYER: (*Object)->mSpriteTexture = TextureArray[0]; break;
    case Hairball::BACKGROUND: (*Object)->mSpriteTexture = TextureArray[1]; break;
    case Hairball::HUD: (*Object)->mSpriteTexture = TextureArray[2]; break;
    default:
    break;
    ++Object;
    // Clears the view with grey
    glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
    // Set the texture parameters to use a minifying filter and a linear filer (weighted average)
    glTexParameteri(GLTEXTURE2D, GLTEXTURE_MINFILTER, GL_LINEAR);
    // Enable use of the texture
    glEnable(GLTEXTURE2D);
    // Set a blending function to use
    glBlendFunc(GL_ONE, GLONE_MINUS_SRCALPHA);
    // Enable blending
    glEnable(GL_BLEND);
    - (void)drawView
    [EAGLContext setCurrentContext:context];
    glBindFramebufferOES(GLFRAMEBUFFEROES, viewFramebuffer);
    glViewport(0, 0, backingWidth, backingHeight);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrthof(-1.0f, 1.0f, -1.5f, 1.5f, -1.0f, 1.0f);
    glMatrixMode(GL_MODELVIEW);
    //Clear the backbuffer
    glClear(GLCOLOR_BUFFERBIT);
    std::list<GameObject*>::iterator Object = (ObjectMgr->mObjectList.begin());
    std::list<GameObject*>::iterator End = (ObjectMgr->mObjectList.end());
    //For each game object
    while(Object != End)
    // Bind the texture name.
    glBindTexture(GLTEXTURE2D, (*Object)->mSpriteTexture);
    //apply transformations
    glPushMatrix();
    glTranslatef((*Object)->mPosition.x, (*Object)->mPosition.y, (*Object)->mPosition.z);
    glRotatef((*Object)->mRotation, 0.0f, 0.0f, 1.0f);
    (*Object)->mRotation += 0.5f; //Rotate
    //Get current sprites verticies
    glVertexPointer(2, GL_FLOAT, 0, (*Object)->mSpriteVertices);
    glEnableClientState(GLVERTEXARRAY);
    //Get current sprites tex coords
    glTexCoordPointer(2, GL_SHORT, 0, (*Object)->mSpriteTexcoords);
    glEnableClientState(GLTEXTURE_COORDARRAY);
    //Render the vertex array
    glDrawArrays(GLTRIANGLESTRIP, 0, 4);
    //pop the transformation matrix
    glPopMatrix();
    ++Object;
    glBindRenderbufferOES(GLRENDERBUFFEROES, viewRenderbuffer);
    [context presentRenderbuffer:GLRENDERBUFFEROES];
    }

    The value generated by glGenTextures() in (*Object)->mSpriteTexture for the BACKGROUND object is 1 and for the sprite object it is 2. Which appear to be correct values?
    If I exchange:
    self GenerateTextures:Hairball::PLAYER;
    self GenerateTextures:Hairball::BACKGROUND;
    To
    self GenerateTextures:Hairball::BACKGROUND;
    self GenerateTextures:Hairball::PLAYER;
    then my scene goes from this:
    http://img207.imageshack.us/img207/8229/picture1nf6.png
    to this:
    http://img253.imageshack.us/img253/5282/picture2gr8.png
    So both textures draw, just not at the same time?
    Oh, here it is formatted better:
    //Generates textures for a game object
    - (void)GenerateTextures:(Hairball::Objects)Obj
    CGImageRef spriteImage;
    CGContextRef spriteContext;
    GLubyte *spriteData;
    size_t width, height;
    int texIndex = 0;
    // Creates a Core Graphics image from an image file
    switch (Obj)
    case Hairball::PLAYER:
    spriteImage = [UIImage imageNamed:@"Sprite.png"].CGImage;
    texIndex = 0;
    break;
    case Hairball::BACKGROUND:
    spriteImage = [UIImage imageNamed:@"BG1.png"].CGImage;
    texIndex = 1;
    break;
    case Hairball::HUD:
    spriteImage = [UIImage imageNamed:@"Icon.png"].CGImage;
    texIndex = 2;
    break;
    default:
    break;
    // Get the width and height of the image
    width = CGImageGetWidth(spriteImage);
    height = CGImageGetHeight(spriteImage);
    if(spriteImage)
    // Allocated memory needed for the bitmap context
    spriteData = (GLubyte *) malloc(width * height * 4);
    // Uses the bitmatp creation function provided by the Core Graphics framework.
    spriteContext = CGBitmapContextCreate(spriteData, width, height, 8, width * 4, CGImageGetColorSpace(spriteImage), kCGImageAlphaPremultipliedLast);
    // After you create the context, you can draw the sprite image to the context.
    CGContextDrawImage(spriteContext, CGRectMake(0.0, 0.0, (CGFloat)width, (CGFloat)height), spriteImage);
    // You don't need the context at this point, so you need to release it to avoid memory leaks.
    CGContextRelease(spriteContext);
    // Bind the texture name.
    glBindTexture(GLTEXTURE2D, TextureArray[texIndex]);
    // Speidfy a 2D texture image, provideing the a pointer to the image data in memory
    glTexImage2D(GLTEXTURE2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GLUNSIGNEDBYTE, spriteData);
    // Release the image data
    free(spriteData);
    //Inits OpenGl for drawing
    - (void)setupView
    //Creates object Manager to handle
    ObjectMgr = new ObjectManager();
    //Create Objects
    GameObject* Object1 = new GameObject(Hairball::BACKGROUND, 0.0f, 0.0f, 0.0f, 0.0f, 3.2f, 3.2f);
    ObjectMgr->AddToList(Object1);
    GameObject* Object2 = new GameObject(Hairball::PLAYER, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f);
    ObjectMgr->AddToList(Object2);
    //Generate all textures
    glGenTextures(NUMTEXTURES, TextureArray); // Use OpenGL ES to generate a name for the texture.
    [self GenerateTextures:Hairball::BACKGROUND];
    [self GenerateTextures:Hairball::PLAYER];
    //For each obj assign a texture
    std::list<GameObject*>::iterator Object = (ObjectMgr->mObjectList.begin());
    std::list<GameObject*>::iterator End = (ObjectMgr->mObjectList.end());
    //For each game object
    while(Object != End)
    //Apply texture to each object
    switch ((*Object)->mObjectType)
    case Hairball::PLAYER: (*Object)->mSpriteTexture = TextureArray[0]; break;
    case Hairball::BACKGROUND: (*Object)->mSpriteTexture = TextureArray[1]; break;
    case Hairball::HUD: (*Object)->mSpriteTexture = TextureArray[2]; break;
    default:
    break;
    ++Object;
    // Clears the view with grey
    glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
    // Set the texture parameters to use a minifying filter and a linear filer (weighted average)
    glTexParameteri(GLTEXTURE2D, GLTEXTURE_MINFILTER, GL_LINEAR);
    // Enable use of the texture
    glEnable(GLTEXTURE2D);
    // Set a blending function to use
    glBlendFunc(GL_ONE, GLONE_MINUS_SRCALPHA);
    // Enable blending
    glEnable(GL_BLEND);
    - (void)drawView
    [EAGLContext setCurrentContext:context];
    glBindFramebufferOES(GLFRAMEBUFFEROES, viewFramebuffer);
    glViewport(0, 0, backingWidth, backingHeight);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrthof(-1.0f, 1.0f, -1.5f, 1.5f, -1.0f, 1.0f);
    glMatrixMode(GL_MODELVIEW);
    //Clear the backbuffer
    glClear(GLCOLOR_BUFFERBIT);
    std::list<GameObject*>::iterator Object = (ObjectMgr->mObjectList.begin());
    std::list<GameObject*>::iterator End = (ObjectMgr->mObjectList.end());
    //For each game object
    while(Object != End)
    // Bind the texture name.
    glBindTexture(GLTEXTURE2D, (*Object)->mSpriteTexture);
    //apply transformations
    glPushMatrix();
    glTranslatef((*Object)->mPosition.x, (*Object)->mPosition.y, (*Object)->mPosition.z);
    glRotatef((*Object)->mRotation, 0.0f, 0.0f, 1.0f);
    //(*Object)->mRotation += 0.5f; //Rotate
    //Get current sprites verticies
    glVertexPointer(2, GL_FLOAT, 0, (*Object)->mSpriteVertices);
    glEnableClientState(GLVERTEXARRAY);
    //Get current sprites tex coords
    glTexCoordPointer(2, GL_SHORT, 0, (*Object)->mSpriteTexcoords);
    glEnableClientState(GLTEXTURE_COORDARRAY);
    //Render the vertex array
    glDrawArrays(GLTRIANGLESTRIP, 0, 4);
    //pop the transformation matrix
    glPopMatrix();
    ++Object;
    glBindRenderbufferOES(GLRENDERBUFFEROES, viewRenderbuffer);
    [context presentRenderbuffer:GLRENDERBUFFEROES];

  • How can you combine 2 shapes while preserving individual colors?

    I want to be able to apply vector textures [for t-shirts for example] by knocking the texture shape out of the original shape. Now, say I have a logo with several layers, or a bunch of shapes together, and I want to apply ONE texture across the entire thing (as a knockout). What is the best way to go about this.
    And as my question asks, how can I combine two objects into one shape without making them one color? Using the pathfinder of course. Aka, while still maintaining individual colors. Thanks!

    I don't have a specific project in mind, but I can mock one up. Okay, so in this example I have a "logo" that has text (in outlines), a gradient, and another shape (it's not a stroke) behind everything. And on the side you can see my texture. Normally, using the "minus front" feature, you can knock the texture out of the shape. But that doesn't work for a complicated combination of shapes (even if it's grouped).
    Solutions for this?
    I should start a whole post about every possible way to apply textures in Illustrator. Because I know a few different ways, but they all seem to have problems....

  • How do I remove the grid map over an object when working in 3D?

    I am working through Adobe's Photoshop CS6 Classroom in a Book, Section 12 - Working with 3D Images.
    So far I have found it all fairly straight forward and very useful.
    I am at a point where I am applying textures and materials to my objects, however I cannot seem to find out how to remove the grid that has mapped itself over the objects. I have included a image to illustrate.
    Can anyone help?
    What is the command that will hide these grid maps?!
    Thanks so much in advance.

    I went into YouTube as well, and indeed: It didn't remove the white background.
    Then I went into Photoshop and was surprised: It was able to remove the white background by just playing around with the Magic Wand Tool. I also went into other programmes similar to Photoshop and was excited that there were connatural ways to remove the white background. Finally, I went into Illustrator and observed that the clipping path route worked. Even in CS6.
    Not sure why it didn't work for you.

  • How do I make Flash use the original Photoshop file, not a .png one?

    Hi, this might be kind of a basic question/problem but I can't seem get Google to help me. Since I've recently started out with Flash, I guess I just missed some newbie thing out, still very greatful for help though, since this'll soon be causing a brain hemorrage...
    Ok, here goes: 
    I'd like to draw key frames in Flash, just simple drawings/skelettons using the pen tool, basically to create the movement itself. After that, I want to export the frames that I drew as images to Photoshop in order to apply texture and colour, and then put them back into Flash again, without tampering with the Flash doc I've already created, since the animation is already done. I want the file(s) that I'm working with to remain the same files throughout the process, from Flash to Photoshop and back to Flash again, like the way InDesign works. Is this even possible?
    If this isn't possible at all, I guess the alternative is to draw in Photoshop and then import the drawings into Flash, put them in order and then make any eventual changes after you've created the animation in Flash, this is less smooth though still possible. But here emerges (sort of) the same problem:
    When I import images from Photoshop, create animation out of them, and then realize I have to make some changes in the original PS pic file I head back to PS to correct it. But it just doesn't work the way I want it to... If I modify the pic file in PS, then use the "update" alternative in Flash Library, Flash just tells me that the file can't be found, and does not update the image. If I choose the "edit in PS"-alternative from right clicking on a symbol that is in the library, the file opens as a .png file in PS, not as my original file! It seems to me that Flash is creating its own library, not using the existing document. Is there anyway to go around this? How do I make Flash use my PS file which allows me to change it as much as I want (as with InDesign)?
    This is driving me crazy, what I'm working on is supposed to be full HD, I can't use a freaking .png file... Gah!
    Very many Thanks in advance!
    (If anyone has any suggestion for alternative software, that's also very welcome!)

    If you start the artwork in Flash, you are starting with a vector drawing. If you export this art as a .png so that you can edit it in Photoshop, you will be translating the artwork to a bitmap image at a specific resolution. When you edit this .png in Photoshop, you can save it, as a .png, and then import that .png into Flash.
    After you import the .png, place it on the stage in a new layer. Position the new artwork over the old artwork. Then throw away the original artwork. Now, when you want to edit the artwork, go to the original file in the movie's Library and select Edit with Photoshop. When you save the file in Photoshop, the updated file will appear in the Flash movie.
    If you have Illustrator, you can export your original artwork as an Illustrator file. Then you can open this file in Illustrator, edit it, and save it. Then, as above, import the .ai file into Flash and toss out the original. Now you can edit the original file through the Library in your Flash movie.
    Alternately, you could start by creating the artwork in either Photoshop or Illustrator. Then import that art into Flash. Now you have a link to the editor for either file in your Library. This may simplify things.
    Working with Photoshop and/or .png files will give you a larger finished file than working with Illustrator files. In either case the finished resolution of the Flash movie will be the computer's screen resolution, 72 ppi.

  • Is it possible to insert numerical indicators in 3D picture

    Hello,
    Let's say I have a *.wrl file which contains a room drawing.  Take into account that I know how manipulate the SceneObject and display it into 3D picture.  Is it possible to position different temperature indicators (numerical indicators) in the 3D Picture indicator, so that when I move around the room in the 3D picture the indicators follow there respective position (while updating their values) ?
    Thanks,
    Michel
    Solved!
    Go to Solution.

    A trick that I know is to get the image of the control you want and apply texture to a plane. I did this below:
    In short what I did is:
    1. Create a room using a box. Make it transparent and blend with other objects
    2. Create a plane (a box with y = 0.001) and apply texture to it. The texture is the image of the control (the temperature control)
    3. Do the scene and change the image (texture) as the value changes
    4. close references.
    Here is the code as a reference (using LV 2013). Does that work for you?
    Barp - Control and Simulation Group - LabVIEW R&D - National Instruments
    Attachments:
    Thermometer.vi ‏34 KB

  • Background image help

    I haven't used fireworks in a long while, and I can't figure
    out how to set an image as my background.
    Any help out there would be appreciated.
    Thanks
    Acromedian

    Ah. Sure...the term in Fireworks is texture. Search your
    Fireworks help file for "texture." There should be an entry on
    adding a custom texture. For CS3, the instructions are
    quote:
    Adding a custom texture
    You can use bitmap files from Fireworks and other
    applications as textures. You can apply textures from files with
    these formats: PNG, GIF, JPEG, BMP, TIFF, and PICT (Macintosh
    only).
    When you add a new texture, its name appears in the Texture
    Name pop-up menu.
    To create a new texture from an external file:
    1. With vector object properties displayed in the Property
    inspector, select Other from either of the Texture Name pop-up
    menus.
    2. Navigate to the bitmap file you want to use as the new
    texture, and click Open.
    The new texture is added to the Texture Name list in
    alphabetical order.
    Help Resource Center
    This
    page on the Web
    To get the menu, you need to have a vector object selected.
    If you don't have one, just make a rectangle and go from there. You
    won't be able to fill your canvas, you'll have to make a vector
    rectangle the size of your canvas to fill, anyway.
    Hope that helps! (Oh...the link goes to the same info, for
    CS3. If you have a different version, you should be able to link
    from there to the same info for your version.)

Maybe you are looking for

  • Apps keep turning cellular data on

    I keep turning off data for most of my apps so that I can only use them on wifi but lately some pass keep turning their cellular data on. I try to turn it off again but they always manage to turn it back on after I leave my settings

  • Error in updating new ipod version 1.2

    I just downloaded the new iTunes 7.1 and now i am trying to update my ipod version to 1.2. So i clicked install and i waited 30-40 minutes and all i saw was the loading green thing going across a bar saying "Updating Ipod" but then it changed and sai

  • US iPhone to be used in the UK

    Hi I have a US iphone which I plan to cancel with AT&T and then hopefully use in the UK with a new O2 sim card. Would this work? or would I be better off selling my iPhone on ebay first and then purchasing a new phone in the UK?

  • File managing

    How can i "lock" a file to make it impossible to delete, someone said something about going to "get info" tab and go from there but i cant change the settings there is none i can change, the files are in a external hard drive but i want to protect al

  • Need help using iPod as external hard drive

    Hi. Will soon be receiving a new iMac to replace my old Dell PC and had a question about how to get all of the contents of the Dell hard drive onto my new iMac using my 60GB iPod. I am a complete computer novice. 1. How do I do it? 2. The iPod is cur