Importing .dae file on Processing - object

What I am trying to do is export from Blender a .dae file of an animated object and then import this file on processing and use it there. I created a rotating cube, baked action and exported it as .dae file. the problem is when I am importing it on processing the animation doesn't work and I can see only a square.
import ch.dieseite.colladaloader.ColladaLoader;
import ch.dieseite.colladaloader.wrappers.ColladaModel;
ColladaModel model;
void setup() {
size(500,600,P3D);
background(255);
lights();
frameRate(10);
model = ColladaLoader.load("cuberot.dae", this, null);
model.scale(25);
}
void draw() {
translate(width/2,height/2);
model.draw();
}
Can someone explain how this can work?

Related

How can you position a HaxeFlixel canvas in the centre of a chrome window?

At the moment, I'm learning HaxeFlixel, and I can centre the text in the canvas, but i can't position the canvas in the centre of chrome the chrome window. Is there a way to do it and Main.hx?
PlayState.hx :
package;
import flixel.FlxG;
import flixel.FlxState;
import flixel.text.FlxText;
class PlayState extends FlxState
{
override public function create()
{
super.create();
var text = new FlxText(0, 0, 0, "Hello World\n", 64);
text.screenCenter();
add(text);
}
override public function update(elapsed:Float)
{
super.update(elapsed);
enterFullscreen();
}
public function enterFullscreen()
{
if (FlxG.keys.justPressed.ENTER)
{
FlxG.fullscreen = !FlxG.fullscreen;
}
}
}
Main.hx :
package;
import flixel.FlxGame;
import openfl.display.Sprite;
class Main extends Sprite
{
public function new()
{
super();
addChild(new FlxGame(0, 0, PlayState));
}
}
Please help,
Thanks.
When you compile an HaxeFlixel project for the web, there are two parts:
all the Haxe code is converted to Javascript, executing inside a <canvas> HTML object; all the rest of the HTML page is taken from a template, and you need to change that to center your canvas or otherwise add other elements on the side.
The default template that HaxeFlixel uses is inside the Lime project: https://github.com/openfl/lime/blob/develop/templates/html5/template/index.html
You need to copy that file inside your project, for example in assets/index.html; then customize it, for example adding the <center> tag around <div id="content"></div> (the div where your game canvas will be placed):
<center>
<div id="content"></div>
</center>
You can use CSS to center it, too, if you're so inclined. Just be careful touching the lines with :: as those are template directives.
With your new template placed in assets/index.html, add this line inside project.xml:
<template path="assets/index.html" />

Javafx won't play mp3s from a certain album

I have a javafx program that looks a little something like this:
import javafx.scene.media.MediaPlayer;
import javafx.scene.media.MediaView;
import javafx.scene.media.Media;
import java.io.File;
import java.net.URL;
public class MusicPlayer
{
MediaPlayer medplay;
public void start()
{
String songDir = new File("/Users/myusername/Desktop/song.mp3").getAbsolutePath();
Media med = new Media(new File(songDir).toURI().toString());
medplay = new MediaPlayer(med);
medplay.play();
}
public void pause()
{
medplay.pause();
}
public void resume()
{
medplay.play();
}
}
I tested various different mp3s I have all of which are from the same source. They are all 320kbs mp3s as well. When I try any song from Sum 41's album 13 Voices (if that's relevant) it won't play. Also Boston for some reason. I'm not sure why these mp3s won't play as opposed to any other songs I have in mp3. I am using the BlueJ IDE(it's for high school). Is there anyway I can debug what happens start() is called, but no music starts playing? I am open to moving this project into another IDE if anyone knows better how to debug there and it would help them help me.

Spark is creating too many threads when reading ML model

I have a multilabel text classification problem that I tried to resolve using the binary relevance method, by creating one binary classifier per label.
I have to read 10000 models classifier to perform my classification phase, after my training phase, on all my documents, using spark.
But for an unknown reason, it becomes very slow when I try to read more than 1000 models, because spark creates a new thread each time, which progressively slow down the process, and I don't know why.
Here is the minimal code which illustrate my problem.
package entrepot.spark;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.spark.ml.classification.MultilayerPerceptronClassificationModel;
import org.apache.spark.sql.SparkSession;
public class maintest {
public static void main(String[] args) throws FileNotFoundException, IllegalArgumentException, IOException {
try(SparkSession spark = SparkSession.builder().appName("test").getOrCreate()) {
//Listing directories to get the list of labels
Set<String> labels = new HashSet<>();
FileStatus[] filesstatus = FileSystem.get(spark.sparkContext().hadoopConfiguration()).listStatus(new Path("C:\\Users\\*\\Desktop\\model\\"));
for(int i = 0; i < filesstatus.length; i++) {
if(filesstatus[i].isDirectory()) {
labels.add(filesstatus[i].getPath().getName());
}
}
List<MultilayerPerceptronClassificationModel> models = new ArrayList<>();
// Here is the problem
for(String label : labels) {
System.out.println(label);
MultilayerPerceptronClassificationModel model = MultilayerPerceptronClassificationModel.load("C:\\Users\\*\\Desktop\\model\\" + label + "\\CL\\");
models.add(model);
}
System.out.println("done");
}
}
}
I'm running the program on Windows, with Spark 2.1.1 and Hadoop 2.7.3, using the following command line:
.\bin\spark-submit^
--class entrepot.spark.maintest^
--master local[*]^
/C:/Users/*/eclipse-workspace/spark/target/spark-0.0.1-SNAPSHOT.jar
To download a small repetitive sample of one of my labels model, here is the link : we.tl/T50s9UffYV (Why can't I post a simple link ??)
PS: Even though the models are serializable, I couldn't save and load everything at once using a java collection and an object stream, because I get a scala conversion error. Instead, I'm using the save/load static method from MLLib on each model, resulting in hundreds of thousands of files.

Setting style on a paragraph using ODF toolkit simple-odf.0.8.1

This question has been already asked by another member in octobre 2014, but the incubating simple-odf.0.8.1 does not seem to solve the problem.
I'm trying to generate an ODF text document (*.odt), applying styles to the newly generated paragraphs. When opening the generated document with LibreOffice 5, the newly generated paragraphs appear with the default style and not the wanted one.
Am I doing something wrong or is there an, as yet, not corrected bug ?
import java.io.FileOutputStream;
import org.odftoolkit.odfdom.dom.style.OdfStyleFamily;
import org.odftoolkit.odfdom.incubator.doc.office.OdfOfficeStyles;
import org.odftoolkit.odfdom.incubator.doc.style.OdfStyle;
import org.odftoolkit.simple.TextDocument;
import org.odftoolkit.simple.text.Paragraph;
public class Test {
public static void main(String[] args) {
try {
// Loading template document with styles
TextDocument doc = (TextDocument)TextDocument.loadDocument("Template.odt");
// Checking if "MyStyle" is included
OdfOfficeStyles styles = doc.getOrCreateDocumentStyles();
for (OdfStyle e : styles.getStylesForFamily(OdfStyleFamily.Paragraph)) {
System.out.println(e.getStyleNameAttribute());
}
// Adding a styled paragraph, first way
Paragraph paragraph = doc.addParagraph("Text before setting style");
paragraph.setStyleName("MyStyle");
// adding a styled paragraph, other way just to be sure
paragraph = doc.addParagraph("");
paragraph.setStyleName("MyStyle");
paragraph.setTextContent("Text after setting style");
// Saving the result
doc.save(new FileOutputStream("Result.odt"));
System.out.println("saved");
} catch (Exception ex) {
System.err.println("ex=" + ex.getMessage());
}
}
}

Actor position is incorrect - Libgdx

Please help me, I'm pulling my hair out.
I have a class called "HudBarView" which extends the Group class(scene2d). It takes care of the drawing of the HUD Bar at the top of the screen(Pause button, score, etc).
Another class I have is "HUDManager" which takes care of all the HUD work in the game, including HUD Bar.
These two classes are very short and self-explantory. There is nothing sophisticated.
Now, currently I have only a pause button(ImageButton) in my HUD Bar but the problem is - it is visible only after I resize or pause and then resume the screen.
Here is a gif that describes my problem:
http://i.gyazo.com/6140c4ac1ea0778e4e1afce161ea3dc0.gif
I have tried to play a little bit with the code and I found out that the positioning of the actor is wrong. For instance if I define the position of the button with these values:
Vector2 position = new Vector2(Values.SCREEN_WIDTH-Values.Pause_Width*2,Values.SCREEN_HEIGHT-Values.Pause_Height*2);
Instead of these:
Vector2 position = new Vector2(Values.SCREEN_WIDTH-Values.Pause_Width,Values.SCREEN_HEIGHT-Values.Pause_Height);
It does show up on the screen but at the wrong position and after pause/resume it show up at the correct position.
Here is my HudBarView class:
package views.hud.views;
import views.renderers.HUDManager;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import engine.helpers.AssetsManager;
import engine.helpers.Values;
public class HUDBarView extends Group{
private ImageButton pause;
private HUDManager hud_manager;
private Skin skin;
public HUDBarView(HUDManager hud_manager) {
this.hud_manager = hud_manager;
initiate();
}
private void initiate() {
skin = new Skin(AssetsManager.getAsset(Values.BUTTONS_PACK, TextureAtlas.class));
pause = new ImageButton(skin.getDrawable("pause"));
pause.setSize(Values.Pause_Width, Values.Pause_Height);
pause.setPosition(Values.SCREEN_WIDTH - pause.getWidth(), Values.SCREEN_HEIGHT- pause.getHeight());
addActor(pause);
}
}
HUDManager class:
package views.renderers;
import views.hud.ParticleEffectsActor;
import views.hud.views.HUDBarView;
import aurelienribon.tweenengine.TweenManager;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import engine.helpers.AssetsManager;
import engine.helpers.UIHelper;
import engine.helpers.Values;
public class HUDManager extends Group {
private Stage stage;
private Skin skin;
private Image text;
private HUDBarView hudView;
public HUDManager(Stage stage) {
this.stage = stage;
initiate();
addActor(hudView);
addActor(particles);
}
public void initiate() {
skin = AssetsManager.getAsset(Values.GAME_SKIN_PACK, Skin.class);
hudView = new HUDBarView(this);
particles = new ParticleEffectsActor();
}
public Stage getStage() {
return stage;
}
}
And Here is my game screen problem:
package views.screens;
import views.renderers.GameRenderer;
import views.renderers.HUDManager;
import engine.GameInputHandler;
import engine.GameWorld;
import engine.Values;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputMultiplexer;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.utils.viewport.StretchViewport;
/* Created by David Lasry : 10/25/14 */
public class GameScreen extends ScreenWrapper {
private GameWorld world;
private HUDManager hudManager;
private GameRenderer renderer;
private Stage stage;
public GameScreen() {
super();
ScreenHandler.getInstance().getGame().getAssetsManager()
.loadAsstes(2, this);
world = new GameWorld();
stage = new Stage(new StretchViewport(Values.SCREEN_WIDTH,
Values.SCREEN_HEIGHT));
camera = (OrthographicCamera) stage.getCamera();
InputMultiplexer inputs = new InputMultiplexer();
inputs.addProcessor(stage);
inputs.addProcessor(new GameInputHandler(world.getMonkeyManager(),
camera));
Gdx.input.setInputProcessor(inputs);
}
#Override
public void render(float delta) {
switch (state) {
case RUN:
stage.act(delta);
stage.draw();
world.update(delta);
break;
case PAUSE:
break;
}
}
// Callback method that is called when the assets are loaded
#Override
public void assetsLoaded() {
super.assetsLoaded();
renderer = new GameRenderer(world);
hudManager = new HUDManager();
stage.addActor(renderer);
stage.addActor(hudManager);
}
public HUDManager getHudManager() {
return hudManager;
}
#Override
public void dispose() {
stage.dispose();
ScreenHandler.getInstance().getGame().getAssetsManager().unload(2);
}
}
I'm struggling with this problem for almost 3 days and I have no idea what is causing this.
I even opened a new project, duplicated the relevant classes and just tried to position the button at the top right corner of the screen and it worked! So why it doesn't work in my actual game?
Please help !

Resources